فهرست منبع

PhysFS archive functionality on iOS

Ivan Safrin 10 سال پیش
والد
کامیت
35580efa75

BIN
assets/default/default.pak


+ 4 - 0
assets/default/default/DefaultShader.frag

@@ -1,3 +1,7 @@
+#ifdef GL_ES
+	precision mediump float;
+#endif
+
 varying vec2 texCoordVar;
 varying vec3 varNormal;
 varying vec4 varPosition;

+ 1 - 1
assets/default/default/DefaultShader.vert

@@ -1,4 +1,4 @@
-#ifdef GLES2
+#ifdef GL_ES
 	precision mediump float;
 #endif
 

+ 4 - 0
assets/default/default/DefaultShaderShadows.frag

@@ -1,3 +1,7 @@
+#ifdef GL_ES
+	precision mediump float;
+#endif
+
 varying vec2 texCoordVar;
 varying vec3 varNormal;
 varying vec4 varPosition;

+ 1 - 1
assets/default/default/DefaultShaderShadows.vert

@@ -1,4 +1,4 @@
-#ifdef GLES2
+#ifdef GL_ES
 	precision mediump float;
 #endif
 

+ 4 - 0
assets/default/default/DefaultUntextured.frag

@@ -1,3 +1,7 @@
+#ifdef GL_ES
+	precision mediump float;
+#endif
+
 varying vec2 texCoordVar;
 varying vec3 varNormal;
 varying vec4 varPosition;

+ 4 - 0
assets/default/default/Invert.frag

@@ -1,3 +1,7 @@
+#ifdef GL_ES
+	precision mediump float;
+#endif
+
 uniform sampler2D screenColorBuffer;
 varying vec2 texCoordVar;
 void main()

+ 1 - 1
assets/default/default/LightCube.vert

@@ -1,4 +1,4 @@
-#ifdef GLES2
+#ifdef GL_ES
 	precision mediump float;
 #endif
 

+ 1 - 1
assets/default/default/ScreenShader.vert

@@ -1,4 +1,4 @@
-#ifdef GLES2
+#ifdef GL_ES
 	precision mediump float;
 #endif
 

+ 1 - 1
assets/default/default/Unlit.frag

@@ -1,4 +1,4 @@
-#ifdef GLES2
+#ifdef GL_ES
 	precision mediump float;
 #endif
 

+ 1 - 1
assets/default/default/Unlit.vert

@@ -1,4 +1,4 @@
-#ifdef GLES2
+#ifdef GL_ES
 	precision mediump float;
 #endif
 

+ 1 - 1
assets/default/default/UnlitPoint.vert

@@ -1,4 +1,4 @@
-#ifdef GLES2
+#ifdef GL_ES
 	precision mediump float;
 #endif
 

+ 1 - 1
assets/default/default/UnlitUntextured.frag

@@ -1,4 +1,4 @@
-#ifdef GLES2
+#ifdef GL_ES
 	precision mediump float;
 #endif
 

+ 1 - 1
assets/default/default/UnlitUntextured.vert

@@ -1,4 +1,4 @@
-#ifdef GLES2
+#ifdef GL_ES
 	precision mediump float;
 #endif
 

+ 1 - 1
assets/default/default/UnlitUntexturedVertexColor.frag

@@ -1,4 +1,4 @@
-#ifdef GLES2
+#ifdef GL_ES
 	precision mediump float;
 #endif
 

+ 1 - 1
assets/default/default/UnlitUntexturedVertexColor.vert

@@ -1,4 +1,4 @@
-#ifdef GLES2
+#ifdef GL_ES
 	precision mediump float;
 #endif
 

+ 1 - 1
assets/default/default/UnlitWireframe.frag

@@ -1,4 +1,4 @@
-#ifdef GLES2
+#ifdef GL_ES
 	precision mediump float;
 #endif
 

+ 6 - 0
build/ios/PolycodeCore/PolycodeCore.xcodeproj/project.pbxproj

