gzz-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gzz-commits] gzz/gfx libcallgl/callgl.cxx libcallgl/callgl.h...


From: Janne V. Kujala
Subject: [Gzz-commits] gzz/gfx libcallgl/callgl.cxx libcallgl/callgl.h...
Date: Thu, 31 Oct 2002 09:59:19 -0500

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Janne V. Kujala <address@hidden>        02/10/31 09:59:19

Modified files:
        gfx/libcallgl  : callgl.cxx callgl.hxx 
        gfx/libpaper   : Paper.cxx Paper.hxx 

Log message:
        Replace VPCode with a new NVProg template class that supports nvidia 
fragment programs, too

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libcallgl/callgl.cxx.diff?tr1=1.28&tr2=1.29&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libcallgl/callgl.hxx.diff?tr1=1.18&tr2=1.19&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libpaper/Paper.cxx.diff?tr1=1.17&tr2=1.18&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libpaper/Paper.hxx.diff?tr1=1.14&tr2=1.15&r1=text&r2=text

Patches:
Index: gzz/gfx/libcallgl/callgl.cxx
diff -u gzz/gfx/libcallgl/callgl.cxx:1.28 gzz/gfx/libcallgl/callgl.cxx:1.29
--- gzz/gfx/libcallgl/callgl.cxx:1.28   Thu Oct 31 04:10:07 2002
+++ gzz/gfx/libcallgl/callgl.cxx        Thu Oct 31 09:59:18 2002
@@ -691,8 +691,7 @@
     }
 
 
