Search
lxdream.org :: lxdream/src/pvr2/gl_sl.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/pvr2/gl_sl.c
changeset 736:a02d1475ccfd
prev679:f5ae66677a49
next1009:c29795e15cef
author nkeynes
date Mon Jul 14 07:44:42 2008 +0000 (11 years ago)
permissions -rw-r--r--
last change Re-indent everything consistently
Fix include guards for consistency as well
file annotate diff log raw
1.1 --- a/src/pvr2/gl_sl.c Sun Jun 01 00:37:27 2008 +0000
1.2 +++ b/src/pvr2/gl_sl.c Mon Jul 14 07:44:42 2008 +0000
1.3 @@ -27,8 +27,8 @@
1.4 gboolean glsl_is_supported()
1.5 {
1.6 return isGLExtensionSupported("GL_ARB_fragment_shader") &&
1.7 - isGLExtensionSupported("GL_ARB_vertex_shader") &&
1.8 - isGLExtensionSupported("GL_ARB_shading_language_100");
1.9 + isGLExtensionSupported("GL_ARB_vertex_shader") &&
1.10 + isGLExtensionSupported("GL_ARB_shading_language_100");
1.11 }
1.12
1.13 #ifdef GL_ARB_shader_objects
1.14 @@ -48,8 +48,8 @@
1.15
1.16 glGetObjectParameterivARB(obj, GL_OBJECT_COMPILE_STATUS_ARB, &value);
1.17 if( value == 0 ) {
1.18 - glsl_print_error(msg, obj);
1.19 - return FALSE;
1.20 + glsl_print_error(msg, obj);
1.21 + return FALSE;
1.22 }
1.23 return TRUE;
1.24 }
1.25 @@ -57,7 +57,7 @@
1.26 gboolean glsl_check_program_error( char *msg, GLhandleARB obj )
1.27 {
1.28 if( glGetError() != GL_NO_ERROR ) {
1.29 - glsl_print_error(msg, obj);
1.30 + glsl_print_error(msg, obj);
1.31 }
1.32 return TRUE;
1.33 }
1.34 @@ -68,40 +68,40 @@
1.35 gboolean vsok = TRUE, fsok = TRUE, pok = FALSE;
1.36
1.37 if( vertex_src == NULL && fragment_src == NULL ) {
1.38 - return TRUE; // nothing to do
1.39 + return TRUE; // nothing to do
1.40 }
1.41
1.42 glsl_program = glCreateProgramObjectARB();
1.43
1.44 if( vertex_src != NULL ) {
1.45 - glsl_vert_shader = glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB);
1.46 - glShaderSourceARB( glsl_vert_shader, 1, &vertex_src, NULL );
1.47 - glCompileShaderARB(glsl_vert_shader);
1.48 - vsok = glsl_check_shader_error("Failed to compile vertex shader", glsl_vert_shader);
1.49 + glsl_vert_shader = glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB);
1.50 + glShaderSourceARB( glsl_vert_shader, 1, &vertex_src, NULL );
1.51 + glCompileShaderARB(glsl_vert_shader);
1.52 + vsok = glsl_check_shader_error("Failed to compile vertex shader", glsl_vert_shader);
1.53 }
1.54 if( fragment_src != NULL ) {
1.55 - glsl_frag_shader = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB);
1.56 - glShaderSourceARB( glsl_frag_shader, 1, &fragment_src, NULL );
1.57 - glCompileShaderARB(glsl_frag_shader);
1.58 - fsok = glsl_check_shader_error("Failed to compile fragment shader", glsl_frag_shader);
1.59 + glsl_frag_shader = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB);
1.60 + glShaderSourceARB( glsl_frag_shader, 1, &fragment_src, NULL );
1.61 + glCompileShaderARB(glsl_frag_shader);
1.62 + fsok = glsl_check_shader_error("Failed to compile fragment shader", glsl_frag_shader);
1.63 }
1.64
1.65 if( vsok && fsok ) {
1.66 - if( vertex_src != NULL ) {
1.67 - glAttachObjectARB(glsl_program, glsl_vert_shader);
1.68 - }
1.69 - if( fragment_src != NULL ) {
1.70 - glAttachObjectARB(glsl_program, glsl_frag_shader);
1.71 - }
1.72 - glLinkProgramARB(glsl_program);
1.73 - pok = glsl_check_program_error( "Failed to link shader program", glsl_program );
1.74 + if( vertex_src != NULL ) {
1.75 + glAttachObjectARB(glsl_program, glsl_vert_shader);
1.76 + }
1.77 + if( fragment_src != NULL ) {
1.78 + glAttachObjectARB(glsl_program, glsl_frag_shader);
1.79 + }
1.80 + glLinkProgramARB(glsl_program);
1.81 + pok = glsl_check_program_error( "Failed to link shader program", glsl_program );
1.82 }
1.83 if( pok ) {
1.84 - glUseProgramObjectARB(glsl_program);
1.85 - pok = glsl_check_program_error( "Failed to apply shader program", glsl_program );
1.86 - glsl_enable_shaders(FALSE); // initially disabled
1.87 + glUseProgramObjectARB(glsl_program);
1.88 + pok = glsl_check_program_error( "Failed to apply shader program", glsl_program );
1.89 + glsl_enable_shaders(FALSE); // initially disabled
1.90 } else {
1.91 - glsl_unload_shaders();
1.92 + glsl_unload_shaders();
1.93 }
1.94 return pok;
1.95 }
1.96 @@ -109,11 +109,11 @@
1.97 void glsl_enable_shaders(gboolean en)
1.98 {
1.99 if( glsl_program != 0 ) {
1.100 - if( en ) {
1.101 - glUseProgramObjectARB(glsl_program);
1.102 - } else {
1.103 - glUseProgramObjectARB(0);
1.104 - }
1.105 + if( en ) {
1.106 + glUseProgramObjectARB(glsl_program);
1.107 + } else {
1.108 + glUseProgramObjectARB(0);
1.109 + }
1.110 }
1.111 }
1.112
1.113 @@ -136,22 +136,22 @@
1.114
1.115 glGetShaderiv( shader, GL_COMPILE_STATUS, &value );
1.116 if( value == 0 ) {
1.117 - char buf[MAX_ERROR_BUF];
1.118 - GLsizei length;
1.119 - glGetShaderInfoLog( shader, sizeof(buf), &length, buf );
1.120 - ERROR( "%s: %s", msg, buf );
1.121 - return FALSE;
1.122 + char buf[MAX_ERROR_BUF];
1.123 + GLsizei length;
1.124 + glGetShaderInfoLog( shader, sizeof(buf), &length, buf );
1.125 + ERROR( "%s: %s", msg, buf );
1.126 + return FALSE;
1.127 }
1.128 return TRUE;
1.129 }
1.130 gboolean glsl_check_program_error( char *msg, GLuint program )
1.131 {
1.132 if( glGetError() != GL_NO_ERROR ) {
1.133 - char buf[MAX_ERROR_BUF];
1.134 - GLsizei length;
1.135 - glGetProgramInfoLog( program, sizeof(buf), &length, buf );
1.136 - ERROR( "%s: %s", msg, buf );
1.137 - return FALSE;
1.138 + char buf[MAX_ERROR_BUF];
1.139 + GLsizei length;
1.140 + glGetProgramInfoLog( program, sizeof(buf), &length, buf );
1.141 + ERROR( "%s: %s", msg, buf );
1.142 + return FALSE;
1.143 }
1.144 return TRUE;
1.145 }
1.146 @@ -161,41 +161,41 @@
1.147 gboolean vsok = TRUE, fsok = TRUE, pok = FALSE;
1.148
1.149 if( vertex_src == NULL && fragment_src == NULL ) {
1.150 - return TRUE;
1.151 + return TRUE;
1.152 }
1.153
1.154 glsl_program = glCreateProgram();
1.155
1.156 if( vertex_src != NULL ) {
1.157 - glsl_vert_shader = glCreateShader(GL_VERTEX_SHADER);
1.158 - glShaderSource( glsl_vert_shader, 1, &vertex_src, NULL );
1.159 - glCompileShader(glsl_vert_shader);
1.160 - vsok = glsl_check_shader_error( "Failed to compile vertex shader", glsl_vert_shader );
1.161 + glsl_vert_shader = glCreateShader(GL_VERTEX_SHADER);
1.162 + glShaderSource( glsl_vert_shader, 1, &vertex_src, NULL );
1.163 + glCompileShader(glsl_vert_shader);
1.164 + vsok = glsl_check_shader_error( "Failed to compile vertex shader", glsl_vert_shader );
1.165 }
1.166 if( fragment_src != NULL ) {
1.167 - glsl_frag_shader = glCreateShader(GL_FRAGMENT_SHADER);
1.168 - glShaderSource( glsl_frag_shader, 1, &fragment_src, NULL );
1.169 - glCompileShader(glsl_frag_shader);
1.170 - fsok = glsl_check_shader_error( "Failed to compile fragment shader", glsl_frag_shader );
1.171 + glsl_frag_shader = glCreateShader(GL_FRAGMENT_SHADER);
1.172 + glShaderSource( glsl_frag_shader, 1, &fragment_src, NULL );
1.173 + glCompileShader(glsl_frag_shader);
1.174 + fsok = glsl_check_shader_error( "Failed to compile fragment shader", glsl_frag_shader );
1.175 }
1.176
1.177 if( vsok && fsok ) {
1.178 - if( vertex_src != NULL ) {
1.179 - glAttachShader(glsl_program, glsl_vert_shader);
1.180 - }
1.181 - if( fragment_src != NULL ) {
1.182 - glAttachShader(glsl_program, glsl_frag_shader);
1.183 - }
1.184 - glLinkProgram(glsl_program);
1.185 - pok = glsl_check_program_error( "Failed to link shader program", glsl_program );
1.186 + if( vertex_src != NULL ) {
1.187 + glAttachShader(glsl_program, glsl_vert_shader);
1.188 + }
1.189 + if( fragment_src != NULL ) {
1.190 + glAttachShader(glsl_program, glsl_frag_shader);
1.191 + }
1.192 + glLinkProgram(glsl_program);
1.193 + pok = glsl_check_program_error( "Failed to link shader program", glsl_program );
1.194 }
1.195
1.196 if( pok ) {
1.197 - glUseProgram(glsl_program);
1.198 - pok = glsl_check_program_error( "Failed to apply shader program", glsl_program );
1.199 - glsl_enable_shaders(FALSE); // initially disabled
1.200 + glUseProgram(glsl_program);
1.201 + pok = glsl_check_program_error( "Failed to apply shader program", glsl_program );
1.202 + glsl_enable_shaders(FALSE); // initially disabled
1.203 } else {
1.204 - glsl_unload_shaders();
1.205 + glsl_unload_shaders();
1.206 }
1.207 return pok;
1.208 }
1.209 @@ -204,11 +204,11 @@
1.210 void glsl_enable_shaders(gboolean en)
1.211 {
1.212 if( glsl_program != 0 ) {
1.213 - if( en ) {
1.214 - glUseProgram(glsl_program);
1.215 - } else {
1.216 - glUseProgram(0);
1.217 - }
1.218 + if( en ) {
1.219 + glUseProgram(glsl_program);
1.220 + } else {
1.221 + glUseProgram(0);
1.222 + }
1.223 }
1.224 }
1.225
.