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: | ||
+ | {{Midgard article}} | ||
+ | |||
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= | |
- | + | ==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 12: | ||
* 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== | |
Things to remember: | Things to remember: | ||
- | * The screen is natively 800x480 | + | * The screen is natively 800x480. No resolution changes are supported. Maybe in the future we might have support for 400x240 res for faster graphics but this is quite unlikely. If trying to set fullscreen window smaller than the native screen size, you will just have black borders. |
- | * In windowed mode | + | * In windowed mode matchbox will force the window to certain size (you should look at the UI specifications to see the actual window size). If your requested window is smaller than this, your window will be aligned to the upper-left and have black borders on the lower-right. |
- | * Avoid full 800x480 screen updates. Memory bandwidth is limited. If you still have to do these for some reason, you should make the area smaller ( | + | Generally SDL windows (not fullscreen) look quite bad with the theme if nothing for the theme is done inside the SDL window, but it's up to you to decide. |
- | * 32 bit mode doesn't work. The reason was that there was a bug that caused SDL to segfault when you had 32 bit window and you recreated the window. Since the display is only 16 bit, there is no reason to support 32 bit mode, which would just give | + | * Avoid full 800x480 screen updates. Memory bandwidth is limited. If you still have to do these for some reason, you should make the area smaller (eg having some statusbar or any GUI elements which doesn't need to be updated each time). Also do not use SDL_Flip(), since it will update whole screen. Use rect updating functions instead. Thank you. |
- | * Mouse events. There is touchscreen, and you | + | * 32 bit mode doesn't work. The reason was that there was a bug that caused SDL to segfault when you had 32 bit window and you recreated the window. Since the display is only 16 bit, there is no reason to support 32 bit mode, which would just give extra round of pixel conversion and therefore slow things down. Convert your images on loading to native 16-bit with SDL. |
+ | * Mouse events. There is touchscreen, and you can't assume average end user Billy-Bob would hack the device to 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 keypad to move the cursor, and then use the touchscreen, the actuall cursor will be at offset from original touchpadpress. Think absolutely, not relatively ;) | ||
- | |||
- | ====Create an entry in the task list | + | ==Adding support for the Task Navigator== |
+ | |||
+ | ===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 47: | ||
* 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: | ||
- | < | + | <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 "$@" | ||
- | </ | + | </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 58: | ||
* 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 | ||
- | < | + | <pre> |
putenv("SDL_VIDEO_X11_WMCLASS=app"); | putenv("SDL_VIDEO_X11_WMCLASS=app"); | ||
- | </ | + | </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=== | |
- | + | You can set the title shown in the task list by using: | |
- | < | + | <pre> |
#include <SDL/SDL_syswm.h> | #include <SDL/SDL_syswm.h> | ||
#include <X11/Xutil.h> | #include <X11/Xutil.h> | ||
Line 80: | Line 84: | ||
if (dpy && win) XStoreName(dpy, win, "Title"); | if (dpy && win) XStoreName(dpy, win, "Title"); | ||
} | } | ||
- | </ | + | </pre> |
- | + | ==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. | ||
- | |||
- | |||
====What is pixel doubling?==== | ====What is pixel doubling?==== | ||
Line 122: | Line 107: | ||
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: | ||
- | < | + | <pre> |
#include <X11/Xlib.h> | #include <X11/Xlib.h> | ||
#include <X11/extensions/Xsp.h> | #include <X11/extensions/Xsp.h> | ||
Line 137: | Line 122: | ||
XSPSetPixelDoubling(wminfo.info.x11.display, 0, enable); | XSPSetPixelDoubling(wminfo.info.x11.display, 0, enable); | ||
} | } | ||
- | </ | + | </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= | |
- | + | ||
+ | [http://www.libsdl.org/ Simple DirectMedia Layer Homepage] | ||
+ | |||
+ | [http://www.gamedev.net/ Game Development Resources] | ||
[[Category:Development]] | [[Category:Development]] | ||
- | [[Category: | + | [[Category:Midgard wiki]] |
Learn more about Contributing to the wiki.