]> Dogcows Code - chaz/yoink/blobdiff - src/moof/opengl.hh
initial runloop implementation
[chaz/yoink] / src / moof / opengl.hh
index 04cc13e9c72bfac4e7196cf6ae6b3df2299a76d7..3367bc8616ddcf569dfa78261bec5f90b9432462 100644 (file)
@@ -18,7 +18,9 @@
  * and matrices.
  */
 
-#include "../config.h"
+#include "config.h"
+
+#include <vector>
 
 #include <SDL/SDL_opengl.h>
 
@@ -57,7 +59,7 @@
 #define PASS_V4                v[0], v[1], v[2], v[3]
 
 
-#if USE_DOUBLE_PRECISION
+#if ENABLE_DOUBLE_PRECISION
 
 #define OPENGL_GENERIC_FUNC(R, N, L)                                                                   \
        inline R gl##N(ARGS_##L) { gl##N##d(PASS_##L); }//
@@ -105,7 +107,37 @@ OPENGL_GENERIC_FUNC(void,  Rect,           S4);
 OPENGL_GENERIC_FUNC(void,      Rect,           V4);
 
 
-#if USE_DOUBLE_PRECISION
+inline void glMaterial(GLenum face, GLenum pname, moof::scalar s)
+{
+       glMaterialf(face, pname, float(s));
+}
+
+inline void glMaterial(GLenum face, GLenum pname, const moof::vector4& v)
+{
+#if ENABLE_DOUBLE_PRECISION
+       float f[] = {v[0], v[1], v[2], v[3]};
+       glMaterialfv(face, pname, f);
+#else
+       glMaterialfv(face, pname, v.data());
+#endif
+}
+
+inline void glVertexPointer(const std::vector<moof::vector3>& v)
+{
+       glVertexPointer(3, GL_SCALAR, 0, v[0].data());
+}
+inline void glTexCoordPointer(const std::vector<moof::vector2>& v)
+{
+       glTexCoordPointer(2, GL_SCALAR, 0, v[0].data());
+}
+
+inline void glDrawElements(GLenum type, const std::vector<GLuint>& v)
+{
+       glDrawElements(type, v.size(), GL_UNSIGNED_INT, &v[0]);
+}
+
+
+#if ENABLE_DOUBLE_PRECISION
 inline void glGetScalar(GLenum a, GLscalar* b) { glGetDoublev(a, b); }
 #else
 inline void glGetScalar(GLenum a, GLscalar* b) { glGetFloatv(a, b); }
This page took 0.019462 seconds and 4 git commands to generate.