@@ -84,6 +84,7 @@
 		8A0F81921BF541F900E24F9B /* tinyxml.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8A0F81441BF541F900E24F9B /* tinyxml.cpp */; };
 		8A0F81931BF541F900E24F9B /* tinyxmlerror.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8A0F81451BF541F900E24F9B /* tinyxmlerror.cpp */; };
 		8A0F81941BF541F900E24F9B /* tinyxmlparser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8A0F81461BF541F900E24F9B /* tinyxmlparser.cpp */; };
+		8A35E1A11C87B25900BF9EEA /* PolyPhysFSFileProvider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8A35E1A01C87B25900BF9EEA /* PolyPhysFSFileProvider.cpp */; };
 /* End PBXBuildFile section */
 
 /* Begin PBXCopyFilesBuildPhase section */
@@ -251,6 +252,8 @@
 		8A0F81441BF541F900E24F9B /* tinyxml.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = tinyxml.cpp; path = ../../../src/core/tinyxml.cpp; sourceTree = "<group>"; };
 		8A0F81451BF541F900E24F9B /* tinyxmlerror.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = tinyxmlerror.cpp; path = ../../../src/core/tinyxmlerror.cpp; sourceTree = "<group>"; };
 		8A0F81461BF541F900E24F9B /* tinyxmlparser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = tinyxmlparser.cpp; path = ../../../src/core/tinyxmlparser.cpp; sourceTree = "<group>"; };
+		8A35E19F1C87B20400BF9EEA /* PolyPhysFSFileProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PolyPhysFSFileProvider.h; path = ../../../include/polycode/core/PolyPhysFSFileProvider.h; sourceTree = "<group>"; };
+		8A35E1A01C87B25900BF9EEA /* PolyPhysFSFileProvider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PolyPhysFSFileProvider.cpp; path = ../../../src/core/PolyPhysFSFileProvider.cpp; sourceTree = "<group>"; };
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
@@ -309,6 +312,7 @@
 				8A0F80C41BF5417E00E24F9B /* PolyImage.h */,
 				8A0F80C51BF5417E00E24F9B /* PolyInputEvent.h */,
 				8A0F80C61BF5417E00E24F9B /* PolyInputKeys.h */,
+				8A35E19F1C87B20400BF9EEA /* PolyPhysFSFileProvider.h */,
 				8A0F80C71BF5417E00E24F9B /* PolyIOSCore.h */,
 				8A0F80C81BF5417E00E24F9B /* PolyLabel.h */,
 				8A0F80C91BF5417E00E24F9B /* PolyLogger.h */,
@@ -378,6 +382,7 @@
 				8A0F81031BF541F800E24F9B /* PolyCoreInput.cpp */,
 				8A0F81041BF541F800E24F9B /* PolyCoreServices.cpp */,
 				8A0F81051BF541F800E24F9B /* PolyCubemap.cpp */,
+				8A35E1A01C87B25900BF9EEA /* PolyPhysFSFileProvider.cpp */,
 				8A0F81061BF541F800E24F9B /* PolyData.cpp */,
 				8A0F81071BF541F800E24F9B /* PolyEntity.cpp */,
 				8A0F81081BF541F800E24F9B /* PolyEvent.cpp */,
@@ -522,6 +527,7 @@
 				8A0F815F1BF541F900E24F9B /* PolyIOSCore.mm in Sources */,
 				8A0F81911BF541F900E24F9B /* tinystr.cpp in Sources */,
 				8A0F81701BF541F900E24F9B /* PolyRenderDataArray.cpp in Sources */,
+				8A35E1A11C87B25900BF9EEA /* PolyPhysFSFileProvider.cpp in Sources */,
 				8A0F814C1BF541F900E24F9B /* PolyClient.cpp in Sources */,
 				8A0F814E1BF541F900E24F9B /* PolyConfig.cpp in Sources */,
 				8A0F815B1BF541F900E24F9B /* PolyFontManager.cpp in Sources */,

+ 8 - 0
build/ios/TemplateApp/TemplateApp.xcodeproj/project.pbxproj

@@ -16,6 +16,8 @@
 		8A0F81991BF56A2D00E24F9B /* PolycodeView.m in Sources */ = {isa = PBXBuildFile; fileRef = 8A0F81981BF56A2D00E24F9B /* PolycodeView.m */; };
 		8A35E14B1C877A8B00BF9EEA /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 8A35E14A1C877A8B00BF9EEA /* main.m */; };
 		8A35E14F1C877DDB00BF9EEA /* libFreetype2.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8A35E14E1C877DDB00BF9EEA /* libFreetype2.a */; };
+		8A35E1C61C87B3BC00BF9EEA /* libphysfs.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8A35E1C51C87B3BC00BF9EEA /* libphysfs.a */; };
+		8A35E1DC1C87B50600BF9EEA /* default.pak in Resources */ = {isa = PBXBuildFile; fileRef = 8A35E1DB1C87B50600BF9EEA /* default.pak */; };
 		8AD300AB1BF68290004D243B /* libPolycodeCore.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8AD300AA1BF68290004D243B /* libPolycodeCore.a */; };
 /* End PBXBuildFile section */
 
@@ -35,6 +37,8 @@
 		8A35E14A1C877A8B00BF9EEA /* main.m */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp.preprocessed; fileEncoding = 4; path = main.m; sourceTree = "<group>"; };
 		8A35E14E1C877DDB00BF9EEA /* libFreetype2.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libFreetype2.a; path = ../../../../lib/ios/iphonesimulator/libFreetype2.a; sourceTree = "<group>"; };
 		8A35E19E1C87A54A00BF9EEA /* PolycodeView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PolycodeView.h; path = ../../../../include/polycode/view/ios/PolycodeView.h; sourceTree = "<group>"; };
+		8A35E1C51C87B3BC00BF9EEA /* libphysfs.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libphysfs.a; path = ../../../../lib/ios/iphonesimulator/libphysfs.a; sourceTree = "<group>"; };
+		8A35E1DB1C87B50600BF9EEA /* default.pak */ = {isa = PBXFileReference; lastKnownFileType = file; name = default.pak; path = ../../../../assets/default/default.pak; sourceTree = "<group>"; };
 		8AD300AA1BF68290004D243B /* libPolycodeCore.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libPolycodeCore.a; path = ../../../../lib/ios/iphonesimulator/libPolycodeCore.a; sourceTree = "<group>"; };
 /* End PBXFileReference section */
 
