Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Update github copy of simple PDK example to 1.2.0

  • Loading branch information...
commit 559b2bbdf888713c1dce61f74b0eb6fe7c8b7732 1 parent 076f63e
Ben Combee authored July 26, 2010
2  simple/mac/buildit_for_device.sh
@@ -23,7 +23,7 @@ export SRC="simple.cpp"
23 23
 ### List the libraries needed.                                      ###
24 24
 ### LIBS="-l<libname>"                                              ###
25 25
 #######################################################################
26  
-export LIBS="-lSDL -lGLESv2"
  26
+export LIBS="-lSDL -lGLESv2 -lpdl"
27 27
 
28 28
 #######################################################################
29 29
 ### Name your output executable                                     ###
2  simple/mac/buildit_for_host.sh
@@ -17,7 +17,7 @@ LIBDIR="${PalmPDK}/host/lib"
17 17
 
18 18
 CPPFLAGS="-I${INCLUDEDIR} -I${INCLUDEDIR}/SDL -framework Cocoa -arch i386"
19 19
 LDFLAGS="-L${LIBDIR}"
20  
-LIBS="-lSDL -lSDLmain -lGLESv2"
  20
+LIBS="-lSDL -lSDLmain -lGLESv2 -lpdl"
21 21
 SRCDIR="../src"
22 22
 
23 23
 $CC $CPPFLAGS $LDFLAGS $LIBS -o ${BUILDDIR}/simple $SRCDIR/simple.cpp
10  simple/mac/packageit.sh
... ...
@@ -0,0 +1,10 @@
  1
+STAGING_DIR=STAGING/com.palmdts.app.simplepdk
  2
+
  3
+rm -rf $STAGING_DIR
  4
+rm *.ipk
  5
+mkdir -p $STAGING_DIR
  6
+./mac/buildit_for_device.sh
  7
+cp simple $STAGING_DIR
  8
+cp src/appinfo.json $STAGING_DIR
  9
+echo "filemode.755=simple" > $STAGING_DIR/package.properties
  10
+palm-package $STAGING_DIR
3  simple/mac/runit.sh
@@ -15,5 +15,6 @@ if [ "$EXEC" == "" ];then
15 15
         exit 1
16 16
 fi
17 17
 
18  
-scp -r -P 10022 $BUILDDIR/$APP root@localhost:/media/internal/$APP
  18
+novacom run "file:///usr/bin/killall -9 $APP"
  19
+novacom put file:///media/internal/$APP < $BUILDDIR/$APP
19 20
 novacom run file:///media/internal/$EXEC
8  simple/mac/simple.xcodeproj/project.pbxproj
@@ -22,7 +22,7 @@
22 22
 		29B97325FDCFA39411CA2CEA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; };
23 23
 		8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
24 24
 		C870E3F2115C3D5E00E0268B /* simple.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = simple.cpp; path = ../src/simple.cpp; sourceTree = SOURCE_ROOT; };
25  
-		C870E405115C3DBD00E0268B /* simple.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; name = simple.app; path = build/Debug/simple.app; sourceTree = "<group>"; };
  25
+		C870E405115C3DBD00E0268B /* simple.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = simple.app; sourceTree = BUILT_PRODUCTS_DIR; };
26 26
 /* End PBXFileReference section */
27 27
 
28 28
 /* Begin PBXFrameworksBuildPhase section */
@@ -196,7 +196,7 @@
196 196
 				COPY_PHASE_STRIP = NO;
197 197
 				FRAMEWORK_SEARCH_PATHS = (
198 198
 					"$(inherited)",
199  
-					/opt/PalmNativeSDK,
  199
+					/opt/PalmPDK,
200 200
 				);
201 201
 				GCC_DYNAMIC_NO_PIC = NO;
202 202
 				GCC_ENABLE_FIX_AND_CONTINUE = YES;
@@ -218,7 +218,7 @@
218 218
 				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
219 219
 				FRAMEWORK_SEARCH_PATHS = (
220 220
 					"$(inherited)",
221  
-					/opt/PalmNativeSDK,
  221
+					/opt/PalmPDK,
222 222
 				);
223 223
 				GCC_MODEL_TUNING = G5;
224 224
 				GCC_PRECOMPILE_PREFIX_HEADER = YES;
@@ -244,6 +244,7 @@
244 244
 					"-lSDL",
245 245
 					"-lSDLmain",
246 246
 					"-lGLESv2",
  247
+					"-lpdl",
247 248
 				);
248 249
 				PREBINDING = NO;
249 250
 				PRELINK_LIBS = "";
@@ -270,6 +271,7 @@
270 271
 					"-lSDL",
271 272
 					"-lSDLmain",
272 273
 					"-lGLESv2",
  274
+					"-lpdl",
273 275
 				);
274 276
 				PREBINDING = NO;
275 277
 				PRELINK_LIBS = "";
7  simple/mac/simple_Prefix.pch
... ...
@@ -0,0 +1,7 @@
  1
+//
  2
+// Prefix header for all source files of the 'simple' target in the 'simple' project
  3
+//
  4
+
  5
+#ifdef __OBJC__
  6
+    #import <Cocoa/Cocoa.h>
  7
+#endif
9  simple/src/appinfo.json
... ...
@@ -0,0 +1,9 @@
  1
+{
  2
+	"title": "SimplePDK",
  3
+	"type": "pdk",
  4
+	"main": "simple",
  5
+	"id": "com.palmdts.app.simplepdk",
  6
+	"version": "1.2.0",
  7
+	"vendor": "Palm, Inc.",
  8
+    "requiredMemory": 15
  9
+}
44  simple/src/simple.cpp
@@ -7,6 +7,7 @@
7 7
 
