Fixed a bug with rendering and added rpath in linux build

dev
Shariq Shah 7 years ago
parent c651847d43
commit e47b494d80
  1. 6
      README.md
  2. 1
      build/genie.lua
  3. 1
      src/common/log.h
  4. 2
      src/game/platform.c
  5. 2
      src/game/sound.c
  6. 32
      src/libsymmetry/console.c
  7. 2
      src/libsymmetry/console.h
  8. 54
      src/libsymmetry/editor.c
  9. 2
      src/libsymmetry/light.h
  10. 1
      src/libsymmetry/model.h
  11. 1
      src/libsymmetry/player.c
  12. 1
      src/libsymmetry/player.h
  13. 5
      src/libsymmetry/renderer.c
  14. 1
      src/libsymmetry/renderer.h
  15. 2
      src/libsymmetry/scene.h
  16. 0
      tools/genie

@ -155,6 +155,11 @@
- ## TODO - ## TODO
- String data-type that is based on array implementation
- Remove all malloc calls/free and move them into custom memory allocator/deallocator functions that only tag/track usage for now
- Rethink/remove the game executable and game library split.
- Remove all previous build system files and implement cross-compilation to windows in current build system or move to a build system that supports it as a first-class citizen
- Refactor all global application state into 'Application_Context' struct. A single global instance of which is available everywhere
- Fix mouse button press/release behaviour by investigating how sdl handles mouse release or by explicitly caching mouse state by using event callbacks recieved when a mousebutton release event is reported by sdl - Fix mouse button press/release behaviour by investigating how sdl handles mouse release or by explicitly caching mouse state by using event callbacks recieved when a mousebutton release event is reported by sdl
- Improve bounding sphere calculation - Improve bounding sphere calculation
- Screen mouse coordinates to world-coordinates for aiming - Screen mouse coordinates to world-coordinates for aiming
@ -164,7 +169,6 @@
- Console command history - Console command history
- Console command help - Console command help
- Space partitioning and scene handling - Space partitioning and scene handling
- NPR and cross-hatching
- Move Gui_State and Editor_State into game_state and modify usage as needed - Move Gui_State and Editor_State into game_state and modify usage as needed
- Remove model and replace all usages with static mesh - Remove model and replace all usages with static mesh
- Get editor camera speed and other settings from config file - Get editor camera speed and other settings from config file

@ -68,6 +68,7 @@ solution "Symmetry"
configuration "linux" configuration "linux"
includedirs {"../include/linux/sdl2/", "../include/common/soloud/", "../include/linux/"} includedirs {"../include/linux/sdl2/", "../include/common/soloud/", "../include/linux/"}
libdirs {"../lib/linux/sdl2/", "../lib/linux/soloud/", "../lib/linux/ode/"} libdirs {"../lib/linux/sdl2/", "../lib/linux/soloud/", "../lib/linux/ode/"}
linkoptions {"'-Wl,-rpath,$$ORIGIN'"}
links {"SDL2", "m", "ode", "pthread"} links {"SDL2", "m", "ode", "pthread"}
configuration {"windows", "vs2017"} configuration {"windows", "vs2017"}

@ -2,6 +2,7 @@
#define LOG_H #define LOG_H
#include <stdio.h> #include <stdio.h>
#include <stdarg.h>
typedef void (*Log_Message_CB)(const char* message, va_list args); typedef void (*Log_Message_CB)(const char* message, va_list args);
typedef void (*Log_Warning_CB)(const char* warning_message, va_list args); typedef void (*Log_Warning_CB)(const char* warning_message, va_list args);

@ -96,7 +96,7 @@ struct Window* window_create(const char* title, int width, int height, int msaa,
SDL_Window* current_window = SDL_GL_GetCurrentWindow(); SDL_Window* current_window = SDL_GL_GetCurrentWindow();
SDL_GLContext current_context = SDL_GL_GetCurrentContext(); SDL_GLContext current_context = SDL_GL_GetCurrentContext();
SDL_GL_MakeCurrent((SDL_Window*)new_window->sdl_window, new_window->gl_context); SDL_GL_MakeCurrent((SDL_Window*)new_window->sdl_window, new_window->gl_context);
SDL_GL_SetSwapInterval(1); /* 0: Vsync disabled, 1: Vsync enabled*/ SDL_GL_SetSwapInterval(0); /* 0: Vsync disabled, 1: Vsync enabled*/
if(current_window && current_context) SDL_GL_MakeCurrent(current_window, current_context); if(current_window && current_context) SDL_GL_MakeCurrent(current_window, current_context);
int major = 0, minor = 0; int major = 0, minor = 0;

@ -207,7 +207,7 @@ struct Sound_Source_Buffer* sound_source_create(const char* filename, int type)
} }
long size = 0L; long size = 0L;
char* memory = io_file_read(DIRT_INSTALL, filename, "rb", &size); unsigned char* memory = io_file_read(DIRT_INSTALL, filename, "rb", &size);
source = malloc(sizeof(*source)); source = malloc(sizeof(*source));
if(!source) if(!source)

