Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
aschuhardt committed Nov 24, 2020
1 parent 864bdd4 commit 1010f5e
Show file tree
Hide file tree
Showing 34 changed files with 511 additions and 468 deletions.
2 changes: 1 addition & 1 deletion include/color.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ typedef struct procy_color_t {

procy_color_t procy_create_color(float r, float g, float b);

bool procy_colors_equal(procy_color_t* first, procy_color_t* second);
bool procy_colors_equal(procy_color_t *first, procy_color_t *second);

#endif
34 changes: 18 additions & 16 deletions include/drawing.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,34 +32,36 @@ typedef struct procy_draw_op_t {
} data;
} procy_draw_op_t;

void procy_draw_string(struct procy_window_t* window, short x, short y,
void procy_draw_string(struct procy_window_t *window, short x, short y,
procy_color_t forecolor, procy_color_t backcolor,
const char* contents);
const char *contents);

void procy_draw_string_bold(struct procy_window_t* window, short x, short y,
void procy_draw_string_bold(struct procy_window_t *window, short x, short y,
procy_color_t forecolor, procy_color_t backcolor,
const char* contents);
const char *contents);

void procy_draw_rect(struct procy_window_t* window, short x, short y, short width,
short height, procy_color_t color);
void procy_draw_rect(struct procy_window_t *window, short x, short y,
short width, short height, procy_color_t color);

void procy_draw_line(struct procy_window_t* window, short x1, short y1, short x2,
short y2, procy_color_t color);
void procy_draw_line(struct procy_window_t *window, short x1, short y1,
short x2, short y2, procy_color_t color);
/*
* Returns a new text drawing operation for the character at the provided
* index in a string whose first character's position is the given pixel
* position
*/
procy_draw_op_t procy_create_draw_op_string(short x, short y, int size,
const char* contents, size_t index,
const char *contents, size_t index,
bool bold);
/*
* Returns a new text drawing operation bearing the provided foreground color,
* at the provided pixel coordinates
*/
procy_draw_op_t procy_create_draw_op_string_colored(
short x, short y, int size, procy_color_t forecolor, procy_color_t backcolor,
const char* contents, size_t index, bool bold);
procy_draw_op_t procy_create_draw_op_string_colored(short x, short y, int size,
procy_color_t forecolor,
procy_color_t backcolor,
const char *contents,
size_t index, bool bold);

procy_draw_op_t procy_create_draw_op_char(short x, short y, char c, bool bold);

Expand All @@ -68,10 +70,10 @@ procy_draw_op_t procy_create_draw_op_char_colored(short x, short y,
procy_color_t backcolor,
char c, bool bold);

procy_draw_op_t procy_create_draw_op_rect(short x, short y, short width, short height,
procy_color_t color);
procy_draw_op_t procy_create_draw_op_rect(short x, short y, short width,
short height, procy_color_t color);

procy_draw_op_t procy_create_draw_op_line(short x1, short y1, short x2, short y2,
procy_color_t color);
procy_draw_op_t procy_create_draw_op_line(short x1, short y1, short x2,
short y2, procy_color_t color);

#endif
4 changes: 2 additions & 2 deletions include/keys.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
#include <stddef.h>

typedef struct procy_key_info_t {
const char* name;
const char *name;
int value;
} procy_key_info_t;

void procy_get_keys(procy_key_info_t** buffer, size_t* len);
void procy_get_keys(procy_key_info_t **buffer, size_t *len);

#define KEY_SPACE 32
#define KEY_APOSTROPHE 39
Expand Down
3 changes: 2 additions & 1 deletion include/procyon.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

#ifdef WIN32

// when NVIDIA Optimus is present, we need to indicate that the device should use the discrete GPU for running this
// when NVIDIA Optimus is present, we need to indicate that the device should
// use the discrete GPU for running this

#include <windows.h>

Expand Down
8 changes: 4 additions & 4 deletions include/shader.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ typedef struct procy_shader_program_t {
bool valid;
} procy_shader_program_t;

void procy_destroy_shader_program(procy_shader_program_t* shader);
void procy_destroy_shader_program(procy_shader_program_t *shader);

bool procy_compile_frag_shader(const char* data, unsigned int* index);
bool procy_compile_frag_shader(const char *data, unsigned int *index);

bool procy_compile_vert_shader(const char* data, unsigned int* index);
bool procy_compile_vert_shader(const char *data, unsigned int *index);

bool procy_link_shader_program(unsigned int vert, unsigned int frag,
unsigned int* index);
unsigned int *index);

#endif
8 changes: 4 additions & 4 deletions include/shader/error.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

#ifndef NDEBUG

const char* gl_error_string(int err);
const char *gl_error_string(int err);

void gl_print_errors(int line, const char* expr, const char* file);
void gl_print_errors(int line, const char *expr, const char *file);

