diff --git a/source/Irrlicht/COpenGLDriver.cpp b/source/Irrlicht/COpenGLDriver.cpp index 51fa9009..97fb05d9 100644 --- a/source/Irrlicht/COpenGLDriver.cpp +++ b/source/Irrlicht/COpenGLDriver.cpp @@ -31,37 +31,10 @@ namespace video #ifdef _IRR_USE_WINDOWS_DEVICE_ //! Windows constructor and init code COpenGLDriver::COpenGLDriver(const core::dimension2d& screenSize, HWND window, bool fullscreen, bool stencilBuffer, io::IFileSystem* io, bool antiAlias) -: CNullDriver(io, screenSize), +: CNullDriver(io, screenSize), COpenGLExtensionHandler(), CurrentRenderMode(ERM_NONE), ResetRenderStates(true), Transformation3DChanged(true), - StencilBuffer(stencilBuffer), AntiAlias(antiAlias), - MultiTextureExtension(false), MultiSamplingExtension(false), AnisotropyExtension(false), - ARBVertexProgramExtension(false), ARBFragmentProgramExtension(false), - ARBShadingLanguage100Extension(false), SeparateStencilExtension(false), - GenerateMipmapExtension(false), TextureCompressionExtension(false), - TextureNPOTExtension(false), FramebufferObjectExtension(false), EXTPackedDepthStencil(false), - RenderTargetTexture(0), LastSetLight(-1), MaxAnisotropy(1), - MaxTextureUnits(1), MaxLights(1), CurrentRendertargetSize(0,0), -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - pGlActiveTextureARB(0), pGlClientActiveTextureARB(0), - pGlGenProgramsARB(0), pGlBindProgramARB(0), pGlProgramStringARB(0), - pGlDeleteProgramsARB(0), pGlProgramLocalParameter4fvARB(0), - pGlCreateShaderObjectARB(0), pGlShaderSourceARB(0), - pGlCompileShaderARB(0), pGlCreateProgramObjectARB(0), pGlAttachObjectARB(0), - pGlLinkProgramARB(0), pGlUseProgramObjectARB(0), pGlDeleteObjectARB(0), - pGlGetObjectParameterivARB(0), pGlGetUniformLocationARB(0), - pGlUniform1ivARB(0), pGlUniform1fvARB(0), pGlUniform2fvARB(0), pGlUniform3fvARB(0), pGlUniform4fvARB(0), pGlUniformMatrix2fvARB(0), - pGlUniformMatrix3fvARB(0), pGlUniformMatrix4fvARB(0), pGlGetActiveUniformARB(0), pGlPointParameterfARB(0), pGlPointParameterfvARB(0), - pGlStencilFuncSeparate(0), pGlStencilOpSeparate(0), - pGlStencilFuncSeparateATI(0), pGlStencilOpSeparateATI(0), - #ifdef PFNGLCOMPRESSEDTEXIMAGE2DPROC - pGlCompressedTexImage2D(0), - #endif -#endif // _IRR_OPENGL_USE_EXTPOINTER_ - wglSwapIntervalEXT(0), - pGlBindFramebufferEXT(0), pGlDeleteFramebuffersEXT(0), pGlGenFramebuffersEXT(0), - pGlCheckFramebufferStatusEXT(0), pGlFramebufferTexture2DEXT(0), - pGlBindRenderbufferEXT(0), pGlDeleteRenderbuffersEXT(0), pGlGenRenderbuffersEXT(0), - pGlRenderbufferStorageEXT(0), pGlFramebufferRenderbufferEXT(0), + AntiAlias(antiAlias), RenderTargetTexture(0), LastSetLight(-1), + CurrentRendertargetSize(0,0), HDc(0), Window(window), HRc(0) { #ifdef _DEBUG @@ -71,7 +44,7 @@ COpenGLDriver::COpenGLDriver(const core::dimension2d& screenSize, HWND wind //! inits the open gl driver bool COpenGLDriver::initDriver(const core::dimension2d& screenSize, - HWND window, u32 bits, bool fullscreen, bool vsync) + HWND window, u32 bits, bool fullscreen, bool vsync, bool stencilBuffer) { static PIXELFORMATDESCRIPTOR pfd = { sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor @@ -87,7 +60,7 @@ bool COpenGLDriver::initDriver(const core::dimension2d& screenSize, 0, // No Accumulation Buffer 0, 0, 0, 0, // Accumulation Bits Ignored 24, // Z-Buffer (Depth Buffer) - StencilBuffer ? 1 : 0, // Stencil Buffer Depth + stencilBuffer ? 1 : 0, // Stencil Buffer Depth 0, // No Auxiliary Buffer PFD_MAIN_PLANE, // Main Drawing Layer 0, // Reserved @@ -98,9 +71,9 @@ bool COpenGLDriver::initDriver(const core::dimension2d& screenSize, { if (i == 1) { - if (StencilBuffer) + if (stencilBuffer) os::Printer::log("Cannot create a GL device with stencil buffer, disabling stencil shadows.", ELL_WARNING); - StencilBuffer = false; + stencilBuffer = false; pfd.cStencilBits = 0; } else @@ -159,7 +132,7 @@ bool COpenGLDriver::initDriver(const core::dimension2d& screenSize, break; } - genericDriverInit(screenSize); + genericDriverInit(screenSize, stencilBuffer); // set vsync if (wglSwapIntervalEXT) @@ -173,34 +146,6 @@ bool COpenGLDriver::initDriver(const core::dimension2d& screenSize, return true; } - - -//! win32 destructor -COpenGLDriver::~COpenGLDriver() -{ - deleteMaterialRenders(); - - // I get a blue screen on my laptop, when I do not delete the - // textures manually before releasing the dc. Oh how I love this. - - deleteAllTextures(); - - if (HRc) - { - if (!wglMakeCurrent(0, 0)) - os::Printer::log("Release of dc and rc failed.", ELL_WARNING); - - if (!wglDeleteContext(HRc)) - os::Printer::log("Release of rendering context failed.", ELL_WARNING); - - HRc = 0; - } - - if (HDc) - ReleaseDC(Window, HDc); - - HDc = 0; -} #endif //IRR_USE_WINDOWS_DEVICE_ // ----------------------------------------------------------------------- @@ -209,27 +154,16 @@ COpenGLDriver::~COpenGLDriver() #ifdef MACOSX //! Windows constructor and init code COpenGLDriver::COpenGLDriver(const core::dimension2d& screenSize, bool fullscreen, bool stencilBuffer, CIrrDeviceMacOSX *device, io::IFileSystem* io, bool vsync, bool antiAlias) -: CNullDriver(io, screenSize), +: CNullDriver(io, screenSize), COpenGLExtensionHandler(), CurrentRenderMode(ERM_NONE), ResetRenderStates(true), Transformation3DChanged(true), - StencilBuffer(stencilBuffer), AntiAlias(antiAlias), - MultiTextureExtension(false), MultiSamplingExtension(false), AnisotropyExtension(false), - ARBVertexProgramExtension(false), ARBFragmentProgramExtension(false), - ARBShadingLanguage100Extension(false), SeparateStencilExtension(false), - GenerateMipmapExtension(false), TextureCompressionExtension(false), - TextureNPOTExtension(false), FramebufferObjectExtension(false), EXTPackedDepthStencil(false), - RenderTargetTexture(0), LastSetLight(-1), MaxAnisotropy(1), - MaxTextureUnits(1), MaxLights(1), + AntiAlias(antiAlias), + RenderTargetTexture(0), LastSetLight(-1), CurrentRendertargetSize(0,0), _device(device) { #ifdef _DEBUG setDebugName("COpenGLDriver"); #endif - genericDriverInit(screenSize); -} - -COpenGLDriver::~COpenGLDriver() -{ - deleteAllTextures(); + genericDriverInit(screenSize, stencilBuffer); } #endif @@ -240,31 +174,11 @@ COpenGLDriver::~COpenGLDriver() #ifdef _IRR_USE_LINUX_DEVICE_ //! Linux constructor and init code COpenGLDriver::COpenGLDriver(const core::dimension2d& screenSize, bool fullscreen, bool stencilBuffer, io::IFileSystem* io, bool vsync, bool antiAlias) -: CNullDriver(io, screenSize), +: CNullDriver(io, screenSize), COpenGLExtensionHandler(), CurrentRenderMode(ERM_NONE), ResetRenderStates(true), Transformation3DChanged(true), - StencilBuffer(stencilBuffer), AntiAlias(antiAlias), - MultiTextureExtension(false), MultiSamplingExtension(false), AnisotropyExtension(false), - ARBVertexProgramExtension(false), ARBFragmentProgramExtension(false), - ARBShadingLanguage100Extension(false), SeparateStencilExtension(false), - GenerateMipmapExtension(false), TextureCompressionExtension(false), - TextureNPOTExtension(false), FramebufferObjectExtension(false), EXTPackedDepthStencil(false), - RenderTargetTexture(0), LastSetLight(-1), MaxAnisotropy(1), - MaxTextureUnits(1), MaxLights(1), CurrentRendertargetSize(0,0) -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - ,pGlActiveTextureARB(0), pGlClientActiveTextureARB(0), - pGlGenProgramsARB(0), pGlBindProgramARB(0), pGlProgramStringARB(0), - pGlDeleteProgramsARB(0), pGlProgramLocalParameter4fvARB(0) - #ifdef PFNGLCOMPRESSEDTEXIMAGE2DPROC - ,pGlCompressedTexImage2D(0) - #endif -#ifdef GLX_SGI_swap_control - ,glxSwapIntervalSGI(0) -#endif - ,pGlBindFramebufferEXT(0), pGlDeleteFramebuffersEXT(0), pGlGenFramebuffersEXT(0), - pGlCheckFramebufferStatusEXT(0), pGlFramebufferTexture2DEXT(0), - pGlBindRenderbufferEXT(0), pGlDeleteRenderbuffersEXT(0), pGlGenRenderbuffersEXT(0), - pGlRenderbufferStorageEXT(0), pGlFramebufferRenderbufferEXT(0) -#endif + AntiAlias(antiAlias), + RenderTargetTexture(0), LastSetLight(-1), + CurrentRendertargetSize(0,0) { #ifdef _DEBUG setDebugName("COpenGLDriver"); @@ -273,7 +187,7 @@ COpenGLDriver::COpenGLDriver(const core::dimension2d& screenSize, bool full XDisplay = glXGetCurrentDisplay(); ExposedData.OpenGLLinux.X11Display = XDisplay; ExposedData.OpenGLLinux.X11Window = XWindow; - genericDriverInit(screenSize); + genericDriverInit(screenSize, stencilBuffer); // set vsync #ifdef GLX_SGI_swap_control @@ -287,12 +201,6 @@ COpenGLDriver::COpenGLDriver(const core::dimension2d& screenSize, bool full #endif } -//! linux destructor -COpenGLDriver::~COpenGLDriver() -{ - deleteAllTextures(); -} - #endif // _IRR_USE_LINUX_DEVICE_ @@ -302,51 +210,52 @@ COpenGLDriver::~COpenGLDriver() #ifdef _IRR_USE_SDL_DEVICE_ //! SDL constructor and init code COpenGLDriver::COpenGLDriver(const core::dimension2d& screenSize, bool fullscreen, bool stencilBuffer, io::IFileSystem* io, bool vsync, bool antiAlias) -: CNullDriver(io, screenSize), +: CNullDriver(io, screenSize), COpenGLExtensionHandler(), CurrentRenderMode(ERM_NONE), ResetRenderStates(true), Transformation3DChanged(true), - StencilBuffer(stencilBuffer), AntiAlias(antiAlias), - MultiTextureExtension(false), MultiSamplingExtension(false), AnisotropyExtension(false), - ARBVertexProgramExtension(false), ARBFragmentProgramExtension(false), - ARBShadingLanguage100Extension(false), SeparateStencilExtension(false), - GenerateMipmapExtension(false), TextureCompressionExtension(false), - TextureNPOTExtension(false), FramebufferObjectExtension(false), EXTPackedDepthStencil(false), - RenderTargetTexture(0), LastSetLight(-1), MaxAnisotropy(1), - MaxTextureUnits(1), MaxLights(1), CurrentRendertargetSize(0,0) -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - ,pGlActiveTextureARB(0), pGlClientActiveTextureARB(0), - pGlGenProgramsARB(0), pGlBindProgramARB(0), pGlProgramStringARB(0), - pGlDeleteProgramsARB(0), pGlProgramLocalParameter4fvARB(0) - #ifdef PFNGLCOMPRESSEDTEXIMAGE2DPROC - ,pGlCompressedTexImage2D(0) - #endif - ,pGlBindFramebufferEXT(0), pGlDeleteFramebuffersEXT(0), pGlGenFramebuffersEXT(0), - pGlCheckFramebufferStatusEXT(0), pGlFramebufferTexture2DEXT(0), - pGlBindRenderbufferEXT(0), pGlDeleteRenderbuffersEXT(0), pGlGenRenderbuffersEXT(0), - pGlRenderbufferStorageEXT(0), pGlFramebufferRenderbufferEXT(0) -#endif + AntiAlias(antiAlias), + RenderTargetTexture(0), LastSetLight(-1), + CurrentRendertargetSize(0,0) { #ifdef _DEBUG setDebugName("COpenGLDriver"); #endif - genericDriverInit(screenSize); -} - -//! SDL destructor -COpenGLDriver::~COpenGLDriver() -{ - deleteAllTextures(); + genericDriverInit(screenSize, stencilBuffer); } #endif // _IRR_USE_SDL_DEVICE_ +//! destructor +COpenGLDriver::~COpenGLDriver() +{ + deleteMaterialRenders(); + + // I get a blue screen on my laptop, when I do not delete the + // textures manually before releasing the dc. Oh how I love this. + + deleteAllTextures(); + +#ifdef _IRR_USE_WINDOWS_DEVICE_ + if (HRc) + { + if (!wglMakeCurrent(0, 0)) + os::Printer::log("Release of dc and rc failed.", ELL_WARNING); + + if (!wglDeleteContext(HRc)) + os::Printer::log("Release of rendering context failed.", ELL_WARNING); + } + + if (HDc) + ReleaseDC(Window, HDc); +#endif +} // ----------------------------------------------------------------------- // METHODS // ----------------------------------------------------------------------- -bool COpenGLDriver::genericDriverInit(const core::dimension2d& screenSize) +bool COpenGLDriver::genericDriverInit(const core::dimension2d& screenSize, bool stencilBuffer) { Name=L"OpenGL "; Name.append(glGetString(GL_VERSION)); @@ -359,19 +268,17 @@ bool COpenGLDriver::genericDriverInit(const core::dimension2d& screenSize) const GLubyte* renderer = glGetString(GL_RENDERER); const GLubyte* vendor = glGetString(GL_VENDOR); if (renderer && vendor) - { os::Printer::log((const c8*)renderer, (const c8*)vendor, ELL_INFORMATION); - } for (u32 i=0; i= 1.2) - os::Printer::log("OpenGL driver version is 1.2 or better.", ELL_INFORMATION); - else - os::Printer::log("OpenGL driver version is not 1.2 or better.", ELL_WARNING); - - const GLubyte* t = glGetString(GL_EXTENSIONS); -// os::Printer::log((const c8*)t, ELL_INFORMATION); - #ifdef GLU_VERSION_1_3 - const GLubyte* gluVersion = gluGetString(GLU_VERSION); - - if (gluVersion[0]>1 || gluVersion[3]>2) - { - MultiTextureExtension = gluCheckExtension((const GLubyte*)"GL_ARB_multitexture", t); - MultiSamplingExtension = gluCheckExtension((const GLubyte*)"GL_ARB_multisample", t); - ARBVertexProgramExtension = gluCheckExtension((const GLubyte*)"GL_ARB_vertex_program", t); - ARBFragmentProgramExtension = gluCheckExtension((const GLubyte*)"GL_ARB_fragment_program", t); - ARBShadingLanguage100Extension = gluCheckExtension((const GLubyte*)"GL_ARB_shading_language_100", t); - AnisotropyExtension = gluCheckExtension((const GLubyte*)"GL_EXT_texture_filter_anisotropic", t); - SeparateStencilExtension = gluCheckExtension((const GLubyte*)"GL_ATI_separate_stencil", t); - SeparateStencilExtension = SeparateStencilExtension || gluCheckExtension((const GLubyte*)"GL_ARB_separate_stencil", t); - GenerateMipmapExtension = gluCheckExtension((const GLubyte*)"GL_SGIS_generate_mipmap", t); - TextureCompressionExtension = gluCheckExtension((const GLubyte*)"GL_ARB_texture_compression", t); - TextureNPOTExtension = gluCheckExtension((const GLubyte*)"GL_ARB_texture_non_power_of_two", t); - FramebufferObjectExtension = gluCheckExtension((const GLubyte*)"GL_EXT_framebuffer_object", t); - EXTPackedDepthStencil = gluCheckExtension((const GLubyte*)"GL_EXT_packed_depth_stencil", t); - EXTSeparateSpecularColor = gluCheckExtension((const GLubyte*)"GL_EXT_separate_specular_color", t); - } - else - #endif - { - s32 len = (s32)strlen((const char*)t); - c8 *str = new c8[len+1]; - c8* p = str; - - for (s32 i=0; i(x)) - #else - // Accessing the correct function is quite complex - // All libraries should support the ARB version, however - // since GLX 1.4 the non-ARB version is the official one - // So we have to check the runtime environment and - // choose the proper symbol - // In case you still have problems please enable the - // next line by uncommenting it - // #define _IRR_GETPROCADDRESS_WORKAROUND_ - - #ifndef _IRR_GETPROCADDRESS_WORKAROUND_ - __GLXextFuncPtr (*IRR_OGL_LOAD_EXTENSION)(const GLubyte*)=0; - #ifdef GLX_VERSION_1_4 - int major,minor; - glXQueryVersion(XDisplay, &major, &minor); - if ((major>1) || (minor>3)) - IRR_OGL_LOAD_EXTENSION=glXGetProcAddress; - else - #endif - IRR_OGL_LOAD_EXTENSION=glXGetProcAddressARB; - #else - #define IRR_OGL_LOAD_EXTENSION glXGetProcAddressARB - #endif - #endif - - pGlActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glActiveTextureARB")); - - pGlClientActiveTextureARB = (PFNGLCLIENTACTIVETEXTUREARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glClientActiveTextureARB")); - - // get fragment and vertex program function pointers - pGlGenProgramsARB = (PFNGLGENPROGRAMSARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glGenProgramsARB")); - - pGlBindProgramARB = (PFNGLBINDPROGRAMARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glBindProgramARB")); - - pGlProgramStringARB = (PFNGLPROGRAMSTRINGARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glProgramStringARB")); - - pGlDeleteProgramsARB = (PFNGLDELETEPROGRAMSNVPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glDeleteProgramsARB")); - - pGlProgramLocalParameter4fvARB = (PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glProgramLocalParameter4fvARB")); - - pGlCreateShaderObjectARB = (PFNGLCREATESHADEROBJECTARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glCreateShaderObjectARB")); - - pGlShaderSourceARB = (PFNGLSHADERSOURCEARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glShaderSourceARB")); - - pGlCompileShaderARB = (PFNGLCOMPILESHADERARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glCompileShaderARB")); - - pGlCreateProgramObjectARB = (PFNGLCREATEPROGRAMOBJECTARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glCreateProgramObjectARB")); - - pGlAttachObjectARB = (PFNGLATTACHOBJECTARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glAttachObjectARB")); - - pGlLinkProgramARB = (PFNGLLINKPROGRAMARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glLinkProgramARB")); - - pGlUseProgramObjectARB = (PFNGLUSEPROGRAMOBJECTARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glUseProgramObjectARB")); - - pGlDeleteObjectARB = (PFNGLDELETEOBJECTARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glDeleteObjectARB")); - - pGlGetInfoLogARB = (PFNGLGETINFOLOGARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glGetInfoLogARB")); - - pGlGetObjectParameterivARB = (PFNGLGETOBJECTPARAMETERIVARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glGetObjectParameterivARB")); - - pGlGetUniformLocationARB = (PFNGLGETUNIFORMLOCATIONARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glGetUniformLocationARB")); - - pGlUniform4fvARB = (PFNGLUNIFORM4FVARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glUniform4fvARB")); - - pGlUniform1ivARB = (PFNGLUNIFORM1IVARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glUniform1ivARB")); - - pGlUniform1fvARB = (PFNGLUNIFORM1FVARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glUniform1fvARB")); - - pGlUniform2fvARB = (PFNGLUNIFORM2FVARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glUniform2fvARB")); - - pGlUniform3fvARB = (PFNGLUNIFORM3FVARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glUniform3fvARB")); - - pGlUniform4fvARB = (PFNGLUNIFORM4FVARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glUniform4fvARB")); - - pGlUniformMatrix2fvARB = (PFNGLUNIFORMMATRIX2FVARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glUniformMatrix2fvARB")); - - pGlUniformMatrix3fvARB = (PFNGLUNIFORMMATRIX3FVARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glUniformMatrix3fvARB")); - - pGlUniformMatrix4fvARB = (PFNGLUNIFORMMATRIX4FVARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glUniformMatrix4fvARB")); - - pGlGetActiveUniformARB = (PFNGLGETACTIVEUNIFORMARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glGetActiveUniformARB")); - - // get point parameter extension - pGlPointParameterfARB = (PFNGLPOINTPARAMETERFARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glPointParameterfARB")); - pGlPointParameterfvARB = (PFNGLPOINTPARAMETERFVARBPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glPointParameterfvARB")); - - // get stencil extension - pGlStencilFuncSeparate = (PFNGLSTENCILFUNCSEPARATEPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glStencilFuncSeparate")); - pGlStencilOpSeparate = (PFNGLSTENCILOPSEPARATEPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glStencilOpSeparate")); - pGlStencilFuncSeparateATI = (PFNGLSTENCILFUNCSEPARATEATIPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glStencilFuncSeparateATI")); - pGlStencilOpSeparateATI = (PFNGLSTENCILOPSEPARATEATIPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glStencilOpSeparateATI")); - - #ifdef PFNGLCOMPRESSEDTEXIMAGE2DPROC - pGlCompressedTexImage2D = (PFNGLCOMPRESSEDTEXIMAGE2DPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glCompressedTexImage2D")); - #endif - -#if defined(GLX_SGI_swap_control) && !defined(_IRR_USE_SDL_DEVICE_) - // get vsync extension - glxSwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC)IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glXSwapIntervalSGI")); -#endif - - // FrameBufferObjects - pGlBindFramebufferEXT = (PFNGLBINDFRAMEBUFFEREXTPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glBindFramebufferEXT")); - - pGlDeleteFramebuffersEXT = (PFNGLDELETEFRAMEBUFFERSEXTPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glDeleteFramebuffersEXT")); - - pGlGenFramebuffersEXT = (PFNGLGENFRAMEBUFFERSEXTPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glGenFramebuffersEXT")); - - pGlCheckFramebufferStatusEXT = (PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glCheckFramebufferStatusEXT")); - - pGlFramebufferTexture2DEXT = (PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glFramebufferTexture2DEXT")); - - pGlBindRenderbufferEXT = (PFNGLBINDRENDERBUFFEREXTPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glBindRenderbufferEXT")); - - pGlDeleteRenderbuffersEXT = (PFNGLDELETERENDERBUFFERSEXTPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glDeleteRenderbuffersEXT")); - - pGlGenRenderbuffersEXT = (PFNGLGENRENDERBUFFERSEXTPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glGenRenderbuffersEXT")); - - pGlRenderbufferStorageEXT = (PFNGLRENDERBUFFERSTORAGEEXTPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glRenderbufferStorageEXT")); - - pGlFramebufferRenderbufferEXT = (PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) - IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glFramebufferRenderbufferEXT")); - - #endif // _IRR_OPENGL_USE_EXTPOINTER_ - #endif // _IRR_WINDOWS_API_ - - // load common extensions - - glGetIntegerv(GL_MAX_TEXTURE_UNITS, &MaxTextureUnits); - glGetIntegerv(GL_MAX_LIGHTS, &MaxLights); - glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &MaxAnisotropy); - } - -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (!pGlActiveTextureARB || !pGlClientActiveTextureARB) - { - MultiTextureExtension = false; - os::Printer::log("Failed to load OpenGL's multitexture extension, proceeding without.", ELL_WARNING); - } - else -#endif - if (MaxTextureUnits < 2) - { - MultiTextureExtension = false; - os::Printer::log("Warning: OpenGL device only has one texture unit. Disabling multitexturing.", ELL_WARNING); - } - MaxTextureUnits = core::min_((u32)MaxTextureUnits,MATERIAL_MAX_TEXTURES); - glGetIntegerv(GL_MAX_ELEMENTS_INDICES, &MaxIndices); -} - - //! presents the rendered scene on the screen, returns false if failed bool COpenGLDriver::endScene( s32 windowId, core::rect* sourceRect ) @@ -1489,41 +1038,6 @@ void COpenGLDriver::draw2DLine(const core::position2d& start, -//! queries the features of the driver, returns true if feature is available -bool COpenGLDriver::queryFeature(E_VIDEO_DRIVER_FEATURE feature) -{ - switch (feature) - { - case EVDF_RENDER_TO_TARGET: - return true; - case EVDF_MULTITEXTURE: - return MultiTextureExtension; - case EVDF_BILINEAR_FILTER: - return true; - case EVDF_MIP_MAP: - return true; - case EVDF_MIP_MAP_AUTO_UPDATE: - return GenerateMipmapExtension; - case EVDF_STENCIL_BUFFER: - return StencilBuffer; - case EVDF_ARB_VERTEX_PROGRAM_1: - return ARBVertexProgramExtension; - case EVDF_ARB_FRAGMENT_PROGRAM_1: - return ARBFragmentProgramExtension; - case EVDF_ARB_GLSL: - return ARBShadingLanguage100Extension; - case EVDF_TEXTURE_NPOT: - return TextureNPOTExtension; - case EVDF_FRAMEBUFFER_OBJECT: - return FramebufferObjectExtension; - default: - return false; - }; -} - - - -//! sets the current Texture bool COpenGLDriver::setTexture(s32 stage, video::ITexture* texture) { if (stage >= MaxTextureUnits) @@ -1611,8 +1125,6 @@ video::ITexture* COpenGLDriver::createDeviceDependentTexture(IImage* surface, co return new COpenGLTexture(surface, name, this); } - - //! Sets a material. All 3d drawing functions draw geometry now //! using this material. //! \param material: Material to be used from now on. @@ -1740,7 +1252,7 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater if (material.Shininess != 0.0f) { #ifdef GL_EXT_separate_specular_color - if (EXTSeparateSpecularColor) + if (SeparateSpecularColorExtension) glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR); #endif glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, material.Shininess); @@ -1752,7 +1264,7 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater } #ifdef GL_EXT_separate_specular_color else - if (EXTSeparateSpecularColor) + if (SeparateSpecularColorExtension) glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SINGLE_COLOR); #endif @@ -2328,498 +1840,6 @@ E_DRIVER_TYPE COpenGLDriver::getDriverType() -void COpenGLDriver::extGlActiveTextureARB(GLenum texture) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (MultiTextureExtension && pGlActiveTextureARB) - pGlActiveTextureARB(texture); -#else - if (MultiTextureExtension) glActiveTextureARB(texture); -#endif -} - -void COpenGLDriver::extGlClientActiveTextureARB(GLenum texture) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (MultiTextureExtension && pGlClientActiveTextureARB) - pGlClientActiveTextureARB(texture); -#else - if (MultiTextureExtension) glClientActiveTextureARB(texture); -#endif -} - -void COpenGLDriver::extGlGenProgramsARB(GLsizei n, GLuint *programs) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlGenProgramsARB) - pGlGenProgramsARB(n, programs); -#elif defined(GL_ARB_vertex_program) - glGenProgramsARB(n,programs); -#else - os::Printer::log("glGenProgramsARB not supported", ELL_ERROR); -#endif -} - -void COpenGLDriver::extGlBindProgramARB(GLenum target, GLuint program) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlBindProgramARB) - pGlBindProgramARB(target, program); -#elif defined(GL_ARB_vertex_program) - glBindProgramARB(target, program); -#else - os::Printer::log("glBindProgramARB not supported", ELL_ERROR); -#endif -} - -void COpenGLDriver::extGlProgramStringARB(GLenum target, GLenum format, GLsizei len, const GLvoid *string) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlProgramStringARB) - pGlProgramStringARB(target, format, len, string); -#elif defined(GL_ARB_vertex_program) - glProgramStringARB(target,format,len,string); -#else - os::Printer::log("glProgramStringARB not supported", ELL_ERROR); -#endif -} - -void COpenGLDriver::extGlDeleteProgramsARB(GLsizei n, const GLuint *programs) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlDeleteProgramsARB) - pGlDeleteProgramsARB(n, programs); -#elif defined(GL_ARB_vertex_program) - glDeleteProgramsARB(n,programs); -#else - os::Printer::log("glDeleteProgramsARB not supported", ELL_ERROR); -#endif -} - -void COpenGLDriver::extGlProgramLocalParameter4fvARB(GLenum n, GLuint i, const GLfloat * f) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlProgramLocalParameter4fvARB) - pGlProgramLocalParameter4fvARB(n,i,f); -#elif defined(GL_ARB_vertex_program) - glProgramLocalParameter4fvARB(n,i,f); -#else - os::Printer::log("glProgramLocalParameter4fvARB not supported", ELL_ERROR); -#endif -} - -GLhandleARB COpenGLDriver::extGlCreateShaderObjectARB(GLenum shaderType) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlCreateShaderObjectARB) - return pGlCreateShaderObjectARB(shaderType); -#elif defined(GL_ARB_shader_objects) - return glCreateShaderObjectARB(shaderType); -#else - os::Printer::log("glCreateShaderObjectARB not supported", ELL_ERROR); -#endif - return 0; -} - -void COpenGLDriver::extGlShaderSourceARB(GLhandleARB shader, int numOfStrings, const char **strings, int *lenOfStrings) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlShaderSourceARB) - pGlShaderSourceARB(shader, numOfStrings, strings, lenOfStrings); -#elif defined(GL_ARB_shader_objects) - glShaderSourceARB(shader, numOfStrings, strings, (GLint *)lenOfStrings); -#else - os::Printer::log("glShaderSourceARB not supported", ELL_ERROR); -#endif -} - -void COpenGLDriver::extGlCompileShaderARB(GLhandleARB shader) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlCompileShaderARB) - pGlCompileShaderARB(shader); -#elif defined(GL_ARB_shader_objects) - glCompileShaderARB(shader); -#else - os::Printer::log("glCompileShaderARB not supported", ELL_ERROR); -#endif -} - -GLhandleARB COpenGLDriver::extGlCreateProgramObjectARB(void) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlCreateProgramObjectARB) - return pGlCreateProgramObjectARB(); -#elif defined(GL_ARB_shader_objects) - return glCreateProgramObjectARB(); -#else - os::Printer::log("glCreateProgramObjectARB not supported", ELL_ERROR); -#endif - return 0; -} - -void COpenGLDriver::extGlAttachObjectARB(GLhandleARB program, GLhandleARB shader) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlAttachObjectARB) - pGlAttachObjectARB(program, shader); -#elif defined(GL_ARB_shader_objects) - glAttachObjectARB(program, shader); -#else - os::Printer::log("glAttachObjectARB not supported", ELL_ERROR); -#endif -} - -void COpenGLDriver::extGlLinkProgramARB(GLhandleARB program) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlLinkProgramARB) - pGlLinkProgramARB(program); -#elif defined(GL_ARB_shader_objects) - glLinkProgramARB(program); -#else - os::Printer::log("glLinkProgramARB not supported", ELL_ERROR); -#endif -} - -void COpenGLDriver::extGlUseProgramObjectARB(GLhandleARB prog) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlUseProgramObjectARB) - pGlUseProgramObjectARB(prog); -#elif defined(GL_ARB_shader_objects) - glUseProgramObjectARB(prog); -#else - os::Printer::log("glUseProgramObjectARB not supported", ELL_ERROR); -#endif -} - -void COpenGLDriver::extGlDeleteObjectARB(GLhandleARB object) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlDeleteObjectARB) - pGlDeleteObjectARB(object); -#elif defined(GL_ARB_shader_objects) - glDeleteObjectARB(object); -#else - os::Printer::log("gldeleteObjectARB not supported", ELL_ERROR); -#endif -} - -void COpenGLDriver::extGlGetInfoLogARB(GLhandleARB object, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlGetInfoLogARB) - pGlGetInfoLogARB(object, maxLength, length, infoLog); -#elif defined(GL_ARB_shader_objects) - glGetInfoLogARB(object, maxLength, length, infoLog); -#else - os::Printer::log("glGetInfoLogARB not supported", ELL_ERROR); -#endif -} - -void COpenGLDriver::extGlGetObjectParameterivARB(GLhandleARB object, GLenum type, int *param) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlGetObjectParameterivARB) - pGlGetObjectParameterivARB(object, type, param); -#elif defined(GL_ARB_shader_objects) - glGetObjectParameterivARB(object, type, (GLint *)param); -#else - os::Printer::log("glGetObjectParameterivARB not supported", ELL_ERROR); -#endif -} - -GLint COpenGLDriver::extGlGetUniformLocationARB(GLhandleARB program, const char *name) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlGetUniformLocationARB) - return pGlGetUniformLocationARB(program, name); -#elif defined(GL_ARB_shader_objects) - return glGetUniformLocationARB(program, name); -#else - os::Printer::log("glGetUniformLocationARB not supported", ELL_ERROR); -#endif - return 0; -} - -void COpenGLDriver::extGlUniform4fvARB(GLint location, GLsizei count, const GLfloat *v) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlUniform4fvARB) - pGlUniform4fvARB(location, count, v); -#elif defined(GL_ARB_shader_objects) - glUniform4fvARB(location, count, v); -#else - os::Printer::log("glUniform4fvARB not supported", ELL_ERROR); -#endif -} - -void COpenGLDriver::extGlUniform1ivARB (GLint loc, GLsizei count, const GLint *v) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlUniform1ivARB) - pGlUniform1ivARB(loc, count, v); -#elif defined(GL_ARB_shader_objects) - glUniform1ivARB(loc, count, v); -#else - os::Printer::log("glUniform1ivARB not supported", ELL_ERROR); -#endif -} - -void COpenGLDriver::extGlUniform1fvARB (GLint loc, GLsizei count, const GLfloat *v) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlUniform1fvARB) - pGlUniform1fvARB(loc, count, v); -#elif defined(GL_ARB_shader_objects) - glUniform1fvARB(loc, count, v); -#else - os::Printer::log("glUniform1fvARB not supported", ELL_ERROR); -#endif -} - -void COpenGLDriver::extGlUniform2fvARB (GLint loc, GLsizei count, const GLfloat *v) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlUniform2fvARB) - pGlUniform2fvARB(loc, count, v); -#elif defined(GL_ARB_shader_objects) - glUniform2fvARB(loc, count, v); -#else - os::Printer::log("glUniform2fvARB not supported", ELL_ERROR); -#endif -} - -void COpenGLDriver::extGlUniform3fvARB (GLint loc, GLsizei count, const GLfloat *v) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlUniform3fvARB) - pGlUniform3fvARB(loc, count, v); -#elif defined(GL_ARB_shader_objects) - glUniform3fvARB(loc, count, v); -#else - os::Printer::log("glUniform3fvARB not supported", ELL_ERROR); -#endif -} - -void COpenGLDriver::extGlUniformMatrix2fvARB (GLint loc, GLsizei count, GLboolean transpose, const GLfloat *v) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlUniformMatrix2fvARB) - pGlUniformMatrix2fvARB(loc, count, transpose, v); -#elif defined(GL_ARB_shader_objects) - glUniformMatrix2fvARB(loc, count, transpose, v); -#else - os::Printer::log("glUniformMatrix2fvARB not supported", ELL_ERROR); -#endif -} - -void COpenGLDriver::extGlUniformMatrix3fvARB (GLint loc, GLsizei count, GLboolean transpose, const GLfloat *v) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlUniformMatrix3fvARB) - pGlUniformMatrix3fvARB(loc, count, transpose, v); -#elif defined(GL_ARB_shader_objects) - glUniformMatrix3fvARB(loc, count, transpose, v); -#else - os::Printer::log("glUniformMatrix3fvARB not supported", ELL_ERROR); -#endif -} - -void COpenGLDriver::extGlUniformMatrix4fvARB (GLint loc, GLsizei count, GLboolean transpose, const GLfloat *v) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlUniformMatrix4fvARB) - pGlUniformMatrix4fvARB(loc, count, transpose, v); -#elif defined(GL_ARB_shader_objects) - glUniformMatrix4fvARB(loc, count, transpose, v); -#else - os::Printer::log("glUniformMatrix4fvARB not supported", ELL_ERROR); -#endif -} - -void COpenGLDriver::extGlGetActiveUniformARB (GLhandleARB program, GLuint index, GLsizei maxlength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlGetActiveUniformARB) - pGlGetActiveUniformARB(program, index, maxlength, length, size, type, name); -#elif defined(GL_ARB_shader_objects) - glGetActiveUniformARB(program, index, maxlength, length, size, type, name); -#else - os::Printer::log("glGetActiveUniformARB not supported", ELL_ERROR); -#endif -} - -void COpenGLDriver::extGlPointParameterfARB (GLint loc, GLfloat f) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlPointParameterfARB) - pGlPointParameterfARB(loc, f); -#else - glPointParameterfARB(loc, f); -#endif -} - -void COpenGLDriver::extGlPointParameterfvARB (GLint loc, const GLfloat *v) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlPointParameterfvARB) - pGlPointParameterfvARB(loc, v); -#else - glPointParameterfvARB(loc, v); -#endif -} - -void COpenGLDriver::extGlStencilFuncSeparate (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlStencilFuncSeparate) - pGlStencilFuncSeparate(frontfunc, backfunc, ref, mask); - else if (pGlStencilFuncSeparateATI) - pGlStencilFuncSeparateATI(frontfunc, backfunc, ref, mask); -#elif defined(GL_VERSION_2_0) - glStencilFuncSeparate(frontfunc, backfunc, ref, mask); -#elif defined(GL_ATI_separate_stencil) - glStencilFuncSeparateATI(frontfunc, backfunc, ref, mask); -#else - os::Printer::log("glStencilFuncSeparate not supported", ELL_ERROR); -#endif -} - -void COpenGLDriver::extGlStencilOpSeparate (GLenum face, GLenum fail, GLenum zfail, GLenum zpass) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlStencilOpSeparate) - pGlStencilOpSeparate(face, fail, zfail, zpass); - else if (pGlStencilOpSeparateATI) - pGlStencilOpSeparateATI(face, fail, zfail, zpass); -#elif defined(GL_VERSION_2_0) - glStencilOpSeparate(face, fail, zfail, zpass); -#elif defined(GL_ATI_separate_stencil) - glStencilOpSeparateATI(face, fail, zfail, zpass); -#else - os::Printer::log("glStencilOpSeparate not supported", ELL_ERROR); -#endif -} - -void COpenGLDriver::extGlCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, - GLsizei height, GLint border, GLsizei imageSize, const void* data) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - #ifdef PFNGLCOMPRESSEDTEXIMAGE2DPROC - if (pGlCompressedTexImage2D) - pGlCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data); - #endif -#else - glCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data); -#endif -} - -void COpenGLDriver::extGlBindFramebufferEXT (GLenum target, GLuint framebuffer) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlBindFramebufferEXT) - pGlBindFramebufferEXT(target, framebuffer); -#elif defined(GL_EXT_framebuffer_object) - glBindFramebufferEXT(target, framebuffer); -#endif -} - -void COpenGLDriver::extGlDeleteFramebuffersEXT (GLsizei n, const GLuint *framebuffers) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlDeleteFramebuffersEXT) - pGlDeleteFramebuffersEXT(n, framebuffers); -#elif defined(GL_EXT_framebuffer_object) - glDeleteFramebuffersEXT(n, framebuffers); -#endif -} - -void COpenGLDriver::extGlGenFramebuffersEXT (GLsizei n, GLuint *framebuffers) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlGenFramebuffersEXT) - pGlGenFramebuffersEXT(n, framebuffers); -#elif defined(GL_EXT_framebuffer_object) - glGenFramebuffersEXT(n, framebuffers); -#endif -} - -GLenum COpenGLDriver::extGlCheckFramebufferStatusEXT (GLenum target) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlCheckFramebufferStatusEXT) - return pGlCheckFramebufferStatusEXT(target); - else - return 0; -#elif defined(GL_EXT_framebuffer_object) - return glCheckFramebufferStatusEXT(target); -#else - return 0; -#endif -} - -void COpenGLDriver::extGlFramebufferTexture2DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlFramebufferTexture2DEXT) - pGlFramebufferTexture2DEXT(target, attachment, textarget, texture, level); -#elif defined(GL_EXT_framebuffer_object) - glFramebufferTexture2DEXT(target, attachment, textarget, texture, level); -#endif -} - -void COpenGLDriver::extGlBindRenderbufferEXT (GLenum target, GLuint renderbuffer) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlBindRenderbufferEXT) - pGlBindRenderbufferEXT(target, renderbuffer); -#elif defined(GL_EXT_framebuffer_object) - glBindRenderbufferEXT(target, renderbuffer); -#endif -} - -void COpenGLDriver::extGlDeleteRenderbuffersEXT (GLsizei n, const GLuint *renderbuffers) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlDeleteRenderbuffersEXT) - pGlDeleteRenderbuffersEXT(n, renderbuffers); -#elif defined(GL_EXT_framebuffer_object) - glDeleteRenderbuffersEXT(n, renderbuffers); -#endif -} - -void COpenGLDriver::extGlGenRenderbuffersEXT (GLsizei n, GLuint *renderbuffers) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlGenRenderbuffersEXT) - pGlGenRenderbuffersEXT(n, renderbuffers); -#elif defined(GL_EXT_framebuffer_object) - glGenRenderbuffersEXT(n, renderbuffers); -#endif -} - -void COpenGLDriver::extGlRenderbufferStorageEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlRenderbufferStorageEXT) - pGlRenderbufferStorageEXT(target, internalformat, width, height); -#elif defined(GL_EXT_framebuffer_object) - glRenderbufferStorageEXT(target, internalformat, width, height); -#endif -} - -void COpenGLDriver::extGlFramebufferRenderbufferEXT (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) -{ -#ifdef _IRR_OPENGL_USE_EXTPOINTER_ - if (pGlFramebufferRenderbufferEXT) - pGlFramebufferRenderbufferEXT(target, attachment, renderbuffertarget, renderbuffer); -#elif defined(GL_EXT_framebuffer_object) - glFramebufferRenderbufferEXT(target, attachment, renderbuffertarget, renderbuffer); -#endif -} - //! Sets a vertex shader constant. void COpenGLDriver::setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount) { @@ -2915,8 +1935,8 @@ ITexture* COpenGLDriver::createRenderTargetTexture(const core::dimension2d& video::ITexture* rtt = 0; #if defined(GL_EXT_framebuffer_object) // if driver supports FrameBufferObjects, use them - if (FramebufferObjectExtension) - rtt = new COpenGLTexture(size, EXTPackedDepthStencil, "rt", this); + if (queryFeature(EVDF_FRAMEBUFFER_OBJECT)) + rtt = new COpenGLTexture(size, PackedDepthStencilExtension, "rt", this); else #endif { @@ -3095,7 +2115,7 @@ IVideoDriver* createOpenGLDriver(const core::dimension2d& screenSize, { #ifdef _IRR_COMPILE_WITH_OPENGL_ COpenGLDriver* ogl = new COpenGLDriver(screenSize, window, fullscreen, stencilBuffer, io, antiAlias); - if (!ogl->initDriver(screenSize, window, bits, fullscreen, vsync)) + if (!ogl->initDriver(screenSize, window, bits, fullscreen, vsync, stencilBuffer)) { ogl->drop(); ogl = 0; diff --git a/source/Irrlicht/COpenGLDriver.h b/source/Irrlicht/COpenGLDriver.h index 4925ad10..8c8e44aa 100644 --- a/source/Irrlicht/COpenGLDriver.h +++ b/source/Irrlicht/COpenGLDriver.h @@ -8,6 +8,7 @@ #include "IrrCompileConfig.h" #include "CNullDriver.h" #include "IMaterialRendererServices.h" +#include "COpenGLExtensionHandler.h" #ifdef _IRR_COMPILE_WITH_OPENGL_ @@ -63,7 +64,7 @@ namespace video { class COpenGLTexture; - class COpenGLDriver : public CNullDriver, public IMaterialRendererServices + class COpenGLDriver : public CNullDriver, public IMaterialRendererServices, public COpenGLExtensionHandler { public: @@ -108,7 +109,10 @@ namespace video void drawVertexPrimitiveList(const void* vertices, u32 vertexCount, const u16* indexList, u32 primitiveCount, E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType); //! queries the features of the driver, returns true if feature is available - bool queryFeature(E_VIDEO_DRIVER_FEATURE feature); + bool queryFeature(E_VIDEO_DRIVER_FEATURE feature) + { + return COpenGLExtensionHandler::queryFeature(feature); + } //! Sets a material. All 3d drawing functions draw geometry now //! using this material. @@ -217,54 +221,6 @@ namespace video //! Returns the transformation set by setTransform virtual const core::matrix4& getTransform(E_TRANSFORMATION_STATE state); - // public access to the (loaded) extensions. - void extGlActiveTextureARB(GLenum texture); - void extGlClientActiveTextureARB(GLenum texture); - void extGlGenProgramsARB(GLsizei n, GLuint *programs); - void extGlBindProgramARB(GLenum target, GLuint program); - void extGlProgramStringARB(GLenum target, GLenum format, GLsizei len, const GLvoid *string); - void extGlDeleteProgramsARB(GLsizei n, const GLuint *programs); - void extGlProgramLocalParameter4fvARB(GLenum, GLuint, const GLfloat *); - GLhandleARB extGlCreateShaderObjectARB(GLenum shaderType); - void extGlShaderSourceARB(GLhandleARB shader, int numOfStrings, const char **strings, int *lenOfStrings); - void extGlCompileShaderARB(GLhandleARB shader); - GLhandleARB extGlCreateProgramObjectARB(void); - void extGlAttachObjectARB(GLhandleARB program, GLhandleARB shader); - void extGlLinkProgramARB(GLhandleARB program); - void extGlUseProgramObjectARB(GLhandleARB prog); - void extGlDeleteObjectARB(GLhandleARB object); - void extGlGetInfoLogARB(GLhandleARB object, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); - void extGlGetObjectParameterivARB(GLhandleARB object, GLenum type, int *param); - GLint extGlGetUniformLocationARB(GLhandleARB program, const char *name); - void extGlUniform4fvARB(GLint location, GLsizei count, const GLfloat *v); - - void extGlUniform1ivARB (GLint loc, GLsizei count, const GLint *v); - void extGlUniform1fvARB (GLint loc, GLsizei count, const GLfloat *v); - void extGlUniform2fvARB (GLint loc, GLsizei count, const GLfloat *v); - void extGlUniform3fvARB (GLint loc, GLsizei count, const GLfloat *v); - void extGlUniformMatrix2fvARB (GLint loc, GLsizei count, GLboolean transpose, const GLfloat *v); - void extGlUniformMatrix3fvARB (GLint loc, GLsizei count, GLboolean transpose, const GLfloat *v); - void extGlUniformMatrix4fvARB (GLint loc, GLsizei count, GLboolean transpose, const GLfloat *v); - void extGlGetActiveUniformARB (GLhandleARB program, GLuint index, GLsizei maxlength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); - void extGlPointParameterfARB (GLint loc, GLfloat f); - void extGlPointParameterfvARB (GLint loc, const GLfloat *v); - void extGlStencilFuncSeparate (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); - void extGlStencilOpSeparate (GLenum face, GLenum fail, GLenum zfail, GLenum zpass); - void extGlCompressedTexImage2D(GLenum target, GLint level, - GLenum internalformat, GLsizei width, GLsizei height, - GLint border, GLsizei imageSize, const void* data); - - void extGlBindFramebufferEXT (GLenum target, GLuint framebuffer); - void extGlDeleteFramebuffersEXT (GLsizei n, const GLuint *framebuffers); - void extGlGenFramebuffersEXT (GLsizei n, GLuint *framebuffers); - GLenum extGlCheckFramebufferStatusEXT (GLenum target); - void extGlFramebufferTexture2DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); - void extGlBindRenderbufferEXT (GLenum target, GLuint renderbuffer); - void extGlDeleteRenderbuffersEXT (GLsizei n, const GLuint *renderbuffers); - void extGlGenRenderbuffersEXT (GLsizei n, GLuint *renderbuffers); - void extGlRenderbufferStorageEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); - void extGlFramebufferRenderbufferEXT (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); - //! Can be called by an IMaterialRenderer to make its work easier. void setBasicRenderStates(const SMaterial& material, const SMaterial& lastmaterial, bool resetAllRenderstates); @@ -330,7 +286,7 @@ namespace video private: //! inits the parts of the open gl driver used on all platforms - bool genericDriverInit(const core::dimension2d& screenSize); + bool genericDriverInit(const core::dimension2d& screenSize, bool stencilBuffer); //! returns a device dependent texture from a software surface (IImage) virtual video::ITexture* createDeviceDependentTexture(IImage* surface, const char* name); @@ -338,7 +294,6 @@ namespace video void createGLMatrix(GLfloat gl_matrix[16], const core::matrix4& m); void createGLTextureMatrix(GLfloat gl_matrix[16], const core::matrix4& m); - //! sets the needed renderstates void setRenderStates3DMode(); @@ -348,14 +303,13 @@ namespace video // returns the current size of the screen or rendertarget core::dimension2d getCurrentRenderTargetSize(); - void loadExtensions(); void createMaterialRenderers(); core::stringw Name; core::matrix4 Matrices[ETS_COUNT]; core::array ColorBuffer; - // enumeration for rendering modes such as 2d and 3d for minizing the switching of renderStates. + //! enumeration for rendering modes such as 2d and 3d for minizing the switching of renderStates. enum E_RENDER_MODE { ERM_NONE = 0, // no render state has been set yet. @@ -364,93 +318,18 @@ namespace video }; E_RENDER_MODE CurrentRenderMode; - bool ResetRenderStates; // bool to make all renderstates be reseted if set. + //! bool to make all renderstates reset if set to true. + bool ResetRenderStates; bool Transformation3DChanged; - bool StencilBuffer; bool AntiAlias; - bool MultiTextureExtension; - bool MultiSamplingExtension; - bool AnisotropyExtension; - bool ARBVertexProgramExtension; //GL_ARB_vertex_program - bool ARBFragmentProgramExtension; //GL_ARB_fragment_program - bool ARBShadingLanguage100Extension; - bool SeparateStencilExtension; - bool GenerateMipmapExtension; - bool TextureCompressionExtension; - bool TextureNPOTExtension; - bool FramebufferObjectExtension; - bool EXTPackedDepthStencil; - bool EXTSeparateSpecularColor; SMaterial Material, LastMaterial; COpenGLTexture* RenderTargetTexture; ITexture* CurrentTexture[MATERIAL_MAX_TEXTURES]; s32 LastSetLight; - f32 MaxAnisotropy; - - GLint MaxTextureUnits; - GLint MaxLights; - GLint MaxIndices; core::dimension2d CurrentRendertargetSize; - #if defined(_IRR_OPENGL_USE_EXTPOINTER_) - PFNGLACTIVETEXTUREARBPROC pGlActiveTextureARB; - PFNGLCLIENTACTIVETEXTUREARBPROC pGlClientActiveTextureARB; - PFNGLGENPROGRAMSARBPROC pGlGenProgramsARB; - PFNGLBINDPROGRAMARBPROC pGlBindProgramARB; - PFNGLPROGRAMSTRINGARBPROC pGlProgramStringARB; - PFNGLDELETEPROGRAMSNVPROC pGlDeleteProgramsARB; - PFNGLPROGRAMLOCALPARAMETER4FVARBPROC pGlProgramLocalParameter4fvARB; - PFNGLCREATESHADEROBJECTARBPROC pGlCreateShaderObjectARB; - PFNGLSHADERSOURCEARBPROC pGlShaderSourceARB; - PFNGLCOMPILESHADERARBPROC pGlCompileShaderARB; - PFNGLCREATEPROGRAMOBJECTARBPROC pGlCreateProgramObjectARB; - PFNGLATTACHOBJECTARBPROC pGlAttachObjectARB; - PFNGLLINKPROGRAMARBPROC pGlLinkProgramARB; - PFNGLUSEPROGRAMOBJECTARBPROC pGlUseProgramObjectARB; - PFNGLDELETEOBJECTARBPROC pGlDeleteObjectARB; - PFNGLGETINFOLOGARBPROC pGlGetInfoLogARB; - PFNGLGETOBJECTPARAMETERIVARBPROC pGlGetObjectParameterivARB; - PFNGLGETUNIFORMLOCATIONARBPROC pGlGetUniformLocationARB; - PFNGLUNIFORM1IVARBPROC pGlUniform1ivARB; - PFNGLUNIFORM1FVARBPROC pGlUniform1fvARB; - PFNGLUNIFORM2FVARBPROC pGlUniform2fvARB; - PFNGLUNIFORM3FVARBPROC pGlUniform3fvARB; - PFNGLUNIFORM4FVARBPROC pGlUniform4fvARB; - PFNGLUNIFORMMATRIX2FVARBPROC pGlUniformMatrix2fvARB; - PFNGLUNIFORMMATRIX3FVARBPROC pGlUniformMatrix3fvARB; - PFNGLUNIFORMMATRIX4FVARBPROC pGlUniformMatrix4fvARB; - PFNGLGETACTIVEUNIFORMARBPROC pGlGetActiveUniformARB; - PFNGLPOINTPARAMETERFARBPROC pGlPointParameterfARB; - PFNGLPOINTPARAMETERFVARBPROC pGlPointParameterfvARB; - #ifdef GL_ATI_separate_stencil - PFNGLSTENCILFUNCSEPARATEPROC pGlStencilFuncSeparate; - PFNGLSTENCILOPSEPARATEPROC pGlStencilOpSeparate; - PFNGLSTENCILFUNCSEPARATEATIPROC pGlStencilFuncSeparateATI; - PFNGLSTENCILOPSEPARATEATIPROC pGlStencilOpSeparateATI; - #endif - #ifdef PFNGLCOMPRESSEDTEXIMAGE2DPROC - PFNGLCOMPRESSEDTEXIMAGE2DPROC pGlCompressedTexImage2D; - #endif // PFNGLCOMPRESSEDTEXIMAGE2DPROC - #ifdef _IRR_WINDOWS_API_ - typedef BOOL (APIENTRY *PFNWGLSWAPINTERVALFARPROC)(int); - PFNWGLSWAPINTERVALFARPROC wglSwapIntervalEXT; - #elif defined(_IRR_LINUX_PLATFORM_) && defined(GLX_SGI_swap_control) - PFNGLXSWAPINTERVALSGIPROC glxSwapIntervalSGI; - #endif - PFNGLBINDFRAMEBUFFEREXTPROC pGlBindFramebufferEXT; - PFNGLDELETEFRAMEBUFFERSEXTPROC pGlDeleteFramebuffersEXT; - PFNGLGENFRAMEBUFFERSEXTPROC pGlGenFramebuffersEXT; - PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC pGlCheckFramebufferStatusEXT; - PFNGLFRAMEBUFFERTEXTURE2DEXTPROC pGlFramebufferTexture2DEXT; - PFNGLBINDRENDERBUFFEREXTPROC pGlBindRenderbufferEXT; - PFNGLDELETERENDERBUFFERSEXTPROC pGlDeleteRenderbuffersEXT; - PFNGLGENRENDERBUFFERSEXTPROC pGlGenRenderbuffersEXT; - PFNGLRENDERBUFFERSTORAGEEXTPROC pGlRenderbufferStorageEXT; - PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC pGlFramebufferRenderbufferEXT; - #endif - #ifdef _IRR_WINDOWS_API_ HDC HDc; // Private GDI Device Context HWND Window; diff --git a/source/Irrlicht/COpenGLExtensionHandler.cpp b/source/Irrlicht/COpenGLExtensionHandler.cpp new file mode 100644 index 00000000..de18bb97 --- /dev/null +++ b/source/Irrlicht/COpenGLExtensionHandler.cpp @@ -0,0 +1,905 @@ +#include "COpenGLExtensionHandler.h" +#include "os.h" +#include "irrString.h" +#include "SMaterial.h" // for MATERIAL_MAX_TEXTURES + +#include "IrrCompileConfig.h" + +#ifdef _IRR_COMPILE_WITH_OPENGL_ + +namespace irr +{ +namespace video +{ + +COpenGLExtensionHandler::COpenGLExtensionHandler() : + StencilBuffer(false), + MultiTextureExtension(false), MultiSamplingExtension(false), AnisotropyExtension(false), + SeparateStencilExtension(false), + TextureCompressionExtension(false), + PackedDepthStencilExtension(false), + MaxTextureUnits(1), MaxLights(1), MaxIndices(1), + MaxAnisotropy(1), +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + pGlActiveTextureARB(0), pGlClientActiveTextureARB(0), + pGlGenProgramsARB(0), pGlBindProgramARB(0), pGlProgramStringARB(0), + pGlDeleteProgramsARB(0), pGlProgramLocalParameter4fvARB(0), + pGlCreateShaderObjectARB(0), pGlShaderSourceARB(0), + pGlCompileShaderARB(0), pGlCreateProgramObjectARB(0), pGlAttachObjectARB(0), + pGlLinkProgramARB(0), pGlUseProgramObjectARB(0), pGlDeleteObjectARB(0), + pGlGetObjectParameterivARB(0), pGlGetUniformLocationARB(0), + pGlUniform1ivARB(0), pGlUniform1fvARB(0), pGlUniform2fvARB(0), pGlUniform3fvARB(0), pGlUniform4fvARB(0), pGlUniformMatrix2fvARB(0), + pGlUniformMatrix3fvARB(0), pGlUniformMatrix4fvARB(0), pGlGetActiveUniformARB(0), pGlPointParameterfARB(0), pGlPointParameterfvARB(0), + pGlStencilFuncSeparate(0), pGlStencilOpSeparate(0), + pGlStencilFuncSeparateATI(0), pGlStencilOpSeparateATI(0), + #ifdef PFNGLCOMPRESSEDTEXIMAGE2DPROC + pGlCompressedTexImage2D(0), + #endif +#ifdef _IRR_USE_WINDOWS_DEVICE_ + wglSwapIntervalEXT(0), +#elif defined(GLX_SGI_swap_control) + glxSwapIntervalSGI(0), +#endif + pGlBindFramebufferEXT(0), pGlDeleteFramebuffersEXT(0), pGlGenFramebuffersEXT(0), + pGlCheckFramebufferStatusEXT(0), pGlFramebufferTexture2DEXT(0), + pGlBindRenderbufferEXT(0), pGlDeleteRenderbuffersEXT(0), pGlGenRenderbuffersEXT(0), + pGlRenderbufferStorageEXT(0), pGlFramebufferRenderbufferEXT(0) +#endif // _IRR_OPENGL_USE_EXTPOINTER_ +{ + for (u32 i=0; i= 1.2) + os::Printer::log("OpenGL driver version is 1.2 or better.", ELL_INFORMATION); + else + os::Printer::log("OpenGL driver version is not 1.2 or better.", ELL_WARNING); + + const GLubyte* t = glGetString(GL_EXTENSIONS); +// os::Printer::log((const c8*)t, ELL_INFORMATION); + #ifdef GLU_VERSION_1_3 + const GLubyte* gluVersion = gluGetString(GLU_VERSION); + + if (gluVersion[0]>1 || gluVersion[3]>2) + { + for (u32 i=0; i(x)) + #else + // Accessing the correct function is quite complex + // All libraries should support the ARB version, however + // since GLX 1.4 the non-ARB version is the official one + // So we have to check the runtime environment and + // choose the proper symbol + // In case you still have problems please enable the + // next line by uncommenting it + // #define _IRR_GETPROCADDRESS_WORKAROUND_ + + #ifndef _IRR_GETPROCADDRESS_WORKAROUND_ + __GLXextFuncPtr (*IRR_OGL_LOAD_EXTENSION)(const GLubyte*)=0; + #ifdef GLX_VERSION_1_4 + int major,minor; + glXQueryVersion(glXGetCurrentDisplay(), &major, &minor); + if ((major>1) || (minor>3)) + IRR_OGL_LOAD_EXTENSION=glXGetProcAddress; + else + #endif + IRR_OGL_LOAD_EXTENSION=glXGetProcAddressARB; + #else + #define IRR_OGL_LOAD_EXTENSION glXGetProcAddressARB + #endif + #endif + + pGlActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glActiveTextureARB")); + + pGlClientActiveTextureARB = (PFNGLCLIENTACTIVETEXTUREARBPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glClientActiveTextureARB")); + + // get fragment and vertex program function pointers + pGlGenProgramsARB = (PFNGLGENPROGRAMSARBPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glGenProgramsARB")); + + pGlBindProgramARB = (PFNGLBINDPROGRAMARBPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glBindProgramARB")); + + pGlProgramStringARB = (PFNGLPROGRAMSTRINGARBPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glProgramStringARB")); + + pGlDeleteProgramsARB = (PFNGLDELETEPROGRAMSNVPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glDeleteProgramsARB")); + + pGlProgramLocalParameter4fvARB = (PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glProgramLocalParameter4fvARB")); + + pGlCreateShaderObjectARB = (PFNGLCREATESHADEROBJECTARBPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glCreateShaderObjectARB")); + + pGlShaderSourceARB = (PFNGLSHADERSOURCEARBPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glShaderSourceARB")); + + pGlCompileShaderARB = (PFNGLCOMPILESHADERARBPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glCompileShaderARB")); + + pGlCreateProgramObjectARB = (PFNGLCREATEPROGRAMOBJECTARBPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glCreateProgramObjectARB")); + + pGlAttachObjectARB = (PFNGLATTACHOBJECTARBPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glAttachObjectARB")); + + pGlLinkProgramARB = (PFNGLLINKPROGRAMARBPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glLinkProgramARB")); + + pGlUseProgramObjectARB = (PFNGLUSEPROGRAMOBJECTARBPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glUseProgramObjectARB")); + + pGlDeleteObjectARB = (PFNGLDELETEOBJECTARBPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glDeleteObjectARB")); + + pGlGetInfoLogARB = (PFNGLGETINFOLOGARBPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glGetInfoLogARB")); + + pGlGetObjectParameterivARB = (PFNGLGETOBJECTPARAMETERIVARBPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glGetObjectParameterivARB")); + + pGlGetUniformLocationARB = (PFNGLGETUNIFORMLOCATIONARBPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glGetUniformLocationARB")); + + pGlUniform4fvARB = (PFNGLUNIFORM4FVARBPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glUniform4fvARB")); + + pGlUniform1ivARB = (PFNGLUNIFORM1IVARBPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glUniform1ivARB")); + + pGlUniform1fvARB = (PFNGLUNIFORM1FVARBPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glUniform1fvARB")); + + pGlUniform2fvARB = (PFNGLUNIFORM2FVARBPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glUniform2fvARB")); + + pGlUniform3fvARB = (PFNGLUNIFORM3FVARBPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glUniform3fvARB")); + + pGlUniform4fvARB = (PFNGLUNIFORM4FVARBPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glUniform4fvARB")); + + pGlUniformMatrix2fvARB = (PFNGLUNIFORMMATRIX2FVARBPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glUniformMatrix2fvARB")); + + pGlUniformMatrix3fvARB = (PFNGLUNIFORMMATRIX3FVARBPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glUniformMatrix3fvARB")); + + pGlUniformMatrix4fvARB = (PFNGLUNIFORMMATRIX4FVARBPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glUniformMatrix4fvARB")); + + pGlGetActiveUniformARB = (PFNGLGETACTIVEUNIFORMARBPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glGetActiveUniformARB")); + + // get point parameter extension + pGlPointParameterfARB = (PFNGLPOINTPARAMETERFARBPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glPointParameterfARB")); + pGlPointParameterfvARB = (PFNGLPOINTPARAMETERFVARBPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glPointParameterfvARB")); + + // get stencil extension + pGlStencilFuncSeparate = (PFNGLSTENCILFUNCSEPARATEPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glStencilFuncSeparate")); + pGlStencilOpSeparate = (PFNGLSTENCILOPSEPARATEPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glStencilOpSeparate")); + pGlStencilFuncSeparateATI = (PFNGLSTENCILFUNCSEPARATEATIPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glStencilFuncSeparateATI")); + pGlStencilOpSeparateATI = (PFNGLSTENCILOPSEPARATEATIPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glStencilOpSeparateATI")); + + // compressed textures + #ifdef PFNGLCOMPRESSEDTEXIMAGE2DPROC + pGlCompressedTexImage2D = (PFNGLCOMPRESSEDTEXIMAGE2DPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glCompressedTexImage2D")); + #endif + + #if defined(GLX_SGI_swap_control) && !defined(_IRR_USE_SDL_DEVICE_) + // get vsync extension + glxSwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC)IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glXSwapIntervalSGI")); + #endif + + // FrameBufferObjects + pGlBindFramebufferEXT = (PFNGLBINDFRAMEBUFFEREXTPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glBindFramebufferEXT")); + + pGlDeleteFramebuffersEXT = (PFNGLDELETEFRAMEBUFFERSEXTPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glDeleteFramebuffersEXT")); + + pGlGenFramebuffersEXT = (PFNGLGENFRAMEBUFFERSEXTPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glGenFramebuffersEXT")); + + pGlCheckFramebufferStatusEXT = (PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glCheckFramebufferStatusEXT")); + + pGlFramebufferTexture2DEXT = (PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glFramebufferTexture2DEXT")); + + pGlBindRenderbufferEXT = (PFNGLBINDRENDERBUFFEREXTPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glBindRenderbufferEXT")); + + pGlDeleteRenderbuffersEXT = (PFNGLDELETERENDERBUFFERSEXTPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glDeleteRenderbuffersEXT")); + + pGlGenRenderbuffersEXT = (PFNGLGENRENDERBUFFERSEXTPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glGenRenderbuffersEXT")); + + pGlRenderbufferStorageEXT = (PFNGLRENDERBUFFERSTORAGEEXTPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glRenderbufferStorageEXT")); + + pGlFramebufferRenderbufferEXT = (PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) + IRR_OGL_LOAD_EXTENSION(reinterpret_cast("glFramebufferRenderbufferEXT")); + + #endif // _IRR_OPENGL_USE_EXTPOINTER_ +#endif // _IRR_WINDOWS_API_ + + // set some properties + glGetIntegerv(GL_MAX_TEXTURE_UNITS, &MaxTextureUnits); + glGetIntegerv(GL_MAX_LIGHTS, &MaxLights); + glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &MaxAnisotropy); + +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (!pGlActiveTextureARB || !pGlClientActiveTextureARB) + { + MultiTextureExtension = false; +// ExtensionHandler.MultiTextureExtension = false; + os::Printer::log("Failed to load OpenGL's multitexture extension, proceeding without.", ELL_WARNING); + } + else +#endif + if (MaxTextureUnits < 2) + { + MultiTextureExtension = false; +// ExtensionHandler.MultiTextureExtension = false; + os::Printer::log("Warning: OpenGL device only has one texture unit. Disabling multitexturing.", ELL_WARNING); + } + MaxTextureUnits = core::min_((u32)MaxTextureUnits,MATERIAL_MAX_TEXTURES); + glGetIntegerv(GL_MAX_ELEMENTS_INDICES, &MaxIndices); + +} + +bool COpenGLExtensionHandler::queryFeature(E_VIDEO_DRIVER_FEATURE feature) const +{ + switch (feature) + { + case EVDF_RENDER_TO_TARGET: + return true; + case EVDF_MULTITEXTURE: + return MultiTextureExtension; + case EVDF_BILINEAR_FILTER: + return true; + case EVDF_MIP_MAP: + return true; + case EVDF_MIP_MAP_AUTO_UPDATE: + return FeatureAvailable[IRR_SGIS_generate_mipmap]; + case EVDF_STENCIL_BUFFER: + return StencilBuffer; + case EVDF_ARB_VERTEX_PROGRAM_1: + return FeatureAvailable[IRR_ARB_vertex_program]; + case EVDF_ARB_FRAGMENT_PROGRAM_1: + return FeatureAvailable[IRR_ARB_fragment_program]; + case EVDF_ARB_GLSL: + return FeatureAvailable[IRR_ARB_shading_language_100]; + case EVDF_TEXTURE_NPOT: + return FeatureAvailable[IRR_ARB_texture_non_power_of_two]; + case EVDF_FRAMEBUFFER_OBJECT: + return FeatureAvailable[IRR_EXT_framebuffer_object]; + default: + return false; + }; +} + +void COpenGLExtensionHandler::extGlActiveTextureARB(GLenum texture) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (MultiTextureExtension && pGlActiveTextureARB) +// if (ExtensionHandler.MultiTextureExtension && pGlActiveTextureARB) + pGlActiveTextureARB(texture); +#else + if (MultiTextureExtension) glActiveTextureARB(texture); +// if (ExtensionHandler.MultiTextureExtension) glActiveTextureARB(texture); +#endif +} + +void COpenGLExtensionHandler::extGlClientActiveTextureARB(GLenum texture) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (MultiTextureExtension && pGlClientActiveTextureARB) +// if (ExtensionHandler.MultiTextureExtension && pGlClientActiveTextureARB) + pGlClientActiveTextureARB(texture); +#else + if (MultiTextureExtension) glClientActiveTextureARB(texture); +// if (ExtensionHandler.MultiTextureExtension) glClientActiveTextureARB(texture); +#endif +} + +void COpenGLExtensionHandler::extGlGenProgramsARB(GLsizei n, GLuint *programs) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlGenProgramsARB) + pGlGenProgramsARB(n, programs); +#elif defined(GL_ARB_vertex_program) + glGenProgramsARB(n,programs); +#else + os::Printer::log("glGenProgramsARB not supported", ELL_ERROR); +#endif +} + +void COpenGLExtensionHandler::extGlBindProgramARB(GLenum target, GLuint program) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlBindProgramARB) + pGlBindProgramARB(target, program); +#elif defined(GL_ARB_vertex_program) + glBindProgramARB(target, program); +#else + os::Printer::log("glBindProgramARB not supported", ELL_ERROR); +#endif +} + +void COpenGLExtensionHandler::extGlProgramStringARB(GLenum target, GLenum format, GLsizei len, const GLvoid *string) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlProgramStringARB) + pGlProgramStringARB(target, format, len, string); +#elif defined(GL_ARB_vertex_program) + glProgramStringARB(target,format,len,string); +#else + os::Printer::log("glProgramStringARB not supported", ELL_ERROR); +#endif +} + +void COpenGLExtensionHandler::extGlDeleteProgramsARB(GLsizei n, const GLuint *programs) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlDeleteProgramsARB) + pGlDeleteProgramsARB(n, programs); +#elif defined(GL_ARB_vertex_program) + glDeleteProgramsARB(n,programs); +#else + os::Printer::log("glDeleteProgramsARB not supported", ELL_ERROR); +#endif +} + +void COpenGLExtensionHandler::extGlProgramLocalParameter4fvARB(GLenum n, GLuint i, const GLfloat * f) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlProgramLocalParameter4fvARB) + pGlProgramLocalParameter4fvARB(n,i,f); +#elif defined(GL_ARB_vertex_program) + glProgramLocalParameter4fvARB(n,i,f); +#else + os::Printer::log("glProgramLocalParameter4fvARB not supported", ELL_ERROR); +#endif +} + +GLhandleARB COpenGLExtensionHandler::extGlCreateShaderObjectARB(GLenum shaderType) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlCreateShaderObjectARB) + return pGlCreateShaderObjectARB(shaderType); +#elif defined(GL_ARB_shader_objects) + return glCreateShaderObjectARB(shaderType); +#else + os::Printer::log("glCreateShaderObjectARB not supported", ELL_ERROR); +#endif + return 0; +} + +void COpenGLExtensionHandler::extGlShaderSourceARB(GLhandleARB shader, int numOfStrings, const char **strings, int *lenOfStrings) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlShaderSourceARB) + pGlShaderSourceARB(shader, numOfStrings, strings, lenOfStrings); +#elif defined(GL_ARB_shader_objects) + glShaderSourceARB(shader, numOfStrings, strings, (GLint *)lenOfStrings); +#else + os::Printer::log("glShaderSourceARB not supported", ELL_ERROR); +#endif +} + +void COpenGLExtensionHandler::extGlCompileShaderARB(GLhandleARB shader) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlCompileShaderARB) + pGlCompileShaderARB(shader); +#elif defined(GL_ARB_shader_objects) + glCompileShaderARB(shader); +#else + os::Printer::log("glCompileShaderARB not supported", ELL_ERROR); +#endif +} + +GLhandleARB COpenGLExtensionHandler::extGlCreateProgramObjectARB(void) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlCreateProgramObjectARB) + return pGlCreateProgramObjectARB(); +#elif defined(GL_ARB_shader_objects) + return glCreateProgramObjectARB(); +#else + os::Printer::log("glCreateProgramObjectARB not supported", ELL_ERROR); +#endif + return 0; +} + +void COpenGLExtensionHandler::extGlAttachObjectARB(GLhandleARB program, GLhandleARB shader) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlAttachObjectARB) + pGlAttachObjectARB(program, shader); +#elif defined(GL_ARB_shader_objects) + glAttachObjectARB(program, shader); +#else + os::Printer::log("glAttachObjectARB not supported", ELL_ERROR); +#endif +} + +void COpenGLExtensionHandler::extGlLinkProgramARB(GLhandleARB program) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlLinkProgramARB) + pGlLinkProgramARB(program); +#elif defined(GL_ARB_shader_objects) + glLinkProgramARB(program); +#else + os::Printer::log("glLinkProgramARB not supported", ELL_ERROR); +#endif +} + +void COpenGLExtensionHandler::extGlUseProgramObjectARB(GLhandleARB prog) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlUseProgramObjectARB) + pGlUseProgramObjectARB(prog); +#elif defined(GL_ARB_shader_objects) + glUseProgramObjectARB(prog); +#else + os::Printer::log("glUseProgramObjectARB not supported", ELL_ERROR); +#endif +} + +void COpenGLExtensionHandler::extGlDeleteObjectARB(GLhandleARB object) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlDeleteObjectARB) + pGlDeleteObjectARB(object); +#elif defined(GL_ARB_shader_objects) + glDeleteObjectARB(object); +#else + os::Printer::log("gldeleteObjectARB not supported", ELL_ERROR); +#endif +} + +void COpenGLExtensionHandler::extGlGetInfoLogARB(GLhandleARB object, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlGetInfoLogARB) + pGlGetInfoLogARB(object, maxLength, length, infoLog); +#elif defined(GL_ARB_shader_objects) + glGetInfoLogARB(object, maxLength, length, infoLog); +#else + os::Printer::log("glGetInfoLogARB not supported", ELL_ERROR); +#endif +} + +void COpenGLExtensionHandler::extGlGetObjectParameterivARB(GLhandleARB object, GLenum type, int *param) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlGetObjectParameterivARB) + pGlGetObjectParameterivARB(object, type, param); +#elif defined(GL_ARB_shader_objects) + glGetObjectParameterivARB(object, type, (GLint *)param); +#else + os::Printer::log("glGetObjectParameterivARB not supported", ELL_ERROR); +#endif +} + +GLint COpenGLExtensionHandler::extGlGetUniformLocationARB(GLhandleARB program, const char *name) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlGetUniformLocationARB) + return pGlGetUniformLocationARB(program, name); +#elif defined(GL_ARB_shader_objects) + return glGetUniformLocationARB(program, name); +#else + os::Printer::log("glGetUniformLocationARB not supported", ELL_ERROR); +#endif + return 0; +} + +void COpenGLExtensionHandler::extGlUniform4fvARB(GLint location, GLsizei count, const GLfloat *v) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlUniform4fvARB) + pGlUniform4fvARB(location, count, v); +#elif defined(GL_ARB_shader_objects) + glUniform4fvARB(location, count, v); +#else + os::Printer::log("glUniform4fvARB not supported", ELL_ERROR); +#endif +} + +void COpenGLExtensionHandler::extGlUniform1ivARB (GLint loc, GLsizei count, const GLint *v) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlUniform1ivARB) + pGlUniform1ivARB(loc, count, v); +#elif defined(GL_ARB_shader_objects) + glUniform1ivARB(loc, count, v); +#else + os::Printer::log("glUniform1ivARB not supported", ELL_ERROR); +#endif +} + +void COpenGLExtensionHandler::extGlUniform1fvARB (GLint loc, GLsizei count, const GLfloat *v) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlUniform1fvARB) + pGlUniform1fvARB(loc, count, v); +#elif defined(GL_ARB_shader_objects) + glUniform1fvARB(loc, count, v); +#else + os::Printer::log("glUniform1fvARB not supported", ELL_ERROR); +#endif +} + +void COpenGLExtensionHandler::extGlUniform2fvARB (GLint loc, GLsizei count, const GLfloat *v) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlUniform2fvARB) + pGlUniform2fvARB(loc, count, v); +#elif defined(GL_ARB_shader_objects) + glUniform2fvARB(loc, count, v); +#else + os::Printer::log("glUniform2fvARB not supported", ELL_ERROR); +#endif +} + +void COpenGLExtensionHandler::extGlUniform3fvARB (GLint loc, GLsizei count, const GLfloat *v) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlUniform3fvARB) + pGlUniform3fvARB(loc, count, v); +#elif defined(GL_ARB_shader_objects) + glUniform3fvARB(loc, count, v); +#else + os::Printer::log("glUniform3fvARB not supported", ELL_ERROR); +#endif +} + +void COpenGLExtensionHandler::extGlUniformMatrix2fvARB (GLint loc, GLsizei count, GLboolean transpose, const GLfloat *v) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlUniformMatrix2fvARB) + pGlUniformMatrix2fvARB(loc, count, transpose, v); +#elif defined(GL_ARB_shader_objects) + glUniformMatrix2fvARB(loc, count, transpose, v); +#else + os::Printer::log("glUniformMatrix2fvARB not supported", ELL_ERROR); +#endif +} + +void COpenGLExtensionHandler::extGlUniformMatrix3fvARB (GLint loc, GLsizei count, GLboolean transpose, const GLfloat *v) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlUniformMatrix3fvARB) + pGlUniformMatrix3fvARB(loc, count, transpose, v); +#elif defined(GL_ARB_shader_objects) + glUniformMatrix3fvARB(loc, count, transpose, v); +#else + os::Printer::log("glUniformMatrix3fvARB not supported", ELL_ERROR); +#endif +} + +void COpenGLExtensionHandler::extGlUniformMatrix4fvARB (GLint loc, GLsizei count, GLboolean transpose, const GLfloat *v) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlUniformMatrix4fvARB) + pGlUniformMatrix4fvARB(loc, count, transpose, v); +#elif defined(GL_ARB_shader_objects) + glUniformMatrix4fvARB(loc, count, transpose, v); +#else + os::Printer::log("glUniformMatrix4fvARB not supported", ELL_ERROR); +#endif +} + +void COpenGLExtensionHandler::extGlGetActiveUniformARB (GLhandleARB program, GLuint index, GLsizei maxlength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlGetActiveUniformARB) + pGlGetActiveUniformARB(program, index, maxlength, length, size, type, name); +#elif defined(GL_ARB_shader_objects) + glGetActiveUniformARB(program, index, maxlength, length, size, type, name); +#else + os::Printer::log("glGetActiveUniformARB not supported", ELL_ERROR); +#endif +} + +void COpenGLExtensionHandler::extGlPointParameterfARB (GLint loc, GLfloat f) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlPointParameterfARB) + pGlPointParameterfARB(loc, f); +#else + glPointParameterfARB(loc, f); +#endif +} + +void COpenGLExtensionHandler::extGlPointParameterfvARB (GLint loc, const GLfloat *v) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlPointParameterfvARB) + pGlPointParameterfvARB(loc, v); +#else + glPointParameterfvARB(loc, v); +#endif +} + +void COpenGLExtensionHandler::extGlStencilFuncSeparate (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlStencilFuncSeparate) + pGlStencilFuncSeparate(frontfunc, backfunc, ref, mask); + else if (pGlStencilFuncSeparateATI) + pGlStencilFuncSeparateATI(frontfunc, backfunc, ref, mask); +#elif defined(GL_VERSION_2_0) + glStencilFuncSeparate(frontfunc, backfunc, ref, mask); +#elif defined(GL_ATI_separate_stencil) + glStencilFuncSeparateATI(frontfunc, backfunc, ref, mask); +#else + os::Printer::log("glStencilFuncSeparate not supported", ELL_ERROR); +#endif +} + +void COpenGLExtensionHandler::extGlStencilOpSeparate (GLenum face, GLenum fail, GLenum zfail, GLenum zpass) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlStencilOpSeparate) + pGlStencilOpSeparate(face, fail, zfail, zpass); + else if (pGlStencilOpSeparateATI) + pGlStencilOpSeparateATI(face, fail, zfail, zpass); +#elif defined(GL_VERSION_2_0) + glStencilOpSeparate(face, fail, zfail, zpass); +#elif defined(GL_ATI_separate_stencil) + glStencilOpSeparateATI(face, fail, zfail, zpass); +#else + os::Printer::log("glStencilOpSeparate not supported", ELL_ERROR); +#endif +} + +void COpenGLExtensionHandler::extGlCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, + GLsizei height, GLint border, GLsizei imageSize, const void* data) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + #ifdef PFNGLCOMPRESSEDTEXIMAGE2DPROC + if (pGlCompressedTexImage2D) + pGlCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data); + #endif +#else + glCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data); +#endif +} + +void COpenGLExtensionHandler::extGlBindFramebufferEXT (GLenum target, GLuint framebuffer) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlBindFramebufferEXT) + pGlBindFramebufferEXT(target, framebuffer); +#elif defined(GL_EXT_framebuffer_object) + glBindFramebufferEXT(target, framebuffer); +#endif +} + +void COpenGLExtensionHandler::extGlDeleteFramebuffersEXT (GLsizei n, const GLuint *framebuffers) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlDeleteFramebuffersEXT) + pGlDeleteFramebuffersEXT(n, framebuffers); +#elif defined(GL_EXT_framebuffer_object) + glDeleteFramebuffersEXT(n, framebuffers); +#endif +} + +void COpenGLExtensionHandler::extGlGenFramebuffersEXT (GLsizei n, GLuint *framebuffers) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlGenFramebuffersEXT) + pGlGenFramebuffersEXT(n, framebuffers); +#elif defined(GL_EXT_framebuffer_object) + glGenFramebuffersEXT(n, framebuffers); +#endif +} + +GLenum COpenGLExtensionHandler::extGlCheckFramebufferStatusEXT (GLenum target) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlCheckFramebufferStatusEXT) + return pGlCheckFramebufferStatusEXT(target); + else + return 0; +#elif defined(GL_EXT_framebuffer_object) + return glCheckFramebufferStatusEXT(target); +#else + return 0; +#endif +} + +void COpenGLExtensionHandler::extGlFramebufferTexture2DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlFramebufferTexture2DEXT) + pGlFramebufferTexture2DEXT(target, attachment, textarget, texture, level); +#elif defined(GL_EXT_framebuffer_object) + glFramebufferTexture2DEXT(target, attachment, textarget, texture, level); +#endif +} + +void COpenGLExtensionHandler::extGlBindRenderbufferEXT (GLenum target, GLuint renderbuffer) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlBindRenderbufferEXT) + pGlBindRenderbufferEXT(target, renderbuffer); +#elif defined(GL_EXT_framebuffer_object) + glBindRenderbufferEXT(target, renderbuffer); +#endif +} + +void COpenGLExtensionHandler::extGlDeleteRenderbuffersEXT (GLsizei n, const GLuint *renderbuffers) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlDeleteRenderbuffersEXT) + pGlDeleteRenderbuffersEXT(n, renderbuffers); +#elif defined(GL_EXT_framebuffer_object) + glDeleteRenderbuffersEXT(n, renderbuffers); +#endif +} + +void COpenGLExtensionHandler::extGlGenRenderbuffersEXT (GLsizei n, GLuint *renderbuffers) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlGenRenderbuffersEXT) + pGlGenRenderbuffersEXT(n, renderbuffers); +#elif defined(GL_EXT_framebuffer_object) + glGenRenderbuffersEXT(n, renderbuffers); +#endif +} + +void COpenGLExtensionHandler::extGlRenderbufferStorageEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlRenderbufferStorageEXT) + pGlRenderbufferStorageEXT(target, internalformat, width, height); +#elif defined(GL_EXT_framebuffer_object) + glRenderbufferStorageEXT(target, internalformat, width, height); +#endif +} + +void COpenGLExtensionHandler::extGlFramebufferRenderbufferEXT (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) +{ +#ifdef _IRR_OPENGL_USE_EXTPOINTER_ + if (pGlFramebufferRenderbufferEXT) + pGlFramebufferRenderbufferEXT(target, attachment, renderbuffertarget, renderbuffer); +#elif defined(GL_EXT_framebuffer_object) + glFramebufferRenderbufferEXT(target, attachment, renderbuffertarget, renderbuffer); +#endif +} + + +} +} + +#endif diff --git a/source/Irrlicht/COpenGLExtensionHandler.h b/source/Irrlicht/COpenGLExtensionHandler.h new file mode 100644 index 00000000..2c8d4792 --- /dev/null +++ b/source/Irrlicht/COpenGLExtensionHandler.h @@ -0,0 +1,793 @@ +// Copyright (C) 2002-2007 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in Irrlicht.h + +#ifndef __C_OPEN_GL_FEATURE_MAP_H_INCLUDED__ +#define __C_OPEN_GL_FEATURE_MAP_H_INCLUDED__ + +#include "EDriverFeatures.h" +#include "irrTypes.h" + +#if defined(_IRR_WINDOWS_API_) + // include windows headers for HWND + #define WIN32_LEAN_AND_MEAN + #include + #include + #include + #include "glext.h" +#ifdef _MSC_VER + #pragma comment(lib, "OpenGL32.lib") + #pragma comment(lib, "GLu32.lib") +#endif +#elif defined(MACOSX) + #define GL_EXT_texture_env_combine 1 + #include "CIrrDeviceMacOSX.h" + #include + #include + #include +#elif defined(_IRR_USE_SDL_DEVICE_) + #if defined(_IRR_OPENGL_USE_EXTPOINTER_) + #define GL_GLEXT_LEGACY 1 + #define GLX_GLXEXT_LEGACY 1 + #else + #define GL_GLEXT_PROTOTYPES 1 + #define GLX_GLXEXT_PROTOTYPES 1 + #endif + #include + #define NO_SDL_GLEXT + #include "glext.h" +#else + #if defined(_IRR_OPENGL_USE_EXTPOINTER_) + #define GL_GLEXT_LEGACY 1 + #define GLX_GLXEXT_LEGACY 1 + #else + #define GL_GLEXT_PROTOTYPES 1 + #define GLX_GLXEXT_PROTOTYPES 1 + #endif + #include + #include + #include + #if defined(_IRR_OPENGL_USE_EXTPOINTER_) + #include "glext.h" + #undef GLX_ARB_get_proc_address // avoid problems with local glxext.h + #include "glxext.h" + #endif +#endif + + +namespace irr +{ +namespace video +{ + +static const char* const OpenGLFeatureStrings[] = { + "GL_3DFX_multisample", + "GL_3DFX_tbuffer", + "GL_3DFX_texture_compression_FXT1", + "GL_APPLE_client_storage", + "GL_APPLE_element_array", + "GL_APPLE_fence", + "GL_APPLE_flush_buffer_range", + "GL_APPLE_specular_vector", + "GL_APPLE_transform_hint", + "GL_APPLE_vertex_array_object", + "GL_APPLE_vertex_array_range", + "GL_APPLE_ycbcr_422", + "GL_ARB_color_buffer_float", + "GL_ARB_depth_texture", + "GL_ARB_draw_buffers", + "GL_ARB_fragment_program", + "GL_ARB_fragment_program_shadow", + "GL_ARB_fragment_shader", + "GL_ARB_half_float_pixel", + "GL_ARB_imaging", + "GL_ARB_matrix_palette", + "GL_ARB_multisample", + "GL_ARB_multitexture", + "GL_ARB_occlusion_query", + "GL_ARB_pixel_buffer_object", + "GL_ARB_point_parameters", + "GL_ARB_point_sprite", + "GL_ARB_shader_objects", + "GL_ARB_shading_language_100", + "GL_ARB_shadow", + "GL_ARB_shadow_ambient", + "GL_ARB_texture_border_clamp", + "GL_ARB_texture_compression", + "GL_ARB_texture_cube_map", + "GL_ARB_texture_env_add", + "GL_ARB_texture_env_combine", + "GL_ARB_texture_env_crossbar", + "GL_ARB_texture_env_dot3", + "GL_ARB_texture_float", + "GL_ARB_texture_mirrored_repeat", + "GL_ARB_texture_non_power_of_two", + "GL_ARB_texture_rectangle", + "GL_ARB_transpose_matrix", + "GL_ARB_vertex_blend", + "GL_ARB_vertex_buffer_object", + "GL_ARB_vertex_program", + "GL_ARB_vertex_shader", + "GL_ARB_window_pos", + "GL_ATI_draw_buffers", + "GL_ATI_element_array", + "GL_ATI_envmap_bumpmap", + "GL_ATI_fragment_shader", + "GL_ATI_map_object_buffer", + "GL_ATI_pixel_format_float", + "GL_ATI_pn_triangles", + "GL_ATI_separate_stencil", + "GL_ATI_text_fragment_shader", + "GL_ATI_texture_env_combine3", + "GL_ATI_texture_float", + "GL_ATI_texture_mirror_once", + "GL_ATI_vertex_array_object", + "GL_ATI_vertex_attrib_array_object", + "GL_ATI_vertex_streams", + "GL_EXT_422_pixels", + "GL_EXT_abgr", + "GL_EXT_bgra", + "GL_EXT_bindable_uniform", + "GL_EXT_blend_color", + "GL_EXT_blend_equation_separate", + "GL_EXT_blend_func_separate", + "GL_EXT_blend_logic_op", + "GL_EXT_blend_minmax", + "GL_EXT_blend_subtract", + "GL_EXT_clip_volume_hint", + "GL_EXT_cmyka", + "GL_EXT_color_subtable", + "GL_EXT_compiled_vertex_array", + "GL_EXT_convolution", + "GL_EXT_coordinate_frame", + "GL_EXT_copy_texture", + "GL_EXT_cull_vertex", + "GL_EXT_depth_bounds_test", + "GL_EXT_draw_buffers2", + "GL_EXT_draw_instanced", + "GL_EXT_draw_range_elements", + "GL_EXT_fog_coord", + "GL_EXT_framebuffer_blit", + "GL_EXT_framebuffer_multisample", + "GL_EXT_framebuffer_object", + "GL_EXT_framebuffer_sRGB", + "GL_EXT_geometry_shader4", + "GL_EXT_gpu_program_parameters", + "GL_EXT_gpu_shader4", + "GL_EXT_histogram", + "GL_EXT_index_array_formats", + "GL_EXT_index_func", + "GL_EXT_index_material", + "GL_EXT_index_texture", + "GL_EXT_light_texture", + "GL_EXT_misc_attribute", + "GL_EXT_multi_draw_arrays", + "GL_EXT_multisample", + "GL_EXT_packed_depth_stencil", + "GL_EXT_packed_float", + "GL_EXT_packed_pixels", + "GL_EXT_paletted_texture", + "GL_EXT_pixel_buffer_object", + "GL_EXT_pixel_transform", + "GL_EXT_pixel_transform_color_table", + "GL_EXT_point_parameters", + "GL_EXT_polygon_offset", + "GL_EXT_rescale_normal", + "GL_EXT_secondary_color", + "GL_EXT_separate_specular_color", + "GL_EXT_shadow_funcs", + "GL_EXT_shared_texture_palette", + "GL_EXT_stencil_clear_tag", + "GL_EXT_stencil_two_side", + "GL_EXT_stencil_wrap", + "GL_EXT_subtexture", + "GL_EXT_texture", + "GL_EXT_texture3D", + "GL_EXT_texture_array", + "GL_EXT_texture_buffer_object", + "GL_EXT_texture_compression_latc", + "GL_EXT_texture_compression_rgtc", + "GL_EXT_texture_compression_s3tc", + "GL_EXT_texture_cube_map", + "GL_EXT_texture_env_add", + "GL_EXT_texture_env_combine", + "GL_EXT_texture_env_dot3", + "GL_EXT_texture_filter_anisotropic", + "GL_EXT_texture_integer", + "GL_EXT_texture_lod_bias", + "GL_EXT_texture_mirror_clamp", + "GL_EXT_texture_object", + "GL_EXT_texture_perturb_normal", + "GL_EXT_texture_shared_exponent", + "GL_EXT_texture_sRGB", + "GL_EXT_timer_query", + "GL_EXT_vertex_array", + "GL_EXT_vertex_shader", + "GL_EXT_vertex_weighting", + "GL_FfdMaskSGIX", + "GL_GREMEDY_string_marker", + "GL_HP_convolution_border_modes", + "GL_HP_image_transform", + "GL_HP_occlusion_test", + "GL_HP_texture_lighting", + "GL_IBM_cull_vertex", + "GL_IBM_multimode_draw_arrays", + "GL_IBM_rasterpos_clip", + "GL_IBM_texture_mirrored_repeat", + "GL_IBM_vertex_array_lists", + "GL_INGR_blend_func_separate", + "GL_INGR_color_clamp", + "GL_INGR_interlace_read", + "GL_INGR_palette_buffer", + "GL_INTEL_parallel_arrays", + "GL_INTEL_texture_scissor", + "GL_MESA_pack_invert", + "GL_MESA_resize_buffers", + "GL_MESA_window_pos", + "GL_MESAX_texture_stack", + "GL_MESA_ycbcr_texture", + "GL_NV_blend_square", + "GL_NV_copy_depth_to_color", + "GL_NV_depth_buffer_float", + "GL_NV_depth_clamp", + "GL_NV_evaluators", + "GL_NV_fence", + "GL_NV_float_buffer", + "GL_NV_fog_distance", + "GL_NV_fragment_program", + "GL_NV_fragment_program2", + "GL_NV_fragment_program4", + "GL_NV_fragment_program_option", + "GL_NV_framebuffer_multisample_coverage", + "GL_NV_geometry_program4", + "GL_NV_geometry_shader4", + "GL_NV_gpu_program4", + "GL_NV_half_float", + "GL_NV_light_max_exponent", + "GL_NV_multisample_filter_hint", + "GL_NV_occlusion_query", + "GL_NV_packed_depth_stencil", + "GL_NV_parameter_buffer_object", + "GL_NV_pixel_data_range", + "GL_NV_point_sprite", + "GL_NV_primitive_restart", + "GL_NV_register_combiners", + "GL_NV_register_combiners2", + "GL_NV_texgen_emboss", + "GL_NV_texgen_reflection", + "GL_NV_texture_compression_vtc", + "GL_NV_texture_env_combine4", + "GL_NV_texture_expand_normal", + "GL_NV_texture_rectangle", + "GL_NV_texture_shader", + "GL_NV_texture_shader2", + "GL_NV_texture_shader3", + "GL_NV_transform_feedback", + "GL_NV_vertex_array_range", + "GL_NV_vertex_array_range2", + "GL_NV_vertex_program", + "GL_NV_vertex_program1_1", + "GL_NV_vertex_program2", + "GL_NV_vertex_program2_option", + "GL_NV_vertex_program3", + "GL_NV_vertex_program4", + "GL_OES_read_format", + "GL_OML_interlace", + "GL_OML_resample", + "GL_OML_subsample", + "GL_PGI_misc_hints", + "GL_PGI_vertex_hints", + "GL_REND_screen_coordinates", + "GL_S3_s3tc", + "GL_SGI_color_matrix", + "GL_SGI_color_table", + "GL_SGI_depth_pass_instrument", + "GL_SGIS_detail_texture", + "GL_SGIS_fog_function", + "GL_SGIS_generate_mipmap", + "GL_SGIS_multisample", + "GL_SGIS_pixel_texture", + "GL_SGIS_point_line_texgen", + "GL_SGIS_point_parameters", + "GL_SGIS_sharpen_texture", + "GL_SGIS_texture4D", + "GL_SGIS_texture_border_clamp", + "GL_SGIS_texture_color_mask", + "GL_SGIS_texture_edge_clamp", + "GL_SGIS_texture_filter4", + "GL_SGIS_texture_lod", + "GL_SGIS_texture_select", + "GL_SGI_texture_color_table", + "GL_SGIX_async", + "GL_SGIX_async_histogram", + "GL_SGIX_async_pixel", + "GL_SGIX_blend_alpha_minmax", + "GL_SGIX_calligraphic_fragment", + "GL_SGIX_clipmap", + "GL_SGIX_convolution_accuracy", + "GL_SGIX_depth_pass_instrument", + "GL_SGIX_depth_texture", + "GL_SGIX_flush_raster", + "GL_SGIX_fog_offset", + "GL_SGIX_fog_scale", + "GL_SGIX_fragment_lighting", + "GL_SGIX_framezoom", + "GL_SGIX_igloo_interface", + "GL_SGIX_impact_pixel_texture", + "GL_SGIX_instruments", + "GL_SGIX_interlace", + "GL_SGIX_ir_instrument1", + "GL_SGIX_list_priority", + "GL_SGIX_pixel_texture", + "GL_SGIX_pixel_tiles", + "GL_SGIX_polynomial_ffd", + "GL_SGIX_reference_plane", + "GL_SGIX_resample", + "GL_SGIX_scalebias_hint", + "GL_SGIX_shadow", + "GL_SGIX_shadow_ambient", + "GL_SGIX_sprite", + "GL_SGIX_subsample", + "GL_SGIX_tag_sample_buffer", + "GL_SGIX_texture_add_env", + "GL_SGIX_texture_coordinate_clamp", + "GL_SGIX_texture_lod_bias", + "GL_SGIX_texture_multi_buffer", + "GL_SGIX_texture_scale_bias", + "GL_SGIX_texture_select", + "GL_SGIX_vertex_preclip", + "GL_SGIX_ycrcb", + "GL_SGIX_ycrcba", + "GL_SGIX_ycrcb_subsample", + "GL_SUN_convolution_border_modes", + "GL_SUN_global_alpha", + "GL_SUN_mesh_array", + "GL_SUN_slice_accum", + "GL_SUN_triangle_list", + "GL_SUN_vertex", + "GL_SUNX_constant_data", + "GL_WIN_phong_shading", + "GL_WIN_specular_fog" +}; + + +class COpenGLExtensionHandler +{ + enum EOpenGLFeatures { + IRR_3DFX_multisample = 0, + IRR_3DFX_tbuffer, + IRR_3DFX_texture_compression_FXT1, + IRR_APPLE_client_storage, + IRR_APPLE_element_array, + IRR_APPLE_fence, + IRR_APPLE_flush_buffer_range, + IRR_APPLE_specular_vector, + IRR_APPLE_transform_hint, + IRR_APPLE_vertex_array_object, + IRR_APPLE_vertex_array_range, + IRR_APPLE_ycbcr_422, + IRR_ARB_color_buffer_float, + IRR_ARB_depth_texture, + IRR_ARB_draw_buffers, + IRR_ARB_fragment_program, + IRR_ARB_fragment_program_shadow, + IRR_ARB_fragment_shader, + IRR_ARB_half_float_pixel, + IRR_ARB_imaging, + IRR_ARB_matrix_palette, + IRR_ARB_multisample, + IRR_ARB_multitexture, + IRR_ARB_occlusion_query, + IRR_ARB_pixel_buffer_object, + IRR_ARB_point_parameters, + IRR_ARB_point_sprite, + IRR_ARB_shader_objects, + IRR_ARB_shading_language_100, + IRR_ARB_shadow, + IRR_ARB_shadow_ambient, + IRR_ARB_texture_border_clamp, + IRR_ARB_texture_compression, + IRR_ARB_texture_cube_map, + IRR_ARB_texture_env_add, + IRR_ARB_texture_env_combine, + IRR_ARB_texture_env_crossbar, + IRR_ARB_texture_env_dot3, + IRR_ARB_texture_float, + IRR_ARB_texture_mirrored_repeat, + IRR_ARB_texture_non_power_of_two, + IRR_ARB_texture_rectangle, + IRR_ARB_transpose_matrix, + IRR_ARB_vertex_blend, + IRR_ARB_vertex_buffer_object, + IRR_ARB_vertex_program, + IRR_ARB_vertex_shader, + IRR_ARB_window_pos, + IRR_ATI_draw_buffers, + IRR_ATI_element_array, + IRR_ATI_envmap_bumpmap, + IRR_ATI_fragment_shader, + IRR_ATI_map_object_buffer, + IRR_ATI_pixel_format_float, + IRR_ATI_pn_triangles, + IRR_ATI_separate_stencil, + IRR_ATI_text_fragment_shader, + IRR_ATI_texture_env_combine3, + IRR_ATI_texture_float, + IRR_ATI_texture_mirror_once, + IRR_ATI_vertex_array_object, + IRR_ATI_vertex_attrib_array_object, + IRR_ATI_vertex_streams, + IRR_EXT_422_pixels, + IRR_EXT_abgr, + IRR_EXT_bgra, + IRR_EXT_bindable_uniform, + IRR_EXT_blend_color, + IRR_EXT_blend_equation_separate, + IRR_EXT_blend_func_separate, + IRR_EXT_blend_logic_op, + IRR_EXT_blend_minmax, + IRR_EXT_blend_subtract, + IRR_EXT_clip_volume_hint, + IRR_EXT_cmyka, + IRR_EXT_color_subtable, + IRR_EXT_compiled_vertex_array, + IRR_EXT_convolution, + IRR_EXT_coordinate_frame, + IRR_EXT_copy_texture, + IRR_EXT_cull_vertex, + IRR_EXT_depth_bounds_test, + IRR_EXT_draw_buffers2, + IRR_EXT_draw_instanced, + IRR_EXT_draw_range_elements, + IRR_EXT_fog_coord, + IRR_EXT_framebuffer_blit, + IRR_EXT_framebuffer_multisample, + IRR_EXT_framebuffer_object, + IRR_EXT_framebuffer_sRGB, + IRR_EXT_geometry_shader4, + IRR_EXT_gpu_program_parameters, + IRR_EXT_gpu_shader4, + IRR_EXT_histogram, + IRR_EXT_index_array_formats, + IRR_EXT_index_func, + IRR_EXT_index_material, + IRR_EXT_index_texture, + IRR_EXT_light_texture, + IRR_EXT_misc_attribute, + IRR_EXT_multi_draw_arrays, + IRR_EXT_multisample, + IRR_EXT_packed_depth_stencil, + IRR_EXT_packed_float, + IRR_EXT_packed_pixels, + IRR_EXT_paletted_texture, + IRR_EXT_pixel_buffer_object, + IRR_EXT_pixel_transform, + IRR_EXT_pixel_transform_color_table, + IRR_EXT_point_parameters, + IRR_EXT_polygon_offset, + IRR_EXT_rescale_normal, + IRR_EXT_secondary_color, + IRR_EXT_separate_specular_color, + IRR_EXT_shadow_funcs, + IRR_EXT_shared_texture_palette, + IRR_EXT_stencil_clear_tag, + IRR_EXT_stencil_two_side, + IRR_EXT_stencil_wrap, + IRR_EXT_subtexture, + IRR_EXT_texture, + IRR_EXT_texture3D, + IRR_EXT_texture_array, + IRR_EXT_texture_buffer_object, + IRR_EXT_texture_compression_latc, + IRR_EXT_texture_compression_rgtc, + IRR_EXT_texture_compression_s3tc, + IRR_EXT_texture_cube_map, + IRR_EXT_texture_env_add, + IRR_EXT_texture_env_combine, + IRR_EXT_texture_env_dot3, + IRR_EXT_texture_filter_anisotropic, + IRR_EXT_texture_integer, + IRR_EXT_texture_lod_bias, + IRR_EXT_texture_mirror_clamp, + IRR_EXT_texture_object, + IRR_EXT_texture_perturb_normal, + IRR_EXT_texture_shared_exponent, + IRR_EXT_texture_sRGB, + IRR_EXT_timer_query, + IRR_EXT_vertex_array, + IRR_EXT_vertex_shader, + IRR_EXT_vertex_weighting, + IRR_FfdMaskSGIX, + IRR_GREMEDY_string_marker, + IRR_HP_convolution_border_modes, + IRR_HP_image_transform, + IRR_HP_occlusion_test, + IRR_HP_texture_lighting, + IRR_IBM_cull_vertex, + IRR_IBM_multimode_draw_arrays, + IRR_IBM_rasterpos_clip, + IRR_IBM_texture_mirrored_repeat, + IRR_IBM_vertex_array_lists, + IRR_INGR_blend_func_separate, + IRR_INGR_color_clamp, + IRR_INGR_interlace_read, + IRR_INGR_palette_buffer, + IRR_INTEL_parallel_arrays, + IRR_INTEL_texture_scissor, + IRR_MESA_pack_invert, + IRR_MESA_resize_buffers, + IRR_MESA_window_pos, + IRR_MESAX_texture_stack, + IRR_MESA_ycbcr_texture, + IRR_NV_blend_square, + IRR_NV_copy_depth_to_color, + IRR_NV_depth_buffer_float, + IRR_NV_depth_clamp, + IRR_NV_evaluators, + IRR_NV_fence, + IRR_NV_float_buffer, + IRR_NV_fog_distance, + IRR_NV_fragment_program, + IRR_NV_fragment_program2, + IRR_NV_fragment_program4, + IRR_NV_fragment_program_option, + IRR_NV_framebuffer_multisample_coverage, + IRR_NV_geometry_program4, + IRR_NV_geometry_shader4, + IRR_NV_gpu_program4, + IRR_NV_half_float, + IRR_NV_light_max_exponent, + IRR_NV_multisample_filter_hint, + IRR_NV_occlusion_query, + IRR_NV_packed_depth_stencil, + IRR_NV_parameter_buffer_object, + IRR_NV_pixel_data_range, + IRR_NV_point_sprite, + IRR_NV_primitive_restart, + IRR_NV_register_combiners, + IRR_NV_register_combiners2, + IRR_NV_texgen_emboss, + IRR_NV_texgen_reflection, + IRR_NV_texture_compression_vtc, + IRR_NV_texture_env_combine4, + IRR_NV_texture_expand_normal, + IRR_NV_texture_rectangle, + IRR_NV_texture_shader, + IRR_NV_texture_shader2, + IRR_NV_texture_shader3, + IRR_NV_transform_feedback, + IRR_NV_vertex_array_range, + IRR_NV_vertex_array_range2, + IRR_NV_vertex_program, + IRR_NV_vertex_program1_1, + IRR_NV_vertex_program2, + IRR_NV_vertex_program2_option, + IRR_NV_vertex_program3, + IRR_NV_vertex_program4, + IRR_OES_read_format, + IRR_OML_interlace, + IRR_OML_resample, + IRR_OML_subsample, + IRR_PGI_misc_hints, + IRR_PGI_vertex_hints, + IRR_REND_screen_coordinates, + IRR_S3_s3tc, + IRR_SGI_color_matrix, + IRR_SGI_color_table, + IRR_SGI_depth_pass_instrument, + IRR_SGIS_detail_texture, + IRR_SGIS_fog_function, + IRR_SGIS_generate_mipmap, + IRR_SGIS_multisample, + IRR_SGIS_pixel_texture, + IRR_SGIS_point_line_texgen, + IRR_SGIS_point_parameters, + IRR_SGIS_sharpen_texture, + IRR_SGIS_texture4D, + IRR_SGIS_texture_border_clamp, + IRR_SGIS_texture_color_mask, + IRR_SGIS_texture_edge_clamp, + IRR_SGIS_texture_filter4, + IRR_SGIS_texture_lod, + IRR_SGIS_texture_select, + IRR_SGI_texture_color_table, + IRR_SGIX_async, + IRR_SGIX_async_histogram, + IRR_SGIX_async_pixel, + IRR_SGIX_blend_alpha_minmax, + IRR_SGIX_calligraphic_fragment, + IRR_SGIX_clipmap, + IRR_SGIX_convolution_accuracy, + IRR_SGIX_depth_pass_instrument, + IRR_SGIX_depth_texture, + IRR_SGIX_flush_raster, + IRR_SGIX_fog_offset, + IRR_SGIX_fog_scale, + IRR_SGIX_fragment_lighting, + IRR_SGIX_framezoom, + IRR_SGIX_igloo_interface, + IRR_SGIX_impact_pixel_texture, + IRR_SGIX_instruments, + IRR_SGIX_interlace, + IRR_SGIX_ir_instrument1, + IRR_SGIX_list_priority, + IRR_SGIX_pixel_texture, + IRR_SGIX_pixel_tiles, + IRR_SGIX_polynomial_ffd, + IRR_SGIX_reference_plane, + IRR_SGIX_resample, + IRR_SGIX_scalebias_hint, + IRR_SGIX_shadow, + IRR_SGIX_shadow_ambient, + IRR_SGIX_sprite, + IRR_SGIX_subsample, + IRR_SGIX_tag_sample_buffer, + IRR_SGIX_texture_add_env, + IRR_SGIX_texture_coordinate_clamp, + IRR_SGIX_texture_lod_bias, + IRR_SGIX_texture_multi_buffer, + IRR_SGIX_texture_scale_bias, + IRR_SGIX_texture_select, + IRR_SGIX_vertex_preclip, + IRR_SGIX_ycrcb, + IRR_SGIX_ycrcba, + IRR_SGIX_ycrcb_subsample, + IRR_SUN_convolution_border_modes, + IRR_SUN_global_alpha, + IRR_SUN_mesh_array, + IRR_SUN_slice_accum, + IRR_SUN_triangle_list, + IRR_SUN_vertex, + IRR_SUNX_constant_data, + IRR_WIN_phong_shading, + IRR_WIN_specular_fog, + IRR_OpenGL_Feature_Count + }; + + public: + // constructor + COpenGLExtensionHandler(); + + // deferred initialization + void initExtensions(bool stencilBuffer); + + //! queries the features of the driver, returns true if feature is available + bool queryFeature(E_VIDEO_DRIVER_FEATURE feature) const; + + // show all features with availablity + void dump() const; + + // public access to the (loaded) extensions. + // general functions + void extGlActiveTextureARB(GLenum texture); + void extGlClientActiveTextureARB(GLenum texture); + void extGlPointParameterfARB (GLint loc, GLfloat f); + void extGlPointParameterfvARB (GLint loc, const GLfloat *v); + void extGlStencilFuncSeparate (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); + void extGlStencilOpSeparate (GLenum face, GLenum fail, GLenum zfail, GLenum zpass); + void extGlCompressedTexImage2D(GLenum target, GLint level, + GLenum internalformat, GLsizei width, GLsizei height, + GLint border, GLsizei imageSize, const void* data); + + // shader programming + void extGlGenProgramsARB(GLsizei n, GLuint *programs); + void extGlBindProgramARB(GLenum target, GLuint program); + void extGlProgramStringARB(GLenum target, GLenum format, GLsizei len, const GLvoid *string); + void extGlDeleteProgramsARB(GLsizei n, const GLuint *programs); + void extGlProgramLocalParameter4fvARB(GLenum, GLuint, const GLfloat *); + GLhandleARB extGlCreateShaderObjectARB(GLenum shaderType); + void extGlShaderSourceARB(GLhandleARB shader, int numOfStrings, const char **strings, int *lenOfStrings); + void extGlCompileShaderARB(GLhandleARB shader); + GLhandleARB extGlCreateProgramObjectARB(void); + void extGlAttachObjectARB(GLhandleARB program, GLhandleARB shader); + void extGlLinkProgramARB(GLhandleARB program); + void extGlUseProgramObjectARB(GLhandleARB prog); + void extGlDeleteObjectARB(GLhandleARB object); + void extGlGetInfoLogARB(GLhandleARB object, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); + void extGlGetObjectParameterivARB(GLhandleARB object, GLenum type, int *param); + GLint extGlGetUniformLocationARB(GLhandleARB program, const char *name); + void extGlUniform4fvARB(GLint location, GLsizei count, const GLfloat *v); + void extGlUniform1ivARB (GLint loc, GLsizei count, const GLint *v); + void extGlUniform1fvARB (GLint loc, GLsizei count, const GLfloat *v); + void extGlUniform2fvARB (GLint loc, GLsizei count, const GLfloat *v); + void extGlUniform3fvARB (GLint loc, GLsizei count, const GLfloat *v); + void extGlUniformMatrix2fvARB (GLint loc, GLsizei count, GLboolean transpose, const GLfloat *v); + void extGlUniformMatrix3fvARB (GLint loc, GLsizei count, GLboolean transpose, const GLfloat *v); + void extGlUniformMatrix4fvARB (GLint loc, GLsizei count, GLboolean transpose, const GLfloat *v); + void extGlGetActiveUniformARB (GLhandleARB program, GLuint index, GLsizei maxlength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); + + // framebuffer objects + void extGlBindFramebufferEXT (GLenum target, GLuint framebuffer); + void extGlDeleteFramebuffersEXT (GLsizei n, const GLuint *framebuffers); + void extGlGenFramebuffersEXT (GLsizei n, GLuint *framebuffers); + GLenum extGlCheckFramebufferStatusEXT (GLenum target); + void extGlFramebufferTexture2DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); + void extGlBindRenderbufferEXT (GLenum target, GLuint renderbuffer); + void extGlDeleteRenderbuffersEXT (GLsizei n, const GLuint *renderbuffers); + void extGlGenRenderbuffersEXT (GLsizei n, GLuint *renderbuffers); + void extGlRenderbufferStorageEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); + void extGlFramebufferRenderbufferEXT (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); + + // Some variables for properties + bool StencilBuffer; + bool MultiTextureExtension; + bool MultiSamplingExtension; + bool AnisotropyExtension; + bool SeparateStencilExtension; + bool TextureCompressionExtension; + bool PackedDepthStencilExtension; + bool SeparateSpecularColorExtension; + + // Some non-boolean properties + GLint MaxTextureUnits; + GLint MaxLights; + GLint MaxIndices; + f32 MaxAnisotropy; + + protected: + // the global feature array + bool FeatureAvailable[IRR_OpenGL_Feature_Count]; + + #if defined(_IRR_OPENGL_USE_EXTPOINTER_) + PFNGLACTIVETEXTUREARBPROC pGlActiveTextureARB; + PFNGLCLIENTACTIVETEXTUREARBPROC pGlClientActiveTextureARB; + PFNGLGENPROGRAMSARBPROC pGlGenProgramsARB; + PFNGLBINDPROGRAMARBPROC pGlBindProgramARB; + PFNGLPROGRAMSTRINGARBPROC pGlProgramStringARB; + PFNGLDELETEPROGRAMSNVPROC pGlDeleteProgramsARB; + PFNGLPROGRAMLOCALPARAMETER4FVARBPROC pGlProgramLocalParameter4fvARB; + PFNGLCREATESHADEROBJECTARBPROC pGlCreateShaderObjectARB; + PFNGLSHADERSOURCEARBPROC pGlShaderSourceARB; + PFNGLCOMPILESHADERARBPROC pGlCompileShaderARB; + PFNGLCREATEPROGRAMOBJECTARBPROC pGlCreateProgramObjectARB; + PFNGLATTACHOBJECTARBPROC pGlAttachObjectARB; + PFNGLLINKPROGRAMARBPROC pGlLinkProgramARB; + PFNGLUSEPROGRAMOBJECTARBPROC pGlUseProgramObjectARB; + PFNGLDELETEOBJECTARBPROC pGlDeleteObjectARB; + PFNGLGETINFOLOGARBPROC pGlGetInfoLogARB; + PFNGLGETOBJECTPARAMETERIVARBPROC pGlGetObjectParameterivARB; + PFNGLGETUNIFORMLOCATIONARBPROC pGlGetUniformLocationARB; + PFNGLUNIFORM1IVARBPROC pGlUniform1ivARB; + PFNGLUNIFORM1FVARBPROC pGlUniform1fvARB; + PFNGLUNIFORM2FVARBPROC pGlUniform2fvARB; + PFNGLUNIFORM3FVARBPROC pGlUniform3fvARB; + PFNGLUNIFORM4FVARBPROC pGlUniform4fvARB; + PFNGLUNIFORMMATRIX2FVARBPROC pGlUniformMatrix2fvARB; + PFNGLUNIFORMMATRIX3FVARBPROC pGlUniformMatrix3fvARB; + PFNGLUNIFORMMATRIX4FVARBPROC pGlUniformMatrix4fvARB; + PFNGLGETACTIVEUNIFORMARBPROC pGlGetActiveUniformARB; + PFNGLPOINTPARAMETERFARBPROC pGlPointParameterfARB; + PFNGLPOINTPARAMETERFVARBPROC pGlPointParameterfvARB; + #ifdef GL_ATI_separate_stencil + PFNGLSTENCILFUNCSEPARATEPROC pGlStencilFuncSeparate; + PFNGLSTENCILOPSEPARATEPROC pGlStencilOpSeparate; + PFNGLSTENCILFUNCSEPARATEATIPROC pGlStencilFuncSeparateATI; + PFNGLSTENCILOPSEPARATEATIPROC pGlStencilOpSeparateATI; + #endif + #ifdef PFNGLCOMPRESSEDTEXIMAGE2DPROC + PFNGLCOMPRESSEDTEXIMAGE2DPROC pGlCompressedTexImage2D; + #endif // PFNGLCOMPRESSEDTEXIMAGE2DPROC + #ifdef _IRR_WINDOWS_API_ + typedef BOOL (APIENTRY *PFNWGLSWAPINTERVALFARPROC)(int); + PFNWGLSWAPINTERVALFARPROC wglSwapIntervalEXT; + #elif defined(_IRR_LINUX_PLATFORM_) && defined(GLX_SGI_swap_control) + PFNGLXSWAPINTERVALSGIPROC glxSwapIntervalSGI; + #endif + PFNGLBINDFRAMEBUFFEREXTPROC pGlBindFramebufferEXT; + PFNGLDELETEFRAMEBUFFERSEXTPROC pGlDeleteFramebuffersEXT; + PFNGLGENFRAMEBUFFERSEXTPROC pGlGenFramebuffersEXT; + PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC pGlCheckFramebufferStatusEXT; + PFNGLFRAMEBUFFERTEXTURE2DEXTPROC pGlFramebufferTexture2DEXT; + PFNGLBINDRENDERBUFFEREXTPROC pGlBindRenderbufferEXT; + PFNGLDELETERENDERBUFFERSEXTPROC pGlDeleteRenderbuffersEXT; + PFNGLGENRENDERBUFFERSEXTPROC pGlGenRenderbuffersEXT; + PFNGLRENDERBUFFERSTORAGEEXTPROC pGlRenderbufferStorageEXT; + PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC pGlFramebufferRenderbufferEXT; + #endif +}; + +} +} + +#endif + diff --git a/source/Irrlicht/Irrlicht.dev b/source/Irrlicht/Irrlicht.dev index ed4f7989..e1d86b20 100644 --- a/source/Irrlicht/Irrlicht.dev +++ b/source/Irrlicht/Irrlicht.dev @@ -9,7 +9,7 @@ CppCompiler=-D__GNUWIN32__ -W -DWIN32 -DNDEBUG -D_WINDOWS -D_MBCS -D_USRDLL -DIR Includes=..\..\include;zlib Linker=-lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32 -lglu32 -lopengl32_@@_ Libs= -UnitCount=579 +UnitCount=580 Folders=doc,gui_impl,include,include/core,include/gui,include/io,include/scene,include/video,io_impl,other_impl,other_impl/extern,other_impl/extern/jpeglib,other_impl/extern/libpng,other_impl/extern/zlib,scene_impl,video_impl,"video_impl/Burning Video",video_impl/DirectX8,video_impl/DirectX9,video_impl/Null,video_impl/OpenGL,video_impl/Software ObjFiles= PrivateResource= @@ -5837,3 +5837,13 @@ Priority=1000 OverrideBuildCmd=0 BuildCmd= +[Unit580] +FileName=COpenGLExtensionHandler.cpp +Folder=video_impl/OpenGL +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + diff --git a/source/Irrlicht/Irrlicht7.1.vcproj b/source/Irrlicht/Irrlicht7.1.vcproj index e6e6320a..6954e43a 100644 --- a/source/Irrlicht/Irrlicht7.1.vcproj +++ b/source/Irrlicht/Irrlicht7.1.vcproj @@ -983,6 +983,12 @@ + + + + diff --git a/source/Irrlicht/Irrlicht8.0.vcproj b/source/Irrlicht/Irrlicht8.0.vcproj index c9f1213c..3495c46a 100644 --- a/source/Irrlicht/Irrlicht8.0.vcproj +++ b/source/Irrlicht/Irrlicht8.0.vcproj @@ -1168,6 +1168,14 @@ RelativePath=".\COpenGLTexture.h" > + + + + diff --git a/source/Irrlicht/Irrlicht_Win32-gcc.cbp b/source/Irrlicht/Irrlicht_Win32-gcc.cbp index ba79dccb..0631ebf3 100644 --- a/source/Irrlicht/Irrlicht_Win32-gcc.cbp +++ b/source/Irrlicht/Irrlicht_Win32-gcc.cbp @@ -53,7 +53,7 @@