@ -108,28 +108,28 @@ int console_filter(const struct nk_text_edit *box, nk_rune unicode)
void console_on_log_message(struct Console* console, const char* message, va_list args) void console_on_log_message(struct Console* console, const char* message, va_list args)
{ {
if(++console->current_message_index >= MAX_CONSOLE_MESSAGES) /* if(++console->current_message_index >= MAX_CONSOLE_MESSAGES) */
console->current_message_index = 0; /* console->current_message_index = 0; */
vsnprintf(console->console_messages[console->current_message_index].message, MAX_CONSOLE_MESSAGE_LEN, message, args); /* vsnprintf(console->console_messages[console->current_message_index].message, MAX_CONSOLE_MESSAGE_LEN, message, args); */
console->console_messages[console->current_message_index].type = CMT_MESSAGE; /* console->console_messages[console->current_message_index].type = CMT_MESSAGE; */
console->scroll_to_bottom = true; /* console->scroll_to_bottom = true; */
} }
void console_on_log_warning(struct Console* console, const char* warning_message, va_list args) void console_on_log_warning(struct Console* console, const char* warning_message, va_list args)
{ {
if(++console->current_message_index >= MAX_CONSOLE_MESSAGES) /* if(++console->current_message_index >= MAX_CONSOLE_MESSAGES) */
console->current_message_index = 0; /* console->current_message_index = 0; */
vsnprintf(console->console_messages[console->current_message_index].message, MAX_CONSOLE_MESSAGE_LEN, warning_message, args); /* vsnprintf(console->console_messages[console->current_message_index].message, MAX_CONSOLE_MESSAGE_LEN, warning_message, args); */
console->console_messages[console->current_message_index].type = CMT_WARNING; /* console->console_messages[console->current_message_index].type = CMT_WARNING; */
console->scroll_to_bottom = true; /* console->scroll_to_bottom = true; */
} }
void console_on_log_error(struct Console* console, const char* context, const char* error, va_list args) void console_on_log_error(struct Console* console, const char* context, const char* error, va_list args)
{ {
if(++console->current_message_index >= MAX_CONSOLE_MESSAGES) /* if(++console->current_message_index >= MAX_CONSOLE_MESSAGES) */
console->current_message_index = 0; /* console->current_message_index = 0; */
int loc = snprintf(console->console_messages[console->current_message_index].message, MAX_CONSOLE_MESSAGE_LEN, "(%s)", context); /* int loc = snprintf(console->console_messages[console->current_message_index].message, MAX_CONSOLE_MESSAGE_LEN, "(%s)", context); */
vsnprintf(console->console_messages[console->current_message_index].message + loc, MAX_CONSOLE_MESSAGE_LEN, error, args); /* vsnprintf(console->console_messages[console->current_message_index].message + loc, MAX_CONSOLE_MESSAGE_LEN - loc, error, args); */
console->console_messages[console->current_message_index].type = CMT_ERROR; /* console->console_messages[console->current_message_index].type = CMT_ERROR; */
console->scroll_to_bottom = true; /* console->scroll_to_bottom = true; */
} }

@ -7,6 +7,8 @@
#define MAX_CONSOLE_MESSAGE_LEN 256 #define MAX_CONSOLE_MESSAGE_LEN 256
#define MAX_CONSOLE_MESSAGES 1024 #define MAX_CONSOLE_MESSAGES 1024
struct Gui_State;
enum Console_Message_Type enum Console_Message_Type
{ {
CMT_NONE = 0, CMT_NONE = 0,

@ -588,33 +588,33 @@ void editor_camera_update(float dt)
//Picking //Picking
//If we're not looking around then allow picking //If we're not looking around then allow picking
if(input_mousebutton_state_get(MSB_LEFT, KS_RELEASED)) /* if(input_mousebutton_state_get(MSB_LEFT, KS_RELEASED)) */
{ /* { */
log_message("editor picking"); /* log_message("editor picking"); */
int mouse_x = 0, mouse_y = 0; /* int mouse_x = 0, mouse_y = 0; */
platform->mouse_position_get(&mouse_x, &mouse_y); /* platform->mouse_position_get(&mouse_x, &mouse_y); */
struct Ray ray = camera_screen_coord_to_ray(editor_camera, mouse_x, mouse_y); /* struct Ray ray = camera_screen_coord_to_ray(editor_camera, mouse_x, mouse_y); */
//log_message("Ray: %.3f, %.3f, %.3f", ray.direction.x, ray.direction.y, ray.direction.z); /* //log_message("Ray: %.3f, %.3f, %.3f", ray.direction.x, ray.direction.y, ray.direction.z); */
struct Scene* scene = game_state_get()->scene; /* struct Scene* scene = game_state_get()->scene; */
struct Raycast_Result ray_result; /* struct Raycast_Result ray_result; */
scene_ray_intersect(scene, &ray, &ray_result); /* scene_ray_intersect(scene, &ray, &ray_result); */
if(ray_result.num_entities_intersected > 0) /* if(ray_result.num_entities_intersected > 0) */
{ /* { */
//For now, just select the first entity that is intersected /* //For now, just select the first entity that is intersected */
struct Entity* intersected_entity = ray_result.entities_intersected[0]; /* struct Entity* intersected_entity = ray_result.entities_intersected[0]; */
if(editor_state.selected_entity && editor_state.selected_entity != intersected_entity) /* if(editor_state.selected_entity && editor_state.selected_entity != intersected_entity) */
{ /* { */
editor_state.selected_entity->editor_selected = false; /* editor_state.selected_entity->editor_selected = false; */
editor_state.selected_entity = NULL; /* editor_state.selected_entity = NULL; */
} /* } */
intersected_entity->editor_selected = true; /* intersected_entity->editor_selected = true; */
editor_state.selected_entity = intersected_entity; /* editor_state.selected_entity = intersected_entity; */
} /* } */
} /* } */
} }
total_up_down_rot += turn_up_down; total_up_down_rot += turn_up_down;

