El soporte para Linux está cerca...
Se ha actualizado premake5 para que soporte VS22 y se ha añadido para linux. Modificada la configuración de premake para crear los makefiles correctamente en sistemas linux. Modificados todos los include para ser compatibles con linux (cambiar la barrita \ por / ). Adiciones al .gitignore para ignorar archivos de .make .
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
#Directorios:
|
#Directorios:
|
||||||
.vs
|
.vs
|
||||||
|
.vscode
|
||||||
bin/
|
bin/
|
||||||
bin-obj/
|
bin-obj/
|
||||||
|
|
||||||
@@ -9,3 +10,5 @@ imgui.ini
|
|||||||
*.vcxproj
|
*.vcxproj
|
||||||
*.filters
|
*.filters
|
||||||
*.sln
|
*.sln
|
||||||
|
*.make
|
||||||
|
Makefile
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
premake/premake5 gmake2
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <json\json.hpp>
|
#include <json/json.hpp>
|
||||||
using json = nlohmann::ordered_json;
|
using json = nlohmann::ordered_json;
|
||||||
|
|
||||||
#include <SDL_rect.h>
|
#include <SDL_rect.h>
|
||||||
@@ -33,7 +33,7 @@ namespace UE
|
|||||||
AssetType _type = AssetType::Unvalid;
|
AssetType _type = AssetType::Unvalid;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Conversión de una struct Asset a JSON */
|
/* Conversi�n de una struct Asset a JSON */
|
||||||
inline void to_json(nlohmann::ordered_json& j, const Asset& as)
|
inline void to_json(nlohmann::ordered_json& j, const Asset& as)
|
||||||
{
|
{
|
||||||
j = nlohmann::ordered_json
|
j = nlohmann::ordered_json
|
||||||
@@ -44,7 +44,7 @@ namespace UE
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Conversión de un JSON a una struct Asset */
|
/* Conversi�n de un JSON a una struct Asset */
|
||||||
inline void from_json(const nlohmann::ordered_json& j, Asset& as)
|
inline void from_json(const nlohmann::ordered_json& j, Asset& as)
|
||||||
{
|
{
|
||||||
j.at("name").get_to(as._name);
|
j.at("name").get_to(as._name);
|
||||||
@@ -56,10 +56,10 @@ namespace UE
|
|||||||
|
|
||||||
//---------------
|
//---------------
|
||||||
//Es necesario hacerlo fuera del namespace UE para que JSON no se enfade.
|
//Es necesario hacerlo fuera del namespace UE para que JSON no se enfade.
|
||||||
// Es importante mantener a tus librerías contentas.
|
// Es importante mantener a tus librer�as contentas.
|
||||||
//---------------
|
//---------------
|
||||||
|
|
||||||
/* Conversión de un Struct SDL_Rect a JSON */
|
/* Conversi�n de un Struct SDL_Rect a JSON */
|
||||||
inline void to_json(nlohmann::ordered_json& j, const SDL_Rect& rect)
|
inline void to_json(nlohmann::ordered_json& j, const SDL_Rect& rect)
|
||||||
{
|
{
|
||||||
j = nlohmann::ordered_json
|
j = nlohmann::ordered_json
|
||||||
@@ -71,7 +71,7 @@ inline void to_json(nlohmann::ordered_json& j, const SDL_Rect& rect)
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Conversión de un JSON a un struct SDL_Rect */
|
/* Conversi�n de un JSON a un struct SDL_Rect */
|
||||||
inline void from_json(const nlohmann::ordered_json& j, SDL_Rect& rect)
|
inline void from_json(const nlohmann::ordered_json& j, SDL_Rect& rect)
|
||||||
{
|
{
|
||||||
j.at("posX").get_to(rect.x);
|
j.at("posX").get_to(rect.x);
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include "Logging\Logger.h"
|
#include "Logging/Logger.h"
|
||||||
#include "Assets\AssetManager.h"
|
#include "Assets/AssetManager.h"
|
||||||
|
|
||||||
|
|
||||||
#include "SDL_rect.h"
|
#include "SDL_rect.h"
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
/*STD Includes*/
|
/*STD Includes*/
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <deque>
|
#include <deque>
|
||||||
@@ -13,9 +11,10 @@
|
|||||||
#include <SDL_image.h>
|
#include <SDL_image.h>
|
||||||
|
|
||||||
/*UberEngine Includes*/
|
/*UberEngine Includes*/
|
||||||
#include "Assets\Asset.h"
|
//#include "Assets\Asset.h"
|
||||||
#include "Assets\Texture.h"
|
#include "Assets/Texture.h"
|
||||||
#include "Assets\Font.h"
|
#include "Assets/Font.h"
|
||||||
|
#include "Assets/Asset.h"
|
||||||
|
|
||||||
using json = nlohmann::ordered_json;
|
using json = nlohmann::ordered_json;
|
||||||
|
|
||||||
@@ -24,9 +23,9 @@ using json = nlohmann::ordered_json;
|
|||||||
/// TODO:
|
/// TODO:
|
||||||
/// - Modificar las funciones de Carga para quitar la queue o implementar una que tenga sentido.
|
/// - Modificar las funciones de Carga para quitar la queue o implementar una que tenga sentido.
|
||||||
/// Por ejemplo, se puede crear una cola (std::deque) y cargar un asset cada gameLoop en vez de
|
/// Por ejemplo, se puede crear una cola (std::deque) y cargar un asset cada gameLoop en vez de
|
||||||
/// procesar toda la cola de golpe. Optimizaría la carga de assets.
|
/// procesar toda la cola de golpe. Optimizar�a la carga de assets.
|
||||||
/// - Terminar la implementación del tipo de carga (queue/now).
|
/// - Terminar la implementaci�n del tipo de carga (queue/now).
|
||||||
/// - Modificar los for en la carga de archivo, así como la estructura del archivo JSON. El tipo de Asset está repetido.
|
/// - Modificar los for en la carga de archivo, as� como la estructura del archivo JSON. El tipo de Asset est� repetido.
|
||||||
/// - Logging.
|
/// - Logging.
|
||||||
/// - ERROR HANDLING
|
/// - ERROR HANDLING
|
||||||
/// - More asset types.
|
/// - More asset types.
|
||||||
@@ -61,19 +60,19 @@ namespace UE
|
|||||||
/* Carga de Assets */
|
/* Carga de Assets */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Carga los datos de los Assets desde un fichero JSON según parámetros.
|
* Carga los datos de los Assets desde un fichero JSON seg�n par�metros.
|
||||||
*
|
*
|
||||||
* \param filePath: Ubicación del archivo JSON.
|
* \param filePath: Ubicaci�n del archivo JSON.
|
||||||
* \param loadMethod: Forma de carga. Procesado al momento o añadido a la cola de carga.
|
* \param loadMethod: Forma de carga. Procesado al momento o a�adido a la cola de carga.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void LoadAssetsFromFile(std::string filePath);
|
void LoadAssetsFromFile(std::string filePath);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Carga el Asset pasado por parámetro.
|
* Carga el Asset pasado por par�metro.
|
||||||
*
|
*
|
||||||
* \param as: Asset que cargar.
|
* \param as: Asset que cargar.
|
||||||
* \param loadMethod: Forma de carga. Procesado al momento o añadido a la cola de carga.
|
* \param loadMethod: Forma de carga. Procesado al momento o a�adido a la cola de carga.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void LoadAsset(Asset& as);
|
void LoadAsset(Asset& as);
|
||||||
@@ -82,7 +81,7 @@ namespace UE
|
|||||||
/**
|
/**
|
||||||
* Procesa la cola de carga de Assets.
|
* Procesa la cola de carga de Assets.
|
||||||
*
|
*
|
||||||
* \param Amount: Número de Assets de la cola a procesar. Si vale -1 se procesarán todos.
|
* \param Amount: N�mero de Assets de la cola a procesar. Si vale -1 se procesar�n todos.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void ProcessAssetQueue(int amount = -1);
|
void ProcessAssetQueue(int amount = -1);
|
||||||
@@ -95,17 +94,17 @@ namespace UE
|
|||||||
inline int GetAssetQueueSize() { return _assetQueue.size(); }
|
inline int GetAssetQueueSize() { return _assetQueue.size(); }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Comprueba si la cola de carga de Assets está vacía.
|
/// Comprueba si la cola de carga de Assets est� vac�a.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>El resultado de la cola.</returns>
|
/// <returns>El resultado de la cola.</returns>
|
||||||
inline bool IsAssetQueueEmpty() { return _assetQueue.empty(); }
|
inline bool IsAssetQueueEmpty() { return _assetQueue.empty(); }
|
||||||
|
|
||||||
|
|
||||||
/*--------------------------------------/
|
/*--------------------------------------/
|
||||||
* Métodos para manejar las texturas. *
|
* M�todos para manejar las texturas. *
|
||||||
*--------------------------------------*/
|
*--------------------------------------*/
|
||||||
|
|
||||||
//Crea una textura de SDL y la añade al mapa de texturas identificada por su nombre.
|
//Crea una textura de SDL y la a�ade al mapa de texturas identificada por su nombre.
|
||||||
void LoadTexture(std::string name, std::string txPath);
|
void LoadTexture(std::string name, std::string txPath);
|
||||||
|
|
||||||
//Elimina una textura del mapa a partir de su nombre.
|
//Elimina una textura del mapa a partir de su nombre.
|
||||||
@@ -119,20 +118,20 @@ namespace UE
|
|||||||
|
|
||||||
|
|
||||||
/*------------------------------------/
|
/*------------------------------------/
|
||||||
* Métodos para manejar las fuentes. *
|
* M�todos para manejar las fuentes. *
|
||||||
*------------------------------------*/
|
*------------------------------------*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Crea un objeto UE:Font y lo añade al mapa de fuentes.
|
* Crea un objeto UE:Font y lo a�ade al mapa de fuentes.
|
||||||
*
|
*
|
||||||
* @param name : Nombre del asset (key para el mapa de fuentes).
|
* @param name : Nombre del asset (key para el mapa de fuentes).
|
||||||
* @param fontPath : Ubicación del archivo de datos sobre la fuente.
|
* @param fontPath : Ubicaci�n del archivo de datos sobre la fuente.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void LoadFont(std::string name, std::string fontPath);
|
void LoadFont(std::string name, std::string fontPath);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Elimina una fuente (y en teoría limpia la fuente) dado su nombre de Asset.
|
* Elimina una fuente (y en teor�a limpia la fuente) dado su nombre de Asset.
|
||||||
*
|
*
|
||||||
* @param name : Nombre del Asset (key del mapa de fuentes).
|
* @param name : Nombre del Asset (key del mapa de fuentes).
|
||||||
*
|
*
|
||||||
@@ -168,7 +167,7 @@ namespace UE
|
|||||||
|
|
||||||
/* Almacenes de asssets */
|
/* Almacenes de asssets */
|
||||||
|
|
||||||
//Almacén de SDL_Texture* (ptrs, pues lo gestiona SDL).
|
//Almac�n de SDL_Texture* (ptrs, pues lo gestiona SDL).
|
||||||
//std::unordered_map<std::string, SDL_Texture*> _textures = {};
|
//std::unordered_map<std::string, SDL_Texture*> _textures = {};
|
||||||
//std::unordered_map<std::string, std::vector<SDL_Rect>> _textureRects = {};
|
//std::unordered_map<std::string, std::vector<SDL_Rect>> _textureRects = {};
|
||||||
std::unordered_map <std::string, Texture*> _textures = {};
|
std::unordered_map <std::string, Texture*> _textures = {};
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
#include "Font.h"
|
#include "Font.h"
|
||||||
#include "Logging\Logger.h"
|
#include "Logging/Logger.h"
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
#include <json\json.hpp>
|
#include <json/json.hpp>
|
||||||
using json = nlohmann::ordered_json;
|
using json = nlohmann::ordered_json;
|
||||||
|
|
||||||
|
|
||||||
@@ -15,7 +15,7 @@ TTF_Font* UE::Font::GetFont(int size)
|
|||||||
auto it = _fonts.find(size);
|
auto it = _fonts.find(size);
|
||||||
if (it == _fonts.end())
|
if (it == _fonts.end())
|
||||||
{
|
{
|
||||||
//El tamaño pedido no está disponible.
|
//El tama�o pedido no est� disponible.
|
||||||
//La creamos nueva.
|
//La creamos nueva.
|
||||||
font = CreateFontSize(size);
|
font = CreateFontSize(size);
|
||||||
return font;
|
return font;
|
||||||
@@ -41,7 +41,7 @@ void UE::Font::InitFont()
|
|||||||
|
|
||||||
_fontPath = jread["FontPath"].get<std::string>();
|
_fontPath = jread["FontPath"].get<std::string>();
|
||||||
|
|
||||||
//Obtenemos los tamaños que crear de inicio.
|
//Obtenemos los tama�os que crear de inicio.
|
||||||
std::vector<int> vect = jread["FontSizes"].get<std::vector<int>>();
|
std::vector<int> vect = jread["FontSizes"].get<std::vector<int>>();
|
||||||
for (auto it : vect)
|
for (auto it : vect)
|
||||||
{
|
{
|
||||||
@@ -53,7 +53,7 @@ void UE::Font::InitFont()
|
|||||||
|
|
||||||
void UE::Font::CleanFont()
|
void UE::Font::CleanFont()
|
||||||
{
|
{
|
||||||
//Eliminamos todos los tamaños de las fuentes.
|
//Eliminamos todos los tama�os de las fuentes.
|
||||||
for (auto i = _fonts.begin(); i != _fonts.end(); i++)
|
for (auto i = _fonts.begin(); i != _fonts.end(); i++)
|
||||||
{
|
{
|
||||||
TTF_CloseFont(i->second);
|
TTF_CloseFont(i->second);
|
||||||
@@ -62,7 +62,7 @@ void UE::Font::CleanFont()
|
|||||||
|
|
||||||
TTF_Font* UE::Font::CreateFontSize(int size)
|
TTF_Font* UE::Font::CreateFontSize(int size)
|
||||||
{
|
{
|
||||||
//Creamos la fuente del tamaño requerido.
|
//Creamos la fuente del tama�o requerido.
|
||||||
TTF_Font* font = TTF_OpenFont(_fontPath.c_str(), size);
|
TTF_Font* font = TTF_OpenFont(_fontPath.c_str(), size);
|
||||||
if (font == nullptr)
|
if (font == nullptr)
|
||||||
{
|
{
|
||||||
@@ -70,7 +70,7 @@ TTF_Font* UE::Font::CreateFontSize(int size)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
//La añadimos al mapa.
|
//La a�adimos al mapa.
|
||||||
_fonts.insert(std::make_pair(size, font));
|
_fonts.insert(std::make_pair(size, font));
|
||||||
|
|
||||||
UE_LOG_TRACE("Font: {0} se ha creado con tamanho: {1}", _fontPath, size);
|
UE_LOG_TRACE("Font: {0} se ha creado con tamanho: {1}", _fontPath, size);
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
#include "Texture.h"
|
#include "Texture.h"
|
||||||
#include "Logging\Logger.h"
|
#include "Logging/Logger.h"
|
||||||
|
|
||||||
#include "Asset.h"
|
#include "Asset.h"
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
#include <json\json.hpp>
|
#include <json/json.hpp>
|
||||||
using json = nlohmann::ordered_json;
|
using json = nlohmann::ordered_json;
|
||||||
|
|
||||||
SDL_Rect* UE::Texture::GetTextureRect(int i)
|
SDL_Rect* UE::Texture::GetTextureRect(int i)
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
#include "Sprite.h"
|
#include "Sprite.h"
|
||||||
|
|
||||||
#include "Render\Renderer.h"
|
#include "Render/Renderer.h"
|
||||||
#include "Assets\AssetManager.h"
|
#include "Assets/AssetManager.h"
|
||||||
|
|
||||||
#include "Logging\Logger.h"
|
#include "Logging/Logger.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,16 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
//#include <glm.hpp>
|
//#include <glm.hpp>
|
||||||
|
|
||||||
#include <glm\vec2.hpp>
|
#include <glm/vec2.hpp>
|
||||||
|
|
||||||
|
|
||||||
#include "Render\Drawable.h"
|
#include "Render/Drawable.h"
|
||||||
#include "Render\Transformable.h"
|
#include "Render/Transformable.h"
|
||||||
#include "Assets\Texture.h"
|
#include "Assets/Texture.h"
|
||||||
|
|
||||||
//
|
//
|
||||||
// TODO:
|
// TODO:
|
||||||
@@ -35,16 +36,16 @@ namespace UE
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Se establecen todos los parámetos.
|
Se establecen todos los par�metos.
|
||||||
La textura es obligatoria, y puede ha de darse:
|
La textura es obligatoria, y puede ha de darse:
|
||||||
- En SDL_Texture* -> Sin más, se entiende.
|
- En SDL_Texture* -> Sin m�s, se entiende.
|
||||||
En ambos casos se llama al método SetTexturePtr.
|
En ambos casos se llama al m�todo SetTexturePtr.
|
||||||
Los demás parámetros tienen un valor por defecto.
|
Los dem�s par�metros tienen un valor por defecto.
|
||||||
|
|
||||||
\param texturePtr: El pointer a la textura de SDL.
|
\param texturePtr: El pointer a la textura de SDL.
|
||||||
\param textureRects: El pointer al conjunto de SDL_Rects de la textura.
|
\param textureRects: El pointer al conjunto de SDL_Rects de la textura.
|
||||||
\param textureRectID: El número de Rect del conjunto de rects.
|
\param textureRectID: El n�mero de Rect del conjunto de rects.
|
||||||
\param renderLayer: La Layer en que se renderizará.
|
\param renderLayer: La Layer en que se renderizar�.
|
||||||
*/
|
*/
|
||||||
Sprite(UE::Texture* texture,
|
Sprite(UE::Texture* texture,
|
||||||
int textureRectID = 0,
|
int textureRectID = 0,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include "TextBox.h"
|
#include "TextBox.h"
|
||||||
|
|
||||||
#include "Logging\Logger.h"
|
#include "Logging/Logger.h"
|
||||||
#include "Render\Renderer.h"
|
#include "Render/Renderer.h"
|
||||||
|
|
||||||
void UE::TextBox::SetText(std::string newText)
|
void UE::TextBox::SetText(std::string newText)
|
||||||
{
|
{
|
||||||
@@ -34,7 +34,7 @@ void UE::TextBox::SetColor(int r, int g, int b, int a)
|
|||||||
|
|
||||||
void UE::TextBox::Draw(Renderer* renderer)
|
void UE::TextBox::Draw(Renderer* renderer)
|
||||||
{
|
{
|
||||||
//Si aún no tenemos renderer, lo guardamos y procesamos.
|
//Si a�n no tenemos renderer, lo guardamos y procesamos.
|
||||||
if (_sdlRenderer == nullptr)
|
if (_sdlRenderer == nullptr)
|
||||||
{
|
{
|
||||||
_sdlRenderer = renderer->GetSDLRenderer();
|
_sdlRenderer = renderer->GetSDLRenderer();
|
||||||
@@ -42,7 +42,7 @@ void UE::TextBox::Draw(Renderer* renderer)
|
|||||||
}
|
}
|
||||||
if (_textTexture == nullptr)
|
if (_textTexture == nullptr)
|
||||||
{
|
{
|
||||||
UE_LOG_WARN("El texto: {0} ; No se está renderizando. La textura no existe.", _text);
|
UE_LOG_WARN("El texto: {0} ; No se est� renderizando. La textura no existe.", _text);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,7 +63,7 @@ void UE::TextBox::RenderTextTexture()
|
|||||||
//Creamos el SDL_Color a partir del vec4 que contiene el color.
|
//Creamos el SDL_Color a partir del vec4 que contiene el color.
|
||||||
SDL_Color color = { _textColor.x,_textColor.y, _textColor.z, _textColor.w };
|
SDL_Color color = { _textColor.x,_textColor.y, _textColor.z, _textColor.w };
|
||||||
|
|
||||||
//Tomamos la TTF_Font del tamaño que queremos de UE::Font.
|
//Tomamos la TTF_Font del tama�o que queremos de UE::Font.
|
||||||
TTF_Font* fn = _font->GetFont(_textSize);
|
TTF_Font* fn = _font->GetFont(_textSize);
|
||||||
|
|
||||||
SDL_Surface* loader = TTF_RenderText_Solid(fn, _text.c_str(), color);
|
SDL_Surface* loader = TTF_RenderText_Solid(fn, _text.c_str(), color);
|
||||||
|
|||||||
@@ -2,13 +2,13 @@
|
|||||||
|
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#include <SDL_ttf.h>
|
#include <SDL_ttf.h>
|
||||||
#include <glm\vec4.hpp>
|
#include <glm/vec4.hpp>
|
||||||
|
|
||||||
|
|
||||||
#include "Render\Drawable.h"
|
#include "Render/Drawable.h"
|
||||||
#include "Render\Transformable.h"
|
#include "Render/Transformable.h"
|
||||||
|
|
||||||
#include "Assets\Font.h"
|
#include "Assets/Font.h"
|
||||||
|
|
||||||
|
|
||||||
namespace UE
|
namespace UE
|
||||||
@@ -38,7 +38,7 @@ namespace UE
|
|||||||
RenderTextTexture();
|
RenderTextTexture();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Se generará una textura y todo eso...
|
//Se generar� una textura y todo eso...
|
||||||
void SetText(std::string newText);
|
void SetText(std::string newText);
|
||||||
void SetSize(int newSize);
|
void SetSize(int newSize);
|
||||||
|
|
||||||
@@ -61,7 +61,7 @@ namespace UE
|
|||||||
|
|
||||||
SDL_Texture* _textTexture = nullptr;
|
SDL_Texture* _textTexture = nullptr;
|
||||||
|
|
||||||
//Esto está muy mal hecho, no debería de ser así.
|
//Esto est� muy mal hecho, no deber�a de ser as�.
|
||||||
//Necesito un renderer para crear la textura del texto, pero no puedo conseguirlo con la arquitectura actual.
|
//Necesito un renderer para crear la textura del texto, pero no puedo conseguirlo con la arquitectura actual.
|
||||||
//No quiero regenerar la textura en cada frame de forma innecesaria...
|
//No quiero regenerar la textura en cada frame de forma innecesaria...
|
||||||
//Por ello, me toca forzar un poco el sistema.
|
//Por ello, me toca forzar un poco el sistema.
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
|
|
||||||
#include "spdlog\sinks\stdout_color_sinks.h"
|
#include "spdlog/sinks/stdout_color_sinks.h"
|
||||||
|
|
||||||
|
|
||||||
namespace UE
|
namespace UE
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "spdlog\spdlog.h"
|
#include "spdlog/spdlog.h"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
@@ -23,7 +23,7 @@ namespace UE
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//Macros para el Logging. Es más cómodo que estar poniendo la línea entera cada vez...
|
//Macros para el Logging. Es m�s c�modo que estar poniendo la l�nea entera cada vez...
|
||||||
#define UE_LOG_TRACE(...) ::UE::Logger::GetEngineLogger()->trace(__VA_ARGS__)
|
#define UE_LOG_TRACE(...) ::UE::Logger::GetEngineLogger()->trace(__VA_ARGS__)
|
||||||
#define UE_LOG_DEBUG(...) ::UE::Logger::GetEngineLogger()->debug(__VA_ARGS__)
|
#define UE_LOG_DEBUG(...) ::UE::Logger::GetEngineLogger()->debug(__VA_ARGS__)
|
||||||
#define UE_LOG_INFO(...) ::UE::Logger::GetEngineLogger()->info(__VA_ARGS__)
|
#define UE_LOG_INFO(...) ::UE::Logger::GetEngineLogger()->info(__VA_ARGS__)
|
||||||
|
|||||||
@@ -1,15 +1,19 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include <ImGui\imgui.h>
|
#include <ImGui/imgui.h>
|
||||||
#include <ImGui\imgui_impl_sdl.h>
|
#include <ImGui/imgui_impl_sdl.h>
|
||||||
#include <ImGui\imgui_impl_sdlrenderer.h>
|
#include <ImGui/imgui_impl_sdlrenderer.h>
|
||||||
//#include <ImGui\imgui_impl_opengl3.h>
|
//#include <ImGui\imgui_impl_opengl3.h>
|
||||||
|
|
||||||
#include <SDL\include\SDL_opengl.h>
|
#ifdef __LINUX__
|
||||||
|
#include <GL/glew.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <SDL_opengl.h>
|
||||||
|
|
||||||
|
|
||||||
#include "Renderer.h"
|
#include "Renderer.h"
|
||||||
#include "Logging\Logger.h"
|
#include "Logging/Logger.h"
|
||||||
|
|
||||||
namespace UE
|
namespace UE
|
||||||
{
|
{
|
||||||
@@ -23,11 +27,11 @@ namespace UE
|
|||||||
Uint32 SDL_Flags = SDL_INIT_TIMER | SDL_INIT_VIDEO | SDL_INIT_EVENTS;
|
Uint32 SDL_Flags = SDL_INIT_TIMER | SDL_INIT_VIDEO | SDL_INIT_EVENTS;
|
||||||
if (SDL_Init(SDL_Flags) < 0)
|
if (SDL_Init(SDL_Flags) < 0)
|
||||||
{
|
{
|
||||||
UE_LOG_CRITICAL("No se ha podido iniciar SDL, sufre mamón: {0}", SDL_GetError());
|
UE_LOG_CRITICAL("No se ha podido iniciar SDL, sufre mam�n: {0}", SDL_GetError());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Configuramos los parámetros de la ventana de SDL.
|
//Configuramos los par�metros de la ventana de SDL.
|
||||||
Uint32 windowFlags = (SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL | SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_RESIZABLE);
|
Uint32 windowFlags = (SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL | SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_RESIZABLE);
|
||||||
|
|
||||||
//Creamos la ventana de SDL.
|
//Creamos la ventana de SDL.
|
||||||
@@ -99,7 +103,7 @@ namespace UE
|
|||||||
ImGui_ImplSDL2_NewFrame();
|
ImGui_ImplSDL2_NewFrame();
|
||||||
ImGui::NewFrame();
|
ImGui::NewFrame();
|
||||||
|
|
||||||
//Quizás deberíamos limpiar la cola y las Layers aquí para eliminar residuos...
|
//Quiz�s deber�amos limpiar la cola y las Layers aqu� para eliminar residuos...
|
||||||
//callCounter = 0;
|
//callCounter = 0;
|
||||||
//rendererCounter = 0;
|
//rendererCounter = 0;
|
||||||
}
|
}
|
||||||
@@ -196,17 +200,17 @@ namespace UE
|
|||||||
return fPos;
|
return fPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
//CREO QUE ESTE MÉTODO NO FUNCIONA.
|
//CREO QUE ESTE M�TODO NO FUNCIONA.
|
||||||
//LAS COORDS QUE USAMOS EN LA COMPROBACIÓN NO SON LAS ADECUADAS.
|
//LAS COORDS QUE USAMOS EN LA COMPROBACI�N NO SON LAS ADECUADAS.
|
||||||
bool Renderer::IsObjectVisible(SDL_Rect* objectRect)
|
bool Renderer::IsObjectVisible(SDL_Rect* objectRect)
|
||||||
{
|
{
|
||||||
|
|
||||||
//Generamos un rect que representa la pantalla.
|
//Generamos un rect que representa la pantalla.
|
||||||
SDL_Rect screen{ camPosition.x, camPosition.y, screenSize.x, screenSize.y };
|
SDL_Rect screen{ camPosition.x, camPosition.y, screenSize.x, screenSize.y };
|
||||||
//Comprobamos si hay intersección entre ambos.
|
//Comprobamos si hay intersecci�n entre ambos.
|
||||||
if (!SDL_HasIntersection(&screen, objectRect))
|
if (!SDL_HasIntersection(&screen, objectRect))
|
||||||
{
|
{
|
||||||
//UE_LOG_TRACE("Se omite el renderizado de un objeto al estar fuera de la cámara.");
|
//UE_LOG_TRACE("Se omite el renderizado de un objeto al estar fuera de la c�mara.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -214,7 +218,7 @@ namespace UE
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
//¿Deberíamos operar la posición para que tenga en cuenta la cámara?
|
//�Deber�amos operar la posici�n para que tenga en cuenta la c�mara?
|
||||||
void Renderer::DrawObject(SDL_Rect* position, SDL_Rect* texture_pos, SDL_Texture* texture)
|
void Renderer::DrawObject(SDL_Rect* position, SDL_Rect* texture_pos, SDL_Texture* texture)
|
||||||
{
|
{
|
||||||
SDL_RenderCopy(main_Renderer, texture, texture_pos, position);
|
SDL_RenderCopy(main_Renderer, texture, texture_pos, position);
|
||||||
@@ -235,10 +239,10 @@ namespace UE
|
|||||||
//
|
//
|
||||||
//Generamos un rect que representa la pantalla.
|
//Generamos un rect que representa la pantalla.
|
||||||
SDL_Rect screen{ 0, 0, screenSize.x, screenSize.y };
|
SDL_Rect screen{ 0, 0, screenSize.x, screenSize.y };
|
||||||
//Comprobamos si hay intersección entre ambos.
|
//Comprobamos si hay intersecci�n entre ambos.
|
||||||
if (!SDL_HasIntersection(&screen, &drawCall.pos_rect))
|
if (!SDL_HasIntersection(&screen, &drawCall.pos_rect))
|
||||||
{
|
{
|
||||||
//UE_LOG_TRACE("Se omite el renderizado de un objeto al estar fuera de la cámara.");
|
//UE_LOG_TRACE("Se omite el renderizado de un objeto al estar fuera de la c�mara.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,15 +5,15 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#include <glm\vec2.hpp>
|
#include <glm/vec2.hpp>
|
||||||
|
|
||||||
#include "Drawable.h"
|
#include "Drawable.h"
|
||||||
|
|
||||||
//
|
//
|
||||||
// TODO:
|
// TODO:
|
||||||
// - Optimizar RenderDraw moviendo la ordenación por capas a Queue, quitando renderQueue.
|
// - Optimizar RenderDraw moviendo la ordenaci�n por capas a Queue, quitando renderQueue.
|
||||||
// - Limpiar las funciones moviendo código a otras funciones.
|
// - Limpiar las funciones moviendo c�digo a otras funciones.
|
||||||
// - ¿Podría moverse todo a static? De esta forma, ya no harían falta instancias.
|
// - �Podr�a moverse todo a static? De esta forma, ya no har�an falta instancias.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
@@ -57,7 +57,7 @@ namespace UE
|
|||||||
void NewFrame();
|
void NewFrame();
|
||||||
|
|
||||||
//Ordena por layer todos los objetos de la renderQueue y los dibuja en orden.
|
//Ordena por layer todos los objetos de la renderQueue y los dibuja en orden.
|
||||||
//Se puede mover el proceso de ordenado a otra función, con el objeto de ir vaciando la Queue.
|
//Se puede mover el proceso de ordenado a otra funci�n, con el objeto de ir vaciando la Queue.
|
||||||
void RenderData();
|
void RenderData();
|
||||||
|
|
||||||
|
|
||||||
@@ -65,7 +65,7 @@ namespace UE
|
|||||||
void EndFrame();
|
void EndFrame();
|
||||||
|
|
||||||
|
|
||||||
//Añade un DrawCall al renderQueue.
|
//A�ade un DrawCall al renderQueue.
|
||||||
void QueueDrawCall(DrawCall drawCall);
|
void QueueDrawCall(DrawCall drawCall);
|
||||||
void QueueDrawCall(int layer, SDL_Rect& position, SDL_Texture* texture, SDL_Rect& texture_position);
|
void QueueDrawCall(int layer, SDL_Rect& position, SDL_Texture* texture, SDL_Rect& texture_position);
|
||||||
void QueueDrawCall(int layer, SDL_Rect & position, SDL_Texture* texture);
|
void QueueDrawCall(int layer, SDL_Rect & position, SDL_Texture* texture);
|
||||||
@@ -83,20 +83,20 @@ namespace UE
|
|||||||
inline glm::ivec2 GetCamPosition() { return camPosition; }
|
inline glm::ivec2 GetCamPosition() { return camPosition; }
|
||||||
void SetCamPosition(int posX, int posY);
|
void SetCamPosition(int posX, int posY);
|
||||||
|
|
||||||
/* Métodos para transformar las coordenadas entre Screen y Wolrd. */
|
/* M�todos para transformar las coordenadas entre Screen y Wolrd. */
|
||||||
//WorldCoords = ScreenPos + CamPos -> ScreenPos = WorldCoords - CamPos;
|
//WorldCoords = ScreenPos + CamPos -> ScreenPos = WorldCoords - CamPos;
|
||||||
//Convierte coordenadas de mundo a la pantalla (en función de la cámara).
|
//Convierte coordenadas de mundo a la pantalla (en funci�n de la c�mara).
|
||||||
glm::ivec2 WorldToSreenCoords(glm::ivec2 worldCoord);
|
glm::ivec2 WorldToSreenCoords(glm::ivec2 worldCoord);
|
||||||
//Convierte coordenadas de la pantalla al mundo.
|
//Convierte coordenadas de la pantalla al mundo.
|
||||||
glm::ivec2 ScreenToWorldCoords(glm::ivec2 screenCoord);
|
glm::ivec2 ScreenToWorldCoords(glm::ivec2 screenCoord);
|
||||||
|
|
||||||
//Comprueba si un objeto está dentro del rectángulo de la cámara.
|
//Comprueba si un objeto est� dentro del rect�ngulo de la c�mara.
|
||||||
//Usada para saber si un objeto se debería de renderizar o no.
|
//Usada para saber si un objeto se deber�a de renderizar o no.
|
||||||
bool IsObjectVisible(SDL_Rect* objectRect);
|
bool IsObjectVisible(SDL_Rect* objectRect);
|
||||||
|
|
||||||
|
|
||||||
//DEBUG
|
//DEBUG
|
||||||
//Función para renderizar un objeto un objeto en concreto directamente en el SDL_Renderer.
|
//Funci�n para renderizar un objeto un objeto en concreto directamente en el SDL_Renderer.
|
||||||
void DrawObject(SDL_Rect* position, SDL_Rect* texture_pos, SDL_Texture* texture);
|
void DrawObject(SDL_Rect* position, SDL_Rect* texture_pos, SDL_Texture* texture);
|
||||||
|
|
||||||
|
|
||||||
@@ -115,7 +115,7 @@ namespace UE
|
|||||||
//SDL_GLContext _glContext = nullptr;
|
//SDL_GLContext _glContext = nullptr;
|
||||||
|
|
||||||
//Almacena todas las "draw calls" para luego ordenar los objetos por layers y dibujarlos.
|
//Almacena todas las "draw calls" para luego ordenar los objetos por layers y dibujarlos.
|
||||||
//Se podría sustituir por un std::queue o std::deque si fuera necesario.
|
//Se podr�a sustituir por un std::queue o std::deque si fuera necesario.
|
||||||
std::vector<DrawCall> renderQueue;
|
std::vector<DrawCall> renderQueue;
|
||||||
|
|
||||||
//Las capas en las que se organizan los diferentes objetos.
|
//Las capas en las que se organizan los diferentes objetos.
|
||||||
|
|||||||
@@ -3,12 +3,12 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <glm\vec2.hpp>
|
#include <glm/vec2.hpp>
|
||||||
|
|
||||||
namespace UE
|
namespace UE
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
Clase que contiene lo necesario para crear un objeto con posición en el espacio y modificarlo.
|
Clase que contiene lo necesario para crear un objeto con posici�n en el espacio y modificarlo.
|
||||||
*/
|
*/
|
||||||
class Transformable
|
class Transformable
|
||||||
{
|
{
|
||||||
@@ -20,7 +20,7 @@ namespace UE
|
|||||||
//-----------
|
//-----------
|
||||||
|
|
||||||
|
|
||||||
//Modifica la posición del Objeto.
|
//Modifica la posici�n del Objeto.
|
||||||
inline void SetPosition(float x, float y) { _pos = glm::vec<2, float>(x, y); }
|
inline void SetPosition(float x, float y) { _pos = glm::vec<2, float>(x, y); }
|
||||||
inline void SetPosition(glm::vec<2, float> newPosition) { _pos = newPosition; }
|
inline void SetPosition(glm::vec<2, float> newPosition) { _pos = newPosition; }
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ namespace UE
|
|||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//Se almacena la posición y el tamaño del objeto. Con esto se puede crear un SDL_Rect.
|
//Se almacena la posici�n y el tama�o del objeto. Con esto se puede crear un SDL_Rect.
|
||||||
glm::vec<2, float> _pos;
|
glm::vec<2, float> _pos;
|
||||||
glm::vec<2, float> _size;
|
glm::vec<2, float> _size;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
#include "Scene.h"
|
#include "Scene.h"
|
||||||
#include "SceneBuilder.h"
|
#include "SceneBuilder.h"
|
||||||
|
|
||||||
#include "Logging\Logger.h"
|
#include "Logging/Logger.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
@@ -44,7 +44,7 @@ namespace UE
|
|||||||
// _scenes.insert(std::make_pair(sceneToAdd->GetName(), sceneToAdd));
|
// _scenes.insert(std::make_pair(sceneToAdd->GetName(), sceneToAdd));
|
||||||
// sceneToAdd->SceneInit();
|
// sceneToAdd->SceneInit();
|
||||||
|
|
||||||
// UE_LOG_INFO("Se ha añadido la escena {0} al SceneManager.", sceneToAdd->GetName());
|
// UE_LOG_INFO("Se ha a�adido la escena {0} al SceneManager.", sceneToAdd->GetName());
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Logging\Logger.h"
|
#include "Logging/Logger.h"
|
||||||
|
|
||||||
#include "Render\Renderer.h"
|
#include "Render/Renderer.h"
|
||||||
#include "Drawables\Sprite.h"
|
#include "Drawables/Sprite.h"
|
||||||
|
|
||||||
#include "Assets\AssetManager.h"
|
#include "Assets/AssetManager.h"
|
||||||
|
|
||||||
#include "Scene\SceneManager.h"
|
#include "Scene/SceneManager.h"
|
||||||
|
|
||||||
#include "Time\Time.h"
|
#include "Time/Time.h"
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Scene\SceneBuilder.h"
|
#include "Scene/SceneBuilder.h"
|
||||||
#include "Scene\Scene.h"
|
#include "Scene/Scene.h"
|
||||||
|
|
||||||
#include "Scenes\MainScene.hpp"
|
#include "Scenes/MainScene.hpp"
|
||||||
#include "Scenes\TestScene2.hpp"
|
#include "Scenes/TestScene2.hpp"
|
||||||
|
|
||||||
//#include "Logging\Logger.h"
|
//#include "Logging\Logger.h"
|
||||||
|
|
||||||
|
|||||||
+6
-6
@@ -1,10 +1,10 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include <glm\glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
|
|
||||||
#include <ImGui\imgui.h>
|
#include <ImGui/imgui.h>
|
||||||
#include <ImGui\imgui_impl_sdl.h>
|
#include <ImGui/imgui_impl_sdl.h>
|
||||||
#include <ImGui\imgui_impl_opengl3.h>
|
#include <ImGui/imgui_impl_opengl3.h>
|
||||||
|
|
||||||
#include "UberGame1.h"
|
#include "UberGame1.h"
|
||||||
#include "GameScenes.hpp"
|
#include "GameScenes.hpp"
|
||||||
@@ -12,8 +12,8 @@
|
|||||||
#include "UberEngine.h"
|
#include "UberEngine.h"
|
||||||
|
|
||||||
|
|
||||||
#include "Scenes\MainScene.hpp"
|
#include "Scenes/MainScene.hpp"
|
||||||
#include "Scenes\TestScene2.hpp"
|
#include "Scenes/TestScene2.hpp"
|
||||||
|
|
||||||
static bool _quit = false;
|
static bool _quit = false;
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
//#include "UberEngine.h"
|
//#include "UberEngine.h"
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Scene\Scene.h"
|
#include "Scene/Scene.h"
|
||||||
#include "Render\Renderer.h"
|
#include "Render/Renderer.h"
|
||||||
#include "Assets\AssetManager.h"
|
#include "Assets/AssetManager.h"
|
||||||
#include "Logging\Logger.h"
|
#include "Logging/Logger.h"
|
||||||
|
|
||||||
#include "Drawables\Sprite.h"
|
#include "Drawables/Sprite.h"
|
||||||
#include "Drawables\TextBox.h"
|
#include "Drawables/TextBox.h"
|
||||||
|
|
||||||
#include "Time\Time.h"
|
#include "Time/Time.h"
|
||||||
|
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#include <SDL_ttf.h>
|
#include <SDL_ttf.h>
|
||||||
|
|
||||||
#include <ImGui\imgui.h>
|
#include <ImGui/imgui.h>
|
||||||
|
|
||||||
class MainScene : public UE::Scene
|
class MainScene : public UE::Scene
|
||||||
{
|
{
|
||||||
@@ -82,7 +82,7 @@ public:
|
|||||||
|
|
||||||
for (UE::Sprite& sp : sprites)
|
for (UE::Sprite& sp : sprites)
|
||||||
{
|
{
|
||||||
//Si el obj. no está activo, lo saltamos.
|
//Si el obj. no est� activo, lo saltamos.
|
||||||
if (sp.IsActive())
|
if (sp.IsActive())
|
||||||
{
|
{
|
||||||
renderer->Render(sp);
|
renderer->Render(sp);
|
||||||
@@ -210,7 +210,7 @@ private:
|
|||||||
{
|
{
|
||||||
sp.SetTextureRect(textRect);
|
sp.SetTextureRect(textRect);
|
||||||
}
|
}
|
||||||
//Añadir un input para modificar la layer.
|
//A�adir un input para modificar la layer.
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Scene\Scene.h"
|
#include "Scene/Scene.h"
|
||||||
#include "Render\Renderer.h"
|
#include "Render/Renderer.h"
|
||||||
#include "Logging\Logger.h"
|
#include "Logging/Logger.h"
|
||||||
|
|
||||||
#include "Assets\AssetManager.h"
|
#include "Assets/AssetManager.h"
|
||||||
#include "Assets\Texture.h"
|
#include "Assets/Texture.h"
|
||||||
|
|
||||||
#include "Drawables\Sprite.h"
|
#include "Drawables/Sprite.h"
|
||||||
|
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@@ -59,7 +59,7 @@ public:
|
|||||||
|
|
||||||
for (UE::Sprite& sp : sprites)
|
for (UE::Sprite& sp : sprites)
|
||||||
{
|
{
|
||||||
//Si el obj. no está activo, lo saltamos.
|
//Si el obj. no est� activo, lo saltamos.
|
||||||
if (sp.IsActive())
|
if (sp.IsActive())
|
||||||
{
|
{
|
||||||
renderer->Render(sp);
|
renderer->Render(sp);
|
||||||
@@ -105,11 +105,12 @@ private:
|
|||||||
{
|
{
|
||||||
SDL_Rect mouseRect = { wPos.x, wPos.y, 2, 2 };
|
SDL_Rect mouseRect = { wPos.x, wPos.y, 2, 2 };
|
||||||
|
|
||||||
|
//Esto hay que optimizarlo calculando el ID con la posición del ratón.
|
||||||
for (int i = 0; i < sprites.size(); i++)
|
for (int i = 0; i < sprites.size(); i++)
|
||||||
{
|
{
|
||||||
UE::Sprite& sp = sprites.at(i);
|
UE::Sprite& sp = sprites.at(i);
|
||||||
|
SDL_Rect sp_Pos = sp.getPositionRect();
|
||||||
if (SDL_HasIntersection(&mouseRect, &sp.getPositionRect()))
|
if (SDL_HasIntersection(&mouseRect, &sp_Pos))
|
||||||
{
|
{
|
||||||
int i = rand() % 5;
|
int i = rand() % 5;
|
||||||
sp.SetTextureRect(i);
|
sp.SetTextureRect(i);
|
||||||
@@ -179,7 +180,7 @@ private:
|
|||||||
{
|
{
|
||||||
sp.SetTextureRect(textRect);
|
sp.SetTextureRect(textRect);
|
||||||
}
|
}
|
||||||
//Añadir un input para modificar la layer.
|
//A�adir un input para modificar la layer.
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
#include "UberGame1.h"
|
#include "UberGame1.h"
|
||||||
|
|
||||||
#include "Logging\Logger.h"
|
#include "Logging/Logger.h"
|
||||||
#include "Render\Renderer.h"
|
#include "Render/Renderer.h"
|
||||||
#include "Assets\AssetManager.h"
|
#include "Assets/AssetManager.h"
|
||||||
|
|
||||||
#include "Scene\SceneManager.h"
|
#include "Scene/SceneManager.h"
|
||||||
#include "Scene\SceneBuilder.h"
|
#include "Scene/SceneBuilder.h"
|
||||||
|
|
||||||
#include "GameScenes.hpp"
|
#include "GameScenes.hpp"
|
||||||
|
|
||||||
|
|||||||
Executable
BIN
Binary file not shown.
Binary file not shown.
+51
-16
@@ -6,7 +6,7 @@ GameName = "UberGame1"
|
|||||||
|
|
||||||
|
|
||||||
workspace (""..GameName.."")
|
workspace (""..GameName.."")
|
||||||
configurations {"Debug", "Release"}
|
configurations { "Debug", "Release" }
|
||||||
architecture "x64"
|
architecture "x64"
|
||||||
|
|
||||||
|
|
||||||
@@ -38,28 +38,39 @@ project (""..GameName.."")
|
|||||||
-- "UberEngine/vendor/glm",
|
-- "UberEngine/vendor/glm",
|
||||||
-- "UberEngine/vendor/ImGui",
|
-- "UberEngine/vendor/ImGui",
|
||||||
-- "UberEngine/vendor/json", --Header-Only
|
-- "UberEngine/vendor/json", --Header-Only
|
||||||
"UberEngine/vendor/SDL/include",
|
|
||||||
"UberEngine/vendor/SDL2_image/include",
|
|
||||||
"UberEngine/vendor/SDL2_ttf/include",
|
|
||||||
"UberEngine/vendor/spdlog/include",
|
"UberEngine/vendor/spdlog/include",
|
||||||
"UberEngine/vendor",
|
"UberEngine/vendor",
|
||||||
"UberEngine/src"
|
"UberEngine/src"
|
||||||
|
|
||||||
}
|
}
|
||||||
libdirs { "UberEngine/vendor/SDL/lib/x64", "UberEngine/vendor/SDL2_image/lib/x64", "UberEngine/vendor/SDL2_ttf/lib/x64" }
|
|
||||||
links { "opengl32.lib", "SDL2.lib", "SDL2main.lib", "SDL2_image.lib", "SDL2_ttf.lib" }
|
|
||||||
|
|
||||||
filter "system:windows"
|
|
||||||
cppdialect "C++17"
|
cppdialect "C++17"
|
||||||
systemversion "latest"
|
|
||||||
|
|
||||||
|
|
||||||
filter "configurations:Debug"
|
filter "configurations:Debug"
|
||||||
defines { "DEBUG" }
|
defines { "DEBUG" }
|
||||||
symbols "On"
|
symbols "On"
|
||||||
|
|
||||||
--libdirs { "UberEngine/vendor/SFML/lib/Debug" }
|
filter "configurations:Release"
|
||||||
--links { "sfml-audio-d.lib", "sfml-graphics-d.lib", "sfml-network-d.lib", "sfml-main-d.lib", "sfml-system-d.lib", "sfml-window-d.lib" }
|
defines { "NDEBUG" }
|
||||||
|
optimize "On"
|
||||||
|
|
||||||
|
|
||||||
|
-- Opciones de Windows.
|
||||||
|
filter "system:windows"
|
||||||
|
systemversion "latest"
|
||||||
|
includedirs
|
||||||
|
{
|
||||||
|
"UberEngine/vendor/SDL/include",
|
||||||
|
"UberEngine/vendor/SDL2_image/include",
|
||||||
|
"UberEngine/vendor/SDL2_ttf/include",
|
||||||
|
}
|
||||||
|
|
||||||
|
libdirs { "UberEngine/vendor/SDL/lib/x64", "UberEngine/vendor/SDL2_image/lib/x64", "UberEngine/vendor/SDL2_ttf/lib/x64" }
|
||||||
|
links { "opengl32.lib", "SDL2.lib", "SDL2main.lib", "SDL2_image.lib", "SDL2_ttf.lib" }
|
||||||
|
defines { "SDL_VIDEO_DRIVER_WINDOWS" }
|
||||||
|
|
||||||
|
filter { "system:windows", "configurations:Debug" }
|
||||||
postbuildcommands
|
postbuildcommands
|
||||||
{
|
{
|
||||||
"xcopy UberEngine\\vendor\\SDL\\lib\\x64\\*.dll bin\\Debug\\ /y /f",
|
"xcopy UberEngine\\vendor\\SDL\\lib\\x64\\*.dll bin\\Debug\\ /y /f",
|
||||||
@@ -69,12 +80,7 @@ project (""..GameName.."")
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
filter "configurations:Release"
|
filter { "system:windows", "configurations:Release" }
|
||||||
defines { "NDEBUG" }
|
|
||||||
optimize "On"
|
|
||||||
|
|
||||||
--libdirs { "UberEngine/vendor/SFML/lib/Release" }
|
|
||||||
--links { "sfml-audio.lib", "sfml-graphics.lib", "sfml-network.lib", "sfml-main.lib", "sfml-system.lib", "sfml-window.lib" }
|
|
||||||
postbuildcommands
|
postbuildcommands
|
||||||
{
|
{
|
||||||
"xcopy UberEngine\\vendor\\SDL\\lib\\x64\\*.dll bin\\Release\\ /y /f",
|
"xcopy UberEngine\\vendor\\SDL\\lib\\x64\\*.dll bin\\Release\\ /y /f",
|
||||||
@@ -82,3 +88,32 @@ project (""..GameName.."")
|
|||||||
"xcopy UberEngine\\vendor\\SDL2_ttf\\lib\\x64\\*.dll bin\\Release\\ /y /f",
|
"xcopy UberEngine\\vendor\\SDL2_ttf\\lib\\x64\\*.dll bin\\Release\\ /y /f",
|
||||||
"xcopy resources\\ bin\\Release\\resources\\ /e /y /f"
|
"xcopy resources\\ bin\\Release\\resources\\ /e /y /f"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-- Opciones de Linux.
|
||||||
|
filter "system:linux"
|
||||||
|
includedirs
|
||||||
|
{
|
||||||
|
"/usr/include/SDL2/"
|
||||||
|
}
|
||||||
|
|
||||||
|
links { "SDL2", "SDL2main", "SDL2_image", "SDL2_ttf", "dl", "GL", "GLEW"}
|
||||||
|
defines { "SDL_VIDEO_DRIVER_X11" }
|
||||||
|
|
||||||
|
filter { "system:linux", "configurations:Debug" }
|
||||||
|
postbuildcommands
|
||||||
|
{
|
||||||
|
-- "cp UberEngine/vendor/SDL/lib/x64/*.dll bin/Debug/",
|
||||||
|
-- "cp UberEngine/vendor/SDL2_image/lib/x64/*.dll bin/Debug/",
|
||||||
|
-- "cp UberEngine/vendor/SDL2_ttf/lib/x64/*.dll bin/Debug/",
|
||||||
|
"cp -r resources/ bin/Debug/resources/"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
filter { "system:linux", "configurations:Release" }
|
||||||
|
postbuildcommands
|
||||||
|
{
|
||||||
|
-- "cp UberEngine/vendor/SDL/lib/x64/*.dll bin/Release/",
|
||||||
|
-- "cp UberEngine/vendor/SDL2_image/lib/x64/*.dll bin/Release/",
|
||||||
|
-- "cp UberEngine/vendor/SDL2_ttf/lib/x64/*.dll bin/Release/",
|
||||||
|
"cp -r resources/ bin/Release/resources/"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user