@@ -83,6 +83,7 @@ static GLuint packedTexCoordsAttribLocation;
8383static GLuint textureLocation ;
8484static GLuint scaleLocation ;
8585static GLuint brightnessLocation ;
86+ static GLuint pseudoColorLocation ;
8687static GLuint DotTextureID ;
8788static GLuint BloomTextureID ;
8889static GLuint vbo ;
@@ -112,6 +113,7 @@ static float lineBrightness = 216.0f;
112113static float bloomWidthMultiplier = 8.0f ;
113114static float maxAlpha = 0.2f ;
114115static const float bloomBrightness = 200.0f ;
116+ static GLfloat pseudoColor [] = {1.0f , 1.0f , 1.0f , 1.0f };
115117
116118typedef struct
117119{
@@ -193,6 +195,14 @@ void retro_get_system_av_info(struct retro_system_av_info *info)
193195#define POINT_NEAR (-1.0f)
194196#define POINT_FAR (1.0f)
195197
198+ static void set_color (uint8_t r , uint8_t g , uint8_t b )
199+ {
200+ pseudoColor [0 ] = (float )r / 255.f ;
201+ pseudoColor [1 ] = (float )g / 255.f ;
202+ pseudoColor [2 ] = (float )b / 255.f ;
203+ pseudoColor [3 ] = 1.0f ;
204+ }
205+
196206static void make_mvp_matrix (float mvp_mat [16 ],
197207 float left , float bottom , float right , float top )
198208{
@@ -254,17 +264,19 @@ static void compile_gl_program(void)
254264 "}\n"
255265 };
256266 const char * fragmentShaderSource [] = {
257- "#ifdef GL_ES\n"
267+ "#ifdef GL_ES\n"
258268 "precision mediump float;\n"
259269 "#endif\n"
260270 "uniform sampler2D texture;\n"
271+ "uniform vec4 pseudoColor;\n"
261272
262273 "varying float fragColour;\n"
263274 "varying vec2 fragTexCoords;\n"
264275
265276 "void main()\n"
266277 "{\n"
267278 " vec4 colour = texture2D(texture, fragTexCoords).rgbr;\n"
279+ " colour *= pseudoColor;\n"
268280 " colour *= fragColour;\n"
269281 " gl_FragColor = colour;\n"
270282 "}\n"
@@ -288,6 +300,7 @@ static void compile_gl_program(void)
288300 textureLocation = glGetUniformLocation (ProgramID , "texture" );
289301 scaleLocation = glGetUniformLocation (ProgramID , "scale" );
290302 brightnessLocation = glGetUniformLocation (ProgramID , "brightness" );
303+ pseudoColorLocation = glGetUniformLocation (ProgramID , "pseudoColor" );
291304 positionAttribLocation = glGetAttribLocation (ProgramID , "position" );
292305 offsetAttribLocation = glGetAttribLocation (ProgramID , "offset" );
293306 colourAttribLocation = glGetAttribLocation (ProgramID , "colour" );
@@ -528,6 +541,40 @@ static void check_variables(void)
528541 value = 8 ;
529542 bloomWidthMultiplier = value ;
530543 }
544+
545+ var .value = NULL ;
546+ var .key = "vecx_line_color" ;
547+ if (environ_cb (RETRO_ENVIRONMENT_GET_VARIABLE , & var ) && var .value )
548+ {
549+ if (strcmp (var .value , "White" ) == 0 )
550+ {
551+ set_color (0xff , 0xff , 0xff );
552+ }
553+ else if (strcmp (var .value , "Green" ) == 0 )
554+ {
555+ set_color (0x44 , 0xff , 0x44 );
556+ }
557+ else if (strcmp (var .value , "Cyan" ) == 0 )
558+ {
559+ set_color (0x44 , 0xff , 0xff );
560+ }
561+ else if (strcmp (var .value , "Yellow" ) == 0 )
562+ {
563+ set_color (0xff , 0xff , 0x44 );
564+ }
565+ else if (strcmp (var .value , "Magenta" ) == 0 )
566+ {
567+ set_color (0xff , 0x44 , 0xff );
568+ }
569+ else if (strcmp (var .value , "Red" ) == 0 )
570+ {
571+ set_color (0xff , 0x44 , 0x44 );
572+ }
573+ else if (strcmp (var .value , "Blue" ) == 0 )
574+ {
575+ set_color (0x44 , 0x44 , 0xff );
576+ }
577+ }
531578 }
532579 else
533580#endif
@@ -1110,6 +1157,7 @@ void osint_render(void)
11101157 glUniform1i (textureLocation , 0 );
11111158 glUniform1f (scaleLocation , lineWidth * bloomWidthMultiplier );
11121159 glUniform1f (brightnessLocation , bloomBrightness );
1160+ glUniform4fv (pseudoColorLocation , 1 , pseudoColor );
11131161 glBlendEquation (GL_FUNC_ADD );
11141162 glBlendFunc (GL_ONE_MINUS_DST_ALPHA , GL_ONE );
11151163 glDrawArrays (GL_TRIANGLES , 0 , num_verts );
@@ -1122,6 +1170,7 @@ void osint_render(void)
11221170 glUniform1i (textureLocation , 0 );
11231171 glUniform1f (scaleLocation , lineWidth );
11241172 glUniform1f (brightnessLocation , lineBrightness );
1173+ glUniform4fv (pseudoColorLocation , 1 , pseudoColor );
11251174 glBlendFunc (GL_ONE , GL_ONE );
11261175 glDrawArrays (GL_TRIANGLES , 0 , num_verts );
11271176
0 commit comments