Moved source file locations for easier compiling; cleaned up Makefile; cleaned up opengl code
This commit is contained in:
parent
18eefd4937
commit
60bf5ca7bc
44
Makefile
44
Makefile
|
@ -36,14 +36,11 @@ define rm
|
||||||
rm $${tmp}
|
rm $${tmp}
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define findindir
|
|
||||||
find $(1) -maxdepth 1 -type f -name '$(2)'
|
|
||||||
endef
|
|
||||||
|
|
||||||
# All other sources
|
# All other sources
|
||||||
edirs != find source -type d -name include
|
edirs != find source -type d -name include
|
||||||
edirs += source/engine source/engine/thirdparty/Nuklear
|
subengs = sound debug editor 3d
|
||||||
ehead != $(call findindir, source/engine,*.h)
|
edirs += source/engine $(addprefix source/engine/, $(subengs)) source/engine/thirdparty/Nuklear
|
||||||
|
ehead != find source/engine source/engine/sound source/engine/debug source/engine/editor -maxdepth 1 -type f -name *.h
|
||||||
eobjects != find source/engine -type f -name '*.c' | sed -r 's|^(.*)\.c|$(objprefix)/\1.o|' # Gets all .c files and makes .o refs
|
eobjects != find source/engine -type f -name '*.c' | sed -r 's|^(.*)\.c|$(objprefix)/\1.o|' # Gets all .c files and makes .o refs
|
||||||
eobjects != $(call rm,$(eobjects),sqlite pl_mpeg_extract_frames pl_mpeg_player yugine nuklear)
|
eobjects != $(call rm,$(eobjects),sqlite pl_mpeg_extract_frames pl_mpeg_player yugine nuklear)
|
||||||
|
|
||||||
|
@ -88,24 +85,33 @@ LINK = $(LIBPATH) $(LINKER_FLAGS) $(ELIBS)
|
||||||
|
|
||||||
MYTAG = $(VER)_$(PTYPE)_$(INFO)
|
MYTAG = $(VER)_$(PTYPE)_$(INFO)
|
||||||
|
|
||||||
|
DIST = yugine-$(MYTAG).tar.gz
|
||||||
|
|
||||||
.PHONY: yugine
|
.PHONY: yugine
|
||||||
|
|
||||||
yugine: $(objprefix)/source/engine/yugine.o $(ENGINE)
|
$(BIN)yugine: $(objprefix)/source/engine/yugine.o $(ENGINE)
|
||||||
@echo $(CC)
|
|
||||||
@echo Linking yugine
|
@echo Linking yugine
|
||||||
$(CC) $< $(LINK) -o yugine
|
$(CC) $< $(LINK) -o $(BIN)yugine
|
||||||
@echo Finished build
|
@echo Finished build
|
||||||
|
|
||||||
dist: yugine
|
$(BIN)$(DIST): $(BIN)yugine
|
||||||
mkdir -p bin/dist
|
@echo Creating distribution zip
|
||||||
cp yugine bin/dist
|
@mkdir -p $(BIN)dist
|
||||||
cp -rf assets/fonts bin/dist
|
@cp $(BIN)yugine $(BIN)dist
|
||||||
cp -rf source/scripts bin/dist
|
@cp -rf assets/fonts $(BIN)dist
|
||||||
cp -rf source/shaders bin/dist
|
@cp -rf source/scripts $(BIN)dist
|
||||||
tar -czf yugine-$(MYTAG).tar.gz --directory bin/dist .
|
@cp -rf source/shaders $(BIN)dist
|
||||||
|
@tar czf $(DIST) --directory $(BIN)dist .
|
||||||
|
@mv $(DIST) $(BIN)
|
||||||
|
|
||||||
install: yugine
|
|
||||||
cp yugine ~/.local/bin
|
dist: $(BIN)$(DIST)
|
||||||
|
|
||||||
|
install: $(BIN)$(DIST)
|
||||||
|
@echo Unpacking distribution in $(DESTDIR)
|
||||||
|
@cp $(BIN)$(DIST) $(DESTDIR)
|
||||||
|
@tar xzf $(DESTDIR)/$(DIST) -C $(DESTDIR)
|
||||||
|
@rm $(DESTDIR)/$(DIST)
|
||||||
|
|
||||||
$(ENGINE): $(eobjects)
|
$(ENGINE): $(eobjects)
|
||||||
@echo Making library engine.a
|
@echo Making library engine.a
|
||||||
|
@ -122,4 +128,4 @@ $(objprefix)/%.o:%.c
|
||||||
clean:
|
clean:
|
||||||
@echo Cleaning project
|
@echo Cleaning project
|
||||||
@find $(BIN) -type f -delete
|
@find $(BIN) -type f -delete
|
||||||
@rm -rf source/portaudio/build source/glfw/build
|
@rm -f *.gz
|
||||||
|
|
|
@ -16,8 +16,7 @@ struct mCamera {
|
||||||
|
|
||||||
void camera_2d_update(struct mCamera *camera, float deltaT);
|
void camera_2d_update(struct mCamera *camera, float deltaT);
|
||||||
|
|
||||||
mfloat_t *getviewmatrix(mfloat_t view[MAT4_SIZE],
|
mfloat_t *getviewmatrix(mfloat_t view[MAT4_SIZE], const struct mCamera *const camera);
|
||||||
const struct mCamera *const camera);
|
|
||||||
void cam_goto_object(struct mCamera *cam, struct mTransform *transform);
|
void cam_goto_object(struct mCamera *cam, struct mTransform *transform);
|
||||||
void cam_inverse_goto(struct mCamera *cam, struct mTransform *transform);
|
void cam_inverse_goto(struct mCamera *cam, struct mTransform *transform);
|
||||||
|
|
||||||
|
|
|
@ -37,8 +37,7 @@ void debugdraw_init()
|
||||||
glGenVertexArrays(1, &gridVAO);
|
glGenVertexArrays(1, &gridVAO);
|
||||||
glBindVertexArray(gridVAO);
|
glBindVertexArray(gridVAO);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, gridVBO);
|
glBindBuffer(GL_ARRAY_BUFFER, gridVBO);
|
||||||
glBufferData(GL_ARRAY_BUFFER, sizeof(gridverts), &gridverts,
|
glBufferData(GL_ARRAY_BUFFER, sizeof(gridverts), &gridverts, GL_STATIC_DRAW);
|
||||||
GL_STATIC_DRAW);
|
|
||||||
glEnableVertexAttribArray(0);
|
glEnableVertexAttribArray(0);
|
||||||
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, NULL);
|
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, NULL);
|
||||||
|
|
||||||
|
@ -56,24 +55,12 @@ void draw_line(int x1, int y1, int x2, int y2)
|
||||||
x2, y2
|
x2, y2
|
||||||
};
|
};
|
||||||
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, rectVBO);
|
draw_poly(&verts, 2);
|
||||||
glBufferData(GL_ARRAY_BUFFER, sizeof(verts), &verts, GL_DYNAMIC_DRAW);
|
|
||||||
glBindVertexArray(rectVAO);
|
|
||||||
glEnableVertexAttribArray(0);
|
|
||||||
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, NULL);
|
|
||||||
glDrawArrays(GL_LINE_STRIP, 0, 2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void draw_edge(float *points, int n)
|
void draw_edge(float *points, int n)
|
||||||
{
|
{
|
||||||
shader_use(rectShader);
|
draw_poly(points, n);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, rectVBO);
|
|
||||||
glBufferData(GL_ARRAY_BUFFER, sizeof(float) * n * 2, points,
|
|
||||||
GL_DYNAMIC_DRAW);
|
|
||||||
glBindVertexArray(rectVAO);
|
|
||||||
glEnableVertexAttribArray(0);
|
|
||||||
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, NULL);
|
|
||||||
glDrawArrays(GL_LINE_STRIP, 0, n);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void draw_circle(int x, int y, float radius, int pixels)
|
void draw_circle(int x, int y, float radius, int pixels)
|
||||||
|
@ -81,10 +68,10 @@ void draw_circle(int x, int y, float radius, int pixels)
|
||||||
shader_use(circleShader);
|
shader_use(circleShader);
|
||||||
|
|
||||||
float verts[] = {
|
float verts[] = {
|
||||||
x - radius, y - radius, -1.f, -1.f,
|
x - radius, y - radius,
|
||||||
x + radius, y - radius, 1.f, -1.f,
|
x + radius, y - radius,
|
||||||
x - radius, y + radius, -1.f, 1.f,
|
x - radius, y + radius,
|
||||||
x + radius, y + radius, 1.f, 1.f
|
x + radius, y + radius,
|
||||||
};
|
};
|
||||||
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, circleVBO);
|
glBindBuffer(GL_ARRAY_BUFFER, circleVBO);
|
||||||
|
@ -95,7 +82,7 @@ void draw_circle(int x, int y, float radius, int pixels)
|
||||||
|
|
||||||
glBindVertexArray(circleVAO);
|
glBindVertexArray(circleVAO);
|
||||||
glEnableVertexAttribArray(0);
|
glEnableVertexAttribArray(0);
|
||||||
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, NULL);
|
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, NULL);
|
||||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,13 +98,7 @@ void draw_rect(int x, int y, int w, int h)
|
||||||
x - hw, y + hh
|
x - hw, y + hh
|
||||||
};
|
};
|
||||||
|
|
||||||
shader_use(rectShader);
|
draw_poly(&verts, 4);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, rectVBO);
|
|
||||||
glBufferData(GL_ARRAY_BUFFER, sizeof(verts), &verts, GL_DYNAMIC_DRAW);
|
|
||||||
glBindVertexArray(rectVAO);
|
|
||||||
glEnableVertexAttribArray(0);
|
|
||||||
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, NULL);
|
|
||||||
glDrawArrays(GL_LINE_LOOP, 0, 4);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void draw_grid(int width, int span)
|
void draw_grid(int width, int span)
|
||||||
|
@ -140,8 +121,7 @@ void draw_poly(float *points, int n)
|
||||||
{
|
{
|
||||||
shader_use(rectShader);
|
shader_use(rectShader);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, rectVBO);
|
glBindBuffer(GL_ARRAY_BUFFER, rectVBO);
|
||||||
glBufferData(GL_ARRAY_BUFFER, sizeof(float) * n * 2, points,
|
glBufferData(GL_ARRAY_BUFFER, sizeof(float) * n * 2, points, GL_DYNAMIC_DRAW);
|
||||||
GL_DYNAMIC_DRAW);
|
|
||||||
glBindVertexArray(rectVAO);
|
glBindVertexArray(rectVAO);
|
||||||
glEnableVertexAttribArray(0);
|
glEnableVertexAttribArray(0);
|
||||||
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, NULL);
|
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, NULL);
|
|
@ -336,7 +336,6 @@ static void edit_input_cb(GLFWwindow *w, int key, int scancode, int action, int
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GLFW_KEY_F5:
|
case GLFW_KEY_F5:
|
||||||
NEGATE(editor.lighting.show);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GLFW_KEY_F6:
|
case GLFW_KEY_F6:
|
||||||
|
@ -543,19 +542,6 @@ void editor_project_gui() {
|
||||||
|
|
||||||
NK_MENU_END()
|
NK_MENU_END()
|
||||||
|
|
||||||
// Shadow map vars
|
|
||||||
NK_MENU_START(lighting)
|
|
||||||
|
|
||||||
nk_layout_row_dynamic(ctx, 25, 1);
|
|
||||||
nk_label(ctx, "Directional shadow map", NK_TEXT_LEFT);
|
|
||||||
|
|
||||||
nk_property_float(ctx, "Near plane", -200.f, &near_plane, 200.f, 1.f, 0.01f);
|
|
||||||
nk_property_float(ctx, "Far plane", -200.f, &far_plane, 200.f, 1.f, 0.01f);
|
|
||||||
nk_property_float(ctx, "Shadow lookahead", 0.f, &shadowLookahead, 100.f, 1.f, 0.01f);
|
|
||||||
nk_property_float(ctx, "Plane size", 0.f, &plane_size, 100.f, 1.f, 0.01f);
|
|
||||||
|
|
||||||
NK_MENU_END()
|
|
||||||
|
|
||||||
NK_MENU_START(gamesettings)
|
NK_MENU_START(gamesettings)
|
||||||
nk_layout_row_dynamic(ctx,25,1);
|
nk_layout_row_dynamic(ctx,25,1);
|
||||||
|
|
||||||
|
@ -598,34 +584,6 @@ void editor_project_gui() {
|
||||||
|
|
||||||
NK_MENU_START(debug)
|
NK_MENU_START(debug)
|
||||||
|
|
||||||
nk_layout_row_dynamic(ctx, 25, 1);
|
|
||||||
|
|
||||||
nk_property_float(ctx, "Camera FOV", 0.1f, &editorFOV, 90.f, 1.f, 0.1f);
|
|
||||||
nk_property_float(ctx, "Camera Near Plane", 0.1f, &editorClose, 5.f, 0.1f, 0.01f);
|
|
||||||
nk_property_float(ctx, "Camera Far Plane", 50.f, &editorFar, 10000.f, 1.f,1.f);
|
|
||||||
|
|
||||||
if (nk_tree_push(ctx, NK_TREE_NODE, "Shading mode", NK_MINIMIZED)) {
|
|
||||||
renderMode =
|
|
||||||
nk_option_label(ctx, "Lit", renderMode == LIT) ? LIT : renderMode;
|
|
||||||
renderMode = nk_option_label(ctx, "Unlit", renderMode == UNLIT)
|
|
||||||
? UNLIT
|
|
||||||
: renderMode;
|
|
||||||
renderMode = nk_option_label(ctx, "Wireframe", renderMode == WIREFRAME)
|
|
||||||
? WIREFRAME
|
|
||||||
: renderMode;
|
|
||||||
renderMode = nk_option_label(ctx, "Directional shadow map",
|
|
||||||
renderMode == DIRSHADOWMAP)
|
|
||||||
? DIRSHADOWMAP
|
|
||||||
: renderMode;
|
|
||||||
nk_tree_pop(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nk_tree_push(ctx, NK_TREE_NODE, "Lighting", NK_MINIMIZED)) {
|
|
||||||
nk_checkbox_label(ctx, "Shadows", &renderDynamicShadows);
|
|
||||||
nk_checkbox_label(ctx, "Ambient Occlusion", &renderAO);
|
|
||||||
nk_tree_pop(ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nk_tree_push(ctx, NK_TREE_NODE, "Debug Draws", NK_MINIMIZED)) {
|
if (nk_tree_push(ctx, NK_TREE_NODE, "Debug Draws", NK_MINIMIZED)) {
|
||||||
nk_checkbox_label(ctx, "Gizmos", &renderGizmos);
|
nk_checkbox_label(ctx, "Gizmos", &renderGizmos);
|
||||||
nk_checkbox_label(ctx, "Grid", &showGrid);
|
nk_checkbox_label(ctx, "Grid", &showGrid);
|
|
@ -27,7 +27,6 @@ typedef struct {
|
||||||
struct editorVars {
|
struct editorVars {
|
||||||
editor_win stats;
|
editor_win stats;
|
||||||
editor_win hierarchy;
|
editor_win hierarchy;
|
||||||
editor_win lighting;
|
|
||||||
editor_win gamesettings;
|
editor_win gamesettings;
|
||||||
editor_win viewmode;
|
editor_win viewmode;
|
||||||
editor_win debug;
|
editor_win debug;
|
|
@ -103,7 +103,7 @@ void win_key_callback(GLFWwindow *w, int key, int scancode, int action, int mods
|
||||||
|
|
||||||
void cursor_hide()
|
void cursor_hide()
|
||||||
{
|
{
|
||||||
glfwSetInputMode(mainwin->window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
|
glfwSetInputMode(mainwin->window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cursor_show()
|
void cursor_show()
|
||||||
|
|
|
@ -16,38 +16,10 @@ int renderMode = 0;
|
||||||
|
|
||||||
static GLuint UBO;
|
static GLuint UBO;
|
||||||
|
|
||||||
|
|
||||||
static GLuint gridVBO = 0;
|
|
||||||
static GLuint gridVAO = 0;
|
|
||||||
|
|
||||||
static GLuint quadVAO = 0;
|
|
||||||
static GLuint quadVBO = 0;
|
|
||||||
|
|
||||||
static GLuint depthMapFBO = 0;
|
|
||||||
static GLuint depthMap = 0;
|
|
||||||
const unsigned int SHADOW_WIDTH = 2048, SHADOW_HEIGHT = 2048;
|
|
||||||
|
|
||||||
static struct shader *outlineShader;
|
|
||||||
static struct shader *modelShader;
|
|
||||||
static struct shader *shadowShader;
|
|
||||||
|
|
||||||
struct shader *spriteShader = NULL;
|
struct shader *spriteShader = NULL;
|
||||||
struct shader *animSpriteShader = NULL;
|
struct shader *animSpriteShader = NULL;
|
||||||
static struct shader *textShader;
|
static struct shader *textShader;
|
||||||
static struct shader *diffuseShader;
|
|
||||||
|
|
||||||
struct sFont *stdFont;
|
|
||||||
|
|
||||||
static struct shader *debugDepthQuad;
|
|
||||||
static struct shader *debugColorPickShader;
|
|
||||||
static struct shader *debugGridShader;
|
|
||||||
static struct shader *debugGizmoShader;
|
|
||||||
|
|
||||||
struct mStaticActor *gizmo;
|
|
||||||
|
|
||||||
float editorFOV = 45.f;
|
|
||||||
float editorClose = 0.1f;
|
|
||||||
float editorFar = 1000.f;
|
|
||||||
mfloat_t editorClearColor[4] = { 0.2f, 0.4f, 0.3f, 1.f };
|
mfloat_t editorClearColor[4] = { 0.2f, 0.4f, 0.3f, 1.f };
|
||||||
|
|
||||||
float shadowLookahead = 8.5f;
|
float shadowLookahead = 8.5f;
|
||||||
|
@ -65,9 +37,6 @@ float gridOpacity = 0.3f;
|
||||||
|
|
||||||
mfloat_t proj[16];
|
mfloat_t proj[16];
|
||||||
|
|
||||||
float near_plane = -100.f, far_plane = 10.f, plane_size = 60.f;
|
|
||||||
|
|
||||||
|
|
||||||
// Debug render modes
|
// Debug render modes
|
||||||
bool renderGizmos = false;
|
bool renderGizmos = false;
|
||||||
bool showGrid = true;
|
bool showGrid = true;
|
||||||
|
@ -116,23 +85,12 @@ void openglInit()
|
||||||
sprite_initialize();
|
sprite_initialize();
|
||||||
debugdraw_init();
|
debugdraw_init();
|
||||||
|
|
||||||
//glEnable(GL_STENCIL_TEST);
|
|
||||||
|
|
||||||
|
|
||||||
glClearColor(editorClearColor[0], editorClearColor[1], editorClearColor[2], editorClearColor[3]);
|
glClearColor(editorClearColor[0], editorClearColor[1], editorClearColor[2], editorClearColor[3]);
|
||||||
|
|
||||||
glEnable(GL_CULL_FACE);
|
glEnable(GL_CULL_FACE);
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
|
||||||
//glDisable(GL_DEPTH_TEST);
|
|
||||||
//glLineWidth(1.3f);
|
|
||||||
|
|
||||||
//glEnable(GL_TEXTURE_3D);
|
|
||||||
//glEnable(GL_MULTISAMPLE);
|
|
||||||
//glLineWidth(2);
|
|
||||||
|
|
||||||
|
|
||||||
glGenBuffers(1, &projUBO);
|
glGenBuffers(1, &projUBO);
|
||||||
glBindBuffer(GL_UNIFORM_BUFFER, projUBO);
|
glBindBuffer(GL_UNIFORM_BUFFER, projUBO);
|
||||||
glBufferData(GL_UNIFORM_BUFFER, 64, NULL, GL_DYNAMIC_DRAW);
|
glBufferData(GL_UNIFORM_BUFFER, 64, NULL, GL_DYNAMIC_DRAW);
|
||||||
|
@ -181,467 +139,7 @@ void openglRender(struct window *window)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BindUniformBlock(GLuint shaderID, const char *bufferName, GLuint bufferBind)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void openglInit3d(struct window *window)
|
|
||||||
{
|
{
|
||||||
/* TODO: IMG init doesn't work in C++
|
glUniformBlockBinding(shaderID, glGetUniformBlockIndex(shaderID, bufferName), bufferBind);
|
||||||
int init =(0x00000001 | 0x00000002);
|
|
||||||
int initted =IMG_Init(init);
|
|
||||||
YughLog(0, SDL_LOG_PRIORITY_ERROR, "Init flags: %d\nInitted values: %d ", init, initted);
|
|
||||||
if ((initted & (IMG_INIT_JPG | IMG_INIT_PNG)) != (IMG_INIT_JPG | IMG_INIT_PNG)) {
|
|
||||||
YughLog(0, SDL_LOG_PRIORITY_ERROR,
|
|
||||||
"IMG_Init: Failed to init required jpg and png support! SDL_IMG error: %s",
|
|
||||||
IMG_GetError());
|
|
||||||
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////// MAKE SHADERS
|
|
||||||
outlineShader = MakeShader("outlinevert.glsl", "outline.glsl");
|
|
||||||
diffuseShader = MakeShader("simplevert.glsl", "albedofrag.glsl");
|
|
||||||
modelShader = MakeShader("modelvert.glsl", "modelfrag.glsl");
|
|
||||||
shadowShader = MakeShader("shadowvert.glsl", "shadowfrag.glsl");
|
|
||||||
|
|
||||||
textShader = MakeShader("textvert.glsl", "textfrag.glsl");
|
|
||||||
spriteShader = MakeShader("spritevert.glsl", "spritefrag.glsl");
|
|
||||||
|
|
||||||
debugDepthQuad = MakeShader("postvert.glsl", "debugdepthfrag.glsl");
|
|
||||||
debugColorPickShader =
|
|
||||||
MakeShader("simplevert.glsl", "debugcolorfrag.glsl");
|
|
||||||
debugGridShader = MakeShader("gridvert.glsl", "gridfrag.glsl");
|
|
||||||
debugGizmoShader = MakeShader("gizmovert.glsl", "gizmofrag.glsl");
|
|
||||||
|
|
||||||
stdFont = MakeFont("notosans.ttf", 300);
|
|
||||||
|
|
||||||
shader_compile_all();
|
|
||||||
|
|
||||||
mat4_perspective_fov(proj, editorFOV * DEG2RADS, window->width,
|
|
||||||
window->height, editorClose, editorFar);
|
|
||||||
|
|
||||||
glEnable(GL_STENCIL_TEST);
|
|
||||||
glEnable(GL_BLEND);
|
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
||||||
glEnable(GL_TEXTURE_3D);
|
|
||||||
glEnable(GL_MULTISAMPLE);
|
|
||||||
glLineWidth(2);
|
|
||||||
|
|
||||||
////
|
|
||||||
// Shadow mapping buffers
|
|
||||||
////
|
|
||||||
glGenFramebuffers(1, &depthMapFBO);
|
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, depthMapFBO);
|
|
||||||
|
|
||||||
glGenTextures(1, &depthMap);
|
|
||||||
glBindTexture(GL_TEXTURE_2D, depthMap);
|
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT16, SHADOW_WIDTH,
|
|
||||||
SHADOW_HEIGHT, 0, GL_DEPTH_COMPONENT, GL_FLOAT, NULL);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
|
|
||||||
float borderColor[] = { 1.0f, 1.0f, 1.0f, 1.0f };
|
|
||||||
glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, borderColor);
|
|
||||||
|
|
||||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
|
|
||||||
GL_TEXTURE_2D, depthMap, 0);
|
|
||||||
glDrawBuffer(GL_NONE);
|
|
||||||
//glReadBuffer(GL_NONE);
|
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
|
||||||
|
|
||||||
//// Universal buffer to hold projection and light coordinates
|
|
||||||
glGenBuffers(1, &UBO);
|
|
||||||
glBindBuffer(GL_UNIFORM_BUFFER, UBO);
|
|
||||||
|
|
||||||
glBufferData(GL_UNIFORM_BUFFER, 2 * sizeof(proj), NULL,
|
|
||||||
GL_STATIC_DRAW);
|
|
||||||
glBindBuffer(GL_UNIFORM_BUFFER, 0);
|
|
||||||
glBindBufferRange(GL_UNIFORM_BUFFER, 0, UBO, 0, 2 * sizeof(proj));
|
|
||||||
|
|
||||||
|
|
||||||
glBindBuffer(GL_UNIFORM_BUFFER, UBO);
|
|
||||||
glBufferSubData(GL_UNIFORM_BUFFER, 0, sizeof(proj), proj);
|
|
||||||
glBindBuffer(GL_UNIFORM_BUFFER, 0);
|
|
||||||
|
|
||||||
////// debug color pick buffer
|
|
||||||
glGenFramebuffers(1, &debugColorPickBO);
|
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, debugColorPickBO);
|
|
||||||
|
|
||||||
glGenTextures(1, &debugColorPickTEX);
|
|
||||||
glBindTexture(GL_TEXTURE_2D, debugColorPickTEX);
|
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, SCREEN_WIDTH, SCREEN_HEIGHT, 0,
|
|
||||||
GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
|
||||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
|
|
||||||
GL_TEXTURE_2D, debugColorPickTEX, 0);
|
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
|
||||||
|
|
||||||
|
|
||||||
//////// Create grid
|
|
||||||
float gridVertices[] = {
|
|
||||||
-1.f, 0.f, 1.f, 0.f, 1.f,
|
|
||||||
-1.f, 0.f, -1.f, 0.f, 0.f,
|
|
||||||
1.f, 0.f, 1.f, 1.f, 1.f,
|
|
||||||
1.f, 0.f, -1.f, 1.f, 0.f,
|
|
||||||
};
|
|
||||||
|
|
||||||
glGenVertexArrays(1, &gridVAO);
|
|
||||||
glGenBuffers(1, &gridVBO);
|
|
||||||
glBindVertexArray(gridVAO);
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, gridVBO);
|
|
||||||
glBufferData(GL_ARRAY_BUFFER, sizeof(gridVertices), &gridVertices,
|
|
||||||
GL_STATIC_DRAW);
|
|
||||||
glEnableVertexAttribArray(0);
|
|
||||||
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(float),
|
|
||||||
(void *) 0);
|
|
||||||
glEnableVertexAttribArray(1);
|
|
||||||
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(float),
|
|
||||||
(void *) (3 * sizeof(float)));
|
|
||||||
|
|
||||||
//////// Create post quad
|
|
||||||
float quadVertices[] = {
|
|
||||||
// positions // texture Coords
|
|
||||||
-1.0f, 1.0f, 0.0f, 0.0f, 1.0f,
|
|
||||||
-1.0f, -1.0f, 0.0f, 0.0f, 0.0f,
|
|
||||||
1.0f, 1.0f, 0.0f, 1.0f, 1.0f,
|
|
||||||
1.0f, -1.0f, 0.0f, 1.0f, 0.0f,
|
|
||||||
};
|
|
||||||
// setup plane VAO
|
|
||||||
glGenVertexArrays(1, &quadVAO);
|
|
||||||
glGenBuffers(1, &quadVBO);
|
|
||||||
glBindVertexArray(quadVAO);
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, quadVBO);
|
|
||||||
glBufferData(GL_ARRAY_BUFFER, sizeof(quadVertices), &quadVertices,
|
|
||||||
GL_STATIC_DRAW);
|
|
||||||
glEnableVertexAttribArray(0);
|
|
||||||
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(float),
|
|
||||||
(void *) 0);
|
|
||||||
glEnableVertexAttribArray(1);
|
|
||||||
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(float),
|
|
||||||
(void *) (3 * sizeof(float)));
|
|
||||||
|
|
||||||
//////
|
|
||||||
|
|
||||||
// skybox = new Skybox("skybox");
|
|
||||||
|
|
||||||
BindUniformBlock(modelShader->id, "Matrices", 0);
|
|
||||||
BindUniformBlock(outlineShader->id, "Matrices", 0);
|
|
||||||
// BindUniformBlock(skybox->shader->id, "Matrices", 0);
|
|
||||||
BindUniformBlock(diffuseShader->id, "Matrices", 0);
|
|
||||||
|
|
||||||
BindUniformBlock(debugGridShader->id, "Matrices", 0);
|
|
||||||
BindUniformBlock(debugGizmoShader->id, "Matrices", 0);
|
|
||||||
|
|
||||||
shader_use(debugDepthQuad);
|
|
||||||
shader_setint(debugDepthQuad, "depthMap", 0);
|
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
|
||||||
|
|
||||||
//////////// 2D projection
|
|
||||||
mfloat_t projection[16] = { 0.f };
|
|
||||||
mat4_ortho(projection, 0.f, SCREEN_WIDTH, SCREEN_HEIGHT, 1.f, -1.f,
|
|
||||||
1.f);
|
|
||||||
shader_setmat4(textShader, "projection", projection);
|
|
||||||
shader_setmat4(spriteShader, "projection", projection);
|
|
||||||
shader_setmat4(debugGizmoShader, "proj", projection);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void openglRender3d(struct window *window, struct mCamera *mcamera)
|
|
||||||
{
|
|
||||||
//////// SET NEW PROJECTION
|
|
||||||
// TODO: Make this not happen every frame
|
|
||||||
mat4_perspective_fov(proj, editorFOV * DEG2RADS, window->width,
|
|
||||||
window->height, editorClose, editorFar);
|
|
||||||
|
|
||||||
glBindBuffer(GL_UNIFORM_BUFFER, UBO);
|
|
||||||
glBufferSubData(GL_UNIFORM_BUFFER, 0, sizeof(proj), proj);
|
|
||||||
glBindBuffer(GL_UNIFORM_BUFFER, 0);
|
|
||||||
glEnable(GL_CULL_FACE);
|
|
||||||
glEnable(GL_DEPTH_TEST);
|
|
||||||
|
|
||||||
////////// Render a depthmap from the perspective of the directional light
|
|
||||||
|
|
||||||
glViewport(0, 0, SHADOW_WIDTH, SHADOW_HEIGHT);
|
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, depthMapFBO);
|
|
||||||
glCullFace(GL_BACK);
|
|
||||||
glClear(GL_DEPTH_BUFFER_BIT);
|
|
||||||
|
|
||||||
// Configure matrices with an orthogonal
|
|
||||||
|
|
||||||
mfloat_t lightSpaceMatrix[16] = { 0.f };
|
|
||||||
|
|
||||||
/*
|
|
||||||
if (dLight) {
|
|
||||||
|
|
||||||
mfloat_t lightProjection[16] = { 0.f };
|
|
||||||
mat4_ortho(lightProjection, -plane_size, plane_size, -plane_size,
|
|
||||||
plane_size, near_plane, far_plane);
|
|
||||||
|
|
||||||
mfloat_t lookPos[3] = { 0.f };
|
|
||||||
mfloat_t cam_fwd[3] = { 0.f };
|
|
||||||
vec3_add(lookPos, mcamera->transform.position,
|
|
||||||
vec3_multiply_f(lookPos,
|
|
||||||
trans_forward(cam_fwd,
|
|
||||||
&mcamera->transform),
|
|
||||||
shadowLookahead));
|
|
||||||
lookPos[1] = 0.f;
|
|
||||||
|
|
||||||
mfloat_t lightLookPos[3] = { 0.f };
|
|
||||||
mfloat_t light_fwd[3] = { 0.f };
|
|
||||||
mat4_look_at(lightView,
|
|
||||||
vec3_subtract(lightLookPos, lookPos,
|
|
||||||
trans_forward(light_fwd,
|
|
||||||
&dLight->light.obj.
|
|
||||||
transform)), lookPos, UP);
|
|
||||||
|
|
||||||
mat4_multiply(lightSpaceMatrix, lightProjection, lightView);
|
|
||||||
//lightSpaceMatrix = lightProjection * lightView;
|
|
||||||
|
|
||||||
if (renderDynamicShadows) {
|
|
||||||
shader_use(shadowShader);
|
|
||||||
shader_setmat4(shadowShader, "lightSpaceMatrix",
|
|
||||||
lightSpaceMatrix);
|
|
||||||
staticactor_draw_shadowcasters(shadowShader);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
//////////////////////////
|
|
||||||
|
|
||||||
// Back to the normal render
|
|
||||||
window_makecurrent(window);
|
|
||||||
|
|
||||||
|
|
||||||
glCullFace(GL_BACK);
|
|
||||||
|
|
||||||
// Render the color thing for debug picking
|
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, debugColorPickBO);
|
|
||||||
glClearColor(editorClearColor[0], editorClearColor[1],
|
|
||||||
editorClearColor[2], editorClearColor[3]);
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
|
||||||
shader_use(debugColorPickShader);
|
|
||||||
staticactor_draw_dbg_color_pick(debugColorPickShader);
|
|
||||||
|
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
|
||||||
|
|
||||||
// Clear color and depth
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT |
|
|
||||||
GL_STENCIL_BUFFER_BIT);
|
|
||||||
|
|
||||||
if (renderMode == DIRSHADOWMAP) {
|
|
||||||
// render Depth map to quad for visual debugging
|
|
||||||
// ---------------------------------------------
|
|
||||||
shader_use(debugDepthQuad);
|
|
||||||
shader_setfloat(debugDepthQuad, "near_plane", near_plane);
|
|
||||||
shader_setfloat(debugDepthQuad, "far_plane", far_plane);
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
|
||||||
glBindTexture(GL_TEXTURE_2D, depthMap);
|
|
||||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
|
||||||
glBindVertexArray(quadVAO);
|
|
||||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
|
||||||
glBindVertexArray(0);
|
|
||||||
} else if (renderMode == OBJECTPICKER) {
|
|
||||||
// TODO: This rendering mode
|
|
||||||
shader_use(debugColorPickShader);
|
|
||||||
} else {
|
|
||||||
|
|
||||||
glClearColor(editorClearColor[0], editorClearColor[1],
|
|
||||||
editorClearColor[2], editorClearColor[3]);
|
|
||||||
glDepthMask(GL_TRUE);
|
|
||||||
|
|
||||||
mfloat_t view[16] = { 0.f };
|
|
||||||
getviewmatrix(view, mcamera);
|
|
||||||
|
|
||||||
glBindBuffer(GL_UNIFORM_BUFFER, UBO);
|
|
||||||
glBufferSubData(GL_UNIFORM_BUFFER, sizeof(view), sizeof(view),
|
|
||||||
view);
|
|
||||||
glBindBuffer(GL_UNIFORM_BUFFER, 0);
|
|
||||||
|
|
||||||
switch (renderMode) {
|
|
||||||
case LIT:
|
|
||||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
|
||||||
|
|
||||||
shader_use(modelShader);
|
|
||||||
|
|
||||||
/*
|
|
||||||
if (dLight)
|
|
||||||
dlight_prepshader(dLight, modelShader);
|
|
||||||
|
|
||||||
pointlights_prepshader(modelShader);
|
|
||||||
spotlights_prepshader(modelShader);
|
|
||||||
*/
|
|
||||||
|
|
||||||
shader_setvec3(modelShader, "viewPos",
|
|
||||||
mcamera->transform.position);
|
|
||||||
shader_setmat4(modelShader, "lightSpaceMatrix",
|
|
||||||
lightSpaceMatrix);
|
|
||||||
shader_setint(modelShader, "shadowMap", 12);
|
|
||||||
glActiveTexture(GL_TEXTURE);
|
|
||||||
glBindTexture(GL_TEXTURE_2D, depthMap);
|
|
||||||
staticactor_draw_models(modelShader);
|
|
||||||
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case UNLIT:
|
|
||||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
|
||||||
shader_use(diffuseShader);
|
|
||||||
staticactor_draw_models(diffuseShader);
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WIREFRAME:
|
|
||||||
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
|
||||||
shader_use(diffuseShader);
|
|
||||||
staticactor_draw_models(diffuseShader);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
//// skybox
|
|
||||||
// draw skybox as last
|
|
||||||
glDepthFunc(GL_LEQUAL);
|
|
||||||
// skybox->Draw(mcamera);
|
|
||||||
glDepthFunc(GL_LESS);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (debugDrawPhysics) {
|
|
||||||
// Render physics world
|
|
||||||
//dynamicsWorld->debugDrawWorld();
|
|
||||||
}
|
|
||||||
// Draw outline
|
|
||||||
if (selectedobject != NULL) {
|
|
||||||
// Draw the selected object outlined
|
|
||||||
glClearStencil(0);
|
|
||||||
glClear(GL_STENCIL_BUFFER_BIT);
|
|
||||||
glStencilFunc(GL_ALWAYS, 1, 0xFF);
|
|
||||||
glDepthFunc(GL_ALWAYS);
|
|
||||||
glDepthMask(false);
|
|
||||||
glColorMask(false, false, false, false);
|
|
||||||
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
|
|
||||||
glStencilMask(0xFF);
|
|
||||||
shader_use(diffuseShader);
|
|
||||||
setup_model_transform(&selectedobject->transform,
|
|
||||||
diffuseShader, 1.f);
|
|
||||||
//selectedobject->draw(diffuseShader);
|
|
||||||
|
|
||||||
glStencilFunc(GL_NOTEQUAL, 1, 0xFF);
|
|
||||||
glDepthMask(true);
|
|
||||||
glColorMask(true, true, true, true);
|
|
||||||
glStencilMask(0x00);
|
|
||||||
shader_use(outlineShader);
|
|
||||||
setup_model_transform(&selectedobject->transform,
|
|
||||||
outlineShader, 1.f);
|
|
||||||
//selectedobject->draw(outlineShader);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
glDepthFunc(GL_LESS);
|
|
||||||
glStencilMask(0xFF);
|
|
||||||
glStencilFunc(GL_ALWAYS, 0, 0xFF);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
////// TEXT && GUI
|
|
||||||
// glCullFace(GL_FRONT);
|
|
||||||
glDepthFunc(GL_ALWAYS);
|
|
||||||
shader_use(textShader);
|
|
||||||
shader_setmat4(textShader, "projection", window->projection);
|
|
||||||
mfloat_t fontpos[2] = { 25.f, 25.f };
|
|
||||||
mfloat_t fontcolor[3] = { 0.5f, 0.8f, 0.2f };
|
|
||||||
text_settype(stdFont);
|
|
||||||
renderText("Sample text", fontpos, 0.4f,
|
|
||||||
fontcolor, -1.f);
|
|
||||||
|
|
||||||
sprite_draw(tsprite);
|
|
||||||
|
|
||||||
glDepthFunc(GL_LESS);
|
|
||||||
|
|
||||||
|
|
||||||
////// Render grid
|
|
||||||
if (showGrid) {
|
|
||||||
glDisable(GL_CULL_FACE);
|
|
||||||
shader_use(debugGridShader);
|
|
||||||
mfloat_t gmodel[16] = { 0.f };
|
|
||||||
mfloat_t gridscale[3] = { 0.f };
|
|
||||||
vec3(gridscale, gridScale, gridScale, gridScale);
|
|
||||||
mat4_multiply_f(gmodel, gmodel, gridScale);
|
|
||||||
// TODO: Hook into here to make the grid scalable
|
|
||||||
shader_setmat4(debugGridShader, "model", gmodel);
|
|
||||||
shader_setvec3(debugGridShader, "smallColor", gridSmallColor);
|
|
||||||
shader_setvec3(debugGridShader, "bigColor", gridBigColor);
|
|
||||||
shader_setfloat(debugGridShader, "gridScale", gridScale);
|
|
||||||
shader_setfloat(debugGridShader, "smallUnit", smallGridUnit);
|
|
||||||
shader_setfloat(debugGridShader, "bigUnit", bigGridUnit);
|
|
||||||
shader_setfloat(debugGridShader, "smallThickness",
|
|
||||||
gridSmallThickness);
|
|
||||||
shader_setfloat(debugGridShader, "largeThickness",
|
|
||||||
gridBigThickness);
|
|
||||||
shader_setfloat(debugGridShader, "opacity", gridOpacity);
|
|
||||||
glBindVertexArray(gridVAO);
|
|
||||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
|
||||||
glBindVertexArray(0);
|
|
||||||
}
|
|
||||||
///// Render gizmos
|
|
||||||
// These are things that are overlaid on everything else
|
|
||||||
|
|
||||||
|
|
||||||
// glBindFramebuffer(GL_FRAMEBUFFER, 0); // back to default
|
|
||||||
// glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
|
|
||||||
// glClear(GL_COLOR_BUFFER_BIT);
|
|
||||||
|
|
||||||
// postShader.use();
|
|
||||||
// glBindVertexArray(quadVAO);
|
|
||||||
// glBindTexture(GL_TEXTURE_2D, fboTexture);
|
|
||||||
// glDrawArrays(GL_TRIANGLES, 0, 6);
|
|
||||||
}
|
|
||||||
|
|
||||||
void BindUniformBlock(GLuint shaderID, const char *bufferName,
|
|
||||||
GLuint bufferBind)
|
|
||||||
{
|
|
||||||
glUniformBlockBinding(shaderID,
|
|
||||||
glGetUniformBlockIndex(shaderID, bufferName),
|
|
||||||
bufferBind);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,9 +13,6 @@ extern struct sprite *tsprite;
|
||||||
|
|
||||||
extern int renderMode;
|
extern int renderMode;
|
||||||
|
|
||||||
|
|
||||||
extern float editorClose;
|
|
||||||
extern float editorFar;
|
|
||||||
extern float gridScale;
|
extern float gridScale;
|
||||||
extern float smallGridUnit;
|
extern float smallGridUnit;
|
||||||
extern float bigGridUnit;
|
extern float bigGridUnit;
|
||||||
|
@ -26,9 +23,6 @@ extern float gridSmallColor[];
|
||||||
extern float gridOpacity;
|
extern float gridOpacity;
|
||||||
extern float editorFOV;
|
extern float editorFOV;
|
||||||
extern float shadowLookahead;
|
extern float shadowLookahead;
|
||||||
extern float plane_size;
|
|
||||||
extern float near_plane;
|
|
||||||
extern float far_plane;
|
|
||||||
extern char objectName[];
|
extern char objectName[];
|
||||||
extern GLuint debugColorPickBO;
|
extern GLuint debugColorPickBO;
|
||||||
|
|
||||||
|
|
|
@ -131,10 +131,6 @@ void sprite_initialize()
|
||||||
|
|
||||||
glEnableVertexAttribArray(0);
|
glEnableVertexAttribArray(0);
|
||||||
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, NULL);
|
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, NULL);
|
||||||
|
|
||||||
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
|
||||||
glBindVertexArray(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void sprite_draw(struct sprite *sprite)
|
void sprite_draw(struct sprite *sprite)
|
||||||
|
|
|
@ -282,12 +282,14 @@ void window_render(struct window *w) {
|
||||||
script_call_sym(w->nuke_cb);
|
script_call_sym(w->nuke_cb);
|
||||||
nk_end(ctx);
|
nk_end(ctx);
|
||||||
nuke_end();
|
nuke_end();
|
||||||
} else if (w->nuke_gui != NULL) {
|
} else
|
||||||
|
|
||||||
|
*/if (w->nuke_gui != NULL) {
|
||||||
nuke_start();
|
nuke_start();
|
||||||
w->nuke_gui();
|
w->nuke_gui();
|
||||||
nuke_end();
|
nuke_end();
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
window_swap(w);
|
window_swap(w);
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,15 +123,15 @@ int main(int argc, char **args) {
|
||||||
|
|
||||||
double framet = fmin(fmin(renderMS,physMS),updateMS);
|
double framet = fmin(fmin(renderMS,physMS),updateMS);
|
||||||
|
|
||||||
script_dofile("scripts/engine.rb");
|
script_dofile("scripts/engine.scm");
|
||||||
script_dofile("config.rb");
|
script_dofile("config.scm");
|
||||||
|
|
||||||
window_set_icon("icon.png");
|
window_set_icon("icon.png");
|
||||||
|
|
||||||
if (ed) {
|
if (ed) {
|
||||||
editor_init(MakeSDLWindow("Editor", 600, 600, 0));
|
editor_init(MakeSDLWindow("Editor", 600, 600, 0));
|
||||||
} else {
|
} else {
|
||||||
script_dofile("game.rb");
|
script_dofile("game.scm");
|
||||||
}
|
}
|
||||||
|
|
||||||
openglInit();
|
openglInit();
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
REM Generate the JNI header file from the Java code for JPortAudio
|
|
||||||
REM by Phil Burk
|
|
||||||
|
|
||||||
javah -classpath ../jportaudio/bin -d ../c/src com.portaudio.PortAudio com.portaudio.BlockingStream
|
|
|
@ -1,61 +0,0 @@
|
||||||
; $Id: $
|
|
||||||
;
|
|
||||||
; !!! @GENERATED_MESSAGE@ !!!
|
|
||||||
EXPORTS
|
|
||||||
|
|
||||||
;
|
|
||||||
Pa_GetVersion @1
|
|
||||||
Pa_GetVersionText @2
|
|
||||||
Pa_GetErrorText @3
|
|
||||||
Pa_Initialize @4
|
|
||||||
Pa_Terminate @5
|
|
||||||
Pa_GetHostApiCount @6
|
|
||||||
Pa_GetDefaultHostApi @7
|
|
||||||
Pa_GetHostApiInfo @8
|
|
||||||
Pa_HostApiTypeIdToHostApiIndex @9
|
|
||||||
Pa_HostApiDeviceIndexToDeviceIndex @10
|
|
||||||
Pa_GetLastHostErrorInfo @11
|
|
||||||
Pa_GetDeviceCount @12
|
|
||||||
Pa_GetDefaultInputDevice @13
|
|
||||||
Pa_GetDefaultOutputDevice @14
|
|
||||||
Pa_GetDeviceInfo @15
|
|
||||||
Pa_IsFormatSupported @16
|
|
||||||
Pa_OpenStream @17
|
|
||||||
Pa_OpenDefaultStream @18
|
|
||||||
Pa_CloseStream @19
|
|
||||||
Pa_SetStreamFinishedCallback @20
|
|
||||||
Pa_StartStream @21
|
|
||||||
Pa_StopStream @22
|
|
||||||
Pa_AbortStream @23
|
|
||||||
Pa_IsStreamStopped @24
|
|
||||||
Pa_IsStreamActive @25
|
|
||||||
Pa_GetStreamInfo @26
|
|
||||||
Pa_GetStreamTime @27
|
|
||||||
Pa_GetStreamCpuLoad @28
|
|
||||||
Pa_ReadStream @29
|
|
||||||
Pa_WriteStream @30
|
|
||||||
Pa_GetStreamReadAvailable @31
|
|
||||||
Pa_GetStreamWriteAvailable @32
|
|
||||||
Pa_GetSampleSize @33
|
|
||||||
Pa_Sleep @34
|
|
||||||
@DEF_EXCLUDE_ASIO_SYMBOLS@PaAsio_GetAvailableBufferSizes @50
|
|
||||||
@DEF_EXCLUDE_ASIO_SYMBOLS@PaAsio_ShowControlPanel @51
|
|
||||||
@DEF_EXCLUDE_X86_PLAIN_CONVERTERS@PaUtil_InitializeX86PlainConverters @52
|
|
||||||
@DEF_EXCLUDE_ASIO_SYMBOLS@PaAsio_GetInputChannelName @53
|
|
||||||
@DEF_EXCLUDE_ASIO_SYMBOLS@PaAsio_GetOutputChannelName @54
|
|
||||||
PaUtil_SetDebugPrintFunction @55
|
|
||||||
@DEF_EXCLUDE_WASAPI_SYMBOLS@PaWasapi_GetAudioClient @56
|
|
||||||
@DEF_EXCLUDE_WASAPI_SYMBOLS@PaWasapi_UpdateDeviceList @57
|
|
||||||
@DEF_EXCLUDE_WASAPI_SYMBOLS@PaWasapi_GetDeviceCurrentFormat @58
|
|
||||||
@DEF_EXCLUDE_WASAPI_SYMBOLS@PaWasapi_GetDeviceDefaultFormat @59
|
|
||||||
@DEF_EXCLUDE_WASAPI_SYMBOLS@PaWasapi_GetDeviceMixFormat @60
|
|
||||||
@DEF_EXCLUDE_WASAPI_SYMBOLS@PaWasapi_GetDeviceRole @61
|
|
||||||
@DEF_EXCLUDE_WASAPI_SYMBOLS@PaWasapi_ThreadPriorityBoost @62
|
|
||||||
@DEF_EXCLUDE_WASAPI_SYMBOLS@PaWasapi_ThreadPriorityRevert @63
|
|
||||||
@DEF_EXCLUDE_WASAPI_SYMBOLS@PaWasapi_GetFramesPerHostBuffer @64
|
|
||||||
@DEF_EXCLUDE_WASAPI_SYMBOLS@PaWasapi_GetJackCount @65
|
|
||||||
@DEF_EXCLUDE_WASAPI_SYMBOLS@PaWasapi_GetJackDescription @66
|
|
||||||
@DEF_EXCLUDE_WASAPI_SYMBOLS@PaWasapi_SetStreamStateHandler @68
|
|
||||||
@DEF_EXCLUDE_WASAPI_SYMBOLS@PaWasapiWinrt_SetDefaultDeviceId @67
|
|
||||||
@DEF_EXCLUDE_WASAPI_SYMBOLS@PaWasapiWinrt_PopulateDeviceList @69
|
|
||||||
@DEF_EXCLUDE_WASAPI_SYMBOLS@PaWasapi_GetIMMDevice @70
|
|
|
@ -1,35 +0,0 @@
|
||||||
LIBRARY PABLIO
|
|
||||||
DESCRIPTION 'PABLIO Portable Audio Blocking I/O'
|
|
||||||
|
|
||||||
EXPORTS
|
|
||||||
; Explicit exports can go here
|
|
||||||
Pa_Initialize @1
|
|
||||||
Pa_Terminate @2
|
|
||||||
Pa_GetHostError @3
|
|
||||||
Pa_GetErrorText @4
|
|
||||||
Pa_CountDevices @5
|
|
||||||
Pa_GetDefaultInputDeviceID @6
|
|
||||||
Pa_GetDefaultOutputDeviceID @7
|
|
||||||
Pa_GetDeviceInfo @8
|
|
||||||
Pa_OpenStream @9
|
|
||||||
Pa_OpenDefaultStream @10
|
|
||||||
Pa_CloseStream @11
|
|
||||||
Pa_StartStream @12
|
|
||||||
Pa_StopStream @13
|
|
||||||
Pa_StreamActive @14
|
|
||||||
Pa_StreamTime @15
|
|
||||||
Pa_GetCPULoad @16
|
|
||||||
Pa_GetMinNumBuffers @17
|
|
||||||
Pa_Sleep @18
|
|
||||||
|
|
||||||
OpenAudioStream @19
|
|
||||||
CloseAudioStream @20
|
|
||||||
WriteAudioStream @21
|
|
||||||
ReadAudioStream @22
|
|
||||||
|
|
||||||
Pa_GetSampleSize @23
|
|
||||||
|
|
||||||
;123456789012345678901234567890123456
|
|
||||||
;000000000111111111122222222223333333
|
|
||||||
|
|
||||||
|
|
|
@ -1,62 +0,0 @@
|
||||||
class Method
|
|
||||||
def source(n=5)
|
|
||||||
loc = source_location
|
|
||||||
puts `sed -n "#{loc[1]},#{loc[1]+n}p;#{loc[1]+6}q" #{loc[0]}`
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
class Music
|
|
||||||
|
|
||||||
def initialize(mpath = "")
|
|
||||||
load(mpath);
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
def load(mpath)
|
|
||||||
#@music = load(path);
|
|
||||||
end
|
|
||||||
|
|
||||||
def play
|
|
||||||
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
class Sound
|
|
||||||
def initialize(path = "")
|
|
||||||
load(path);
|
|
||||||
end
|
|
||||||
|
|
||||||
def load(path)
|
|
||||||
#@sound =
|
|
||||||
end
|
|
||||||
|
|
||||||
def play
|
|
||||||
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def checknewer
|
|
||||||
$maketimes ||= {}
|
|
||||||
file = caller[0].split(":")[0]
|
|
||||||
if $maketimes[file].nil?
|
|
||||||
$maketimes[file] = `stat --printf '%Y' #{file}`
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
newtime = `stat --printf '%Y' #{file}`
|
|
||||||
if newtime > $maketimes[file]
|
|
||||||
load(file)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def set_renderms(val)
|
|
||||||
settings_cmd(0, val);
|
|
||||||
end
|
|
||||||
|
|
||||||
def set_updatems(val)
|
|
||||||
settings_cmd(1, val);
|
|
||||||
end
|
|
||||||
|
|
||||||
def set_physms(val)
|
|
||||||
settings_cmd(2, val);
|
|
||||||
end
|
|
0
source/scripts/engine.scm
Normal file
0
source/scripts/engine.scm
Normal file
Loading…
Reference in a new issue