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
296fa03f
Commit
296fa03f
authored
Feb 09, 2011
by
Sam Lantinga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed the shaders (needed to use texture2DRect) - thanks Ryan!
parent
fd61299f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
12 deletions
+30
-12
SDL_render_gl.c
src/render/opengl/SDL_render_gl.c
+0
-5
SDL_shaders_gl.c
src/render/opengl/SDL_shaders_gl.c
+30
-7
No files found.
src/render/opengl/SDL_render_gl.c
View file @
296fa03f
...
...
@@ -297,11 +297,6 @@ GL_CreateRenderer(SDL_Window * window, Uint32 flags)
data
->
glDisable
(
GL_CULL_FACE
);
/* This ended up causing video discrepancies between OpenGL and Direct3D */
/*data->glEnable(GL_LINE_SMOOTH);*/
if
(
data
->
GL_ARB_texture_rectangle_supported
)
{
data
->
glEnable
(
GL_TEXTURE_RECTANGLE_ARB
);
}
else
{
data
->
glEnable
(
GL_TEXTURE_2D
);
}
data
->
updateSize
=
SDL_TRUE
;
return
renderer
;
...
...
src/render/opengl/SDL_shaders_gl.c
View file @
296fa03f
...
...
@@ -56,10 +56,16 @@ struct GL_ShaderContext
PFNGLUNIFORM1FARBPROC
glUniform1fARB
;
PFNGLUSEPROGRAMOBJECTARBPROC
glUseProgramObjectARB
;
SDL_bool
GL_ARB_texture_rectangle_supported
;
GL_Shader
current_shader
;
GL_ShaderData
shaders
[
NUM_SHADERS
];
};
/*
* NOTE: Always use sampler2D, etc here. We'll #define them to the
* texture_rectangle versions if we choose to use that extension.
*/
static
const
char
*
shader_source
[
NUM_SHADERS
][
2
]
=
{
/* SHADER_NONE */
...
...
@@ -73,7 +79,7 @@ varying vec4 v_color; \
\
void main() \
{ \
gl_Position =
ftransform()
; \
gl_Position =
gl_ModelViewProjectionMatrix * gl_Vertex
; \
v_color = gl_Color; \
} \
"
,
...
...
@@ -97,7 +103,7 @@ varying vec2 v_texCoord; \
\
void main() \
{ \
gl_Position =
ftransform()
; \
gl_Position =
gl_ModelViewProjectionMatrix * gl_Vertex
; \
v_color = gl_Color; \
v_texCoord = vec2(gl_MultiTexCoord0); \
} \
...
...
@@ -117,11 +123,15 @@ void main() \
};
static
SDL_bool
CompileShader
(
GL_ShaderContext
*
ctx
,
GLenum
shader
,
const
char
*
source
)
CompileShader
(
GL_ShaderContext
*
ctx
,
GLenum
shader
,
const
char
*
defines
,
const
char
*
source
)
{
GLint
status
;
const
char
*
sources
[
2
];
ctx
->
glShaderSourceARB
(
shader
,
1
,
&
source
,
NULL
);
sources
[
0
]
=
defines
;
sources
[
1
]
=
source
;
ctx
->
glShaderSourceARB
(
shader
,
SDL_arraysize
(
sources
),
sources
,
NULL
);
ctx
->
glCompileShaderARB
(
shader
);
ctx
->
glGetObjectParameterivARB
(
shader
,
GL_OBJECT_COMPILE_STATUS_ARB
,
&
status
);
if
(
status
==
0
)
{
...
...
@@ -146,7 +156,8 @@ static SDL_bool
CompileShaderProgram
(
GL_ShaderContext
*
ctx
,
int
index
,
GL_ShaderData
*
data
)
{
const
int
num_tmus_bound
=
4
;
GLint
status
;
const
char
*
vert_defines
=
""
;
const
char
*
frag_defines
=
""
;
int
i
;
GLint
location
;
...
...
@@ -156,18 +167,25 @@ CompileShaderProgram(GL_ShaderContext *ctx, int index, GL_ShaderData *data)
ctx
->
glGetError
();
/* Make sure we use the correct sampler type for our texture type */
if
(
ctx
->
GL_ARB_texture_rectangle_supported
)
{
frag_defines
=
"#define sampler2D sampler2DRect
\n
"
"#define texture2D texture2DRect
\n
"
;
}
/* Create one program object to rule them all */
data
->
program
=
ctx
->
glCreateProgramObjectARB
();
/* Create the vertex shader */
data
->
vert_shader
=
ctx
->
glCreateShaderObjectARB
(
GL_VERTEX_SHADER_ARB
);
if
(
!
CompileShader
(
ctx
,
data
->
vert_shader
,
shader_source
[
index
][
0
]))
{
if
(
!
CompileShader
(
ctx
,
data
->
vert_shader
,
vert_defines
,
shader_source
[
index
][
0
]))
{
return
SDL_FALSE
;
}
/* Create the fragment shader */
data
->
frag_shader
=
ctx
->
glCreateShaderObjectARB
(
GL_FRAGMENT_SHADER_ARB
);
if
(
!
CompileShader
(
ctx
,
data
->
frag_shader
,
shader_source
[
index
][
1
]))
{
if
(
!
CompileShader
(
ctx
,
data
->
frag_shader
,
frag_defines
,
shader_source
[
index
][
1
]))
{
return
SDL_FALSE
;
}
...
...
@@ -215,6 +233,11 @@ GL_CreateShaderContext()
return
NULL
;
}
if
(
SDL_GL_ExtensionSupported
(
"GL_ARB_texture_rectangle"
)
||
SDL_GL_ExtensionSupported
(
"GL_EXT_texture_rectangle"
))
{
ctx
->
GL_ARB_texture_rectangle_supported
=
SDL_TRUE
;
}
/* Check for shader support */
shaders_supported
=
SDL_FALSE
;
if
(
SDL_GL_ExtensionSupported
(
"GL_ARB_shader_objects"
)
&&
...
...
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