big rendering overhaul (cleaning and api abstraction)
This commit is contained in:
@ -12,13 +12,6 @@
|
||||
#include <stb_ds.h>
|
||||
#include <toml.h>
|
||||
|
||||
/* TODO: should not be used here directly */
|
||||
#ifdef EMSCRIPTEN
|
||||
#include <GLES2/gl2.h>
|
||||
#else
|
||||
#include <glad/glad.h>
|
||||
#endif
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <limits.h>
|
||||
|
||||
@ -100,28 +93,6 @@ static void poll_events(void) {
|
||||
}
|
||||
|
||||
|
||||
#ifndef EMSCRIPTEN
|
||||
|
||||
static void APIENTRY opengl_log(GLenum source,
|
||||
GLenum type,
|
||||
GLuint id,
|
||||
GLenum severity,
|
||||
GLsizei length,
|
||||
const GLchar* message,
|
||||
const void* userParam)
|
||||
{
|
||||
(void)source;
|
||||
(void)type;
|
||||
(void)id;
|
||||
(void)severity;
|
||||
(void)userParam;
|
||||
|
||||
log_info("OpenGL: %.*s\n", length, message);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
static void preserve_persistent_ctx_fields(void) {
|
||||
ctx.game.udata = ctx.game_copy.udata;
|
||||
}
|
||||
@ -539,25 +510,13 @@ static bool initialize(void) {
|
||||
if (SDL_GL_SetSwapInterval(-1))
|
||||
SDL_GL_SetSwapInterval(1);
|
||||
|
||||
#ifndef EMSCRIPTEN
|
||||
if (gladLoadGL() == 0) {
|
||||
CRY("Init", "GLAD failed");
|
||||
if (!render_init())
|
||||
goto fail;
|
||||
}
|
||||
#endif
|
||||
|
||||
log_info("OpenGL context: %s\n", glGetString(GL_VERSION));
|
||||
|
||||
#ifndef EMSCRIPTEN
|
||||
glHint(GL_TEXTURE_COMPRESSION_HINT, GL_NICEST);
|
||||
glHint(GL_GENERATE_MIPMAP_HINT, GL_NICEST);
|
||||
glHint(GL_FOG_HINT, GL_FASTEST);
|
||||
#endif
|
||||
|
||||
/* might need this to have multiple windows */
|
||||
ctx.window_id = SDL_GetWindowID(ctx.window);
|
||||
|
||||
glViewport(0, 0, (GLsizei)ctx.base_render_width, (GLsizei)ctx.base_render_height);
|
||||
setup_viewport(0, 0, (int)ctx.base_render_width, (int)ctx.base_render_height);
|
||||
|
||||
/* TODO: */
|
||||
// SDL_GetRendererOutputSize(ctx.renderer, &ctx.window_w, &ctx.window_h);
|
||||
@ -596,14 +555,6 @@ static bool initialize(void) {
|
||||
/* you could change this at runtime if you wanted */
|
||||
ctx.update_multiplicity = 1;
|
||||
|
||||
#ifndef EMSCRIPTEN
|
||||
/* hook up opengl debugging callback */
|
||||
if (ctx.game.debug) {
|
||||
glEnable(GL_DEBUG_OUTPUT);
|
||||
glDebugMessageCallback(opengl_log, NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* random seeding */
|
||||
/* SDL_GetPerformanceCounter returns some platform-dependent number. */
|
||||
/* it should vary between game instances. i checked! random enough for me. */
|
||||
@ -718,6 +669,9 @@ static bool initialize(void) {
|
||||
ctx.render_double_buffered = true;
|
||||
ctx.window_mouse_resident = true;
|
||||
|
||||
ctx.game.fog_color = (Color){ 255, 255, 255, 255 }; /* TODO: pick some grey? */
|
||||
ctx.game.fog_end = 1.0f;
|
||||
|
||||
return true;
|
||||
|
||||
fail:
|
||||
|
Reference in New Issue
Block a user