Editing Game development

Warning: You are not logged in. Your IP address will be recorded in this page's edit history.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 1: Line 1:
This page contains tips on game development and SDL library usage for internet tablets.
This page contains tips on game development and SDL library usage for internet tablets.
-
==Useful Tips==
+
=Useful Tips=
-
===Hardware notes===
+
==Hardware notes==
* Internet tablets use a touchscreen, which enables new ways to implement game-features, such as on-screen buttons, in-game drawing, moving * character by tapping screen. etc.
* Internet tablets use a touchscreen, which enables new ways to implement game-features, such as on-screen buttons, in-game drawing, moving * character by tapping screen. etc.
Line 10: Line 10:
* When using screen's vertical orientation (as in tetris) think other use for esc button than exiting game. It's so close to the rocker that accidental presses will happen.
* When using screen's vertical orientation (as in tetris) think other use for esc button than exiting game. It's so close to the rocker that accidental presses will happen.
-
===SDL specific notes===
+
==SDL specific notes==
Things to remember:
Things to remember:
Line 19: Line 19:
* Mouse events. There is touchscreen, and you cannot assume that an average end user would hack the device to give USB host mode and use the USB mouse. So, use absolute coordinates as much as possible. One example where relative coordinates are used is scummvm. If you use the keypad to move the cursor, and then use the touchscreen, the actuall cursor will be at offset from original touchpadpress. Think absolutely, not relatively ;)
* Mouse events. There is touchscreen, and you cannot assume that an average end user would hack the device to give USB host mode and use the USB mouse. So, use absolute coordinates as much as possible. One example where relative coordinates are used is scummvm. If you use the keypad to move the cursor, and then use the touchscreen, the actuall cursor will be at offset from original touchpadpress. Think absolutely, not relatively ;)
-
===Adding support for the Task Navigator===
+
==Adding support for the Task Navigator==
-
====Create an entry in the task list====
+
===Create an entry in the task list===
The Maemo Task Navigator identifies non-Maemo programs (like pure SDL applications) by matching the <code>StartupWMClass</code>-variable in the <code>.desktop</code>-file and the application "window manager class" name. By default all SDL applications have the name <code>SDL_App</code>. This can be changed with the environment variable <code>SDL_VIDEO_X11_WMCLASS</code>.
The Maemo Task Navigator identifies non-Maemo programs (like pure SDL applications) by matching the <code>StartupWMClass</code>-variable in the <code>.desktop</code>-file and the application "window manager class" name. By default all SDL applications have the name <code>SDL_App</code>. This can be changed with the environment variable <code>SDL_VIDEO_X11_WMCLASS</code>.
Line 43: Line 43:
* Alternative 1: Here <code>app.bin</code> is the binary executable and <code>app</code> is a wrapper script:
* Alternative 1: Here <code>app.bin</code> is the binary executable and <code>app</code> is a wrapper script:
-
<source lang="bash">
+
<pre>
#!/bin/sh
#!/bin/sh
BASENAME=`basename $0`
BASENAME=`basename $0`
export SDL_VIDEO_X11_WMCLASS=${BASENAME}
export SDL_VIDEO_X11_WMCLASS=${BASENAME}
exec ${0}.bin "$@"  
exec ${0}.bin "$@"  
-
</source>
+
</pre>
Notice that <code>StartupWMClass == SDL_VIDEO_X11_WMCLASS</code>, and that <code>Exec</code> points to the wrapper script, not the main program.
Notice that <code>StartupWMClass == SDL_VIDEO_X11_WMCLASS</code>, and that <code>Exec</code> points to the wrapper script, not the main program.
Line 54: Line 54:
* Alternative 2: An other possibility that doesn't need a script is the following. Put the line
* Alternative 2: An other possibility that doesn't need a script is the following. Put the line
-
<source lang="c">
+
<pre>
putenv("SDL_VIDEO_X11_WMCLASS=app");
putenv("SDL_VIDEO_X11_WMCLASS=app");
-
</source>
+
</pre>
in your code. A good position is directly at the beginning of the <code>main</code> method. This way there is no need for a helper script.
in your code. A good position is directly at the beginning of the <code>main</code> method. This way there is no need for a helper script.
-
====Set the window title====
+
===Set the window title===
If you see "unknown" title in task list (OS2008 bug/feature), you can set it by using:
If you see "unknown" title in task list (OS2008 bug/feature), you can set it by using:
-
<source lang="c">
+
<pre>
#include <SDL/SDL_syswm.h>
#include <SDL/SDL_syswm.h>
#include <X11/Xutil.h>
#include <X11/Xutil.h>
Line 80: Line 80:
   if (dpy && win) XStoreName(dpy, win, "Title");
   if (dpy && win) XStoreName(dpy, win, "Title");
}
}
-
</source>
+
</pre>
-
 
