summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/gl.c3
-rw-r--r--src/log.c41
-rw-r--r--src/main.c2
3 files changed, 41 insertions, 5 deletions
diff --git a/src/gl.c b/src/gl.c
index 8937d41..d387364 100644
--- a/src/gl.c
+++ b/src/gl.c
@@ -168,12 +168,11 @@ void gl_draw_texture(
texture->swizzle ? GL_BGRA : GL_RGBA,
GL_UNSIGNED_BYTE,
(GLvoid *)texture->buffer);
- glGetError();
texture->redraw = false;
}
glViewport(x, y, width, height);
- glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, 0);
+ glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, NULL);
}
void load_shader(GLuint shader, const char *filename)
diff --git a/src/log.c b/src/log.c
index e80cdfa..f7138c5 100644
--- a/src/log.c
+++ b/src/log.c
@@ -1,7 +1,14 @@
#include <stdarg.h>
+#include <stdint.h>
#include <stdio.h>
#include <time.h>
+#define SECOND 1000000000ul
+
+static struct timespec time_diff(
+ struct timespec cur,
+ struct timespec old);
+
void log_error(const char *const fmt, ...)
{
va_list args;
@@ -25,11 +32,25 @@ void log_debug(const char *const fmt, ...)
#ifndef DEBUG
return;
#endif
- struct timespec t;
- clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &t);
+ static struct timespec start_time;
+ if (start_time.tv_nsec == 0) {
+ fprintf(stderr, "[ real, cpu]\n");
+ clock_gettime(CLOCK_REALTIME, &start_time);
+ }
+ struct timespec real_time;
+ struct timespec cpu_time;
+ clock_gettime(CLOCK_REALTIME, &real_time);
+ clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &cpu_time);
+ real_time = time_diff(real_time, start_time);
va_list args;
va_start(args, fmt);
- fprintf(stderr, "[%ld.%03ld][DEBUG]: ", t.tv_sec, t.tv_nsec / 1000000);
+ fprintf(
+ stderr,
+ "[%ld.%03ld, %ld.%03ld][DEBUG]: ",
+ real_time.tv_sec,
+ real_time.tv_nsec / 1000000,
+ cpu_time.tv_sec,
+ cpu_time.tv_nsec / 1000000);
vfprintf(stderr, fmt, args);
va_end(args);
}
@@ -42,3 +63,17 @@ void log_info(const char *const fmt, ...)
vprintf(fmt, args);
va_end(args);
}
+
+struct timespec time_diff(struct timespec cur,
+ struct timespec old)
+{
+ struct timespec diff;
+ diff.tv_sec = cur.tv_sec - old.tv_sec;
+ if (cur.tv_nsec > old.tv_nsec) {
+ diff.tv_nsec = cur.tv_nsec - old.tv_nsec;
+ } else {
+ diff.tv_nsec = SECOND + cur.tv_nsec - old.tv_nsec;
+ diff.tv_sec -= 1;
+ }
+ return diff;
+}
diff --git a/src/main.c b/src/main.c
index 8c53838..d903c32 100644
--- a/src/main.c
+++ b/src/main.c
@@ -615,6 +615,8 @@ int main(int argc, char *argv[])
.window = {
.background_color = {0.89, 0.8, 0.824, 1.0},
.scale = 1,
+ .width = 640,
+ .height = 480,
.surface = { .width = 640, .height = 480 },
.entry = {
.border = {