Skip to content

Commit

Permalink
V1.13.0-win_0x02
Browse files Browse the repository at this point in the history
- Añadido el método SetBackdropColor(); a la clase NGN_Graphics, el cual permite escoger el color de backdrop del viewport principal.
  • Loading branch information
knightfox75 committed Mar 7, 2023
1 parent 52fd81d commit 5ada53e
Show file tree
Hide file tree
Showing 49 changed files with 104 additions and 69 deletions.
4 changes: 2 additions & 2 deletions Source/config_flags.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/******************************************************************************
N'gine Lib for C++
*** Version 1.13.0-win_0x01 ***
*** Version 1.13.0-win_0x02 ***
FLAGS de configuracion de la libreria
La libreria debe compilarse para que estos FLAGS sean efectivos
Expand Down Expand Up @@ -117,7 +117,7 @@
That speeds up to 50% in lowend GPU's, but also disables the option
of enable bilinear filtering in objects and layers separately.
*/
//#define DISABLE_BACKBUFFER
// #define DISABLE_BACKBUFFER



Expand Down
2 changes: 1 addition & 1 deletion Source/ngn.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/******************************************************************************
N'gine Lib for C++
*** Version 1.13.0-win_0x01 ***
*** Version 1.13.0-win_0x02 ***
Archivo principal de la libreria
Proyecto iniciado el 1 de Febrero del 2016
Expand Down
2 changes: 1 addition & 1 deletion Source/ngn.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/******************************************************************************
N'gine Lib for C++
*** Version 1.13.0-win_0x01 ***
*** Version 1.13.0-win_0x02 ***
Archivo principal de la libreria
Proyecto iniciado el 1 de Febrero del 2016
Expand Down
2 changes: 1 addition & 1 deletion Source/ngn_audio_clip.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/******************************************************************************
N'gine Lib for C++
*** Version 1.13.0-win_0x01 ***
*** Version 1.13.0-win_0x02 ***
Clips de audio
Proyecto iniciado el 1 de Febrero del 2016
Expand Down
2 changes: 1 addition & 1 deletion Source/ngn_audio_clip.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/******************************************************************************
N'gine Lib for C++
*** Version 1.13.0-win_0x01 ***
*** Version 1.13.0-win_0x02 ***
Clips de audio
Proyecto iniciado el 1 de Febrero del 2016
Expand Down
2 changes: 1 addition & 1 deletion Source/ngn_camera.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/******************************************************************************
N'gine Lib for C++
*** Version 1.13.0-win_0x01 ***
*** Version 1.13.0-win_0x02 ***
Camara virtual en 2D
Proyecto iniciado el 1 de Febrero del 2016
Expand Down
2 changes: 1 addition & 1 deletion Source/ngn_camera.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/******************************************************************************
N'gine Lib for C++
*** Version 1.13.0-win_0x01 ***
*** Version 1.13.0-win_0x02 ***
Camara virtual en 2D
Proyecto iniciado el 1 de Febrero del 2016
Expand Down
2 changes: 1 addition & 1 deletion Source/ngn_canvas.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/******************************************************************************
N'gine Lib for C++
*** Version 1.13.0-win_0x01 ***
*** Version 1.13.0-win_0x02 ***
Canvas - Capa de dibujo
Proyecto iniciado el 1 de Febrero del 2016
Expand Down
2 changes: 1 addition & 1 deletion Source/ngn_canvas.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/******************************************************************************
N'gine Lib for C++
*** Version 1.13.0-win_0x01 ***
*** Version 1.13.0-win_0x02 ***
Canvas - Capa de dibujo
Proyecto iniciado el 1 de Febrero del 2016
Expand Down
2 changes: 1 addition & 1 deletion Source/ngn_collisions.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/******************************************************************************
N'gine Lib for C++
*** Version 1.13.0-win_0x01 ***
*** Version 1.13.0-win_0x02 ***
Sistema de colisiones
Proyecto iniciado el 1 de Febrero del 2016
Expand Down
2 changes: 1 addition & 1 deletion Source/ngn_collisions.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/******************************************************************************
N'gine Lib for C++
*** Version 1.13.0-win_0x01 ***
*** Version 1.13.0-win_0x02 ***
Sistema de colisiones
Proyecto iniciado el 1 de Febrero del 2016
Expand Down
2 changes: 1 addition & 1 deletion Source/ngn_defines.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/******************************************************************************
N'gine Lib for C++
*** Version 1.13.0-win_0x01 ***
*** Version 1.13.0-win_0x02 ***
Definiciones de prototipos
Proyecto iniciado el 1 de Febrero del 2016
Expand Down
4 changes: 2 additions & 2 deletions Source/ngn_defines.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/******************************************************************************
N'gine Lib for C++
*** Version 1.13.0-win_0x01 ***
*** Version 1.13.0-win_0x02 ***
Definiciones de prototipos
Proyecto iniciado el 1 de Febrero del 2016
Expand Down Expand Up @@ -61,7 +61,7 @@
static const int32_t NGN_VERSION_MAJOR = 1; // Version mayor
static const int32_t NGN_VERSION_MINOR = 13; // Version menor
static const int32_t NGN_VERSION_PATCH = 0; // Version parche
static const std::string NGN_VERSION_METADATA = "wip_0x01"; // Version metadatos
static const std::string NGN_VERSION_METADATA = "wip_0x02"; // Version metadatos

/*** Definiciones generales ***/
static const int32_t NGN_DEFAULT_VALUE = 0x7FFFFFFF; // Valor de "defecto"
Expand Down
2 changes: 1 addition & 1 deletion Source/ngn_disk.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/******************************************************************************
N'gine Lib for C++
*** Version 1.13.0-win_0x01 ***
*** Version 1.13.0-win_0x02 ***
Funciones de acceso al disco
Proyecto iniciado el 1 de Febrero del 2016
Expand Down
2 changes: 1 addition & 1 deletion Source/ngn_disk.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/******************************************************************************
N'gine Lib for C++
*** Version 1.13.0-win_0x01 ***
*** Version 1.13.0-win_0x02 ***
Funciones de acceso al disco
Proyecto iniciado el 1 de Febrero del 2016
Expand Down
2 changes: 1 addition & 1 deletion Source/ngn_filesystem.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/******************************************************************************
N'gine Lib for C++
*** Version 1.13.0-win_0x01 ***
*** Version 1.13.0-win_0x02 ***
Funciones del sistema de archivos
Proyecto iniciado el 1 de Febrero del 2016
Expand Down
2 changes: 1 addition & 1 deletion Source/ngn_filesystem.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/******************************************************************************
N'gine Lib for C++
*** Version 1.13.0-win_0x01 ***
*** Version 1.13.0-win_0x02 ***
Funciones del sistema de archivos
Proyecto iniciado el 1 de Febrero del 2016
Expand Down
67 changes: 48 additions & 19 deletions Source/ngn_graphics.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/******************************************************************************
N'gine Lib for C++
*** Version 1.13.0-win_0x01 ***
*** Version 1.13.0-win_0x02 ***
Gestion del Renderer de SDL
Proyecto iniciado el 1 de Febrero del 2016
Expand Down Expand Up @@ -128,6 +128,9 @@ NGN_Graphics::NGN_Graphics() {
output_viewport.x = 0.0f;
output_viewport.y = 0.0f;

// Color del backdrop
backdrop_color = {0x00, 0x00, 0x00, 0x00};

// Grabacion de la pantalla a PNG
png_pixels.clear();
png_buffer.clear();
Expand Down Expand Up @@ -341,7 +344,17 @@ void NGN_Graphics::RenderToSelected() {
#endif
}
// Restaura el color y alpha del renderer
SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0x00, 0xFF);
#if !defined (DISABLE_BACKBUFFER)
SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0x00, 0xFF);
#else
SDL_SetRenderDrawColor(
renderer,
backdrop_color.r,
backdrop_color.g,
backdrop_color.b,
0xFF
);
#endif

}

Expand Down Expand Up @@ -452,11 +465,8 @@ void NGN_Graphics::OpenViewport(
v.clip_area.w = v.render_w;
v.clip_area.h = v.render_h;

// Color de backdrop por defecto (negro)
v.backdrop_color.r = 0x00;
v.backdrop_color.g = 0x00;
v.backdrop_color.b = 0x00;
v.backdrop_color.a = 0x00;
// Color de backdrop por defecto (negro, transparente)
v.backdrop_color = {0x00, 0x00, 0x00, 0x00};

// Viewport disponible
v.available = true;
Expand Down Expand Up @@ -490,6 +500,7 @@ void NGN_Graphics::CloseViewport(uint8_t id) {
v.render_h = 0;
v.surface = NULL;
v._local_filter = v.local_filter = false;
v.backdrop_color = {0x00, 0x00, 0x00, 0x00};

// Actualiza los datos del viewport cerrado
viewport_list[id] = v;
Expand Down Expand Up @@ -1018,10 +1029,7 @@ void NGN_Graphics::SetupViewports() {
v.clip_area = {0, 0, 0, 0};
v.surface = NULL;
v._local_filter = v.local_filter = false;
v.backdrop_color.r = 0;
v.backdrop_color.g = 0;
v.backdrop_color.b = 0;
v.backdrop_color.a = 0;
v.backdrop_color = {0x00, 0x00, 0x00, 0x00};

viewport_list.clear();
viewport_list.reserve(VIEWPORT_NUMBER);
Expand Down Expand Up @@ -1121,17 +1129,23 @@ void NGN_Graphics::GenerateRuntimeFrameId() {

// Crea el backbuffer de este fondo
backbuffer = SDL_CreateTexture(
renderer, // Renderer
SDL_PIXELFORMAT_BGRA8888, // Formato del pixel
SDL_TEXTUREACCESS_TARGET, // Textura como destino del renderer
native_w, // Ancho de la textura
native_h // Alto de la textura
);
renderer, // Renderer
SDL_PIXELFORMAT_BGRA8888, // Formato del pixel
SDL_TEXTUREACCESS_TARGET, // Textura como destino del renderer
native_w, // Ancho de la textura
native_h // Alto de la textura
);

SDL_SetRenderTarget(renderer, backbuffer);

// Borra el contenido de la textura actual
SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0x00, 0x00);
SDL_SetRenderDrawColor(
renderer,
backdrop_color.r,
backdrop_color.g,
backdrop_color.b,
backdrop_color.a
);
SDL_SetTextureBlendMode(backbuffer, SDL_BLENDMODE_BLEND);
SDL_SetTextureAlphaMod(backbuffer, 0xFF);
SDL_RenderFillRect(renderer, NULL);
Expand Down Expand Up @@ -1204,7 +1218,13 @@ void NGN_Graphics::ClearBackbuffer() {
if (filtering != _filtering) {
SetBackbuffer();
} else {
SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0x00, 0x00);
SDL_SetRenderDrawColor(
renderer,
backdrop_color.r,
backdrop_color.g,
backdrop_color.b,
backdrop_color.a
);
SDL_SetTextureBlendMode(backbuffer, SDL_BLENDMODE_BLEND);
SDL_SetTextureAlphaMod(backbuffer, 0xFF);
SDL_RenderFillRect(renderer, NULL);
Expand All @@ -1216,6 +1236,15 @@ void NGN_Graphics::ClearBackbuffer() {



/*** Establece el color del backdrop ***/
void NGN_Graphics::SetBackdropColor(uint8_t r, uint8_t g, uint8_t b, uint8_t a) {

backdrop_color = {r, g, b, a};

}



