Explorar el Código

Updated define for PVRTC.
Enabled on Windows

setaylor hace 13 años
padre
commit
7ced2c3b98

+ 4 - 5
gameplay/src/Base.h

@@ -198,7 +198,7 @@ extern void printError(const char* format, ...);
     extern PFNGLISVERTEXARRAYOESPROC glIsVertexArray;
     #define glClearDepth glClearDepthf
     #define OPENGL_ES
-    #define OPENGL_ES_PVR    
+    #define USE_PVRTC
 #elif WIN32
     #define WIN32_LEAN_AND_MEAN
     #define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG                      0x8C00
@@ -206,6 +206,7 @@ extern void printError(const char* format, ...);
     #define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG                     0x8C02
     #define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG                     0x8C03
     #include <GL/glew.h>
+    #define USE_VAO
 #elif __APPLE__
     #include "TargetConditionals.h"
     #if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
@@ -217,7 +218,7 @@ extern void printError(const char* format, ...);
         #define glIsVertexArray glIsVertexArrayOES
         #define glClearDepth glClearDepthf
         #define OPENGL_ES
-        #define OPENGL_ES_PVR    
+        #define USE_PVRTC 
     #elif TARGET_OS_MAC
         #include <OpenGL/gl.h>
         #include <OpenGL/glext.h>
@@ -230,8 +231,6 @@ extern void printError(const char* format, ...);
     #endif
 #endif
 
-
-
 // Graphics (GLSL)
 #define VERTEX_ATTRIBUTE_POSITION_NAME              "a_position"
 #define VERTEX_ATTRIBUTE_NORMAL_NAME                "a_normal"
@@ -240,7 +239,7 @@ extern void printError(const char* format, ...);
 #define VERTEX_ATTRIBUTE_BINORMAL_NAME              "a_binormal"
 #define VERTEX_ATTRIBUTE_BLENDWEIGHTS_NAME          "a_blendWeights"
 #define VERTEX_ATTRIBUTE_BLENDINDICES_NAME          "a_blendIndices"
-#define VERTEX_ATTRIBUTE_TEXCOORD_PREFIX            "a_texCoord"
+#define VERTEX_ATTRIBUTE_TEXCOORD_PREFIX_NAME       "a_texCoord"
 
 // Hardware Resources
 namespace gameplay

+ 31 - 31
gameplay/src/Texture.cpp

@@ -75,11 +75,11 @@ Texture* Texture::create(const char* path, bool generateMipmaps)
             }
             else if (tolower(ext[1]) == 'p' && tolower(ext[2]) == 'v' && tolower(ext[3]) == 'r')
             {
-#ifdef OPENGL_ES_PVR
-                // PowerVR Compressed RGBA
-                texture = createCompressedPVR(path);
+#ifdef USE_PVRTC
+                // PowerVR Compressed Texture RGBA
+                texture = createCompressedPVRTC(path);
 #else
-                texture = NULL; // Cannot handle PVR if not supported on platform
+                texture = NULL; // Cannot handle PVRTC if not supported on platform
 #endif
             }
             break;
@@ -147,32 +147,32 @@ Texture* Texture::create(Format format, unsigned int width, unsigned int height,
     return texture;
 }
 
