This commit is contained in:
John Alanbrook 2022-08-14 19:19:36 +00:00
parent b0d2757f70
commit 28c69ff62f
27 changed files with 900 additions and 1117 deletions

View file

@ -89,18 +89,18 @@ yuginec = ./source/engine/yugine.c
ENGINE = $(BIN)libengine.a ENGINE = $(BIN)libengine.a
INCLUDE = $(BIN)include INCLUDE = $(BIN)include
LINK = $(LIBPATH) $(LINKER_FLAGS) $(LELIBS) -o $@ LINK = $(LIBPATH) $(LINKER_FLAGS) $(LELIBS)
engine: $(yuginec:.%.c=$(objprefix)%.o) $(ENGINE) engine: $(yuginec:.%.c=$(objprefix)%.o) $(ENGINE)
@echo Linking engine @echo Linking engine
$(CLINK) $< $(LINK) $(CLINK) $< $(LINK) -o $@
@echo Finished build @echo Finished build
bs: engine bs: engine
cp engine brainstorm cp engine brainstorm
ed: engine pin: engine
cp engine editor cp engine pinball
$(ENGINE): $(eobjects) bin/libglfw3.a $(ENGINE): $(eobjects) bin/libglfw3.a
@echo Making library engine.a @echo Making library engine.a

View file

View file

@ -1,10 +0,0 @@
window = win_make("editor")
nuke_cb(window, :editor)
def editor
editor_render()
end
def update(dt)
end

601
source/engine/editor.c Executable file → Normal file

File diff suppressed because it is too large Load diff

View file

@ -31,10 +31,13 @@ struct editorVars {
bool showLevel; bool showLevel;
}; };
struct gameproject { struct vec;
char name[127]; struct gameproject;
char path[MAXPATH]; struct mSprite;
};
extern struct gameproject *cur_project;
extern struct vec *projects;
struct Texture; struct Texture;
struct mSDLWindow; struct mSDLWindow;
@ -51,13 +54,6 @@ void editor_makenewobject();
void editor_project_gui(); void editor_project_gui();
void editor_init_project(struct gameproject *gp);
void editor_save_projects();
void editor_load_projects();
void editor_proj_select_gui();
void editor_import_project(char *path);
void editor_make_project(char *path);
void editor_selectasset(struct fileasset *asset); void editor_selectasset(struct fileasset *asset);
void editor_selectasset_str(char *path); void editor_selectasset_str(char *path);
void editor_asset_gui(struct fileasset *asset); void editor_asset_gui(struct fileasset *asset);

View file

