Do not use some deprecated function with core ctx

This commit is contained in:
vlj 2014-09-26 15:27:50 +02:00
parent a593c81a64
commit f320b36db3

View File

@ -88,16 +88,18 @@ bool COpenGLDriver::changeRenderContext(const SExposedVideoData& videoData, CIrr
}
static PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribs_ARB;
bool useCoreContext;
static HGLRC getMeAGLContext(HDC HDc)
{
useCoreContext = true;
HGLRC hrc = 0;
int ctx44debug[] =
{
WGL_CONTEXT_MAJOR_VERSION_ARB, 4,
WGL_CONTEXT_MINOR_VERSION_ARB, 3,
WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_DEBUG_BIT_ARB,
WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB,
WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
0
};
@ -155,6 +157,7 @@ static HGLRC getMeAGLContext(HDC HDc)
if (hrc)
return hrc;
useCoreContext = false;
int legacyctx[] =
{
WGL_CONTEXT_MAJOR_VERSION_ARB, 2,
@ -794,9 +797,10 @@ bool COpenGLDriver::genericDriverInit()
setAmbientLight(SColorf(0.0f,0.0f,0.0f,0.0f));
#ifdef GL_EXT_separate_specular_color
if (FeatureAvailable[IRR_EXT_separate_specular_color])
if (FeatureAvailable[IRR_EXT_separate_specular_color] && !useCoreContext)
glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR);
#endif
if (!useCoreContext)
glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1);
Params.HandleSRGB &= ((FeatureAvailable[IRR_ARB_framebuffer_sRGB] || FeatureAvailable[IRR_EXT_framebuffer_sRGB]) &&
@ -830,6 +834,7 @@ bool COpenGLDriver::genericDriverInit()
// set the renderstates
setRenderStates3DMode();
if (!useCoreContext)
glAlphaFunc(GL_GREATER, 0.f);
// set fog mode
@ -1027,9 +1032,11 @@ void COpenGLDriver::setTransform(E_TRANSFORMATION_STATE state, const core::matri
case ETS_WORLD:
{
// OpenGL only has a model matrix, view and world is not existent. so lets fake these two.
if (!useCoreContext)
glMatrixMode(GL_MODELVIEW);
// first load the viewing transformation for user clip planes
if (!useCoreContext)
glLoadMatrixf((Matrices[ETS_VIEW]).pointer());
// we have to update the clip planes to the latest view matrix
@ -1038,12 +1045,15 @@ void COpenGLDriver::setTransform(E_TRANSFORMATION_STATE state, const core::matri
uploadClipPlane(i);
// now the real model-view matrix
if (!useCoreContext)
glMultMatrixf(Matrices[ETS_WORLD].pointer());
}
break;
case ETS_PROJECTION:
{
if (!useCoreContext)
glMatrixMode(GL_PROJECTION);
if (!useCoreContext)
glLoadMatrixf(mat.pointer());
}
break;
@ -1060,8 +1070,9 @@ void COpenGLDriver::setTransform(E_TRANSFORMATION_STATE state, const core::matri
if (MultiTextureExtension)
extGlActiveTexture(GL_TEXTURE0_ARB + i);
if (!useCoreContext)
glMatrixMode(GL_TEXTURE);
if (!isRTT && mat.isIdentity() )
if (!isRTT && mat.isIdentity() && !useCoreContext)
glLoadIdentity();
else
{
@ -1070,6 +1081,7 @@ void COpenGLDriver::setTransform(E_TRANSFORMATION_STATE state, const core::matri
getGLTextureMatrix(glmat, mat * TextureFlipMatrix);
else
getGLTextureMatrix(glmat, mat);
if (!useCoreContext)
glLoadMatrixf(glmat);
}
break;
@ -2651,10 +2663,14 @@ void COpenGLDriver::setRenderStates3DMode()
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// switch back the matrices
if (!useCoreContext)
glMatrixMode(GL_MODELVIEW);
if (!useCoreContext)
glLoadMatrixf((Matrices[ETS_VIEW] * Matrices[ETS_WORLD]).pointer());
if (!useCoreContext)
glMatrixMode(GL_PROJECTION);
if (!useCoreContext)
glLoadMatrixf(Matrices[ETS_PROJECTION].pointer());
ResetRenderStates = true;
@ -2822,18 +2838,23 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater
glDisable(GL_COLOR_MATERIAL);
break;
case ECM_DIFFUSE:
if (!useCoreContext)
glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
break;
case ECM_AMBIENT:
if (!useCoreContext)
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT);
break;
case ECM_EMISSIVE:
if (!useCoreContext)
glColorMaterial(GL_FRONT_AND_BACK, GL_EMISSION);
break;
case ECM_SPECULAR:
if (!useCoreContext)
glColorMaterial(GL_FRONT_AND_BACK, GL_SPECULAR);
break;
case ECM_DIFFUSE_AND_AMBIENT:
if (!useCoreContext)
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
break;
}
@ -2858,6 +2879,7 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater
color[1] = material.AmbientColor.getGreen() * inv;
color[2] = material.AmbientColor.getBlue() * inv;
color[3] = material.AmbientColor.getAlpha() * inv;
if (!useCoreContext)
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, color);
}
@ -2868,6 +2890,7 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater
color[1] = material.DiffuseColor.getGreen() * inv;
color[2] = material.DiffuseColor.getBlue() * inv;
color[3] = material.DiffuseColor.getAlpha() * inv;
if (!useCoreContext)
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, color);
}
@ -2877,6 +2900,7 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater
color[1] = material.EmissiveColor.getGreen() * inv;
color[2] = material.EmissiveColor.getBlue() * inv;
color[3] = material.EmissiveColor.getAlpha() * inv;
if (!useCoreContext)
glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, color);
}
}
@ -2889,13 +2913,14 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater
GLfloat color[4]={0.f,0.f,0.f,1.f};
const f32 inv = 1.0f / 255.0f;
if (!useCoreContext)
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, material.Shininess);
// disable Specular colors if no shininess is set
if ((material.Shininess != 0.0f) &&
(material.ColorMaterial != video::ECM_SPECULAR))
{
#ifdef GL_EXT_separate_specular_color
if (FeatureAvailable[IRR_EXT_separate_specular_color])
if (FeatureAvailable[IRR_EXT_separate_specular_color] && !useCoreContext)
glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR);
#endif
color[0] = material.SpecularColor.getRed() * inv;
@ -2904,9 +2929,10 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater
color[3] = material.SpecularColor.getAlpha() * inv;
}
#ifdef GL_EXT_separate_specular_color
else if (FeatureAvailable[IRR_EXT_separate_specular_color])
else if (FeatureAvailable[IRR_EXT_separate_specular_color] && !useCoreContext)
glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SINGLE_COLOR);
#endif
if (!useCoreContext)
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, color);
}
@ -2961,9 +2987,9 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater
// shademode
if (resetAllRenderStates || (lastmaterial.GouraudShading != material.GouraudShading))
{
if (material.GouraudShading)
if (material.GouraudShading && !useCoreContext)
glShadeModel(GL_SMOOTH);
else
else if (!useCoreContext)
glShadeModel(GL_FLAT);
}
@ -3618,6 +3644,7 @@ u32 COpenGLDriver::getMaximalDynamicLightAmount() const
void COpenGLDriver::setAmbientLight(const SColorf& color)
{
GLfloat data[4] = {color.r, color.g, color.b, color.a};
if (!useCoreContext)
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, data);
}