-    void VPCode::compile() { 
-       vpid = shared_ptr<VPid>(new VPid);
+    void compileNVProg(GLuint TARGET, GLuint id, const string source) {
 
        int er = glGetError(); 
        if (er != GL_NO_ERROR)
@@ -701,13 +700,7 @@
               << " before loading vertex program\n"; 
 
 #ifdef GL_VERTEX_PROGRAM_NV
-       if (source.compare(0, 5, "!!VSP") == 0) {
-         glLoadProgramNV(GL_VERTEX_STATE_PROGRAM_NV, vpid->name, 
-                         source.length(), (GLubyte*)source.data());
-       } else {
-         glLoadProgramNV(GL_VERTEX_PROGRAM_NV, vpid->name, source.length(), 
-                         (GLubyte*)source.data());
-       }
+       glLoadProgramNV(TARGET, id, source.length(), (GLubyte*)source.data());
        
        er = glGetError(); 
        if (er != GL_NO_ERROR) {
@@ -715,7 +708,9 @@
          
          cerr << "OPENGL ERROR " 
               << gluErrorString(er)
-              << " when loading vertex program\n"; 
+              << " when loading " 
+              << getTokenString(TARGET) 
+              << " program\n"; 
 
          glGetIntegerv(GL_PROGRAM_ERROR_POSITION_NV, &errpos);
          std::cerr << "Program error position: " << errpos << "\n";
Index: gzz/gfx/libcallgl/callgl.hxx
diff -u gzz/gfx/libcallgl/callgl.hxx:1.18 gzz/gfx/libcallgl/callgl.hxx:1.19
--- gzz/gfx/libcallgl/callgl.hxx:1.18   Mon Sep 23 14:08:46 2002
+++ gzz/gfx/libcallgl/callgl.hxx        Thu Oct 31 09:59:18 2002
@@ -149,49 +149,64 @@
 
 
 
-    /** A simple automatic Vertex Program id object.
-     * Allocates a new VP name when created
+    /** A simple automatic NVIDIA program id object.
+     * Allocates a new program name when created
      * and deletes the name when destroyed.
      * No assignment or copying is allowed; 
-     * use shared_ptr<VPid> for proper value semantics.
+     * use shared_ptr<NVProgID> for proper value semantics.
      */
-    class VPid {
+    class NVProgID {
     public:
       GLuint name;
 #ifdef GL_VERTEX_PROGRAM_NV
-      VPid(GLuint name) : name(name) {}
-      VPid() { glGenProgramsNV(1, &name); }
-      ~VPid() { glDeleteProgramsNV(1, &name); }
+      NVProgID(GLuint name) : name(name) {}
+      NVProgID() { glGenProgramsNV(1, &name); }
+      ~NVProgID() { glDeleteProgramsNV(1, &name); }
 #endif
     };
 
-    /** An instance of Vertex Program code loaded into the driver.
-     * The VPCode objects are immutable with value semantics.
+
+    void compileNVProg(GLuint TARGET, GLuint id, const string source);
+
+    /** An instance of an NVIDIA program loaded into the driver.
+     * The NVProg objects are immutable with value semantics.
      * Example:
-     *                 VPCode code("!!VP1.0;MOV o[HPOS], v[OPOS];END");
+     *                 NVProg<GL_VERTEX_PROGRAM_NV> code("!!VP1.0;MOV o[HPOS], 
v[OPOS];END");
      */
-    class VPCode {
+    template <GLuint TARGET>
+    class NVProg {
     public:
-      VPCode() { }
-      VPCode(const char *source) : source(source) { compile(); }
-      string getSource() const { return source; }
-      void operator () (void) const {
+       NVProg() { }
+       NVProg(const char *source) : source(source) { compile(); }
+       string getSource() const { return source; }
+       void bind(void) const {
 #ifdef GL_VERTEX_PROGRAM_NV
-       glBindProgramNV(GL_VERTEX_PROGRAM_NV, vpid->name);
+           glBindProgramNV(TARGET, progid->name);
 #endif
-      }
-      void operator () (const float *params) const {
+       }
+       void operator () (const float *params) const {
 #ifdef GL_VERTEX_PROGRAM_NV
-       glExecuteProgramNV(GL_VERTEX_STATE_PROGRAM_NV, vpid->name, params);
+           glExecuteProgramNV(TARGET, progid->name, params);
 #endif
-      }
-
+       }
+       
     protected:
-      void compile();
-      string source;
-      shared_ptr<VPid> vpid;
+       void compile() {
+           progid = shared_ptr<NVProgID>(new NVProgID);
+           compileNVProg(TARGET, progid->name, source);
+       }
+       string source;
+       shared_ptr<NVProgID> progid;
     };
 
+
+#ifdef GL_VERTEX_PROGRAM_NV
+    typedef NVProg<GL_VERTEX_PROGRAM_NV> VertexProgram;
+    typedef NVProg<GL_VERTEX_STATE_PROGRAM_NV> VertexStateProgram;
+#endif
+#ifdef GL_FRAGMENT_PROGRAM_NV
+    typedef NVProg<GL_FRAGMENT_PROGRAM_NV> FragmentProgram;
+#endif
 
 
   /* Just a simple container for Extender Calls
Index: gzz/gfx/libpaper/Paper.cxx
diff -u gzz/gfx/libpaper/Paper.cxx:1.17 gzz/gfx/libpaper/Paper.cxx:1.18
--- gzz/gfx/libpaper/Paper.cxx:1.17     Thu Oct 10 02:48:39 2002
+++ gzz/gfx/libpaper/Paper.cxx  Thu Oct 31 09:59:18 2002
@@ -338,7 +338,7 @@
     
     //std::cerr << "Creating VPCode with the source " << code.str() << "\n";
     
-    texgenvp = VPCode(code.c_str());
+    texgenvp = VertexProgram(code.c_str());
   }
   
   void PaperPass::setUp_VP(LightParam *param) {
@@ -360,7 +360,7 @@
       else std::cerr << "Warning: ignoring null LightSetup\n";
     }
     
-    texgenvp(); // Bind vertex program
+    texgenvp.bind(); // Bind vertex program
 #ifdef GL_VERTEX_PROGRAM_NV
     glEnable(GL_VERTEX_PROGRAM_NV);
 #endif
Index: gzz/gfx/libpaper/Paper.hxx
diff -u gzz/gfx/libpaper/Paper.hxx:1.14 gzz/gfx/libpaper/Paper.hxx:1.15
--- gzz/gfx/libpaper/Paper.hxx:1.14     Thu Oct 10 02:28:53 2002
+++ gzz/gfx/libpaper/Paper.hxx  Thu Oct 31 09:59:18 2002
@@ -265,7 +265,7 @@
          
   protected:
     /* Vertex program code. */
-    VPCode texgenvp;
+    VertexProgram texgenvp;
   };
   
   /** A paper is simply a vector of passes.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]