Commit e3750c97 authored by Ilkka Ollakka's avatar Ilkka Ollakka

opengl: check GL_UNPACK_ROW_LENGTH instead of OPENGL_ES

This way we don't need to define dummy GL_UNPACK_ROW_LENGHT for opengl es
compiles.
parent cccbf365
...@@ -62,7 +62,6 @@ ...@@ -62,7 +62,6 @@
# define PFNGLDELETEPROGRAMPROC typeof(glDeleteProgram)* # define PFNGLDELETEPROGRAMPROC typeof(glDeleteProgram)*
# define PFNGLATTACHSHADERPROC typeof(glAttachShader)* # define PFNGLATTACHSHADERPROC typeof(glAttachShader)*
#if USE_OPENGL_ES #if USE_OPENGL_ES
# define GL_UNPACK_ROW_LENGTH 0
# import <CoreFoundation/CoreFoundation.h> # import <CoreFoundation/CoreFoundation.h>
#endif #endif
#endif #endif
...@@ -659,11 +658,10 @@ int vout_display_opengl_Prepare(vout_display_opengl_t *vgl, ...@@ -659,11 +658,10 @@ int vout_display_opengl_Prepare(vout_display_opengl_t *vgl,
glClientActiveTexture(GL_TEXTURE0 + j); glClientActiveTexture(GL_TEXTURE0 + j);
} }
glBindTexture(vgl->tex_target, vgl->texture[0][j]); glBindTexture(vgl->tex_target, vgl->texture[0][j]);
glPixelStorei(GL_UNPACK_ROW_LENGTH, picture->p[j].i_pitch / picture->p[j].i_pixel_pitch);
#if USE_OPENGL_ES
if ( (picture->p[j].i_pitch / picture->p[j].i_pixel_pitch) != (vgl->fmt.i_width * vgl->chroma->p[j].w.num / vgl->chroma->p[j].w.den) ) { if ( (picture->p[j].i_pitch / picture->p[j].i_pixel_pitch) != (vgl->fmt.i_width * vgl->chroma->p[j].w.num / vgl->chroma->p[j].w.den) ) {
uint8_t *new_plane = malloc(picture->p[j].i_pitch*picture->p[j].i_pixel_pitch *vgl->fmt.i_height * vgl->chroma->p[j].h.num / vgl->chroma->p[j].h.den); uint8_t *new_plane = malloc(picture->p[j].i_pitch*picture->p[j].i_pixel_pitch *vgl->fmt.i_height * vgl->chroma->p[j].h.num / vgl->chroma->p[j].h.den);
#ifndef GL_UNPACK_ROW_LENGTH
uint8_t *destination = new_plane; uint8_t *destination = new_plane;
const uint8_t *source = picture->p[j].p_pixels; const uint8_t *source = picture->p[j].p_pixels;
for( unsigned height = 0; height < vgl->fmt.i_height * vgl->chroma->p[j].h.num / vgl->chroma->p[j].h.den; height++ ) for( unsigned height = 0; height < vgl->fmt.i_height * vgl->chroma->p[j].h.num / vgl->chroma->p[j].h.den; height++ )
...@@ -679,13 +677,15 @@ int vout_display_opengl_Prepare(vout_display_opengl_t *vgl, ...@@ -679,13 +677,15 @@ int vout_display_opengl_Prepare(vout_display_opengl_t *vgl,
vgl->tex_format, vgl->tex_type, new_plane ); vgl->tex_format, vgl->tex_type, new_plane );
free( new_plane ); free( new_plane );
} else { } else {
#else
glPixelStorei(GL_UNPACK_ROW_LENGTH, picture->p[j].i_pitch / picture->p[j].i_pixel_pitch);
#endif #endif
glTexSubImage2D(vgl->tex_target, 0, glTexSubImage2D(vgl->tex_target, 0,
0, 0, 0, 0,
vgl->fmt.i_width * vgl->chroma->p[j].w.num / vgl->chroma->p[j].w.den, vgl->fmt.i_width * vgl->chroma->p[j].w.num / vgl->chroma->p[j].w.den,
vgl->fmt.i_height * vgl->chroma->p[j].h.num / vgl->chroma->p[j].h.den, vgl->fmt.i_height * vgl->chroma->p[j].h.num / vgl->chroma->p[j].h.den,
vgl->tex_format, vgl->tex_type, picture->p[j].p_pixels); vgl->tex_format, vgl->tex_type, picture->p[j].p_pixels);
#if USE_OPENGL_ES #ifndef GL_UNPACK_ROW_LENGTH
} }
#endif #endif
} }
...@@ -745,7 +745,9 @@ int vout_display_opengl_Prepare(vout_display_opengl_t *vgl, ...@@ -745,7 +745,9 @@ int vout_display_opengl_Prepare(vout_display_opengl_t *vgl,
if (glr->texture) { if (glr->texture) {
glBindTexture(GL_TEXTURE_2D, glr->texture); glBindTexture(GL_TEXTURE_2D, glr->texture);
/* TODO set GL_UNPACK_ALIGNMENT */ /* TODO set GL_UNPACK_ALIGNMENT */
#ifdef GL_UNPACK_ROW_LENGTH
glPixelStorei(GL_UNPACK_ROW_LENGTH, r->p_picture->p->i_pitch / r->p_picture->p->i_pixel_pitch); glPixelStorei(GL_UNPACK_ROW_LENGTH, r->p_picture->p->i_pitch / r->p_picture->p->i_pixel_pitch);
#endif
glTexSubImage2D(GL_TEXTURE_2D, 0, glTexSubImage2D(GL_TEXTURE_2D, 0,
0, 0, glr->width, glr->height, 0, 0, glr->width, glr->height,
glr->format, glr->type, &r->p_picture->p->p_pixels[pixels_offset]); glr->format, glr->type, &r->p_picture->p->p_pixels[pixels_offset]);
...@@ -761,7 +763,9 @@ int vout_display_opengl_Prepare(vout_display_opengl_t *vgl, ...@@ -761,7 +763,9 @@ int vout_display_opengl_Prepare(vout_display_opengl_t *vgl,
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
/* TODO set GL_UNPACK_ALIGNMENT */ /* TODO set GL_UNPACK_ALIGNMENT */
#ifdef GL_UNPACK_ROW_LENGTH
glPixelStorei(GL_UNPACK_ROW_LENGTH, r->p_picture->p->i_pitch / r->p_picture->p->i_pixel_pitch); glPixelStorei(GL_UNPACK_ROW_LENGTH, r->p_picture->p->i_pitch / r->p_picture->p->i_pixel_pitch);
#endif
glTexImage2D(GL_TEXTURE_2D, 0, glr->format, glTexImage2D(GL_TEXTURE_2D, 0, glr->format,
glr->width, glr->height, 0, glr->format, glr->type, glr->width, glr->height, 0, glr->format, glr->type,
&r->p_picture->p->p_pixels[pixels_offset]); &r->p_picture->p->p_pixels[pixels_offset]);
......
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