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
505dd64a
Commit
505dd64a
authored
Feb 09, 2011
by
Sam Lantinga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made the shaders easier to debug when they don't compile
parent
296fa03f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
40 deletions
+37
-40
SDL_shaders_gl.c
src/render/opengl/SDL_shaders_gl.c
+37
-40
No files found.
src/render/opengl/SDL_shaders_gl.c
View file @
505dd64a
...
@@ -31,6 +31,8 @@
...
@@ -31,6 +31,8 @@
/* OpenGL shader implementation */
/* OpenGL shader implementation */
/*#define DEBUG_SHADERS*/
typedef
struct
typedef
struct
{
{
GLenum
program
;
GLenum
program
;
...
@@ -74,51 +76,43 @@ static const char *shader_source[NUM_SHADERS][2] =
...
@@ -74,51 +76,43 @@ static const char *shader_source[NUM_SHADERS][2] =
/* SHADER_SOLID */
/* SHADER_SOLID */
{
{
/* vertex shader */
/* vertex shader */
" \
"varying vec4 v_color;
\n
"
varying vec4 v_color; \
"
\n
"
\
"void main()
\n
"
void main() \
"{
\n
"
{ \
" gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
\n
"
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; \
" v_color = gl_Color;
\n
"
v_color = gl_Color; \
"}"
,
} \
"
,
/* fragment shader */
/* fragment shader */
" \
"varying vec4 v_color;
\n
"
varying vec4 v_color; \
"
\n
"
\
"void main()
\n
"
void main() \
"{
\n
"
{ \
" gl_FragColor = v_color;
\n
"
gl_FragColor = v_color; \
"}"
} \
"
},
},
/* SHADER_RGB */
/* SHADER_RGB */
{
{
/* vertex shader */
/* vertex shader */
" \
"varying vec4 v_color;
\n
"
varying vec4 v_color; \
"varying vec2 v_texCoord;
\n
"
varying vec2 v_texCoord; \
"
\n
"
\
"void main()
\n
"
void main() \
"{
\n
"
{ \
" gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
\n
"
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; \
" v_color = gl_Color;
\n
"
v_color = gl_Color; \
" v_texCoord = vec2(gl_MultiTexCoord0);
\n
"
v_texCoord = vec2(gl_MultiTexCoord0); \
"}"
,
} \
"
,
/* fragment shader */
/* fragment shader */
" \
"varying vec4 v_color;
\n
"
varying vec4 v_color; \
"varying vec2 v_texCoord;
\n
"
varying vec2 v_texCoord; \
"uniform sampler2D tex0;
\n
"
uniform sampler2D tex0; \
"
\n
"
\
"void main()
\n
"
void main() \
"{
\n
"
{ \
" gl_FragColor = texture2D(tex0, v_texCoord) * v_color;
\n
"
gl_FragColor = texture2D(tex0, v_texCoord) * v_color; \
"}"
} \
"
},
},
};
};
...
@@ -142,8 +136,11 @@ CompileShader(GL_ShaderContext *ctx, GLenum shader, const char *defines, const c
...
@@ -142,8 +136,11 @@ CompileShader(GL_ShaderContext *ctx, GLenum shader, const char *defines, const c
info
=
SDL_stack_alloc
(
char
,
length
+
1
);
info
=
SDL_stack_alloc
(
char
,
length
+
1
);
ctx
->
glGetInfoLogARB
(
shader
,
length
,
NULL
,
info
);
ctx
->
glGetInfoLogARB
(
shader
,
length
,
NULL
,
info
);
SDL_LogError
(
SDL_LOG_CATEGORY_RENDER
,
SDL_LogError
(
SDL_LOG_CATEGORY_RENDER
,
"Failed to compile shader:
\n
%s
\n
%s"
,
source
,
info
);
"Failed to compile shader:
\n
%s%s
\n
%s"
,
defines
,
source
,
info
);
fprintf
(
stderr
,
"Failed to compile shader:
\n
%s
\n
%s"
,
source
,
info
);
#ifdef DEBUG_SHADERS
fprintf
(
stderr
,
"Failed to compile shader:
\n
%s%s
\n
%s"
,
defines
,
source
,
info
);
#endif
SDL_stack_free
(
info
);
SDL_stack_free
(
info
);
return
SDL_FALSE
;
return
SDL_FALSE
;
...
...
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