Commit 00246f15 authored by Laurent Aimar's avatar Laurent Aimar

Small clean up (opengl)

parent 05a86500
...@@ -461,30 +461,30 @@ vout_display_opengl_t *vout_display_opengl_New(video_format_t *fmt, ...@@ -461,30 +461,30 @@ vout_display_opengl_t *vout_display_opengl_New(video_format_t *fmt,
free(code); free(code);
for (GLuint i = 0; i < 2; i++) { for (GLuint i = 0; i < 2; i++) {
int infoLength = 0; int infoLength = 0;
int charsWritten = 0;
char *infolog;
vgl->GetProgramiv(vgl->program[i], GL_INFO_LOG_LENGTH, &infoLength); vgl->GetProgramiv(vgl->program[i], GL_INFO_LOG_LENGTH, &infoLength);
if (infoLength > 1) { if (infoLength > 1) {
/* If there is some message, better to check linking is ok */ int charsWritten;
GLint link_status = GL_TRUE; char *infolog;
vgl->GetProgramiv(vgl->program[i], GL_LINK_STATUS, &link_status);
infolog = (char *)malloc(infoLength); infolog = malloc(infoLength);
vgl->GetProgramInfoLog(vgl->program[i], infoLength, &charsWritten, infolog); vgl->GetProgramInfoLog(vgl->program[i], infoLength, &charsWritten, infolog);
fprintf(stderr, "shader program %d:%s %d\n",i,infolog,infoLength); fprintf(stderr, "shader program %d: %s\n", i, infolog);
free(infolog); free(infolog);
/* Check shaders messages too */ /* Check shaders messages too */
for (GLuint j = 0; j < 2; j++) { for (GLuint j = 0; j < 2; j++) {
vgl->GetShaderiv(vgl->shader[j], GL_INFO_LOG_LENGTH, &infoLength); vgl->GetShaderiv(vgl->shader[j], GL_INFO_LOG_LENGTH, &infoLength);
if (infoLength > 1) { if (infoLength > 1) {
infolog = (char *)malloc(infoLength); infolog = malloc(infoLength);
vgl->GetShaderInfoLog(vgl->shader[j], infoLength, &charsWritten, infolog); vgl->GetShaderInfoLog(vgl->shader[j], infoLength, &charsWritten, infolog);
fprintf(stderr, "shader %d: %s\n",j, infolog); fprintf(stderr, "shader %d: %s\n", j, infolog);
free(infolog); free(infolog);
} }
} }
/* If there is some message, better to check linking is ok */
GLint link_status = GL_TRUE;
vgl->GetProgramiv(vgl->program[i], GL_LINK_STATUS, &link_status);
if (link_status == GL_FALSE) { if (link_status == GL_FALSE) {
fprintf(stderr, "Unable to use program %d\n", i); fprintf(stderr, "Unable to use program %d\n", i);
free(vgl); free(vgl);
...@@ -555,7 +555,7 @@ picture_pool_t *vout_display_opengl_GetPool(vout_display_opengl_t *vgl, unsigned ...@@ -555,7 +555,7 @@ picture_pool_t *vout_display_opengl_GetPool(vout_display_opengl_t *vgl, unsigned
/* Allocate our pictures */ /* Allocate our pictures */
picture_t *picture[VLCGL_PICTURE_MAX] = {NULL, }; picture_t *picture[VLCGL_PICTURE_MAX] = {NULL, };
unsigned count = 0; unsigned count;
for (count = 0; count < __MIN(VLCGL_PICTURE_MAX, requested_count); count++) { for (count = 0; count < __MIN(VLCGL_PICTURE_MAX, requested_count); count++) {
picture[count] = picture_NewFromFormat(&vgl->fmt); picture[count] = picture_NewFromFormat(&vgl->fmt);
...@@ -751,7 +751,7 @@ static void DrawWithoutShaders(vout_display_opengl_t *vgl, ...@@ -751,7 +751,7 @@ static void DrawWithoutShaders(vout_display_opengl_t *vgl,
1.0f, 1.0f, 1.0f, 1.0f,
}; };
const GLfloat textureCoord[8] = { const GLfloat textureCoord[] = {
left[0], bottom[0], left[0], bottom[0],
right[0], bottom[0], right[0], bottom[0],
left[0], top[0], left[0], top[0],
...@@ -791,7 +791,7 @@ static void DrawWithoutShaders(vout_display_opengl_t *vgl, ...@@ -791,7 +791,7 @@ static void DrawWithoutShaders(vout_display_opengl_t *vgl,
static void DrawWithShaders(vout_display_opengl_t *vgl, static void DrawWithShaders(vout_display_opengl_t *vgl,
float *left, float *top, float *right, float *bottom) float *left, float *top, float *right, float *bottom)
{ {
const GLfloat vertexCoord[] = { static const GLfloat vertexCoord[] = {
-1.0, 1.0, -1.0, 1.0,
-1.0, -1.0, -1.0, -1.0,
1.0, 1.0, 1.0, 1.0,
...@@ -799,8 +799,7 @@ static void DrawWithShaders(vout_display_opengl_t *vgl, ...@@ -799,8 +799,7 @@ static void DrawWithShaders(vout_display_opengl_t *vgl,
}; };
for (unsigned j = 0; j < vgl->chroma->plane_count; j++) { for (unsigned j = 0; j < vgl->chroma->plane_count; j++) {
char *attribute = NULL; const GLfloat textureCoord[] = {
const GLfloat texCoord[] = {
left[j], top[j], left[j], top[j],
left[j], bottom[j], left[j], bottom[j],
right[j], top[j], right[j], top[j],
...@@ -810,13 +809,11 @@ static void DrawWithShaders(vout_display_opengl_t *vgl, ...@@ -810,13 +809,11 @@ static void DrawWithShaders(vout_display_opengl_t *vgl,
glClientActiveTexture(GL_TEXTURE0+j); glClientActiveTexture(GL_TEXTURE0+j);
glEnable(vgl->tex_target); glEnable(vgl->tex_target);
glBindTexture(vgl->tex_target, vgl->texture[0][j]); glBindTexture(vgl->tex_target, vgl->texture[0][j]);
if (asprintf(&attribute, "MultiTexCoord%1d", j) == -1)
return;
char attribute[20];
snprintf(attribute, sizeof(attribute), "MultiTexCoord%1d", j);
vgl->EnableVertexAttribArray(vgl->GetAttribLocation(vgl->program[0], attribute)); vgl->EnableVertexAttribArray(vgl->GetAttribLocation(vgl->program[0], attribute));
vgl->VertexAttribPointer(vgl->GetAttribLocation(vgl->program[0], attribute), 2, GL_FLOAT, 0, 0, texCoord); vgl->VertexAttribPointer(vgl->GetAttribLocation(vgl->program[0], attribute), 2, GL_FLOAT, 0, 0, textureCoord);
free(attribute);
attribute = NULL;
} }
glActiveTexture(GL_TEXTURE0 + 0); glActiveTexture(GL_TEXTURE0 + 0);
glClientActiveTexture(GL_TEXTURE0 + 0); glClientActiveTexture(GL_TEXTURE0 + 0);
...@@ -886,7 +883,7 @@ int vout_display_opengl_Display(vout_display_opengl_t *vgl, ...@@ -886,7 +883,7 @@ int vout_display_opengl_Display(vout_display_opengl_t *vgl,
glr->left, glr->top, glr->left, glr->top,
glr->left, glr->bottom, glr->left, glr->bottom,
glr->right, glr->top, glr->right, glr->top,
glr->right,glr->bottom, glr->right, glr->bottom,
}; };
static const GLfloat textureCoord[] = { static const GLfloat textureCoord[] = {
0.0, 0.0, 0.0, 0.0,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment