Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libSDL
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PocketInsanity
libSDL
Commits
0f1080b5
Commit
0f1080b5
authored
Feb 09, 2011
by
Sam Lantinga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed compiling on Windows
Added an untested shader for YV12 textures
parent
85a93efa
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
63 additions
and
6 deletions
+63
-6
SDL_VS2008.vcproj
VisualC/SDL/SDL_VS2008.vcproj
+8
-0
SDL_VS2010.vcxproj
VisualC/SDL/SDL_VS2010.vcxproj
+2
-0
SDL_shaders_gl.c
src/render/opengl/SDL_shaders_gl.c
+52
-5
SDL_shaders_gl.h
src/render/opengl/SDL_shaders_gl.h
+1
-1
No files found.
VisualC/SDL/SDL_VS2008.vcproj
View file @
0f1080b5
...
...
@@ -1054,6 +1054,14 @@
RelativePath=
"..\..\src\file\SDL_rwops.c"
>
</File>
<File
RelativePath=
"..\..\src\render\opengl\SDL_shaders_gl.c"
>
</File>
<File
RelativePath=
"..\..\src\render\opengl\SDL_shaders_gl.h"
>
</File>
<File
RelativePath=
"..\..\src\video\SDL_shape.c"
>
...
...
VisualC/SDL/SDL_VS2010.vcxproj
View file @
0f1080b5
...
...
@@ -285,6 +285,7 @@ echo #define SDL_REVISION "hg-0:baadf00d" >"$(ProjectDir)\..\..\include\SDL_r
<ClInclude
Include=
"..\..\src\libm\math.h"
/>
<ClInclude
Include=
"..\..\src\libm\math_private.h"
/>
<ClInclude
Include=
"..\..\src\render\mmx.h"
/>
<ClInclude
Include=
"..\..\src\render\opengl\SDL_shaders_gl.h"
/>
<ClInclude
Include=
"..\..\src\render\SDL_sysrender.h"
/>
<ClInclude
Include=
"..\..\src\render\SDL_yuv_sw_c.h"
/>
<ClInclude
Include=
"..\..\src\audio\SDL_audio_c.h"
/>
...
...
@@ -373,6 +374,7 @@ echo #define SDL_REVISION "hg-0:baadf00d" >"$(ProjectDir)\..\..\include\SDL_r
<ClCompile
Include=
"..\..\src\libm\s_sin.c"
/>
<ClCompile
Include=
"..\..\src\render\direct3d\SDL_render_d3d.c"
/>
<ClCompile
Include=
"..\..\src\render\opengl\SDL_render_gl.c"
/>
<ClCompile
Include=
"..\..\src\render\opengl\SDL_shaders_gl.c"
/>
<ClCompile
Include=
"..\..\src\render\SDL_render.c"
/>
<ClCompile
Include=
"..\..\src\render\SDL_yuv_mmx.c"
/>
<ClCompile
Include=
"..\..\src\render\SDL_yuv_sw.c"
/>
...
...
src/render/opengl/SDL_shaders_gl.c
100644 → 100755
View file @
0f1080b5
...
...
@@ -112,6 +112,58 @@ static const char *shader_source[NUM_SHADERS][2] =
"void main()
\n
"
"{
\n
"
" gl_FragColor = texture2D(tex0, v_texCoord) * v_color;
\n
"
"}"
},
/* SHADER_YV12 */
{
/* vertex shader */
"varying vec4 v_color;
\n
"
"varying vec2 v_texCoord;
\n
"
"
\n
"
"void main()
\n
"
"{
\n
"
" gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
\n
"
" v_color = gl_Color;
\n
"
" v_texCoord = vec2(gl_MultiTexCoord0);
\n
"
"}"
,
/* fragment shader */
"varying vec4 v_color;
\n
"
"varying vec2 v_texCoord;
\n
"
"uniform sampler2D tex0; // Y
\n
"
"uniform sampler2D tex1; // U
\n
"
"uniform sampler2D tex2; // V
\n
"
"
\n
"
"// YUV offset
\n
"
"const vec3 offset = vec3(-0.0625, -0.5, -0.5);
\n
"
"
\n
"
"// RGB coefficients
\n
"
"const vec3 Rcoeff = vec3(1.164, 0.000, 1.596);
\n
"
"const vec3 Gcoeff = vec3(1.164, -0.391, -0.813);
\n
"
"const vec3 Bcoeff = vec3(1.164, 2.018, 0.000);
\n
"
"
\n
"
"void main()
\n
"
"{
\n
"
" vec2 tcoord;
\n
"
" vec3 yuv, rgb;
\n
"
"
\n
"
" // Get the Y value
\n
"
" tcoord = v_texCoord;
\n
"
" yuv.x = texture2D(tex0, tcoord).r;
\n
"
"
\n
"
" // Get the U and V values
\n
"
" tcoord *= 0.5;
\n
"
" yuv.y = texture2D(tex1, tcoord).r;
\n
"
" yuv.z = texture2D(tex2, tcoord).r;
\n
"
"
\n
"
" // Do the color transform
\n
"
" yuv += offset;
\n
"
" rgb.r = dot(yuv, Rcoeff);
\n
"
" rgb.g = dot(yuv, Gcoeff);
\n
"
" rgb.b = dot(yuv, Bcoeff);
\n
"
"
\n
"
" // That was easy. :)
\n
"
" gl_FragColor = vec4(rgb, 1.0) * v_color;
\n
"
"}"
},
};
...
...
@@ -209,10 +261,6 @@ CompileShaderProgram(GL_ShaderContext *ctx, int index, GL_ShaderData *data)
static
void
DestroyShaderProgram
(
GL_ShaderContext
*
ctx
,
GL_ShaderData
*
data
)
{
if
(
index
==
SHADER_NONE
)
{
return
;
}
ctx
->
glDeleteObjectARB
(
data
->
vert_shader
);
ctx
->
glDeleteObjectARB
(
data
->
frag_shader
);
ctx
->
glDeleteObjectARB
(
data
->
program
);
...
...
@@ -281,7 +329,6 @@ GL_CreateShaderContext()
/* Compile all the shaders */
for
(
i
=
0
;
i
<
NUM_SHADERS
;
++
i
)
{
if
(
!
CompileShaderProgram
(
ctx
,
i
,
&
ctx
->
shaders
[
i
]))
{
fprintf
(
stderr
,
"Unable to compile shader!
\n
"
);
GL_DestroyShaderContext
(
ctx
);
return
NULL
;
}
...
...
src/render/opengl/SDL_shaders_gl.h
View file @
0f1080b5
...
...
@@ -27,7 +27,7 @@ typedef enum {
SHADER_NONE
,
SHADER_SOLID
,
SHADER_RGB
,
//
SHADER_YV12,
SHADER_YV12
,
NUM_SHADERS
}
GL_Shader
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment