Datastream manages its own video shader now

This commit is contained in:
John Alanbrook 2022-06-27 20:16:16 +00:00
parent 9c5767436d
commit f93b49e0d0
2 changed files with 8 additions and 5 deletions

View file

@ -8,6 +8,8 @@
#include <stdbool.h> #include <stdbool.h>
#include "log.h" #include "log.h"
struct mShader *vid_shader;
static void ds_update_texture(uint32_t unit, uint32_t texture, static void ds_update_texture(uint32_t unit, uint32_t texture,
plm_plane_t * plane) plm_plane_t * plane)
{ {
@ -63,11 +65,12 @@ void ds_openvideo(struct datastream *ds, const char *video, const char *adriver)
ds->playing = true; ds->playing = true;
} }
struct datastream *MakeDatastream(struct mShader *shader) struct datastream *MakeDatastream()
{ {
struct datastream *newds = struct datastream *newds = malloc(sizeof(*newds));
(struct datastream *) malloc(sizeof(struct datastream)); if (!vid_shader) vid_shader = MakeShader("videovert.glsl", "videofrag.glsl");
newds->shader = shader;
newds->shader = vid_shader;
shader_use(newds->shader); shader_use(newds->shader);
glGenTextures(1, &newds->texture_y); glGenTextures(1, &newds->texture_y);
glBindTexture(GL_TEXTURE_2D, newds->texture_y); glBindTexture(GL_TEXTURE_2D, newds->texture_y);

View file

@ -15,7 +15,7 @@ struct datastream {
uint32_t texture_cr; uint32_t texture_cr;
}; };
struct datastream *MakeDatastream(struct mShader *shader); struct datastream *MakeDatastream();
void ds_openvideo(struct datastream *ds, const char *path, void ds_openvideo(struct datastream *ds, const char *path,
const char *adriver); const char *adriver);
void ds_advance(struct datastream *ds, uint32_t ms); void ds_advance(struct datastream *ds, uint32_t ms);