+
Alternatively you can try to set title for both windows no matter if fullscreen or not. This seems to work and saves you setting the title again after fullscreen switch.
Alternatively you can try to set title for both windows no matter if fullscreen or not. This seems to work and saves you setting the title again after fullscreen switch.
-
 
+
<pre>
-
<source lang="c">
+
   Display *dpy = info.info.x11.display;
   Display *dpy = info.info.x11.display;
   Window win;
   Window win;
Line 93: Line 91:
     if (win) XStoreName(dpy, win, "Title");
     if (win) XStoreName(dpy, win, "Title");
   }
   }
-
</source>
+
</pre>
-
If <code>SDL_WM_SetCaption</code> is present in the code, add the code above after that call. Or, just remove <code>SDL_WM_SetCaption</code> as the code above will set the window title and the icon for the window is handled by hildon-desktop using the Icon field in your desktop file.
+
If SDL_WM_SetCaption is present in the code, add the code above after that call. Or, just remove SDL_WM_SetCaption as the code above will set the window title and the icon for the window is handled by hildon-desktop using the Icon field in your desktop file.
If you wish for text to appear in the task navigator on the second line corresponding to your game; make "Title" be: "'text to display on first line' - 'text to display on second line'". The " - " (with spaces) are important.
If you wish for text to appear in the task navigator on the second line corresponding to your game; make "Title" be: "'text to display on first line' - 'text to display on second line'". The " - " (with spaces) are important.
-
===Utilizing pixel doubling inside SDL===
+
==Utilizing pixel doubling inside SDL==
As there is support for pixel-doubled drawing to the screen inside the HW, there is implementations to utilize that up to X. So if you want to use it you have to do some xlib code, therefore it might be a good idea to put this small piece of code to switch pixel doubling mode to a separate file.
As there is support for pixel-doubled drawing to the screen inside the HW, there is implementations to utilize that up to X. So if you want to use it you have to do some xlib code, therefore it might be a good idea to put this small piece of code to switch pixel doubling mode to a separate file.
-
'''NOTE:''' There is no Xsp scaling on [[Nokia N900|N900]] anymore. You might want to use Hildon Animation Actor to scale the pixmap. Either with [http://git.maemo.org/git/sdlhildon/?p=sdlhildon;a=tree;f=sdlhaa SDL_haa] or [[Documentation/Maemo_5_Developer_Guide/Porting_Software/Scaling_Fixed_Size_Windows|directly]].
+
'''NOTE:''' There is no Xsp scaling on N900 anymore. You might want to use Hildon Animation Actor to scale the pixmap. Either with [http://git.maemo.org/git/sdlhildon/?p=sdlhildon;a=tree;f=sdlhaa SDL_haa] or [http://wiki.maemo.org/Documentation/Maemo_5_Developer_Guide/Porting_Software/Scaling_Fixed_Size_Windows directly].
-
 
+
====What is pixel doubling?====
====What is pixel doubling?====
Line 122: Line 119:
There exists one X extension (Xsp), which can be used for that. Sample piece of code with SDL:
There exists one X extension (Xsp), which can be used for that. Sample piece of code with SDL:
-
<source lang="c">
+
<pre>
#include <X11/Xlib.h>
#include <X11/Xlib.h>
#include <X11/extensions/Xsp.h>
#include <X11/extensions/Xsp.h>
Line 137: Line 134:
   XSPSetPixelDoubling(wminfo.info.x11.display, 0, enable);
   XSPSetPixelDoubling(wminfo.info.x11.display, 0, enable);
}
}
-
</source>
+
</pre>
Note that when you compile it you have to include X include path and link this with libXsp (-lXsp).
Note that when you compile it you have to include X include path and link this with libXsp (-lXsp).
-
==External Links==
+
=External Links=
 +
 
 +
[http://www.libsdl.org/ Simple DirectMedia Layer Homepage]
-
* [http://www.libsdl.org/ Simple DirectMedia Layer Homepage]
+
[http://www.gamedev.net/ Game Development Resources]
-
* [http://www.gamedev.net/ Game Development Resources]
+
[[Category:Development]]
[[Category:Development]]
[[Category:Games]]
[[Category:Games]]

Learn more about Contributing to the wiki.


Please note that all contributions to maemo.org wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see maemo.org wiki:Copyrights for details). Do not submit copyrighted work without permission!


Cancel | Editing help (opens in new window)