Some doc and typos
This commit is contained in:
parent
5ab200bf3d
commit
50a3586d2f
@ -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();
|
glfwGetCurrentContext();
|
||||||
return (void *)(glfwGetProcAddress(name));
|
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.
|
// we set the wakeup flag here to enable the mpv_render_context_render path in the main loop.
|
||||||
wakeup = 1;
|
wakeup = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void on_mpv_events(void *ctx)
|
static void on_mpv_events(void *ctx){
|
||||||
{
|
|
||||||
printf("INFO::%s\n",__func__);
|
printf("INFO::%s\n",__func__);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void check_error(int status)
|
static inline void check_error(int status) {
|
||||||
{
|
|
||||||
if(status < 0) {
|
if(status < 0) {
|
||||||
printf("MPV API error: %s\n", mpv_error_string(status));
|
printf("MPV API error: %s\n", mpv_error_string(status));
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -41,9 +41,11 @@ void renderer_init(struct Renderer *self) {
|
|||||||
{ .index = 0, .name = "texcoord" }
|
{ .index = 0, .name = "texcoord" }
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Set up the specific renderer environments
|
||||||
_renderer_mpv(self);
|
_renderer_mpv(self);
|
||||||
_renderer_glyph(self);
|
_renderer_glyph(self);
|
||||||
|
|
||||||
|
// TMP, create bitmaps for the font
|
||||||
self->atlas = makeBitmaps();
|
self->atlas = makeBitmaps();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,8 +75,9 @@ void _renderer_glyph(struct Renderer *self) {
|
|||||||
vao_attr(self->glyphVAO, self->glyphVBO, 0, 4, GL_FLOAT, 4*sizeof(float), 0);
|
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) {
|
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, 0, 3, GL_FLOAT, 5*sizeof(float), 0);
|
||||||
vao_attr(self->screenVAO, self->screenVBO, 1, 2, GL_FLOAT, 5*sizeof(float), (3 * sizeof(float)));
|
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));
|
glGenFramebuffers(1, &(self->video_framebuffer));
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, self->video_framebuffer);
|
glBindFramebuffer(GL_FRAMEBUFFER, self->video_framebuffer);
|
||||||
|
|
||||||
/* create a color attachment texture */
|
/* Create a color attachment texture */
|
||||||
glGenTextures(1, &(self->video_textureColorbuffer));
|
glGenTextures(1, &(self->video_textureColorbuffer));
|
||||||
glBindTexture(GL_TEXTURE_2D, 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);
|
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_OPENGL_FBO, &(self->mpv_fbo)},
|
||||||
{MPV_RENDER_PARAM_FLIP_Y, &flip_y},
|
{MPV_RENDER_PARAM_FLIP_Y, &flip_y},
|
||||||
{MPV_RENDER_PARAM_INVALID, NULL}}, sizeof(mpv_render_param [3]));
|
{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]);
|
shader_bind(self->shaders[SHADER_GLYPH]);
|
||||||
glUniform3f(glGetUniformLocation((self->shaders[SHADER_GLYPH]).handle, "textColor"), color[0], color[1], color[2]);
|
glUniform3f(glGetUniformLocation((self->shaders[SHADER_GLYPH]).handle, "textColor"), color[0], color[1], color[2]);
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
Reference in New Issue
Block a user