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