THIS REVISION WILL NOT WORK! Compiled and linked SDL_renderer_gles.c into SDL 1.2 lib, no code was added to actually use it. ifdef overkill, yay!

This commit is contained in:
pelya
2010-07-26 18:24:57 +03:00
parent 90b09cd587
commit eda66c6d45
31 changed files with 137 additions and 15 deletions

View File

@@ -3,5 +3,5 @@
# Set here your own NDK path if needed
# export PATH=$PATH:~/src/endless_space/android-ndk-r4
cd project && nice -n5 ndk-build -j2 V=1 && ant debug && cd bin && adb install -r DemoActivity-debug.apk
cd project && nice -n5 ndk-build V=1 && ant debug && cd bin && adb install -r DemoActivity-debug.apk

View File

@@ -125,7 +125,6 @@ static inline int SDL_SetAlpha(SdlCompat_AcceleratedSurface * surface, Uint32 fl
#else
// TODO: did not check if SDL 1.2 part compiles
typedef SDL_Surface SdlCompat_AcceleratedSurface;
static inline SdlCompat_AcceleratedSurface * SdlCompat_CreateAcceleratedSurface(SDL_Surface * surface)

View File

@@ -33,7 +33,7 @@ JAVA_EXPORT_NAME(DemoRenderer_nativeInit) ( JNIEnv* env, jobject thiz )
char curdir[512];
if( isSdcardUsed )
{
strcpy(curdir, "/sdcard/");
strcpy(curdir, "/sdcard/app-data/");
strcat(curdir, SDL_CURDIR_PATH);
}
else

View File

@@ -258,6 +258,9 @@ extern DECLSPEC void SDLCALL SDL_qsort(void *base, size_t nmemb, size_t size,
extern DECLSPEC void * SDLCALL SDL_memset(void *dst, int c, size_t len);
#endif
#define SDL_zero(x) SDL_memset(&(x), 0, sizeof((x)))
#define SDL_zerop(x) SDL_memset((x), 0, sizeof(*(x)))
#if defined(__GNUC__) && defined(i386)
#define SDL_memset4(dst, val, len) \
do { \

View File

@@ -0,0 +1 @@
../SDL_blit.h

View File

@@ -0,0 +1 @@
../../../../sdl-1.3/src/video/SDL_glesfuncs.h

View File

@@ -0,0 +1 @@
../../../../sdl-1.3/include/SDL_opengles.h

View File

@@ -0,0 +1 @@
../../../../sdl-1.3/src/video/SDL_pixels.c

View File

@@ -0,0 +1 @@
../../../../sdl-1.3/include/SDL_pixels.h

View File

@@ -0,0 +1 @@
../../../../sdl-1.3/src/video/SDL_pixels_c.h

View File

@@ -0,0 +1 @@
../../../../sdl-1.3/src/video/SDL_rect.c

View File

@@ -0,0 +1 @@
../../../../sdl-1.3/include/SDL_rect.h

View File

@@ -0,0 +1 @@
../../../../sdl-1.3/src/video/SDL_rect_c.h

View File

@@ -0,0 +1 @@
../../../../sdl-1.3/src/video/SDL_renderer_gles.c

View File

@@ -0,0 +1 @@
../../../../sdl-1.3/src/video/SDL_renderer_gles.h

View File

@@ -0,0 +1 @@
../../../../sdl-1.3/src/video/SDL_sysvideo.h

View File

@@ -0,0 +1 @@
../../../../sdl-1.3/include/SDL_video.h

View File

@@ -0,0 +1 @@
../../../../sdl-1.3/src/video/SDL_video.c

View File

@@ -29,6 +29,14 @@
#ifndef _SDL_pixels_h
#define _SDL_pixels_h
#include "SDL_version.h"
#if SDL_VERSION_ATLEAST(1,3,0)
#include "SDL_video.h"
#else
#include "SDL_video-1.3.h"
#endif
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
@@ -219,6 +227,7 @@ enum
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ARGB,
SDL_PACKEDLAYOUT_2101010, 32, 4),
#if SDL_VERSION_ATLEAST(1,3,0)
SDL_PIXELFORMAT_YV12 = /**< Planar mode: Y + V + U (3 planes) */
SDL_DEFINE_PIXELFOURCC('Y', 'V', '1', '2'),
SDL_PIXELFORMAT_IYUV = /**< Planar mode: Y + U + V (3 planes) */
@@ -229,8 +238,10 @@ enum
SDL_DEFINE_PIXELFOURCC('U', 'Y', 'V', 'Y'),
SDL_PIXELFORMAT_YVYU = /**< Packed mode: Y0+V0+Y1+U0 (1 plane) */
SDL_DEFINE_PIXELFOURCC('Y', 'V', 'Y', 'U')
#endif
};
#if SDL_VERSION_ATLEAST(1,3,0)
typedef struct SDL_Color
{
Uint8 r;
@@ -274,6 +285,7 @@ typedef struct SDL_PixelFormat
Uint32 Bmask;
Uint32 Amask;
} SDL_PixelFormat;
#endif
/**
* \brief Convert one of the enumerated pixel formats to a bpp and RGBA masks.
@@ -320,6 +332,7 @@ extern DECLSPEC SDL_Palette *SDLCALL SDL_AllocPalette(int ncolors);
*
* \sa SDL_DelPaletteWatch()
*/
#if SDL_VERSION_ATLEAST(1,3,0)
extern DECLSPEC int SDLCALL SDL_AddPaletteWatch(SDL_Palette * palette,
SDL_PaletteChangedFunc
callback, void *userdata);
@@ -333,7 +346,7 @@ extern DECLSPEC int SDLCALL SDL_AddPaletteWatch(SDL_Palette * palette,
extern DECLSPEC void SDLCALL SDL_DelPaletteWatch(SDL_Palette * palette,
SDL_PaletteChangedFunc
callback, void *userdata);
#endif
/**
* \brief Set a range of colors in a palette.
*

View File

@@ -31,8 +31,11 @@
#include "SDL_stdinc.h"
#include "SDL_error.h"
#include "SDL_pixels.h"
#include "SDL_rwops.h"
#include "SDL_version.h"
#if ! SDL_VERSION_ATLEAST(1,3,0)
#include "SDL_video.h"
#endif
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
@@ -63,11 +66,13 @@ typedef struct
* \sa SDL_UnionRect
* \sa SDL_EnclosePoints
*/
#if SDL_VERSION_ATLEAST(1,3,0)
typedef struct SDL_Rect
{
int x, y;
int w, h;
} SDL_Rect;
#endif
/**
* \brief Returns true if the rectangle has no area.

View File

@@ -26,13 +26,17 @@
* Header file for SDL video functions.
*/
#ifndef _SDL_video_h
#define _SDL_video_h
#ifndef _SDL_video_1_3_h
#define _SDL_video_1_3_h
#include "SDL_stdinc.h"
#include "SDL_pixels.h"
#include "SDL_rect.h"
#include "SDL_pixels.h"
#include "SDL_surface.h"
#include "SDL_version.h"
#if ! SDL_VERSION_ATLEAST(1,3,0)
#include "SDL_video.h"
#endif
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
@@ -256,6 +260,7 @@ typedef struct SDL_Texture SDL_Texture;
*/
typedef void *SDL_GLContext;
#if SDL_VERSION_ATLEAST(1,3,0)
/**
* \brief OpenGL configuration attributes
*/
@@ -281,7 +286,7 @@ typedef enum
SDL_GL_CONTEXT_MAJOR_VERSION,
SDL_GL_CONTEXT_MINOR_VERSION
} SDL_GLattr;
#endif
/* Function prototypes */

View File

@@ -20,22 +20,32 @@
slouken@libsdl.org
*/
#include "SDL_config.h"
#include "SDL_version.h"
/* General (mostly internal) pixel/color manipulation routines for SDL */
#include "SDL_endian.h"
#if SDL_VERSION_ATLEAST(1,3,0)
#include "SDL_video.h"
#include "SDL_sysvideo.h"
#else
#include "SDL_video-1.3.h"
#include "SDL_sysvideo-1.3.h"
#endif
#include "SDL_blit.h"
#include "SDL_pixels_c.h"
#if SDL_VERSION_ATLEAST(1,3,0)
#include "SDL_RLEaccel_c.h"
#endif
#if SDL_VERSION_ATLEAST(1,3,0)
struct SDL_PaletteWatch
{
SDL_PaletteChangedFunc callback;
void *userdata;
struct SDL_PaletteWatch *next;
};
#endif
/* Helper functions */
@@ -288,7 +298,7 @@ SDL_MasksToPixelFormatEnum(int bpp, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask,
return SDL_PIXELFORMAT_UNKNOWN;
}
#if SDL_VERSION_ATLEAST(1,3,0)
SDL_Palette *
SDL_AllocPalette(int ncolors)
{
@@ -428,6 +438,8 @@ SDL_AllocFormat(int bpp,
return SDL_InitFormat(format, bpp, Rmask, Gmask, Bmask, Amask);
}
#endif
SDL_PixelFormat *
SDL_InitFormat(SDL_PixelFormat * format, int bpp, Uint32 Rmask, Uint32 Gmask,
Uint32 Bmask, Uint32 Amask)
@@ -508,6 +520,8 @@ SDL_InitFormat(SDL_PixelFormat * format, int bpp, Uint32 Rmask, Uint32 Gmask,
return format;
}
#if SDL_VERSION_ATLEAST(1,3,0)
/*
* Change any previous mappings from/to the new surface format
*/
@@ -913,5 +927,6 @@ SDL_FreeBlitMap(SDL_BlitMap * map)
SDL_free(map);
}
}
#endif
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -20,6 +20,7 @@
slouken@libsdl.org
*/
#include "SDL_config.h"
#include "SDL_version.h"
/* Useful functions and variables from SDL_pixel.c */