#define GL_CHECK(expr) \
expr; \
#define GL_CHECK(expr) \
expr; \
gl_print_errors(__LINE__, #expr, __FILE__);

#else
Expand Down
12 changes: 6 additions & 6 deletions include/shader/glyph.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,25 @@ typedef struct procy_glyph_shader_program_t {
* Builds and compiles a shader program with information for rendering text
* glyphs from a bitmap font.
*/
procy_glyph_shader_program_t* procy_create_glyph_shader(float scale);
procy_glyph_shader_program_t *procy_create_glyph_shader(float scale);

/*
* Builds and executes a draw call on the GPU, consisting of vertex data built
* from all of the `GLYPH` type draw operations
*/
void procy_draw_glyph_shader(procy_glyph_shader_program_t* shader,
struct procy_window_t* window);
void procy_draw_glyph_shader(procy_glyph_shader_program_t *shader,
struct procy_window_t *window);

/*
* Computes scaled glyph bounds in pixels
*/
void procy_get_glyph_bounds(procy_glyph_shader_program_t* shader, int* width,
int* height);
void procy_get_glyph_bounds(procy_glyph_shader_program_t *shader, int *width,
int *height);

/*
* Disposes of a glyph shader program and deletes its bound resources from
* the OpenGL context
*/
void procy_destroy_glyph_shader(procy_glyph_shader_program_t* shader);
void procy_destroy_glyph_shader(procy_glyph_shader_program_t *shader);

#endif
10 changes: 5 additions & 5 deletions include/shader/line.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
typedef struct procy_line_shader_program_t {
unsigned int u_ortho;
procy_shader_program_t program;
void* vertex_batch_buffer;
void *vertex_batch_buffer;
} procy_line_shader_program_t;

procy_line_shader_program_t* procy_create_line_shader();
procy_line_shader_program_t *procy_create_line_shader();

void procy_destroy_line_shader(procy_line_shader_program_t* shader);
void procy_destroy_line_shader(procy_line_shader_program_t *shader);

void procy_draw_line_shader(procy_line_shader_program_t* shader,
struct procy_window_t* window);
void procy_draw_line_shader(procy_line_shader_program_t *shader,
struct procy_window_t *window);

#endif
8 changes: 4 additions & 4 deletions include/shader/rect.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ typedef struct procy_rect_shader_program_t {
void *vertex_batch_buffer, *index_batch_buffer;
} procy_rect_shader_program_t;

procy_rect_shader_program_t* procy_create_rect_shader();
procy_rect_shader_program_t *procy_create_rect_shader();

void procy_destroy_rect_shader(procy_rect_shader_program_t* shader);
void procy_destroy_rect_shader(procy_rect_shader_program_t *shader);

void procy_draw_rect_shader(procy_rect_shader_program_t* shader,
struct procy_window_t* window);
void procy_draw_rect_shader(procy_rect_shader_program_t *shader,
struct procy_window_t *window);

#endif
26 changes: 13 additions & 13 deletions include/state.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@
struct procy_state_t;
struct procy_key_info_t;

typedef void (*procy_on_load_callback_t)(struct procy_state_t*);
typedef void (*procy_on_unload_callback_t)(struct procy_state_t*);
typedef void (*procy_on_draw_callback_t)(struct procy_state_t*, double);
typedef void (*procy_on_resize_callback_t)(struct procy_state_t*, int, int);
typedef void (*procy_on_key_pressed_callback_t)(struct procy_state_t*,
typedef void (*procy_on_load_callback_t)(struct procy_state_t *);
typedef void (*procy_on_unload_callback_t)(struct procy_state_t *);
typedef void (*procy_on_draw_callback_t)(struct procy_state_t *, double);
typedef void (*procy_on_resize_callback_t)(struct procy_state_t *, int, int);
typedef void (*procy_on_key_pressed_callback_t)(struct procy_state_t *,
struct procy_key_info_t, bool,
bool, bool);
typedef void (*procy_on_key_released_callback_t)(struct procy_state_t*,
typedef void (*procy_on_key_released_callback_t)(struct procy_state_t *,
struct procy_key_info_t, bool,
bool, bool);
typedef void (*procy_on_char_entered_callback_t)(struct procy_state_t*,
typedef void (*procy_on_char_entered_callback_t)(struct procy_state_t *,
unsigned int);

typedef struct procy_state_t {
void* data;
struct procy_state_t* parent;
struct procy_state_t** children;
void *data;
struct procy_state_t *parent;
struct procy_state_t **children;
size_t child_count;
procy_on_load_callback_t on_load;
procy_on_unload_callback_t on_unload;
Expand All @@ -34,15 +34,15 @@ typedef struct procy_state_t {
procy_on_char_entered_callback_t on_char_entered;
} procy_state_t;

procy_state_t* procy_create_callback_state(
procy_state_t *procy_create_callback_state(
procy_on_load_callback_t on_load, procy_on_unload_callback_t on_unload,
procy_on_draw_callback_t on_draw, procy_on_resize_callback_t on_resize,
procy_on_key_pressed_callback_t on_key_pressed,
procy_on_key_released_callback_t on_key_released,
procy_on_char_entered_callback_t on_char_entered);

void procy_append_child_state(procy_state_t* parent, procy_state_t* child);
void procy_append_child_state(procy_state_t *parent, procy_state_t *child);

void procy_destroy_callback_state(procy_state_t* state);
void procy_destroy_callback_state(procy_state_t *state);

#endif
38 changes: 19 additions & 19 deletions include/window.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,49 +15,49 @@ struct procy_line_shader_program_t;
struct GLFWwindow;

typedef struct procy_draw_op_buffer_t {
struct procy_draw_op_t* buffer;
struct procy_draw_op_t *buffer;
size_t length;
size_t capacity;
} procy_draw_op_buffer_t;

typedef struct procy_shaders_t {
struct procy_glyph_shader_program_t* glyph;
struct procy_rect_shader_program_t* rect;
struct procy_line_shader_program_t* line;
struct procy_glyph_shader_program_t *glyph;
struct procy_rect_shader_program_t *rect;
struct procy_line_shader_program_t *line;
} procy_shaders_t;

typedef struct procy_window_t {
procy_draw_op_buffer_t draw_ops;
procy_shaders_t shaders;
float ortho[4][4];
bool quitting, high_fps;
struct procy_state_t* state;
struct procy_key_info_t* key_table;
struct GLFWwindow* glfw_win;
struct procy_state_t *state;
struct procy_key_info_t *key_table;
struct GLFWwindow *glfw_win;
} procy_window_t;

procy_window_t* procy_create_window(int width, int height, const char* title,
procy_window_t *procy_create_window(int width, int height, const char *title,
float text_scale,
struct procy_state_t* state);
struct procy_state_t *state);

void procy_destroy_window(procy_window_t* window);
void procy_destroy_window(procy_window_t *window);

void procy_begin_loop(procy_window_t* window);
void procy_begin_loop(procy_window_t *window);

void procy_append_draw_op(procy_window_t* window,
struct procy_draw_op_t* draw_op);
void procy_append_draw_op(procy_window_t *window,
struct procy_draw_op_t *draw_op);

void procy_append_draw_ops(procy_window_t* window,
struct procy_draw_op_t* draw_ops, size_t n);
void procy_append_draw_ops(procy_window_t *window,
struct procy_draw_op_t *draw_ops, size_t n);

void procy_get_window_size(procy_window_t* window, int* width, int* height);
void procy_get_window_size(procy_window_t *window, int *width, int *height);

void procy_get_glyph_size(procy_window_t* window, int* width, int* height);
void procy_get_glyph_size(procy_window_t *window, int *width, int *height);

void procy_set_clear_color(procy_color_t c);

void procy_set_glyph_scale(procy_window_t* window, float scale);
void procy_set_glyph_scale(procy_window_t *window, float scale);

void procy_close_window(procy_window_t* window);
void procy_close_window(procy_window_t *window);

#endif
2 changes: 1 addition & 1 deletion lua/include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ typedef struct config_t {
float glyph_scale;
} config_t;

bool parse_config_args(int argc, const char** argv, config_t* cfg);
bool parse_config_args(int argc, const char **argv, config_t *cfg);

#endif
16 changes: 8 additions & 8 deletions lua/include/script.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ struct script_env_t;
struct procy_state_t;

typedef struct script_env_t {
struct lua_State* L;
struct procy_window_t* window;
struct procy_state_t* state;
bool reload; // when true, restart the in main after main loop ends
struct lua_State *L;
struct procy_window_t *window;
struct procy_state_t *state;
bool reload; // when true, restart the in main after main loop ends
} script_env_t;

script_env_t* create_script_env(struct procy_window_t* window,
struct procy_state_t* state);
script_env_t *create_script_env(struct procy_window_t *window,
struct procy_state_t *state);

void destroy_script_env(script_env_t* env);
void destroy_script_env(script_env_t *env);

bool load_scripts(script_env_t* env, char* path);
bool load_scripts(script_env_t *env, char *path);

#endif
16 changes: 8 additions & 8 deletions lua/include/script/environment.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@ typedef struct lua_State lua_State;
typedef struct script_env_t script_env_t;
typedef struct state_t state_t;

void add_globals(lua_State* L, script_env_t* env);
void add_input(lua_State* L, script_env_t* env);
void add_drawing(lua_State* L, script_env_t* env);
void add_window(lua_State* L, script_env_t* env);
void add_utilities(lua_State* L);
void add_globals(lua_State *L, script_env_t *env);
void add_input(lua_State *L, script_env_t *env);
void add_drawing(lua_State *L, script_env_t *env);
void add_window(lua_State *L, script_env_t *env);
void add_utilities(lua_State *L);

/*
* Utility methods available to script-setup logic
*/

bool verify_arg_count(lua_State* L, int n, const char* name);
bool verify_arg_count(lua_State *L, int n, const char *name);

void push_rgb_table(lua_State* L, float r, float g, float b);
void push_rgb_table(lua_State *L, float r, float g, float b);

procy_color_t get_color(lua_State* L, int index);
procy_color_t get_color(lua_State *L, int index);

#endif
Loading

0 comments on commit 1010f5e

Please sign in to comment.