Host OpenGL ES 2.0 code now building without warning or error using GCC. bug235_bringup_0
authorMatt Plumtree <matt.plumtree@nokia.com>
Fri, 12 Nov 2010 17:56:05 +0000
branchbug235_bringup_0
changeset 76 24381b61de5c
parent 75 82d8da1d79c7
child 77 b0395290e61f
Host OpenGL ES 2.0 code now building without warning or error using GCC.
bug235.pkgdef.xml
hostsupport/hostopengles20/src/buffer.c
hostsupport/hostopengles20/src/buffer.h
hostsupport/hostopengles20/src/context.c
hostsupport/hostopengles20/src/context.h
hostsupport/hostopengles20/src/degl.cpp
hostsupport/hostopengles20/src/degl.h
hostsupport/hostopengles20/src/fbo.c
hostsupport/hostopengles20/src/get.c
hostsupport/hostopengles20/src/get.h
hostsupport/hostopengles20/src/half.c
hostsupport/hostopengles20/src/half.h
hostsupport/hostopengles20/src/hgl.h
hostsupport/hostopengles20/src/object.c
hostsupport/hostopengles20/src/object.h
hostsupport/hostopengles20/src/program.c
hostsupport/hostopengles20/src/shader.c
hostsupport/hostopengles20/src/texture.c
hostsupport/hostopengles20/src/util.c
hostsupport/hostopengles20/src/vertex.c
--- a/bug235.pkgdef.xml	Wed Nov 10 15:26:31 2010 +0000
+++ b/bug235.pkgdef.xml	Fri Nov 12 17:56:05 2010 +0000
@@ -115,6 +115,9 @@
 <component name="hostopengles11" long-name="Host OpenGL ES 1.1" introduced="^4" class="PC">
 <unit bldFile="hostsupport/hostopengles11/group"/>
 </component>
+<component name="hostopengles20" long-name="Host OpenGL ES 2.0" introduced="^4" class="PC">
+<unit bldFile="hostsupport/hostopengles20/group"/>
+</component>
 <component name="hostopenvg" long-name="Host OpenVG" introduced="^4" class="PC">
 <unit bldFile="hostsupport/hostopenvg/group"/>
 </component>
