Browse Source

Allows GamePlay to be compiled on non-pvr systems

Modifies 'texture' to optionally compile in the PVR compressed
texture defines and functions if the platform supports PVR

Currently this check is probably insufficient (do all Android devices
use a PowerVR graphics chip?)
The #ifdef's in Texture are also not very nice, especially because
two of them are in the header file.

Should probably be extracted to simply 'compressTexture' and then
the texture object compresses the texture with PVR on those platforms
that support it and with other tools (E.g. DXT1 or S3TC). I am not
sure however, how this works with differeing graphics cards such as
nvida vs. AMD ATI.
Brandon Slack 13 years ago
parent
commit
abb64177af
4 changed files with 18 additions and 6 deletions
  1. 5 3
      gameplay/src/Base.h
  2. 1 1
      gameplay/src/Game.cpp
  3. 7 1
      gameplay/src/Texture.cpp
  4. 5 1
      gameplay/src/Texture.h

+ 5 - 3
gameplay/src/Base.h

@@ -201,11 +201,12 @@ extern void printError(const char* format, ...);
     extern PFNGLISVERTEXARRAYOESPROC glIsVertexArray;
     #define glClearDepth glClearDepthf
     #define OPENGL_ES
+    #define OPENGL_ES_PVR    
 #elif WIN32
     #define WIN32_LEAN_AND_MEAN
-	#define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG                      0x8C00
-	#define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG                      0x8C01
-	#define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG                     0x8C02
+	#define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG                      0x8C00
+	#define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG                      0x8C01
+	#define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG                     0x8C02
 	#define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG                     0x8C03
     #include <GL/glew.h>
 #elif __APPLE__
@@ -219,6 +220,7 @@ extern void printError(const char* format, ...);
         #define glIsVertexArray glIsVertexArrayOES
         #define glClearDepth glClearDepthf
         #define OPENGL_ES
+        #define OPENGL_ES_PVR    
     #elif TARGET_OS_MAC
         #include <OpenGL/gl.h>
         #include <OpenGL/glext.h>

+ 1 - 1
gameplay/src/Game.cpp

@@ -295,7 +295,7 @@ void Game::fireTimeEvents(long frameTime)
 {
     while (_timeEvents.size() > 0)
     {
-        TimeEvent* timeEvent = &_timeEvents.top();
+        const TimeEvent* timeEvent = &_timeEvents.top();
         if (timeEvent->time > frameTime)
         {
             break;

+ 7 - 1
gameplay/src/Texture.cpp

@@ -75,8 +75,12 @@ 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);
+#else
+                texture = NULL; // Cannot handle PVR if not supported on platform
+#endif
 			}
             break;
         }
@@ -143,6 +147,7 @@ Texture* Texture::create(Format format, unsigned int width, unsigned int height,
     return texture;
 }
 
+#ifdef OPENGL_ES_PVR
 Texture* Texture::createCompressedPVR(const char* path)
 {
 	char PVRTexIdentifier[] = "PVR!";
@@ -274,7 +279,8 @@ Texture* Texture::createCompressedPVR(const char* path)
 
 	return texture;
 }
-
+#endif
+    
 unsigned int Texture::getWidth() const
 {
     return _width;

+ 5 - 1
gameplay/src/Texture.h

@@ -30,10 +30,12 @@ public:
         RGBA    = GL_RGBA,
         ALPHA   = GL_ALPHA,
         DEPTH   = GL_DEPTH_COMPONENT,
+#ifdef OPENGL_ES_PVR
         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,
 		COMPRESSED_RGBA_PVRTC_2BPP = GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG
+#endif
     };
 
     /**
@@ -211,8 +213,10 @@ private:
      */
     virtual ~Texture();
 
+#ifdef OPENGL_ES_PVR
 	static Texture* createCompressedPVR(const char* path);
-
+#endif
+    
     std::string _path;
     TextureHandle _handle;
     unsigned int _width;