2023-10-10 18:01:15 +00:00
|
|
|
#include "state.h"
|
2023-10-11 08:10:06 +00:00
|
|
|
#include "world.h"
|
2023-10-10 18:01:15 +00:00
|
|
|
|
|
|
|
#include <SDL2/SDL.h>
|
|
|
|
|
|
|
|
const char *tc_window_title_g = "Techneck";
|
|
|
|
|
|
|
|
void tc_init_renderer(techneck_s *techneck)
|
|
|
|
{
|
|
|
|
SDL_Init(SDL_INIT_EVERYTHING);
|
|
|
|
|
|
|
|
techneck->renderer.window = SDL_CreateWindow(
|
|
|
|
tc_window_title_g,
|
|
|
|
SDL_WINDOWPOS_CENTERED,
|
|
|
|
SDL_WINDOWPOS_CENTERED,
|
|
|
|
1200,
|
|
|
|
800,
|
|
|
|
SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE
|
|
|
|
);
|
|
|
|
|
2023-10-11 08:10:06 +00:00
|
|
|
techneck->renderer.active_camera.position.x = 0.0f;
|
|
|
|
techneck->renderer.active_camera.position.y = 0.0f;
|
|
|
|
techneck->renderer.active_camera.position.z = 0.0f;
|
|
|
|
|
2023-10-10 18:01:15 +00:00
|
|
|
techneck->renderer.gl_context = SDL_GL_CreateContext(techneck->renderer.window);
|
|
|
|
gladLoadGLLoader(&SDL_GL_GetProcAddress);
|
|
|
|
gladLoadGL();
|
|
|
|
|
|
|
|
techneck->renderer.draw_shader = tc_make_shader_program("vertex_shader.glsl", "fragment_shader.glsl");
|
|
|
|
|
|
|
|
glEnable(GL_DEPTH_TEST);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
techneck_s tc_init()
|
|
|
|
{
|
|
|
|
techneck_s techneck;
|
|
|
|
tc_init_renderer(&techneck);
|
2023-10-11 08:10:06 +00:00
|
|
|
techneck.main_world = tc_init_worlds();
|
|
|
|
techneck.block_registry = tc_init_blocks();
|
2023-10-10 18:01:15 +00:00
|
|
|
|
|
|
|
return techneck;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void tc_cleanup()
|
|
|
|
{
|
|
|
|
SDL_GL_DeleteContext(tc_game_state_g.renderer.gl_context);
|
|
|
|
SDL_DestroyWindow(tc_game_state_g.renderer.window);
|
|
|
|
}
|
|
|
|
|