Created
June 17, 2013 08:43
-
-
Save roxlu/5795504 to your computer and use it in GitHub Desktop.
GL 3.0, UYVY422 shader using GL_RGB_422_APPLE as internalFormat, GL_UNSIGNED_SHORT_8_8_APPLE as format
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static const char* YUYV_VS = "" | |
"#version 150\n" | |
"uniform mat4 u_pm;" | |
"uniform mat4 u_mm;" | |
"in vec4 a_pos;" | |
"in vec2 a_tex;" | |
"out vec2 v_tex;" | |
"void main() {" | |
" gl_Position = u_pm * u_mm * a_pos; " | |
" v_tex = a_tex;" | |
"}" | |
""; | |
static const char* YUYV_FS = "" | |
"#version 150\n" | |
"uniform sampler2D u_tex;" | |
"out vec4 outcol;" | |
"in vec2 v_tex;" | |
"const vec3 R_cf = vec3(1.164383, 0.000000, 1.596027);" | |
"const vec3 G_cf = vec3(1.164383, -0.391762, -0.812968);" | |
"const vec3 B_cf = vec3(1.164383, 2.017232, 0.000000);" | |
"const vec3 offset = vec3(-0.0625, -0.5, -0.5);" | |
"void main() {" | |
" vec3 tc = texture( u_tex, v_tex ).rgb;" | |
" vec3 yuv = vec3(tc.g, tc.b, tc.r);" | |
" yuv += offset;" | |
" outcol.r = dot(yuv, R_cf);" | |
" outcol.g = dot(yuv, G_cf);" | |
" outcol.b = dot(yuv, B_cf);" | |
" outcol.a = 1.0;" | |
"}" | |
""; |
Hey, I'm having difficulty (as in its 100% broken :P) loading in the texture using the following code:
glGenTextures(1, &texture);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB_422_APPLE, textureWidth, textureHeight, 0, GL_UNSIGNED_SHORT_8_8_APPLE, GL_UNSIGNED_BYTE, imageData);
Any chance someone could give me a hint?
PS: If anyone has good suggestions on where to learn GL ES for iPhone, that would be helpful (yeah I've googled it, results we're mediocre at best).
👍🏻
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Wow! You saved my life, I was about to cry when I recently move my code to core profile and the video stuff didn't work. Thank you so much