@ -3,6 +3,8 @@
#define MAX_SHADOWMAPS 4 #define MAX_SHADOWMAPS 4
struct Light;
void light_init(struct Light* light, int light_type); void light_init(struct Light* light, int light_type);
void light_reset(struct Light* light); void light_reset(struct Light* light);

@ -2,6 +2,7 @@
#define MODEL_H #define MODEL_H
struct Model; struct Model;
struct Static_Mesh;
void model_init(struct Model* model, struct Static_Mesh* mesh, const char* geometry_name, int material_type); void model_init(struct Model* model, struct Static_Mesh* mesh, const char* geometry_name, int material_type);
void model_reset(struct Model* model, struct Static_Mesh* mesh); void model_reset(struct Model* model, struct Static_Mesh* mesh);

@ -8,6 +8,7 @@
#include "bounding_volumes.h" #include "bounding_volumes.h"
#include "../common/hashmap.h" #include "../common/hashmap.h"
#include "../common/log.h" #include "../common/log.h"
#include "entity.h"
void player_init(struct Player* player, struct Scene* scene) void player_init(struct Player* player, struct Scene* scene)
{ {

@ -2,6 +2,7 @@
#define PLAYER_H #define PLAYER_H
struct Player; struct Player;
struct Scene;
void player_init(struct Player* player, struct Scene* scene); void player_init(struct Player* player, struct Scene* scene);
void player_destroy(struct Player* player); void player_destroy(struct Player* player);

@ -177,7 +177,7 @@ void renderer_draw(struct Renderer* renderer, struct Scene* scene)
for(int i = 0; i < MAX_LIGHTS; i++) for(int i = 0; i < MAX_LIGHTS; i++)
{ {
struct Light* light = &scene->lights[i]; /* TODO: Cull lights according to camera frustum */ struct Light* light = &scene->lights[i]; /* TODO: Cull lights according to camera frustum */
if(!light->base.active && light->valid) continue; if(!light->base.active || !light->valid) continue;
light_count++; light_count++;
vec3 light_pos = {0, 0, 0}; vec3 light_pos = {0, 0, 0};
@ -229,8 +229,9 @@ void renderer_draw(struct Renderer* renderer, struct Scene* scene)
memset(uniform_name, '\0', MAX_UNIFORM_NAME_LEN); memset(uniform_name, '\0', MAX_UNIFORM_NAME_LEN);
} }
light_count++; // this variable is going to be used for looping an array so increase its length by one light_count++; // this variable is going to be sent as a uniform and be used for looping an array so increase its length by one
GL_CHECK(shader_set_uniform(material->pipeline_params[MPP_TOTAL_LIGHTS].type, material->pipeline_params[MPP_TOTAL_LIGHTS].location, &light_count)); GL_CHECK(shader_set_uniform(material->pipeline_params[MPP_TOTAL_LIGHTS].type, material->pipeline_params[MPP_TOTAL_LIGHTS].location, &light_count));
vec3 camera_pos = {0, 0, 0}; vec3 camera_pos = {0, 0, 0};
transform_get_absolute_position(&camera->base, &camera_pos); transform_get_absolute_position(&camera->base, &camera_pos);
GL_CHECK(shader_set_uniform(material->pipeline_params[MPP_CAM_POS].type, material->pipeline_params[MPP_CAM_POS].location, &camera_pos)); GL_CHECK(shader_set_uniform(material->pipeline_params[MPP_CAM_POS].type, material->pipeline_params[MPP_CAM_POS].location, &camera_pos));

@ -6,6 +6,7 @@
#include "material.h" #include "material.h"
struct Sprite_Batch; struct Sprite_Batch;
struct Scene;
enum Fog_Mode enum Fog_Mode
{ {

@ -10,8 +10,8 @@
#define MAX_STATIC_MESHES 1024 #define MAX_STATIC_MESHES 1024
#define MAX_SOUND_SOURCES 128 #define MAX_SOUND_SOURCES 128
struct Ray; struct Ray;
struct Raycast_Result;
struct Scene struct Scene
{ {

Loading…
Cancel
Save