--- a/hostsupport/hostopengles20/src/buffer.c	Wed Nov 10 15:26:31 2010 +0000
+++ b/hostsupport/hostopengles20/src/buffer.c	Fri Nov 12 17:56:05 2010 +0000
@@ -32,7 +32,7 @@
 
 DGLBuffer* DGLBuffer_create(GLuint name)
 {
-	DGLBuffer* buffer = malloc(sizeof(DGLBuffer));
+	DGLBuffer* buffer = (DGLBuffer*)malloc(sizeof(DGLBuffer));
 	if(buffer == NULL)
 	{
 		return NULL;
--- a/hostsupport/hostopengles20/src/buffer.h	Wed Nov 10 15:26:31 2010 +0000
+++ b/hostsupport/hostopengles20/src/buffer.h	Fri Nov 12 17:56:05 2010 +0000
@@ -44,4 +44,4 @@
 DGLBuffer*	DGLBuffer_create(GLuint name);
 void		DGLBuffer_destroy(DGLBuffer* buffer);
 
-#endif /* BUFFER_H_ */
\ No newline at end of file
+#endif /* BUFFER_H_ */
--- a/hostsupport/hostopengles20/src/context.c	Wed Nov 10 15:26:31 2010 +0000
+++ b/hostsupport/hostopengles20/src/context.c	Fri Nov 12 17:56:05 2010 +0000
@@ -31,7 +31,7 @@
 
 DGLContext* DGLContext_create(void* native_context)
 {
-    DGLContext* ctx = malloc(sizeof(DGLContext));
+    DGLContext* ctx = (DGLContext*)malloc(sizeof(DGLContext));
     if(ctx == NULL)
     {
         return NULL;
@@ -61,7 +61,7 @@
     ctx->hgl.GetIntegerv(GL_MAX_VERTEX_ATTRIBS, &temp);
     ctx->max_vertex_attribs = temp;
 
-    ctx->vertex_arrays = malloc(ctx->max_vertex_attribs * sizeof(DGLVertexArray));
+    ctx->vertex_arrays = (DGLVertexArray*)malloc(ctx->max_vertex_attribs * sizeof(DGLVertexArray));
     if(ctx->vertex_arrays == NULL)
     {
         return GL_FALSE;
@@ -363,7 +363,7 @@
         DGLES2_ASSERT(source != NULL);
         DGLES2_ASSERT(length >= 0);
 
-        shader->source = malloc(length + 1);
+        shader->source = (char*)malloc(length + 1);
         if(shader->source == NULL)
         {
             return GL_FALSE;
--- a/hostsupport/hostopengles20/src/context.h	Wed Nov 10 15:26:31 2010 +0000
+++ b/hostsupport/hostopengles20/src/context.h	Fri Nov 12 17:56:05 2010 +0000
@@ -29,10 +29,6 @@
 #ifndef _GLESCONTEXT_H_
 #define _GLESCONTEXT_H_
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 #include "platform.h"
 #include "degl.h"
 #include "vertex.h"
@@ -42,6 +38,10 @@
 #include "texture.h"
 #include "fbo.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 typedef struct DGLContext
 {
     GLboolean	initialized;
--- a/hostsupport/hostopengles20/src/degl.cpp	Wed Nov 10 15:26:31 2010 +0000
+++ b/hostsupport/hostopengles20/src/degl.cpp	Fri Nov 12 17:56:05 2010 +0000
@@ -366,7 +366,7 @@
 
 int EGLtoGLES2Interface::BindTexImage( void* surface, int level, bool generate_mipmap, const SurfaceDescriptor* desc, void* buffer )
 {
-	DGLES2_ENTER_RET(NULL);
+	DGLES2_ENTER_RET(0);
 
 	GLuint ret = 0;
 
@@ -495,7 +495,7 @@
 	}
 
 	// Not reached.
-	return -1;
+	return (GLenum)-1;
 }
 
 static bool dglPrepareState(DGLContext& ctx, GLuint name, EImageTarget target, GLint level, GLenum& query_target, GLenum& bind_target, GLint& binding)
@@ -617,7 +617,7 @@
 	surfDesc.m_blueShift = 0;
 	surfDesc.m_luminanceShift = 0;
 	surfDesc.m_alphaShift = 0;
-	int bpp = 0;
+
 	switch(format)
 	{
 #ifndef DGLES2_NO_SRGB
--- a/hostsupport/hostopengles20/src/degl.h	Wed Nov 10 15:26:31 2010 +0000
+++ b/hostsupport/hostopengles20/src/degl.h	Fri Nov 12 17:56:05 2010 +0000
@@ -62,6 +62,7 @@
 {
 public:
     EGLtoGLES2Interface();
+    virtual ~EGLtoGLES2Interface() {}
 
 	void SetEGLInterface( IGLEStoEGLInterface* );
 	void* CreateContext( void* nativeContext );
@@ -88,4 +89,4 @@
 
 #endif /* __cplusplus */
 
-#endif /* DEGL_H */
\ No newline at end of file
+#endif /* DEGL_H */
--- a/hostsupport/hostopengles20/src/fbo.c	Wed Nov 10 15:26:31 2010 +0000
+++ b/hostsupport/hostopengles20/src/fbo.c	Fri Nov 12 17:56:05 2010 +0000
@@ -30,9 +30,16 @@
 #include "hgl.h"
 #include "context.h"
 
+#ifdef __cplusplus
+extern "C"
+{
+GL_APICALL void GL_APIENTRY glEGLImageTargetRenderbufferStorageOES (GLenum target, GLeglImageOES image);
+}
+#endif
+
 DGLRenderbuffer* DGLRenderbuffer_create(GLuint name)
 {
-	DGLRenderbuffer* buffer = malloc(sizeof(DGLRenderbuffer));
+	DGLRenderbuffer* buffer = (DGLRenderbuffer*)malloc(sizeof(DGLRenderbuffer));
 	if(buffer == NULL)
 	{
 		return NULL;
@@ -261,4 +268,4 @@
 		DGLES2_ERROR(GL_INVALID_OPERATION);
 	}
 	DGLES2_LEAVE_NO_ERROR_CHECK();
-}
\ No newline at end of file
+}
--- a/hostsupport/hostopengles20/src/get.c	Wed Nov 10 15:26:31 2010 +0000
+++ b/hostsupport/hostopengles20/src/get.c	Fri Nov 12 17:56:05 2010 +0000
@@ -254,4 +254,3 @@
 		DGLES2_LEAVE_RET(str);
 	}
 }
-
--- a/hostsupport/hostopengles20/src/get.h	Wed Nov 10 15:26:31 2010 +0000
+++ b/hostsupport/hostopengles20/src/get.h	Fri Nov 12 17:56:05 2010 +0000
@@ -37,4 +37,4 @@
 	DGLES2_TYPE_BOOL
 } DGLType;
 
-#endif /* GET_H_ */
\ No newline at end of file
+#endif /* GET_H_ */
--- a/hostsupport/hostopengles20/src/half.c	Wed Nov 10 15:26:31 2010 +0000
+++ b/hostsupport/hostopengles20/src/half.c	Fri Nov 12 17:56:05 2010 +0000
@@ -54,4 +54,4 @@
 							   (mantissa << 13);
 		return *(GLfloat*)&conv;
 	}
-}
\ No newline at end of file
+}
--- a/hostsupport/hostopengles20/src/half.h	Wed Nov 10 15:26:31 2010 +0000
+++ b/hostsupport/hostopengles20/src/half.h	Fri Nov 12 17:56:05 2010 +0000
@@ -33,4 +33,4 @@
 
 GLfloat dglConvertHalfToFloat(khronos_int16_t half);
 
-#endif /* HALF_H_ */
\ No newline at end of file
+#endif /* HALF_H_ */
--- a/hostsupport/hostopengles20/src/hgl.h	Wed Nov 10 15:26:31 2010 +0000
+++ b/hostsupport/hostopengles20/src/hgl.h	Fri Nov 12 17:56:05 2010 +0000
@@ -219,7 +219,7 @@
 #ifndef HGL_NO_VARIABLES
 extern HGL hgl;
 
-extern int hglLoad();
+extern int hglLoad(HGL* hgl);
 #endif // HGL_NO_VARIABLES
 
 #endif // HGL_H_
--- a/hostsupport/hostopengles20/src/object.c	Wed Nov 10 15:26:31 2010 +0000
+++ b/hostsupport/hostopengles20/src/object.c	Fri Nov 12 17:56:05 2010 +0000
@@ -107,4 +107,4 @@
 		object = object->next;
 	}
 	return object;
