From 94fa6b316eaab93d30eafe4f1dd257f410a08cf3 Mon Sep 17 00:00:00 2001 From: mittorn Date: Thu, 27 Aug 2015 01:41:03 +0700 Subject: [PATCH] Change c++ code to c --- Android.mk | 20 ++++---------------- GL/glesinterface.h | 6 +++--- eglwrap.cpp => eglwrap.c | 6 +++--- nanoWrap.cpp => nanoWrap.c | 35 ++++++++++++++++++++--------------- nanogl.cpp => nanogl.c | 0 5 files changed, 30 insertions(+), 37 deletions(-) rename eglwrap.cpp => eglwrap.c (97%) rename nanoWrap.cpp => nanoWrap.c (98%) rename nanogl.cpp => nanogl.c (100%) diff --git a/Android.mk b/Android.mk index 11fc7cd..b0bf541 100644 --- a/Android.mk +++ b/Android.mk @@ -18,28 +18,16 @@ include $(CLEAR_VARS) LOCAL_MODULE := NanoGL -LOCAL_CFLAGS += $(CFLAGS_OPT) -ifeq ($(TARGET_ARCH_ABI),armeabi-v7a-hard) -LOCAL_CFLAGS += $(CFLAGS_OPT_ARM) -mfloat-abi=hard -mhard-float -DLOAD_HARDFP -DSOFTFP_LINK -endif -ifeq ($(TARGET_ARCH_ABI),armeabi-v7a) -LOCAL_CFLAGS += $(CFLAGS_OPT_ARM) -mfloat-abi=softfp -endif -ifeq ($(TARGET_ARCH_ABI),armeabi) -LOCAL_CFLAGS += $(CFLAGS_OPT_ARMv5) -endif -ifeq ($(TARGET_ARCH_ABI),x86) -LOCAL_CFLAGS += $(CFLAGS_OPT_X86) -endif +include $(XASH3D_CONFIG) LOCAL_CFLAGS += LOCAL_C_INCLUDES := $(LOCAL_PATH)/GL LOCAL_SRC_FILES := \ - nanogl.cpp \ - nanoWrap.cpp \ - eglwrap.cpp + nanogl.c \ + nanoWrap.c \ + eglwrap.c LOCAL_LDLIBS := -llog diff --git a/GL/glesinterface.h b/GL/glesinterface.h index 46de9e4..6f28571 100644 --- a/GL/glesinterface.h +++ b/GL/glesinterface.h @@ -34,7 +34,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define S #endif -struct GlESInterface +typedef struct GlESInterface_s { int (*eglChooseConfig) (int dpy, const int *attrib_list, int *configs, int config_size, int *num_config) S; @@ -53,7 +53,7 @@ struct GlESInterface int (*eglGetDisplay) (int display) S; int (*eglGetError) (void) S; - void (*(*eglGetProcAddress) (const char *procname))(...) S; + void *(*eglGetProcAddress) (const char *procname) S; int (*eglInitialize) (int dpy, int *major, int *minor) S; int (*eglMakeCurrent) (int dpy, int draw, int read, int ctx) S; @@ -216,7 +216,7 @@ struct GlESInterface int (*eglReleaseTexImage) (int dpy, int surface, int buffer) S; int (*eglSurfaceAttrib) (int dpy, int surface, int attribute, int value) S; - }; + } GlESInterface; #if !defined (__WINS__) #if defined(__TARGET_FPU_VFP) #pragma no_softfp_linkage diff --git a/eglwrap.cpp b/eglwrap.c similarity index 97% rename from eglwrap.cpp rename to eglwrap.c index ab57519..b551d05 100644 --- a/eglwrap.cpp +++ b/eglwrap.c @@ -26,8 +26,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include -extern "C++" GlESInterface* glEsImpl; -extern "C++" void FlushOnStateChange(); +extern GlESInterface* glEsImpl; +extern void FlushOnStateChange(); EGLint eglGetError (void) @@ -55,7 +55,7 @@ const char * eglQueryString (EGLDisplay dpy, EGLint name) } #if defined(__MULTITEXTURE_SUPPORT__) -extern "C" void glMultiTexCoord2fARB( GLenum target, GLfloat s, GLfloat t ); +void glMultiTexCoord2fARB( GLenum target, GLfloat s, GLfloat t ); #endif void * eglGetProcAddress (const char *procname) diff --git a/nanoWrap.cpp b/nanoWrap.c similarity index 98% rename from nanoWrap.cpp rename to nanoWrap.c index a30a009..c07a9ec 100644 --- a/nanoWrap.cpp +++ b/nanoWrap.c @@ -163,7 +163,7 @@ static struct nanotmuState tmuInitState = static struct nanotmuState* activetmuState = &tmuState0; -extern "C++" GlESInterface* glEsImpl; +extern GlESInterface* glEsImpl; static GLenum wrapperPrimitiveMode = GL_QUADS; GLboolean useTexCoordArray = GL_FALSE; @@ -185,7 +185,7 @@ GLboolean useMultiTexCoordArray = GL_FALSE; static GLboolean delayedttmuchange = GL_FALSE; static GLenum delayedtmutarget = GL_TEXTURE0; -struct VertexAttrib +typedef struct VertexAttrib_s { float x; float y; @@ -204,7 +204,7 @@ struct VertexAttrib float s_multi; float t_multi; #endif - }; + } VertexAttrib; static VertexAttrib vertexattribs[40000]; @@ -244,7 +244,7 @@ void InitGLStructs() memcpy(&nanoglState, &nanoglInitState, sizeof(struct nanoState)); memcpy(&tmuState0,&tmuInitState,sizeof(struct nanotmuState)); memcpy(&tmuState1,&tmuInitState,sizeof(struct nanotmuState)); - memcpy(¤tVertexAttrib,¤tVertexAttribInit,sizeof(struct VertexAttrib)); + memcpy(¤tVertexAttrib,¤tVertexAttribInit,sizeof(VertexAttrib)); activetmuState = &tmuState0; wrapperPrimitiveMode = GL_QUADS; @@ -400,8 +400,8 @@ void glEnd(void) break; case GL_TRIANGLES: { - int vcount = (vertexCount-vertexMark)/3; - for (int count = 0; count < vcount; count++) + int count, vcount = (vertexCount-vertexMark)/3; + for (count = 0; count < vcount; count++) { *ptrIndexArray++ = indexCount; *ptrIndexArray++ = indexCount+1; @@ -419,6 +419,8 @@ void glEnd(void) int vcount = ((vertexCount-vertexMark)-3); if (vcount && ((long)ptrIndexArray & 0x02)) { + unsigned int *longptr; + int count; *ptrIndexArray++ = indexCount-1; // 2 *ptrIndexArray++ = indexCount-2; // 1 *ptrIndexArray++ = indexCount; // 3 @@ -426,9 +428,9 @@ void glEnd(void) vcount-=1; int odd = vcount&1; vcount/=2; - unsigned int* longptr = (unsigned int*) ptrIndexArray; + longptr = (unsigned int*) ptrIndexArray; - for (int count = 0; count < vcount; count++) + for (count = 0; count < vcount; count++) { *(longptr++) = (indexCount-2) | ((indexCount-1)<<16); *(longptr++) = (indexCount) | ((indexCount)<<16); @@ -447,11 +449,13 @@ void glEnd(void) else { //already aligned + unsigned int *longptr; + int count; int odd = vcount&1; vcount/=2; - unsigned int* longptr = (unsigned int*) ptrIndexArray; + longptr = (unsigned int*) ptrIndexArray; - for (int count = 0; count < vcount; count++) + for (count = 0; count < vcount; count++) { *(longptr++) = (indexCount-1) | ((indexCount-2)<<16); *(longptr++) = (indexCount) | ((indexCount-1)<<16); @@ -475,11 +479,12 @@ void glEnd(void) case GL_POLYGON: case GL_TRIANGLE_FAN: { + int count, vcount = ((vertexCount-vertexMark)-3); *ptrIndexArray++ = indexCount++; *ptrIndexArray++ = indexCount++; *ptrIndexArray++ = indexCount++; - int vcount = ((vertexCount-vertexMark)-3); - for (int count = 0; count < vcount; count++) + + for (count = 0; count < vcount; count++) { *ptrIndexArray++ = indexbase; *ptrIndexArray++ = indexCount-1; @@ -1037,7 +1042,7 @@ void glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei wid glEsImpl->glTexImage2D(target, level, internalformat, width, height,border,format,type,pixels); } -void glDrawBuffer(GLenum /*mode*/) +void glDrawBuffer(GLenum mode) { } @@ -1395,7 +1400,7 @@ void glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum forma glEsImpl->glReadPixels(x,y,width,height,format,type,pixels); } -void glReadBuffer( GLenum /*mode*/ ) +void glReadBuffer( GLenum mode ) { } @@ -1745,7 +1750,7 @@ void glClearStencil( GLint s ) {} #if defined(__MULTITEXTURE_SUPPORT__) -extern "C" void glMultiTexCoord2fARB( GLenum target, GLfloat s, GLfloat t ); +void glMultiTexCoord2fARB( GLenum target, GLfloat s, GLfloat t ); void glMultiTexCoord2fARB( GLenum target, GLfloat s, GLfloat t ) { diff --git a/nanogl.cpp b/nanogl.c similarity index 100% rename from nanogl.cpp rename to nanogl.c -- 2.29.2