From 253a79d605e15bebb126750a43a3e09f9ff49889 Mon Sep 17 00:00:00 2001 From: hybrid Date: Sun, 24 Jan 2010 20:26:32 +0000 Subject: [PATCH] Error message check added for egl setup. Updated to latest OpenGL driver code to fix AntiAlias etc. git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/branches/ogl-es@3178 dfc29bdd-3216-0410-991c-e03cc46cb475 --- source/Irrlicht/COGLESDriver.cpp | 78 ++++++++++++---------- source/Irrlicht/COGLESExtensionHandler.cpp | 25 +++++-- source/Irrlicht/COGLESExtensionHandler.h | 9 +++ 3 files changed, 69 insertions(+), 43 deletions(-) diff --git a/source/Irrlicht/COGLESDriver.cpp b/source/Irrlicht/COGLESDriver.cpp index 07f10e9d..9c053676 100644 --- a/source/Irrlicht/COGLESDriver.cpp +++ b/source/Irrlicht/COGLESDriver.cpp @@ -102,6 +102,7 @@ COGLES1Driver::COGLES1Driver(const SIrrlichtCreationParameters& params, EglSurface = eglCreateWindowSurface(EglDisplay, config, NULL, NULL); if (EGL_NO_SURFACE==EglSurface) { + testEGLError(); os::Printer::log("Could not create surface for OpenGL-ES1 display."); } @@ -161,6 +162,7 @@ COGLES1Driver::COGLES1Driver(const SIrrlichtCreationParameters& params, //! destructor COGLES1Driver::~COGLES1Driver() { + RequestedLights.clear(); deleteMaterialRenders(); deleteAllTextures(); @@ -225,36 +227,6 @@ bool COGLES1Driver::genericDriverInit(const core::dimension2d& screenSize, // Reset The Current Viewport glViewport(0, 0, screenSize.Width, screenSize.Height); -// This needs an SMaterial flag to enable/disable later on, but should become default sometimes -// glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); -// glEnable(GL_COLOR_MATERIAL); - - setAmbientLight(SColorf(0.0f,0.0f,0.0f,0.0f)); -#ifdef GL_separate_specular_color - if (FeatureAvailable[IRR_separate_specular_color]) - glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR); -#endif -// TODO ogl-es -// glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1); - glClearDepthf(1.0f); - - glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST); - glHint(GL_GENERATE_MIPMAP_HINT, GL_FASTEST); - glDepthFunc(GL_LEQUAL); - glFrontFace( GL_CW ); - - if (AntiAlias>1) - { - if (MultiSamplingExtension) - glEnable(GL_MULTISAMPLE); - - glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); - glEnable(GL_LINE_SMOOTH); - } -// currently disabled, because often in software, and thus very slow - glHint(GL_POINT_SMOOTH_HINT, GL_FASTEST); -// glEnable(GL_POINT_SMOOTH); - UserClipPlane.reallocate(MaxUserClipPlanes); UserClipPlaneEnabled.reallocate(MaxUserClipPlanes); for (i=0; i& screenSize, UserClipPlaneEnabled.push_back(false); } + for (i=0; i(i), core::IdentityMatrix); + + setAmbientLight(SColorf(0.0f,0.0f,0.0f,0.0f)); +#ifdef GL_EXT_separate_specular_color + if (FeatureAvailable[IRR_EXT_separate_specular_color]) + glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR); +#endif +// TODO ogl-es +// glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1); + + glClearDepthf(1.0f); + glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST); + glHint(GL_GENERATE_MIPMAP_HINT, GL_FASTEST); + glHint(GL_LINE_SMOOTH_HINT, GL_FASTEST); + glHint(GL_POINT_SMOOTH_HINT, GL_FASTEST); + glDepthFunc(GL_LEQUAL); + glFrontFace( GL_CW ); + // create material renderers createMaterialRenderers(); @@ -1762,8 +1753,8 @@ void COGLES1Driver::setBasicRenderStates(const SMaterial& material, const SMater if ((material.Shininess != 0.0f) && (material.ColorMaterial != video::ECM_SPECULAR)) { -#ifdef GL_separate_specular_color - if (FeatureAvailable[IRR_separate_specular_color]) +#ifdef GL_EXT_separate_specular_color + if (FeatureAvailable[IRR_EXT_separate_specular_color]) glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR); #endif glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, material.Shininess); @@ -1773,9 +1764,9 @@ void COGLES1Driver::setBasicRenderStates(const SMaterial& material, const SMater color[3] = material.SpecularColor.getAlpha() * inv; glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, color); } -#ifdef GL_separate_specular_color +#ifdef GL_EXT_separate_specular_color else - if (FeatureAvailable[IRR_separate_specular_color]) + if (FeatureAvailable[IRR_EXT_separate_specular_color]) glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SINGLE_COLOR); #endif } @@ -1963,8 +1954,18 @@ void COGLES1Driver::setBasicRenderStates(const SMaterial& material, const SMater // thickness if (resetAllRenderStates || lastmaterial.Thickness != material.Thickness) { - glPointSize(material.Thickness); - glLineWidth(material.Thickness); + if (AntiAlias) + { +// glPointSize(core::clamp(static_cast(material.Thickness), DimSmoothedPoint[0], DimSmoothedPoint[1])); + // we don't use point smoothing + glPointSize(core::clamp(static_cast(material.Thickness), DimAliasedPoint[0], DimAliasedPoint[1])); + glLineWidth(core::clamp(static_cast(material.Thickness), DimSmoothedLine[0], DimSmoothedLine[1])); + } + else + { + glPointSize(core::clamp(static_cast(material.Thickness), DimAliasedPoint[0], DimAliasedPoint[1])); + glLineWidth(core::clamp(static_cast(material.Thickness), DimAliasedLine[0], DimAliasedLine[1])); + } } // Anti aliasing @@ -1982,12 +1983,15 @@ void COGLES1Driver::setBasicRenderStates(const SMaterial& material, const SMater else glDisable(GL_MULTISAMPLE); } - if (AntiAlias >= 2) + if ((material.AntiAliasing & EAAM_LINE_SMOOTH) != (lastmaterial.AntiAliasing & EAAM_LINE_SMOOTH)) { if (material.AntiAliasing & EAAM_LINE_SMOOTH) glEnable(GL_LINE_SMOOTH); else if (lastmaterial.AntiAliasing & EAAM_LINE_SMOOTH) glDisable(GL_LINE_SMOOTH); + } + if ((material.AntiAliasing & EAAM_POINT_SMOOTH) != (lastmaterial.AntiAliasing & EAAM_POINT_SMOOTH)) + { if (material.AntiAliasing & EAAM_POINT_SMOOTH) // often in software, and thus very slow glEnable(GL_POINT_SMOOTH); diff --git a/source/Irrlicht/COGLESExtensionHandler.cpp b/source/Irrlicht/COGLESExtensionHandler.cpp index 6c5ce455..9de8c8a7 100644 --- a/source/Irrlicht/COGLESExtensionHandler.cpp +++ b/source/Irrlicht/COGLESExtensionHandler.cpp @@ -109,13 +109,23 @@ COGLES1ExtensionHandler::COGLES1ExtensionHandler() : pGlFramebufferRenderbufferOES(0), pGlFramebufferTexture2DOES(0), pGlGenerateMipMapOES(0), #endif - EGLVersion(0), Version(0), MaxTextureUnits(0), MaxLights(0), MaxAnisotropy(1), - MaxUserClipPlanes(0), MaxAuxBuffers(0), MaxIndices(65535), MaxTextureSize(1), - MaxTextureLODBias(0.f), CommonProfile(false), MultiTextureExtension(false), - MultiSamplingExtension(false), StencilBuffer(false) + EGLVersion(0), Version(0), MaxTextureUnits(0), MaxLights(0), + MaxAnisotropy(1), MaxUserClipPlanes(0), MaxAuxBuffers(0), + MaxMultipleRenderTargets(1), MaxIndices(65535), MaxTextureSize(1), + MaxTextureLODBias(0.f), CommonProfile(false), + MultiTextureExtension(false), MultiSamplingExtension(false), + StencilBuffer(false) { for (u32 i=0; i(val); -#ifdef EXT_texture_lod_bias +#ifdef GL_EXT_texture_lod_bias if (FeatureAvailable[IRR_EXT_texture_lod_bias]) glGetFloatv(GL_MAX_TEXTURE_LOD_BIAS_EXT, &MaxTextureLODBias); #endif @@ -213,7 +223,10 @@ void COGLES1ExtensionHandler::initExtensions(COGLES1Driver* driver, glGetIntegerv(GL_MAX_CLIP_PLANES, &val); MaxUserClipPlanes = static_cast(val); } - MaxAuxBuffers=static_cast(val); + glGetFloatv(GL_ALIASED_LINE_WIDTH_RANGE, DimAliasedLine); + glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE, DimAliasedPoint); + glGetFloatv(GL_SMOOTH_LINE_WIDTH_RANGE, DimSmoothedLine); + glGetFloatv(GL_SMOOTH_POINT_SIZE_RANGE, DimSmoothedPoint); #if defined(_IRR_OPENGL_USE_EXTPOINTER_) if (FeatureAvailable[IRR_OES_draw_texture]) diff --git a/source/Irrlicht/COGLESExtensionHandler.h b/source/Irrlicht/COGLESExtensionHandler.h index a15fae03..1a0c6bf3 100644 --- a/source/Irrlicht/COGLESExtensionHandler.h +++ b/source/Irrlicht/COGLESExtensionHandler.h @@ -126,9 +126,18 @@ namespace video u8 MaxAnisotropy; u8 MaxUserClipPlanes; u8 MaxAuxBuffers; + u8 MaxMultipleRenderTargets; u32 MaxIndices; u32 MaxTextureSize; f32 MaxTextureLODBias; + //! Minimal and maximal supported thickness for lines without smoothing + GLfloat DimAliasedLine[2]; + //! Minimal and maximal supported thickness for points without smoothing + GLfloat DimAliasedPoint[2]; + //! Minimal and maximal supported thickness for lines with smoothing + GLfloat DimSmoothedLine[2]; + //! Minimal and maximal supported thickness for points with smoothing + GLfloat DimSmoothedPoint[2]; bool CommonProfile; bool MultiTextureExtension; bool MultiSamplingExtension;