Compare commits
4 Commits
3119e02d2c
...
78a689760d
| Author | SHA1 | Date | |
|---|---|---|---|
| 78a689760d | |||
| abb0151560 | |||
| b770bdb7d1 | |||
| d36f3539cc |
2
Makefile
2
Makefile
@@ -118,7 +118,7 @@ print-variables:
|
|||||||
@echo RM: $(RM)
|
@echo RM: $(RM)
|
||||||
|
|
||||||
raspi3:
|
raspi3:
|
||||||
$(CXX) $(SOURCES) -D RASPI $(CXXFLAGS) -lSDL2 -o $(TARGET_FILE)
|
$(CXX) $(SOURCES) -D NO_SHADERS $(CXXFLAGS) -lSDL2 -o $(TARGET_FILE)
|
||||||
strip -s -R .comment -R .gnu.version $(TARGET_FILE) --strip-unneeded
|
strip -s -R .comment -R .gnu.version $(TARGET_FILE) --strip-unneeded
|
||||||
|
|
||||||
raspi5:
|
raspi5:
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#ifndef RASPI
|
#ifndef NO_SHADERS
|
||||||
#include "jshader.h"
|
#include "jshader.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#ifndef RASPI
|
#ifndef NO_SHADERS
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <streambuf>
|
#include <streambuf>
|
||||||
#ifndef RASPI
|
#ifndef NO_SHADERS
|
||||||
#include "jshader.h"
|
#include "jshader.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -81,7 +81,7 @@ void Screen::blit()
|
|||||||
// Atenua la pantalla
|
// Atenua la pantalla
|
||||||
doAttenuate();
|
doAttenuate();
|
||||||
|
|
||||||
#ifdef RASPI
|
#ifdef NO_SHADERS
|
||||||
// Vuelve a dejar el renderizador en modo normal
|
// Vuelve a dejar el renderizador en modo normal
|
||||||
SDL_SetRenderTarget(renderer, nullptr);
|
SDL_SetRenderTarget(renderer, nullptr);
|
||||||
|
|
||||||
@@ -120,18 +120,15 @@ void Screen::blit()
|
|||||||
// Establece el modo de video
|
// Establece el modo de video
|
||||||
void Screen::setVideoMode(int videoMode)
|
void Screen::setVideoMode(int videoMode)
|
||||||
{
|
{
|
||||||
// Aplica el modo de video
|
|
||||||
SDL_SetWindowFullscreen(window, videoMode);
|
|
||||||
|
|
||||||
// Si está activo el modo ventana quita el borde
|
// Si está activo el modo ventana quita el borde
|
||||||
if (videoMode == 0)
|
if (videoMode == VIDEO_MODE_WINDOW)
|
||||||
{
|
{
|
||||||
|
// Aplica el modo de video
|
||||||
|
SDL_SetWindowFullscreen(window, 0);
|
||||||
|
|
||||||
// Muestra el puntero
|
// Muestra el puntero
|
||||||
SDL_ShowCursor(SDL_ENABLE);
|
SDL_ShowCursor(SDL_ENABLE);
|
||||||
|
|
||||||
// Esconde la ventana
|
|
||||||
// SDL_HideWindow(window);
|
|
||||||
|
|
||||||
if (options->video.border.enabled)
|
if (options->video.border.enabled)
|
||||||
{
|
{
|
||||||
windowWidth = gameCanvasWidth + borderWidth;
|
windowWidth = gameCanvasWidth + borderWidth;
|
||||||
@@ -152,8 +149,11 @@ void Screen::setVideoMode(int videoMode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Si está activo el modo de pantalla completa añade el borde
|
// Si está activo el modo de pantalla completa añade el borde
|
||||||
else if (videoMode == SDL_WINDOW_FULLSCREEN_DESKTOP)
|
else if (videoMode == VIDEO_MODE_FULLSCREEN)
|
||||||
{
|
{
|
||||||
|
// Aplica el modo de video
|
||||||
|
SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN);
|
||||||
|
|
||||||
// Oculta el puntero
|
// Oculta el puntero
|
||||||
SDL_ShowCursor(SDL_DISABLE);
|
SDL_ShowCursor(SDL_DISABLE);
|
||||||
|
|
||||||
@@ -201,7 +201,7 @@ void Screen::setVideoMode(int videoMode)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef RASPI
|
#ifdef NO_SHADERS
|
||||||
SDL_RenderSetLogicalSize(renderer, windowWidth, windowHeight);
|
SDL_RenderSetLogicalSize(renderer, windowWidth, windowHeight);
|
||||||
#else
|
#else
|
||||||
// Reinicia los shaders
|
// Reinicia los shaders
|
||||||
@@ -232,7 +232,7 @@ void Screen::setVideoMode(int videoMode)
|
|||||||
// Camibia entre pantalla completa y ventana
|
// Camibia entre pantalla completa y ventana
|
||||||
void Screen::switchVideoMode()
|
void Screen::switchVideoMode()
|
||||||
{
|
{
|
||||||
options->video.mode = (options->video.mode == 0) ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0;
|
options->video.mode = (options->video.mode == VIDEO_MODE_WINDOW) ? VIDEO_MODE_FULLSCREEN : VIDEO_MODE_WINDOW;
|
||||||
setVideoMode(options->video.mode);
|
setVideoMode(options->video.mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,7 +240,7 @@ void Screen::switchVideoMode()
|
|||||||
void Screen::setWindowSize(int size)
|
void Screen::setWindowSize(int size)
|
||||||
{
|
{
|
||||||
options->video.window.size = size;
|
options->video.window.size = size;
|
||||||
setVideoMode(0);
|
setVideoMode(VIDEO_MODE_WINDOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reduce el tamaño de la ventana
|
// Reduce el tamaño de la ventana
|
||||||
@@ -248,7 +248,7 @@ void Screen::decWindowSize()
|
|||||||
{
|
{
|
||||||
--options->video.window.size;
|
--options->video.window.size;
|
||||||
options->video.window.size = std::max(options->video.window.size, 1);
|
options->video.window.size = std::max(options->video.window.size, 1);
|
||||||
setVideoMode(0);
|
setVideoMode(VIDEO_MODE_WINDOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Aumenta el tamaño de la ventana
|
// Aumenta el tamaño de la ventana
|
||||||
@@ -256,7 +256,7 @@ void Screen::incWindowSize()
|
|||||||
{
|
{
|
||||||
++options->video.window.size;
|
++options->video.window.size;
|
||||||
options->video.window.size = std::min(options->video.window.size, 4);
|
options->video.window.size = std::min(options->video.window.size, 4);
|
||||||
setVideoMode(0);
|
setVideoMode(VIDEO_MODE_WINDOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cambia el color del borde
|
// Cambia el color del borde
|
||||||
@@ -293,7 +293,7 @@ void Screen::setBorderEnabled(bool value)
|
|||||||
void Screen::switchBorder()
|
void Screen::switchBorder()
|
||||||
{
|
{
|
||||||
options->video.border.enabled = !options->video.border.enabled;
|
options->video.border.enabled = !options->video.border.enabled;
|
||||||
setVideoMode(0);
|
setVideoMode(VIDEO_MODE_WINDOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Activa el fade
|
// Activa el fade
|
||||||
|
|||||||
@@ -13,6 +13,9 @@
|
|||||||
#define FILTER_NEAREST 0
|
#define FILTER_NEAREST 0
|
||||||
#define FILTER_LINEAL 1
|
#define FILTER_LINEAL 1
|
||||||
|
|
||||||
|
#define VIDEO_MODE_WINDOW 0
|
||||||
|
#define VIDEO_MODE_FULLSCREEN 1
|
||||||
|
|
||||||
class Screen
|
class Screen
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -192,15 +192,14 @@ bool Director::initSDL()
|
|||||||
std::cout << "Warning: texture filtering not enabled!\n";
|
std::cout << "Warning: texture filtering not enabled!\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifndef RASPI
|
#ifndef NO_SHADERS
|
||||||
if (options->video.shaders)
|
if (!SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengl"))
|
||||||
if (!SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengl"))
|
{
|
||||||
|
if (options->console)
|
||||||
{
|
{
|
||||||
if (options->console)
|
std::cout << "Warning: opengl not enabled!\n";
|
||||||
{
|
|
||||||
std::cout << "Warning: opengl not enabled!\n";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
// Crea la ventana
|
// Crea la ventana
|
||||||
int incW = 0;
|
int incW = 0;
|
||||||
@@ -227,12 +226,9 @@ bool Director::initSDL()
|
|||||||
{
|
{
|
||||||
flags = flags | SDL_RENDERER_PRESENTVSYNC;
|
flags = flags | SDL_RENDERER_PRESENTVSYNC;
|
||||||
}
|
}
|
||||||
#ifndef RASPI
|
#ifndef NO_SHADERS
|
||||||
// La aceleración se activa según las opciones
|
// La aceleración se activa según el define
|
||||||
if (options->video.shaders || true)
|
flags = flags | SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE;
|
||||||
{
|
|
||||||
flags = flags | SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
renderer = SDL_CreateRenderer(window, -1, flags);
|
renderer = SDL_CreateRenderer(window, -1, flags);
|
||||||
|
|
||||||
@@ -619,28 +615,23 @@ bool Director::saveConfigFile()
|
|||||||
|
|
||||||
// Opciones de video
|
// Opciones de video
|
||||||
file << "## VIDEO\n";
|
file << "## VIDEO\n";
|
||||||
file << "## video.mode [0, SDL_WINDOW_FULLSCREEN, SDL_WINDOW_FULLSCREEN_DESKTOP]\n";
|
file << "## video.mode [0: window, 1: full screen]\n";
|
||||||
file << "## video.filter [FILTER_NEAREST, FILTER_LINEAL]\n";
|
file << "## video.filter [0: nearest, 1: lineal]\n";
|
||||||
file << "\n";
|
file << "\n";
|
||||||
|
|
||||||
if (options->video.mode == 0)
|
if (options->video.mode == VIDEO_MODE_WINDOW)
|
||||||
{
|
{
|
||||||
file << "video.mode=0\n";
|
file << "video.mode=0\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (options->video.mode == SDL_WINDOW_FULLSCREEN)
|
else if (options->video.mode == VIDEO_MODE_FULLSCREEN)
|
||||||
{
|
{
|
||||||
file << "video.mode=SDL_WINDOW_FULLSCREEN\n";
|
file << "video.mode=1\n";
|
||||||
}
|
|
||||||
|
|
||||||
else if (options->video.mode == SDL_WINDOW_FULLSCREEN_DESKTOP)
|
|
||||||
{
|
|
||||||
file << "video.mode=SDL_WINDOW_FULLSCREEN_DESKTOP\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
file << "video.window.size=" + std::to_string(options->video.window.size) + "\n";
|
file << "video.window.size=" + std::to_string(options->video.window.size) + "\n";
|
||||||
|
|
||||||
options->video.filter == FILTER_NEAREST ? file << "video.filter=FILTER_NEAREST\n" : file << "video.filter=FILTER_LINEAL\n";
|
options->video.filter == FILTER_NEAREST ? file << "video.filter=0\n" : file << "video.filter=1\n";
|
||||||
|
|
||||||
file << "video.shaders=" + boolToString(options->video.shaders) + "\n";
|
file << "video.shaders=" + boolToString(options->video.shaders) + "\n";
|
||||||
file << "video.vSync=" + boolToString(options->video.vSync) + "\n";
|
file << "video.vSync=" + boolToString(options->video.vSync) + "\n";
|
||||||
@@ -835,17 +826,13 @@ bool Director::setOptions(options_t *options, std::string var, std::string value
|
|||||||
// Opciones de video
|
// Opciones de video
|
||||||
if (var == "video.mode")
|
if (var == "video.mode")
|
||||||
{
|
{
|
||||||
if (value == "SDL_WINDOW_FULLSCREEN_DESKTOP")
|
if (value == "0")
|
||||||
{
|
{
|
||||||
options->video.mode = SDL_WINDOW_FULLSCREEN_DESKTOP;
|
options->video.mode = VIDEO_MODE_WINDOW;
|
||||||
}
|
|
||||||
else if (value == "SDL_WINDOW_FULLSCREEN")
|
|
||||||
{
|
|
||||||
options->video.mode = SDL_WINDOW_FULLSCREEN;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
options->video.mode = 0;
|
options->video.mode = VIDEO_MODE_FULLSCREEN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -860,13 +847,13 @@ bool Director::setOptions(options_t *options, std::string var, std::string value
|
|||||||
|
|
||||||
else if (var == "video.filter")
|
else if (var == "video.filter")
|
||||||
{
|
{
|
||||||
if (value == "FILTER_LINEAL")
|
if (value == "0")
|
||||||
{
|
{
|
||||||
options->video.filter = FILTER_LINEAL;
|
options->video.filter = FILTER_NEAREST;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
options->video.filter = FILTER_NEAREST;
|
options->video.filter = FILTER_LINEAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3224,7 +3224,10 @@ void Game::checkEvents()
|
|||||||
{
|
{
|
||||||
if (eventHandler->window.event == SDL_WINDOWEVENT_FOCUS_LOST)
|
if (eventHandler->window.event == SDL_WINDOWEVENT_FOCUS_LOST)
|
||||||
{
|
{
|
||||||
pause(true);
|
if (!demo.enabled)
|
||||||
|
{
|
||||||
|
pause(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (eventHandler->window.event == SDL_WINDOWEVENT_FOCUS_GAINED)
|
if (eventHandler->window.event == SDL_WINDOWEVENT_FOCUS_GAINED)
|
||||||
|
|||||||
Reference in New Issue
Block a user