Add driver attrributes for ogles2.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/branches/ogl-es@3839 dfc29bdd-3216-0410-991c-e03cc46cb475
master
hybrid 2011-06-09 16:19:22 +00:00
parent ed4b37f8bc
commit 8a0144ae8d
5 changed files with 305 additions and 299 deletions

View File

@ -280,21 +280,32 @@ namespace video
StencilBuffer = stencilBuffer; StencilBuffer = stencilBuffer;
DriverAttributes->setAttribute("MaxTextures", MaxTextureUnits);
DriverAttributes->setAttribute("MaxSupportedTextures", MaxSupportedTextures);
DriverAttributes->setAttribute("MaxLights", MaxLights);
DriverAttributes->setAttribute("MaxAnisotropy", MaxAnisotropy);
DriverAttributes->setAttribute("MaxUserClipPlanes", MaxUserClipPlanes);
// DriverAttributes->setAttribute("MaxAuxBuffers", MaxAuxBuffers);
// DriverAttributes->setAttribute("MaxMultipleRenderTargets", MaxMultipleRenderTargets);
DriverAttributes->setAttribute("MaxIndices", (s32)MaxIndices);
DriverAttributes->setAttribute("MaxTextureSize", (s32)MaxTextureSize);
DriverAttributes->setAttribute("MaxTextureLODBias", MaxTextureLODBias);
DriverAttributes->setAttribute("Version", Version);
DriverAttributes->setAttribute("AntiAlias", AntiAlias);
FixedPipeline = new COGLES2FixedPipelineShader(this, FileSystem); FixedPipeline = new COGLES2FixedPipelineShader(this, FileSystem);
FixedPipeline->useProgram(); //For setting the default uniforms (Alpha) FixedPipeline->useProgram(); //For setting the default uniforms (Alpha)
TwoDRenderer = new COGLES2Renderer2d(this, FileSystem); TwoDRenderer = new COGLES2Renderer2d(this, FileSystem);
glPixelStorei(GL_PACK_ALIGNMENT, 2); glPixelStorei(GL_PACK_ALIGNMENT, 1);
// Reset The Current Viewport // Reset The Current Viewport
glViewport(0, 0, screenSize.Width, screenSize.Height); glViewport(0, 0, screenSize.Width, screenSize.Height);
UserClipPlane.reallocate(0);
setAmbientLight(SColorf(0.0f, 0.0f, 0.0f, 0.0f)); 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
glClearDepthf(1.0f); glClearDepthf(1.0f);
//TODO : OpenGL ES 2.0 Port : GL_PERSPECTIVE_CORRECTION_HINT //TODO : OpenGL ES 2.0 Port : GL_PERSPECTIVE_CORRECTION_HINT
@ -303,8 +314,6 @@ namespace video
glDepthFunc(GL_LEQUAL); glDepthFunc(GL_LEQUAL);
glFrontFace(GL_CW); glFrontFace(GL_CW);
UserClipPlane.reallocate(0);
// create material renderers // create material renderers
createMaterialRenderers(); createMaterialRenderers();

View File

