Alien Blaster compiles and works with new SDL 1.3, but the alpha channel fails for SDL_Texture (is that an SDL bug?)
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
#include "global.h"
|
||||
#include "surfaceDB.h"
|
||||
#include <android/log.h>
|
||||
#include <SDL_image.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -36,6 +37,8 @@ Video::~Video(){
|
||||
// kill something
|
||||
}
|
||||
|
||||
SDL_Renderer * SDL_global_renderer = NULL;
|
||||
|
||||
SdlCompat_AcceleratedSurface *Video::init(){
|
||||
// --------------------------------------------------
|
||||
// SDL initialisation
|
||||
@@ -48,28 +51,41 @@ SdlCompat_AcceleratedSurface *Video::init(){
|
||||
__android_log_print(ANDROID_LOG_ERROR, "Alien Blaster", "Couldn't initialize SDL video subsystem: %s\n", SDL_GetError());
|
||||
exit(1);
|
||||
}
|
||||
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||
// SDL_VideoInit(NULL);
|
||||
SDL_Window * window = SDL_CreateWindow("Alien Blaster", 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_BORDERLESS | SDL_WINDOW_SHOWN | SDL_WINDOW_INPUT_GRABBED);
|
||||
if (!window) {
|
||||
__android_log_print(ANDROID_LOG_ERROR, "Alien Blaster", "SDL_CreateWindow() failed: %s", SDL_GetError());
|
||||
exit(1);
|
||||
}
|
||||
__android_log_print(ANDROID_LOG_INFO, "Alien Blaster", "SDL_CreateWindow() ret %p", window);
|
||||
SDL_global_renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
|
||||
if (!SDL_global_renderer) {
|
||||
__android_log_print(ANDROID_LOG_ERROR, "Alien Blaster", "SDL_CreateRenderer() ret %p", SDL_global_renderer);
|
||||
exit(1);
|
||||
}
|
||||
__android_log_print(ANDROID_LOG_INFO, "Alien Blaster", "SDL_CreateRenderer() ret %p", SDL_global_renderer);
|
||||
// Dummy texture
|
||||
__android_log_print(ANDROID_LOG_INFO, "Alien Blaster", "Creating dummy video surface");
|
||||
SDL_Surface *screen2 = IMG_Load( "images/bomber.png" );
|
||||
__android_log_print(ANDROID_LOG_INFO, "Alien Blaster", "Creating dummy video surface 2");
|
||||
screen = SdlCompat_CreateAcceleratedSurface(screen2);
|
||||
screen->w = SCREEN_WIDTH;
|
||||
screen->h = SCREEN_HEIGHT;
|
||||
SDL_FreeSurface(screen2);
|
||||
__android_log_print(ANDROID_LOG_INFO, "Alien Blaster", "video init done");
|
||||
#else
|
||||
SDL_Surface * screen2 = SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, BIT_DEPTH, SDL_DOUBLEBUF | SDL_HWSURFACE );
|
||||
if (!screen2) {
|
||||
printf("Couldn't set %dx%d, %dbit video mode: %s\n", SCREEN_WIDTH, SCREEN_HEIGHT, BIT_DEPTH, SDL_GetError());
|
||||
__android_log_print(ANDROID_LOG_ERROR, "Alien Blaster", "Couldn't set %dx%d, %dbit video mode: %s\n", SCREEN_WIDTH, SCREEN_HEIGHT, BIT_DEPTH, SDL_GetError());
|
||||
exit(2);
|
||||
}
|
||||
#if SDL_VERSION_ATLEAST(1,3,0)
|
||||
// Dummy texture
|
||||
screen2 = SDL_CreateRGBSurface( 0, 16, 16, 16, 0xff, 0x00ff, 0x0000ff, 0 );
|
||||
SDL_Surface * screen3 = SDL_DisplayFormat( screen2 );
|
||||
SDL_FreeSurface(screen2);
|
||||
screen = SdlCompat_CreateAcceleratedSurface(screen3);
|
||||
screen->w = SCREEN_WIDTH;
|
||||
screen->h = SCREEN_HEIGHT;
|
||||
SDL_FreeSurface(screen3);
|
||||
#else
|
||||
screen = screen2;
|
||||
#endif
|
||||
SDL_WM_SetCaption("AlienBlaster", "AlienBlaster");
|
||||
SDL_WM_SetIcon(SDL_LoadBMP( FN_ALIENBLASTER_ICON.c_str() ), NULL);
|
||||
SDL_ShowCursor(SDL_DISABLE);
|
||||
|
||||
#endif
|
||||
__android_log_print(ANDROID_LOG_INFO, "Alien Blaster", "Initializing video done");
|
||||
|
||||
return screen;
|
||||
|
||||
Reference in New Issue
Block a user