View File

@@ -20,6 +20,7 @@
slouken@libsdl.org
*/
#include "SDL_config.h"
#include "SDL_rect.h"
typedef struct SDL_DirtyRect
{

View File

@@ -20,15 +20,23 @@
slouken@libsdl.org
*/
#include "SDL_config.h"
#include "SDL_version.h"
#if SDL_VIDEO_RENDER_OGL_ES
#if SDL_VERSION_ATLEAST(1,3,0)
#include "SDL_video.h"
#include "SDL_opengles.h"
#include "SDL_sysvideo.h"
#else
#include "SDL_video-1.3.h"
#include "SDL_sysvideo-1.3.h"
#endif
#include "SDL_opengles.h"
#include "SDL_pixels_c.h"
#include "SDL_rect_c.h"
#if SDL_VERSION_ATLEAST(1,3,0)
#include "SDL_yuv_sw_c.h"
#endif
#ifdef ANDROID
#include <android/log.h>
#endif
@@ -221,11 +229,13 @@ GLES_CreateRenderer(SDL_Window * window, Uint32 flags)
GLint value;
int doublebuffer;
#if SDL_VERSION_ATLEAST(1,3,0)
if (!(window->flags & SDL_WINDOW_OPENGL)) {
if (SDL_RecreateWindow(window, window->flags | SDL_WINDOW_OPENGL) < 0) {
return NULL;
}
}
#endif
renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
if (!renderer) {
@@ -303,11 +313,15 @@ GLES_CreateRenderer(SDL_Window * window, Uint32 flags)
renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC;
}
#ifdef ANDROID
// Always double-buffered
#else
if (SDL_GL_GetAttribute(SDL_GL_DOUBLEBUFFER, &doublebuffer) == 0) {
if (!doublebuffer) {
renderer->info.flags |= SDL_RENDERER_SINGLEBUFFER;
}
}
#endif
#if SDL_VIDEO_DRIVER_PANDORA
data->GL_OES_draw_texture_supported = SDL_FALSE;
data->useDrawTexture = SDL_FALSE;

View File

@@ -21,11 +21,12 @@
*/
#include "SDL_config.h"
#ifndef _SDL_sysvideo_h
#define _SDL_sysvideo_h
#ifndef _SDL_sysvideo_1_3_h
#define _SDL_sysvideo_1_3_h
#include "SDL_mouse.h"
#include "SDL_keysym.h"
#include "SDL_rect.h"
/* The SDL video driver */

View File

@@ -20,19 +20,27 @@
slouken@libsdl.org
*/
#include "SDL_config.h"
#include "SDL_version.h"
/* The high-level video driver subsystem */
#include "SDL.h"
#if SDL_VERSION_ATLEAST(1,3,0)
#include "SDL_video.h"
#include "SDL_sysvideo.h"
#else
#include "SDL_video-1.3.h"
#include "SDL_sysvideo-1.3.h"
#endif
#include "SDL_blit.h"
#include "SDL_pixels_c.h"
#include "SDL_renderer_gl.h"
#include "SDL_renderer_gles.h"
#include "SDL_renderer_sw.h"
#if SDL_VERSION_ATLEAST(1,3,0)
#include "../events/SDL_sysevents.h"
#include "../events/SDL_events_c.h"
#endif
#ifdef ANDROID
#include <android/log.h>
#endif
@@ -183,7 +191,12 @@ SDL_GetVideoDriver(int index)
* Initialize the video and event subsystems -- determine native pixel format
*/
int
SDL_VideoInit(const char *driver_name, Uint32 flags)
#if SDL_VERSION_ATLEAST(1,3,0)
SDL_VideoInit
#else
SDL_VideoInit_1_3
#endif
(const char *driver_name, Uint32 flags)
{
SDL_VideoDevice *video;
int index;
@@ -290,9 +303,11 @@ SDL_VideoInit(const char *driver_name, Uint32 flags)
SDL_AddRenderDriver(display, &GL_ES_RenderDriver);
#endif
}
#if SDL_VERSION_ATLEAST(1,3,0)
if (display->num_render_drivers > 0) {
SDL_AddRenderDriver(display, &SW_RenderDriver);
}
#endif
}
/* We're ready to go! */
@@ -698,6 +713,7 @@ SDL_SetDisplayModeForDisplay(SDL_VideoDisplay * display, const SDL_DisplayMode *
}
display->current_mode = display_mode;
#if SDL_VERSION_ATLEAST(1,3,0)
/* Set up a palette, if necessary */
if (SDL_ISPIXELFORMAT_INDEXED(display_mode.format)) {
ncolors = (1 << SDL_BITSPERPIXEL(display_mode.format));
@@ -719,6 +735,7 @@ SDL_SetDisplayModeForDisplay(SDL_VideoDisplay * display, const SDL_DisplayMode *
SDL_BITSPERPIXEL(display_mode.format));
}
}
#endif
return 0;
}
@@ -764,6 +781,8 @@ SDL_GetWindowDisplayMode(SDL_Window * window, SDL_DisplayMode * mode)
return 0;
}
#if SDL_VERSION_ATLEAST(1,3,0)
static void
SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool attempt)
{
@@ -1036,6 +1055,7 @@ SDL_RecreateWindow(SDL_Window * window, Uint32 flags)
return 0;
}
#endif
static __inline__ SDL_Renderer *
SDL_GetCurrentRenderer(SDL_bool create)
@@ -1056,6 +1076,7 @@ SDL_GetCurrentRenderer(SDL_bool create)
return SDL_CurrentRenderer;
}
#if SDL_VERSION_ATLEAST(1,3,0)
Uint32
SDL_GetWindowID(SDL_Window * window)
{
@@ -1486,6 +1507,8 @@ SDL_DestroyWindow(SDL_Window * window)
SDL_free(window);
}
#endif
void
SDL_AddRenderDriver(SDL_VideoDisplay * display, const SDL_RenderDriver * driver)
{
@@ -1706,8 +1729,13 @@ SDL_CreateTextureFromSurface(Uint32 format, SDL_Surface * surface)
}
} else {
if (surface->format->Amask
#if SDL_VERSION_ATLEAST(1,3,0)
|| !(surface->map->info.flags &
(SDL_COPY_COLORKEY | SDL_COPY_MASK | SDL_COPY_BLEND))) {
#else
|| !(surface->flags &
(SDL_SRCCOLORKEY | SDL_SRCALPHA))) {
#endif
Uint32 it;
int pfmt;
@@ -1932,6 +1960,7 @@ SDL_CreateTextureFromSurface(Uint32 format, SDL_Surface * surface)
/* Set up a destination surface for the texture update */
SDL_InitFormat(&dst_fmt, bpp, Rmask, Gmask, Bmask, Amask);
#if SDL_VERSION_ATLEAST(1,3,0)
if (SDL_ISPIXELFORMAT_INDEXED(format)) {
dst_fmt.palette =
SDL_AllocPalette((1 << SDL_BITSPERPIXEL(format)));
@@ -1944,14 +1973,17 @@ SDL_CreateTextureFromSurface(Uint32 format, SDL_Surface * surface)
SDL_BITSPERPIXEL(format));
}
}
#endif
dst = SDL_ConvertSurface(surface, &dst_fmt, 0);
if (dst) {
SDL_UpdateTexture(texture, NULL, dst->pixels, dst->pitch);
SDL_FreeSurface(dst);
}
#if SDL_VERSION_ATLEAST(1,3,0)
if (dst_fmt.palette) {
SDL_FreePalette(dst_fmt.palette);
}
#endif
if (!dst) {
SDL_DestroyTexture(texture);
return 0;
@@ -1963,6 +1995,7 @@ SDL_CreateTextureFromSurface(Uint32 format, SDL_Surface * surface)
int blendMode;
int scaleMode;
#if SDL_VERSION_ATLEAST(1,3,0)
SDL_GetSurfaceColorMod(surface, &r, &g, &b);
SDL_SetTextureColorMod(texture, r, g, b);
@@ -1974,12 +2007,20 @@ SDL_CreateTextureFromSurface(Uint32 format, SDL_Surface * surface)
SDL_GetSurfaceScaleMode(surface, &scaleMode);
SDL_SetTextureScaleMode(texture, scaleMode);
#else
if(surface->flags & SDL_SRCALPHA) {
SDL_SetTextureAlphaMod(texture, surface->format->alpha);
SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND);
}
#endif
}
#if SDL_VERSION_ATLEAST(1,3,0)
if (SDL_ISPIXELFORMAT_INDEXED(format) && fmt->palette) {
SDL_SetTexturePalette(texture, fmt->palette->colors, 0,
fmt->palette->ncolors);
}
#endif
return texture;
}
@@ -2954,6 +2995,8 @@ SDL_DisableScreenSaver()
}
}
#if SDL_VERSION_ATLEAST(1,3,0)
void
SDL_VideoQuit(void)
{
@@ -3088,6 +3131,8 @@ SDL_GL_UnloadLibrary(void)
}
}
#endif
SDL_bool
SDL_GL_ExtensionSupported(const char *extension)
{
@@ -3142,6 +3187,8 @@ SDL_GL_ExtensionSupported(const char *extension)
#endif
}
#if SDL_VERSION_ATLEAST(1,3,0)
int
SDL_GL_SetAttribute(SDL_GLattr attr, int value)
{
@@ -3379,6 +3426,8 @@ SDL_GL_GetAttribute(SDL_GLattr attr, int *value)
#endif /* SDL_VIDEO_OPENGL */
}
#endif /* SDL 1.3.0 */
SDL_GLContext
SDL_GL_CreateContext(SDL_Window * window)
{
@@ -3557,6 +3606,7 @@ SDL_WM_SetIcon(SDL_Surface * icon, Uint8 * mask)
}
#endif
#if SDL_VERSION_ATLEAST(1,3,0)
SDL_bool
SDL_GetWindowWMInfo(SDL_Window * window, struct SDL_SysWMinfo *info)
{
@@ -3595,5 +3645,6 @@ SDL_SetTextInputRect(SDL_Rect *rect)
_this->SetTextInputRect(_this, rect);
}
}
#endif
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -135,7 +135,7 @@ class DataDownloader extends Thread
Status.setText( "Connecting to " + Globals.DataDownloadUrl );
outFilesDir = Parent.getFilesDir().getAbsolutePath();
if( Globals.DownloadToSdcard )
outFilesDir = "/sdcard/" + Globals.class.getPackage().getName();
outFilesDir = "/sdcard/app-data/" + Globals.class.getPackage().getName();
this.start();
}