@ -118,8 +118,9 @@ namespace video
COGLES2ExtensionHandler::COGLES2ExtensionHandler() : COGLES2ExtensionHandler::COGLES2ExtensionHandler() :
EGLVersion(0), Version(0), MaxTextureUnits(0), MaxLights(0), MaxAnisotropy(1), EGLVersion(0), Version(0), MaxTextureUnits(0), MaxSupportedTextures(0),
MaxUserClipPlanes(1), MaxTextureSize(1), CommonProfile(false), MultiTextureExtension(false), MaxLights(0), MaxAnisotropy(1), MaxUserClipPlanes(6), MaxTextureSize(1),
MaxIndices(0xffff), MaxTextureLODBias(0.f), MultiTextureExtension(false),
MultiSamplingExtension(false), StencilBuffer(false) MultiSamplingExtension(false), StencilBuffer(false)
{ {
for (u32 i=0; i<IRR_OGLES2_Feature_Count; ++i) for (u32 i=0; i<IRR_OGLES2_Feature_Count; ++i)
@ -137,18 +138,17 @@ namespace video
void COGLES2ExtensionHandler::initExtensions(COGLES2Driver* driver, void COGLES2ExtensionHandler::initExtensions(COGLES2Driver* driver,
EGLDisplay display, bool withStencil) EGLDisplay display, bool withStencil)
{ {
#ifdef EGL_VERSION_1_0
const f32 egl_ver = core::fast_atof(reinterpret_cast<const c8*>(eglQueryString(display, EGL_VERSION))); const f32 egl_ver = core::fast_atof(reinterpret_cast<const c8*>(eglQueryString(display, EGL_VERSION)));
EGLVersion = static_cast<u16>(core::floor32(egl_ver) * 100 + core::round32(core::fract(egl_ver) * 10.0f)); EGLVersion = static_cast<u16>(core::floor32(egl_ver) * 100 + core::round32(core::fract(egl_ver) * 10.0f));
core::stringc eglExtensions = eglQueryString(display, EGL_EXTENSIONS); core::stringc eglExtensions = eglQueryString(display, EGL_EXTENSIONS);
os::Printer::log(eglExtensions.c_str()); os::Printer::log(eglExtensions.c_str());
#endif
const core::stringc stringVer(glGetString(GL_VERSION)); const core::stringc stringVer(glGetString(GL_VERSION));
//CommonProfile = (stringVer[11] == 'M'); const f32 ogl_ver = core::fast_atof(stringVer.c_str() + 10);
const f32 ogl_ver = core::fast_atof(stringVer.c_str() + 13);
Version = static_cast<u16>(core::floor32(ogl_ver) * 100 + core::round32(core::fract(ogl_ver) * 10.0f)); Version = static_cast<u16>(core::floor32(ogl_ver) * 100 + core::round32(core::fract(ogl_ver) * 10.0f));
core::stringc extensions = glGetString(GL_EXTENSIONS); core::stringc extensions = glGetString(GL_EXTENSIONS);
os::Printer::log(extensions.c_str()); os::Printer::log(extensions.c_str());
// typo in the simulator (note the postfixed s) // typo in the simulator (note the postfixed s)
if (extensions.find("GL_IMG_user_clip_planes")) if (extensions.find("GL_IMG_user_clip_planes"))
FeatureAvailable[IRR_IMG_user_clip_plane] = true; FeatureAvailable[IRR_IMG_user_clip_plane] = true;
@ -184,11 +184,11 @@ namespace video
GLint val = 0; GLint val = 0;
glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &val); glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &val);
MaxTextureUnits = core::min_(MATERIAL_MAX_TEXTURES, static_cast<u32>(val)); MaxSupportedTextures = core::min_(MATERIAL_MAX_TEXTURES, static_cast<u32>(val));
MultiTextureExtension = true; MultiTextureExtension = true;
//TODO : OpenGL ES 2.0 Port //TODO : OpenGL ES 2.0 Port
//glGetIntegerv(GL_MAX_LIGHTS, &val); //glGetIntegerv(GL_MAX_LIGHTS, &val);
MaxLights = static_cast<u8>(val); MaxLights = 8;
#ifdef GL_EXT_texture_filter_anisotropic #ifdef GL_EXT_texture_filter_anisotropic
if (FeatureAvailable[IRR_EXT_texture_filter_anisotropic]) if (FeatureAvailable[IRR_EXT_texture_filter_anisotropic])
{ {
@ -198,13 +198,11 @@ namespace video
#endif #endif
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &val); glGetIntegerv(GL_MAX_TEXTURE_SIZE, &val);
MaxTextureSize=static_cast<u32>(val); MaxTextureSize=static_cast<u32>(val);
if ((Version > 100) || FeatureAvailable[IRR_IMG_user_clip_plane] ) #ifdef GL_EXT_texture_lod_bias
{ if (FeatureAvailable[IRR_EXT_texture_lod_bias])
//TODO : OpenGL ES 2.0 Port glGetFloatv(GL_MAX_TEXTURE_LOD_BIAS_EXT, &MaxTextureLODBias);
//glGetIntegerv(GL_MAX_CLIP_PLANES, &val); #endif
val = 6; MaxTextureUnits = core::min_(MaxSupportedTextures, static_cast<u8>(MATERIAL_MAX_TEXTURES));
MaxUserClipPlanes = static_cast<u8>(val);
}
} }
} // end namespace video } // end namespace video

View File

@ -185,11 +185,14 @@ namespace video
u16 EGLVersion; u16 EGLVersion;
u16 Version; u16 Version;
u8 MaxTextureUnits; u8 MaxTextureUnits;
u8 MaxSupportedTextures;
u8 MaxLights; u8 MaxLights;
u8 MaxAnisotropy; u8 MaxAnisotropy;
u8 MaxUserClipPlanes; u8 MaxUserClipPlanes;
u32 MaxTextureSize; u32 MaxTextureSize;
bool CommonProfile; u32 MaxIndices;
f32 MaxTextureLODBias;
bool MultiTextureExtension; bool MultiTextureExtension;
bool MultiSamplingExtension; bool MultiSamplingExtension;
bool StencilBuffer; bool StencilBuffer;

View File

@ -332,10 +332,6 @@ bool COGLES1Driver::genericDriverInit(const core::dimension2d<u32>& screenSize,
setTransform(static_cast<E_TRANSFORMATION_STATE>(i), core::IdentityMatrix); setTransform(static_cast<E_TRANSFORMATION_STATE>(i), core::IdentityMatrix);
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
if (FeatureAvailable[IRR_EXT_separate_specular_color])
glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR);
#endif
// TODO ogl-es // TODO ogl-es
// glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1); // glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1);