Simple sample to write ‘Hello world’ to screen.
Using library
GP2X minimal library by rlyeh, 2005
License
- Free for non-commercial projects (it would be nice receiving a mail from you). Other cases, ask me first.
- GamePark Holdings is not allowed to use this library and/or use parts from it.
Source code
#include "minimal.h"
int main(int argc, char *argv[])
{
gp2x_init(1000, 16, 11025,16,1,60, 1);
//printfs a text to screen
gp2x_printf(NULL,0,0,"Hello world\n");
//updates video changes
gp2x_video_RGB_flip(0);
while(!(gp2x_joystick_read() & GP2X_A));
}
void gp2x_sound_frame(void *blah, void *buff, int samples) { }
Explanation
- Our gp2x_init line inits the whole library. We set 1000 ticks per second, 16 bits video mode, 11025/16bits/stereo/60Hz sound mode, and solid font.
- Our gp2x_printf line writes a ‘hello world’ string into screen, at coordinates (0,0) and using default font.
- Our gp2x_video_RGB_flip updates all video changes (in this case, our printed line).
- Our gp2x_joystick_read line reads the joystick. In this case we do a loop until any press is found.
- Our gp2x_sound_frame line fills our sound buffer. Note that this function will not generate any sound since we have written a void function.
C Compilation
arm-linux-gcc minimal.c hello.c -static -lpthread -lm
C++ Compilation
arm-linux-g++ minimal.c hello.c -static -lpthread -lm
Output
- this program prints hello world to screen, then it waits for A button before exiting.