[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gzz-commits] gzz/gfx/libcallgl callgl.cxx callgl.hxx
From: |
Matti Katila |
Subject: |
[Gzz-commits] gzz/gfx/libcallgl callgl.cxx callgl.hxx |
Date: |
Tue, 17 Sep 2002 11:11:07 -0400 |
CVSROOT: /cvsroot/gzz
Module name: gzz
Changes by: Matti Katila <address@hidden> 02/09/17 11:11:07
Modified files:
gfx/libcallgl : callgl.cxx callgl.hxx
Log message:
Being frustrated with complexity of OpenGL calls - just make extension
calls
work. Anyway, still commented out.
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libcallgl/callgl.cxx.diff?tr1=1.13&tr2=1.14&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libcallgl/callgl.hxx.diff?tr1=1.15&tr2=1.16&r1=text&r2=text
Patches:
Index: gzz/gfx/libcallgl/callgl.cxx
diff -c gzz/gfx/libcallgl/callgl.cxx:1.13 gzz/gfx/libcallgl/callgl.cxx:1.14
*** gzz/gfx/libcallgl/callgl.cxx:1.13 Mon Sep 16 14:57:21 2002
--- gzz/gfx/libcallgl/callgl.cxx Tue Sep 17 11:11:07 2002
***************
*** 12,19 ****
#include <vector>
using std::vector;
- #include <map>
-
// Should include nvidia's gl.h...
//extern "C" void glCombinerStageParameterfvNV (GLenum stage, GLenum pname,
const GLfloat *params);
--- 12,17 ----
***************
*** 22,34 ****
using std::string;
using std::vector;
- using std::map;
using std::cerr;
using std::cout;
! map<string, void (*)()> extended_calls;
! ExtCallsCheckList ext_check;
static bool Begin = false;
--- 20,30 ----
using std::string;
using std::vector;
using std::cerr;
using std::cout;
! ExtCalls ext_calls;
static bool Begin = false;
***************
*** 438,506 ****
#endif
// XXX
//#define USE_GL_EXTENSION_CALLS
#ifdef USE_GL_EXTENSION_CALLS
!
! } else if (checkfunc(v, "GetProcAddress", 1)) {
! if (ext_check.isCallNameFound(v[1])) {
!
! void (* addr)() = Os::getExtendedProcAddress(v[1]);
!
! if (addr == NULL) {
! cerr << v[1] << " not supported by your gl-driver.\n";
! return false;
! }
! extended_calls[v[1]] = addr;
!
! } else {
! cerr << v[1] << " not found from extended calls list.\n";
! return false;
! }
} else {
- if (ext_check.isCallNameFound(v[0])) {
- ExtCall ext_c = ext_check.getCallObj(v[0]);
! void (* addr)() = extended_calls[v[0]];
!
! if (addr == NULL) {
! cerr << v[0] << " is extension function but "<<
! "it haven't been initialized with \"GetProcAddress\".\n";
! return false;
! }
! switch (ext_c.getType()) {
! case EXT_ERROR:
! cerr << "something very broken in extended call.\n";
! return false;
! case FLOAT3: { if (v.size() != 4) goto error_args_count;
! void (* a)(float,float,float);
! a = (void (*)( float, float,float))(addr);
(* a)( atof(v[1].c_str()), atof(v[2].c_str()),
! atof(v[3].c_str()));
! break;
! }
! case FLOAT4: {
! if (v.size() != 5) goto error_args_count;
! void (* a)(float,float,float,float);
! a = (void (*)( float, float,float,float))(addr);
(* a)( atof(v[1].c_str()), atof(v[2].c_str()),
! atof(v[3].c_str()), atof(v[4].c_str()));
! break;
! }
! /* //probably just put ints to map<string> or something
! case ENUM1: {
! if (v.size() != 2) goto error_args_count;
! void (* a)(enum);
! a = (void (*)(enum))(addr);
!
! //(* a)( );
! break;
}
- */
- } // end of switch
-
} else {
- error_args_count:
cerr << "Unknown function \"" << v[0] << "\" with "
<< v.size() - 1 << " arguments\n";
return false;
--- 434,467 ----
#endif
+
+ #define FLOAT3(ADDRESS) ((void (*)(float, float, float))(ADDRESS))
+ #define FLOAT4(ADDRESS) ((void (*)(float, float, float, float))(ADDRESS))
+
// XXX
//#define USE_GL_EXTENSION_CALLS
#ifdef USE_GL_EXTENSION_CALLS
!
} else {
! void (* addr)() = ext_calls.getAddress(v[0]);
! bool isOpenGLCall = true;
! if (addr == NULL) isOpenGLCall = false;
!
! if (isOpenGLCall) {
! if(checkfunc(v, "SecondaryColorEXT", 3)) {
! void (* a)(float,float,float) = FLOAT3(addr);
(* a)( atof(v[1].c_str()), atof(v[2].c_str()),
! atof(v[3].c_str()));
! } else if(checkfunc(v, "BlendColorEXT", 4)) {
! void (* a)(float,float,float,float) = FLOAT4(addr);
(* a)( atof(v[1].c_str()), atof(v[2].c_str()),
! atof(v[3].c_str()), atof(v[4].c_str()));
! } else {
! cerr << "Extension OpenGL call \'" << v[0]
! <<"\' not supported.\n";
}
} else {
cerr << "Unknown function \"" << v[0] << "\" with "
<< v.size() - 1 << " arguments\n";
return false;
Index: gzz/gfx/libcallgl/callgl.hxx
diff -c gzz/gfx/libcallgl/callgl.hxx:1.15 gzz/gfx/libcallgl/callgl.hxx:1.16
*** gzz/gfx/libcallgl/callgl.hxx:1.15 Mon Sep 16 09:59:42 2002
--- gzz/gfx/libcallgl/callgl.hxx Tue Sep 17 11:11:07 2002
***************
*** 12,17 ****
--- 12,20 ----
#include <vector>
using std::vector;
+ #include <map>
+ using std::map;
+
#include <boost/shared_ptr.hpp>
using boost::shared_ptr;
***************
*** 180,245 ****
! const int EXT_ERROR = 0;
! const int FLOAT3 = 1;
! const int FLOAT4 = 2;
! const int ENUM1 = 3;
!
!
! class ExtCall {
! private:
! string name;
! int type;
!
! public:
! ExtCall(string s, int type) {
! this->name = s;
! this->type = type;
! }
!
! inline string getName(void) const { return name; }
! inline int getType(void) const { return type; }
! };
!
!
! /* Just a simple container for ExtCalls
! * All used extended calls should be listed in constructor.
! * -BlendColorEXT
*/
! class ExtCallsCheckList {
private:
! vector<ExtCall> list;
private:
! void add(string s, int type) {
! list.push_back(ExtCall(s, type));
}
public:
! ExtCallsCheckList() {
! this->add("null", EXT_ERROR);
! // GL_ARB_imaging
! this->add("glBlendColorEXT", FLOAT4);
! this->add("BlendEquationEXT", ENUM1);
}
! bool isCallNameFound(string str_find) const {
! for (unsigned int i=0; i<list.size(); i++) {
! if (list[i].getName() == str_find) return true;
! }
! return false;
! }
! const ExtCall & getCallObj(string str_find) const {
! for (unsigned int i=0; i<list.size(); i++) {
! if( str_find == list[i].getName()) return list[i];
}
! // be sure you added "exception"
! return list[0];
! }
};
-
}
#endif // GZZ CALLGL HXX
--- 183,228 ----
! /* Just a simple container for Extender Calls
! * -SecondaryColorEXT
! * -GL_EXT_blend_color
*/
! class ExtCalls {
private:
! // < function name, proc address>
! map<string, void (*)()> list_address;
!
! // <OpenGL call name, function name>
! map<string, string> list_names;
private:
! void add(string call_name, string func_name) {
! list_names[call_name] = func_name;
}
public:
! ExtCalls() {
! // EXT_secondary_color
! add("SecondaryColorEXT", "glSecondaryColor3dEXT");
! // GL_EXT_blend_color
! add("BlendColorEXT","glBlendColorEXT");
}
! void (* getAddress(string call_name))() {
! string func_name = list_names[call_name];
! if (func_name == "") return NULL;
!
! void (* addr)() = list_address[func_name];
! if (addr == NULL) {
! addr = Os::getExtendedProcAddress(func_name);
! list_address[func_name] = addr;
}
! return addr;
! }
};
}
#endif // GZZ CALLGL HXX
+