From: havoc Date: Tue, 8 Feb 2011 18:23:47 +0000 (+0000) Subject: DPiOS almost works now... X-Git-Tag: xonotic-v0.5.0~438^2~11 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=7de8b7bc89c7c708cd4a527dcafa391b96fdaf17;p=xonotic%2Fdarkplaces.git DPiOS almost works now... Side effects: had to change the internalformat hints on the GL texture formats, because values 3 and 4 are not supported on GLES, using GL_RGB and GL_RGBA instead (same meaning). git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10830 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/DPiOS.xcodeproj/project.pbxproj b/DPiOS.xcodeproj/project.pbxproj index a661e1ed..e73b85ca 100755 --- a/DPiOS.xcodeproj/project.pbxproj +++ b/DPiOS.xcodeproj/project.pbxproj @@ -107,6 +107,7 @@ 7463B7EA12F9D11E00983F6A /* mod_skeletal_animatevertices_sse.c in Sources */ = {isa = PBXBuildFile; fileRef = 7463B7E812F9D11E00983F6A /* mod_skeletal_animatevertices_sse.c */; }; 7463B7EF12F9D17D00983F6A /* builddate.c in Sources */ = {isa = PBXBuildFile; fileRef = 7463B7ED12F9D17D00983F6A /* builddate.c */; }; 7463B7F012F9D17D00983F6A /* clvm_cmds.c in Sources */ = {isa = PBXBuildFile; fileRef = 7463B7EE12F9D17D00983F6A /* clvm_cmds.c */; }; + 7487D481130102AA00AEE909 /* thread_sdl.c in Sources */ = {isa = PBXBuildFile; fileRef = 7487D47F130102AA00AEE909 /* thread_sdl.c */; }; FD779ED20E26B9B000F39101 /* libSDLSimulator.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FD779ED00E26B9B000F39101 /* libSDLSimulator.a */; }; FD779ED30E26B9B000F39101 /* libSDLiPhoneOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FD779ED10E26B9B000F39101 /* libSDLiPhoneOS.a */; }; FD779EDE0E26BA1200F39101 /* CoreAudio.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FD779EDD0E26BA1200F39101 /* CoreAudio.framework */; }; @@ -309,6 +310,8 @@ 7463B7E912F9D11E00983F6A /* mod_skeletal_animatevertices_sse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mod_skeletal_animatevertices_sse.h; sourceTree = ""; }; 7463B7ED12F9D17D00983F6A /* builddate.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = builddate.c; sourceTree = ""; }; 7463B7EE12F9D17D00983F6A /* clvm_cmds.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = clvm_cmds.c; sourceTree = ""; }; + 7487D47F130102AA00AEE909 /* thread_sdl.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = thread_sdl.c; sourceTree = ""; }; + 7487D480130102AA00AEE909 /* thread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = thread.h; sourceTree = ""; }; 8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; FD779ED00E26B9B000F39101 /* libSDLSimulator.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libSDLSimulator.a; path = lib/libSDLSimulator.a; sourceTree = ""; }; FD779ED10E26B9B000F39101 /* libSDLiPhoneOS.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libSDLiPhoneOS.a; path = lib/libSDLiPhoneOS.a; sourceTree = ""; }; @@ -360,6 +363,8 @@ 29B97315FDCFA39411CA2CEA /* Sources */ = { isa = PBXGroup; children = ( + 7487D47F130102AA00AEE909 /* thread_sdl.c */, + 7487D480130102AA00AEE909 /* thread.h */, 7463B7ED12F9D17D00983F6A /* builddate.c */, 7463B7EE12F9D17D00983F6A /* clvm_cmds.c */, 7463B7E812F9D11E00983F6A /* mod_skeletal_animatevertices_sse.c */, @@ -739,6 +744,7 @@ 7463B7EA12F9D11E00983F6A /* mod_skeletal_animatevertices_sse.c in Sources */, 7463B7EF12F9D17D00983F6A /* builddate.c in Sources */, 7463B7F012F9D17D00983F6A /* clvm_cmds.c in Sources */, + 7487D481130102AA00AEE909 /* thread_sdl.c in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/fs.c b/fs.c index a0dd2c8e..871a632a 100644 --- a/fs.c +++ b/fs.c @@ -22,6 +22,14 @@ Boston, MA 02111-1307, USA */ +#ifdef __APPLE__ +// include SDL for IPHONEOS code +# include +# if TARGET_OS_IPHONE +# include +# endif +#endif + #include #include @@ -1683,7 +1691,9 @@ void FS_Init (void) size_t homedirlen; #endif #endif +#ifndef __IPHONEOS__ char *homedir; +#endif #ifdef WIN32 const char* dllnames [] = @@ -1695,6 +1705,13 @@ void FS_Init (void) // don't care for the result; if it fails, %USERPROFILE% will be used instead #endif + *fs_basedir = 0; + *fs_userdir = 0; + *fs_gamedir = 0; + +#ifdef __IPHONEOS__ + // FIXME: set fs_userdir to the documents folder +#else // Add the personal game directory if((i = COM_CheckParm("-userdir")) && i < com_argc - 1) { @@ -1781,6 +1798,7 @@ void FS_Init (void) fs_basedir[split - com_argv[0]] = 0; } #endif +#endif #endif // -basedir diff --git a/gl_backend.c b/gl_backend.c index d4d83266..e4a157e4 100644 --- a/gl_backend.c +++ b/gl_backend.c @@ -1560,7 +1560,8 @@ static void GL_Backend_ResetState(void) qglBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); qglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); qglBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0); - qglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, gl_state.defaultframebufferobject); + if (vid.support.ext_framebuffer_object) + qglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, gl_state.defaultframebufferobject); qglEnableVertexAttribArray(GLES2ATTRIB_POSITION); qglVertexAttribPointer(GLES2ATTRIB_POSITION, 3, GL_FLOAT, false, sizeof(float[3]), NULL);CHECKGLERROR qglDisableVertexAttribArray(GLES2ATTRIB_COLOR); @@ -2980,6 +2981,8 @@ void R_Mesh_Draw(int firstvertex, int numvertices, int firsttriangle, int numtri // GLES does not have glDrawRangeElements, and generally // underperforms with index buffers, so this code path is // relatively straightforward... + //if (qglCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) != GL_FRAMEBUFFER_COMPLETE_EXT) + // Con_DPrintf("fbo %i not complete (default %i)\n", gl_state.framebufferobject, gl_state.defaultframebufferobject); if (element3s) { qglDrawElements(GL_TRIANGLES, numelements, GL_UNSIGNED_SHORT, element3s); diff --git a/gl_textures.c b/gl_textures.c index 03dc5ef1..8122db46 100644 --- a/gl_textures.c +++ b/gl_textures.c @@ -75,14 +75,14 @@ typedef struct textypeinfo_s textypeinfo_t; -static textypeinfo_t textype_palette = {TEXTYPE_PALETTE , 1, 4, 4.0f, 3 , GL_BGRA , GL_UNSIGNED_BYTE }; -static textypeinfo_t textype_palette_alpha = {TEXTYPE_PALETTE , 1, 4, 4.0f, 4 , GL_BGRA , GL_UNSIGNED_BYTE }; -static textypeinfo_t textype_rgba = {TEXTYPE_RGBA , 4, 4, 4.0f, 3 , GL_RGBA , GL_UNSIGNED_BYTE }; -static textypeinfo_t textype_rgba_alpha = {TEXTYPE_RGBA , 4, 4, 4.0f, 4 , GL_RGBA , GL_UNSIGNED_BYTE }; +static textypeinfo_t textype_palette = {TEXTYPE_PALETTE , 1, 4, 4.0f, GL_RGBA , GL_BGRA , GL_UNSIGNED_BYTE }; +static textypeinfo_t textype_palette_alpha = {TEXTYPE_PALETTE , 1, 4, 4.0f, GL_RGBA , GL_BGRA , GL_UNSIGNED_BYTE }; +static textypeinfo_t textype_rgba = {TEXTYPE_RGBA , 4, 4, 4.0f, GL_RGBA , GL_RGBA , GL_UNSIGNED_BYTE }; +static textypeinfo_t textype_rgba_alpha = {TEXTYPE_RGBA , 4, 4, 4.0f, GL_RGBA , GL_RGBA , GL_UNSIGNED_BYTE }; static textypeinfo_t textype_rgba_compress = {TEXTYPE_RGBA , 4, 4, 0.5f, GL_COMPRESSED_RGB_S3TC_DXT1_EXT , GL_RGBA , GL_UNSIGNED_BYTE }; static textypeinfo_t textype_rgba_alpha_compress = {TEXTYPE_RGBA , 4, 4, 1.0f, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_RGBA , GL_UNSIGNED_BYTE }; -static textypeinfo_t textype_bgra = {TEXTYPE_BGRA , 4, 4, 4.0f, 3 , GL_BGRA , GL_UNSIGNED_BYTE }; -static textypeinfo_t textype_bgra_alpha = {TEXTYPE_BGRA , 4, 4, 4.0f, 4 , GL_BGRA , GL_UNSIGNED_BYTE }; +static textypeinfo_t textype_bgra = {TEXTYPE_BGRA , 4, 4, 4.0f, GL_RGBA , GL_BGRA , GL_UNSIGNED_BYTE }; +static textypeinfo_t textype_bgra_alpha = {TEXTYPE_BGRA , 4, 4, 4.0f, GL_RGBA , GL_BGRA , GL_UNSIGNED_BYTE }; static textypeinfo_t textype_bgra_compress = {TEXTYPE_BGRA , 4, 4, 0.5f, GL_COMPRESSED_RGB_S3TC_DXT1_EXT , GL_BGRA , GL_UNSIGNED_BYTE }; static textypeinfo_t textype_bgra_alpha_compress = {TEXTYPE_BGRA , 4, 4, 1.0f, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_BGRA , GL_UNSIGNED_BYTE }; static textypeinfo_t textype_shadowmap16 = {TEXTYPE_SHADOWMAP , 2, 2, 2.0f, GL_DEPTH_COMPONENT16_ARB , GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT}; @@ -92,7 +92,7 @@ static textypeinfo_t textype_dxt1 = {TEXTYPE_DXT1 , 4, 0 static textypeinfo_t textype_dxt1a = {TEXTYPE_DXT1A , 4, 0, 0.5f, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, 0 , 0 }; static textypeinfo_t textype_dxt3 = {TEXTYPE_DXT3 , 4, 0, 1.0f, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, 0 , 0 }; static textypeinfo_t textype_dxt5 = {TEXTYPE_DXT5 , 4, 0, 1.0f, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, 0 , 0 }; -static textypeinfo_t textype_colorbuffer = {TEXTYPE_COLORBUFFER, 4, 4, 4.0f, 4 , GL_BGRA , GL_UNSIGNED_BYTE }; +static textypeinfo_t textype_colorbuffer = {TEXTYPE_COLORBUFFER, 4, 4, 4.0f, GL_RGBA , GL_BGRA , GL_UNSIGNED_BYTE }; typedef enum gltexturetype_e diff --git a/vid_sdl.c b/vid_sdl.c index 0a99097e..4cd97d69 100644 --- a/vid_sdl.c +++ b/vid_sdl.c @@ -987,7 +987,7 @@ void GLES_Init(void) qglGetActiveUniform = wrapglGetActiveUniform; qglGetAttachedShaders = wrapglGetAttachedShaders; qglGetBooleanv = wrapglGetBooleanv; - qglGetCompressedTexImageARB = wrapglGetCompressedTexImage; +// qglGetCompressedTexImageARB = wrapglGetCompressedTexImage; qglGetDoublev = wrapglGetDoublev; qglGetFloatv = wrapglGetFloatv; qglGetFramebufferAttachmentParameterivEXT = wrapglGetFramebufferAttachmentParameteriv; @@ -1023,7 +1023,7 @@ void GLES_Init(void) qglPointSize = wrapglPointSize; qglPolygonMode = wrapglPolygonMode; qglPolygonOffset = wrapglPolygonOffset; - qglPolygonStipple = wrapglPolygonStipple; +// qglPolygonStipple = wrapglPolygonStipple; qglReadBuffer = wrapglReadBuffer; qglReadPixels = wrapglReadPixels; qglRenderbufferStorageEXT = wrapglRenderbufferStorage; @@ -1153,7 +1153,7 @@ void GLES_Init(void) vid.support.ext_blend_minmax = false; vid.support.ext_blend_subtract = true; vid.support.ext_draw_range_elements = true; - vid.support.ext_framebuffer_object = true; + vid.support.ext_framebuffer_object = false;//true; vid.support.ext_stencil_two_side = false; vid.support.ext_texture_3d = false;//SDL_GL_ExtensionSupported("GL_OES_texture_3D"); // iPhoneOS does not support 3D textures, odd... vid.support.ext_texture_compression_s3tc = false; @@ -1620,7 +1620,14 @@ qboolean VID_InitModeGL(viddef_mode_t *mode) else SDL_GL_SetAttribute (SDL_GL_SWAP_CONTROL, 0); #else - // TODO: SDL_GL_CONTEXT_MAJOR_VERSION, SDL_GL_CONTEXT_MINOR_VERSION +#ifdef __IPHONEOS__ + SDL_GL_SetAttribute (SDL_GL_CONTEXT_MAJOR_VERSION, 2); + SDL_GL_SetAttribute (SDL_GL_CONTEXT_MINOR_VERSION, 0); + SDL_GL_SetAttribute (SDL_GL_RETAINED_BACKING, 1); + // FIXME: get proper resolution from OS somehow (iPad for instance...) + mode->width = 320; + mode->height = 480; +#endif #endif video_bpp = mode->bitsperpixel; @@ -1636,6 +1643,8 @@ qboolean VID_InitModeGL(viddef_mode_t *mode) return false; } + mode->width = screen->w; + mode->height = screen->h; vid_softsurface = NULL; vid.softpixels = NULL; diff --git a/vid_shared.c b/vid_shared.c index 5b62b9b1..0db91b50 100644 --- a/vid_shared.c +++ b/vid_shared.c @@ -400,7 +400,6 @@ void (GLAPIENTRY *qglGetQueryObjectuivARB)(GLuint qid, GLenum pname, GLuint *par #define sscanf sscanf_s #endif -#ifndef __IPHONEOS__ qboolean GL_CheckExtension(const char *minglver_or_ext, const dllfunction_t *funcs, const char *disableparm, int silent) { int failed = false; @@ -970,7 +969,6 @@ void VID_CheckExtensions(void) Cvar_SetQuick(&gl_info_platform, gl_platform ? gl_platform : ""); Cvar_SetQuick(&gl_info_driver, gl_driver); } -#endif // __IPHONEOS__ void Force_CenterView_f (void) {