Fixed video init
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
#include "SDL.h"
|
||||
#include <stdlib.h>
|
||||
#include "global.h"
|
||||
#include <android/log.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -38,16 +39,21 @@ SDL_Surface *Video::init(){
|
||||
// --------------------------------------------------
|
||||
// SDL initialisation
|
||||
// -----------------------------------------------------
|
||||
__android_log_print(ANDROID_LOG_INFO, "Alien Blaster", "SDL_InitSubSystem(SDL_INIT_VIDEO)");
|
||||
|
||||
fullscreen = false;
|
||||
if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0) {
|
||||
__android_log_print(ANDROID_LOG_INFO, "Alien Blaster", "Couldn't initialize SDL video subsystem: %s\n", SDL_GetError());
|
||||
printf("Couldn't initialize SDL video subsystem: %s\n", SDL_GetError());
|
||||
exit(1);
|
||||
}
|
||||
screen = SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, BIT_DEPTH, SDL_DOUBLEBUF /* | SDL_FULLSCREEN */ );
|
||||
if (!screen) {
|
||||
__android_log_print(ANDROID_LOG_INFO, "Alien Blaster", "Couldn't set %dx%d, %dbit video mode: %s\n", SCREEN_WIDTH, SCREEN_HEIGHT, BIT_DEPTH, SDL_GetError());
|
||||
printf("Couldn't set %dx%d, %dbit video mode: %s\n", SCREEN_WIDTH, SCREEN_HEIGHT, BIT_DEPTH, SDL_GetError());
|
||||
exit(2);
|
||||
}
|
||||
__android_log_print(ANDROID_LOG_INFO, "Alien Blaster", "Video initialized");
|
||||
|
||||
SDL_WM_SetCaption("AlienBlaster", "AlienBlaster");
|
||||
SDL_WM_SetIcon(SDL_LoadBMP( FN_ALIENBLASTER_ICON.c_str() ), NULL);
|
||||
|
||||
@@ -31,7 +31,6 @@ SDL_SRCS := \
|
||||
src/thread/pthread/*.c \
|
||||
src/timer/unix/*.c \
|
||||
src/audio/android/*.c \
|
||||
src/audio/dummy/*.c \
|
||||
src/video/android/*.c \
|
||||
src/joystick/dummy/*.c \
|
||||
src/haptic/dummy/*.c \
|
||||
|
||||
@@ -35,8 +35,7 @@
|
||||
#define SDL_VIDEO_OPENGL_ES 1
|
||||
#define SDL_VIDEO_RENDER_OGL_ES 1
|
||||
|
||||
// #define SDL_AUDIO_DRIVER_ANDROID 1
|
||||
#define SDL_AUDIO_DRIVER_DUMMY 1 // TODO: fix audio and remove that
|
||||
#define SDL_AUDIO_DRIVER_ANDROID 1
|
||||
|
||||
#define SDL_CDROM_DISABLED 1
|
||||
|
||||
|
||||
@@ -115,6 +115,8 @@ static SDL_VideoDevice *ANDROID_CreateDevice(int devindex)
|
||||
device->GL_MakeCurrent = ANDROID_GL_MakeCurrent;
|
||||
device->GL_DeleteContext = ANDROID_GL_DeleteContext;
|
||||
|
||||
__android_log_print(ANDROID_LOG_INFO, "libSDL", "ANDROID_CreateDevice() called");
|
||||
|
||||
return device;
|
||||
}
|
||||
|
||||
@@ -126,7 +128,22 @@ VideoBootStrap ANDROID_bootstrap = {
|
||||
|
||||
int ANDROID_VideoInit(_THIS)
|
||||
{
|
||||
return 0;
|
||||
SDL_VideoDisplay display;
|
||||
SDL_DisplayMode mode;
|
||||
|
||||
mode.w = sWindowWidth;
|
||||
mode.h = sWindowHeight;
|
||||
mode.refresh_rate = 0;
|
||||
mode.format = SDL_PIXELFORMAT_BGR565; // SDL_PIXELFORMAT_RGB565;
|
||||
mode.driverdata = NULL;
|
||||
|
||||
SDL_zero(display);
|
||||
display.desktop_mode = mode;
|
||||
display.current_mode = mode;
|
||||
display.driverdata = NULL;
|
||||
SDL_AddVideoDisplay(&display);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -135,11 +152,11 @@ void ANDROID_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
|
||||
SDL_DisplayMode mode;
|
||||
mode.w = sWindowWidth;
|
||||
mode.h = sWindowHeight;
|
||||
mode.refresh_rate = 30;
|
||||
mode.format = SDL_PIXELFORMAT_RGB565;
|
||||
mode.refresh_rate = 0;
|
||||
mode.format = SDL_PIXELFORMAT_BGR565; // SDL_PIXELFORMAT_RGB565;
|
||||
mode.driverdata = NULL;
|
||||
SDL_AddDisplayMode(display, &mode);
|
||||
|
||||
|
||||
/*
|
||||
struct compatModes_t { int x, int y } compatModes[] =
|
||||
{ {800, 600}, {640, 480}, {320, 240}, {320, 200} };
|
||||
@@ -158,12 +175,12 @@ int ANDROID_GetDisplayBounds(_THIS, SDL_VideoDisplay * display, SDL_Rect * rect)
|
||||
{
|
||||
rect->w = sWindowWidth;
|
||||
rect->h = sWindowHeight;
|
||||
return 0;
|
||||
return 1;
|
||||
};
|
||||
|
||||
int ANDROID_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
|
||||
{
|
||||
return 0;
|
||||
return 1;
|
||||
};
|
||||
|
||||
|
||||
@@ -185,11 +202,11 @@ void ANDROID_GL_SwapBuffers(_THIS, SDL_Window * window)
|
||||
|
||||
SDL_GLContext ANDROID_GL_CreateContext(_THIS, SDL_Window * window)
|
||||
{
|
||||
return (1);
|
||||
return (SDL_GLContext)1;
|
||||
};
|
||||
int ANDROID_GL_MakeCurrent (_THIS, SDL_Window * window, SDL_GLContext context)
|
||||
{
|
||||
return 0;
|
||||
return 1;
|
||||
};
|
||||
void ANDROID_GL_DeleteContext (_THIS, SDL_GLContext context)
|
||||
{
|
||||
@@ -231,6 +248,7 @@ JAVA_EXPORT_NAME(DemoRenderer_nativeInitJavaCallbacks) ( JNIEnv* env, jobject t
|
||||
JavaSwapBuffers = (*JavaEnv)->GetMethodID(JavaEnv, JavaRendererClass, "swapBuffers", "()I");
|
||||
|
||||
ANDROID_InitOSKeymap();
|
||||
|
||||
}
|
||||
|
||||
int CallJavaSwapBuffers()
|
||||
|
||||
Reference in New Issue
Block a user