@@ -44,6 +48,7 @@
 			buildActionMask = 2147483647;
 			files = (
 				8A35E14F1C877DDB00BF9EEA /* libFreetype2.a in Frameworks */,
+				8A35E1C61C87B3BC00BF9EEA /* libphysfs.a in Frameworks */,
 				8AD300AB1BF68290004D243B /* libPolycodeCore.a in Frameworks */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
@@ -71,6 +76,7 @@
 			isa = PBXGroup;
 			children = (
 				8A35E14E1C877DDB00BF9EEA /* libFreetype2.a */,
+				8A35E1C51C87B3BC00BF9EEA /* libphysfs.a */,
 				8AD300AA1BF68290004D243B /* libPolycodeCore.a */,
 				8A0F80621BF536C800E24F9B /* AppDelegate.h */,
 				8A0F80631BF536C800E24F9B /* AppDelegate.m */,
@@ -78,6 +84,7 @@
 				8A0F80661BF536C800E24F9B /* ViewController.m */,
 				8A0F80791BF53DD200E24F9B /* PolycodeTemplateApp.h */,
 				8A0F807A1BF53DD200E24F9B /* PolycodeTemplateApp.mm */,
+				8A35E1DB1C87B50600BF9EEA /* default.pak */,
 				8A0F80681BF536C800E24F9B /* Main.storyboard */,
 				8A35E19E1C87A54A00BF9EEA /* PolycodeView.h */,
 				8A0F81981BF56A2D00E24F9B /* PolycodeView.m */,
@@ -148,6 +155,7 @@
 			files = (
 				8A0F806F1BF536C800E24F9B /* LaunchScreen.storyboard in Resources */,
 				8A0F806C1BF536C800E24F9B /* Assets.xcassets in Resources */,
+				8A35E1DC1C87B50600BF9EEA /* default.pak in Resources */,
 				8A0F806A1BF536C800E24F9B /* Main.storyboard in Resources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;

+ 4 - 2
build/ios/TemplateApp/TemplateApp/PolycodeTemplateApp.mm

@@ -6,9 +6,11 @@
 
 
 PolycodeTemplateApp::PolycodeTemplateApp(PolycodeView *view) {
-    core = new POLYCODE_CORE(view, 1280/2,720/2,false,false, 0,0,60, 0, true);
+    core = new POLYCODE_CORE(view, 64,64,false,false, 0,0,60, 0, true);
     
-    core->addFileSource("archive", "default.pak");
+    NSString *str = [[NSBundle mainBundle] pathForResource: @"default" ofType: @"pak"];
+    
+    core->addFileSource("archive", [str UTF8String]);
     ResourcePool *globalPool = Services()->getResourceManager()->getGlobalPool();
     globalPool->loadResourcesFromFolder("default", true);
     

+ 1 - 1
lib

@@ -1 +1 @@
-Subproject commit f2dfaa4c3f353e211028f0440a8bb48ce0b3b582
+Subproject commit 9d74dbd90f903af05cdd44547e1afd061dc7d2ba

+ 12 - 2
src/core/PolyIOSCore.mm

@@ -23,6 +23,9 @@ THE SOFTWARE.
 
 #include "polycode/core/PolyIOSCore.h"
 
+#include "polycode/core/PolyBasicFileProvider.h"
+#include "polycode/core/PolyPhysFSFileProvider.h"
+
 using namespace Polycode;
 
 void PosixMutex::lock() {
@@ -36,6 +39,10 @@ void PosixMutex::unlock() {
 IOSCore::IOSCore(PolycodeView *view, int xRes, int yRes, bool fullScreen, bool vSync, int aaLevel, int anisotropyLevel, int frameRate, int monitorIndex, bool retinaSupport)
 	: Core(xRes, yRes, fullScreen, vSync, aaLevel, anisotropyLevel, frameRate, monitorIndex) {
         
+        
+        fileProviders.push_back(new BasicFileProvider());
+        fileProviders.push_back(new PhysFSFileProvider());
+        
         glView = view;
         
         renderer = new Renderer();
@@ -44,7 +51,7 @@ IOSCore::IOSCore(PolycodeView *view, int xRes, int yRes, bool fullScreen, bool v
         renderer->setGraphicsInterface(this, interface);
         services->setRenderer(renderer);
         
-        setVideoMode(xRes, yRes, fullScreen, vSync, aaLevel, anisotropyLevel, retinaSupport);
+        setVideoMode([glView frame].size.width , [glView frame].size.height, fullScreen, vSync, aaLevel, anisotropyLevel, retinaSupport);
 
 }
 
@@ -54,7 +61,7 @@ IOSCore::~IOSCore() {
 
 void IOSCore::Render() {
     renderer->beginFrame();
-    services->Render(Polycode::Rectangle(0, 0, 800, 600));
+    services->Render(Polycode::Rectangle(0, 0, getBackingXRes(), getBackingYRes()));
     renderer->endFrame();
     [glView display];
 }
@@ -143,6 +150,9 @@ String IOSCore::saveFilePicker(std::vector<CoreFileExtension> extensions) {
 
 void IOSCore::handleVideoModeChange(VideoModeChangeInfo *modeInfo) {
     
+    xRes = modeInfo->xRes;
+    yRes = modeInfo->yRes;
+    
     EAGLContext *context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
     
     if (!context) {