[Armadeus-commitlog] SF.net SVN: armadeus:[1204] trunk/target/demos
Brought to you by:
sszy
|
From: <ar...@us...> - 2009-04-07 10:31:22
|
Revision: 1204
http://armadeus.svn.sourceforge.net/armadeus/?rev=1204&view=rev
Author: artemys
Date: 2009-04-07 10:31:12 +0000 (Tue, 07 Apr 2009)
Log Message:
-----------
[DEMOS] Add README + SDL_image example
Modified Paths:
--------------
trunk/target/demos/backlight_control/backlight.c
Added Paths:
-----------
trunk/target/demos/README
trunk/target/demos/show_image/
trunk/target/demos/show_image/Makefile
trunk/target/demos/show_image/image.c
Added: trunk/target/demos/README
===================================================================
--- trunk/target/demos/README (rev 0)
+++ trunk/target/demos/README 2009-04-07 10:31:12 UTC (rev 1204)
@@ -0,0 +1,15 @@
+Some program examples to show how to use some Armadeus boards functionnalities:
+- armanoid:
+ SDL 2D game (very basic)
+- backlight_control:
+ Backlight control with SDL and Tslib (touchscreen)
+- gps:
+ NMEA decoding examples (GPS connected on 2nd serial port)
+- show_image:
+ SDL_image library usage example
+- input_test:
+ Event handling in SDL (keyboard, mouse, joypad)
+- real_time:
+ Xenomai examples
+- wolfenstein3d:
+ SDL 3D game (buggy)
Modified: trunk/target/demos/backlight_control/backlight.c
===================================================================
--- trunk/target/demos/backlight_control/backlight.c 2009-04-07 09:03:46 UTC (rev 1203)
+++ trunk/target/demos/backlight_control/backlight.c 2009-04-07 10:31:12 UTC (rev 1204)
@@ -1,6 +1,6 @@
/*
* Small tool to demonstrate how to use (or not use ;-) ) Tslib + SDL library
- * for the Armadeus project. www.armadeus.og
+ * for the Armadeus project: http://www.armadeus.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Added: trunk/target/demos/show_image/Makefile
===================================================================
--- trunk/target/demos/show_image/Makefile (rev 0)
+++ trunk/target/demos/show_image/Makefile 2009-04-07 10:31:12 UTC (rev 1204)
@@ -0,0 +1,47 @@
+ARMADEUS_BASE_DIR=../../..
+include $(ARMADEUS_BASE_DIR)/Makefile.in
+
+ifeq ($(TARGET),)
+ ROOT_DIR:=$(ARMADEUS_ROOTFS_DIR)
+ CC:=$(ARMADEUS_TOOLCHAIN_PATH)/arm-linux-gcc
+ DEFINES="-DTARGET"
+ CFLAGS:=$(shell STAGING_DIR=$(ARMADEUS_STAGING_DIR) sh $(ARMADEUS_SDL_DIR)/sdl-config --cflags)
+ LIBS:=$(shell STAGING_DIR=$(ARMADEUS_STAGING_DIR) sh $(ARMADEUS_SDL_DIR)/sdl-config --libs) -lSDL_image
+else
+ ROOT_DIR:="/"
+ CFLAGS=`/usr/bin/sdl-config --cflags`
+ LIBS=`/usr/bin/sdl-config --libs` -lSDL_Image
+ CC=gcc
+ DEFINES="-DHOST"
+endif
+
+INSTALL_DIR:=$(ROOT_DIR)/usr/bin/
+ifneq ($(DEBUG),)
+CFLAGS+="-g"
+endif
+
+
+EXEC_NAME=show_image
+
+default: $(EXEC_NAME)
+
+all: $(EXEC_NAME)
+
+
+image.o: image.c
+ $(CC) $(CFLAGS) -c -o $@ $^
+
+$(EXEC_NAME): image.o
+ $(CC) $(LIBS) -o $@ $^
+
+
+install: $(EXEC_NAME)
+ mkdir -p $(INSTALL_DIR)
+ cp $^ $(INSTALL_DIR)
+
+clean:
+ rm -rf $(EXEC_NAME)
+ rm -rf *.o
+
+.PHONY: clean install
+
Added: trunk/target/demos/show_image/image.c
===================================================================
--- trunk/target/demos/show_image/image.c (rev 0)
+++ trunk/target/demos/show_image/image.c 2009-04-07 10:31:12 UTC (rev 1204)
@@ -0,0 +1,78 @@
+/*
+ * Small tool to demonstrate how to use SDL_image library
+ * for the Armadeus project: http://www.armadeus.org
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <SDL/SDL.h>
+#include <SDL/SDL_image.h>
+
+
+#define SCREEN_WIDTH 480
+#define SCREEN_HEIGHT 272
+
+
+void wait()
+{
+ int end = 0;
+ SDL_Event event;
+
+ while (!end)
+ {
+ SDL_WaitEvent(&event);
+ switch(event.type)
+ {
+ case SDL_QUIT:
+ end = 1;
+ break;
+ }
+ }
+}
+
+int main(int argc, char *argv[])
+{
+ SDL_Surface *screen = NULL, *image = NULL;
+ SDL_Rect coord;
+
+ if (argc != 2) {
+ printf("Usage: %s file\n", argv[0]);
+ return EXIT_FAILURE;
+ }
+ SDL_Init(SDL_INIT_VIDEO);
+ atexit(SDL_Quit);
+
+ screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 16, SDL_ANYFORMAT);
+ if (!screen) {
+ printf("Unable to open display (%dx%d)\n", SCREEN_WIDTH, SCREEN_HEIGHT);
+ return EXIT_FAILURE;
+ }
+
+ image = IMG_Load(argv[1]);
+ if (!image) {
+ printf("Unable to load image file: %s\n", SDL_GetError());
+ return EXIT_FAILURE;
+ }
+ SDL_BlitSurface(image, NULL, screen, 0);
+ SDL_Flip(screen);
+
+ wait();
+
+ SDL_FreeSurface(image);
+
+ return EXIT_SUCCESS;
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|