diff options
Diffstat (limited to 'source/gameengine/Rasterizer/RAS_OpenGLRasterizer')
13 files changed, 497 insertions, 2915 deletions
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/ARB_multitexture.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/ARB_multitexture.h deleted file mode 100644 index a2f27ce3361..00000000000 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/ARB_multitexture.h +++ /dev/null @@ -1,150 +0,0 @@ -#ifndef __ARB_MULTITEXTURE_H__ -#define __ARB_MULTITEXTURE_H__ - -/* -*/ - -/* ---------------------------------------------------------------------------- - GL_ARB_multitexture ----------------------------------------------------------------------------- */ -#ifdef GL_ARB_multitexture - #define GL_TEXTURE0_ARB 0x84C0 - #define GL_TEXTURE1_ARB 0x84C1 - #define GL_TEXTURE2_ARB 0x84C2 - #define GL_TEXTURE3_ARB 0x84C3 - #define GL_TEXTURE4_ARB 0x84C4 - #define GL_TEXTURE5_ARB 0x84C5 - #define GL_TEXTURE6_ARB 0x84C6 - #define GL_TEXTURE7_ARB 0x84C7 - #define GL_TEXTURE8_ARB 0x84C8 - #define GL_TEXTURE9_ARB 0x84C9 - #define GL_TEXTURE10_ARB 0x84CA - #define GL_ACTIVE_TEXTURE_ARB 0x84E0 - #define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1 - #define GL_MAX_TEXTURE_UNITS_ARB 0x84E2 -#endif - - -/* ---------------------------------------------------------------------------- - GL_ARB_texture_env_combine ----------------------------------------------------------------------------- */ -#ifdef GL_ARB_texture_env_combine - #define GL_COMBINE_ARB 0x8570 - #define GL_COMBINE_RGB_ARB 0x8571 - #define GL_COMBINE_ALPHA_ARB 0x8572 - #define GL_SOURCE0_RGB_ARB 0x8580 - #define GL_SOURCE1_RGB_ARB 0x8581 - #define GL_SOURCE2_RGB_ARB 0x8582 - #define GL_SOURCE0_ALPHA_ARB 0x8588 - #define GL_SOURCE1_ALPHA_ARB 0x8589 - #define GL_SOURCE2_ALPHA_ARB 0x858A - #define GL_OPERAND0_RGB_ARB 0x8590 - #define GL_OPERAND1_RGB_ARB 0x8591 - #define GL_OPERAND2_RGB_ARB 0x8592 - #define GL_OPERAND0_ALPHA_ARB 0x8598 - #define GL_OPERAND1_ALPHA_ARB 0x8599 - #define GL_OPERAND2_ALPHA_ARB 0x859A - #define GL_RGB_SCALE_ARB 0x8573 - #define GL_ADD_SIGNED_ARB 0x8574 - #define GL_INTERPOLATE_ARB 0x8575 - #define GL_SUBTRACT_ARB 0x84E7 - #define GL_CONSTANT_ARB 0x8576 - #define GL_PRIMARY_COLOR_ARB 0x8577 - #define GL_PREVIOUS_ARB 0x8578 -#endif - -/* ---------------------------------------------------------------------------- - GL_ARB_texture_cube_map ----------------------------------------------------------------------------- */ -#ifdef GL_ARB_texture_cube_map - #define GL_NORMAL_MAP_ARB 0x8511 - #define GL_REFLECTION_MAP_ARB 0x8512 - #define GL_TEXTURE_CUBE_MAP_ARB 0x8513 - #define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514 - #define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515 - #define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516 - #define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517 - #define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518 - #define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519 - #define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A - #define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B - #define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C -#endif - -/* ---------------------------------------------------------------------------- - GL_ARB_shader_objects ----------------------------------------------------------------------------- */ -#ifdef GL_ARB_shader_objects - #define GL_PROGRAM_OBJECT_ARB 0x8B40 - #define GL_SHADER_OBJECT_ARB 0x8B48 - #define GL_OBJECT_TYPE_ARB 0x8B4E - #define GL_OBJECT_SUBTYPE_ARB 0x8B4F - #define GL_FLOAT_VEC2_ARB 0x8B50 - #define GL_FLOAT_VEC3_ARB 0x8B51 - #define GL_FLOAT_VEC4_ARB 0x8B52 - #define GL_INT_VEC2_ARB 0x8B53 - #define GL_INT_VEC3_ARB 0x8B54 - #define GL_INT_VEC4_ARB 0x8B55 - #define GL_BOOL_ARB 0x8B56 - #define GL_BOOL_VEC2_ARB 0x8B57 - #define GL_BOOL_VEC3_ARB 0x8B58 - #define GL_BOOL_VEC4_ARB 0x8B59 - #define GL_FLOAT_MAT2_ARB 0x8B5A - #define GL_FLOAT_MAT3_ARB 0x8B5B - #define GL_FLOAT_MAT4_ARB 0x8B5C - #define GL_SAMPLER_1D_ARB 0x8B5D - #define GL_SAMPLER_2D_ARB 0x8B5E - #define GL_SAMPLER_3D_ARB 0x8B5F - #define GL_SAMPLER_CUBE_ARB 0x8B60 - #define GL_SAMPLER_1D_SHADOW_ARB 0x8B61 - #define GL_SAMPLER_2D_SHADOW_ARB 0x8B62 - #define GL_SAMPLER_2D_RECT_ARB 0x8B63 - #define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 - #define GL_OBJECT_DELETE_STATUS_ARB 0x8B80 - #define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81 - #define GL_OBJECT_LINK_STATUS_ARB 0x8B82 - #define GL_OBJECT_VALIDATE_STATUS_ARB 0x8B83 - #define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84 - #define GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8B85 - #define GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8B86 - #define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87 - #define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8B88 -#endif - -/* ---------------------------------------------------------------------------- - GL_ARB_vertex_shader ----------------------------------------------------------------------------- */ -#ifdef GL_ARB_vertex_shader - #define GL_VERTEX_SHADER_ARB 0x8B31 - #define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A - #define GL_MAX_VARYING_FLOATS_ARB 0x8B4B - #define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C - #define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D - #define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89 - #define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A -#endif - - -/* ---------------------------------------------------------------------------- - GL_ARB_fragment_shader ----------------------------------------------------------------------------- */ -#ifdef GL_ARB_fragment_shader - #define GL_FRAGMENT_SHADER_ARB 0x8B30 - #define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49 - #define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B -#endif - - -/* ---------------------------------------------------------------------------- - GL_ARB_depth_texture ----------------------------------------------------------------------------- */ -#ifndef GL_ARB_depth_texture - #define GL_DEPTH_COMPONENT16_ARB 0x81A5 - #define GL_DEPTH_COMPONENT24_ARB 0x81A6 - #define GL_DEPTH_COMPONENT32_ARB 0x81A7 - #define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A - #define GL_DEPTH_TEXTURE_MODE_ARB 0x884B -#endif - - -#endif//__ARB_MULTITEXTURE_H__ diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt index 5153834899b..2a6d64ecc73 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt @@ -31,6 +31,7 @@ SET(INC ../../../../intern/string ../../../../intern/moto/include ../../../../source/gameengine/Rasterizer + ../../../../extern/glew/include ) BLENDERLIB(bf_oglrasterizer "${SRC}" "${INC}") diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/EXT_separate_specular_color.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/EXT_separate_specular_color.h deleted file mode 100644 index 5a9d8f32a87..00000000000 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/EXT_separate_specular_color.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef GL_EXT_separate_specular_color -#define GL_EXT_separate_specular_color 1 -#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT 0x81F8 -#define GL_SINGLE_COLOR_EXT 0x81F9 -#define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA -#endif - -#ifndef GL_VERSION_1_2 -#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 -#define GL_SINGLE_COLOR 0x81F9 -#define GL_SEPARATE_SPECULAR_COLOR 0x81FA -#endif diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/Makefile b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/Makefile index 1a88c51dc25..f01978b8eb1 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/Makefile +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/Makefile @@ -36,6 +36,7 @@ include nan_compile.mk CCFLAGS += $(LEVEL_1_CPP_WARNINGS) +CPPFLAGS += -I$(NAN_GLEW)/include CPPFLAGS += -I$(OPENGL_HEADERS) CPPFLAGS += -I$(NAN_STRING)/include CPPFLAGS += -I$(NAN_MOTO)/include diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.cpp index 81a7ccb7a5d..d241bd1ee31 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.cpp @@ -25,665 +25,43 @@ * * ***** END GPL LICENSE BLOCK ***** */ -/* - The extension manager's job is to link at runtime OpenGL extension - functions. - Since the various platform have different methods of finding a fn - pointer, this file attempts to encapsulate all that, so it gets a - little messy. Hopefully we can -*/ -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#ifdef WIN32 -# include <windows.h> - -# include <GL/gl.h> - -#elif defined(__APPLE__) -# include <Carbon/Carbon.h> -# define GL_GLEXT_LEGACY 1 -# include <OpenGL/gl.h> - -#else /* UNIX */ -# include <GL/gl.h> -# include <GL/glx.h> - -# include <dlfcn.h> -#endif - -#include <vector> #include <iostream> -#include <algorithm> -#include <bitset> -#include <stdlib.h> - -#include "STR_String.h" #include "RAS_GLExtensionManager.h" -/* ----------------------------------------------------------------------------- - - Platform specific functions section. - - Required Functions: - static void bglInitEntryPoints (void) -- Loads the GL library - static void bglDeallocEntryPoints (void) -- Frees the GL library - static void *bglGetProcAddress(const GLubyte* entry) -- Finds the address of - the GL function entry - -*/ -#if defined(BGL_NO_EXTENSIONS) -static void bglInitEntryPoints (void) {} -static void bglDeallocEntryPoints (void) {} - -static void *bglGetProcAddress(const GLubyte* entry) -{ - /* No Extensions! */ - return NULL; -} -#elif defined(__APPLE__) -/* http://developer.apple.com/qa/qa2001/qa1188.html */ -CFBundleRef gBundleRefOpenGL = NULL; - -// ------------------------- - -static OSStatus bglInitEntryPoints (void) -{ - OSStatus err = noErr; - const Str255 frameworkName = "\pOpenGL.framework"; - FSRefParam fileRefParam; - FSRef fileRef; - CFURLRef bundleURLOpenGL; - - memset(&fileRefParam, 0, sizeof(fileRefParam)); - memset(&fileRef, 0, sizeof(fileRef)); - - fileRefParam.ioNamePtr = frameworkName; - fileRefParam.newRef = &fileRef; - - // Frameworks directory/folder - err = FindFolder (kSystemDomain, kFrameworksFolderType, false, - &fileRefParam.ioVRefNum, (SInt32*)&fileRefParam.ioDirID); - if (noErr != err) { - DebugStr ((unsigned char *)"\pCould not find frameworks folder"); - return err; - } - err = PBMakeFSRefSync (&fileRefParam); // make FSRef for folder - if (noErr != err) { - DebugStr ((unsigned char *)"\pCould make FSref to frameworks folder"); - return err; - } - // create URL to folder - bundleURLOpenGL = CFURLCreateFromFSRef (kCFAllocatorDefault, - &fileRef); - if (!bundleURLOpenGL) { - DebugStr ((unsigned char *)"\pCould create OpenGL Framework bundle URL"); - return paramErr; - } - // create ref to GL's bundle - gBundleRefOpenGL = CFBundleCreate (kCFAllocatorDefault, - bundleURLOpenGL); - if (!gBundleRefOpenGL) { - DebugStr ((unsigned char *)"\pCould not create OpenGL Framework bundle"); - return paramErr; - } - CFRelease (bundleURLOpenGL); // release created bundle - // if the code was successfully loaded, look for our function. - if (!CFBundleLoadExecutable (gBundleRefOpenGL)) { - DebugStr ((unsigned char *)"\pCould not load MachO executable"); - return paramErr; - } - return err; -} - -// ------------------------- - -static void bglDeallocEntryPoints (void) -{ - if (gBundleRefOpenGL != NULL) { - // unload the bundle's code. - CFBundleUnloadExecutable (gBundleRefOpenGL); - CFRelease (gBundleRefOpenGL); - gBundleRefOpenGL = NULL; - } -} - -// ------------------------- - -/*unused*/ -static void * bglGetProcAddress (const GLubyte * pszProc) -{ - if (!gBundleRefOpenGL) - return NULL; - - return CFBundleGetFunctionPointerForName (gBundleRefOpenGL, - CFStringCreateWithCStringNoCopy (NULL, - (const char *) pszProc, CFStringGetSystemEncoding (), NULL)); -} -#elif defined(GLX_ARB_get_proc_address) -/* Not all glx.h define PFNGLXGETPROCADDRESSARBPROC ! - We define our own if needed. */ -#ifdef HAVE_PFNGLXGETPROCADDRESSARBPROC -#define PFNBGLXGETPROCADDRESSARBPROC PFNGLXGETPROCADDRESSARBPROC -#else -typedef void (*(*PFNBGLXGETPROCADDRESSARBPROC)(const GLubyte *procname))(); -#endif - -void *_getProcAddress(const GLubyte *procName) { return NULL; } -PFNBGLXGETPROCADDRESSARBPROC bglGetProcAddress; - - -//weird bug related to combination of pthreads,libGL and dlopen -//cannot call dlclose in such environment, causes crashes -//so try to keep a global handle to libGL -void* libGL = 0; - -static void bglInitEntryPoints (void) -{ - Display *dpy = glXGetCurrentDisplay(); - std::vector<STR_String> Xextensions = STR_String(glXQueryExtensionsString(dpy, DefaultScreen(dpy))).Explode(' '); - if (std::find(Xextensions.begin(), Xextensions.end(), "GLX_ARB_get_proc_address") != Xextensions.end()) - { - if (!libGL) - { - libGL = dlopen("libGL.so", RTLD_LAZY|RTLD_GLOBAL); - if (libGL) - bglGetProcAddress = (PFNBGLXGETPROCADDRESSARBPROC) (dlsym(libGL, "glXGetProcAddressARB")); - else - std::cout << "Error: " << dlerror() << std::endl; - - // dlclose(libGL); - if (!bglGetProcAddress) - bglGetProcAddress = (PFNBGLXGETPROCADDRESSARBPROC) _getProcAddress; - - // -- - if(!bglGetProcAddress) - std::cout << "Error: unable to find _getProcAddress in libGL" << std::endl; - } - } -} - -static void bglDeallocEntryPoints (void) {} - -#elif defined(WIN32) -static void bglInitEntryPoints (void) {} -static void bglDeallocEntryPoints (void) {} - -#define bglGetProcAddress(entry) wglGetProcAddress((LPCSTR) entry) - -#else /* Unknown Platform - disable extensions */ -static void bglInitEntryPoints (void) {} -static void bglDeallocEntryPoints (void) {} - -static void *bglGetProcAddress(const GLubyte* entry) -{ - /* No Extensions! */ - return NULL; -} - -#endif /* End Platform Specific */ - -/* ----------------------------------------------------------------------------- - - GL Extension Manager. -*/ - /* Bit array of available extensions */ -static std::bitset<bgl::NUM_EXTENSIONS> enabled_extensions; -static std::vector<STR_String> extensions; -static int m_debug; - -static void LinkExtensions(); - -static void EnableExtension(bgl::ExtensionName name) -{ - unsigned int num = (unsigned int) name; - if (num < bgl::NUM_EXTENSIONS) - enabled_extensions.set(num); -} - - -static bool QueryExtension(STR_String extension_name) -{ - return std::find(extensions.begin(), extensions.end(), extension_name) != extensions.end(); -} - namespace bgl { - -void InitExtensions(int debug) -{ - m_debug = debug; - bglInitEntryPoints (); //init bundle - EnableExtension(_BGL_TEST); - LinkExtensions(); - bglDeallocEntryPoints(); -} - -bool QueryExtension(ExtensionName name) -{ - unsigned int num = (unsigned int) name; - if (num < NUM_EXTENSIONS) - return enabled_extensions[num]; - - return false; -} - -bool QueryVersion(int major, int minor) -{ - static int gl_major = 0; - static int gl_minor = 0; - - if (gl_major == 0) + void InitExtensions(bool debug) { - const char *gl_version_str = (const char *) glGetString(GL_VERSION); - if (!gl_version_str) - return false; - STR_String gl_version = STR_String(gl_version_str); - int i = gl_version.Find('.'); - gl_major = gl_version.Left(i).ToInt(); - gl_minor = gl_version.Mid(i+1, gl_version.FindOneOf(". ", i+1) - i - 1).ToInt(); - - static bool doQueryVersion = m_debug; - if (doQueryVersion) - { - doQueryVersion = false; - std::cout << "GL_VERSION: " << gl_major << "." << gl_minor << " (" << gl_version << ")" << std::endl; - } - } - - if (gl_major > major) - return true; - - if (gl_major == major && gl_minor >= minor) - return true; + static bool firsttime = true; - return false; -} - - -/******************************************************************************* -1. Extension function entry points go here - -Need to #ifdef (compile time test for extension) -Add null functions if appropriate - -Some extensions have been incorporated into the core GL, eg Multitexture was -added in GL v1.1. If Blender calls one of these functions before they are -linked, it will crash. Even worse, if Blender *indirectly* calls one of these -functions, (ie the GL implementation calls them itself) Blender will crash. - -We fix this by adding them to the bgl namespace - the functions are now -private to the gameengine. Code can transparently use extensions by adding: - -using namespace bgl; - -to their source. Cunning like a weasel. - - ******************************************************************************/ - -#if defined(PFNGLPNTRIANGLESIATIPROC) -PFNGLPNTRIANGLESIATIPROC glPNTrianglesiATI; -PFNGLPNTRIANGLESFATIPROC glPNTrianglesfATI; -#endif - -BL_EXTInfo RAS_EXT_support; - -#ifdef GL_ARB_multitexture -int max_texture_units = 2; -PFNGLACTIVETEXTUREARBPROC blActiveTextureARB; -PFNGLCLIENTACTIVETEXTUREARBPROC blClientActiveTextureARB; -PFNGLMULTITEXCOORD1DARBPROC blMultiTexCoord1dARB; -PFNGLMULTITEXCOORD1DVARBPROC blMultiTexCoord1dvARB; -PFNGLMULTITEXCOORD1FARBPROC blMultiTexCoord1fARB; -PFNGLMULTITEXCOORD1FVARBPROC blMultiTexCoord1fvARB; -PFNGLMULTITEXCOORD1IARBPROC blMultiTexCoord1iARB; -PFNGLMULTITEXCOORD1IVARBPROC blMultiTexCoord1ivARB; -PFNGLMULTITEXCOORD1SARBPROC blMultiTexCoord1sARB; -PFNGLMULTITEXCOORD1SVARBPROC blMultiTexCoord1svARB; -PFNGLMULTITEXCOORD2DARBPROC blMultiTexCoord2dARB; -PFNGLMULTITEXCOORD2DVARBPROC blMultiTexCoord2dvARB; -PFNGLMULTITEXCOORD2FARBPROC blMultiTexCoord2fARB; -PFNGLMULTITEXCOORD2FVARBPROC blMultiTexCoord2fvARB; -PFNGLMULTITEXCOORD2IARBPROC blMultiTexCoord2iARB; -PFNGLMULTITEXCOORD2IVARBPROC blMultiTexCoord2ivARB; -PFNGLMULTITEXCOORD2SARBPROC blMultiTexCoord2sARB; -PFNGLMULTITEXCOORD2SVARBPROC blMultiTexCoord2svARB; -PFNGLMULTITEXCOORD3DARBPROC blMultiTexCoord3dARB; -PFNGLMULTITEXCOORD3DVARBPROC blMultiTexCoord3dvARB; -PFNGLMULTITEXCOORD3FARBPROC blMultiTexCoord3fARB; -PFNGLMULTITEXCOORD3FVARBPROC blMultiTexCoord3fvARB; -PFNGLMULTITEXCOORD3IARBPROC blMultiTexCoord3iARB; -PFNGLMULTITEXCOORD3IVARBPROC blMultiTexCoord3ivARB; -PFNGLMULTITEXCOORD3SARBPROC blMultiTexCoord3sARB; -PFNGLMULTITEXCOORD3SVARBPROC blMultiTexCoord3svARB; -PFNGLMULTITEXCOORD4DARBPROC blMultiTexCoord4dARB; -PFNGLMULTITEXCOORD4DVARBPROC blMultiTexCoord4dvARB; -PFNGLMULTITEXCOORD4FARBPROC blMultiTexCoord4fARB; -PFNGLMULTITEXCOORD4FVARBPROC blMultiTexCoord4fvARB; -PFNGLMULTITEXCOORD4IARBPROC blMultiTexCoord4iARB; -PFNGLMULTITEXCOORD4IVARBPROC blMultiTexCoord4ivARB; -PFNGLMULTITEXCOORD4SARBPROC blMultiTexCoord4sARB; -PFNGLMULTITEXCOORD4SVARBPROC blMultiTexCoord4svARB; -#endif - -#ifdef GL_ARB_shader_objects - PFNGLDELETEOBJECTARBPROC blDeleteObjectARB; - PFNGLGETHANDLEARBPROC blGetHandleARB; - PFNGLDETACHOBJECTARBPROC blDetachObjectARB; - PFNGLCREATESHADEROBJECTARBPROC blCreateShaderObjectARB; - PFNGLSHADERSOURCEARBPROC blShaderSourceARB; - PFNGLCOMPILESHADERARBPROC blCompileShaderARB; - PFNGLCREATEPROGRAMOBJECTARBPROC blCreateProgramObjectARB; - PFNGLATTACHOBJECTARBPROC blAttachObjectARB; - PFNGLLINKPROGRAMARBPROC blLinkProgramARB; - PFNGLUSEPROGRAMOBJECTARBPROC blUseProgramObjectARB; - PFNGLVALIDATEPROGRAMARBPROC blValidateProgramARB; - PFNGLUNIFORM1FARBPROC blUniform1fARB; - PFNGLUNIFORM2FARBPROC blUniform2fARB; - PFNGLUNIFORM3FARBPROC blUniform3fARB; - PFNGLUNIFORM4FARBPROC blUniform4fARB; - PFNGLUNIFORM1IARBPROC blUniform1iARB; - PFNGLUNIFORM2IARBPROC blUniform2iARB; - PFNGLUNIFORM3IARBPROC blUniform3iARB; - PFNGLUNIFORM4IARBPROC blUniform4iARB; - PFNGLUNIFORM1FVARBPROC blUniform1fvARB; - PFNGLUNIFORM2FVARBPROC blUniform2fvARB; - PFNGLUNIFORM3FVARBPROC blUniform3fvARB; - PFNGLUNIFORM4FVARBPROC blUniform4fvARB; - PFNGLUNIFORM1IVARBPROC blUniform1ivARB; - PFNGLUNIFORM2IVARBPROC blUniform2ivARB; - PFNGLUNIFORM3IVARBPROC blUniform3ivARB; - PFNGLUNIFORM4IVARBPROC blUniform4ivARB; - PFNGLUNIFORMMATRIX2FVARBPROC blUniformMatrix2fvARB; - PFNGLUNIFORMMATRIX3FVARBPROC blUniformMatrix3fvARB; - PFNGLUNIFORMMATRIX4FVARBPROC blUniformMatrix4fvARB; - PFNGLGETOBJECTPARAMETERFVARBPROC blGetObjectParameterfvARB; - PFNGLGETOBJECTPARAMETERIVARBPROC blGetObjectParameterivARB; - PFNGLGETINFOLOGARBPROC blGetInfoLogARB; - PFNGLGETATTACHEDOBJECTSARBPROC blGetAttachedObjectsARB; - PFNGLGETUNIFORMLOCATIONARBPROC blGetUniformLocationARB; - PFNGLGETACTIVEUNIFORMARBPROC blGetActiveUniformARB; - PFNGLGETUNIFORMFVARBPROC blGetUniformfvARB; - PFNGLGETUNIFORMIVARBPROC blGetUniformivARB; - PFNGLGETSHADERSOURCEARBPROC blGetShaderSourceARB; -#endif - -#ifdef GL_ARB_vertex_shader -PFNGLBINDATTRIBLOCATIONARBPROC blBindAttribLocationARB; -PFNGLGETACTIVEATTRIBARBPROC blGetActiveAttribARB; -PFNGLGETATTRIBLOCATIONARBPROC blGetAttribLocationARB; -#endif - -#ifdef GL_ARB_vertex_program - PFNGLVERTEXATTRIB1FARBPROC blVertexAttrib1fARB; - PFNGLVERTEXATTRIB1FVARBPROC blVertexAttrib1fvARB; - PFNGLVERTEXATTRIB2FARBPROC blVertexAttrib2fARB; - PFNGLVERTEXATTRIB2FVARBPROC blVertexAttrib2fvARB; - PFNGLVERTEXATTRIB3FARBPROC blVertexAttrib3fARB; - PFNGLVERTEXATTRIB3FVARBPROC blVertexAttrib3fvARB; - PFNGLVERTEXATTRIB4FARBPROC blVertexAttrib4fARB; - PFNGLVERTEXATTRIB4FVARBPROC blVertexAttrib4fvARB; - PFNGLGETPROGRAMSTRINGARBPROC blGetProgramStringARB; - PFNGLGETVERTEXATTRIBDVARBPROC blGetVertexAttribdvARB; - PFNGLGETVERTEXATTRIBFVARBPROC blGetVertexAttribfvARB; - PFNGLGETVERTEXATTRIBIVARBPROC blGetVertexAttribivARB; -#endif - - /* -#ifdef GL_EXT_compiled_vertex_array - PFNGLLOCKARRAYSEXTPROC blLockArraysEXT; - PFNGLUNLOCKARRAYSEXTPROC blUnlockArraysEXT; -#endif -*/ - -} // namespace bgl - -using namespace bgl; -/******************************************************************************* -2. Query extension functions here - -Need to #ifdef (compile time test for extension) -Use QueryExtension("GL_EXT_name") to test at runtime. -Use bglGetProcAddress to find entry point -Use EnableExtension(_GL_EXT_...) to allow Blender to use the extension. - - ******************************************************************************/ -static void LinkExtensions() -{ - static bool doDebugMessages = m_debug; - extensions = STR_String((const char *) glGetString(GL_EXTENSIONS)).Explode(' '); - RAS_EXT_support = BL_EXTInfo(); - -#if defined(PFNGLPNTRIANGLESIATIPROC) - if (QueryExtension("GL_ATI_pn_triangles")) - { - glPNTrianglesiATI = reinterpret_cast<PFNGLPNTRIANGLESIATIPROC>(bglGetProcAddress((const GLubyte *) "glPNTrianglesiATI")); - glPNTrianglesfATI = reinterpret_cast<PFNGLPNTRIANGLESFATIPROC>(bglGetProcAddress((const GLubyte *) "glPNTrianglesfATI")); - if (glPNTrianglesiATI && glPNTrianglesfATI) { - EnableExtension(_GL_ATI_pn_triangles); - if (doDebugMessages) - std::cout << "Enabled GL_ATI_pn_triangles" << std::endl; - } else { - std::cout << "ERROR: GL_ATI_pn_triangles implementation is broken!" << std::endl; - } - } -#endif - -#ifdef GL_ARB_texture_env_combine - if (QueryExtension("GL_ARB_texture_env_combine")) - { - EnableExtension(_GL_ARB_texture_env_combine); - RAS_EXT_support._ARB_texture_env_combine = 1; - if (doDebugMessages) - { - std::cout << "Detected GL_ARB_texture_env_combine" << std::endl; - } - } -#endif - -#ifdef GL_ARB_texture_cube_map - if (QueryExtension("GL_ARB_texture_cube_map")) - { - EnableExtension(_GL_ARB_texture_cube_map); - RAS_EXT_support._ARB_texture_cube_map = 1; - if (doDebugMessages) - std::cout << "Detected GL_ARB_texture_cube_map" << std::endl; - } -#endif - -#if defined(GL_ARB_multitexture) && defined(WITH_GLEXT) - if (!getenv("WITHOUT_GLEXT")) { - if (QueryExtension("GL_ARB_multitexture")) { - bgl::blActiveTextureARB = reinterpret_cast<PFNGLACTIVETEXTUREARBPROC>(bglGetProcAddress((const GLubyte *) "glActiveTextureARB")); - bgl::blClientActiveTextureARB = reinterpret_cast<PFNGLCLIENTACTIVETEXTUREARBPROC>(bglGetProcAddress((const GLubyte *) "glClientActiveTextureARB")); - bgl::blMultiTexCoord1dARB = reinterpret_cast<PFNGLMULTITEXCOORD1DARBPROC>(bglGetProcAddress((const GLubyte *) "glMultiTexCoord1dARB")); - bgl::blMultiTexCoord1dvARB = reinterpret_cast<PFNGLMULTITEXCOORD1DVARBPROC>(bglGetProcAddress((const GLubyte *) "glMultiTexCoord1dvARB")); - bgl::blMultiTexCoord1fARB = reinterpret_cast<PFNGLMULTITEXCOORD1FARBPROC>(bglGetProcAddress((const GLubyte *) "glMultiTexCoord1fARB")); - bgl::blMultiTexCoord1fvARB = reinterpret_cast<PFNGLMULTITEXCOORD1FVARBPROC>(bglGetProcAddress((const GLubyte *) "glMultiTexCoord1fvARB")); - bgl::blMultiTexCoord1iARB = reinterpret_cast<PFNGLMULTITEXCOORD1IARBPROC>(bglGetProcAddress((const GLubyte *) "glMultiTexCoord1iARB")); - bgl::blMultiTexCoord1ivARB = reinterpret_cast<PFNGLMULTITEXCOORD1IVARBPROC>(bglGetProcAddress((const GLubyte *) "glMultiTexCoord1ivARB")); - bgl::blMultiTexCoord1sARB = reinterpret_cast<PFNGLMULTITEXCOORD1SARBPROC>(bglGetProcAddress((const GLubyte *) "glMultiTexCoord1sARB")); - bgl::blMultiTexCoord1svARB = reinterpret_cast<PFNGLMULTITEXCOORD1SVARBPROC>(bglGetProcAddress((const GLubyte *) "glMultiTexCoord1svARB")); - bgl::blMultiTexCoord2dARB = reinterpret_cast<PFNGLMULTITEXCOORD2DARBPROC>(bglGetProcAddress((const GLubyte *) "glMultiTexCoord2dARB")); - bgl::blMultiTexCoord2dvARB = reinterpret_cast<PFNGLMULTITEXCOORD2DVARBPROC>(bglGetProcAddress((const GLubyte *) "glMultiTexCoord2dvARB")); - bgl::blMultiTexCoord2fARB = reinterpret_cast<PFNGLMULTITEXCOORD2FARBPROC>(bglGetProcAddress((const GLubyte *) "glMultiTexCoord2fARB")); - bgl::blMultiTexCoord2fvARB = reinterpret_cast<PFNGLMULTITEXCOORD2FVARBPROC>(bglGetProcAddress((const GLubyte *) "glMultiTexCoord2fvARB")); - bgl::blMultiTexCoord2iARB = reinterpret_cast<PFNGLMULTITEXCOORD2IARBPROC>(bglGetProcAddress((const GLubyte *) "glMultiTexCoord2iARB")); - bgl::blMultiTexCoord2ivARB = reinterpret_cast<PFNGLMULTITEXCOORD2IVARBPROC>(bglGetProcAddress((const GLubyte *) "glMultiTexCoord2ivARB")); - bgl::blMultiTexCoord2sARB = reinterpret_cast<PFNGLMULTITEXCOORD2SARBPROC>(bglGetProcAddress((const GLubyte *) "glMultiTexCoord2sARB")); - bgl::blMultiTexCoord2svARB = reinterpret_cast<PFNGLMULTITEXCOORD2SVARBPROC>(bglGetProcAddress((const GLubyte *) "glMultiTexCoord2svARB")); - bgl::blMultiTexCoord3dARB = reinterpret_cast<PFNGLMULTITEXCOORD3DARBPROC>(bglGetProcAddress((const GLubyte *) "glMultiTexCoord3dARB")); - bgl::blMultiTexCoord3dvARB = reinterpret_cast<PFNGLMULTITEXCOORD3DVARBPROC>(bglGetProcAddress((const GLubyte *) "glMultiTexCoord3dvARB")); - bgl::blMultiTexCoord3fARB = reinterpret_cast<PFNGLMULTITEXCOORD3FARBPROC>(bglGetProcAddress((const GLubyte *) "glMultiTexCoord3fARB")); - bgl::blMultiTexCoord3fvARB = reinterpret_cast<PFNGLMULTITEXCOORD3FVARBPROC>(bglGetProcAddress((const GLubyte *) "glMultiTexCoord3fvARB")); - bgl::blMultiTexCoord3iARB = reinterpret_cast<PFNGLMULTITEXCOORD3IARBPROC>(bglGetProcAddress((const GLubyte *) "glMultiTexCoord3iARB")); - bgl::blMultiTexCoord3ivARB = reinterpret_cast<PFNGLMULTITEXCOORD3IVARBPROC>(bglGetProcAddress((const GLubyte *) "glMultiTexCoord3ivARB")); - bgl::blMultiTexCoord3sARB = reinterpret_cast<PFNGLMULTITEXCOORD3SARBPROC>(bglGetProcAddress((const GLubyte *) "glMultiTexCoord3sARB")); - bgl::blMultiTexCoord3svARB = reinterpret_cast<PFNGLMULTITEXCOORD3SVARBPROC>(bglGetProcAddress((const GLubyte *) "glMultiTexCoord3svARB")); - bgl::blMultiTexCoord4dARB = reinterpret_cast<PFNGLMULTITEXCOORD4DARBPROC>(bglGetProcAddress((const GLubyte *) "glMultiTexCoord4dARB")); - bgl::blMultiTexCoord4dvARB = reinterpret_cast<PFNGLMULTITEXCOORD4DVARBPROC>(bglGetProcAddress((const GLubyte *) "glMultiTexCoord4dvARB")); - bgl::blMultiTexCoord4fARB = reinterpret_cast<PFNGLMULTITEXCOORD4FARBPROC>(bglGetProcAddress((const GLubyte *) "glMultiTexCoord4fARB")); - bgl::blMultiTexCoord4fvARB = reinterpret_cast<PFNGLMULTITEXCOORD4FVARBPROC>(bglGetProcAddress((const GLubyte *) "glMultiTexCoord4fvARB")); - bgl::blMultiTexCoord4iARB = reinterpret_cast<PFNGLMULTITEXCOORD4IARBPROC>(bglGetProcAddress((const GLubyte *) "glMultiTexCoord4iARB")); - bgl::blMultiTexCoord4ivARB = reinterpret_cast<PFNGLMULTITEXCOORD4IVARBPROC>(bglGetProcAddress((const GLubyte *) "glMultiTexCoord4ivARB")); - bgl::blMultiTexCoord4sARB = reinterpret_cast<PFNGLMULTITEXCOORD4SARBPROC>(bglGetProcAddress((const GLubyte *) "glMultiTexCoord4sARB")); - bgl::blMultiTexCoord4svARB = reinterpret_cast<PFNGLMULTITEXCOORD4SVARBPROC>(bglGetProcAddress((const GLubyte *) "glMultiTexCoord4svARB")); - if (bgl::blActiveTextureARB && bgl::blClientActiveTextureARB && bgl::blMultiTexCoord1dARB && bgl::blMultiTexCoord1dvARB && bgl::blMultiTexCoord1fARB && bgl::blMultiTexCoord1fvARB && bgl::blMultiTexCoord1iARB && bgl::blMultiTexCoord1ivARB && bgl::blMultiTexCoord1sARB && bgl::blMultiTexCoord1svARB && bgl::blMultiTexCoord2dARB && bgl::blMultiTexCoord2dvARB && bgl::blMultiTexCoord2fARB && bgl::blMultiTexCoord2fvARB && bgl::blMultiTexCoord2iARB && bgl::blMultiTexCoord2ivARB && bgl::blMultiTexCoord2sARB && bgl::blMultiTexCoord2svARB && bgl::blMultiTexCoord3dARB && bgl::blMultiTexCoord3dvARB && bgl::blMultiTexCoord3fARB && bgl::blMultiTexCoord3fvARB && bgl::blMultiTexCoord3iARB && bgl::blMultiTexCoord3ivARB && bgl::blMultiTexCoord3sARB && bgl::blMultiTexCoord3svARB && bgl::blMultiTexCoord4dARB && bgl::blMultiTexCoord4dvARB && bgl::blMultiTexCoord4fARB && bgl::blMultiTexCoord4fvARB && bgl::blMultiTexCoord4iARB && bgl::blMultiTexCoord4ivARB && bgl::blMultiTexCoord4sARB && bgl::blMultiTexCoord4svARB) { - EnableExtension(_GL_ARB_multitexture); - RAS_EXT_support._ARB_multitexture = 1; - if (doDebugMessages) - std::cout << "Enabled GL_ARB_multitexture" << std::endl; - } else { - std::cout << "ERROR: GL_ARB_multitexture implementation is broken!" << std::endl; + if(firsttime) { + firsttime = false; + + if(debug) { + if(GLEW_ATI_pn_triangles) + std::cout << "Enabled GL_ATI_pn_triangles" << std::endl; + if(GLEW_ARB_texture_env_combine) + std::cout << "Detected GL_ARB_texture_env_combine" << std::endl; + if(GLEW_ARB_texture_cube_map) + std::cout << "Detected GL_ARB_texture_cube_map" << std::endl; + if(GLEW_ARB_multitexture) + std::cout << "Detected GL_ARB_multitexture" << std::endl; + if(GLEW_ARB_shader_objects) + std::cout << "Detected GL_ARB_shader_objects" << std::endl; + if(GLEW_ARB_vertex_shader) + std::cout << "Detected GL_ARB_vertex_shader" << std::endl; + if(GLEW_ARB_fragment_shader) + std::cout << "Detected GL_ARB_fragment_shader" << std::endl; + if(GLEW_ARB_vertex_program) + std::cout << "Detected GL_ARB_vertex_program" << std::endl; + if(GLEW_ARB_depth_texture) + std::cout << "Detected GL_ARB_depth_texture" << std::endl; + if(GLEW_EXT_separate_specular_color) + std::cout << "Detected GL_EXT_separate_specular_color" << std::endl; } } } -#endif - -#if GL_ARB_shader_objects - if (QueryExtension("GL_ARB_shader_objects")) - { - bgl::blDeleteObjectARB = reinterpret_cast<PFNGLDELETEOBJECTARBPROC>(bglGetProcAddress((const GLubyte *) "glDeleteObjectARB")); - bgl::blGetHandleARB = reinterpret_cast<PFNGLGETHANDLEARBPROC>(bglGetProcAddress((const GLubyte *) "glGetHandleARB")); - bgl::blDetachObjectARB = reinterpret_cast<PFNGLDETACHOBJECTARBPROC>(bglGetProcAddress((const GLubyte *) "glDetachObjectARB")); - bgl::blCreateShaderObjectARB = reinterpret_cast<PFNGLCREATESHADEROBJECTARBPROC>(bglGetProcAddress((const GLubyte *) "glCreateShaderObjectARB")); - bgl::blShaderSourceARB = reinterpret_cast<PFNGLSHADERSOURCEARBPROC>(bglGetProcAddress((const GLubyte *) "glShaderSourceARB")); - bgl::blCompileShaderARB = reinterpret_cast<PFNGLCOMPILESHADERARBPROC>(bglGetProcAddress((const GLubyte *) "glCompileShaderARB")); - bgl::blCreateProgramObjectARB = reinterpret_cast<PFNGLCREATEPROGRAMOBJECTARBPROC>(bglGetProcAddress((const GLubyte *) "glCreateProgramObjectARB")); - bgl::blAttachObjectARB = reinterpret_cast<PFNGLATTACHOBJECTARBPROC>(bglGetProcAddress((const GLubyte *) "glAttachObjectARB")); - bgl::blLinkProgramARB = reinterpret_cast<PFNGLLINKPROGRAMARBPROC>(bglGetProcAddress((const GLubyte *) "glLinkProgramARB")); - bgl::blUseProgramObjectARB = reinterpret_cast<PFNGLUSEPROGRAMOBJECTARBPROC>(bglGetProcAddress((const GLubyte *) "glUseProgramObjectARB")); - bgl::blValidateProgramARB = reinterpret_cast<PFNGLVALIDATEPROGRAMARBPROC>(bglGetProcAddress((const GLubyte *) "glValidateProgramARB")); - bgl::blUniform1fARB = reinterpret_cast<PFNGLUNIFORM1FARBPROC>(bglGetProcAddress((const GLubyte *) "glUniform1fARB")); - bgl::blUniform2fARB = reinterpret_cast<PFNGLUNIFORM2FARBPROC>(bglGetProcAddress((const GLubyte *) "glUniform2fARB")); - bgl::blUniform3fARB = reinterpret_cast<PFNGLUNIFORM3FARBPROC>(bglGetProcAddress((const GLubyte *) "glUniform3fARB")); - bgl::blUniform4fARB = reinterpret_cast<PFNGLUNIFORM4FARBPROC>(bglGetProcAddress((const GLubyte *) "glUniform4fARB")); - bgl::blUniform1iARB = reinterpret_cast<PFNGLUNIFORM1IARBPROC>(bglGetProcAddress((const GLubyte *) "glUniform1iARB")); - bgl::blUniform2iARB = reinterpret_cast<PFNGLUNIFORM2IARBPROC>(bglGetProcAddress((const GLubyte *) "glUniform2iARB")); - bgl::blUniform3iARB = reinterpret_cast<PFNGLUNIFORM3IARBPROC>(bglGetProcAddress((const GLubyte *) "glUniform3iARB")); - bgl::blUniform4iARB = reinterpret_cast<PFNGLUNIFORM4IARBPROC>(bglGetProcAddress((const GLubyte *) "glUniform4iARB")); - bgl::blUniform1fvARB = reinterpret_cast<PFNGLUNIFORM1FVARBPROC>(bglGetProcAddress((const GLubyte *) "glUniform1fvARB")); - bgl::blUniform2fvARB = reinterpret_cast<PFNGLUNIFORM2FVARBPROC>(bglGetProcAddress((const GLubyte *) "glUniform2fvARB")); - bgl::blUniform3fvARB = reinterpret_cast<PFNGLUNIFORM3FVARBPROC>(bglGetProcAddress((const GLubyte *) "glUniform3fvARB")); - bgl::blUniform4fvARB = reinterpret_cast<PFNGLUNIFORM4FVARBPROC>(bglGetProcAddress((const GLubyte *) "glUniform4fvARB")); - bgl::blUniform1ivARB = reinterpret_cast<PFNGLUNIFORM1IVARBPROC>(bglGetProcAddress((const GLubyte *) "glUniform1ivARB")); - bgl::blUniform2ivARB = reinterpret_cast<PFNGLUNIFORM2IVARBPROC>(bglGetProcAddress((const GLubyte *) "glUniform2ivARB")); - bgl::blUniform3ivARB = reinterpret_cast<PFNGLUNIFORM3IVARBPROC>(bglGetProcAddress((const GLubyte *) "glUniform3ivARB")); - bgl::blUniform4ivARB = reinterpret_cast<PFNGLUNIFORM4IVARBPROC>(bglGetProcAddress((const GLubyte *) "glUniform4ivARB")); - bgl::blUniformMatrix2fvARB = reinterpret_cast<PFNGLUNIFORMMATRIX2FVARBPROC>(bglGetProcAddress((const GLubyte *) "glUniformMatrix2fvARB")); - bgl::blUniformMatrix3fvARB = reinterpret_cast<PFNGLUNIFORMMATRIX3FVARBPROC>(bglGetProcAddress((const GLubyte *) "glUniformMatrix3fvARB")); - bgl::blUniformMatrix4fvARB = reinterpret_cast<PFNGLUNIFORMMATRIX4FVARBPROC>(bglGetProcAddress((const GLubyte *) "glUniformMatrix4fvARB")); - bgl::blGetObjectParameterfvARB = reinterpret_cast<PFNGLGETOBJECTPARAMETERFVARBPROC>(bglGetProcAddress((const GLubyte *) "glGetObjectParameterfvARB")); - bgl::blGetObjectParameterivARB = reinterpret_cast<PFNGLGETOBJECTPARAMETERIVARBPROC>(bglGetProcAddress((const GLubyte *) "glGetObjectParameterivARB")); - bgl::blGetInfoLogARB = reinterpret_cast<PFNGLGETINFOLOGARBPROC>(bglGetProcAddress((const GLubyte *) "glGetInfoLogARB")); - bgl::blGetAttachedObjectsARB = reinterpret_cast<PFNGLGETATTACHEDOBJECTSARBPROC>(bglGetProcAddress((const GLubyte *) "glGetAttachedObjectsARB")); - bgl::blGetUniformLocationARB = reinterpret_cast<PFNGLGETUNIFORMLOCATIONARBPROC>(bglGetProcAddress((const GLubyte *) "glGetUniformLocationARB")); - bgl::blGetActiveUniformARB = reinterpret_cast<PFNGLGETACTIVEUNIFORMARBPROC>(bglGetProcAddress((const GLubyte *) "glGetActiveUniformARB")); - bgl::blGetUniformfvARB = reinterpret_cast<PFNGLGETUNIFORMFVARBPROC>(bglGetProcAddress((const GLubyte *) "glGetUniformfvARB")); - bgl::blGetUniformivARB = reinterpret_cast<PFNGLGETUNIFORMIVARBPROC>(bglGetProcAddress((const GLubyte *) "glGetUniformivARB")); - bgl::blGetShaderSourceARB = reinterpret_cast<PFNGLGETSHADERSOURCEARBPROC>(bglGetProcAddress((const GLubyte *) "glGetShaderSourceARB")); - if (bgl::blDeleteObjectARB && bgl::blGetHandleARB && bgl::blDetachObjectARB && bgl::blCreateShaderObjectARB && bgl::blShaderSourceARB && bgl::blCompileShaderARB && bgl::blCreateProgramObjectARB && bgl::blAttachObjectARB && bgl::blLinkProgramARB && bgl::blUseProgramObjectARB && bgl::blValidateProgramARB && bgl::blUniform1fARB && bgl::blUniform2fARB && bgl::blUniform3fARB && bgl::blUniform4fARB && bgl::blUniform1iARB && bgl::blUniform2iARB && bgl::blUniform3iARB && bgl::blUniform4iARB && bgl::blUniform1fvARB && bgl::blUniform2fvARB && bgl::blUniform3fvARB && bgl::blUniform4fvARB && bgl::blUniform1ivARB && bgl::blUniform2ivARB && bgl::blUniform3ivARB && bgl::blUniform4ivARB && bgl::blUniformMatrix2fvARB && bgl::blUniformMatrix3fvARB && bgl::blUniformMatrix4fvARB && bgl::blGetObjectParameterfvARB && bgl::blGetObjectParameterivARB && bgl::blGetInfoLogARB && bgl::blGetAttachedObjectsARB && bgl::blGetUniformLocationARB && bgl::blGetActiveUniformARB && bgl::blGetUniformfvARB && bgl::blGetUniformivARB && bgl::blGetShaderSourceARB) { - EnableExtension(_GL_ARB_shader_objects); - RAS_EXT_support._ARB_shader_objects =1; - if (doDebugMessages) - std::cout << "Enabled GL_ARB_shader_objects" << std::endl; - } else { - std::cout << "ERROR: GL_ARB_shader_objects implementation is broken!" << std::endl; - } - } -#endif - -#if GL_ARB_vertex_shader - if (QueryExtension("GL_ARB_vertex_shader")) - { - bgl::blBindAttribLocationARB = reinterpret_cast<PFNGLBINDATTRIBLOCATIONARBPROC>(bglGetProcAddress((const GLubyte *) "glBindAttribLocationARB")); - bgl::blGetActiveAttribARB = reinterpret_cast<PFNGLGETACTIVEATTRIBARBPROC>(bglGetProcAddress((const GLubyte *) "glGetActiveAttribARB")); - bgl::blGetAttribLocationARB = reinterpret_cast<PFNGLGETATTRIBLOCATIONARBPROC>(bglGetProcAddress((const GLubyte *) "glGetAttribLocationARB")); - if (bgl::blBindAttribLocationARB && bgl::blGetActiveAttribARB && bgl::blGetAttribLocationARB) { - EnableExtension(_GL_ARB_vertex_shader); - RAS_EXT_support._ARB_vertex_shader = 1; - if (doDebugMessages) - std::cout << "Enabled GL_ARB_vertex_shader" << std::endl; - } else { - std::cout << "ERROR: GL_ARB_vertex_shader implementation is broken!" << std::endl; - } - } -#endif - -#ifdef GL_ARB_fragment_shader - if (QueryExtension("GL_ARB_fragment_shader")) - { - EnableExtension(_GL_ARB_fragment_shader); - RAS_EXT_support._ARB_fragment_shader = 1; - if (doDebugMessages) - std::cout << "Detected GL_ARB_fragment_shader" << std::endl; - } -#endif - -#if defined(GL_ARB_vertex_program) - if (QueryExtension("GL_ARB_vertex_program")) - { - bgl::blVertexAttrib1fARB = reinterpret_cast<PFNGLVERTEXATTRIB1FARBPROC>(bglGetProcAddress((const GLubyte *) "glVertexAttrib1fARB")); - bgl::blVertexAttrib1fvARB = reinterpret_cast<PFNGLVERTEXATTRIB1FVARBPROC>(bglGetProcAddress((const GLubyte *) "glVertexAttrib1fvARB")); - bgl::blVertexAttrib2fARB = reinterpret_cast<PFNGLVERTEXATTRIB2FARBPROC>(bglGetProcAddress((const GLubyte *) "glVertexAttrib2fARB")); - bgl::blVertexAttrib2fvARB = reinterpret_cast<PFNGLVERTEXATTRIB2FVARBPROC>(bglGetProcAddress((const GLubyte *) "glVertexAttrib2fvARB")); - bgl::blVertexAttrib3fARB = reinterpret_cast<PFNGLVERTEXATTRIB3FARBPROC>(bglGetProcAddress((const GLubyte *) "glVertexAttrib3fARB")); - bgl::blVertexAttrib3fvARB = reinterpret_cast<PFNGLVERTEXATTRIB3FVARBPROC>(bglGetProcAddress((const GLubyte *) "glVertexAttrib3fvARB")); - bgl::blVertexAttrib4fARB = reinterpret_cast<PFNGLVERTEXATTRIB4FARBPROC>(bglGetProcAddress((const GLubyte *) "glVertexAttrib4fARB")); - bgl::blVertexAttrib4fvARB = reinterpret_cast<PFNGLVERTEXATTRIB4FVARBPROC>(bglGetProcAddress((const GLubyte *) "glVertexAttrib4fvARB")); - bgl::blGetVertexAttribdvARB = reinterpret_cast<PFNGLGETVERTEXATTRIBDVARBPROC>(bglGetProcAddress((const GLubyte *) "glGetVertexAttribdvARB")); - bgl::blGetVertexAttribfvARB = reinterpret_cast<PFNGLGETVERTEXATTRIBFVARBPROC>(bglGetProcAddress((const GLubyte *) "glGetVertexAttribfvARB")); - bgl::blGetVertexAttribivARB = reinterpret_cast<PFNGLGETVERTEXATTRIBIVARBPROC>(bglGetProcAddress((const GLubyte *) "glGetVertexAttribivARB")); - if (bgl::blVertexAttrib1fARB && bgl::blVertexAttrib1fvARB && bgl::blVertexAttrib2fARB && bgl::blVertexAttrib2fvARB && bgl::blVertexAttrib3fARB && bgl::blVertexAttrib3fvARB && bgl::blGetVertexAttribdvARB) { - EnableExtension(_GL_ARB_vertex_program); - RAS_EXT_support._ARB_vertex_program = 1; - if (doDebugMessages) - std::cout << "Enabled GL_ARB_vertex_program" << std::endl; - } else { - std::cout << "ERROR: GL_ARB_vertex_program implementation is broken!" << std::endl; - } - } -#endif - - -#ifdef GL_ARB_depth_texture - if (QueryExtension("GL_ARB_depth_texture")) - { - EnableExtension(_GL_ARB_depth_texture); - RAS_EXT_support._ARB_depth_texture = 1; - if (doDebugMessages) - { - std::cout << "Detected GL_ARB_depth_texture" << std::endl; - } - } -#endif -/* -#ifdef GL_EXT_compiled_vertex_array - if (QueryExtension("GL_EXT_compiled_vertex_array")) - { - blLockArraysEXT = reinterpret_cast<PFNGLLOCKARRAYSEXTPROC>(bglGetProcAddress((const GLubyte *) "glLockArraysEXT")); - blUnlockArraysEXT = reinterpret_cast<PFNGLUNLOCKARRAYSEXTPROC>(bglGetProcAddress((const GLubyte *) "glUnlockArraysEXT")); - if (blLockArraysEXT && blUnlockArraysEXT) { - EnableExtension(_GL_EXT_compiled_vertex_array); - RAS_EXT_support._EXT_compiled_vertex_array = 1; - if (doDebugMessages) - std::cout << "Enabled GL_EXT_compiled_vertex_array" << std::endl; - } else { - std::cout << "ERROR: GL_EXT_compiled_vertex_array implementation is broken!" << std::endl; - } - } -#endif -*/ - if (QueryExtension("GL_EXT_separate_specular_color")) - { - EnableExtension(_GL_EXT_separate_specular_color); - if (doDebugMessages) - std::cout << "Detected GL_EXT_separate_specular_color" << std::endl; - } - - doDebugMessages = false; -} +} // namespace bgl diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.h index 3e24ee204a1..2265becbdad 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.h @@ -29,513 +29,14 @@ #ifndef __RAS_GLEXTENSIONMANAGER_H__ #define __RAS_GLEXTENSIONMANAGER_H__ +#include "GL/glew.h" -#ifdef WIN32 -# include <windows.h> -# include <GL/gl.h> +/* Note: this used to have a lot more code, but now extension handling + * is done by GLEW, so it does mostly debug stuff */ -#elif defined(__APPLE__) -# define GL_GLEXT_LEGACY 1 -# include <OpenGL/gl.h> -# include <OpenGL/glu.h> - -#else /* UNIX */ -# define __glext_h_ -# include <GL/gl.h> -# include <GL/glx.h> -# undef GL_ARB_multitexture // (ubuntu) -# undef __glext_h_ -#endif - -#ifdef WITH_GLEXT -#ifdef WIN32 -# include <GL/glext.h> -#elif defined(__APPLE__) -# include "mac_compat_glext.h" -# include <OpenGL/glext.h> -#else -# include <GL/glext.h> -#endif -#endif - -#ifdef __sgi -# undef GL_ARB_vertex_program -#endif - -#include "EXT_separate_specular_color.h" -#include "ARB_multitexture.h" namespace bgl { - /** - * This is a list of all registered OpenGL extensions. - * It is available from: - * http://oss.sgi.com/projects/ogl-sample/registry/ - */ - typedef enum { - /* ARB Extensions */ - _GL_ARB_imaging, - _GL_ARB_multitexture , - _GLX_ARB_get_proc_address , - _GL_ARB_transpose_matrix , - _WGL_ARB_buffer_region , - _GL_ARB_multisample , - _GL_ARB_texture_env_add , - _GL_ARB_texture_cube_map , - _WGL_ARB_extensions_string , - _WGL_ARB_pixel_format , - _WGL_ARB_make_current_read , - _WGL_ARB_pbuffer , - _GL_ARB_texture_compression , - _GL_ARB_texture_border_clamp , - _GL_ARB_point_parameters , - _GL_ARB_vertex_blend , - _GL_ARB_matrix_palette , - _GL_ARB_texture_env_combine , - _GL_ARB_texture_env_crossbar , - _GL_ARB_texture_env_dot3 , - _WGL_ARB_render_texture , - _GL_ARB_texture_mirrored_repeat , - _GL_ARB_depth_texture , - _GL_ARB_shadow , - _GL_ARB_shadow_ambient , - _GL_ARB_window_pos , - _GL_ARB_vertex_program , - _GL_ARB_fragment_program , - _GL_ARB_vertex_buffer_object , - _GL_ARB_occlusion_query , - _GL_ARB_shader_objects , - _GL_ARB_vertex_shader , - _GL_ARB_fragment_shader , - _GL_ARB_shading_language_100 , - _GL_ARB_texture_non_power_of_two , - _GL_ARB_point_sprite , - _GL_ARB_fragment_program_shadow , - - /* Non ARB Extensions */ - _GL_EXT_abgr , - _GL_EXT_blend_color , - _GL_EXT_polygon_offset , - _GL_EXT_texture , - _GL_EXT_texture3D , - _GL_SGIS_texture_filter4 , - _GL_EXT_subtexture , - _GL_EXT_copy_texture , - _GL_EXT_histogram , - _GL_EXT_convolution , - _GL_SGI_color_matrix , - _GL_SGI_color_table , - _GL_SGIS_pixel_texture , - _GL_SGIS_texture4D , - _GL_SGI_texture_color_table , - _GL_EXT_cmyka , - _GL_EXT_texture_object , - _GL_SGIS_detail_texture , - _GL_SGIS_sharpen_texture , - _GL_EXT_packed_pixels , - _GL_SGIS_texture_lod , - _GL_SGIS_multisample , - _GL_EXT_rescale_normal , - _GLX_EXT_visual_info , - _GL_EXT_vertex_array , - _GL_EXT_misc_attribute , - _GL_SGIS_generate_mipmap , - _GL_SGIX_clipmap , - _GL_SGIX_shadow , - _GL_SGIS_texture_edge_clamp , - _GL_SGIS_texture_border_clamp , - _GL_EXT_blend_minmax , - _GL_EXT_blend_subtract , - _GL_EXT_blend_logic_op , - _GLX_SGI_swap_control , - _GLX_SGI_video_sync , - _GLX_SGI_make_current_read , - _GLX_SGIX_video_source , - _GLX_EXT_visual_rating , - _GL_SGIX_interlace , - _GLX_EXT_import_context , - _GLX_SGIX_fbconfig , - _GLX_SGIX_pbuffer , - _GL_SGIS_texture_select , - _GL_SGIX_sprite , - _GL_SGIX_texture_multi_buffer , - _GL_EXT_point_parameters , - _GL_SGIX_instruments , - _GL_SGIX_texture_scale_bias , - _GL_SGIX_framezoom , - _GL_SGIX_tag_sample_buffer , - _GL_SGIX_reference_plane , - _GL_SGIX_flush_raster , - _GLX_SGI_cushion , - _GL_SGIX_depth_texture , - _GL_SGIS_fog_function , - _GL_SGIX_fog_offset , - _GL_HP_image_transform , - _GL_HP_convolution_border_modes , - _GL_SGIX_texture_add_env , - _GL_EXT_color_subtable , - _GLU_EXT_object_space_tess , - _GL_PGI_vertex_hints , - _GL_PGI_misc_hints , - _GL_EXT_paletted_texture , - _GL_EXT_clip_volume_hint , - _GL_SGIX_list_priority , - _GL_SGIX_ir_instrument1 , - _GLX_SGIX_video_resize , - _GL_SGIX_texture_lod_bias , - _GLU_SGI_filter4_parameters , - _GLX_SGIX_dm_buffer , - _GL_SGIX_shadow_ambient , - _GLX_SGIX_swap_group , - _GLX_SGIX_swap_barrier , - _GL_EXT_index_texture , - _GL_EXT_index_material , - _GL_EXT_index_func , - _GL_EXT_index_array_formats , - _GL_EXT_compiled_vertex_array , - _GL_EXT_cull_vertex , - _GLU_EXT_nurbs_tessellator , - _GL_SGIX_ycrcb , - _GL_EXT_fragment_lighting , - _GL_IBM_rasterpos_clip , - _GL_HP_texture_lighting , - _GL_EXT_draw_range_elements , - _GL_WIN_phong_shading , - _GL_WIN_specular_fog , - _GLX_SGIS_color_range , - _GL_EXT_light_texture , - _GL_SGIX_blend_alpha_minmax , - _GL_EXT_scene_marker , - _GL_SGIX_pixel_texture_bits , - _GL_EXT_bgra , - _GL_SGIX_async , - _GL_SGIX_async_pixel , - _GL_SGIX_async_histogram , - _GL_INTEL_texture_scissor , - _GL_INTEL_parallel_arrays , - _GL_HP_occlusion_test , - _GL_EXT_pixel_transform , - _GL_EXT_pixel_transform_color_table , - _GL_EXT_shared_texture_palette , - _GLX_SGIS_blended_overlay , - _GL_EXT_separate_specular_color , - _GL_EXT_secondary_color , - _GL_EXT_texture_env , - _GL_EXT_texture_perturb_normal , - _GL_EXT_multi_draw_arrays , - _GL_EXT_fog_coord , - _GL_REND_screen_coordinates , - _GL_EXT_coordinate_frame , - _GL_EXT_texture_env_combine , - _GL_APPLE_specular_vector , - _GL_SGIX_pixel_texture , - _GL_APPLE_transform_hint , - _GL_SUNX_constant_data , - _GL_SUN_global_alpha , - _GL_SUN_triangle_list , - _GL_SUN_vertex , - _WGL_EXT_display_color_table , - _WGL_EXT_extensions_string , - _WGL_EXT_make_current_read , - _WGL_EXT_pixel_format , - _WGL_EXT_pbuffer , - _WGL_EXT_swap_control , - _GL_EXT_blend_func_separate , - _GL_INGR_color_clamp , - _GL_INGR_interlace_read , - _GL_EXT_stencil_wrap , - _WGL_EXT_depth_float , - _GL_EXT_422_pixels , - _GL_NV_texgen_reflection , - _GL_SGIX_texture_range , - _GL_SUN_convolution_border_modes , - _GLX_SUN_get_transparent_index , - _GL_EXT_texture_env_add , - _GL_EXT_texture_lod_bias , - _GL_EXT_texture_filter_anisotropic , - _GL_EXT_vertex_weighting , - _GL_NV_light_max_exponent , - _GL_NV_vertex_array_range , - _GL_NV_register_combiners , - _GL_NV_fog_distance , - _GL_NV_texgen_emboss , - _GL_NV_blend_square , - _GL_NV_texture_env_combine4 , - _GL_MESA_resize_buffers , - _GL_MESA_window_pos , - _GL_EXT_texture_compression_s3tc , - _GL_IBM_cull_vertex , - _GL_IBM_multimode_draw_arrays , - _GL_IBM_vertex_array_lists , - _GL_3DFX_texture_compression_FXT1 , - _GL_3DFX_multisample , - _GL_3DFX_tbuffer , - _WGL_EXT_multisample , - _GL_SGIX_vertex_preclip , - _GL_SGIX_resample , - _GL_SGIS_texture_color_mask , - _GLX_MESA_copy_sub_buffer , - _GLX_MESA_pixmap_colormap , - _GLX_MESA_release_buffers , - _GLX_MESA_set_3dfx_mode , - _GL_EXT_texture_env_dot3 , - _GL_ATI_texture_mirror_once , - _GL_NV_fence , - _GL_IBM_static_data , - _GL_IBM_texture_mirrored_repeat , - _GL_NV_evaluators , - _GL_NV_packed_depth_stencil , - _GL_NV_register_combiners2 , - _GL_NV_texture_compression_vtc , - _GL_NV_texture_rectangle , - _GL_NV_texture_shader , - _GL_NV_texture_shader2 , - _GL_NV_vertex_array_range2 , - _GL_NV_vertex_program , - _GLX_SGIX_visual_select_group , - _GL_SGIX_texture_coordinate_clamp , - _GLX_OML_swap_method , - _GLX_OML_sync_control , - _GL_OML_interlace , - _GL_OML_subsample , - _GL_OML_resample , - _WGL_OML_sync_control , - _GL_NV_copy_depth_to_color , - _GL_ATI_envmap_bumpmap , - _GL_ATI_fragment_shader , - _GL_ATI_pn_triangles , - _GL_ATI_vertex_array_object , - _GL_EXT_vertex_shader , - _GL_ATI_vertex_streams , - _WGL_I3D_digital_video_control , - _WGL_I3D_gamma , - _WGL_I3D_genlock , - _WGL_I3D_image_buffer , - _WGL_I3D_swap_frame_lock , - _WGL_I3D_swap_frame_usage , - _GL_ATI_element_array , - _GL_SUN_mesh_array , - _GL_SUN_slice_accum , - _GL_NV_multisample_filter_hint , - _GL_NV_depth_clamp , - _GL_NV_occlusion_query , - _GL_NV_point_sprite , - _WGL_NV_render_depth_texture , - _WGL_NV_render_texture_rectangle , - _GL_NV_texture_shader3 , - _GL_NV_vertex_program1_1 , - _GL_EXT_shadow_funcs , - _GL_EXT_stencil_two_side , - _GL_ATI_text_fragment_shader , - _GL_APPLE_client_storage , - _GL_APPLE_element_array , - _GL_APPLE_fence , - _GL_APPLE_vertex_array_object , - _GL_APPLE_vertex_array_range , - _GL_APPLE_ycbcr_422 , - _GL_S3_s3tc , - _GL_ATI_draw_buffers , - _WGL_ATI_pixel_format_float , - _GL_ATI_texture_env_combine3 , - _GL_ATI_texture_float , - _GL_NV_float_buffer , - _GL_NV_fragment_program , - _GL_NV_half_float , - _GL_NV_pixel_data_range , - _GL_NV_primitive_restart , - _GL_NV_texture_expand_normal , - _GL_NV_vertex_program2 , - _GL_ATI_map_object_buffer , - _GL_ATI_separate_stencil , - _GL_ATI_vertex_attrib_array_object , - _GL_OES_byte_coordinates , - _GL_OES_fixed_point , - _GL_OES_single_precision , - _GL_OES_compressed_paletted_texture , - _GL_OES_read_format , - _GL_OES_query_matrix , - _GL_EXT_depth_bounds_test , - _GL_EXT_texture_mirror_clamp , - _GL_EXT_blend_equation_separate , - _GL_MESA_pack_invert , - _GL_MESA_ycbcr_texture, - - /* Finished */ - _BGL_TEST, - NUM_EXTENSIONS - } ExtensionName; - - /** - * Checks at runtime whether OpenGL supports the named extension. - * Returns true if OpenGL supports the given extension. - * - * @param name The extension name to check. - */ - bool QueryExtension(ExtensionName name); - /** - * Checks the OpenGL version. - * Returns true if OpenGL is at least the given version. - * - * @param major The major version required - * @param minor The minor version required - */ - bool QueryVersion(int major, int minor); - /** - * This will dynamically link all runtime supported extensions into - * the binary. - * - * @param debug Enable debug printing. This will print debugging info - * when extensions are loaded. - */ - void InitExtensions(int debug); - -#if defined(PFNGLPNTRIANGLESIATIPROC) -extern PFNGLPNTRIANGLESIATIPROC blPNTrianglesiATI; -extern PFNGLPNTRIANGLESFATIPROC blPNTrianglesfATI; -#endif - - -// quick runtime checks -typedef struct BL_EXTInfo -{ - BL_EXTInfo(): - _ARB_multitexture(0), - _ARB_texture_env_combine(0), - _EXT_blend_color(0), - _ARB_texture_cube_map(0), - _ARB_shader_objects(0), - _ARB_vertex_shader(0), - _ARB_fragment_shader(0), - _EXT_texture3D(0), - _ARB_vertex_program(0), - _ARB_depth_texture(0), - _EXT_compiled_vertex_array(0) - { - // - } - bool _ARB_multitexture; - bool _ARB_texture_env_combine; - bool _EXT_blend_color; - bool _ARB_texture_cube_map; - bool _ARB_shader_objects; - bool _ARB_vertex_shader; - bool _ARB_fragment_shader; - bool _EXT_texture3D; - bool _ARB_vertex_program; - bool _ARB_depth_texture; - bool _EXT_compiled_vertex_array; -}BL_EXTInfo; - -extern BL_EXTInfo RAS_EXT_support; - -#ifdef GL_ARB_multitexture // defined in glext.h now... -extern int max_texture_units; -extern PFNGLACTIVETEXTUREARBPROC blActiveTextureARB; -extern PFNGLCLIENTACTIVETEXTUREARBPROC blClientActiveTextureARB; -extern PFNGLMULTITEXCOORD1DARBPROC blMultiTexCoord1dARB; -extern PFNGLMULTITEXCOORD1DVARBPROC blMultiTexCoord1dvARB; -extern PFNGLMULTITEXCOORD1FARBPROC blMultiTexCoord1fARB; -extern PFNGLMULTITEXCOORD1FVARBPROC blMultiTexCoord1fvARB; -extern PFNGLMULTITEXCOORD1IARBPROC blMultiTexCoord1iARB; -extern PFNGLMULTITEXCOORD1IVARBPROC blMultiTexCoord1ivARB; -extern PFNGLMULTITEXCOORD1SARBPROC blMultiTexCoord1sARB; -extern PFNGLMULTITEXCOORD1SVARBPROC blMultiTexCoord1svARB; -extern PFNGLMULTITEXCOORD2DARBPROC blMultiTexCoord2dARB; -extern PFNGLMULTITEXCOORD2DVARBPROC blMultiTexCoord2dvARB; -extern PFNGLMULTITEXCOORD2FARBPROC blMultiTexCoord2fARB; -extern PFNGLMULTITEXCOORD2FVARBPROC blMultiTexCoord2fvARB; -extern PFNGLMULTITEXCOORD2IARBPROC blMultiTexCoord2iARB; -extern PFNGLMULTITEXCOORD2IVARBPROC blMultiTexCoord2ivARB; -extern PFNGLMULTITEXCOORD2SARBPROC blMultiTexCoord2sARB; -extern PFNGLMULTITEXCOORD2SVARBPROC blMultiTexCoord2svARB; -extern PFNGLMULTITEXCOORD3DARBPROC blMultiTexCoord3dARB; -extern PFNGLMULTITEXCOORD3DVARBPROC blMultiTexCoord3dvARB; -extern PFNGLMULTITEXCOORD3FARBPROC blMultiTexCoord3fARB; -extern PFNGLMULTITEXCOORD3FVARBPROC blMultiTexCoord3fvARB; -extern PFNGLMULTITEXCOORD3IARBPROC blMultiTexCoord3iARB; -extern PFNGLMULTITEXCOORD3IVARBPROC blMultiTexCoord3ivARB; -extern PFNGLMULTITEXCOORD3SARBPROC blMultiTexCoord3sARB; -extern PFNGLMULTITEXCOORD3SVARBPROC blMultiTexCoord3svARB; -extern PFNGLMULTITEXCOORD4DARBPROC blMultiTexCoord4dARB; -extern PFNGLMULTITEXCOORD4DVARBPROC blMultiTexCoord4dvARB; -extern PFNGLMULTITEXCOORD4FARBPROC blMultiTexCoord4fARB; -extern PFNGLMULTITEXCOORD4FVARBPROC blMultiTexCoord4fvARB; -extern PFNGLMULTITEXCOORD4IARBPROC blMultiTexCoord4iARB; -extern PFNGLMULTITEXCOORD4IVARBPROC blMultiTexCoord4ivARB; -extern PFNGLMULTITEXCOORD4SARBPROC blMultiTexCoord4sARB; -extern PFNGLMULTITEXCOORD4SVARBPROC blMultiTexCoord4svARB; -#endif - - -#ifdef GL_ARB_shader_objects -extern PFNGLDELETEOBJECTARBPROC blDeleteObjectARB; -extern PFNGLGETHANDLEARBPROC blGetHandleARB; -extern PFNGLDETACHOBJECTARBPROC blDetachObjectARB; -extern PFNGLCREATESHADEROBJECTARBPROC blCreateShaderObjectARB; -extern PFNGLSHADERSOURCEARBPROC blShaderSourceARB; -extern PFNGLCOMPILESHADERARBPROC blCompileShaderARB; -extern PFNGLCREATEPROGRAMOBJECTARBPROC blCreateProgramObjectARB; -extern PFNGLATTACHOBJECTARBPROC blAttachObjectARB; -extern PFNGLLINKPROGRAMARBPROC blLinkProgramARB; -extern PFNGLUSEPROGRAMOBJECTARBPROC blUseProgramObjectARB; -extern PFNGLVALIDATEPROGRAMARBPROC blValidateProgramARB; -extern PFNGLUNIFORM1FARBPROC blUniform1fARB; -extern PFNGLUNIFORM2FARBPROC blUniform2fARB; -extern PFNGLUNIFORM3FARBPROC blUniform3fARB; -extern PFNGLUNIFORM4FARBPROC blUniform4fARB; -extern PFNGLUNIFORM1IARBPROC blUniform1iARB; -extern PFNGLUNIFORM2IARBPROC blUniform2iARB; -extern PFNGLUNIFORM3IARBPROC blUniform3iARB; -extern PFNGLUNIFORM4IARBPROC blUniform4iARB; -extern PFNGLUNIFORM1FVARBPROC blUniform1fvARB; -extern PFNGLUNIFORM2FVARBPROC blUniform2fvARB; -extern PFNGLUNIFORM3FVARBPROC blUniform3fvARB; -extern PFNGLUNIFORM4FVARBPROC blUniform4fvARB; -extern PFNGLUNIFORM1IVARBPROC blUniform1ivARB; -extern PFNGLUNIFORM2IVARBPROC blUniform2ivARB; -extern PFNGLUNIFORM3IVARBPROC blUniform3ivARB; -extern PFNGLUNIFORM4IVARBPROC blUniform4ivARB; -extern PFNGLUNIFORMMATRIX2FVARBPROC blUniformMatrix2fvARB; -extern PFNGLUNIFORMMATRIX3FVARBPROC blUniformMatrix3fvARB; -extern PFNGLUNIFORMMATRIX4FVARBPROC blUniformMatrix4fvARB; -extern PFNGLGETOBJECTPARAMETERFVARBPROC blGetObjectParameterfvARB; -extern PFNGLGETOBJECTPARAMETERIVARBPROC blGetObjectParameterivARB; -extern PFNGLGETINFOLOGARBPROC blGetInfoLogARB; -extern PFNGLGETATTACHEDOBJECTSARBPROC blGetAttachedObjectsARB; -extern PFNGLGETUNIFORMLOCATIONARBPROC blGetUniformLocationARB; -extern PFNGLGETACTIVEUNIFORMARBPROC blGetActiveUniformARB; -extern PFNGLGETUNIFORMFVARBPROC blGetUniformfvARB; -extern PFNGLGETUNIFORMIVARBPROC blGetUniformivARB; -extern PFNGLGETSHADERSOURCEARBPROC blGetShaderSourceARB; -#endif - -#ifdef GL_ARB_vertex_shader -extern PFNGLBINDATTRIBLOCATIONARBPROC blBindAttribLocationARB; -extern PFNGLGETACTIVEATTRIBARBPROC blGetActiveAttribARB; -extern PFNGLGETATTRIBLOCATIONARBPROC blGetAttribLocationARB; -#endif - -#ifdef GL_ARB_vertex_program -extern PFNGLVERTEXATTRIB1FARBPROC blVertexAttrib1fARB; -extern PFNGLVERTEXATTRIB1FVARBPROC blVertexAttrib1fvARB; -extern PFNGLVERTEXATTRIB2FARBPROC blVertexAttrib2fARB; -extern PFNGLVERTEXATTRIB2FVARBPROC blVertexAttrib2fvARB; -extern PFNGLVERTEXATTRIB3FARBPROC blVertexAttrib3fARB; -extern PFNGLVERTEXATTRIB3FVARBPROC blVertexAttrib3fvARB; -extern PFNGLVERTEXATTRIB4FARBPROC blVertexAttrib4fARB; -extern PFNGLVERTEXATTRIB4FVARBPROC blVertexAttrib4fvARB; -extern PFNGLGETPROGRAMSTRINGARBPROC blGetProgramStringARB; -extern PFNGLGETVERTEXATTRIBDVARBPROC blGetVertexAttribdvARB; -extern PFNGLGETVERTEXATTRIBFVARBPROC blGetVertexAttribfvARB; -extern PFNGLGETVERTEXATTRIBIVARBPROC blGetVertexAttribivARB; -#endif - -/* -#ifdef GL_EXT_compiled_vertex_array -extern PFNGLLOCKARRAYSEXTPROC blLockArraysEXT; -extern PFNGLUNLOCKARRAYSEXTPROC blUnlockArraysEXT; -#endif -*/ + void InitExtensions(bool debug); } /* namespace bgl */ - #endif /* __RAS_GLEXTENSIONMANAGER_H__ */ diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp index afa98fdb274..39080b80492 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp @@ -6,15 +6,10 @@ #ifdef WIN32 #include <windows.h> #endif // WIN32 -#ifdef __APPLE__ -#define GL_GLEXT_LEGACY 1 -#include <OpenGL/gl.h> -#else -#include <GL/gl.h> -#endif + +#include "GL/glew.h" #include "RAS_TexVert.h" -#include "RAS_GLExtensionManager.h" #include "MT_assert.h" //#ifndef NDEBUG @@ -27,8 +22,8 @@ RAS_ListSlot::RAS_ListSlot(RAS_ListRasterizer* rasty) : KX_ListSlot(), - m_flag(LIST_MODIFY|LIST_CREATE), m_list(0), + m_flag(LIST_MODIFY|LIST_CREATE), m_rasty(rasty) { } @@ -176,7 +171,7 @@ void RAS_ListRasterizer::IndexPrimitives( RAS_ListSlot* localSlot =0; // useObjectColor(are we updating every frame?) - if(!useObjectColor) { + if(!useObjectColor && slot) { localSlot = FindOrAdd(vertexarrays, slot); localSlot->DrawList(); if(localSlot->End()) { @@ -203,7 +198,7 @@ void RAS_ListRasterizer::IndexPrimitives( ); } - if(!useObjectColor) { + if(!useObjectColor && slot) { localSlot->EndList(); *slot = localSlot; } @@ -223,7 +218,7 @@ void RAS_ListRasterizer::IndexPrimitivesMulti( RAS_ListSlot* localSlot =0; // useObjectColor(are we updating every frame?) - if(!useObjectColor) { + if(!useObjectColor && slot) { localSlot = FindOrAdd(vertexarrays, slot); localSlot->DrawList(); @@ -251,7 +246,7 @@ void RAS_ListRasterizer::IndexPrimitivesMulti( ); } - if(!useObjectColor) { + if(!useObjectColor && slot) { localSlot->EndList(); *slot = localSlot; } diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp index f99121e5b7c..d3c0426de86 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp @@ -31,33 +31,13 @@ #include "RAS_OpenGLRasterizer.h" -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#ifdef WIN32 -#include <windows.h> -#endif // WIN32 -#ifdef __APPLE__ -#define GL_GLEXT_LEGACY 1 -#include <OpenGL/gl.h> -#include <OpenGL/glu.h> -#else -#include <GL/gl.h> -#if defined(__sun__) && !defined(__sparc__) -#include <mesa/glu.h> -#else -#include <GL/glu.h> -#endif -#endif +#include "GL/glew.h" #include "RAS_Rect.h" #include "RAS_TexVert.h" #include "MT_CmMatrix4x4.h" #include "RAS_IRenderTools.h" // rendering text -#include "RAS_GLExtensionManager.h" - /** * 32x32 bit masks for vinterlace stereo mode */ @@ -83,10 +63,11 @@ RAS_OpenGLRasterizer::RAS_OpenGLRasterizer(RAS_ICanvas* canvas) m_focallength(0.0), m_setfocallength(false), m_noOfScanlines(32), - m_useTang(false), - m_materialCachingInfo(0), m_motionblur(0), - m_motionblurvalue(-1.0) + m_motionblurvalue(-1.0), + m_texco_num(0), + m_attrib_num(0), + m_materialCachingInfo(0) { m_viewmatrix.Identity(); @@ -335,7 +316,7 @@ void RAS_OpenGLRasterizer::Exit() glDisable(GL_POLYGON_STIPPLE); glDisable(GL_LIGHTING); - if (bgl::QueryExtension(bgl::_GL_EXT_separate_specular_color) || bgl::QueryVersion(1, 2)) + if (GLEW_EXT_separate_specular_color || GLEW_VERSION_1_2) glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SINGLE_COLOR); EndFrame(); @@ -802,277 +783,6 @@ void RAS_OpenGLRasterizer::IndexPrimitives(const vecVertexArray & vertexarrays, } -void RAS_OpenGLRasterizer::IndexPrimitives_Ex(const vecVertexArray & vertexarrays, - const vecIndexArrays & indexarrays, - int mode, - class RAS_IPolyMaterial* polymat, - class RAS_IRenderTools* rendertools, - bool useObjectColor, - const MT_Vector4& rgbacolor - ) -{ - bool recalc; - GLenum drawmode; - switch (mode) - { - case 0: - drawmode = GL_TRIANGLES; - break; - case 1: - drawmode = GL_LINES; - break; - case 2: - drawmode = GL_QUADS; - break; - default: - drawmode = GL_LINES; - break; - } - - const RAS_TexVert* vertexarray ; - unsigned int numindices,vt; - - for (vt=0;vt<vertexarrays.size();vt++) - { - vertexarray = &((*vertexarrays[vt]) [0]); - const KX_IndexArray & indexarray = (*indexarrays[vt]); - numindices = indexarray.size(); - - if (!numindices) - continue; - - int vindex=0; - switch (mode) - { - case 1: - { - glBegin(GL_LINES); - vindex=0; - for (unsigned int i=0;i<numindices;i+=2) - { - glVertex3fv(vertexarray[(indexarray[vindex++])].getLocalXYZ()); - glVertex3fv(vertexarray[(indexarray[vindex++])].getLocalXYZ()); - } - glEnd(); - } - break; - case 2: - { - glBegin(GL_QUADS); - vindex=0; - if (useObjectColor) - { - for (unsigned int i=0;i<numindices;i+=4) - { - MT_Point3 mv1, mv2, mv3, mv4, fnor; - /* Calc a new face normal */ - - if (vertexarray[(indexarray[vindex])].getFlag() & TV_CALCFACENORMAL) - recalc= true; - else - recalc=false; - - if (recalc){ - mv1 = MT_Point3(vertexarray[(indexarray[vindex])].getLocalXYZ()); - mv2 = MT_Point3(vertexarray[(indexarray[vindex+1])].getLocalXYZ()); - mv3 = MT_Point3(vertexarray[(indexarray[vindex+2])].getLocalXYZ()); - mv4 = MT_Point3(vertexarray[(indexarray[vindex+2])].getLocalXYZ()); - - fnor = (((mv2-mv1).cross(mv3-mv2))+((mv4-mv3).cross(mv1-mv4))).safe_normalized(); - - glNormal3f(fnor[0], fnor[1], fnor[2]); - } - - glColor4d(rgbacolor[0], rgbacolor[1], rgbacolor[2], rgbacolor[3]); - - if (!recalc) - glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - glTexCoord2fv(vertexarray[(indexarray[vindex])].getUV1()); - glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); - vindex++; - - if (!recalc) - glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - glTexCoord2fv(vertexarray[(indexarray[vindex])].getUV1()); - glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); - vindex++; - - if (!recalc) - glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - glTexCoord2fv(vertexarray[(indexarray[vindex])].getUV1()); - glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); - vindex++; - - if (!recalc) - glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - glTexCoord2fv(vertexarray[(indexarray[vindex])].getUV1()); - glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); - vindex++; - } - } - else - { - for (unsigned int i=0;i<numindices;i+=4) - { - // This looks curiously endian unsafe to me. - // However it depends on the way the colors are packed into - // the m_rgba field of RAS_TexVert - MT_Point3 mv1, mv2, mv3, mv4, fnor; - /* Calc a new face normal */ - - if (vertexarray[(indexarray[vindex])].getFlag() & TV_CALCFACENORMAL) - recalc= true; - else - recalc=false; - - - if (recalc){ - mv1 = MT_Point3(vertexarray[(indexarray[vindex])].getLocalXYZ()); - mv2 = MT_Point3(vertexarray[(indexarray[vindex+1])].getLocalXYZ()); - mv3 = MT_Point3(vertexarray[(indexarray[vindex+2])].getLocalXYZ()); - mv4 = MT_Point3(vertexarray[(indexarray[vindex+3])].getLocalXYZ()); - - fnor = (((mv2-mv1).cross(mv3-mv2))+((mv4-mv3).cross(mv1-mv4))).safe_normalized(); - - glNormal3f(fnor[0], fnor[1], fnor[2]); - } - - glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA())); - if (!recalc) - glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - glTexCoord2fv(vertexarray[(indexarray[vindex])].getUV1()); - glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); - vindex++; - - glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA())); - if (!recalc) - glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - glTexCoord2fv(vertexarray[(indexarray[vindex])].getUV1()); - glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); - vindex++; - - glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA())); - if (!recalc) - glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - glTexCoord2fv(vertexarray[(indexarray[vindex])].getUV1()); - glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); - vindex++; - - glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA())); - if (!recalc) - glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - glTexCoord2fv(vertexarray[(indexarray[vindex])].getUV1()); - glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); - vindex++; - } - } - glEnd(); - break; - } - case 0: - { - glBegin(GL_TRIANGLES); - vindex=0; - if (useObjectColor) - { - for (unsigned int i=0;i<numindices;i+=3) - { - MT_Point3 mv1, mv2, mv3, fnor; - /* Calc a new face normal */ - - if (vertexarray[(indexarray[vindex])].getFlag() & TV_CALCFACENORMAL) - recalc= true; - else - recalc=false; - - if (recalc){ - mv1 = MT_Point3(vertexarray[(indexarray[vindex])].getLocalXYZ()); - mv2 = MT_Point3(vertexarray[(indexarray[vindex+1])].getLocalXYZ()); - mv3 = MT_Point3(vertexarray[(indexarray[vindex+2])].getLocalXYZ()); - - fnor = ((mv2-mv1).cross(mv3-mv2)).safe_normalized(); - glNormal3f(fnor[0], fnor[1], fnor[2]); - } - - glColor4d(rgbacolor[0], rgbacolor[1], rgbacolor[2], rgbacolor[3]); - - if (!recalc) - glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - glTexCoord2fv(vertexarray[(indexarray[vindex])].getUV1()); - glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); - vindex++; - - if (!recalc) - glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - glTexCoord2fv(vertexarray[(indexarray[vindex])].getUV1()); - glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); - vindex++; - - if (!recalc) - glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - glTexCoord2fv(vertexarray[(indexarray[vindex])].getUV1()); - glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); - vindex++; - } - } - else - { - for (unsigned int i=0;i<numindices;i+=3) - { - MT_Point3 mv1, mv2, mv3, fnor; - /* Calc a new face normal */ - - if (vertexarray[(indexarray[vindex])].getFlag() & TV_CALCFACENORMAL) - recalc= true; - else - recalc=false; - - - if (recalc){ - mv1 = MT_Point3(vertexarray[(indexarray[vindex])].getLocalXYZ()); - mv2 = MT_Point3(vertexarray[(indexarray[vindex+1])].getLocalXYZ()); - mv3 = MT_Point3(vertexarray[(indexarray[vindex+2])].getLocalXYZ()); - - fnor = ((mv2-mv1).cross(mv3-mv2)).safe_normalized(); - glNormal3f(fnor[0], fnor[1], fnor[2]); - } - - glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA())); - if (!recalc) - glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - glTexCoord2fv(vertexarray[(indexarray[vindex])].getUV1()); - glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); - vindex++; - - glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA())); - if (!recalc) - glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - glTexCoord2fv(vertexarray[(indexarray[vindex])].getUV1()); - glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); - vindex++; - - glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA())); - if (!recalc) - glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - glTexCoord2fv(vertexarray[(indexarray[vindex])].getUV1()); - glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); - vindex++; - } - } - glEnd(); - break; - } - default: - { - } - - } // switch - } // for each vertexarray - -} - - - void RAS_OpenGLRasterizer::IndexPrimitives_3DText(const vecVertexArray & vertexarrays, const vecIndexArrays & indexarrays, int mode, @@ -1206,59 +916,91 @@ void RAS_OpenGLRasterizer::IndexPrimitives_3DText(const vecVertexArray & vertexa } //for each vertexarray } -void RAS_OpenGLRasterizer::SetTexCoords(TexCoGen coords,int unit) +void RAS_OpenGLRasterizer::SetTexCoordNum(int num) +{ + m_texco_num = num; + if(m_texco_num > RAS_MAX_TEXCO) + m_texco_num = RAS_MAX_TEXCO; +} + +void RAS_OpenGLRasterizer::SetAttribNum(int num) +{ + m_attrib_num = num; + if(m_attrib_num > RAS_MAX_ATTRIB) + m_attrib_num = RAS_MAX_ATTRIB; +} + +void RAS_OpenGLRasterizer::SetTexCoord(TexCoGen coords, int unit) { // this changes from material to material - if(unit < RAS_MAX) + if(unit < RAS_MAX_TEXCO) m_texco[unit] = coords; } -void RAS_OpenGLRasterizer::SetAttrib(int type) +void RAS_OpenGLRasterizer::SetAttrib(TexCoGen coords, int unit) { - if(type == RAS_TEXTANGENT) m_useTang=true; + // this changes from material to material + if(unit < RAS_MAX_ATTRIB) + m_attrib[unit] = coords; } -void RAS_OpenGLRasterizer::TexCoord(const RAS_TexVert &tv, int enabled) +void RAS_OpenGLRasterizer::TexCoord(const RAS_TexVert &tv) { -#if defined(GL_ARB_multitexture) && defined(WITH_GLEXT) - if (!getenv("WITHOUT_GLEXT")) { - if(bgl::RAS_EXT_support._ARB_multitexture) { - for(int unit=0; unit<enabled; unit++) { - if( tv.getFlag() & TV_2NDUV && tv.getUnit() == unit ) { - bgl::blMultiTexCoord2fvARB(GL_TEXTURE0_ARB+unit, tv.getUV2()); - continue; - } - switch(m_texco[unit]) { - case RAS_TEXCO_DISABLE: - case RAS_TEXCO_OBJECT: - case RAS_TEXCO_GEN: - break; - case RAS_TEXCO_ORCO: - case RAS_TEXCO_GLOB: - bgl::blMultiTexCoord3fvARB(GL_TEXTURE0_ARB+unit, tv.getLocalXYZ()); - break; - case RAS_TEXCO_UV1: - bgl::blMultiTexCoord2fvARB(GL_TEXTURE0_ARB+unit, tv.getUV1()); - break; - case RAS_TEXCO_NORM: - bgl::blMultiTexCoord3fvARB(GL_TEXTURE0_ARB+unit, tv.getNormal()); - break; - case RAS_TEXTANGENT: - bgl::blMultiTexCoord4fvARB(GL_TEXTURE0_ARB+unit, tv.getTangent()); - break; - case RAS_TEXCO_UV2: - bgl::blMultiTexCoord2fvARB(GL_TEXTURE0_ARB+unit, tv.getUV2()); - break; - } + int unit; + + if(GLEW_ARB_multitexture) { + for(unit=0; unit<m_texco_num; unit++) { + if(tv.getFlag() & TV_2NDUV && (int)tv.getUnit() == unit) { + glMultiTexCoord2fvARB(GL_TEXTURE0_ARB+unit, tv.getUV2()); + continue; + } + switch(m_texco[unit]) { + case RAS_TEXCO_ORCO: + case RAS_TEXCO_GLOB: + glMultiTexCoord3fvARB(GL_TEXTURE0_ARB+unit, tv.getLocalXYZ()); + break; + case RAS_TEXCO_UV1: + glMultiTexCoord2fvARB(GL_TEXTURE0_ARB+unit, tv.getUV1()); + break; + case RAS_TEXCO_NORM: + glMultiTexCoord3fvARB(GL_TEXTURE0_ARB+unit, tv.getNormal()); + break; + case RAS_TEXTANGENT: + glMultiTexCoord4fvARB(GL_TEXTURE0_ARB+unit, tv.getTangent()); + break; + case RAS_TEXCO_UV2: + glMultiTexCoord2fvARB(GL_TEXTURE0_ARB+unit, tv.getUV2()); + break; + default: + break; } } } -#endif -#ifdef GL_ARB_vertex_program - if(m_useTang && bgl::RAS_EXT_support._ARB_vertex_program) - bgl::blVertexAttrib4fvARB(1/*tangent*/, tv.getTangent()); -#endif + if(GLEW_ARB_vertex_program) { + for(unit=0; unit<m_attrib_num; unit++) { + switch(m_attrib[unit]) { + case RAS_TEXCO_ORCO: + case RAS_TEXCO_GLOB: + glVertexAttrib3fvARB(unit, tv.getLocalXYZ()); + break; + case RAS_TEXCO_UV1: + glVertexAttrib2fvARB(unit, tv.getUV1()); + break; + case RAS_TEXCO_NORM: + glVertexAttrib3fvARB(unit, tv.getNormal()); + break; + case RAS_TEXTANGENT: + glVertexAttrib4fvARB(unit, tv.getTangent()); + break; + case RAS_TEXCO_UV2: + glVertexAttrib2fvARB(unit, tv.getUV2()); + break; + default: + break; + } + } + } } void RAS_OpenGLRasterizer::Tangent( const RAS_TexVert& v1, @@ -1266,30 +1008,26 @@ void RAS_OpenGLRasterizer::Tangent( const RAS_TexVert& v1, const RAS_TexVert& v3, const MT_Vector3 &no) { -#if defined(GL_ARB_multitexture) && defined(WITH_GLEXT) - if (!getenv("WITHOUT_GLEXT")) { - // TODO: set for deformer... - MT_Vector3 x1(v1.getLocalXYZ()), x2(v2.getLocalXYZ()), x3(v3.getLocalXYZ()); - MT_Vector2 uv1(v1.getUV1()), uv2(v2.getUV1()), uv3(v3.getUV1()); - MT_Vector3 dx1(x2 - x1), dx2(x3 - x1); - MT_Vector2 duv1(uv2 - uv1), duv2(uv3 - uv1); - - MT_Scalar r = 1.0 / (duv1.x() * duv2.y() - duv2.x() * duv1.y()); - duv1 *= r; - duv2 *= r; - MT_Vector3 sdir(duv2.y() * dx1 - duv1.y() * dx2); - MT_Vector3 tdir(duv1.x() * dx2 - duv2.x() * dx1); - - // Gram-Schmidt orthogonalize - MT_Vector3 t(sdir - no.cross(no.cross(sdir))); - if (!MT_fuzzyZero(t)) t /= t.length(); - - float tangent[4]; - t.getValue(tangent); - // Calculate handedness - tangent[3] = no.dot(sdir.cross(tdir)) < 0.0 ? -1.0 : 1.0; - } -#endif + // TODO: set for deformer... + MT_Vector3 x1(v1.getLocalXYZ()), x2(v2.getLocalXYZ()), x3(v3.getLocalXYZ()); + MT_Vector2 uv1(v1.getUV1()), uv2(v2.getUV1()), uv3(v3.getUV1()); + MT_Vector3 dx1(x2 - x1), dx2(x3 - x1); + MT_Vector2 duv1(uv2 - uv1), duv2(uv3 - uv1); + + MT_Scalar r = 1.0 / (duv1.x() * duv2.y() - duv2.x() * duv1.y()); + duv1 *= r; + duv2 *= r; + MT_Vector3 sdir(duv2.y() * dx1 - duv1.y() * dx2); + MT_Vector3 tdir(duv1.x() * dx2 - duv2.x() * dx1); + + // Gram-Schmidt orthogonalize + MT_Vector3 t(sdir - no.cross(no.cross(sdir))); + if (!MT_fuzzyZero(t)) t /= t.length(); + + float tangent[4]; + t.getValue(tangent); + // Calculate handedness + tangent[3] = no.dot(sdir.cross(tdir)) < 0.0 ? -1.0 : 1.0; } @@ -1304,479 +1042,192 @@ void RAS_OpenGLRasterizer::IndexPrimitivesMulti( class KX_ListSlot** slot ) { -#if defined(GL_ARB_multitexture) && defined(WITH_GLEXT) - if (!getenv("WITHOUT_GLEXT")) { - GLenum drawmode; - switch (mode) - { - case 0: - drawmode = GL_TRIANGLES; - break; - case 1: - drawmode = GL_LINES; - break; - case 2: - drawmode = GL_QUADS; - break; - default: - drawmode = GL_LINES; - break; - } - - const RAS_TexVert* vertexarray ; - unsigned int numindices,vt; + GLenum drawmode; + switch (mode) + { + case 0: + drawmode = GL_TRIANGLES; + break; + case 1: + drawmode = GL_LINES; + break; + case 2: + drawmode = GL_QUADS; + break; + default: + drawmode = GL_LINES; + break; + } - for (vt=0;vt<vertexarrays.size();vt++) - { - vertexarray = &((*vertexarrays[vt]) [0]); - const KX_IndexArray & indexarray = (*indexarrays[vt]); - numindices = indexarray.size(); - const unsigned int enabled = polymat->GetEnabled(); + const RAS_TexVert* vertexarray ; + unsigned int numindices,vt; - if (!numindices) - break; + for (vt=0;vt<vertexarrays.size();vt++) + { + vertexarray = &((*vertexarrays[vt]) [0]); + const KX_IndexArray & indexarray = (*indexarrays[vt]); + numindices = indexarray.size(); + + if (!numindices) + break; - int vindex=0; - switch (mode) + int vindex=0; + switch (mode) + { + case 1: { - case 1: + glBegin(GL_LINES); + vindex=0; + for (unsigned int i=0;i<numindices;i+=2) { - glBegin(GL_LINES); - vindex=0; - for (unsigned int i=0;i<numindices;i+=2) - { - glVertex3fv(vertexarray[(indexarray[vindex++])].getLocalXYZ()); - glVertex3fv(vertexarray[(indexarray[vindex++])].getLocalXYZ()); - } - glEnd(); + glVertex3fv(vertexarray[(indexarray[vindex++])].getLocalXYZ()); + glVertex3fv(vertexarray[(indexarray[vindex++])].getLocalXYZ()); } - break; - case 2: + glEnd(); + } + break; + case 2: + { + glBegin(GL_QUADS); + vindex=0; + if (useObjectColor) { - glBegin(GL_QUADS); - vindex=0; - if (useObjectColor) - { - for (unsigned int i=0;i<numindices;i+=4) - { - - glColor4d(rgbacolor[0], rgbacolor[1], rgbacolor[2], rgbacolor[3]); - - // - glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - TexCoord(vertexarray[(indexarray[vindex])],enabled ); - glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); - vindex++; - - // - glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - TexCoord(vertexarray[(indexarray[vindex])],enabled ); - glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); - vindex++; - - // - glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - TexCoord(vertexarray[(indexarray[vindex])],enabled ); - glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); - vindex++; - - // - glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - TexCoord(vertexarray[(indexarray[vindex])],enabled ); - glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); - vindex++; - } - } - else + for (unsigned int i=0;i<numindices;i+=4) { - for (unsigned int i=0;i<numindices;i+=4) - { - // This looks curiously endian unsafe to me. - // However it depends on the way the colors are packed into - // the m_rgba field of RAS_TexVert - - // - glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA())); - - glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - TexCoord(vertexarray[(indexarray[vindex])],enabled ); - glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); - vindex++; - - // - glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA())); - glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - TexCoord(vertexarray[(indexarray[vindex])],enabled ); - glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); - vindex++; - - // - glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA())); - glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - TexCoord(vertexarray[(indexarray[vindex])],enabled ); - glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); - vindex++; - - // - glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA())); - glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - TexCoord(vertexarray[(indexarray[vindex])],enabled ); - glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); - vindex++; - } + + glColor4d(rgbacolor[0], rgbacolor[1], rgbacolor[2], rgbacolor[3]); + + // + glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); + TexCoord(vertexarray[(indexarray[vindex])]); + glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); + vindex++; + + // + glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); + TexCoord(vertexarray[(indexarray[vindex])]); + glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); + vindex++; + + // + glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); + TexCoord(vertexarray[(indexarray[vindex])]); + glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); + vindex++; + + // + glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); + TexCoord(vertexarray[(indexarray[vindex])]); + glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); + vindex++; } - glEnd(); - break; } - case 0: + else { - glBegin(GL_TRIANGLES); - vindex=0; - if (useObjectColor) - { - for (unsigned int i=0;i<numindices;i+=3) - { - - glColor4d(rgbacolor[0], rgbacolor[1], rgbacolor[2], rgbacolor[3]); - // - glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - TexCoord(vertexarray[(indexarray[vindex])],enabled ); - glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); - vindex++; - - // - glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - TexCoord(vertexarray[(indexarray[vindex])],enabled ); - glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); - vindex++; - - // - glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - TexCoord(vertexarray[(indexarray[vindex])],enabled ); - glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); - vindex++; - } - } - else + for (unsigned int i=0;i<numindices;i+=4) { - for (unsigned int i=0;i<numindices;i+=3) - { - // - glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA())); - glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - TexCoord(vertexarray[(indexarray[vindex])],enabled ); - glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); - vindex++; + // This looks curiously endian unsafe to me. + // However it depends on the way the colors are packed into + // the m_rgba field of RAS_TexVert + + // + glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA())); + + glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); + TexCoord(vertexarray[(indexarray[vindex])]); + glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); + vindex++; - // - glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA())); - glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - TexCoord(vertexarray[(indexarray[vindex])],enabled ); - glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); - vindex++; - - // - glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA())); - glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - TexCoord(vertexarray[(indexarray[vindex])],enabled ); - glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); - vindex++; - } - } - glEnd(); - break; - } - default: - { - } - } // switch - } // for each vertexarray - } -#endif// GL_ARB_multitexture -} + // + glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA())); + glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); + TexCoord(vertexarray[(indexarray[vindex])]); + glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); + vindex++; -void RAS_OpenGLRasterizer::IndexPrimitivesMulti_Ex( - const vecVertexArray & vertexarrays, - const vecIndexArrays & indexarrays, - int mode, - class RAS_IPolyMaterial* polymat, - class RAS_IRenderTools* rendertools, - bool useObjectColor, - const MT_Vector4& rgbacolor) -{ -#if defined(GL_ARB_multitexture) && defined(WITH_GLEXT) - if (!getenv("WITHOUT_GLEXT")) { - bool recalc; - GLenum drawmode; - switch (mode) - { - case 0: - drawmode = GL_TRIANGLES; - break; - case 1: - drawmode = GL_LINES; - break; - case 2: - drawmode = GL_QUADS; - break; - default: - drawmode = GL_LINES; - break; - } - - const RAS_TexVert* vertexarray ; - unsigned int numindices,vt; + // + glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA())); + glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); + TexCoord(vertexarray[(indexarray[vindex])]); + glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); + vindex++; - for (vt=0;vt<vertexarrays.size();vt++) - { - vertexarray = &((*vertexarrays[vt]) [0]); - const KX_IndexArray & indexarray = (*indexarrays[vt]); - numindices = indexarray.size(); - const unsigned int enabled = polymat->GetEnabled(); - - if (!numindices) - continue; - - int vindex=0; - switch (mode) - { - case 1: - { - glBegin(GL_LINES); - vindex=0; - for (unsigned int i=0;i<numindices;i+=2) - { - glVertex3fv(vertexarray[(indexarray[vindex++])].getLocalXYZ()); - glVertex3fv(vertexarray[(indexarray[vindex++])].getLocalXYZ()); + // + glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA())); + glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); + TexCoord(vertexarray[(indexarray[vindex])]); + glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); + vindex++; } - glEnd(); } + glEnd(); break; - case 2: + } + case 0: + { + glBegin(GL_TRIANGLES); + vindex=0; + if (useObjectColor) { - glBegin(GL_QUADS); - vindex=0; - if (useObjectColor) + for (unsigned int i=0;i<numindices;i+=3) { - for (unsigned int i=0;i<numindices;i+=4) - { - MT_Point3 mv1, mv2, mv3, mv4, fnor; - /* Calc a new face normal */ - - if (vertexarray[(indexarray[vindex])].getFlag() & TV_CALCFACENORMAL) - recalc= true; - else - recalc=false; - - if (recalc){ - mv1 = MT_Point3(vertexarray[(indexarray[vindex])].getLocalXYZ()); - mv2 = MT_Point3(vertexarray[(indexarray[vindex+1])].getLocalXYZ()); - mv3 = MT_Point3(vertexarray[(indexarray[vindex+2])].getLocalXYZ()); - mv4 = MT_Point3(vertexarray[(indexarray[vindex+2])].getLocalXYZ()); - - fnor = (((mv2-mv1).cross(mv3-mv2))+((mv4-mv3).cross(mv1-mv4))).safe_normalized(); - - glNormal3f(fnor[0], fnor[1], fnor[2]); - } - glColor4d(rgbacolor[0], rgbacolor[1], rgbacolor[2], rgbacolor[3]); - - if (!recalc) - glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); + glColor4d(rgbacolor[0], rgbacolor[1], rgbacolor[2], rgbacolor[3]); + // + glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); + TexCoord(vertexarray[(indexarray[vindex])]); + glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); + vindex++; - TexCoord(vertexarray[(indexarray[vindex])],enabled ); - glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); - vindex++; - - if (!recalc) - glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); + // + glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); + TexCoord(vertexarray[(indexarray[vindex])]); + glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); + vindex++; - TexCoord(vertexarray[(indexarray[vindex])],enabled ); - glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); - vindex++; - - if (!recalc) - glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - - TexCoord(vertexarray[(indexarray[vindex])],enabled ); - glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); - vindex++; - - if (!recalc) - glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - TexCoord(vertexarray[(indexarray[vindex])],enabled ); - glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); - vindex++; - } - } - else - { - for (unsigned int i=0;i<numindices;i+=4) - { - // This looks curiously endian unsafe to me. - // However it depends on the way the colors are packed into - // the m_rgba field of RAS_TexVert - MT_Point3 mv1, mv2, mv3, mv4, fnor; - /* Calc a new face normal */ - - if (vertexarray[(indexarray[vindex])].getFlag() & TV_CALCFACENORMAL) - recalc= true; - else - recalc=false; - - - if (recalc){ - mv1 = MT_Point3(vertexarray[(indexarray[vindex])].getLocalXYZ()); - mv2 = MT_Point3(vertexarray[(indexarray[vindex+1])].getLocalXYZ()); - mv3 = MT_Point3(vertexarray[(indexarray[vindex+2])].getLocalXYZ()); - mv4 = MT_Point3(vertexarray[(indexarray[vindex+3])].getLocalXYZ()); - - fnor = (((mv2-mv1).cross(mv3-mv2))+((mv4-mv3).cross(mv1-mv4))).safe_normalized(); - - glNormal3f(fnor[0], fnor[1], fnor[2]); - } - - glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA())); - if (!recalc) - glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - - TexCoord(vertexarray[(indexarray[vindex])],enabled ); - glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); - vindex++; - - glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA())); - if (!recalc) - glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - - TexCoord(vertexarray[(indexarray[vindex])],enabled ); - glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); - vindex++; - - glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA())); - if (!recalc) - glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - - TexCoord(vertexarray[(indexarray[vindex])],enabled ); - glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); - vindex++; - - glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA())); - if (!recalc) - glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - - TexCoord(vertexarray[(indexarray[vindex])],enabled ); - glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); - vindex++; - } + // + glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); + TexCoord(vertexarray[(indexarray[vindex])]); + glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); + vindex++; } - glEnd(); - break; } - case 0: + else { - glBegin(GL_TRIANGLES); - vindex=0; - if (useObjectColor) - { - for (unsigned int i=0;i<numindices;i+=3) - { - MT_Point3 mv1, mv2, mv3, fnor; - /* Calc a new face normal */ - - if (vertexarray[(indexarray[vindex])].getFlag() & TV_CALCFACENORMAL) - recalc= true; - else - recalc=false; - - if (recalc){ - mv1 = MT_Point3(vertexarray[(indexarray[vindex])].getLocalXYZ()); - mv2 = MT_Point3(vertexarray[(indexarray[vindex+1])].getLocalXYZ()); - mv3 = MT_Point3(vertexarray[(indexarray[vindex+2])].getLocalXYZ()); - - fnor = ((mv2-mv1).cross(mv3-mv2)).safe_normalized(); - glNormal3f(fnor[0], fnor[1], fnor[2]); - } - - glColor4d(rgbacolor[0], rgbacolor[1], rgbacolor[2], rgbacolor[3]); - - if (!recalc) - glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - TexCoord(vertexarray[(indexarray[vindex])],enabled ); - glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); - vindex++; - - if (!recalc) - glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - TexCoord(vertexarray[(indexarray[vindex])],enabled ); - glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); - vindex++; - - if (!recalc) - glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - TexCoord(vertexarray[(indexarray[vindex])],enabled ); - glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); - vindex++; - } - } - else + for (unsigned int i=0;i<numindices;i+=3) { - for (unsigned int i=0;i<numindices;i+=3) - { - MT_Point3 mv1, mv2, mv3, fnor; - /* Calc a new face normal */ - - if (vertexarray[(indexarray[vindex])].getFlag() & TV_CALCFACENORMAL) - recalc= true; - else - recalc=false; - - - if (recalc){ - mv1 = MT_Point3(vertexarray[(indexarray[vindex])].getLocalXYZ()); - mv2 = MT_Point3(vertexarray[(indexarray[vindex+1])].getLocalXYZ()); - mv3 = MT_Point3(vertexarray[(indexarray[vindex+2])].getLocalXYZ()); - - fnor = ((mv2-mv1).cross(mv3-mv2)).safe_normalized(); - glNormal3f(fnor[0], fnor[1], fnor[2]); - } - - glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA())); - if (!recalc) - glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - TexCoord(vertexarray[(indexarray[vindex])],enabled ); - glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); - vindex++; - - glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA())); - if (!recalc) - glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - TexCoord(vertexarray[(indexarray[vindex])],enabled ); - glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); - vindex++; - - glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA())); - if (!recalc) - glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); - TexCoord(vertexarray[(indexarray[vindex])],enabled ); - glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); - vindex++; - } + // + glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA())); + glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); + TexCoord(vertexarray[(indexarray[vindex])]); + glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); + vindex++; + + // + glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA())); + glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); + TexCoord(vertexarray[(indexarray[vindex])]); + glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); + vindex++; + + // + glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA())); + glNormal3fv(vertexarray[(indexarray[vindex])].getNormal()); + TexCoord(vertexarray[(indexarray[vindex])]); + glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ()); + vindex++; } - glEnd(); - break; - } - default: - { } - - } // switch - } // for each vertexarray - } -#endif + glEnd(); + break; + } + default: + { + } + } // switch + } // for each vertexarray } - - void RAS_OpenGLRasterizer::SetProjectionMatrix(MT_CmMatrix4x4 &mat) { glMatrixMode(GL_PROJECTION); diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h index 23714a12151..1f0709e081a 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h @@ -41,7 +41,8 @@ using namespace std; #include "RAS_MaterialBucket.h" #include "RAS_ICanvas.h" -#define RAS_MAX 3// match in BL_Material +#define RAS_MAX_TEXCO 3 // match in BL_Material +#define RAS_MAX_ATTRIB 16 // match in BL_BlenderShader struct OglDebugLine { @@ -94,8 +95,10 @@ class RAS_OpenGLRasterizer : public RAS_IRasterizer protected: int m_drawingmode; - TexCoGen m_texco[RAS_MAX]; - bool m_useTang; + TexCoGen m_texco[RAS_MAX_TEXCO]; + TexCoGen m_attrib[RAS_MAX_ATTRIB]; + int m_texco_num; + int m_attrib_num; /** Stores the caching information for the last material activated. */ RAS_IPolyMaterial::TCachingInfo m_materialCachingInfo; @@ -153,16 +156,6 @@ public: class KX_ListSlot** slot ); - virtual void IndexPrimitives_Ex( - const vecVertexArray& vertexarrays, - const vecIndexArrays & indexarrays, - int mode, - class RAS_IPolyMaterial* polymat, - class RAS_IRenderTools* rendertools, - bool useObjectColor, - const MT_Vector4& rgbacolor - ); - virtual void IndexPrimitives_3DText( const vecVertexArray& vertexarrays, const vecIndexArrays & indexarrays, @@ -183,15 +176,6 @@ public: const MT_Vector4& rgbacolor, class KX_ListSlot** slot); - virtual void IndexPrimitivesMulti_Ex( - const vecVertexArray& vertexarrays, - const vecIndexArrays & indexarrays, - int mode, - class RAS_IPolyMaterial* polymat, - class RAS_IRenderTools* rendertools, - bool useObjectColor, - const MT_Vector4& rgbacolor); - virtual void SetProjectionMatrix(MT_CmMatrix4x4 & mat); virtual void SetProjectionMatrix(const MT_Matrix4x4 & mat); @@ -286,9 +270,12 @@ public: std::vector <OglDebugLine> m_debugLines; - virtual void SetTexCoords(TexCoGen coords,int enabled); - virtual void SetAttrib(int type); - void TexCoord(const RAS_TexVert &tv, int unit); + virtual void SetTexCoordNum(int num); + virtual void SetAttribNum(int num); + virtual void SetTexCoord(TexCoGen coords, int unit); + virtual void SetAttrib(TexCoGen coords, int unit); + + void TexCoord(const RAS_TexVert &tv); virtual void GetViewMatrix(MT_Matrix4x4 &mat) const; void Tangent(const RAS_TexVert& v1, diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.cpp index ddfcc3f3f9d..ce76318c2ce 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.cpp @@ -32,34 +32,21 @@ #include "RAS_VAOpenGLRasterizer.h" #include <stdlib.h> -#ifdef WIN32 -#include <windows.h> -#endif // WIN32 -#ifdef __APPLE__ -#define GL_GLEXT_LEGACY 1 -#include <OpenGL/gl.h> -#else -#include <GL/gl.h> -#endif +#include "GL/glew.h" #include "STR_String.h" #include "RAS_TexVert.h" #include "MT_CmMatrix4x4.h" #include "RAS_IRenderTools.h" // rendering text - -#include "RAS_GLExtensionManager.h" - -using namespace bgl; - RAS_VAOpenGLRasterizer::RAS_VAOpenGLRasterizer(RAS_ICanvas* canvas, bool lock) : RAS_OpenGLRasterizer(canvas), - m_Lock(lock && RAS_EXT_support._EXT_compiled_vertex_array) + m_Lock(lock && GLEW_EXT_compiled_vertex_array), + m_last_texco_num(0), + m_last_attrib_num(0) { } - - RAS_VAOpenGLRasterizer::~RAS_VAOpenGLRasterizer() { } @@ -82,53 +69,36 @@ bool RAS_VAOpenGLRasterizer::Init(void) return result; } - - void RAS_VAOpenGLRasterizer::SetDrawingMode(int drawingmode) { m_drawingmode = drawingmode; - switch (m_drawingmode) + switch (m_drawingmode) { - case KX_BOUNDINGBOX: - { - } - case KX_WIREFRAME: - { + case KX_BOUNDINGBOX: + case KX_WIREFRAME: glDisable (GL_CULL_FACE); break; - } - case KX_TEXTURED: - { - } - case KX_SHADED: - { + case KX_TEXTURED: + case KX_SHADED: glEnableClientState(GL_COLOR_ARRAY); - } - case KX_SOLID: - { + case KX_SOLID: + break; + default: break; - } - default: - { - } } } - - void RAS_VAOpenGLRasterizer::Exit() { glDisableClientState(GL_VERTEX_ARRAY); - glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDisableClientState(GL_COLOR_ARRAY); glDisableClientState(GL_NORMAL_ARRAY); + EnableTextures(false); RAS_OpenGLRasterizer::Exit(); } - - void RAS_VAOpenGLRasterizer::IndexPrimitives( const vecVertexArray& vertexarrays, const vecIndexArrays & indexarrays, int mode, @@ -142,24 +112,16 @@ void RAS_VAOpenGLRasterizer::IndexPrimitives( const vecVertexArray& vertexarrays GLenum drawmode; switch (mode) { - case 0: - { - drawmode = GL_TRIANGLES; - break; - } - case 2: - { - drawmode = GL_QUADS; - break; - } - case 1: //lines - { - } - default: - { - drawmode = GL_LINES; - break; - } + case 0: + drawmode = GL_TRIANGLES; + break; + case 2: + drawmode = GL_QUADS; + break; + case 1: //lines + default: + drawmode = GL_LINES; + break; } const RAS_TexVert* vertexarray; unsigned int numindices, vt; @@ -180,6 +142,9 @@ void RAS_VAOpenGLRasterizer::IndexPrimitives( const vecVertexArray& vertexarrays glColor3d(0,0,0); } + EnableTextures(false); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + // use glDrawElements to draw each vertexarray for (vt=0;vt<vertexarrays.size();vt++) { @@ -206,8 +171,9 @@ void RAS_VAOpenGLRasterizer::IndexPrimitives( const vecVertexArray& vertexarrays } -} + glDisableClientState(GL_TEXTURE_COORD_ARRAY); +} void RAS_VAOpenGLRasterizer::IndexPrimitivesMulti( const vecVertexArray& vertexarrays, const vecIndexArrays & indexarrays, @@ -222,28 +188,19 @@ void RAS_VAOpenGLRasterizer::IndexPrimitivesMulti( const vecVertexArray& vertexa GLenum drawmode; switch (mode) { - case 0: - { - drawmode = GL_TRIANGLES; - break; - } - case 2: - { - drawmode = GL_QUADS; - break; - } - case 1: //lines - { - } - default: - { - drawmode = GL_LINES; - break; - } + case 0: + drawmode = GL_TRIANGLES; + break; + case 2: + drawmode = GL_QUADS; + break; + case 1: //lines + default: + drawmode = GL_LINES; + break; } const RAS_TexVert* vertexarray; unsigned int numindices, vt; - const unsigned int enabled = polymat->GetEnabled(); if (drawmode != GL_LINES) { @@ -251,7 +208,8 @@ void RAS_VAOpenGLRasterizer::IndexPrimitivesMulti( const vecVertexArray& vertexa { glDisableClientState(GL_COLOR_ARRAY); glColor4d(rgbacolor[0], rgbacolor[1], rgbacolor[2], rgbacolor[3]); - } else + } + else { glColor4d(0,0,0,1.0); glEnableClientState(GL_COLOR_ARRAY); @@ -271,11 +229,10 @@ void RAS_VAOpenGLRasterizer::IndexPrimitivesMulti( const vecVertexArray& vertexa if (!numindices) continue; - + glVertexPointer(3,GL_FLOAT,vtxstride,vertexarray->getLocalXYZ()); - TexCoordPtr(vertexarray, enabled); + TexCoordPtr(vertexarray); - //glTexCoordPointer(2,GL_FLOAT,vtxstride,vertexarray->getUV1()); glColorPointer(4,GL_UNSIGNED_BYTE,vtxstride,vertexarray->getRGBA()); glNormalPointer(GL_FLOAT,vtxstride,vertexarray->getNormal()); @@ -290,62 +247,157 @@ void RAS_VAOpenGLRasterizer::IndexPrimitivesMulti( const vecVertexArray& vertexa } } -void RAS_VAOpenGLRasterizer::TexCoordPtr(const RAS_TexVert *tv, int enabled) +void RAS_VAOpenGLRasterizer::TexCoordPtr(const RAS_TexVert *tv) { -#if defined(GL_ARB_multitexture) && defined(WITH_GLEXT) - if (!getenv("WITHOUT_GLEXT")) { - if(bgl::RAS_EXT_support._ARB_multitexture) - { - for(int unit=0; unit<enabled; unit++) - { - bgl::blClientActiveTextureARB(GL_TEXTURE0_ARB+unit); + /* note: this function must closely match EnableTextures to enable/disable + * the right arrays, otherwise coordinate and attribute pointers from other + * materials can still be used and cause crashes */ + int unit; + if(GLEW_ARB_multitexture) + { + for(unit=0; unit<m_texco_num; unit++) + { + glClientActiveTextureARB(GL_TEXTURE0_ARB+unit); + if(tv->getFlag() & TV_2NDUV && (int)tv->getUnit() == unit) { glEnableClientState(GL_TEXTURE_COORD_ARRAY); - if( tv->getFlag() & TV_2NDUV && tv->getUnit() == unit ) { - glTexCoordPointer(2, GL_FLOAT, sizeof(RAS_TexVert), tv->getUV2()); - continue; - } - switch(m_texco[unit]) - { - case RAS_TEXCO_DISABLE: - case RAS_TEXCO_OBJECT: - case RAS_TEXCO_GEN: - glDisableClientState(GL_TEXTURE_COORD_ARRAY); - break; - case RAS_TEXCO_ORCO: - case RAS_TEXCO_GLOB: - glTexCoordPointer(3, GL_FLOAT, sizeof(RAS_TexVert),tv->getLocalXYZ()); - break; - case RAS_TEXCO_UV1: - glTexCoordPointer(2, GL_FLOAT, sizeof(RAS_TexVert),tv->getUV1()); - break; - case RAS_TEXCO_NORM: - glTexCoordPointer(3, GL_FLOAT, sizeof(RAS_TexVert),tv->getNormal()); - break; - case RAS_TEXTANGENT: - glTexCoordPointer(4, GL_FLOAT, sizeof(RAS_TexVert),tv->getTangent()); - break; - case RAS_TEXCO_UV2: - glTexCoordPointer(2, GL_FLOAT, sizeof(RAS_TexVert),tv->getUV2()); - break; - } + glTexCoordPointer(2, GL_FLOAT, sizeof(RAS_TexVert), tv->getUV2()); + continue; + } + switch(m_texco[unit]) + { + case RAS_TEXCO_ORCO: + case RAS_TEXCO_GLOB: + glTexCoordPointer(3, GL_FLOAT, sizeof(RAS_TexVert),tv->getLocalXYZ()); + break; + case RAS_TEXCO_UV1: + glTexCoordPointer(2, GL_FLOAT, sizeof(RAS_TexVert),tv->getUV1()); + break; + case RAS_TEXCO_NORM: + glTexCoordPointer(3, GL_FLOAT, sizeof(RAS_TexVert),tv->getNormal()); + break; + case RAS_TEXTANGENT: + glTexCoordPointer(4, GL_FLOAT, sizeof(RAS_TexVert),tv->getTangent()); + break; + case RAS_TEXCO_UV2: + glTexCoordPointer(2, GL_FLOAT, sizeof(RAS_TexVert),tv->getUV2()); + break; + default: + break; } } -#ifdef GL_ARB_vertex_program - if(m_useTang && bgl::RAS_EXT_support._ARB_vertex_program) - bgl::blVertexAttrib4fvARB(1/*tangent*/, tv->getTangent()); -#endif + glClientActiveTextureARB(GL_TEXTURE0_ARB); } -#endif -} + if(GLEW_ARB_vertex_program) { + for(unit=0; unit<m_attrib_num; unit++) { + switch(m_attrib[unit]) { + case RAS_TEXCO_ORCO: + case RAS_TEXCO_GLOB: + glVertexAttribPointer(unit, 3, GL_FLOAT, GL_FALSE, sizeof(RAS_TexVert), tv->getLocalXYZ()); + break; + case RAS_TEXCO_UV1: + glVertexAttribPointer(unit, 2, GL_FLOAT, GL_FALSE, sizeof(RAS_TexVert), tv->getUV1()); + break; + case RAS_TEXCO_NORM: + glVertexAttribPointer(unit, 3, GL_FLOAT, GL_FALSE, sizeof(RAS_TexVert), tv->getNormal()); + break; + case RAS_TEXTANGENT: + glVertexAttribPointer(unit, 4, GL_FLOAT, GL_FALSE, sizeof(RAS_TexVert), tv->getTangent()); + break; + case RAS_TEXCO_UV2: + glVertexAttribPointer(unit, 2, GL_FLOAT, GL_FALSE, sizeof(RAS_TexVert), tv->getUV2()); + break; + default: + break; + } + } + } +} void RAS_VAOpenGLRasterizer::EnableTextures(bool enable) { - if (enable) - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - else - glDisableClientState(GL_TEXTURE_COORD_ARRAY); + TexCoGen *texco, *attrib; + int unit, texco_num, attrib_num; + + /* disable previously enabled texture coordinates and attributes. ideally + * this shouldn't be necessary .. */ + if(enable) + EnableTextures(false); + + /* we cache last texcoords and attribs to ensure we disable the ones that + * were actually last set */ + if(enable) { + texco = m_texco; + texco_num = m_texco_num; + attrib = m_attrib; + attrib_num = m_attrib_num; + + memcpy(m_last_texco, m_texco, sizeof(TexCoGen)*m_texco_num); + m_last_texco_num = m_texco_num; + memcpy(m_last_attrib, m_attrib, sizeof(TexCoGen)*m_attrib_num); + m_last_attrib_num = m_attrib_num; + } + else { + texco = m_last_texco; + texco_num = m_last_texco_num; + attrib = m_last_attrib; + attrib_num = m_last_attrib_num; + } + + if(GLEW_ARB_multitexture) { + for(unit=0; unit<texco_num; unit++) { + glClientActiveTextureARB(GL_TEXTURE0_ARB+unit); + + switch(texco[unit]) + { + case RAS_TEXCO_ORCO: + case RAS_TEXCO_GLOB: + case RAS_TEXCO_UV1: + case RAS_TEXCO_NORM: + case RAS_TEXTANGENT: + case RAS_TEXCO_UV2: + if(enable) glEnableClientState(GL_TEXTURE_COORD_ARRAY); + else glDisableClientState(GL_TEXTURE_COORD_ARRAY); + break; + default: + glDisableClientState(GL_TEXTURE_COORD_ARRAY); + break; + } + } + + glClientActiveTextureARB(GL_TEXTURE0_ARB); + } + else { + if(texco_num) { + if(enable) glEnableClientState(GL_TEXTURE_COORD_ARRAY); + else glDisableClientState(GL_TEXTURE_COORD_ARRAY); + } + } + + if(GLEW_ARB_vertex_program) { + for(unit=0; unit<attrib_num; unit++) { + switch(attrib[unit]) { + case RAS_TEXCO_ORCO: + case RAS_TEXCO_GLOB: + case RAS_TEXCO_UV1: + case RAS_TEXCO_NORM: + case RAS_TEXTANGENT: + case RAS_TEXCO_UV2: + if(enable) glEnableVertexAttribArray(unit); + else glDisableVertexAttribArray(unit); + break; + default: + glDisableVertexAttribArray(unit); + break; + } + } + } + + if(!enable) { + m_last_texco_num = 0; + m_last_attrib_num = 0; + } } diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.h index 4d478b0171f..ea08887028f 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.h @@ -33,9 +33,14 @@ class RAS_VAOpenGLRasterizer : public RAS_OpenGLRasterizer { - void TexCoordPtr(const RAS_TexVert *tv, int unit); + void TexCoordPtr(const RAS_TexVert *tv); bool m_Lock; + TexCoGen m_last_texco[RAS_MAX_TEXCO]; + TexCoGen m_last_attrib[RAS_MAX_ATTRIB]; + int m_last_texco_num; + int m_last_attrib_num; + public: RAS_VAOpenGLRasterizer(RAS_ICanvas* canvas, bool lock=false); virtual ~RAS_VAOpenGLRasterizer(); diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript index f2d2e977668..0cf9c326370 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript @@ -4,9 +4,9 @@ Import ('env') if env['WITH_BF_GLEXT'] == 1: env['CPPFLAGS'].append('-DWITH_GLEXT') -sources = env.Glob('*.cpp') #'RAS_GLExtensionManager.cpp RAS_ListRasterizer.cpp RAS_OpenGLRasterizer.cpp RAS_VAOpenGLRasterizer.cpp' +sources = env.Glob('*.cpp') -incs = '. #source/kernel/gen_system #intern/string #intern/moto/include #source/gameengine/Rasterizer #source/gameengine/BlenderRoutines' -incs += ' ' + env['BF_OPENGL_INC'] +incs = '. #source/kernel/gen_system #intern/string #intern/moto/include #source/gameengine/Rasterizer #source/gameengine/BlenderRoutines ' +incs += ' #extern/glew/include ' + env['BF_OPENGL_INC'] env.BlenderLib ( 'bf_oglrasterizer', Split(sources), Split(incs), [], libtype=['game','player'], priority=[40, 120] ) diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/mkglext.py b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/mkglext.py deleted file mode 100644 index 8f4065b3d6a..00000000000 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/mkglext.py +++ /dev/null @@ -1,627 +0,0 @@ -#!/usr/bin/python -# -# $Id$ -# ***** BEGIN GPL LICENSE BLOCK ***** -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software Foundation, -# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. -# All rights reserved. -# -# The Original Code is: all of this file. -# -# Contributor(s): none yet. -# -# ***** END GPL LICENSE BLOCK ***** - -# -# mkglext.py generates code for linking extensions. -# -# It reads the glext.h header from stdin and writes code to stdout. -# -# Usage: mkglext.py < glext.h > tmp -# Code can be copied & pasted from tmp to GL_ExtensionManager.cpp. -# -# glext.h is available here: http://oss.sgi.com/projects/ogl-sample/ABI/glext.h -# - -from sys import stdin -import string, re - -glext_h = string.split(stdin.read(), '\n') - -# These extensions have been incorporated into the core GL or been superceded. -# Code will not be generated for these extensions -blacklist = [ - "GL_EXT_multisample", - "GL_INGR_blend_func_separate", - "GL_SGIX_fragment_lighting", - "GL_SGIX_polynomial_ffd", - "GL_SGIS_point_parameters", - "GL_EXT_texture_object", - "GL_EXT_subtexture", - "GL_EXT_copy_texture", - "GL_EXT_vertex_array", - "GL_EXT_point_parameters", - "GL_EXT_blend_color", - "GL_EXT_polygon_offset", - "GL_EXT_texture"] - -# Only code for these extensions will be generated. Extensions on both the -# blacklist & whitelist will not have code generated. -# This list is from http://oss.sgi.com/projects/ogl-sample/registry/ at 14-Mar-04 -whitelist = [ - # ARB Extensions - "GL_ARB_multitexture", - "GLX_ARB_get_proc_address", - "GL_ARB_transpose_matrix", - "WGL_ARB_buffer_region", - "GL_ARB_multisample", - "GL_ARB_texture_env_add", - "GL_ARB_texture_cube_map", - "WGL_ARB_extensions_string", - "WGL_ARB_pixel_format", - "WGL_ARB_make_current_read", - "WGL_ARB_pbuffer", - "GL_ARB_texture_compression", - "GL_ARB_texture_border_clamp", - "GL_ARB_point_parameters", - "GL_ARB_vertex_blend", - "GL_ARB_matrix_palette", - "GL_ARB_texture_env_combine", - "GL_ARB_texture_env_crossbar", - "GL_ARB_texture_env_dot3", - "WGL_ARB_render_texture", - "GL_ARB_texture_mirrored_repeat", - "GL_ARB_depth_texture", - "GL_ARB_shadow", - "GL_ARB_shadow_ambient", - "GL_ARB_window_pos", - "GL_ARB_vertex_program", - "GL_ARB_fragment_program", - "GL_ARB_vertex_buffer_object", - "GL_ARB_occlusion_query", - "GL_ARB_shader_objects", - "GL_ARB_vertex_shader", - "GL_ARB_fragment_shader", - "GL_ARB_shading_language_100", - "GL_ARB_texture_non_power_of_two", - "GL_ARB_point_sprite", - "GL_ARB_fragment_program_shadow", - - # Non ARB Extensions - "GL_EXT_abgr", - "GL_EXT_blend_color", - "GL_EXT_polygon_offset", - "GL_EXT_texture", - "GL_EXT_texture3D", - "GL_SGIS_texture_filter4", - "GL_EXT_subtexture", - "GL_EXT_copy_texture", - "GL_EXT_histogram", - "GL_EXT_convolution", - "GL_SGI_color_matrix", - "GL_SGI_color_table", - "GL_SGIS_pixel_texture", - "GL_SGIS_texture4D", - "GL_SGI_texture_color_table", - "GL_EXT_cmyka", - "GL_EXT_texture_object", - "GL_SGIS_detail_texture", - "GL_SGIS_sharpen_texture", - "GL_EXT_packed_pixels", - "GL_SGIS_texture_lod", - "GL_SGIS_multisample", - "GL_EXT_rescale_normal", - "GLX_EXT_visual_info", - "GL_EXT_vertex_array", - "GL_EXT_misc_attribute", - "GL_SGIS_generate_mipmap", - "GL_SGIX_clipmap", - "GL_SGIX_shadow", - "GL_SGIS_texture_edge_clamp", - "GL_SGIS_texture_border_clamp", - "GL_EXT_blend_minmax", - "GL_EXT_blend_subtract", - "GL_EXT_blend_logic_op", - "GLX_SGI_swap_control", - "GLX_SGI_video_sync", - "GLX_SGI_make_current_read", - "GLX_SGIX_video_source", - "GLX_EXT_visual_rating", - "GL_SGIX_interlace", - "GLX_EXT_import_context", - "GLX_SGIX_fbconfig", - "GLX_SGIX_pbuffer", - "GL_SGIS_texture_select", - "GL_SGIX_sprite", - "GL_SGIX_texture_multi_buffer", - "GL_EXT_point_parameters", - "GL_SGIX_instruments", - "GL_SGIX_texture_scale_bias", - "GL_SGIX_framezoom", - "GL_SGIX_tag_sample_buffer", - "GL_SGIX_reference_plane", - "GL_SGIX_flush_raster", - "GLX_SGI_cushion", - "GL_SGIX_depth_texture", - "GL_SGIS_fog_function", - "GL_SGIX_fog_offset", - "GL_HP_image_transform", - "GL_HP_convolution_border_modes", - "GL_SGIX_texture_add_env", - "GL_EXT_color_subtable", - "GLU_EXT_object_space_tess", - "GL_PGI_vertex_hints", - "GL_PGI_misc_hints", - "GL_EXT_paletted_texture", - "GL_EXT_clip_volume_hint", - "GL_SGIX_list_priority", - "GL_SGIX_ir_instrument1", - "GLX_SGIX_video_resize", - "GL_SGIX_texture_lod_bias", - "GLU_SGI_filter4_parameters", - "GLX_SGIX_dm_buffer", - "GL_SGIX_shadow_ambient", - "GLX_SGIX_swap_group", - "GLX_SGIX_swap_barrier", - "GL_EXT_index_texture", - "GL_EXT_index_material", - "GL_EXT_index_func", - "GL_EXT_index_array_formats", - "GL_EXT_compiled_vertex_array", - "GL_EXT_cull_vertex", - "GLU_EXT_nurbs_tessellator", - "GL_SGIX_ycrcb", - "GL_EXT_fragment_lighting", - "GL_IBM_rasterpos_clip", - "GL_HP_texture_lighting", - "GL_EXT_draw_range_elements", - "GL_WIN_phong_shading", - "GL_WIN_specular_fog", - "GLX_SGIS_color_range", - "GL_EXT_light_texture", - "GL_SGIX_blend_alpha_minmax", - "GL_EXT_scene_marker", - "GL_SGIX_pixel_texture_bits", - "GL_EXT_bgra", - "GL_SGIX_async", - "GL_SGIX_async_pixel", - "GL_SGIX_async_histogram", - "GL_INTEL_texture_scissor", - "GL_INTEL_parallel_arrays", - "GL_HP_occlusion_test", - "GL_EXT_pixel_transform", - "GL_EXT_pixel_transform_color_table", - "GL_EXT_shared_texture_palette", - "GLX_SGIS_blended_overlay", - "GL_EXT_separate_specular_color", - "GL_EXT_secondary_color", - "GL_EXT_texture_env", - "GL_EXT_texture_perturb_normal", - "GL_EXT_multi_draw_arrays", - "GL_EXT_fog_coord", - "GL_REND_screen_coordinates", - "GL_EXT_coordinate_frame", - "GL_EXT_texture_env_combine", - "GL_APPLE_specular_vector", - "GL_SGIX_pixel_texture", - "GL_APPLE_transform_hint", - "GL_SUNX_constant_data", - "GL_SUN_global_alpha", - "GL_SUN_triangle_list", - "GL_SUN_vertex", - "WGL_EXT_display_color_table", - "WGL_EXT_extensions_string", - "WGL_EXT_make_current_read", - "WGL_EXT_pixel_format", - "WGL_EXT_pbuffer", - "WGL_EXT_swap_control", - "GL_EXT_blend_func_separate", - "GL_INGR_color_clamp", - "GL_INGR_interlace_read", - "GL_EXT_stencil_wrap", - "WGL_EXT_depth_float", - "GL_EXT_422_pixels", - "GL_NV_texgen_reflection", - "GL_SGIX_texture_range", - "GL_SUN_convolution_border_modes", - "GLX_SUN_get_transparent_index", - "GL_EXT_texture_env_add", - "GL_EXT_texture_lod_bias", - "GL_EXT_texture_filter_anisotropic", - "GL_EXT_vertex_weighting", - "GL_NV_light_max_exponent", - "GL_NV_vertex_array_range", - "GL_NV_register_combiners", - "GL_NV_fog_distance", - "GL_NV_texgen_emboss", - "GL_NV_blend_square", - "GL_NV_texture_env_combine4", - "GL_MESA_resize_buffers", - "GL_MESA_window_pos", - "GL_EXT_texture_compression_s3tc", - "GL_IBM_cull_vertex", - "GL_IBM_multimode_draw_arrays", - "GL_IBM_vertex_array_lists", - "GL_3DFX_texture_compression_FXT1", - "GL_3DFX_multisample", - "GL_3DFX_tbuffer", - "WGL_EXT_multisample", - "GL_SGIX_vertex_preclip", - "GL_SGIX_resample", - "GL_SGIS_texture_color_mask", - "GLX_MESA_copy_sub_buffer", - "GLX_MESA_pixmap_colormap", - "GLX_MESA_release_buffers", - "GLX_MESA_set_3dfx_mode", - "GL_EXT_texture_env_dot3", - "GL_ATI_texture_mirror_once", - "GL_NV_fence", - "GL_IBM_static_data", - "GL_IBM_texture_mirrored_repeat", - "GL_NV_evaluators", - "GL_NV_packed_depth_stencil", - "GL_NV_register_combiners2", - "GL_NV_texture_compression_vtc", - "GL_NV_texture_rectangle", - "GL_NV_texture_shader", - "GL_NV_texture_shader2", - "GL_NV_vertex_array_range2", - "GL_NV_vertex_program", - "GLX_SGIX_visual_select_group", - "GL_SGIX_texture_coordinate_clamp", - "GLX_OML_swap_method", - "GLX_OML_sync_control", - "GL_OML_interlace", - "GL_OML_subsample", - "GL_OML_resample", - "WGL_OML_sync_control", - "GL_NV_copy_depth_to_color", - "GL_ATI_envmap_bumpmap", - "GL_ATI_fragment_shader", - "GL_ATI_pn_triangles", - "GL_ATI_vertex_array_object", - "GL_EXT_vertex_shader", - "GL_ATI_vertex_streams", - "WGL_I3D_digital_video_control", - "WGL_I3D_gamma", - "WGL_I3D_genlock", - "WGL_I3D_image_buffer", - "WGL_I3D_swap_frame_lock", - "WGL_I3D_swap_frame_usage", - "GL_ATI_element_array", - "GL_SUN_mesh_array", - "GL_SUN_slice_accum", - "GL_NV_multisample_filter_hint", - "GL_NV_depth_clamp", - "GL_NV_occlusion_query", - "GL_NV_point_sprite", - "WGL_NV_render_depth_texture", - "WGL_NV_render_texture_rectangle", - "GL_NV_texture_shader3", - "GL_NV_vertex_program1_1", - "GL_EXT_shadow_funcs", - "GL_EXT_stencil_two_side", - "GL_ATI_text_fragment_shader", - "GL_APPLE_client_storage", - "GL_APPLE_element_array", - "GL_APPLE_fence", - "GL_APPLE_vertex_array_object", - "GL_APPLE_vertex_array_range", - "GL_APPLE_ycbcr_422", - "GL_S3_s3tc", - "GL_ATI_draw_buffers", - "WGL_ATI_pixel_format_float", - "GL_ATI_texture_env_combine3", - "GL_ATI_texture_float", - "GL_NV_float_buffer", - "GL_NV_fragment_program", - "GL_NV_half_float", - "GL_NV_pixel_data_range", - "GL_NV_primitive_restart", - "GL_NV_texture_expand_normal", - "GL_NV_vertex_program2", - "GL_ATI_map_object_buffer", - "GL_ATI_separate_stencil", - "GL_ATI_vertex_attrib_array_object", - "GL_OES_byte_coordinates", - "GL_OES_fixed_point", - "GL_OES_single_precision", - "GL_OES_compressed_paletted_texture", - "GL_OES_read_format", - "GL_OES_query_matrix", - "GL_EXT_depth_bounds_test", - "GL_EXT_texture_mirror_clamp", - "GL_EXT_blend_equation_separate", - "GL_MESA_pack_invert", - "GL_MESA_ycbcr_texture"] - -""" -Example code output: -#ifdef GL_EXT_compiled_vertex_array - if (QueryExtension("GL_EXT_compiled_vertex_array")) - { - glUnlockArraysEXT = reinterpret_cast<PFNGLUNLOCKARRAYSEXTPROC>(bglGetProcAddress((const GLubyte *) "glUnlockArraysEXT")); - glLockArraysEXT = reinterpret_cast<PFNGLLOCKARRAYSEXTPROC>(bglGetProcAddress((const GLubyte *) "glLockArraysEXT")); - if (glUnlockArraysEXT && glLockArraysEXT) - { - EnableExtension(_GL_EXT_compiled_vertex_array); - if (doDebugMessages) - std::cout << "Detected GL_EXT_compiled_vertex_array" << std::endl; - } else { - std::cout << "ERROR: GL_EXT_compiled_vertex_array implementation is broken!" << std::endl; - } - } -#endif -""" -def writeext(ext, fnlist): - if (find(blacklist, ext)): - return - if (len(fnlist) == 0): - # This extension has no functions to detect - don't need to wrap in - # #ifdef GL_extension names - print "\tif (QueryExtension(\"" + ext + "\"))" - print "\t{" - print "\t\tEnableExtension(_" + ext + ");" - print "\t\tif (doDebugMessages)" - print "\t\t\tstd::cout << \"Detected " + ext + "\" << std::endl;" - print "\t}" - print - return - print "#if defined(" + ext + ")" - print "\tif (QueryExtension(\"" + ext + "\"))" - print "\t{" - for fn in fnlist: - print "\t\t" + fn[0] + " = reinterpret_cast<" + fn[1] + ">(bglGetProcAddress((const GLubyte *) \"" + fn[0] + "\"));" - errcheck = "" - for fn in fnlist: - if (errcheck == ""): - errcheck = fn[0] - else: - errcheck = errcheck + " && " + fn[0] - print "\t\tif (" + errcheck + ") {" - print "\t\t\tEnableExtension(_" + ext + ");" - print "\t\t\tif (doDebugMessages)" - print "\t\t\t\tstd::cout << \"Enabled " + ext + "\" << std::endl;" - print "\t\t} else {" - print "\t\t\tstd::cout << \"ERROR: " + ext + " implementation is broken!\" << std::endl;" - print "\t\t}" - print "\t}" - print "#endif" - print - -""" -Example Output: -#if defined(GL_EXT_compiled_vertex_array) -PFNGLLOCKARRAYSEXTPROC glLockArraysEXT; -PFNGLUNLOCKARRAYSEXTPROC glUnlockArraysEXT; -#endif -""" -def writeproto(ext, fnlist): - if (find(blacklist, ext) or not find(whitelist, ext)): - return - print "#if defined(" + ext + ")" - for fn in fnlist: - print fn[1] + " " + fn[0] + ";" - print "#endif" - print - -""" -#ifdef GL_EXT_compiled_vertex_array -extern PFNGLLOCKARRAYSEXTPROC glLockArraysEXT; -extern PFNGLUNLOCKARRAYSEXTPROC glUnlockArraysEXT; -#endif -""" -def writeheader(ext, fnlisti): - if (find(blacklist, ext) or not find(whitelist, ext)): - return - print "#if defined(" + ext + ")" - for fn in fnlist: - print "extern " + fn[1] + " " + fn[0] + ";" - print "#endif" - print - -def find(l, x): - for i in l: - if (i == x): - return 1 - return 0 - - -# Write Prototypes -ext = "" -fns = [] -fnlist = [] -ifdef = 0 -for i in glext_h: - line = re.search('^#ifn?def', i) - if (line): - ifdef = ifdef + 1 - - line = re.search('^#ifndef (GL_.*)', i) - if (line): - if (not re.search('GL_VERSION.*', line.group(1)) and find(whitelist, line.group(1))): - ext = line.group(1) - - line = re.search('^#endif', i) - if (line): - ifdef = ifdef - 1 - if (ifdef == 0 and ext != ""): - writeproto(ext, fnlist) - ext = "" - fns = [] - fnlist = [] - if (ext != ""): - line = re.search('.* (gl.*) \(.*\);', i) - if (line): - fns += [line.group(1)] - line = re.search('.*PFN(.*)PROC.*', i) - if (line): - for j in fns: - if (string.lower(line.group(1)) == string.lower(j)): - fnlist += [(j, "PFN" + line.group(1) + "PROC")] - -# Write link code -ext = "" -fns = [] -fnlist = [] -ifdef = 0 -for i in glext_h: - line = re.search('^#ifn?def', i) - if (line): - ifdef = ifdef + 1 - - line = re.search('^#ifndef (GL_.*)', i) - if (line): - if (not re.search('GL_VERSION.*', line.group(1)) and find(whitelist, line.group(1))): - ext = line.group(1) - - line = re.search('^#endif', i) - if (line): - ifdef = ifdef - 1 - if (ifdef == 0 and ext != ""): - writeext(ext, fnlist) - ext = "" - fns = [] - fnlist = [] - if (ext != ""): - line = re.search('.* (gl.*) \(.*\);', i) - if (line): - fns += [line.group(1)] - line = re.search('.*PFN(.*)PROC.*', i) - if (line): - for j in fns: - if (string.lower(line.group(1)) == string.lower(j)): - fnlist += [(j, "PFN" + line.group(1) + "PROC")] - -# Write header code -ext = "" -fns = [] -fnlist = [] -ifdef = 0 -for i in glext_h: - line = re.search('^#ifn?def', i) - if (line): - ifdef = ifdef + 1 - - line = re.search('^#ifndef (GL_.*)', i) - if (line): - if (not re.search('GL_VERSION.*', line.group(1)) and find(whitelist, line.group(1))): - ext = line.group(1) - - line = re.search('^#endif', i) - if (line): - ifdef = ifdef - 1 - if (ifdef == 0 and ext != ""): - writeheader(ext, fnlist) - ext = "" - fns = [] - fnlist = [] - if (ext != ""): - line = re.search('.* (gl.*) \(.*\);', i) - if (line): - fns += [line.group(1)] - line = re.search('.*PFN(.*)PROC.*', i) - if (line): - for j in fns: - if (string.lower(line.group(1)) == string.lower(j)): - fnlist += [(j, "PFN" + line.group(1) + "PROC")] - -# Write Python link code -ext = "" -extensions = [] -fns = [] -defines = [] -ifdef = 0 -for i in glext_h: - line = re.search('^#ifn?def', i) - if (line): - ifdef = ifdef + 1 - - line = re.search('^#ifndef (GL_.*)', i) - if (line): - if (not re.search('GL_VERSION.*', line.group(1)) and find(whitelist, line.group(1))): - ext = line.group(1) - - line = re.search('^#endif', i) - if (line): - ifdef = ifdef - 1 - if (ifdef == 0 and ext != ""): - done = 0 - for e in range(len(extensions)): - if extensions[e][0] == ext: - extensions[e] = (ext, defines + extensions[e][1], fns + extensions[e][2]) - done = 1 - if not done: - extensions = extensions + [(ext, defines, fns)] - ext = "" - fns = [] - defines = [] - if (ext != ""): - line = re.search('#define +(GL.*) +(0x.*)', i) # #define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 - if (line): - defines += [(line.group(1), line.group(2))] - - line = re.search('(.* )(gl.*)(\(.*\));', i) # GLAPI void APIENTRY glMultiTexCoord2f (GLenum, GLfloat, GLfloat); - if (line): - fns += [(line.group(1), line.group(2), line.group(3))] - -for ext in extensions: - if (find(blacklist, ext[0]) or not find(whitelist, ext[0])): - continue - print "#if defined(" + ext[0] + ")" - for fn in ext[2]: - line = re.search('gl(.*)', fn[1]) - # BGL_Wrap(2, RasterPos2f, void, (GLfloat, GLfloat)) - rtype = "" - for r in string.split(fn[0]): - if r != "GLAPI" and r != "APIENTRY": - rtype = rtype + " " + r - params = "" - for p in string.split(fn[2], ','): - pline = re.search('(.*) \*', p) - if (pline): - p = pline.group(1) + "P" - if params == "": - params = p - else: - params = params + "," + p - if not params[-1] == ")": - params = params + ")" - print "BGL_Wrap(" + str(len(string.split(fn[2], ','))) + ", " + line.group(1) + ",\t" + rtype + ",\t" + params + ")" - print "#endif" - print - -for ext in extensions: - if (find(blacklist, ext[0]) or not find(whitelist, ext[0])): - continue - print 'PyDict_SetItemString(dict, "' + ext[0] + '", PyInt_FromLong(_' + ext[0] + '))' - print "#if defined(" + ext[0] + ")" - print "if (bglQueryExtension(_" + ext[0] + ")) {" - if len(ext[2]) > 0: - for fn in ext[2]: - line = re.search('gl(.*)', fn[1]) - # MethodDef(Vertex3iv), - print " BGL_AddMethod(" + line.group(1) + ");" - print - - for define in ext[1]: - print " BGL_AddConst(" + define[0] + ");" - print - - print "}" - print "#endif" - print |