-}
\ No newline at end of file
+}
--- a/hostsupport/hostopengles20/src/object.h	Wed Nov 10 15:26:31 2010 +0000
+++ b/hostsupport/hostopengles20/src/object.h	Fri Nov 12 17:56:05 2010 +0000
@@ -41,4 +41,4 @@
 DGLObject*	DGLObject_remove(DGLObject** root, GLuint name);
 DGLObject*	DGLObject_find(DGLObject* root, GLuint name);
 
-#endif /* OBJECT_H_ */
\ No newline at end of file
+#endif /* OBJECT_H_ */
--- a/hostsupport/hostopengles20/src/program.c	Wed Nov 10 15:26:31 2010 +0000
+++ b/hostsupport/hostopengles20/src/program.c	Fri Nov 12 17:56:05 2010 +0000
@@ -35,7 +35,7 @@
 
 DGLProgram* DGLProgram_create(GLuint name)
 {
-	DGLProgram* program = malloc(sizeof(DGLProgram));
+	DGLProgram* program = (DGLProgram*)malloc(sizeof(DGLProgram));
 	if(program == NULL)
 	{
 		return NULL;
--- a/hostsupport/hostopengles20/src/shader.c	Wed Nov 10 15:26:31 2010 +0000
+++ b/hostsupport/hostopengles20/src/shader.c	Fri Nov 12 17:56:05 2010 +0000
@@ -33,7 +33,7 @@
 
 DGLShader* DGLShader_create(GLuint name)
 {
-	DGLShader* shader = malloc(sizeof(DGLShader));
+	DGLShader* shader = (DGLShader*)malloc(sizeof(DGLShader));
 	if(shader == NULL)
 	{
 		return NULL;
@@ -255,7 +255,7 @@
 			if (buffer) {
 				free(buffer);
 			}
-			buffer = malloc(buffersize + 1);
+			buffer = (char*)malloc(buffersize + 1);
 		}
 		memcpy(buffer, prev, s - prev);
 		buffer[s - prev] = 0;
@@ -269,7 +269,7 @@
 			if (buffer) {
 				free(buffer);
 			}
-			buffer = malloc(buffersize + 1);
+			buffer = (char*)malloc(buffersize + 1);
 		}
 		memcpy(buffer, s, e - s);
 		buffer[e - s] = 0;
@@ -299,7 +299,7 @@
 		
 		*patched_len = 0;
 		buffer_size = len;
-		patched = malloc(buffer_size + 1);
+		patched = (char*)malloc(buffer_size + 1);
 		if(patched == NULL)	{
 			return NULL;
 		}
@@ -342,7 +342,7 @@
 				tok_len = strlen(p);
 				if(*patched_len + tok_len > buffer_size) {
 					buffer_size *= 2;
-					patched = realloc(patched, buffer_size + 1);
+					patched = (char*)realloc(patched, buffer_size + 1);
 					if(patched == NULL) {
 						return NULL;
 					}
@@ -357,7 +357,7 @@
 		if (!version_found) {
 			char* new_patched;
 			*patched_len += strlen("#version 120\n");
-			new_patched = malloc(*patched_len + 1);
+			new_patched = (char*)malloc(*patched_len + 1);
 			if (new_patched == NULL) {
 				return NULL;
 			}
@@ -405,8 +405,8 @@
 	}
 	Dprintf("---END-ORIGINAL-SHADER---\n");
 #endif // !NDEBUG
-	char** string_dgl = malloc(sizeof(char*)*count);
-	GLint* length_dgl = malloc(sizeof(GLint)*count);
+	char** string_dgl = (char**)malloc(sizeof(char*)*count);
+	GLint* length_dgl = (GLint*)malloc(sizeof(GLint)*count);
 
 	// Remove the non OpenGL 2.x compilant keywords.
 	for(unsigned i = 0; i < count; ++i)
@@ -423,7 +423,7 @@
 		};
 
 		length_dgl[i] = length ? length[i] : strlen(string[i]);
-		string_dgl[i] = malloc(length_dgl[i] + 1);
+		string_dgl[i] = (char*)malloc(length_dgl[i] + 1);
 		memcpy(string_dgl[i], string[i], length_dgl[i]);
 		string_dgl[i][length_dgl[i]] = 0;
 
@@ -487,7 +487,7 @@
 
 					if(source == NULL)
 					{
-						source = malloc(total_len + 1);
+						source = (char*)malloc(total_len + 1);
 						if(source == NULL)
 						{
 							DGLES2_ERROR(GL_OUT_OF_MEMORY);
@@ -496,7 +496,7 @@
 					}
 					else
 					{
-						source = realloc(source, total_len + 1);
+						source = (char*)realloc(source, total_len + 1);
 						if(source == NULL)
 						{
 							DGLES2_ERROR(GL_OUT_OF_MEMORY);
--- a/hostsupport/hostopengles20/src/texture.c	Wed Nov 10 15:26:31 2010 +0000
+++ b/hostsupport/hostopengles20/src/texture.c	Fri Nov 12 17:56:05 2010 +0000
@@ -33,9 +33,16 @@
 #include "util.h"
 #include "degl.h"
 
+#ifdef __cplusplus
+extern "C"
+{
+GL_APICALL void GL_APIENTRY glEGLImageTargetTexture2DOES (GLenum target, GLeglImageOES image);
+}
+#endif
+
 DGLTexture* DGLTexture_create(GLuint name, DGLTextureType type, GLint num_levels)
 {
-	DGLTexture* texture = malloc(sizeof(DGLTexture));
+	DGLTexture* texture = (DGLTexture*)malloc(sizeof(DGLTexture));
 	if(texture == NULL)
 	{
 		return NULL;
@@ -51,7 +58,7 @@
 		for(face = 0; face < 6; face++)
 		{
 			texture->num_levels[face] = 0;
-			texture->levels[face] = malloc(num_levels * sizeof(DGLTextureLevel));
+			texture->levels[face] = (DGLTextureLevel*)malloc(num_levels * sizeof(DGLTextureLevel));
 			if(texture->levels[face] == NULL)
 			{
 				while(face--)
@@ -118,7 +125,7 @@
 
 			default:
 				DGLES2_ASSERT(GL_FALSE);
-				return -1;
+				return (GLenum)-1;
 		}
 	}
 }
@@ -384,7 +391,7 @@
 {
 	int bytes_per_pixel = 3; // RGB888
 
-	unsigned char* decompressed = malloc(width * height * bytes_per_pixel);
+	unsigned char* decompressed = (unsigned char*)malloc(width * height * bytes_per_pixel);
 	if(decompressed == NULL)
 	{
 		return NULL;
@@ -582,7 +589,7 @@
 
 static void* dglDecompressPalettedTexture(int level, GLenum format, int width, int height, int imageSize, const void* data)
 {
-	const unsigned char* palette = data;
+	const unsigned char* palette = (const unsigned char*)data;
 	int bits_per_pixel;
 	int palette_entry_size;
 	int num_palette_entries;
@@ -666,7 +673,7 @@
 		bytes_per_pixel = 4;
 	}
 
-	decompressed_data = malloc(width * height * bytes_per_pixel);
+	decompressed_data = (char*)malloc(width * height * bytes_per_pixel);
 	if(decompressed_data == NULL)
 	{
 		return NULL;
@@ -880,7 +887,7 @@
 				DGLES2_ERROR(GL_INVALID_VALUE);
 			}
 
-			decompressed_data = dglDecompressETCTexture(width, height, data);
+			decompressed_data = dglDecompressETCTexture(width, height, (const unsigned char*)data);
 			ctx->hgl.TexImage2D(target, level, GL_RGB, width, height, border, GL_RGB, GL_UNSIGNED_BYTE, decompressed_data);
 			free(decompressed_data);
 			if(DGLContext_getHostError(ctx) == GL_NO_ERROR)
@@ -1135,7 +1142,7 @@
 			DGLES2_ASSERT(GL_FALSE);
 	}
 
-	conv = malloc(width * height * components * sizeof(GLfloat));
+	conv = (GLfloat*)malloc(width * height * components * sizeof(GLfloat));
 	if(conv == NULL)
 	{
 		return NULL;
@@ -1341,4 +1348,4 @@
 		}
 	}
 	DGLES2_LEAVE_NO_ERROR_CHECK();
-}
\ No newline at end of file
+}
--- a/hostsupport/hostopengles20/src/util.c	Wed Nov 10 15:26:31 2010 +0000
+++ b/hostsupport/hostopengles20/src/util.c	Fri Nov 12 17:56:05 2010 +0000
@@ -46,4 +46,4 @@
 int dglMax(int a, int b)
 {
 	return a > b ? a : b;
-}
\ No newline at end of file
+}
--- a/hostsupport/hostopengles20/src/vertex.c	Wed Nov 10 15:26:31 2010 +0000
+++ b/hostsupport/hostopengles20/src/vertex.c	Fri Nov 12 17:56:05 2010 +0000
@@ -89,12 +89,12 @@
 			{
 				if(type == DGLES2_TYPE_INT)
 				{
-					ctx->hgl.GetVertexAttribiv(index, GL_CURRENT_VERTEX_ATTRIB, params);
+					ctx->hgl.GetVertexAttribiv(index, GL_CURRENT_VERTEX_ATTRIB, (GLint*)params);
 				}
 				else
 				{
 					DGLES2_ASSERT(type == DGLES2_TYPE_FLOAT);
-					ctx->hgl.GetVertexAttribfv(index, GL_CURRENT_VERTEX_ATTRIB, params);
+					ctx->hgl.GetVertexAttribfv(index, GL_CURRENT_VERTEX_ATTRIB, (GLfloat*)params);
 				}
 			}
 			return GL_TRUE;
@@ -165,7 +165,7 @@
 
 				if(va->floatptr) free(va->floatptr);
 
-				va->floatptr = malloc(sizeof(GLfloat)*count*va->size);
+				va->floatptr = (GLfloat*)malloc(sizeof(GLfloat)*count*va->size);
 				{
 					GLsizei j;
 					for(j = 0; j < count; ++j)
@@ -449,4 +449,3 @@
 	}
 	DGLES2_LEAVE();
 }
-