ecere/gfx3D/OpenGL: Making GLVertexPointer() (new) and GLBufferData() public
[sdk] / ecere / src / gfx / drivers / OpenGLDisplayDriver.ec
index 3a72797..576aecf 100644 (file)
@@ -854,11 +854,13 @@ void glesFrustum( double l, double r, double b, double t, double n, double f )
 
 void glesRotated( double a, double b, double c, double d )
 {
-   Matrix m;
    Quaternion q;
-   q.RotationAxis({(float)b,(float)-c,(float)d}, a );
+   Matrix m, r;
+
+   q.RotationAxis({(float)b,(float)c,(float)-d}, a );
    m.RotationQuaternion(q);
-   matrixStack[curStack][matrixIndex[curStack]].Rotate(q);
+   r.Multiply(m, matrixStack[curStack][matrixIndex[curStack]]);
+   matrixStack[curStack][matrixIndex[curStack]] = r;
    LoadCurMatrix();
 }
 void glesScaled( double a, double b, double c )
@@ -893,7 +895,7 @@ void glesMultMatrixd( double * i )
 
 void glesMatrixMode(int mode)
 {
-   curStack = mode == GL_MODELVIEW ? 0 : mode == GL_PROJECTION ? 1 : 2;
+   curStack = (mode == GL_MODELVIEW) ? 0 : (mode == GL_PROJECTION) ? 1 : 2;
    glMatrixMode(mode);
 }
 
@@ -1175,7 +1177,19 @@ void GLBindBuffer(int target, uint buffer)
 #endif
 }
 
-void GLBufferData(int type, GLenum target, int size, const GLvoid *data, GLenum usage)
+public void GLVertexPointer(int numCoords, int glType, int stride, void *pointer, int numVertices)
+{
+#ifdef __ANDROID__
+   if(type == GL_DOUBLE)
+      glesVertexPointerd(numCoords, stride, pointer, numVertices);
+   else if(type == GL_UNSIGNED_INT)
+      glesVertexPointeri(numCoords, stride, pointer, numVertices);
+   else
+#endif
+      glVertexPointer(numCoords, glType, stride, pointer);
+}
+
+public void GLBufferData(int type, GLenum target, int size, const GLvoid *data, GLenum usage)
 {
 #ifdef __ANDROID__
    if(type == GL_DOUBLE)
@@ -2379,8 +2393,9 @@ class OpenGLDisplayDriver : DisplayDriver
          glBindTexture(GL_TEXTURE_2D, glBitmap);
          glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
 
-         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, mipMaps ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR);
+         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, mipMaps ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR);
+         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+
          //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
 
          //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
@@ -2393,9 +2408,11 @@ class OpenGLDisplayDriver : DisplayDriver
 
          result = true;
 
-         for(level = 0; result && (w > 1 || h > 1); level++, w >>= 1, h >>= 1)
+         for(level = 0; result && (w >= 1 || h >= 1); level++, w >>= 1, h >>= 1)
          {
             Bitmap mipMap;
+            if(!w) w = 1;
+            if(!h) h = 1;
             if(bitmap.width != w || bitmap.height != h)
             {
                mipMap = Bitmap { };