Began work on editor and fixed bug with mousewheel events

dev
Shariq Shah 9 years ago
parent 3389c423df
commit 97ac88e7da
  1. 5
      orgfile.org
  2. 79
      src/editor.c
  3. 8
      src/editor.h
  4. 1226
      src/game.c
  5. 2
      src/gui.c
  6. 2
      src/model.c
  7. 3
      src/platform.c
  8. 2
      src/renderer.c
  9. 2
      src/renderer.h

@ -81,8 +81,6 @@ All the code in this repository is under GPLv3, see LICENSE for more information
- State "CANCELED" from "TODO" [2017-02-26 Sun 15:39] \\ - State "CANCELED" from "TODO" [2017-02-26 Sun 15:39] \\
Deferred rendering on hold for now. Deferred rendering on hold for now.
** TODO Fix problems with frustrum culling ** TODO Fix problems with frustrum culling
** TODO
** TODO
- Recalculate bounding boxes for rotated meshes? - Recalculate bounding boxes for rotated meshes?
** TODO 2d drawing routines ** TODO 2d drawing routines
- Sprite batching - Sprite batching
@ -95,6 +93,9 @@ All the code in this repository is under GPLv3, see LICENSE for more information
- State "CANCELED" from "TODO" [2017-02-26 Sun 01:49] \\ - State "CANCELED" from "TODO" [2017-02-26 Sun 01:49] \\
Sticking with forward rendering for now and focusing on tools etc. Sticking with forward rendering for now and focusing on tools etc.
** TODO Fix mouse bugs on windows ** TODO Fix mouse bugs on windows
** TODO Fix mousewheel bugs and gui not responding to mousewheel input
** TODO Ability to mark meshes for debug rendering with possibility of different color for each?
** TODO Setup cross compilation with mingw or stick to msvc?
** DONE Toggleable debug drawing for meshes ** DONE Toggleable debug drawing for meshes
- State "DONE" from "TODO" [2017-03-18 Sat 16:18] - State "DONE" from "TODO" [2017-03-18 Sat 16:18]
** TODO Interleaved vbos for meshes and changes to blender exporter accordingly ** TODO Interleaved vbos for meshes and changes to blender exporter accordingly

@ -0,0 +1,79 @@
#include "editor.h"
#include "renderer.h"
#include "gl_load.h"
#include "log.h"
#include "camera.h"
#include "model.h"
#include "texture.h"
#include "framebuffer.h"
#include "array.h"
#include "shader.h"
#include "num_types.h"
#include "light.h"
#include "entity.h"
#include "transform.h"
#include "game.h"
#include "gui.h"
struct Editor_State
{
int enabled;
int debug_window_enabled;
int top_panel_height;
};
static struct Editor_State editor_state;
void editor_init(void)
{
editor_state.enabled = 1;
editor_state.debug_window_enabled = 0;
editor_state.top_panel_height = 50;
}
void editor_update(float dt)
{
if(!editor_state.enabled) return;
struct Game_State* game_state = game_state_get();
struct Gui_State* gui_state = gui_state_get();
struct nk_context* context = &gui_state->context;
struct Render_Settings* render_settings = renderer_settings_get();
int win_width = 0, win_height = 0;
window_get_drawable_size(game_state->window, &win_width, &win_height);
static int debug_window = 1;
/* Top Panel */
if(nk_begin(context, "Top_Panel", nk_recti(0, 0, win_width, win_height - (win_height - editor_state.top_panel_height)),
NK_WINDOW_NO_SCROLLBAR | NK_WINDOW_BACKGROUND))
{
nk_layout_row_static(context, 40, 100, 2);
if(nk_button_label(context, "Debug")) editor_state.debug_window_enabled = !editor_state.debug_window_enabled;
}
nk_end(context);
/* Debug Window */
if(debug_window)
{
if(nk_begin_titled(context, "Debug_Window", "Debug", nk_recti(0, 0, 200, 200),
NK_WINDOW_BORDER | NK_WINDOW_CLOSABLE | NK_WINDOW_MOVABLE |
NK_WINDOW_SCROLL_AUTO_HIDE | NK_WINDOW_DYNAMIC))
{
debug_window = 1;
nk_layout_row_static(context, 40, 50, 1);
nk_checkbox_label(context, "Debug Draw", &render_settings->debug_draw_enabled);
}
else
{
debug_window = 0;
}
nk_end(context);
}
}
void editor_toggle(void)
{
editor_state.enabled = !editor_state.enabled;
}

@ -0,0 +1,8 @@
#ifndef EDITOR_H
#define EDITOR_H
void editor_init(void);
void editor_update(float dt);
void editor_toggle(void);
#endif

File diff suppressed because it is too large Load Diff

@ -88,7 +88,7 @@ int gui_init(void)
platform_textinput_callback_set(&gui_handle_textinput_event); platform_textinput_callback_set(&gui_handle_textinput_event);
gui_font_set("roboto.ttf", 18); gui_font_set("roboto.ttf", 18);
gui_theme_set(GT_DARK); gui_theme_set(GT_DEFAULT);
success = 1; success = 1;
return success; return success;
} }

@ -136,7 +136,7 @@ void model_render_all(struct Camera* camera, enum Geometry_Draw_Mode draw_mode)
} }
/* Set pipeline uniforms */ /* Set pipeline uniforms */
struct Render_Settings* render_settings = renderer_get_settings(); struct Render_Settings* render_settings = renderer_settings_get();
for(int k = 0; k < array_len(material->pipeline_params); k++) for(int k = 0; k < array_len(material->pipeline_params); k++)
{ {
/* TODO: change this into something better */ /* TODO: change this into something better */

@ -210,16 +210,19 @@ void platform_poll_events(int* out_quit)
int x = event.motion.x; int x = event.motion.x;
int y = event.motion.y; int y = event.motion.y;
platform_state->on_mousemotion_func(x, y, xrel, yrel); platform_state->on_mousemotion_func(x, y, xrel, yrel);
break;
} }
case SDL_MOUSEWHEEL: case SDL_MOUSEWHEEL:
{ {
int x = event.wheel.x; int x = event.wheel.x;
int y = event.wheel.y; int y = event.wheel.y;
platform_state->on_mousewheel_func(x, y); platform_state->on_mousewheel_func(x, y);
break;
} }
case SDL_TEXTINPUT: case SDL_TEXTINPUT:
{ {
platform_state->on_textinput_func(event.text.text); platform_state->on_textinput_func(event.text.text);
break;
} }
case SDL_WINDOWEVENT: case SDL_WINDOWEVENT:
{ {

@ -252,7 +252,7 @@ int renderer_check_glerror(const char* context)
return error; return error;
} }
struct Render_Settings* renderer_get_settings(void) struct Render_Settings* renderer_settings_get(void)
{ {
return &settings; return &settings;
} }

@ -33,7 +33,7 @@ struct Render_Settings
enum Geometry_Draw_Mode debug_draw_mode; enum Geometry_Draw_Mode debug_draw_mode;
}; };
struct Render_Settings* renderer_get_settings(void); struct Render_Settings* renderer_settings_get(void);
void renderer_init(void); void renderer_init(void);
void renderer_draw(void); void renderer_draw(void);
void renderer_cleanup(void); void renderer_cleanup(void);

Loading…
Cancel
Save