Trabajando en el escalado entero y el tamaño personalizable de la ventana de renderizado a traves de las opciones
This commit is contained in:
@@ -2,18 +2,33 @@
|
||||
#include "const.h"
|
||||
|
||||
// Constructor
|
||||
Screen::Screen(SDL_Window *window, SDL_Renderer *renderer)
|
||||
Screen::Screen(SDL_Window *window, SDL_Renderer *renderer, int screenWidth, int screenHeight, bool integerScale)
|
||||
{
|
||||
// Inicializa variables
|
||||
mWindow = window;
|
||||
mRenderer = renderer;
|
||||
|
||||
mScreenWidth = REAL_SCREEN_WIDTH;
|
||||
mScreenHeight = REAL_SCREEN_HEIGHT;
|
||||
mScreenWidth = screenWidth;
|
||||
mScreenHeight = screenHeight;
|
||||
mGameCanvasWidth = SCREEN_WIDTH;
|
||||
mGameCanvasHeight = SCREEN_HEIGHT;
|
||||
mGameCanvasPosX = (mScreenWidth - mGameCanvasWidth) / 2;
|
||||
mGameCanvasPosY = (mScreenHeight - mGameCanvasHeight) / 2;
|
||||
mIntegerScale = integerScale;
|
||||
|
||||
// Calcula el tamaño de la escala máxima
|
||||
mScale = 0;
|
||||
int width = mGameCanvasWidth;
|
||||
int height = mGameCanvasHeight;
|
||||
while (((width * (mScale + 1)) < mScreenWidth) && ((height * (mScale + 1)) < mScreenHeight))
|
||||
{
|
||||
mScale++;
|
||||
}
|
||||
|
||||
width = width * mScale;
|
||||
height = height * mScale;
|
||||
mGameCanvasPosX = (mScreenWidth - width) / 2;
|
||||
mGameCanvasPosY = (mScreenHeight - height) / 2;
|
||||
|
||||
mBorderColor = {0x27, 0x27, 0x36};
|
||||
mBorderColor = {0x00, 0x00, 0x00};
|
||||
@@ -54,7 +69,7 @@ void Screen::blit()
|
||||
SDL_RenderClear(mRenderer);
|
||||
|
||||
// Rectangulo de destino donde se dibujarà la textura con el juego
|
||||
SDL_Rect dest = {mGameCanvasPosX, mGameCanvasPosY, mGameCanvasWidth, mGameCanvasHeight};
|
||||
SDL_Rect dest = {mGameCanvasPosX, mGameCanvasPosY, mGameCanvasWidth*mScale, mGameCanvasHeight*mScale};
|
||||
|
||||
// Copia la textura de juego en el renderizador en la posición adecuada
|
||||
SDL_RenderCopy(mRenderer, mGameCanvas, NULL, &dest);
|
||||
|
||||
Reference in New Issue
Block a user