diff --git a/polymer/eduke32/build/include/glbuild.h b/polymer/eduke32/build/include/glbuild.h index 502c342ad..5c14283be 100644 --- a/polymer/eduke32/build/include/glbuild.h +++ b/polymer/eduke32/build/include/glbuild.h @@ -21,9 +21,11 @@ // Tell gl.h to not include glext.h, we'll include our own copy in a minute #define GL_GLEXT_LEGACY -#if defined(__APPLE__) +#if defined EDUKE32_OSX # include # include +#elif defined EDUKE32_IOS +# include #else # include # include @@ -36,8 +38,23 @@ // get this header from http://oss.sgi.com/projects/ogl-sample/registry/ // if you are missing it //#include -#if defined(__APPLE__) +#if defined EDUKE32_OSX # include +#elif defined EDUKE32_IOS +typedef double GLdouble; +# include +typedef GLintptr GLintptrARB; +typedef GLsizeiptr GLsizeiptrARB; +typedef GLchar GLcharARB; +typedef void* GLhandleARB; +typedef unsigned int GLenum; +# define GL_TEXTURE0_ARB GL_TEXTURE0 +# define GL_RGB_SCALE_ARB GL_RGB_SCALE +# define GL_ELEMENT_ARRAY_BUFFER_ARB GL_ELEMENT_ARRAY_BUFFER +# define GL_ARRAY_BUFFER_ARB GL_ARRAY_BUFFER +# define GL_WRITE_ONLY_ARB 0x88B9 +# define GL_STREAM_DRAW_ARB 0x88E0 +# define GL_STATIC_DRAW_ARB 0x88E4 #else # include "glext.h" #endif diff --git a/polymer/eduke32/build/src/dxtfilter.c b/polymer/eduke32/build/src/dxtfilter.c index da9138387..c10147b3c 100644 --- a/polymer/eduke32/build/src/dxtfilter.c +++ b/polymer/eduke32/build/src/dxtfilter.c @@ -139,11 +139,14 @@ int32_t dxtfilter(int32_t fil, const texcachepicture *pict, const char *pic, voi uint32_t j, k, offs, stride; char *cptr; +#if !defined EDUKE32_GLES if ((pict->format == (signed) B_LITTLE32(GL_COMPRESSED_RGB_S3TC_DXT1_EXT)) || (pict->format == (signed) B_LITTLE32(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT))) { offs = 0; stride = 8; } else if ((pict->format == (signed) B_LITTLE32(GL_COMPRESSED_RGBA_S3TC_DXT3_EXT)) || (pict->format == (signed) B_LITTLE32(GL_COMPRESSED_RGBA_S3TC_DXT5_EXT))) { offs = 8; stride = 16; } - else { offs = 0; stride = 8; } + else +#endif + { offs = 0; stride = 8; } if (stride == 16) //If DXT3... { @@ -187,11 +190,14 @@ int32_t dedxtfilter(int32_t fil, const texcachepicture *pict, char *pic, void *m int32_t j, k, offs, stride; char *cptr; +#if !defined EDUKE32_GLES if ((pict->format == GL_COMPRESSED_RGB_S3TC_DXT1_EXT) || (pict->format == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT)) { offs = 0; stride = 8; } else if ((pict->format == GL_COMPRESSED_RGBA_S3TC_DXT3_EXT) || (pict->format == GL_COMPRESSED_RGBA_S3TC_DXT5_EXT)) { offs = 8; stride = 16; } - else { offs = 0; stride = 8; } + else +#endif + { offs = 0; stride = 8; } if (stride == 16) //If DXT3... { diff --git a/polymer/eduke32/build/src/glbuild.c b/polymer/eduke32/build/src/glbuild.c index 6c8b12b3a..b1754d065 100644 --- a/polymer/eduke32/build/src/glbuild.c +++ b/polymer/eduke32/build/src/glbuild.c @@ -371,7 +371,7 @@ int32_t loadgldriver(const char *driver) { #ifdef _WIN32 driver = "opengl32.dll"; -#elif defined __APPLE__ +#elif defined EDUKE32_OSX driver = "/System/Library/Frameworks/OpenGL.framework/OpenGL"; #elif defined __OpenBSD__ driver = "libGL.so"; @@ -380,7 +380,7 @@ int32_t loadgldriver(const char *driver) #endif } -#if defined RENDERTYPESDL +#if defined RENDERTYPESDL && !defined EDUKE32_IOS if (SDL_GL_LoadLibrary(driver)) { initprintf("Failed loading \"%s\": %s\n", driver, SDL_GetError()); diff --git a/polymer/eduke32/build/src/jwzgles.c b/polymer/eduke32/build/src/jwzgles.c index 9cbdfeaf2..af63ec789 100644 --- a/polymer/eduke32/build/src/jwzgles.c +++ b/polymer/eduke32/build/src/jwzgles.c @@ -72,6 +72,14 @@ # include #endif /* HAVE_UNISTD_H */ + +#ifdef __APPLE__ +# include +# if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR +# define USE_IPHONE +# endif +#endif + #if defined(USE_IPHONE) # include # include @@ -95,16 +103,20 @@ #undef countof #define countof(x) (signed)((signed)sizeof((x))/(signed)sizeof((*x))) +#ifndef USE_IPHONE #include #define LOG_TAG "JWZGLES" #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__) #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__) +#endif #undef Assert #ifdef HAVE_COCOA extern void jwxyz_abort (const char *fmt, ...) __dead2; # define Assert(C,S) do { if (!(C)) { jwxyz_abort ("%s",S); }} while(0) +#elif defined USE_IPHONE +# define Assert(C,S) #else # define Assert(C,S) do { \ if (!(C)) { \ diff --git a/polymer/eduke32/build/src/mdsprite.c b/polymer/eduke32/build/src/mdsprite.c index 1e30f0437..a9ce7ef58 100644 --- a/polymer/eduke32/build/src/mdsprite.c +++ b/polymer/eduke32/build/src/mdsprite.c @@ -885,10 +885,13 @@ int32_t mdloadskin(md2model_t *m, int32_t number, int32_t pal, int32_t surf) bglBindTexture(GL_TEXTURE_2D, *texidx); //gluBuild2DMipmaps(GL_TEXTURE_2D,GL_RGBA,xsiz,ysiz,GL_BGRA_EXT,GL_UNSIGNED_BYTE,(char *)fptr); +#if !defined EDUKE32_GLES if (glinfo.texcompr && glusetexcompr && !(sk->flags & HICR_NOSAVE)) intexfmt = hasalpha ? GL_COMPRESSED_RGBA_ARB : GL_COMPRESSED_RGB_ARB; - else if (!hasalpha) - intexfmt = GL_RGB; + else +#endif + if (!hasalpha) + intexfmt = GL_RGB; if (glinfo.bgra) texfmt = GL_BGRA; diff --git a/polymer/eduke32/build/src/polymer.c b/polymer/eduke32/build/src/polymer.c index a0ededd8f..9d6a7c88a 100644 --- a/polymer/eduke32/build/src/polymer.c +++ b/polymer/eduke32/build/src/polymer.c @@ -1,6 +1,6 @@ // blah -#ifdef USE_OPENGL +#if defined USE_OPENGL && defined POLYMER #include diff --git a/polymer/eduke32/build/src/polymost.c b/polymer/eduke32/build/src/polymost.c index 073ca0299..3e485c06a 100644 --- a/polymer/eduke32/build/src/polymost.c +++ b/polymer/eduke32/build/src/polymost.c @@ -22,10 +22,6 @@ Ken Silverman's official web site: http://www.advsys.net/ken #include "texcache.h" #include "common.h" -#ifdef EDUKE32_GLES -#include "jwzgles.h" -#endif - #ifndef _WIN32 extern int32_t filelength(int h); // kplib.c #endif @@ -1234,9 +1230,12 @@ int32_t gloadtile_hi(int32_t dapic,int32_t dapalnum, int32_t facen, hicreplctyp if (tsiz.x>>r_downsize <= tilesiz[dapic].x || tsiz.y>>r_downsize <= tilesiz[dapic].y) hicr->flags |= (HICR_NOCOMPRESS + HICR_NOSAVE); +#if !defined EDUKE32_GLES if (glinfo.texcompr && glusetexcompr && !(hicr->flags & HICR_NOSAVE)) intexfmt = (hasalpha == 255) ? GL_COMPRESSED_RGB_ARB : GL_COMPRESSED_RGBA_ARB; - else if (hasalpha == 255) intexfmt = GL_RGB; + else +#endif + if (hasalpha == 255) intexfmt = GL_RGB; if ((doalloc&3)==1) bglGenTextures(1, &pth->glpic); //# of textures (make OpenGL allocate structure) @@ -1269,7 +1268,7 @@ int32_t gloadtile_hi(int32_t dapic,int32_t dapalnum, int32_t facen, hicreplctyp pth->picnum = dapic; pth->effects = effect; pth->flags = TO_PTH_CLAMPED(dameth) | PTH_HIGHTILE | ((facen>0) * PTH_SKYBOX) | ((hasalpha != 255) ? PTH_HASALPHA : 0) | - (hicr->flags & HICR_FORCEFILTER ? PTH_FORCEFILTER : 0); + (hicr->flags & HICR_FORCEFILTER ? PTH_FORCEFILTER : 0); pth->skyface = facen; pth->hicr = hicr; @@ -1312,6 +1311,7 @@ int32_t gloadtile_hi(int32_t dapic,int32_t dapalnum, int32_t facen, hicreplctyp return 0; } +#if !defined EDUKE32_GLES void polymost_setupdetailtexture(const int32_t texunits, const int32_t tex) { bglActiveTextureARB(texunits); @@ -1364,6 +1364,7 @@ void polymost_setupglowtexture(const int32_t texunits, const int32_t tex) bglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); bglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); } +#endif //(dpx,dpy) specifies an n-sided polygon. The polygon must be a convex clockwise loop. @@ -5178,7 +5179,7 @@ void polymost_fillpolygon(int32_t npoints) xtex.v = ((float)asm2)*(1.f/4294967296.f); ytex.u = ((float)globalx1)*(1.f/4294967296.f); ytex.v = ((float)globaly2)*(-1.f/4294967296.f); - otex.u = (fxdim*xtex.u + fydim*ytex.u)*-0.5f + fglobalposx * (1.f/4294967296.f); + otex.u = (fxdim*xtex.u + fydim*ytex.u)*-0.5f + fglobalposx * (1.f/4294967296.f); otex.v = (fxdim*xtex.v + fydim*ytex.v)*-0.5f - fglobalposy * (1.f/4294967296.f); //Convert int32_t to float (in-place) for (i=npoints-1; i>=0; i--) diff --git a/polymer/eduke32/build/src/texcache.c b/polymer/eduke32/build/src/texcache.c index 69be39054..fcfa1a61c 100644 --- a/polymer/eduke32/build/src/texcache.c +++ b/polymer/eduke32/build/src/texcache.c @@ -11,10 +11,6 @@ #include "xxhash.h" #include "kplib.h" -#ifdef EDUKE32_GLES -#include "jwzgles.h" -#endif - #define CLEAR_GL_ERRORS() while(bglGetError() != GL_NO_ERROR) { } #define TEXCACHE_FREEBUFS() { Bfree(pic), Bfree(packbuf), Bfree(midbuf); } diff --git a/polymer/eduke32/platform/Apple/EDuke32.xcodeproj/project.pbxproj b/polymer/eduke32/platform/Apple/EDuke32.xcodeproj/project.pbxproj index cd16f4a4f..9459cce1f 100644 --- a/polymer/eduke32/platform/Apple/EDuke32.xcodeproj/project.pbxproj +++ b/polymer/eduke32/platform/Apple/EDuke32.xcodeproj/project.pbxproj @@ -426,6 +426,9 @@ 2038AEA01A8F12B60093B7B2 /* animsounds.c in Sources */ = {isa = PBXBuildFile; fileRef = 2038AE9E1A8F12B60093B7B2 /* animsounds.c */; }; 2038AEA11A8F12B60093B7B2 /* animsounds.c in Sources */ = {isa = PBXBuildFile; fileRef = 2038AE9E1A8F12B60093B7B2 /* animsounds.c */; }; 2038AEA31A8F137E0093B7B2 /* DUKE.RTS in Resources */ = {isa = PBXBuildFile; fileRef = 2038AEA21A8F137E0093B7B2 /* DUKE.RTS */; }; + 206B3A081B074F3800E5DBD0 /* jwzglesI.h in Headers */ = {isa = PBXBuildFile; fileRef = 206B3A061B074F3000E5DBD0 /* jwzglesI.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 206B3A0A1B074F4300E5DBD0 /* jwzgles.h in Headers */ = {isa = PBXBuildFile; fileRef = 206B3A051B074F3000E5DBD0 /* jwzgles.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 206B3A0C1B074F6400E5DBD0 /* jwzgles.c in Sources */ = {isa = PBXBuildFile; fileRef = 206B3A0B1B074F6400E5DBD0 /* jwzgles.c */; }; 2085BEBA1A8F23B9002BF4CE /* libSystem.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 2085BEB91A8F23B9002BF4CE /* libSystem.dylib */; }; 20C2146A1B02C19800917E58 /* game.png in Resources */ = {isa = PBXBuildFile; fileRef = 20C214691B02C19800917E58 /* game.png */; }; 20C2146F1B02C1D800917E58 /* build.png in Resources */ = {isa = PBXBuildFile; fileRef = 20C2146E1B02C1D800917E58 /* build.png */; }; @@ -793,6 +796,9 @@ 2038AE9E1A8F12B60093B7B2 /* animsounds.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = animsounds.c; path = ../../source/animsounds.c; sourceTree = SOURCE_ROOT; }; 2038AE9F1A8F12B60093B7B2 /* animsounds.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = animsounds.h; path = ../../source/animsounds.h; sourceTree = SOURCE_ROOT; }; 2038AEA21A8F137E0093B7B2 /* DUKE.RTS */ = {isa = PBXFileReference; lastKnownFileType = file; name = DUKE.RTS; path = ../../../../../DUKE.RTS; sourceTree = SOURCE_ROOT; }; + 206B3A051B074F3000E5DBD0 /* jwzgles.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = jwzgles.h; sourceTree = ""; }; + 206B3A061B074F3000E5DBD0 /* jwzglesI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = jwzglesI.h; sourceTree = ""; }; + 206B3A0B1B074F6400E5DBD0 /* jwzgles.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = jwzgles.c; sourceTree = ""; }; 2085BEB91A8F23B9002BF4CE /* libSystem.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libSystem.dylib; path = usr/lib/libSystem.dylib; sourceTree = SDKROOT; }; 20C214691B02C19800917E58 /* game.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = game.png; path = bundles/EDuke32.app/Contents/Resources/game.png; sourceTree = SOURCE_ROOT; }; 20C2146E1B02C1D800917E58 /* build.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = build.png; path = bundles/Mapster32.app/Contents/Resources/build.png; sourceTree = SOURCE_ROOT; }; @@ -1220,6 +1226,8 @@ 0008E8AC19F1AC530091588D /* glbuild.h */, 0008E8AD19F1AC530091588D /* glext.h */, 0008E8AF19F1AC530091588D /* hightile.h */, + 206B3A051B074F3000E5DBD0 /* jwzgles.h */, + 206B3A061B074F3000E5DBD0 /* jwzglesI.h */, 0008E8B019F1AC530091588D /* kplib.h */, 2038AE951A8F122D0093B7B2 /* libdivide.h */, 0008E8B219F1AC530091588D /* lz4.h */, @@ -1277,6 +1285,7 @@ 0008E8E819F1AC540091588D /* engine_priv.h */, 0008E8E919F1AC540091588D /* glbuild.c */, 0008E8EB19F1AC540091588D /* hightile.c */, + 206B3A0B1B074F6400E5DBD0 /* jwzgles.c */, 0008E8EC19F1AC540091588D /* kplib.c */, 0008E8EE19F1AC540091588D /* lz4.c */, 2038AE9B1A8F126C0093B7B2 /* md4.c */, @@ -1527,6 +1536,7 @@ 001382C019F361B60007DA6C /* SDLMain.h in Headers */, 001382C119F361B60007DA6C /* pragmas.h in Headers */, 001382C219F361B60007DA6C /* sdlappicon.h in Headers */, + 206B3A0A1B074F4300E5DBD0 /* jwzgles.h in Headers */, 001382C319F361B60007DA6C /* tracker.hpp in Headers */, 001382C419F361B60007DA6C /* hightile.h in Headers */, 001382C519F361B60007DA6C /* glbuild.h in Headers */, @@ -1537,6 +1547,7 @@ 001382CA19F361B60007DA6C /* dxtfilter.h in Headers */, 001382CB19F361B60007DA6C /* kplib.h in Headers */, 001382CC19F361B60007DA6C /* lz4.h in Headers */, + 206B3A081B074F3800E5DBD0 /* jwzglesI.h in Headers */, 001382CE19F361B60007DA6C /* dxdidf.h in Headers */, 001382CF19F361B60007DA6C /* baselayer.h in Headers */, 001382D019F361B60007DA6C /* scriptfile.h in Headers */, @@ -2059,6 +2070,7 @@ 0013828E19F361B60007DA6C /* engine.c in Sources */, 0013828F19F361B60007DA6C /* voxmodel.c in Sources */, 0013829119F361B60007DA6C /* pragmas.c in Sources */, + 206B3A0C1B074F6400E5DBD0 /* jwzgles.c in Sources */, 0013829219F361B60007DA6C /* common.c in Sources */, 0013829319F361B60007DA6C /* mutex.c in Sources */, 0013829519F361B60007DA6C /* crc32.c in Sources */, @@ -3349,6 +3361,8 @@ "-DSDL_TARGET=2", "-DRENDERTYPESDL=1", "-DMIXERTYPESDL=1", + "-DUSE_OPENGL", + "-DHAVE_JWZGLES", "-DHAVE_SDL", "-DUSING_LTO", "-DNOASM", @@ -3431,6 +3445,8 @@ "-DSDL_TARGET=2", "-DRENDERTYPESDL=1", "-DMIXERTYPESDL=1", + "-DUSE_OPENGL", + "-DHAVE_JWZGLES", "-DHAVE_SDL", "-DUSING_LTO", "-DNOASM", @@ -3514,6 +3530,8 @@ "-DSDL_TARGET=2", "-DRENDERTYPESDL=1", "-DMIXERTYPESDL=1", + "-DUSE_OPENGL", + "-DHAVE_JWZGLES", "-DHAVE_SDL", "-DUSING_LTO", "-DNOASM", @@ -3594,6 +3612,8 @@ "-DSDL_TARGET=2", "-DRENDERTYPESDL=1", "-DMIXERTYPESDL=1", + "-DUSE_OPENGL", + "-DHAVE_JWZGLES", "-DHAVE_SDL", "-DUSING_LTO", "-DNOASM", @@ -3675,6 +3695,8 @@ "-DSDL_TARGET=2", "-DRENDERTYPESDL=1", "-DMIXERTYPESDL=1", + "-DUSE_OPENGL", + "-DHAVE_JWZGLES", "-DHAVE_SDL", "-DUSING_LTO", "-DNOASM", @@ -3752,6 +3774,8 @@ "-DSDL_TARGET=2", "-DRENDERTYPESDL=1", "-DMIXERTYPESDL=1", + "-DUSE_OPENGL", + "-DHAVE_JWZGLES", "-DHAVE_SDL", "-DUSING_LTO", "-DNOASM", @@ -3833,6 +3857,8 @@ "-DSDL_TARGET=2", "-DRENDERTYPESDL=1", "-DMIXERTYPESDL=1", + "-DUSE_OPENGL", + "-DHAVE_JWZGLES", "-DHAVE_SDL", "-DUSING_LTO", "-DNOASM", @@ -3910,6 +3936,8 @@ "-DSDL_TARGET=2", "-DRENDERTYPESDL=1", "-DMIXERTYPESDL=1", + "-DUSE_OPENGL", + "-DHAVE_JWZGLES", "-DHAVE_SDL", "-DUSING_LTO", "-DNOASM",