VERSIÓ 1.6.2:
- [FIX] El buffer en que es guardaba l'arxiu de text dels shaders no s'alliberava. - [NEW] Traça per a vore - [NEW] Millors logs de errors de shaders - [NEW] Afegit mode 'consola' per a quan s'executa desde consola sense entorn gràfic
This commit is contained in:
1 parent
9e2b89a4ee
commit
c0faf074fe
6 files changed
+75
-20
No files matched your search
@@ -2,6 +2,7 @@
|
|||||||
/mini
|
/mini
|
||||||
mini_debug.exe
|
mini_debug.exe
|
||||||
mini_debug
|
mini_debug
|
||||||
|
mini_san
|
||||||
.vscode/*
|
.vscode/*
|
||||||
info.plist
|
info.plist
|
||||||
build/*
|
build/*
|
||||||
|
|||||||
+1
-1
@@ -12,7 +12,7 @@ executable = mini_debug
|
|||||||
sourcepath = source+
|
sourcepath = source+
|
||||||
buildpath = build
|
buildpath = build
|
||||||
|
|
||||||
[linux_sanitize] default
|
[linux_sanitize]
|
||||||
cppflags = -D LUA_USE_LINUX -D DEBUG -g -Wall -std=c++20 -fsanitize=address -fno-omit-frame-pointer -Isource
|
cppflags = -D LUA_USE_LINUX -D DEBUG -g -Wall -std=c++20 -fsanitize=address -fno-omit-frame-pointer -Isource
|
||||||
libs = -fsanitize=address -lSDL3 -lGL
|
libs = -fsanitize=address -lSDL3 -lGL
|
||||||
executable = mini_san
|
executable = mini_san
|
||||||
|
|||||||
@@ -21,6 +21,34 @@
|
|||||||
#include <SDL3/SDL_opengl_glext.h>
|
#include <SDL3/SDL_opengl_glext.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void checkGLError() {
|
||||||
|
GLenum err = glGetError();
|
||||||
|
if (err != GL_NO_ERROR) {
|
||||||
|
fprintf(stderr, "OpenGL error 0x%04X\n", err);
|
||||||
|
|
||||||
|
// Mapeo rápido de los errores más comunes de OpenGL
|
||||||
|
while (err != GL_NO_ERROR) {
|
||||||
|
const char* errStr = "";
|
||||||
|
switch (err) {
|
||||||
|
case GL_INVALID_ENUM: errStr = "GL_INVALID_ENUM"; break;
|
||||||
|
case GL_INVALID_VALUE: errStr = "GL_INVALID_STRING/VALUE"; break;
|
||||||
|
case GL_INVALID_OPERATION: errStr = "GL_INVALID_OPERATION"; break;
|
||||||
|
case GL_OUT_OF_MEMORY: errStr = "GL_OUT_OF_MEMORY"; break;
|
||||||
|
case GL_INVALID_FRAMEBUFFER_OPERATION: errStr = "GL_INVALID_FRAMEBUFFER_OPERATION"; break;
|
||||||
|
default: errStr = "UNKNOWN_ERROR"; break;
|
||||||
|
}
|
||||||
|
fprintf(stderr, " -> Código de error: %s (0x%04X)\n", errStr, err);
|
||||||
|
err = glGetError();
|
||||||
|
}
|
||||||
|
::exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#define GL_CHECK(stmt) do { \
|
||||||
|
stmt; \
|
||||||
|
checkGLError(#stmt, __FILE__, __LINE__); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
namespace backend
|
namespace backend
|
||||||
{
|
{
|
||||||
namespace shader
|
namespace shader
|
||||||
@@ -132,18 +160,25 @@ namespace backend
|
|||||||
glAttachShader(programId, vtxShaderId);
|
glAttachShader(programId, vtxShaderId);
|
||||||
glAttachShader(programId, fragShaderId);
|
glAttachShader(programId, fragShaderId);
|
||||||
glLinkProgram(programId);
|
glLinkProgram(programId);
|
||||||
glValidateProgram(programId);
|
//glValidateProgram(programId);
|
||||||
|
|
||||||
// Check the status of the compile/link
|
GLint linkStatus = GL_FALSE;
|
||||||
GLint logLen;
|
glGetProgramiv(programId, GL_LINK_STATUS, &linkStatus);
|
||||||
glGetProgramiv(programId, GL_INFO_LOG_LENGTH, &logLen);
|
|
||||||
if (logLen > 0)
|
if (linkStatus != GL_TRUE)
|
||||||
{
|
{
|
||||||
char* log = (char*) malloc(logLen * sizeof(char));
|
std::cout << "Error en el enlazado (Linking) del programa!" << std::endl;
|
||||||
// Show any errors as appropriate
|
GLint logLen = 0;
|
||||||
glGetProgramInfoLog(programId, logLen, &logLen, log);
|
glGetProgramiv(programId, GL_INFO_LOG_LENGTH, &logLen);
|
||||||
std::cout << "Prog Info Log: " << std::endl << log << std::endl;
|
if (logLen > 0)
|
||||||
free(log);
|
{
|
||||||
|
char* log = (char*)malloc(logLen);
|
||||||
|
glGetProgramInfoLog(programId, logLen, &logLen, log);
|
||||||
|
std::cout << "Program Link Log:\n" << log << std::endl;
|
||||||
|
free(log);
|
||||||
|
}
|
||||||
|
glDeleteProgram(programId);
|
||||||
|
programId = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (vtxShaderId) glDeleteShader(vtxShaderId);
|
if (vtxShaderId) glDeleteShader(vtxShaderId);
|
||||||
@@ -165,12 +200,6 @@ namespace backend
|
|||||||
SDL_GetWindowSize(video::window, &win_size.x, &win_size.y);
|
SDL_GetWindowSize(video::window, &win_size.x, &win_size.y);
|
||||||
SDL_GetTextureSize(video::tex_shader, &tex_size.x, &tex_size.y);
|
SDL_GetTextureSize(video::tex_shader, &tex_size.x, &tex_size.y);
|
||||||
|
|
||||||
int filesize;
|
|
||||||
char *vshaderfile = mini::file::getfilebuffer(vShaderSource, filesize, true);
|
|
||||||
|
|
||||||
char *fshaderfile = nullptr;
|
|
||||||
if (fShaderSource) { fshaderfile = mini::file::getfilebuffer(fShaderSource, filesize, true); }
|
|
||||||
|
|
||||||
SDL_PropertiesID props = SDL_GetTextureProperties(video::tex_shader);
|
SDL_PropertiesID props = SDL_GetTextureProperties(video::tex_shader);
|
||||||
int access = SDL_GetNumberProperty(props, SDL_PROP_TEXTURE_ACCESS_NUMBER, -1);
|
int access = SDL_GetNumberProperty(props, SDL_PROP_TEXTURE_ACCESS_NUMBER, -1);
|
||||||
if (access != SDL_TEXTUREACCESS_TARGET) {
|
if (access != SDL_TEXTUREACCESS_TARGET) {
|
||||||
@@ -190,12 +219,23 @@ namespace backend
|
|||||||
gl_extensions_initialized = true;
|
gl_extensions_initialized = true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
// Compilar el shader y dejarlo listo para usar.
|
|
||||||
|
// Compilar el shader
|
||||||
|
int filesize;
|
||||||
|
char *vshaderfile = mini::file::getfilebuffer(vShaderSource, filesize, true);
|
||||||
|
|
||||||
if (!vshaderfile) {
|
if (!vshaderfile) {
|
||||||
can_use_opengl = false;
|
can_use_opengl = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *fshaderfile = nullptr;
|
||||||
|
if (fShaderSource) { fshaderfile = mini::file::getfilebuffer(fShaderSource, filesize, true); }
|
||||||
|
|
||||||
programId = compileProgram(vshaderfile, fshaderfile);
|
programId = compileProgram(vshaderfile, fshaderfile);
|
||||||
|
|
||||||
|
if (vshaderfile) free(vshaderfile);
|
||||||
|
if (fshaderfile) free(fshaderfile);
|
||||||
} else {
|
} else {
|
||||||
std::cout << "WARNING: El driver del renderer no es OpenGL." << std::endl;
|
std::cout << "WARNING: El driver del renderer no es OpenGL." << std::endl;
|
||||||
can_use_opengl = false;
|
can_use_opengl = false;
|
||||||
@@ -258,10 +298,16 @@ namespace backend
|
|||||||
SDL_RenderTexture(backend::video::renderer, backend::video::tex_shader, NULL, &backend::video::dest_rect);
|
SDL_RenderTexture(backend::video::renderer, backend::video::tex_shader, NULL, &backend::video::dest_rect);
|
||||||
SDL_RenderPresent(backend::video::renderer);
|
SDL_RenderPresent(backend::video::renderer);
|
||||||
}
|
}
|
||||||
if (glGetError()) { printf("GLERROR!\n"); ::exit(1); }
|
checkGLError();
|
||||||
|
//GLenum error = glGetError();
|
||||||
|
//if (error != GL_NO_ERROR) {
|
||||||
|
// printf("GLERROR!\n"); ::exit(1);
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -30,6 +30,7 @@ namespace backend
|
|||||||
if (zoom <= 0) zoom = 1;
|
if (zoom <= 0) zoom = 1;
|
||||||
const SDL_DisplayMode *dm = SDL_GetDesktopDisplayMode(SDL_GetPrimaryDisplay());
|
const SDL_DisplayMode *dm = SDL_GetDesktopDisplayMode(SDL_GetPrimaryDisplay());
|
||||||
while ( width * zoom > dm->w || height * zoom > dm->h) zoom--;
|
while ( width * zoom > dm->w || height * zoom > dm->h) zoom--;
|
||||||
|
log_msg(LOG_INFO, "Display size: %ix%i\n", dm->w, dm->h);
|
||||||
|
|
||||||
const int z = mini::win::state.fullscreen ? 1 : zoom;
|
const int z = mini::win::state.fullscreen ? 1 : zoom;
|
||||||
// Crear SDL_Window i SDL_Renderer
|
// Crear SDL_Window i SDL_Renderer
|
||||||
@@ -74,9 +75,14 @@ namespace backend
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dest_rect.x = dest_rect.y = 0;
|
|
||||||
dest_rect.w = width * zoom;
|
dest_rect.w = width * zoom;
|
||||||
dest_rect.h = height * zoom;
|
dest_rect.h = height * zoom;
|
||||||
|
if (mini::win::state.console) {
|
||||||
|
dest_rect.x = (ww - dest_rect.w)/2;
|
||||||
|
dest_rect.y = (wh - dest_rect.h)/2;
|
||||||
|
} else {
|
||||||
|
dest_rect.x = dest_rect.y = 0;
|
||||||
|
}
|
||||||
printf("dest_rect: (%i,%i)-(%i,%i)\n", (int)dest_rect.x, (int)dest_rect.y, (int)dest_rect.w, (int)dest_rect.h);
|
printf("dest_rect: (%i,%i)-(%i,%i)\n", (int)dest_rect.x, (int)dest_rect.y, (int)dest_rect.w, (int)dest_rect.h);
|
||||||
}
|
}
|
||||||
shader::reinit();
|
shader::reinit();
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ void read_ini() {
|
|||||||
else if (strcmp(line, "height") == 0) { mini::win::state.height = atoi(value); log_msg(LOG_VERBOSE, "screen height = %i\n", mini::win::state.height); }
|
else if (strcmp(line, "height") == 0) { mini::win::state.height = atoi(value); log_msg(LOG_VERBOSE, "screen height = %i\n", mini::win::state.height); }
|
||||||
else if (strcmp(line, "zoom") == 0) { mini::win::state.zoom = atoi(value); log_msg(LOG_VERBOSE, "screen zoom = %i\n", mini::win::state.zoom); }
|
else if (strcmp(line, "zoom") == 0) { mini::win::state.zoom = atoi(value); log_msg(LOG_VERBOSE, "screen zoom = %i\n", mini::win::state.zoom); }
|
||||||
else if (strcmp(line, "fullscreen") == 0) { mini::win::state.fullscreen = atoi(value); log_msg(LOG_VERBOSE, "screen sullscreen = %i\n", mini::win::state.fullscreen); }
|
else if (strcmp(line, "fullscreen") == 0) { mini::win::state.fullscreen = atoi(value); log_msg(LOG_VERBOSE, "screen sullscreen = %i\n", mini::win::state.fullscreen); }
|
||||||
|
else if (strcmp(line, "console") == 0) { mini::win::state.console = atoi(value); log_msg(LOG_VERBOSE, "run from console = %i\n", mini::win::state.console); }
|
||||||
//else if (strcmp(line, "files") == 0) {
|
//else if (strcmp(line, "files") == 0) {
|
||||||
//lua_files = (char*)malloc(strlen(value));
|
//lua_files = (char*)malloc(strlen(value));
|
||||||
// strcpy(lua_files, value);
|
// strcpy(lua_files, value);
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ namespace mini
|
|||||||
uint8_t zoom { 4 };
|
uint8_t zoom { 4 };
|
||||||
bool fullscreen { false };
|
bool fullscreen { false };
|
||||||
bool cursor { true };
|
bool cursor { true };
|
||||||
|
bool console { false };
|
||||||
};
|
};
|
||||||
extern state_t state;
|
extern state_t state;
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user