#define ALPHA_TEST " if(gl_FragColor.a < AlphaRef) discard; \n"
//#define ALPHA_TEST
-
+#define ENABLE true
+#define DISABLE false
GLuint vertexProgram = 9999;
const char *vertexShader =
"attribute lowp vec2 aTexCoord1; \n"\
"attribute lowp vec2 aAtlasTransform; \n"\
" \n"\
-"uniform lowp vec2 FogMinMax; \n"\
-" \n"\
"varying lowp float vFactor; \n"\
"varying lowp vec4 vShadeColor; \n"\
"varying mediump vec2 vTexCoord0; \n"\
"vShadeColor = aColor; \n"\
"vTexCoord0 = aTexCoord0; \n"\
"vTexCoord1 = aTexCoord1; \n"\
-"vFog = clamp((FogMinMax[1] - (gl_Position.z/aPosition.w))/(FogMinMax[1]-FogMinMax[0]),0.0,1.0); \n"\
" \n"\
"} \n"\
" \n";
"uniform vec4 PrimFrac; \n"\
"uniform float AlphaRef; \n"\
"uniform vec4 FogColor; \n"\
+"uniform vec2 FogMinMax; \n"\
" \n"\
"varying lowp float vFactor; \n"\
"varying lowp vec4 vShadeColor; \n"\
"varying mediump vec2 vTexCoord0; \n"\
"varying lowp vec2 vTexCoord1; \n"\
-"varying lowp float vFog; \n"\
" \n"\
"void main() \n"\
"{ \n"\
const char *fragmentFooter =
" \n"\
"#ifdef FOG \n"\
-"gl_FragColor.rgb = mix(FogColor.rgb,comb.rgb,vFog * step(0.5,1.0-FogColor.a)); \n"\
-"gl_FragColor.a = comb.a; \n"\
-"#else \n"\
-"gl_FragColor = comb; \n"\
-"#endif \n"\
-" \n"\
-"#ifdef ALPHA_TEST \n"\
-ALPHA_TEST
-"#endif \n"\
-" \n"\
-" \n"\
-" \n"\
-" \n"\
+" float z = gl_FragCoord.z * 2.0 - 1.0; \n"\
+" float FogFactor = (FogMinMax[1] - z) / (FogMinMax[1] - FogMinMax[0]); \n"\
+" FogFactor = clamp(FogFactor, 0.0, 1.0); \n"\
+" \n"\
+" gl_FragColor.rgb = mix(FogColor.rgb, comb.rgb, FogFactor ); \n"\
+" gl_FragColor.a = comb.a; \n"\
+"#else \n"\
+" gl_FragColor = comb; \n"\
+"#endif \n"\
+" \n"\
+"#ifdef ALPHA_TEST \n"\
+ ALPHA_TEST
+"#endif \n"\
"} \n";
//Fragment shader for InitCycleCopy
m_pDecodedMux = new DecodedMuxForPixelShader;
m_bFragmentProgramIsSupported = true;
m_AlphaRef = 0.0f;
+ bAlphaTestState = DISABLE;
+ bAlphaTestPreviousState = DISABLE;
+ bFogState = DISABLE;
+ bFogPreviousState = DISABLE;
//Create shaders for fill and copy
GLint success;
strcat(oglNewFP, "#define NEED_TEX0\n");
if (bNeedT1)
strcat(oglNewFP, "#define NEED_TEX1\n");
- if(gRDP.bFogEnableInBlender && gRSP.bFogEnabled && options.fogMethod > 0)
- strcat(oglNewFP,"#define FOG");
strcat(oglNewFP, fragmentHeader);
strcat(oglNewFP, newFPBody);
strcat(oglNewFP, fragmentFooter);
}
- //Create 2 shaders, with and without alphatest
+ //Create 4 shaders, with and without alphatest + with and without fog
GenerateProgramStr();
for(int alphaTest = 0;alphaTest < 2;alphaTest++)
{
- res.fragmentShaderID = glCreateShader(GL_FRAGMENT_SHADER);
-
- char* tmpShader = (char*)malloc(sizeof(char) * 4096);
- strcpy(tmpShader,"#version " GLSL_VERSION "\n");
-
- if(alphaTest == 1)
- {
- strcat(tmpShader,"#define ALPHA_TEST\n");
- }
-
- res.alphaTest = alphaTest == 1;
- strcat(tmpShader,oglNewFP);
-
- glShaderSource(res.fragmentShaderID, 1,(const char**) &tmpShader,NULL);
- free(tmpShader);
-
-
- OPENGL_CHECK_ERRORS;
- glCompileShader(res.fragmentShaderID);
-
- glGetShaderiv(res.fragmentShaderID, GL_COMPILE_STATUS, &success);
- if (!success)
- {
- char Log[1024];
- GLint nLength;
- glGetShaderInfoLog(res.fragmentShaderID, 1024, &nLength, Log);
- printf("Error compiling shader!\n %s",oglNewFP);
- printf("%s", Log);
- }
-
- res.programID = glCreateProgram();
- glAttachShader(res.programID,res.vertexShaderID);
- glAttachShader(res.programID,res.fragmentShaderID);
-
- //Bind Attributes
- glBindAttribLocation(res.programID,VS_COLOR,"aColor");
- OPENGL_CHECK_ERRORS;
- glBindAttribLocation(res.programID,VS_TEXCOORD0,"aTexCoord0");
- OPENGL_CHECK_ERRORS;
- glBindAttribLocation(res.programID,VS_TEXCOORD1,"aTexCoord1");
- OPENGL_CHECK_ERRORS;
- glBindAttribLocation(res.programID,VS_POSITION,"aPosition");
- OPENGL_CHECK_ERRORS;
-
- glLinkProgram(res.programID);
- OPENGL_CHECK_ERRORS;
-
- glGetProgramiv(res.programID, GL_LINK_STATUS, &success);
- if (!success)
- {
- char Log[1024];
- GLint nLength;
- glGetShaderInfoLog(res.fragmentShaderID, 1024, &nLength, Log);
- printf("Error linking program!\n");
- printf("%s\n",Log);
- }
-
- glUseProgram(res.programID);
- OPENGL_CHECK_ERRORS;
-
- //Bind texture samplers
- GLint tex0 = glGetUniformLocation(res.programID,"uTex0");
- GLint tex1 = glGetUniformLocation(res.programID,"uTex1");
-
- if(tex0 != -1)
- glUniform1i(tex0,0);
- if(tex1 != -1)
- glUniform1i(tex1,1);
-
- //Bind Uniforms
- res.PrimColorLocation = glGetUniformLocation(res.programID,"PrimColor");
- OPENGL_CHECK_ERRORS;
- res.EnvColorLocation = glGetUniformLocation(res.programID,"EnvColor");
- OPENGL_CHECK_ERRORS;
- res.PrimFracLocation = glGetUniformLocation(res.programID,"PrimFrac");
- OPENGL_CHECK_ERRORS;
- res.EnvFracLocation = glGetUniformLocation(res.programID,"EnvFrac");
- OPENGL_CHECK_ERRORS;
- res.AlphaRefLocation = glGetUniformLocation(res.programID,"AlphaRef");
- OPENGL_CHECK_ERRORS;
- res.FogColorLocation = glGetUniformLocation(res.programID,"FogColor");
- OPENGL_CHECK_ERRORS;
- res.FogMinMaxLocation = glGetUniformLocation(res.programID,"FogMinMax");
- OPENGL_CHECK_ERRORS;
-
- res.dwMux0 = m_pDecodedMux->m_dwMux0;
- res.dwMux1 = m_pDecodedMux->m_dwMux1;
- res.fogIsUsed = gRDP.bFogEnableInBlender && gRSP.bFogEnabled;
-
- m_vCompiledShaders.push_back(res);
+ for(int fog = 0;fog < 2;fog++) {
+ res.fragmentShaderID = glCreateShader(GL_FRAGMENT_SHADER);
+
+ char* tmpShader = (char*)malloc(sizeof(char) * 4096);
+ strcpy(tmpShader,"#version " GLSL_VERSION "\n");
+
+ if(alphaTest == 1)
+ {
+ strcat(tmpShader,"#define ALPHA_TEST\n");
+ }
+ if(fog == 1)
+ {
+ strcat(tmpShader,"#define FOG\n");
+ }
+
+ res.fogIsUsed = fog == 1;
+ res.alphaTest = alphaTest == 1;
+ strcat(tmpShader,oglNewFP);
+
+ glShaderSource(res.fragmentShaderID, 1,(const char**) &tmpShader,NULL);
+ free(tmpShader);
+
+
+ OPENGL_CHECK_ERRORS;
+ glCompileShader(res.fragmentShaderID);
+
+ glGetShaderiv(res.fragmentShaderID, GL_COMPILE_STATUS, &success);
+ if (!success)
+ {
+ char Log[1024];
+ GLint nLength;
+ glGetShaderInfoLog(res.fragmentShaderID, 1024, &nLength, Log);
+ printf("Error compiling shader!\n %s",oglNewFP);
+ printf("%s", Log);
+ }
+
+ res.programID = glCreateProgram();
+ glAttachShader(res.programID,res.vertexShaderID);
+ glAttachShader(res.programID,res.fragmentShaderID);
+
+ //Bind Attributes
+ glBindAttribLocation(res.programID,VS_COLOR,"aColor");
+ OPENGL_CHECK_ERRORS;
+ glBindAttribLocation(res.programID,VS_TEXCOORD0,"aTexCoord0");
+ OPENGL_CHECK_ERRORS;
+ glBindAttribLocation(res.programID,VS_TEXCOORD1,"aTexCoord1");
+ OPENGL_CHECK_ERRORS;
+ glBindAttribLocation(res.programID,VS_POSITION,"aPosition");
+ OPENGL_CHECK_ERRORS;
+
+ glLinkProgram(res.programID);
+ OPENGL_CHECK_ERRORS;
+
+ glGetProgramiv(res.programID, GL_LINK_STATUS, &success);
+ if (!success)
+ {
+ char Log[1024];
+ GLint nLength;
+ glGetShaderInfoLog(res.fragmentShaderID, 1024, &nLength, Log);
+ printf("Error linking program!\n");
+ printf("%s\n",Log);
+ }
+
+ glUseProgram(res.programID);
+ OPENGL_CHECK_ERRORS;
+
+ //Bind texture samplers
+ GLint tex0 = glGetUniformLocation(res.programID,"uTex0");
+ GLint tex1 = glGetUniformLocation(res.programID,"uTex1");
+
+ if(tex0 != -1)
+ glUniform1i(tex0,0);
+ if(tex1 != -1)
+ glUniform1i(tex1,1);
+
+ //Bind Uniforms
+ res.PrimColorLocation = glGetUniformLocation(res.programID,"PrimColor");
+ OPENGL_CHECK_ERRORS;
+ res.EnvColorLocation = glGetUniformLocation(res.programID,"EnvColor");
+ OPENGL_CHECK_ERRORS;
+ res.PrimFracLocation = glGetUniformLocation(res.programID,"PrimFrac");
+ OPENGL_CHECK_ERRORS;
+ res.EnvFracLocation = glGetUniformLocation(res.programID,"EnvFrac");
+ OPENGL_CHECK_ERRORS;
+ res.AlphaRefLocation = glGetUniformLocation(res.programID,"AlphaRef");
+ OPENGL_CHECK_ERRORS;
+ res.FogColorLocation = glGetUniformLocation(res.programID,"FogColor");
+ OPENGL_CHECK_ERRORS;
+ res.FogMinMaxLocation = glGetUniformLocation(res.programID,"FogMinMax");
+ OPENGL_CHECK_ERRORS;
+
+ res.dwMux0 = m_pDecodedMux->m_dwMux0;
+ res.dwMux1 = m_pDecodedMux->m_dwMux1;
+
+ m_vCompiledShaders.push_back(res);
+ }
}
- m_lastIndex = m_vCompiledShaders.size()-2;
+ m_lastIndex = m_vCompiledShaders.size()-4;
return m_lastIndex;
}
OPENGL_CHECK_ERRORS;
}
- //if(prog.FogColorLocation != -1 && prog.FogMinMaxLocation != -1)
- //{
- // //Pass fog colour and distance, use 0 alpha if fog disabled
- // glUniform4f(prog.FogColorLocation, gRDP.fvFogColor[0],gRDP.fvFogColor[1],gRDP.fvFogColor[2],
- // gRSP.bFogEnabled ? gRDP.fvFogColor[0] : 0.0f);
- // glUniform2f(prog.FogMinMaxLocation,gRSPfFogMin,gRSPfFogMax);
- //}
-
- if(prog.AlphaRefLocation != -1)
- glUniform1f(prog.AlphaRefLocation,m_AlphaRef);
- OPENGL_CHECK_ERRORS;
-}
-
-void COGL_FragmentProgramCombiner::UpdateFog(bool bEnable)
-{
- if(m_lastIndex < 0 || m_lastIndex >= m_vCompiledShaders.size())
- return;
- OGLShaderCombinerSaveType prog = m_vCompiledShaders[m_lastIndex];
-
- //if(bEnable)
- // DebugMessage(M64MSG_INFO,"Fog Color %x Min %f Max %f",gRDP.fogColor,gRSPfFogMin,gRSPfFogMax);
-
- if(prog.FogColorLocation != -1 && prog.FogMinMaxLocation != -1)
+ if(prog.FogColorLocation != -1)
{
- //Pass fog colour and distance, use 0 alpha if fog disabled
- glUniform4f(prog.FogColorLocation, gRDP.fvFogColor[0],gRDP.fvFogColor[1],gRDP.fvFogColor[2],
- bEnable ? gRDP.fvFogColor[0] : 0.0f);
- //glUniform4f(prog.FogColorLocation, 1.0f,0.3f,0.3f,1.0f);
- //OPENGL_CHECK_ERRORS;
+ glUniform4f(prog.FogColorLocation, gRDP.fvFogColor[0],gRDP.fvFogColor[1],gRDP.fvFogColor[2], gRDP.fvFogColor[3]);
+ OPENGL_CHECK_ERRORS;
+ }
+
+ if(prog.FogMinMaxLocation != -1)
+ {
glUniform2f(prog.FogMinMaxLocation,gRSPfFogMin,gRSPfFogMax);
OPENGL_CHECK_ERRORS;
}
+
+ if(prog.AlphaRefLocation != -1)
+ {
+ glUniform1f(prog.AlphaRefLocation,m_AlphaRef);
+ OPENGL_CHECK_ERRORS;
+ }
}
int COGL_FragmentProgramCombiner::FindCompiledMux()
{
if( m_vCompiledShaders[i].dwMux0 == m_pDecodedMux->m_dwMux0
&& m_vCompiledShaders[i].dwMux1 == m_pDecodedMux->m_dwMux1
- && m_vCompiledShaders[i].fogIsUsed == (gRDP.bFogEnableInBlender && gRSP.bFogEnabled)
- && m_vCompiledShaders[i].alphaTest == m_AlphaRef > 0.0f)
+ && m_vCompiledShaders[i].fogIsUsed == bFogState
+ && m_vCompiledShaders[i].alphaTest == bAlphaTestState)
{
return (int)i;
}
bool combinerIsChanged = false;
- if( m_pDecodedMux->m_dwMux0 != m_dwLastMux0 || m_pDecodedMux->m_dwMux1 != m_dwLastMux1 || m_lastIndex < 0 )
+ if( m_pDecodedMux->m_dwMux0 != m_dwLastMux0 || m_pDecodedMux->m_dwMux1 != m_dwLastMux1
+ || bAlphaTestState != bAlphaTestPreviousState || bFogState != bFogPreviousState || m_lastIndex < 0 )
{
combinerIsChanged = true;
m_lastIndex = FindCompiledMux();
m_dwLastMux0 = m_pDecodedMux->m_dwMux0;
m_dwLastMux1 = m_pDecodedMux->m_dwMux1;
- }
+ bAlphaTestPreviousState = bAlphaTestState;
+ bFogPreviousState = bFogState;
+ m_AlphaRef = (float)(m_pOGLRender->m_dwAlpha)/255.0f;
+ }
GenerateCombinerSettingConstants(m_lastIndex);
{
public:
bool Initialize(void);
- float m_AlphaRef;
- void UpdateFog(bool bEnable);
+ void SetFogState(bool bEnable)
+ {
+ bFogState = bEnable;
+ }
+ void SetAlphaTestState(bool bEnable)
+ {
+ bAlphaTestState = bEnable;
+ }
protected:
friend class OGLDeviceBuilder;
int FindCompiledMux();
virtual void GenerateCombinerSetting(int index);
virtual void GenerateCombinerSettingConstants(int index);
+ float m_AlphaRef;
+ bool bAlphaTestState;
+ bool bAlphaTestPreviousState;
+ bool bFogState;
+ bool bFogPreviousState;
#ifdef DEBUGGER
void DisplaySimpleMuxString(void);
glDepthRange(-1, 1);
#elif SDL_VIDEO_OPENGL_ES2
- glDepthRangef(0.0f, 1.0f);
+ glDepthRangef(-1.0f, 1.0f);
#endif
OPENGL_CHECK_ERRORS;
}
void COGLGraphicsContext::InitOGLExtension(void)
{
+#if SDL_VIDEO_OPENGL
// important extension features, it is very bad not to have these feature
m_bSupportMultiTexture = IsExtensionSupported(OSAL_GL_ARB_MULTITEXTURE);
m_bSupportTextureEnvCombine = IsExtensionSupported("GL_EXT_texture_env_combine");
m_bSupportRescaleNormal = IsExtensionSupported("GL_EXT_rescale_normal");
m_bSupportLODBias = IsExtensionSupported("GL_EXT_texture_lod_bias");
m_bSupportAnisotropicFiltering = IsExtensionSupported("GL_EXT_texture_filter_anisotropic");
-
+#else
+ m_bSupportMultiTexture = true;
+ m_bSupportFogCoord = false;
+ m_bSupportAnisotropicFiltering = true;
+#endif
// Compute maxAnisotropicFiltering
m_maxAnisotropicFiltering = 0;
if((uint32) m_maxAnisotropicFiltering > options.anisotropicFiltering)
m_maxAnisotropicFiltering = options.anisotropicFiltering;
}
-
+
+#if SDL_VIDEO_OPENGL
// Nvidia only extension features (optional)
m_bSupportNVRegisterCombiner = IsExtensionSupported("GL_NV_register_combiners");
m_bSupportTextureMirrorRepeat = IsExtensionSupported("GL_IBM_texture_mirrored_repeat") || IsExtensionSupported("ARB_texture_mirrored_repeat");
m_bSupportBlendColor = IsExtensionSupported("GL_EXT_blend_color");
m_bSupportBlendSubtract = IsExtensionSupported("GL_EXT_blend_subtract");
m_bSupportNVTextureEnvCombine4 = IsExtensionSupported("GL_NV_texture_env_combine4");
-
+#else
+ m_supportTextureMirror = true;
+#endif
}
bool COGLGraphicsContext::IsExtensionSupported(const char* pExtName)
{TEXTURE_UV_FLAG_CLAMP, GL_CLAMP},
};
-#if SDL_VIDEO_OPENGL_ES2
- static GLuint disabledTextureID;
-#endif
-
//===================================================================
OGLRender::OGLRender()
{
m_texUnitEnabled[i]=FALSE;
}
-#if SDL_VIDEO_OPENGL
m_bEnableMultiTexture = false;
-#elif SDL_VIDEO_OPENGL_ES2
- m_bEnableMultiTexture = true;
-
- //Create a texture as replacement for glEnable/Disable(GL_TEXTURE_2D)
- unsigned int white[8*8];
- for (int i=0; i<8*8; i++) {
- //white[i].r = white[i].g = white[i].b = 0;
- //white[i].a = 0;
- white[i] = 0;
- }
- glGenTextures(1,&disabledTextureID);
- OPENGL_CHECK_ERRORS;
- glBindTexture(GL_TEXTURE_2D, disabledTextureID);
- OPENGL_CHECK_ERRORS;
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- OPENGL_CHECK_ERRORS;
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, white);
- OPENGL_CHECK_ERRORS;
-#endif
}
OGLRender::~OGLRender()
OGLXUVFlagMaps[TEXTURE_UV_FLAG_MIRROR].realFlag = GL_MIRRORED_REPEAT;
m_bSupportClampToEdge = true;
OGLXUVFlagMaps[TEXTURE_UV_FLAG_CLAMP].realFlag = GL_CLAMP_TO_EDGE;
+
+ glVertexAttribPointer(VS_POSITION,4,GL_FLOAT,GL_FALSE,sizeof(float)*5,&(g_vtxProjected5[0][0]));
+ OPENGL_CHECK_ERRORS;
+
+ if( m_bMultiTexture )
+ {
+ glVertexAttribPointer(VS_TEXCOORD0,2,GL_FLOAT,GL_FALSE, sizeof( TLITVERTEX ), &(g_vtxBuffer[0].tcord[0].u));
+ OPENGL_CHECK_ERRORS;
+ glVertexAttribPointer(VS_TEXCOORD1,2,GL_FLOAT,GL_FALSE, sizeof( TLITVERTEX ), &(g_vtxBuffer[0].tcord[1].u));
+ OPENGL_CHECK_ERRORS;
+ }
+ else
+ {
+ glVertexAttribPointer(VS_TEXCOORD0,2,GL_FLOAT,GL_FALSE, sizeof( TLITVERTEX ), &(g_vtxBuffer[0].tcord[0].u));
+ OPENGL_CHECK_ERRORS;
+ }
+
+ glVertexAttribPointer(VS_COLOR, 4, GL_UNSIGNED_BYTE,GL_TRUE, sizeof(uint8)*4, &(g_oglVtxColors[0][0]) );
+ OPENGL_CHECK_ERRORS;
#endif
#ifdef PAULSCODE
g_texRectTVtx[0].tcord[0].u,g_texRectTVtx[0].tcord[0].v
};
+ GLfloat tex2[] = {
+ g_texRectTVtx[3].tcord[1].u,g_texRectTVtx[3].tcord[1].v,
+ g_texRectTVtx[2].tcord[1].u,g_texRectTVtx[2].tcord[1].v,
+ g_texRectTVtx[1].tcord[1].u,g_texRectTVtx[1].tcord[1].v,
+ g_texRectTVtx[0].tcord[1].u,g_texRectTVtx[0].tcord[1].v
+ };
+
float w = windowSetting.uDisplayWidth / 2.0f, h = windowSetting.uDisplayHeight / 2.0f, inv = 1.0f;
GLfloat vertices[] = {
glVertexAttribPointer(VS_COLOR, 4, GL_FLOAT,GL_TRUE, 0, &colour );
glVertexAttribPointer(VS_POSITION,4,GL_FLOAT,GL_FALSE,0,&vertices);
glVertexAttribPointer(VS_TEXCOORD0,2,GL_FLOAT,GL_FALSE, 0, &tex);
+ glVertexAttribPointer(VS_TEXCOORD1,2,GL_FLOAT,GL_FALSE, 0, &tex2);
OPENGL_CHECK_ERRORS;
glDrawArrays(GL_TRIANGLE_FAN,0,4);
OPENGL_CHECK_ERRORS;
glVertexAttribPointer(VS_COLOR, 4, GL_UNSIGNED_BYTE,GL_TRUE, sizeof(uint8)*4, &(g_oglVtxColors[0][0]) );
glVertexAttribPointer(VS_POSITION,4,GL_FLOAT,GL_FALSE,sizeof(float)*5,&(g_vtxProjected5[0][0]));
glVertexAttribPointer(VS_TEXCOORD0,2,GL_FLOAT,GL_FALSE, sizeof( TLITVERTEX ), &(g_vtxBuffer[0].tcord[0].u));
-
+ glVertexAttribPointer(VS_TEXCOORD1,2,GL_FLOAT,GL_FALSE, sizeof( TLITVERTEX ), &(g_vtxBuffer[0].tcord[1].u));
#endif
if( cullface ) glEnable(GL_CULL_FACE);
glVertexAttribPointer(VS_COLOR, 4, GL_FLOAT,GL_FALSE, 0, &colour );
glVertexAttribPointer(VS_POSITION,4,GL_FLOAT,GL_FALSE,0,&vertices);
glDisableVertexAttribArray(VS_TEXCOORD0);
+ glDisableVertexAttribArray(VS_TEXCOORD1);
OPENGL_CHECK_ERRORS;
glDrawArrays(GL_TRIANGLE_FAN,0,4);
OPENGL_CHECK_ERRORS;
glVertexAttribPointer(VS_COLOR, 4, GL_UNSIGNED_BYTE,GL_TRUE, sizeof(uint8)*4, &(g_oglVtxColors[0][0]) );
glVertexAttribPointer(VS_POSITION,4,GL_FLOAT,GL_FALSE,sizeof(float)*5,&(g_vtxProjected5[0][0]));
glEnableVertexAttribArray(VS_TEXCOORD0);
+ glEnableVertexAttribArray(VS_TEXCOORD1);
#endif
g_texRectTVtx[3].tcord[0].u,g_texRectTVtx[3].tcord[0].v,
};
+ GLfloat tex2[] = {
+ g_texRectTVtx[0].tcord[1].u,g_texRectTVtx[0].tcord[1].v,
+ g_texRectTVtx[1].tcord[1].u,g_texRectTVtx[1].tcord[1].v,
+ g_texRectTVtx[2].tcord[1].u,g_texRectTVtx[2].tcord[1].v,
+
+ g_texRectTVtx[0].tcord[1].u,g_texRectTVtx[0].tcord[1].v,
+ g_texRectTVtx[2].tcord[1].u,g_texRectTVtx[2].tcord[1].v,
+ g_texRectTVtx[3].tcord[1].u,g_texRectTVtx[3].tcord[1].v,
+ };
+
float w = windowSetting.uDisplayWidth / 2.0f, h = windowSetting.uDisplayHeight / 2.0f, inv = 1.0f;
GLfloat vertices[] = {
glVertexAttribPointer(VS_COLOR, 4, GL_FLOAT,GL_FALSE, 0, &colour );
glVertexAttribPointer(VS_POSITION,4,GL_FLOAT,GL_FALSE,0,&vertices);
glVertexAttribPointer(VS_TEXCOORD0,2,GL_FLOAT,GL_FALSE, 0, &tex);
+ glVertexAttribPointer(VS_TEXCOORD1,2,GL_FLOAT,GL_FALSE, 0, &tex2);
OPENGL_CHECK_ERRORS;
glDrawArrays(GL_TRIANGLES,0,6);
OPENGL_CHECK_ERRORS;
glVertexAttribPointer(VS_COLOR, 4, GL_UNSIGNED_BYTE,GL_TRUE, sizeof(uint8)*4, &(g_oglVtxColors[0][0]) );
glVertexAttribPointer(VS_POSITION,4,GL_FLOAT,GL_FALSE,sizeof(float)*5,&(g_vtxProjected5[0][0]));
glVertexAttribPointer(VS_TEXCOORD0,2,GL_FLOAT,GL_FALSE, sizeof( TLITVERTEX ), &(g_vtxBuffer[0].tcord[0].u));
+ glVertexAttribPointer(VS_TEXCOORD1,2,GL_FLOAT,GL_FALSE, sizeof( TLITVERTEX ), &(g_vtxBuffer[0].tcord[1].u));
#endif
glVertexAttribPointer(VS_COLOR, 4, GL_FLOAT,GL_FALSE, 0, &colour );
glVertexAttribPointer(VS_POSITION,4,GL_FLOAT,GL_FALSE,0,&vertices);
glDisableVertexAttribArray(VS_TEXCOORD0);
+ glDisableVertexAttribArray(VS_TEXCOORD1);
OPENGL_CHECK_ERRORS;
glDrawArrays(GL_TRIANGLE_FAN,0,4);
OPENGL_CHECK_ERRORS;
glVertexAttribPointer(VS_COLOR, 4, GL_UNSIGNED_BYTE,GL_TRUE, sizeof(uint8)*4, &(g_oglVtxColors[0][0]) );
glVertexAttribPointer(VS_POSITION,4,GL_FLOAT,GL_FALSE,sizeof(float)*5,&(g_vtxProjected5[0][0]));
glEnableVertexAttribArray(VS_TEXCOORD0);
+ glEnableVertexAttribArray(VS_TEXCOORD1);
#endif
#ifdef DEBUGGER
if( bAlphaTestEnable && debuggerEnableAlphaTest )
#else
- if( bAlphaTestEnable )
-#endif
+
#if SDL_VIDEO_OPENGL
+ if( bAlphaTestEnable )
glEnable(GL_ALPHA_TEST);
else
glDisable(GL_ALPHA_TEST);
+ OPENGL_CHECK_ERRORS;
#elif SDL_VIDEO_OPENGL_ES2
- {
- COGL_FragmentProgramCombiner* frag = (COGL_FragmentProgramCombiner*)m_pColorCombiner;
- frag->m_AlphaRef = m_dwAlpha / 255.0f;
- }
- else
- {
- COGL_FragmentProgramCombiner* frag = (COGL_FragmentProgramCombiner*)m_pColorCombiner;
- frag->m_AlphaRef = 0.0f;
- }
+ COGL_FragmentProgramCombiner* frag = (COGL_FragmentProgramCombiner*)m_pColorCombiner;
+ frag->SetAlphaTestState(bAlphaTestEnable);
+#endif
+
#endif
- OPENGL_CHECK_ERRORS;
}
void OGLRender::BindTexture(GLuint texture, int unitno)
if( m_texUnitEnabled[0] != flag )
{
m_texUnitEnabled[0] = flag;
-#if SDL_VIDEO_OPENGL
+
if( flag == TRUE )
glEnable(GL_TEXTURE_2D);
else
glDisable(GL_TEXTURE_2D);
-#elif SDL_VIDEO_OPENGL_ES2
- if(flag)
- {
- pglActiveTexture(GL_TEXTURE0_ARB + unitno);
- OPENGL_CHECK_ERRORS;
- glBindTexture(GL_TEXTURE_2D,m_curBoundTex[unitno]);
- }
- else
- {
- pglActiveTexture(GL_TEXTURE0_ARB + unitno);
- OPENGL_CHECK_ERRORS;
- glEnable(GL_BLEND); //Need blend for transparent disabled texture
- glBindTexture(GL_TEXTURE_2D,disabledTextureID);
- }
-#endif
- OPENGL_CHECK_ERRORS;
}
}
OPENGL_CHECK_ERRORS;
glFogf(GL_FOG_END, gRSPfFogMax); // Fog End Depth
OPENGL_CHECK_ERRORS;
-#elif SDL_VIDEO_OPENGL_ES2
- ((COGL_FragmentProgramCombiner*)m_pColorCombiner)->UpdateFog(gRSP.bFogEnabled);
- OPENGL_CHECK_ERRORS;
#endif
}
glDisable(GL_FOG);
OPENGL_CHECK_ERRORS;
#elif SDL_VIDEO_OPENGL_ES2
- ((COGL_FragmentProgramCombiner*)m_pColorCombiner)->UpdateFog(flag);
+ ((COGL_FragmentProgramCombiner*)m_pColorCombiner)->SetFogState(flag);
OPENGL_CHECK_ERRORS;
#endif
}
OPENGL_CHECK_ERRORS;
}
#elif SDL_VIDEO_OPENGL_ES2
- ((COGL_FragmentProgramCombiner*)m_pColorCombiner)->UpdateFog(gRSP.bFogEnabled);
+ ((COGL_FragmentProgramCombiner*)m_pColorCombiner)->SetFogState(gRSP.bFogEnabled);
OPENGL_CHECK_ERRORS;
#endif
}
g_texRectTVtx[3].tcord[0].u,g_texRectTVtx[3].tcord[0].v,
};
- float w = windowSetting.uDisplayWidth / 2.0f, h = windowSetting.uDisplayHeight / 2.0f, inv = 1.0f;
+ GLfloat tex2[] = {
+ g_texRectTVtx[0].tcord[1].u,g_texRectTVtx[0].tcord[1].v,
+ g_texRectTVtx[1].tcord[1].u,g_texRectTVtx[1].tcord[1].v,
+ g_texRectTVtx[2].tcord[1].u,g_texRectTVtx[2].tcord[1].v,
+
+ g_texRectTVtx[0].tcord[1].u,g_texRectTVtx[0].tcord[1].v,
+ g_texRectTVtx[2].tcord[1].u,g_texRectTVtx[2].tcord[1].v,
+ g_texRectTVtx[3].tcord[1].u,g_texRectTVtx[3].tcord[1].v,
+ };
+
+ float w = windowSetting.uDisplayWidth / 2.0f, h = windowSetting.uDisplayHeight / 2.0f, inv = 1.0f;
GLfloat vertices[] = {
-inv + g_texRectTVtx[0].x/ w, inv - g_texRectTVtx[0].y/ h, -g_texRectTVtx[0].z,1,
glVertexAttribPointer(VS_COLOR, 4, GL_FLOAT,GL_FALSE, 0, &colour );
glVertexAttribPointer(VS_POSITION,4,GL_FLOAT,GL_FALSE,0,&vertices);
glVertexAttribPointer(VS_TEXCOORD0,2,GL_FLOAT,GL_FALSE, 0, &tex);
+ glVertexAttribPointer(VS_TEXCOORD1,2,GL_FLOAT,GL_FALSE, 0, &tex2);
//OPENGL_CHECK_ERRORS;
glDrawArrays(GL_TRIANGLES,0,6);
//OPENGL_CHECK_ERRORS;
glVertexAttribPointer(VS_COLOR, 4, GL_UNSIGNED_BYTE,GL_TRUE, sizeof(uint8)*4, &(g_oglVtxColors[0][0]) );
glVertexAttribPointer(VS_POSITION,4,GL_FLOAT,GL_FALSE,sizeof(float)*5,&(g_vtxProjected5[0][0]));
glVertexAttribPointer(VS_TEXCOORD0,2,GL_FLOAT,GL_FALSE, sizeof( TLITVERTEX ), &(g_vtxBuffer[0].tcord[0].u));
+ glVertexAttribPointer(VS_TEXCOORD1,2,GL_FLOAT,GL_FALSE, sizeof( TLITVERTEX ), &(g_vtxBuffer[0].tcord[1].u));
#endif