From 50a3586d2f41c4a3d8e7af34e2d839b7d1e07859 Mon Sep 17 00:00:00 2001 From: Hoguchi Date: Fri, 3 Feb 2023 10:35:13 -1000 Subject: [PATCH] Some doc and typos --- src/gfx/player.c | 12 ++++-------- src/gfx/renderer.c | 23 +++++++++++++---------- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/src/gfx/player.c b/src/gfx/player.c index 11c4c06..246cc5c 100644 --- a/src/gfx/player.c +++ b/src/gfx/player.c @@ -54,25 +54,21 @@ void player_destroy(struct Player* self) { } -static void *get_proc_address(void *ctx, const char *name) -{ +static void *get_proc_address(void *ctx, const char *name){ glfwGetCurrentContext(); return (void *)(glfwGetProcAddress(name)); } -static void on_mpv_render_update(void *ctx) -{ +static void on_mpv_render_update(void *ctx){ // we set the wakeup flag here to enable the mpv_render_context_render path in the main loop. wakeup = 1; } -static void on_mpv_events(void *ctx) -{ +static void on_mpv_events(void *ctx){ printf("INFO::%s\n",__func__); } -static inline void check_error(int status) -{ +static inline void check_error(int status) { if(status < 0) { printf("MPV API error: %s\n", mpv_error_string(status)); exit(1); diff --git a/src/gfx/renderer.c b/src/gfx/renderer.c index da9ea2d..f732e04 100644 --- a/src/gfx/renderer.c +++ b/src/gfx/renderer.c @@ -41,9 +41,11 @@ void renderer_init(struct Renderer *self) { { .index = 0, .name = "texcoord" } }); + // Set up the specific renderer environments _renderer_mpv(self); _renderer_glyph(self); + // TMP, create bitmaps for the font self->atlas = makeBitmaps(); } @@ -59,7 +61,7 @@ void renderer_destroy(struct Renderer *self) { free(self); } -/* +/* Setting up the glyph renderer (for text) */ void _renderer_glyph(struct Renderer *self) { @@ -73,8 +75,9 @@ void _renderer_glyph(struct Renderer *self) { vao_attr(self->glyphVAO, self->glyphVBO, 0, 4, GL_FLOAT, 4*sizeof(float), 0); } -/* - Setting up the mpv renderer +/** + Setting up the mpv video renderer. + Video is rendered as a texture through a framebuffer. */ void _renderer_mpv(struct Renderer *self) { @@ -89,11 +92,11 @@ void _renderer_mpv(struct Renderer *self) { vao_attr(self->screenVAO, self->screenVBO, 0, 3, GL_FLOAT, 5*sizeof(float), 0); vao_attr(self->screenVAO, self->screenVBO, 1, 2, GL_FLOAT, 5*sizeof(float), (3 * sizeof(float))); - /* Framebuffer for Video */ + /* Framebuffer for video */ glGenFramebuffers(1, &(self->video_framebuffer)); glBindFramebuffer(GL_FRAMEBUFFER, self->video_framebuffer); - /* create a color attachment texture */ + /* Create a color attachment texture */ glGenTextures(1, &(self->video_textureColorbuffer)); glBindTexture(GL_TEXTURE_2D, self->video_textureColorbuffer); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, fbo_width, fbo_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); @@ -111,14 +114,14 @@ void _renderer_mpv(struct Renderer *self) { {MPV_RENDER_PARAM_OPENGL_FBO, &(self->mpv_fbo)}, {MPV_RENDER_PARAM_FLIP_Y, &flip_y}, {MPV_RENDER_PARAM_INVALID, NULL}}, sizeof(mpv_render_param [3])); - } -/* - Render text on the screen using the given Shader +/** + Render text on the screen. + This is pretty rough, it should be called only once to generate the text. + Subsequent frames should make use of transformation matrices to move it around. */ -float render_text(struct Renderer *self, const char* text, uint length, float x, float y, float scale, float color[3]) -{ +float render_text(struct Renderer *self, const char* text, uint length, float x, float y, float scale, float color[3]){ shader_bind(self->shaders[SHADER_GLYPH]); glUniform3f(glGetUniformLocation((self->shaders[SHADER_GLYPH]).handle, "textColor"), color[0], color[1], color[2]); glActiveTexture(GL_TEXTURE0);