/*** Realiza un screenshoot si se solicita ***/
void NGN_Graphics::SaveCurrentFrameToPng() {

Expand Down
8 changes: 7 additions & 1 deletion Source/ngn_graphics.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/******************************************************************************
N'gine Lib for C++
*** Version 1.13.0-win_0x01 ***
*** Version 1.13.0-win_0x02 ***
Gestion del Renderer de SDL
Proyecto iniciado el 1 de Febrero del 2016
Expand Down Expand Up @@ -113,6 +113,9 @@ class NGN_Graphics {
// Estable el destino del render al seleccionado por defecto
void RenderToSelected();

// Color del backdrop del viewport principal
void SetBackdropColor(uint8_t r, uint8_t g, uint8_t b, uint8_t a);

// Actualiza el renderer a 60fps
void Update();

Expand Down Expand Up @@ -258,6 +261,9 @@ class NGN_Graphics {
// Limpia el backbuffer
void ClearBackbuffer();

// Color del backdrop
Rgba backdrop_color;

// Graba el frame actual en formato PNG
std::vector<uint8_t> png_pixels; // Pixeles para formar el PNG
std::vector<uint8_t> png_buffer; // Datos del backbuffer para formar el PNG
Expand Down
2 changes: 1 addition & 1 deletion Source/ngn_image.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/******************************************************************************
N'gine Lib for C++
*** Version 1.13.0-win_0x01 ***
*** Version 1.13.0-win_0x02 ***
Funciones para la manipulacion de imagenes en RAW
Proyecto iniciado el 1 de Febrero del 2016
Expand Down
2 changes: 1 addition & 1 deletion Source/ngn_image.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/******************************************************************************
N'gine Lib for C++
*** Version 1.13.0-win_0x01 ***
*** Version 1.13.0-win_0x02 ***
Funciones para la manipulacion de imagenes en RAW
Proyecto iniciado el 1 de Febrero del 2016
Expand Down
2 changes: 1 addition & 1 deletion Source/ngn_input.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/******************************************************************************
N'gine Lib for C++
*** Version 1.13.0-win_0x01 ***
*** Version 1.13.0-win_0x02 ***
Meotodos de entrada
Proyecto iniciado el 1 de Febrero del 2016
Expand Down
2 changes: 1 addition & 1 deletion Source/ngn_input.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/******************************************************************************
N'gine Lib for C++
*** Version 1.13.0-win_0x01 ***
*** Version 1.13.0-win_0x02 ***
Meotodos de entrada
Proyecto iniciado el 1 de Febrero del 2016
Expand Down
2 changes: 1 addition & 1 deletion Source/ngn_load.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/******************************************************************************
N'gine Lib for C++
*** Version 1.13.0-win_0x01 ***
*** Version 1.13.0-win_0x02 ***
Funciones de carga de archivos
Proyecto iniciado el 1 de Febrero del 2016
Expand Down
2 changes: 1 addition & 1 deletion Source/ngn_load.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/******************************************************************************
N'gine Lib for C++
*** Version 1.13.0-win_0x01 ***
*** Version 1.13.0-win_0x02 ***
Funciones de carga de archivos
Proyecto iniciado el 1 de Febrero del 2016
Expand Down
2 changes: 1 addition & 1 deletion Source/ngn_log.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/******************************************************************************
N'gine Lib for C++
*** Version 1.13.0-win_0x01 ***
*** Version 1.13.0-win_0x02 ***
Funciones de mensages de depuracion
Proyecto iniciado el 1 de Febrero del 2016
Expand Down
Loading

0 comments on commit 5ada53e

Please sign in to comment.