Still working on the BIG FUCKING CONVERSION...

This commit is contained in:
2021-05-10 18:53:31 +02:00
parent 717c5715e9
commit 2ad5241005
21 changed files with 134 additions and 143 deletions

View File

@@ -4,38 +4,31 @@
#include "SDL2/SDL_image.h"
SDL_Window *sdlWindow = NULL;
SDL_Renderer *sdlRenderer = NULL;
DrawManager::DrawManager(int pMode)
{
DrawManager::DrawManager(int pMode) {
mode = pMode;
screen = NULL;
screenBig = NULL;
}
DrawManager::~DrawManager(void)
{
DrawManager::~DrawManager(void) {
SDL_FreeSurface(temp);
SDL_FreeSurface(black);
SDL_FreeSurface(faded);
SDL_DestroyRenderer(sdlRenderer);
SDL_DestroyWindow(sdlWindow);
}
bool DrawManager::Init(void)
{
switch (mode) {
case 1:
screenBig = SDL_SetVideoMode( SCREEN_WIDTH<<1, SCREEN_HEIGHT<<1, SCREEN_BPP, SDL_SWSURFACE );
if( screenBig == NULL ) { return false; }
screen = LoadBitmap("black.gif");
break;
case 2:
screen = SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, SDL_FULLSCREEN );
if( screen == NULL ) { return false; }
break;
default:
screen = SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, SDL_SWSURFACE );
if( screen == NULL ) { return false; }
break;
}
bool DrawManager::Init(void) {
sdlWindow = SDL_CreateWindow(APPLICATION_NAME, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, SDL_WINDOW_SHOWN);
sdlRenderer = SDL_CreateRenderer(sdlWindow, -1, 0);
SDL_RenderSetLogicalSize(sdlRenderer, 320, 240);
SDL_ShowCursor(0);
color_blanco = -1;
color_rojo = SDL_MapRGB( screen->format, 255, 0, 0 );
color_verde = SDL_MapRGB( screen->format, 0, 255, 0 );
@@ -50,34 +43,15 @@ bool DrawManager::Init(void)
bool DrawManager::Flip(void)
{
if (mode == 1) {
for (int x=0; x<320; x++) {
for (int y=0; y<200; y++) {
put_pixel32(screenBig, x<<1 , y<<1 , get_pixel32(screen, x, y));
put_pixel32(screenBig, (x<<1)+1, y<<1 , get_pixel32(screen, x, y));
put_pixel32(screenBig, x<<1 , (y<<1)+1, get_pixel32(screen, x, y));
put_pixel32(screenBig, (x<<1)+1, (y<<1)+1, get_pixel32(screen, x, y));
}
}
if (SDL_Flip( screenBig ) == -1 ) {
return true;
} else {
return false;
}
} else {
if (SDL_Flip( screen ) == -1 ) {
return true;
} else {
return false;
}
}
SDL_RenderPresent(sdlRenderer);
return true;
}
SDL_Surface *DrawManager::LoadBitmap(char *bitmapfilename, bool doColorKey)
SDL_Surface *DrawManager::LoadBitmap(const char *bitmapfilename, const bool doColorKey)
{
//Get the bitmap's buffer and size from the resource file
int filesize = 0;
char *buffer = GetBufferFromResource(bitmapfilename, &filesize);
const char *buffer = file_getBufferFromResource(bitmapfilename, filesize);
//Load the buffer into a surface using RWops
SDL_RWops *rw = SDL_RWFromMem(buffer, filesize);
@@ -111,11 +85,11 @@ SDL_Surface *DrawManager::LoadBitmap(char *bitmapfilename, bool doColorKey)
}
SDL_Surface *DrawManager::LoadMask(char *bitmapfilename)
SDL_Surface *DrawManager::LoadMask(const char *bitmapfilename)
{
//Get the bitmap's buffer and size from the resource file
int filesize = 0;
char *buffer = GetBufferFromResource(bitmapfilename, &filesize);
const char *buffer = file_getBufferFromResource(bitmapfilename, filesize);
//Load the buffer into a surface using RWops
SDL_RWops *rw = SDL_RWFromMem(buffer, filesize);
@@ -162,7 +136,7 @@ void DrawManager::Blit( int x, int y, SDL_Surface* source, SDL_Rect* clip )
apply_surface(x, y, source, screen, clip);
}
void DrawManager::Print( int x, int y, SDL_Surface* source, int w, int h, char *text, SDL_Surface *dest ) {
void DrawManager::Print( int x, int y, SDL_Surface* source, int w, int h, const char *text, SDL_Surface *dest ) {
int index = 0;
SDL_Rect clip;
@@ -273,7 +247,7 @@ void DrawManager::DrawFadedBack() {
Blit(0,0, faded);
}
SDL_Surface *DrawManager::LoadFont(char *bitmapfilename, Uint32 color)
SDL_Surface *DrawManager::LoadFont(const char *bitmapfilename, const Uint32 color)
{
if (color == 0xFFFFFFFF) {
return LoadBitmap(bitmapfilename, true);