8 8
 #include <GLES2/gl2.h>
9 9
 #include "SDL.h"
  10
+#include "PDL.h"
10 11
 
11 12
 SDL_Surface *Surface;               // Screen surface to retrieve width/height information
12 13
 
@@ -258,7 +259,12 @@ int main(int argc, char** argv)
258 259
 {
259 260
     // Initialize the SDL library with the Video subsystem
260 261
     SDL_Init(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE);
261  
-
  262
+    atexit(SDL_Quit);
  263
+    
  264
+    // start the PDL library
  265
+    PDL_Init(0);
  266
+    atexit(PDL_Quit);
  267
+    
262 268
     // Tell it to use OpenGL version 2.0
263 269
     SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
264 270
 
@@ -276,21 +282,31 @@ int main(int argc, char** argv)
276 282
 
277 283
     // Event descriptor
278 284
     SDL_Event Event;
  285
+    bool paused = false;
279 286
 
280  
-    do {
  287
+    while (1) {
281 288
         // Render our scene
282 289
         Display();
283 290
 
284 291
         // Make it visible on the screen
285 292
         SDL_GL_SwapBuffers();
286 293
 
287  
-        // Process the events
288  
-        while (SDL_PollEvent(&Event)) {
  294
+        bool gotEvent;
  295
+        if (paused) {
  296
+            SDL_WaitEvent(&Event);
  297
+            gotEvent = true;
  298
+        }
  299
+        else {
  300
+            gotEvent = SDL_PollEvent(&Event);
  301
+        }
  302
+        
  303
+        while (gotEvent) {
289 304
             switch (Event.type) {
290 305
                 // List of keys that have been pressed
291 306
                 case SDL_KEYDOWN:
292 307
                     switch (Event.key.keysym.sym) {
293 308
                         // Escape forces us to quit the app
  309
+                        // this is also sent when the user makes a back gesture
294 310
                         case SDLK_ESCAPE:
295 311
                             Event.type = SDL_QUIT;
296 312
                             break;
@@ -300,16 +316,24 @@ int main(int argc, char** argv)
300 316
                     }
301 317
                     break;
302 318
 
  319
+                case SDL_ACTIVEEVENT:
  320
+                    if (Event.active.state == SDL_APPACTIVE) {
  321
+                        paused = !Event.active.gain;
  322
+                    }
  323
+                    break;
  324
+
  325
+                case SDL_QUIT:
  326
+                    // We exit anytime we get a request to quit the app
  327
+                    // all shutdown code is registered via atexit() so this is clean.
  328
+                    exit(0);
  329
+                    break;
  330
+
303 331
                 default:
304 332
                     break;
305 333
             }
  334
+            gotEvent = SDL_PollEvent(&Event);
306 335
         }
307  
-
308  
-    } while (Event.type != SDL_QUIT);
309  
-    // We exit anytime we get a request to quit the app
310  
-
311  
-    // Cleanup
312  
-    SDL_Quit();
  336
+    }
313 337
 
314 338
     return 0;
315 339
 }
7  simple/windows/buildit.cmd
... ...
@@ -1,14 +1,15 @@
1 1
 @echo off
2 2
 @rem Set the device you want to build for to 1
3  
-set PRE=1
4  
-set PIXI=0
  3
+@rem Use Pixi to allow running on either device
  4
+set PRE=0
  5
+set PIXI=1
5 6
 set DEBUG=0
6 7
 
7 8
 @rem List your source files here
8 9
 set SRC=simple.cpp
9 10
 
10 11
 @rem List the libraries needed
11  
-set LIBS=-lSDL -lGLESv2
  12
+set LIBS=-lSDL -lGLESv2 -lpdl
12 13
 
13 14
 @rem Name your output executable
14 15
 set OUTFILE=simple
10  simple/windows/packageit.cmd
... ...
@@ -0,0 +1,10 @@
  1
+set STAGING_DIR=STAGING\com.palm.app.simplepdk
  2
+
  3
+rmdir /s /y %STAGING_DIR%
  4
+del *.ipk
  5
+mkdir %STAGING_DIR%
  6
+call buildit.cmd
  7
+copy ..\src\appinfo.json %STAGING_DIR%
  8
+copy simple %STAGING_DIR%
  9
+echo filemode.755=simple > %STAGING_DIR%\package.properties
  10
+palm-package %STAGING_DIR%
4  simple/windows/simple.vcproj
@@ -61,7 +61,7 @@
61 61
 			/>
62 62
 			<Tool
63 63
 				Name="VCLinkerTool"
64  
-				AdditionalDependencies="SDLmain.lib SDL.lib dglesv2.lib"
  64
+				AdditionalDependencies="SDLmain.lib SDL.lib dglesv2.lib libpdl.lib ws2_32.lib"
65 65
 				LinkIncremental="2"
66 66
 				AdditionalLibraryDirectories="$(PalmPDK)\host\lib"
67 67
 				GenerateDebugInformation="true"
@@ -137,7 +137,7 @@
137 137
 			/>
138 138
 			<Tool
139 139
 				Name="VCLinkerTool"
140  
-				AdditionalDependencies="SDLmain.lib SDL.lib dglesv2.lib"
  140
+				AdditionalDependencies="SDLmain.lib SDL.lib dglesv2.lib libpdl.lib"
141 141
 				LinkIncremental="1"
142 142
 				AdditionalLibraryDirectories="$(PalmPDK)\host\lib"
143 143
 				GenerateDebugInformation="true"

0 notes on commit 559b2bb

Please sign in to comment.
Something went wrong with that request. Please try again.