[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: |
Fri, 13 Sep 2002 11:29:56 -0400 |
CVSROOT: /cvsroot/gzz
Module name: gzz
Changes by: Matti Katila <address@hidden> 02/09/13 11:29:56
Modified files:
gfx/libcallgl : callgl.cxx callgl.hxx
Log message:
More framework for OpenGL extension calls. By default it won't be
compiled.
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libcallgl/callgl.cxx.diff?tr1=1.11&tr2=1.12&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libcallgl/callgl.hxx.diff?tr1=1.11&tr2=1.12&r1=text&r2=text
Patches:
Index: gzz/gfx/libcallgl/callgl.cxx
diff -c gzz/gfx/libcallgl/callgl.cxx:1.11 gzz/gfx/libcallgl/callgl.cxx:1.12
*** gzz/gfx/libcallgl/callgl.cxx:1.11 Wed Sep 11 06:41:45 2002
--- gzz/gfx/libcallgl/callgl.cxx Fri Sep 13 11:29:56 2002
***************
*** 12,17 ****
--- 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);
***************
*** 20,28 ****
--- 22,35 ----
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;
int getToken(string tok);
***************
*** 64,76 ****
! /* vector<string> v = split(" asdf # asdffoo fasdf # fadasfd ");
! * 0: asdf
* 1: #
! * 2: asdffoo
! * 3: fasdf
! * 4: #
! * 5: fadasfd
*/
vector<string> split(string str) {
string tmp;
--- 71,80 ----
! /* vector<string> v = split(" foo # bar ");
! * 0: foo
* 1: #
! * 2: bar
*/
vector<string> split(string str) {
string tmp;
***************
*** 125,130 ****
--- 129,135 ----
bool callGLop(string s) {
DBG(dbg) << "callGLop(\"" << s << "\")\n";
+ // Substring comment out -- if '#' found
string::size_type position = s.find('#');
if (position != string::npos) s = s.substr(0, position);
***************
*** 132,140 ****
if (v.size() < 1) return true;
- // Ignore lines where the first splitted "word" starts with a '#'
- //if (v[0][0] == '#') return true;
-
if (checkfunc(v, "Enable", 1)) {
glEnable(getToken(v[1]));
} else if (checkfunc(v, "Disable", 1)) {
--- 137,142 ----
***************
*** 425,435 ****
--- 427,509 ----
#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;
+ }
+ }
+
+ #else /* with no extension calls.. */
} else {
cerr << "Unknown function \"" << v[0] << "\" with "
<< v.size() - 1 << " arguments\n";
return false;
}
+ #endif /* USE_GL_EXTENSION_CALLS */
+
if (!Begin) {
int er = glGetError();
Index: gzz/gfx/libcallgl/callgl.hxx
diff -c gzz/gfx/libcallgl/callgl.hxx:1.11 gzz/gfx/libcallgl/callgl.hxx:1.12
*** gzz/gfx/libcallgl/callgl.hxx:1.11 Thu Sep 12 11:06:03 2002
--- gzz/gfx/libcallgl/callgl.hxx Fri Sep 13 11:29:56 2002
***************
*** 179,202 ****
! /* For GLX_ARB_get_proc_address
! * API to Os-GLX needs proc name, argument count and type.
! */
class ExtCall {
private:
string name;
- int arg_count;
int type;
public:
! ExtCall(string s, int args, int type) {
this->name = s;
- this->arg_count = args;
this->type = type;
}
inline string getName(void) const { return name; }
- inline int getArgCount(void) const { return arg_count; }
inline int getType(void) const { return type; }
};
--- 179,202 ----
! 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; }
};
***************
*** 210,225 ****
vector<ExtCall> list;
private:
! void add(string s, int args, int i) {
! list.push_back(ExtCall(s, args, i));
}
public:
ExtCallsCheckList() {
! this->add("null", -1, -1);
// GL_ARB_imaging
! // this->add("BlendColorEXT", 4, Os::FLOAT4);
}
bool isCallNameFound(string str_find) const {
--- 210,226 ----
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 {
- [Gzz-commits] gzz/gfx/libcallgl callgl.cxx callgl.hxx,
Matti Katila <=