-#ifdef OPENGL_ES_PVR
-Texture* Texture::createCompressedPVR(const char* path)
+#ifdef USE_PVRTC
+Texture* Texture::createCompressedPVRTC(const char* path)
 {
-    char PVRTexIdentifier[] = "PVR!";
+    char PVRTCIdentifier[] = "PVR!";
 
     enum
     {
-        PVRTextureFlagTypePVRTC_2 = 24,
-        PVRTextureFlagTypePVRTC_4
+        PVRTC_2 = 24,
+        PVRTC_4
     };
 
-    struct pvr_file_header
+    struct pvrtc_file_header
     {
         unsigned int size;                  // size of the structure
-        unsigned int height;                  // height of surface to be created
-        unsigned int width;                   // width of input surface
-        unsigned int mipmapCount;             // number of mip-map levels requested
+        unsigned int height;                // height of surface to be created
+        unsigned int width;                 // width of input surface
+        unsigned int mipmapCount;           // number of mip-map levels requested
         unsigned int formatflags;           // pixel format flags
-        unsigned int dataSize;                 // total size in bytes
-        unsigned int bpp;                    // number of bits per pixel
+        unsigned int dataSize;              // total size in bytes
+        unsigned int bpp;                   // number of bits per pixel
         unsigned int redBitMask;            // mask for red bit
         unsigned int greenBitMask;          // mask for green bits
         unsigned int blueBitMask;           // mask for blue bits
-        unsigned int alphaBitMask;            // mask for alpha channel
-        unsigned int pvrTag;                // magic number identifying pvr file
-        unsigned int surfaceCount;          // number of surfaces present in the pvr
+        unsigned int alphaBitMask;          // mask for alpha channel
+        unsigned int pvrtcTag;              // magic number identifying pvrtc file
+        unsigned int surfaceCount;          // number of surfaces present in the pvrtc
     } ;
 
     FILE* file = FileSystem::openFile(path, "rb");
@@ -183,24 +183,24 @@ Texture* Texture::createCompressedPVR(const char* path)
     }
 
     // Read the file header
-    unsigned int size = sizeof(pvr_file_header);
-    pvr_file_header header;
+    unsigned int size = sizeof(pvrtc_file_header);
+    pvrtc_file_header header;
     unsigned int read = (int)fread(&header, 1, size, file);
     assert(read == size);
     if (read != size)
     {
-        LOG_ERROR_VARG("Read file header error for pvr file: %s (%d < %d)", path, (int)read, (int)size);
+        LOG_ERROR_VARG("Read file header error for pvrtc file: %s (%d < %d)", path, (int)read, (int)size);
         fclose(file);
         return NULL;
     }
 
     // Proper file header identifier
-    if (PVRTexIdentifier[0] != (char)((header.pvrTag >>  0) & 0xff) ||
-        PVRTexIdentifier[1] != (char)((header.pvrTag >>  8) & 0xff) ||
-        PVRTexIdentifier[2] != (char)((header.pvrTag >> 16) & 0xff) ||
-        PVRTexIdentifier[3] != (char)((header.pvrTag >> 24) & 0xff))
+    if (PVRTCIdentifier[0] != (char)((header.pvrtcTag >>  0) & 0xff) ||
+        PVRTCIdentifier[1] != (char)((header.pvrtcTag >>  8) & 0xff) ||
+        PVRTCIdentifier[2] != (char)((header.pvrtcTag >> 16) & 0xff) ||
+        PVRTCIdentifier[3] != (char)((header.pvrtcTag >> 24) & 0xff))
      {
-        LOG_ERROR_VARG("Invalid PVR texture file: %s", path);
+        LOG_ERROR_VARG("Invalid PVRTC compressed texture file: %s", path);
         fclose(file);
         return NULL;
     }
@@ -208,17 +208,17 @@ Texture* Texture::createCompressedPVR(const char* path)
     // Format flags for GLenum format
     GLenum format;
     unsigned int formatFlags = header.formatflags & 0xff;
-    if (formatFlags == PVRTextureFlagTypePVRTC_4)
+    if (formatFlags == PVRTC_4)
     {
         format = header.alphaBitMask ? COMPRESSED_RGBA_PVRTC_4BPP : COMPRESSED_RGB_PVRTC_4BPP;
     }
-    else if (formatFlags == PVRTextureFlagTypePVRTC_2)
+    else if (formatFlags == PVRTC_2)
     {
         format = header.alphaBitMask ? COMPRESSED_RGBA_PVRTC_2BPP : COMPRESSED_RGB_PVRTC_2BPP;
     }
     else
     {
-        LOG_ERROR_VARG("Invalid PVR texture format flags for file: %s", path);
+        LOG_ERROR_VARG("Invalid PVRTC compressed texture format flags for file: %s", path);
         fclose(file);
         return NULL;
     }
