Wireframe display mode
This commit is contained in:
parent
7c0f7ef46f
commit
260374c14d
2
Makefile
2
Makefile
|
@ -73,7 +73,7 @@ SEM = 0.0.1
|
||||||
COM != git rev-parse --short HEAD
|
COM != git rev-parse --short HEAD
|
||||||
VER = $(SEM)-$(COM)
|
VER = $(SEM)-$(COM)
|
||||||
|
|
||||||
COMPILER_FLAGS = $(includeflag) $(QFLAGS) -MD $(WARNING_FLAGS) -DCP_USE_DOUBLES=0 -DTINYSPLINE_FLOAT_PRECISION -DVER=\"$(VER)\" -DINFO=\"$(INFO)\" -c $< -o $@
|
COMPILER_FLAGS = $(includeflag) $(QFLAGS) -MD $(WARNING_FLAGS) -DCP_USE_DOUBLES=0 -DTINYSPLINE_FLOAT_PRECISION -DDUK_USE_SYMBOL_BUILTIN -DVER=\"$(VER)\" -DINFO=\"$(INFO)\" -c $< -o $@
|
||||||
|
|
||||||
LIBPATH = -L$(BIN)
|
LIBPATH = -L$(BIN)
|
||||||
|
|
||||||
|
|
|
@ -701,6 +701,14 @@ duk_ret_t duk_cmd(duk_context *duk) {
|
||||||
case 66:
|
case 66:
|
||||||
dukext2paths(duk_to_string(duk, 1));
|
dukext2paths(duk_to_string(duk, 1));
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
case 67:
|
||||||
|
opengl_rendermode(LIT);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 68:
|
||||||
|
opengl_rendermode(WIREFRAME);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -12,9 +12,10 @@
|
||||||
#include "datastream.h"
|
#include "datastream.h"
|
||||||
#include "nuke.h"
|
#include "nuke.h"
|
||||||
|
|
||||||
int renderMode = 0;
|
int renderMode = LIT;
|
||||||
|
|
||||||
struct shader *spriteShader = NULL;
|
struct shader *spriteShader = NULL;
|
||||||
|
struct shader *wireframeShader = NULL;
|
||||||
struct shader *animSpriteShader = NULL;
|
struct shader *animSpriteShader = NULL;
|
||||||
static struct shader *textShader;
|
static struct shader *textShader;
|
||||||
|
|
||||||
|
@ -64,6 +65,11 @@ void debug_draw_phys(int draw) {
|
||||||
debugDrawPhysics = draw;
|
debugDrawPhysics = draw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void opengl_rendermode(enum RenderMode r)
|
||||||
|
{
|
||||||
|
renderMode = r;
|
||||||
|
}
|
||||||
|
|
||||||
void openglInit()
|
void openglInit()
|
||||||
{
|
{
|
||||||
if (!mainwin) {
|
if (!mainwin) {
|
||||||
|
@ -73,6 +79,7 @@ void openglInit()
|
||||||
|
|
||||||
////// MAKE SHADERS
|
////// MAKE SHADERS
|
||||||
spriteShader = MakeShader("spritevert.glsl", "spritefrag.glsl");
|
spriteShader = MakeShader("spritevert.glsl", "spritefrag.glsl");
|
||||||
|
wireframeShader = MakeShader("spritevert.glsl", "spritewireframefrag.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");
|
||||||
|
|
||||||
|
@ -117,8 +124,8 @@ void add_zoom(float val) { zoom = val; }
|
||||||
|
|
||||||
void openglRender(struct window *window)
|
void openglRender(struct window *window)
|
||||||
{
|
{
|
||||||
glCullFace(GL_BACK);
|
|
||||||
|
|
||||||
|
glCullFace(GL_BACK);
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
//////////// 2D projection
|
//////////// 2D projection
|
||||||
|
@ -143,14 +150,25 @@ void openglRender(struct window *window)
|
||||||
glBufferSubData(GL_UNIFORM_BUFFER, 0, 64, projection);
|
glBufferSubData(GL_UNIFORM_BUFFER, 0, 64, projection);
|
||||||
|
|
||||||
|
|
||||||
|
/* Game sprites */
|
||||||
|
switch (renderMode) {
|
||||||
|
case LIT:
|
||||||
|
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||||
|
shader_use(spriteShader);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WIREFRAME:
|
||||||
|
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||||
|
shader_use(wireframeShader);
|
||||||
|
break;
|
||||||
|
};
|
||||||
|
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
///// Sprites
|
|
||||||
glDepthFunc(GL_LESS);
|
glDepthFunc(GL_LESS);
|
||||||
shader_use(spriteShader);
|
|
||||||
sprite_draw_all();
|
sprite_draw_all();
|
||||||
|
|
||||||
|
/* UI Elements & Debug elements */
|
||||||
|
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
//// DEBUG
|
//// DEBUG
|
||||||
if (debugDrawPhysics)
|
if (debugDrawPhysics)
|
||||||
|
|
|
@ -40,6 +40,7 @@ enum RenderMode {
|
||||||
|
|
||||||
void openglInit();
|
void openglInit();
|
||||||
void openglRender(struct window *window);
|
void openglRender(struct window *window);
|
||||||
|
void opengl_rendermode(enum RenderMode r);
|
||||||
|
|
||||||
void openglInit3d(struct window *window);
|
void openglInit3d(struct window *window);
|
||||||
void openglRender3d(struct window *window, struct mCamera *camera);
|
void openglRender3d(struct window *window, struct mCamera *camera);
|
||||||
|
|
12
source/shaders/spritewireframefrag.glsl
Normal file
12
source/shaders/spritewireframefrag.glsl
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
#version 330 core
|
||||||
|
in vec2 texcoords;
|
||||||
|
out vec4 color;
|
||||||
|
|
||||||
|
uniform sampler2D image;
|
||||||
|
uniform vec3 spriteColor;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
color = vec4(spriteColor, 1.f) * texture(image, texcoords);
|
||||||
|
color.a = 1.f;
|
||||||
|
}
|
Loading…
Reference in a new issue