@ -40,7 +40,7 @@ void font_init(struct mShader *textshader) {
// Default font // Default font
font = MakeFont("notosans.ttf", 300); font = MakeFont("teenytinypixels.ttf", 300);
} }
void font_frame(struct mSDLWindow *w) { void font_frame(struct mSDLWindow *w) {

View file

@ -39,7 +39,6 @@ void nuke_start()
void nuke_end() void nuke_end()
{ {
nk_end(ctx);
nk_glfw3_render(&nkglfw, NK_ANTI_ALIASING_ON, MAX_VERTEX_BUFFER, MAX_ELEMENT_BUFFER); nk_glfw3_render(&nkglfw, NK_ANTI_ALIASING_ON, MAX_VERTEX_BUFFER, MAX_ELEMENT_BUFFER);
} }

View file

@ -93,31 +93,6 @@ struct mSprite *tsprite = NULL;
static unsigned int projUBO; static unsigned int projUBO;
const char *textvert =
"#version 330 core\n"
"layout (location = 0) in vec4 vertex; \n"
"out vec2 TexCoords;\n"
"uniform mat4 projection;\n"
"void main() {\n"
" gl_Position = projection * vec4(vertex.xy, 0.0, 1.0);\n"
" TexCoords = vec2(vertex.z, 1.0 - vertex.w);\n"
"}\n";
const char *textfrag =
"#version 330 core\n"
"in vec2 TexCoords;\n"
"out vec4 color;\n"
"uniform sampler2D text;\n"
"uniform vec3 textColor;\n"
"void main() { \n"
" vec4 sampled = vec4(1.0, 1.0, 1.0, texture(text, TexCoords).r);\n"
" color = vec4(textColor, 1.0) * sampled;\n"
"}\n";
void openglInit() void openglInit()
{ {
if (!mainwin) { if (!mainwin) {
@ -126,11 +101,9 @@ void openglInit()
} }
////// MAKE SHADERS ////// MAKE SHADERS
outlineShader = MakeShader("outlinevert.glsl", "outline.glsl");
spriteShader = MakeShader("spritevert.glsl", "spritefrag.glsl"); spriteShader = MakeShader("spritevert.glsl", "spritefrag.glsl");
animSpriteShader = MakeShader("animspritevert.glsl", "animspritefrag.glsl"); animSpriteShader = MakeShader("animspritevert.glsl", "animspritefrag.glsl");
textShader = MakeShader("textvert.glsl", "textfrag.glsl"); textShader = MakeShader("textvert.glsl", "textfrag.glsl");
//textShader = CreateShader(textverg, textfrag);
shader_use(textShader); shader_use(textShader);
shader_setint(textShader, "text", 0); shader_setint(textShader, "text", 0);
@ -139,7 +112,7 @@ void openglInit()
font_init(textShader); font_init(textShader);
sprite_initialize(); sprite_initialize();
//debugdraw_init(); debugdraw_init();
//glEnable(GL_STENCIL_TEST); //glEnable(GL_STENCIL_TEST);
@ -168,8 +141,6 @@ void openglInit()
shader_setUBO(spriteShader, "Projection", 0); shader_setUBO(spriteShader, "Projection", 0);
shader_setUBO(textShader, "Projection", 0); shader_setUBO(textShader, "Projection", 0);
shader_setUBO(animSpriteShader, "Projection", 0); shader_setUBO(animSpriteShader, "Projection", 0);
} }

View file

@ -272,7 +272,13 @@ void window_render(struct mSDLWindow *w) {
nuke_start(); nuke_start();
script_call_sym(w->nuke_cb); script_call_sym(w->nuke_cb);
nuke_end(); nuke_end();
} else if (w->nuke_gui != NULL) {
nuke_start();
w->nuke_gui();
nuke_end();
} }
window_swap(w); window_swap(w);
} }

View file

@ -23,6 +23,7 @@ struct mSDLWindow {
float projection[16]; float projection[16];
mrb_sym nuke_cb; mrb_sym nuke_cb;
mrb_sym gui_cb; mrb_sym gui_cb;
void (*nuke_gui)();
}; };
struct Texture; struct Texture;

View file

@ -5,6 +5,8 @@
#include "input.h" #include "input.h"
#include "openglrender.h" #include "openglrender.h"
#include "string.h"
int physOn = 0; int physOn = 0;
double renderlag = 0; double renderlag = 0;
@ -15,13 +17,28 @@ double renderMS = 1/60.f;
double physMS = 1/120.f; double physMS = 1/120.f;
double updateMS = 1/60.f; double updateMS = 1/60.f;
static int ed = 1;
int main(int argc, char **args) { int main(int argc, char **args) {
for (int i = 1; i < argc; i++) {
if (args[i][0] == '-') {
if (strncmp(args[i][1], "play", 4) == 0) {
ed = 0;
}
}
}
engine_init(); engine_init();
window_set_icon("icon.png"); window_set_icon("icon.png");
if (ed) {
editor_init(MakeSDLWindow("Editor", 600, 600, 0));
} else {
script_dofile("game.rb"); script_dofile("game.rb");
}
openglInit(); openglInit();
@ -45,7 +62,7 @@ int main(int argc, char **args) {
input_poll(updateMS - elapsed < 0 ? 0 : updateMS - elapsed); input_poll(updateMS - elapsed < 0 ? 0 : updateMS - elapsed);
window_all_handle_events(); window_all_handle_events();
script_update(updateMS);
} }
} }