@@ -228,7 +228,7 @@ Texture* Texture::createCompressedPVR(const char* path)
     assert(read == header.dataSize);
     if (read != header.dataSize)
     {
-        LOG_ERROR_VARG("Read file data error for pvr file: %s (%d < %d)", path, (int)read, (int)header.dataSize);
+        LOG_ERROR_VARG("Read file data error for pvrtc file: %s (%d < %d)", path, (int)read, (int)header.dataSize);
         SAFE_DELETE_ARRAY(data);
         fclose(file);
         return NULL;
@@ -259,7 +259,7 @@ Texture* Texture::createCompressedPVR(const char* path)
 
     for (unsigned int level = 0; level <= header.mipmapCount; level++)
     {
-        if (formatFlags == PVRTextureFlagTypePVRTC_4)
+        if (formatFlags == PVRTC_4)
         {
             dataSize = ( max((int)width, 8) * max((int)height, 8) * 4 + 7) / 8;
         }

+ 3 - 3
gameplay/src/Texture.h

@@ -30,7 +30,7 @@ public:
         RGBA    = GL_RGBA,
         ALPHA   = GL_ALPHA,
         DEPTH   = GL_DEPTH_COMPONENT,
-#ifdef OPENGL_ES_PVR
+#ifdef USE_PVRTC
         COMPRESSED_RGB_PVRTC_4BPP = GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG,
         COMPRESSED_RGBA_PVRTC_4BPP = GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,
         COMPRESSED_RGB_PVRTC_2BPP = GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG,
@@ -213,8 +213,8 @@ private:
      */
     virtual ~Texture();
 
-#ifdef OPENGL_ES_PVR
-    static Texture* createCompressedPVR(const char* path);
+#ifdef USE_PVRTC
+    static Texture* createCompressedPVRTC(const char* path);
 #endif
     
     std::string _path;

+ 5 - 5
gameplay/src/VertexAttributeBinding.cpp

@@ -86,7 +86,7 @@ VertexAttributeBinding* VertexAttributeBinding::create(Mesh* mesh, const VertexF
     // Create a new VertexAttributeBinding.
     VertexAttributeBinding* b = new VertexAttributeBinding();
 
-#ifdef USE_GL_VAOS
+#ifdef USE_VAO
     if (mesh && glGenVertexArrays)
     {
         GL_ASSERT( glBindBuffer(GL_ARRAY_BUFFER, 0) );
@@ -168,11 +168,11 @@ VertexAttributeBinding* VertexAttributeBinding::create(Mesh* mesh, const VertexF
             attrib = effect->getVertexAttribute(VERTEX_ATTRIBUTE_BLENDINDICES_NAME);
             break;
         case VertexFormat::TEXCOORD0:
-            attrib = effect->getVertexAttribute(VERTEX_ATTRIBUTE_TEXCOORD_PREFIX);
+            attrib = effect->getVertexAttribute(VERTEX_ATTRIBUTE_TEXCOORD_PREFIX_NAME);
             // Try adding a "0" after the texcoord attrib name (flexible name for this case).
             if (attrib == -1)
             {
-                name = VERTEX_ATTRIBUTE_TEXCOORD_PREFIX;
+                name = VERTEX_ATTRIBUTE_TEXCOORD_PREFIX_NAME;
                 name += "0";
                 attrib = effect->getVertexAttribute(name.c_str());
             }
@@ -184,7 +184,7 @@ VertexAttributeBinding* VertexAttributeBinding::create(Mesh* mesh, const VertexF
         case VertexFormat::TEXCOORD5:
         case VertexFormat::TEXCOORD6:
         case VertexFormat::TEXCOORD7:
-            name = VERTEX_ATTRIBUTE_TEXCOORD_PREFIX;
+            name = VERTEX_ATTRIBUTE_TEXCOORD_PREFIX_NAME;
             name += (e.usage - VertexFormat::TEXCOORD0);
             attrib = effect->getVertexAttribute(name.c_str());
             break;
@@ -221,8 +221,8 @@ void VertexAttributeBinding::setVertexAttribPointer(GLuint indx, GLint size, GLe
     if (_handle)
     {
         // Hardware mode
-        GL_ASSERT( glEnableVertexAttribArray(indx) );
         GL_ASSERT( glVertexAttribPointer(indx, size, type, normalize, stride, pointer) );
+        GL_ASSERT( glEnableVertexAttribArray(indx) );
     }
     else
     {