Port SDL/TinySDGL to android with native C
2013-05-15 18:43
351 查看
I have update the makefile.minimal and minimal config file, now can correct show the context! Enjoy it!!!
I have success port SDL/TinySDGL to android with native C!
Make SDL with Makefile.minimal makefile, and config SDL_config.h to set video use FBCON, and timer user unix implement, and change some code when user FBCON video.
After compile SDL success, then compile TinySDGL, don't change any code, so crazy!
But compile TinySDGL demo need change screen size variables, then can success compile gears example, screensnap pls see the photo:
Steps as follows:
1.Download arm linux cross platform compile toolchains from URL:
http://www.codesourcery.com/gnu_toolchains/arm/download.html
Windows: http://www.codesourcery.com/gnu_toolchains/arm/portal/package3400/public/arm-none-linux-gnueabi/arm-2008q3-41-arm-none-linux-gnueabi.exe
Linux: http://www.codesourcery.com/gnu_toolchains/arm/portal/package3399/public/arm-none-linux-gnueabi/arm-2008q3-41-arm-none-linux-gnueabi.bin
after install the gnu arm linux toolchains, set the dir "bin" to your path;
2.If you use windows, pls install cygwin(http://www.cygwin.com), if you use linux, ignore this step;
3.Download SDL 1.2.13 source from http://www.libsdl.org, and un-zip it to a dir;
4.Change the Makefile.minimal as follows:
And change SDL_config_minimal.h file as follows:
We enable audio driver oss, and video frame buffer, and unix timer, and enable stdio to read/write file;
3.Change $SDL/src/video/fbcon/SDL_fbvideo.c, line 191 & 499, use "/dev/graphics/fb0" instead of "/dev/fb0", becuase Android linux use "/dev/graphics/fb0" video device;
4.Now enter SDL dir, you can type "make" to compile SDL for Android! if success, you can get libSDL.a in SDL dir;
5.Download TinySDL from http://www.kyb.tuebingen.mpg.de/bu/people/gf/software/, TinySDGL:http://www.kyb.tuebingen.mpg.de/bu/people/gf/software/TinySDGL.zip,
and un-zip TinySDGL to the same dir as you un-zip SDL;
6.For compile TinySDGL, you just need change Makefile, don't need change any source code, the makeinclude as follows:
After change this, you can enter TinySDGL dir, and type "make" to compile it, after compile success, enter examples dir, you can find the gears,triangle demos, now you can push them to android emulator, and run
it, first start your android emulator, and type commonds as follwos:
>adb shell mkdir /dev/sample
>adb push gears /dev/sample
>adb shell chmod 777 /dev/sample/gears
>adb shell
#cd /dev/sample
#./gears
OK, you will see the demo run on android emulator!
I have success port SDL/TinySDGL to android with native C!
Make SDL with Makefile.minimal makefile, and config SDL_config.h to set video use FBCON, and timer user unix implement, and change some code when user FBCON video.
After compile SDL success, then compile TinySDGL, don't change any code, so crazy!
But compile TinySDGL demo need change screen size variables, then can success compile gears example, screensnap pls see the photo:
Steps as follows:
1.Download arm linux cross platform compile toolchains from URL:
http://www.codesourcery.com/gnu_toolchains/arm/download.html
Windows: http://www.codesourcery.com/gnu_toolchains/arm/portal/package3400/public/arm-none-linux-gnueabi/arm-2008q3-41-arm-none-linux-gnueabi.exe
Linux: http://www.codesourcery.com/gnu_toolchains/arm/portal/package3399/public/arm-none-linux-gnueabi/arm-2008q3-41-arm-none-linux-gnueabi.bin
after install the gnu arm linux toolchains, set the dir "bin" to your path;
2.If you use windows, pls install cygwin(http://www.cygwin.com), if you use linux, ignore this step;
3.Download SDL 1.2.13 source from http://www.libsdl.org, and un-zip it to a dir;
4.Change the Makefile.minimal as follows:
# Makefile to build the SDL library INCLUDE = -I./include CFLAGS = -g -O2 $(INCLUDE) -static CC = arm-none-linux-gnueabi-gcc AR = arm-none-linux-gnueabi-ar RANLIB = arm-none-linux-gnueabi-ranlib CONFIG_H = include/SDL_config.h TARGET = libSDL.a SOURCES = \ src/*.c \ src/audio/*.c \ src/cdrom/*.c \ src/cpuinfo/*.c \ src/events/*.c \ src/file/*.c \ src/joystick/*.c \ src/stdlib/*.c \ src/thread/*.c \ src/timer/*.c \ src/video/*.c \ src/audio/dsp/*.c \ src/audio/dma/*.c \ src/video/fbcon/*.c \ src/joystick/dummy/*.c \ src/cdrom/dummy/*.c \ src/thread/generic/*.c \ src/timer/unix/*.c \ src/loadso/dlopen/*.c \ OBJECTS = $(shell echo $(SOURCES) | sed -e 's,\.c,\.o,g') all: $(TARGET) $(TARGET): $(CONFIG_H) $(OBJECTS) $(AR) crv $@ $^ $(RANLIB) $@ $(CONFIG_H): cp $(CONFIG_H).default $(CONFIG_H) clean: rm -f $(TARGET) $(OBJECTS) |
And change SDL_config_minimal.h file as follows:
#ifndef _SDL_config_minimal_h #define _SDL_config_minimal_h #include "SDL_platform.h" #include <stdarg.h> typedef signed char int8_t; typedef unsigned char uint8_t; typedef signed short int16_t; typedef unsigned short uint16_t; typedef signed int int32_t; typedef unsigned int uint32_t; typedef unsigned int size_t; //typedef unsigned long uintptr_t; #define HAVE_LIBC 1 #ifdef HAVE_LIBC #define HAVE_ALLOCA_H 1 #define HAVE_SYS_TYPES_H 1 #define HAVE_STDIO_H 1 #define STDC_HEADERS 1 #define HAVE_STDLIB_H 1 #define HAVE_STDARG_H 1 #define HAVE_MALLOC_H 1 #define HAVE_MEMORY_H 1 //#define HAVE_STRING_H 1 //#define HAVE_STRINGS_H 1 #define HAVE_INTTYPES_H 1 #define HAVE_STDINT_H 1 #define HAVE_CTYPE_H 1 #define HAVE_MATH_H 1 //#define HAVE_ICONV_H 1 #define HAVE_SIGNAL_H 1 #define HAVE_ALTIVEC_H 1 #define HAVE_MALLOC 1 #define HAVE_CALLOC 1 #define HAVE_REALLOC 1 #define HAVE_FREE 1 #define HAVE_ALLOCA 1 #define HAVE_GETENV 1 #define HAVE_PUTENV 1 #define HAVE_UNSETENV 1 #define HAVE_QSORT 1 #define HAVE_ABS 1 #define HAVE_BCOPY 1 #define HAVE_MEMSET 1 #define HAVE_MEMCPY 1 #define HAVE_MEMMOVE 1 #define HAVE_MEMCMP 1 #define HAVE_STRLEN 1 //#define HAVE_STRLCPY 1 //#define HAVE_STRLCAT 1 #define HAVE_STRDUP 1 #define HAVE__STRREV 1 #define HAVE__STRUPR 1 #define HAVE__STRLWR 1 #define HAVE_INDEX 1 #define HAVE_RINDEX 1 #define HAVE_STRCHR 1 #define HAVE_STRRCHR 1 #define HAVE_STRSTR 1 #define HAVE_ITOA 1 #define HAVE__LTOA 1 #define HAVE__UITOA 1 #define HAVE__ULTOA 1 #define HAVE_STRTOL 1 #define HAVE_STRTOUL 1 #define HAVE__I64TOA 1 #define HAVE__UI64TOA 1 #define HAVE_STRTOLL 1 #define HAVE_STRTOULL 1 #define HAVE_STRTOD 1 #define HAVE_ATOI 1 #define HAVE_ATOF 1 #define HAVE_STRCMP 1 #define HAVE_STRNCMP 1 #define HAVE__STRICMP 1 #define HAVE_STRCASECMP 1 #define HAVE__STRNICMP 1 #define HAVE_STRNCASECMP 1 #define HAVE_SSCANF 1 #define HAVE_SNPRINTF 1 #define HAVE_VSNPRINTF 1 //#define HAVE_ICONV #define HAVE_SIGACTION 1 #define HAVE_SETJMP 1 #define HAVE_NANOSLEEP 1 //#define HAVE_CLOCK_GETTIME 1 #define HAVE_DLVSYM 1 #define HAVE_GETPAGESIZE 1 #define HAVE_MPROTECT 1 #else #include <stdarg.h> #endif //#define HAVE_STDIO_H 1 //#define HAVE_STDINT_H 1 #define SDL_AUDIO_DRIVER_OSS 1 // SDL_AUDIO_DRIVER_DUMMY #define SDL_CDROM_DISABLED 1 #define SDL_JOYSTICK_DISABLED 1 #define SDL_LOADSO_DLOPEN 1 //SDL_LOADSO_DISABLED 1 //#undef #define SDL_THREADS_DISABLED 1 //SDL_TIMERS_DISABLED #define SDL_TIMER_UNIX 1 // SDL_VIDEO_DRIVER_DUMMY #define SDL_VIDEO_DRIVER_FBCON 1 #endif |
We enable audio driver oss, and video frame buffer, and unix timer, and enable stdio to read/write file;
3.Change $SDL/src/video/fbcon/SDL_fbvideo.c, line 191 & 499, use "/dev/graphics/fb0" instead of "/dev/fb0", becuase Android linux use "/dev/graphics/fb0" video device;
4.Now enter SDL dir, you can type "make" to compile SDL for Android! if success, you can get libSDL.a in SDL dir;
5.Download TinySDL from http://www.kyb.tuebingen.mpg.de/bu/people/gf/software/, TinySDGL:http://www.kyb.tuebingen.mpg.de/bu/people/gf/software/TinySDGL.zip,
and un-zip TinySDGL to the same dir as you un-zip SDL;
6.For compile TinySDGL, you just need change Makefile, don't need change any source code, the makeinclude as follows:
##################################################################### # C compiler # linux / Windows MinGW CC= arm-none-linux-gnueabi-gcc AR = arm-none-linux-gnueabi-ar RANLIB = arm-none-linux-gnueabi-ranlib CFLAGS = -g -Wall -O2 -w -static LFLAGS = -s -static ##################################################################### # SDL configuration (for the examples only) UI_LIBS = -L../../SDL-1.2.13 -lSDL UI_INCLUDES = -I../../SDL-1.2.13/include ##################################################################### # OpenGL configuration (for the examples only) # use TinySDGL GL_LIBS= -L../lib -lTinySDGL GL_INCLUDES= -I../include GL_DEPS= ../lib/libTinySDGL.a # use Mesa #GL_LIBS= -lMesaGL #GL_INCLUDES= #GL_DEPS= # use OpenGL #GL_LIBS= -lGL #GL_INCLUDES= #GL_DEPS= #################################################################### # Compile and link control DIRS= src examples |
After change this, you can enter TinySDGL dir, and type "make" to compile it, after compile success, enter examples dir, you can find the gears,triangle demos, now you can push them to android emulator, and run
it, first start your android emulator, and type commonds as follwos:
>adb shell mkdir /dev/sample
>adb push gears /dev/sample
>adb shell chmod 777 /dev/sample/gears
>adb shell
#cd /dev/sample
#./gears
OK, you will see the demo run on android emulator!
相关文章推荐
- Port SDL/TinySDGL to android with native C
- Port SDL/TinySDGL to android with native C
- Port SDL/TinySDGL to android with native C
- Port SDL/TinySDGL to android with native C
- Xamarin.Android - Binding to android native SDK with AIDL file
- How to debug Android Native Application with eclipse
- How to port native (C/C++) library into android.
- Android错误:Conversion to Dalvik format failed with error 1的解决办法
- 解决 Android N requires the IDE to be running with Java 1.8 or later
- Android| failed to connect to /10.0.2.2 (port 80) after 10000ms
- How to use GitHub with Android Studio
- android中使用代码混淆出现Conversion to Dalvik format failed with error 1错误的解决办法
- Xampp error:Port 80 in use by "Unable to open process" with PID 4!
- “Nothing to push” error in Android studio with Git
- How to record your Android tests with Robotium Recorder
- How to connect to Android with ADB over TCP?
- [Android]使用ProGuard遇到“conversion to Dalvik format failed with error 1”错误的解决办法
- android 混淆Conversion to Dalvik format failed with error 1错误
- (OK) port_lighttpd_to_Android——没有基于android 4.4源码
- UniversalAndroidImageLoader出现异常:ImageLoader: Unable to resolve host "https": No address associated with host