snake_case renderstate_t
parent
1c19c44400
commit
99111665ba
54
bind/v4k.lua
54
bind/v4k.lua
|
@ -1033,33 +1033,33 @@ typedef struct reflect_t {
|
||||||
int ui_reflect(const char *mask);
|
int ui_reflect(const char *mask);
|
||||||
typedef unsigned handle;
|
typedef unsigned handle;
|
||||||
typedef struct renderstate_t {
|
typedef struct renderstate_t {
|
||||||
int viewportX;
|
int viewport_x;
|
||||||
int viewportY;
|
int viewport_y;
|
||||||
int viewportWidth;
|
int viewport_width;
|
||||||
int viewportHeight;
|
int viewport_height;
|
||||||
float clearColor[4];
|
float clear_color[4];
|
||||||
double clearDepth;
|
double clear_depth;
|
||||||
bool depthTestEnabled;
|
bool depth_test_enabled;
|
||||||
unsigned depthFunc;
|
unsigned depth_func;
|
||||||
bool blendEnabled;
|
bool blend_enabled;
|
||||||
unsigned blendFunc;
|
unsigned blend_func;
|
||||||
unsigned blendSrc;
|
unsigned blend_src;
|
||||||
unsigned blendDst;
|
unsigned blend_dst;
|
||||||
bool cullFaceEnabled;
|
bool cull_face_enabled;
|
||||||
unsigned cullFaceMode;
|
unsigned cull_face_mode;
|
||||||
bool stencilTestEnabled;
|
bool stencil_test_enabled;
|
||||||
unsigned stencilFunc;
|
unsigned stencil_func;
|
||||||
int stencilRef;
|
int stencil_ref;
|
||||||
unsigned stencilMask;
|
unsigned stencil_mask;
|
||||||
unsigned frontFace;
|
unsigned front_face;
|
||||||
bool smoothLineEnabled;
|
bool smooth_line_enabled;
|
||||||
float lineWidth;
|
float line_width;
|
||||||
bool pointSizeEnabled;
|
bool point_size_enabled;
|
||||||
float pointSize;
|
float point_size;
|
||||||
unsigned polygonModeFace;
|
unsigned polygon_mode_face;
|
||||||
unsigned polygonModeMode;
|
unsigned polygon_mode_mode;
|
||||||
bool scissorTestEnabled;
|
bool scissor_test_enabled;
|
||||||
int scissorBox[4];
|
int scissor_box[4];
|
||||||
} renderstate_t;
|
} renderstate_t;
|
||||||
renderstate_t renderstate();
|
renderstate_t renderstate();
|
||||||
bool renderstate_compare(const renderstate_t *stateA, const renderstate_t *stateB);
|
bool renderstate_compare(const renderstate_t *stateA, const renderstate_t *stateB);
|
||||||
|
|
|
@ -17034,55 +17034,55 @@ typedef unsigned handle; // GLuint
|
||||||
// renderstate
|
// renderstate
|
||||||
typedef struct renderstate_t {
|
typedef struct renderstate_t {
|
||||||
// Viewport parameters
|
// Viewport parameters
|
||||||
int viewportX;
|
int viewport_x;
|
||||||
int viewportY;
|
int viewport_y;
|
||||||
int viewportWidth;
|
int viewport_width;
|
||||||
int viewportHeight;
|
int viewport_height;
|
||||||
|
|
||||||
// Clear color
|
// Clear color
|
||||||
float clearColor[4];
|
float clear_color[4];
|
||||||
|
|
||||||
// Clear depth
|
// Clear depth
|
||||||
double clearDepth;
|
double clear_depth;
|
||||||
|
|
||||||
// Depth test
|
// Depth test
|
||||||
bool depthTestEnabled;
|
bool depth_test_enabled;
|
||||||
unsigned depthFunc;
|
unsigned depth_func;
|
||||||
|
|
||||||
// Blending
|
// Blending
|
||||||
bool blendEnabled;
|
bool blend_enabled;
|
||||||
unsigned blendFunc;
|
unsigned blend_func;
|
||||||
unsigned blendSrc;
|
unsigned blend_src;
|
||||||
unsigned blendDst;
|
unsigned blend_dst;
|
||||||
|
|
||||||
// Culling
|
// Culling
|
||||||
bool cullFaceEnabled;
|
bool cull_face_enabled;
|
||||||
unsigned cullFaceMode;
|
unsigned cull_face_mode;
|
||||||
|
|
||||||
// Stencil test
|
// Stencil test
|
||||||
bool stencilTestEnabled;
|
bool stencil_test_enabled;
|
||||||
unsigned stencilFunc;
|
unsigned stencil_func;
|
||||||
int stencilRef;
|
int stencil_ref;
|
||||||
unsigned stencilMask;
|
unsigned stencil_mask;
|
||||||
|
|
||||||
// Face culling direction
|
// Face culling direction
|
||||||
unsigned frontFace; // GL_CW or GL_CCW
|
unsigned front_face; // GL_CW or GL_CCW
|
||||||
|
|
||||||
// Line width
|
// Line width
|
||||||
bool smoothLineEnabled;
|
bool smooth_line_enabled;
|
||||||
float lineWidth;
|
float line_width;
|
||||||
|
|
||||||
// Point size
|
// Point size
|
||||||
bool pointSizeEnabled;
|
bool point_size_enabled;
|
||||||
float pointSize;
|
float point_size;
|
||||||
|
|
||||||
// Polygon mode
|
// Polygon mode
|
||||||
unsigned polygonModeFace;
|
unsigned polygon_mode_face;
|
||||||
unsigned polygonModeMode;
|
unsigned polygon_mode_mode;
|
||||||
|
|
||||||
// Scissor test
|
// Scissor test
|
||||||
bool scissorTestEnabled;
|
bool scissor_test_enabled;
|
||||||
int scissorBox[4];
|
int scissor_box[4];
|
||||||
} renderstate_t;
|
} renderstate_t;
|
||||||
|
|
||||||
API renderstate_t renderstate();
|
API renderstate_t renderstate();
|
||||||
|
@ -363508,13 +363508,13 @@ void font_face_from_mem(const char *tag, const void *ttf_data, unsigned ttf_len,
|
||||||
|
|
||||||
// set up pipeline
|
// set up pipeline
|
||||||
f->rs = renderstate();
|
f->rs = renderstate();
|
||||||
f->rs.blendEnabled = 1;
|
f->rs.blend_enabled = 1;
|
||||||
f->rs.blendFunc = GL_FUNC_ADD;
|
f->rs.blend_func = GL_FUNC_ADD;
|
||||||
f->rs.blendSrc = GL_SRC_ALPHA;
|
f->rs.blend_src = GL_SRC_ALPHA;
|
||||||
f->rs.blendDst = GL_ONE_MINUS_SRC_ALPHA;
|
f->rs.blend_dst = GL_ONE_MINUS_SRC_ALPHA;
|
||||||
f->rs.scissorTestEnabled = 1;
|
f->rs.scissor_test_enabled = 1;
|
||||||
f->rs.depthTestEnabled = 0;
|
f->rs.depth_test_enabled = 0;
|
||||||
f->rs.cullFaceEnabled = 0;
|
f->rs.cull_face_enabled = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void font_face(const char *tag, const char *filename_ttf, float font_size, unsigned flags) {
|
void font_face(const char *tag, const char *filename_ttf, float font_size, unsigned flags) {
|
||||||
|
@ -363545,10 +363545,10 @@ void font_draw_cmd(font_t *f, const float *glyph_data, int glyph_idx, float fact
|
||||||
glActiveTexture(GL_TEXTURE2);
|
glActiveTexture(GL_TEXTURE2);
|
||||||
glGetIntegerv(GL_TEXTURE_BINDING_1D, &last_texture2);
|
glGetIntegerv(GL_TEXTURE_BINDING_1D, &last_texture2);
|
||||||
|
|
||||||
f->rs.scissorBox[0] = rect.x;
|
f->rs.scissor_box[0] = rect.x;
|
||||||
f->rs.scissorBox[1] = window_height() - (rect.y+rect.w);
|
f->rs.scissor_box[1] = window_height() - (rect.y+rect.w);
|
||||||
f->rs.scissorBox[2] = rect.z;
|
f->rs.scissor_box[2] = rect.z;
|
||||||
f->rs.scissorBox[3] = rect.w;
|
f->rs.scissor_box[3] = rect.w;
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
glBindTexture(GL_TEXTURE_2D, f->texture_fontdata);
|
glBindTexture(GL_TEXTURE_2D, f->texture_fontdata);
|
||||||
|
@ -370132,61 +370132,61 @@ renderstate_t renderstate() {
|
||||||
renderstate_t state = {0};
|
renderstate_t state = {0};
|
||||||
|
|
||||||
// Set default viewport parameters
|
// Set default viewport parameters
|
||||||
state.viewportX = 0;
|
state.viewport_x = 0;
|
||||||
state.viewportY = 0;
|
state.viewport_y = 0;
|
||||||
state.viewportWidth = window_width();
|
state.viewport_width = window_width();
|
||||||
state.viewportHeight = window_height();
|
state.viewport_height = window_height();
|
||||||
|
|
||||||
// Set default clear color to black
|
// Set default clear color to black
|
||||||
state.clearColor[0] = 0.0f; // Red
|
state.clear_color[0] = 0.0f; // Red
|
||||||
state.clearColor[1] = 0.0f; // Green
|
state.clear_color[1] = 0.0f; // Green
|
||||||
state.clearColor[2] = 0.0f; // Blue
|
state.clear_color[2] = 0.0f; // Blue
|
||||||
state.clearColor[3] = 1.0f; // Alpha
|
state.clear_color[3] = 1.0f; // Alpha
|
||||||
|
|
||||||
// Set default clear depth to maximum distance
|
// Set default clear depth to maximum distance
|
||||||
state.clearDepth = 1.0;
|
state.clear_depth = 1.0;
|
||||||
|
|
||||||
// Enable depth test by default with less or equal function
|
// Enable depth test by default with less or equal function
|
||||||
state.depthTestEnabled = GL_TRUE;
|
state.depth_test_enabled = GL_TRUE;
|
||||||
state.depthFunc = GL_LEQUAL;
|
state.depth_func = GL_LEQUAL;
|
||||||
|
|
||||||
// Disable blending by default
|
// Disable blending by default
|
||||||
state.blendEnabled = GL_FALSE;
|
state.blend_enabled = GL_FALSE;
|
||||||
state.blendFunc = GL_FUNC_ADD;
|
state.blend_func = GL_FUNC_ADD;
|
||||||
state.blendSrc = GL_ONE;
|
state.blend_src = GL_ONE;
|
||||||
state.blendDst = GL_ZERO;
|
state.blend_dst = GL_ZERO;
|
||||||
|
|
||||||
// Enable culling by default and cull back faces
|
// Enable culling by default and cull back faces
|
||||||
state.cullFaceEnabled = GL_TRUE;
|
state.cull_face_enabled = GL_TRUE;
|
||||||
state.cullFaceMode = GL_BACK;
|
state.cull_face_mode = GL_BACK;
|
||||||
|
|
||||||
// Disable stencil test by default
|
// Disable stencil test by default
|
||||||
state.stencilTestEnabled = GL_FALSE;
|
state.stencil_test_enabled = GL_FALSE;
|
||||||
state.stencilFunc = GL_ALWAYS;
|
state.stencil_func = GL_ALWAYS;
|
||||||
state.stencilRef = 0;
|
state.stencil_ref = 0;
|
||||||
state.stencilMask = 0xFFFFFFFF;
|
state.stencil_mask = 0xFFFFFFFF;
|
||||||
|
|
||||||
// Set default front face to counter-clockwise
|
// Set default front face to counter-clockwise
|
||||||
state.frontFace = GL_CCW;
|
state.front_face = GL_CCW;
|
||||||
|
|
||||||
// Set default line width
|
// Set default line width
|
||||||
state.smoothLineEnabled = GL_FALSE;
|
state.smooth_line_enabled = GL_FALSE;
|
||||||
state.lineWidth = 1.0f;
|
state.line_width = 1.0f;
|
||||||
|
|
||||||
// Set default point size
|
// Set default point size
|
||||||
state.pointSizeEnabled = GL_FALSE;
|
state.point_size_enabled = GL_FALSE;
|
||||||
state.pointSize = 1.0f;
|
state.point_size = 1.0f;
|
||||||
|
|
||||||
// Set default polygon mode to fill
|
// Set default polygon mode to fill
|
||||||
state.polygonModeFace = GL_FRONT_AND_BACK;
|
state.polygon_mode_face = GL_FRONT_AND_BACK;
|
||||||
state.polygonModeMode = GL_FILL;
|
state.polygon_mode_mode = GL_FILL;
|
||||||
|
|
||||||
// Disable scissor test by default
|
// Disable scissor test by default
|
||||||
state.scissorTestEnabled = GL_FALSE;
|
state.scissor_test_enabled = GL_FALSE;
|
||||||
state.scissorBox[0] = 0;
|
state.scissor_box[0] = 0;
|
||||||
state.scissorBox[1] = 0;
|
state.scissor_box[1] = 0;
|
||||||
state.scissorBox[2] = window_width();
|
state.scissor_box[2] = window_width();
|
||||||
state.scissorBox[3] = window_height();
|
state.scissor_box[3] = window_height();
|
||||||
|
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
@ -370198,75 +370198,75 @@ bool renderstate_compare(const renderstate_t *stateA, const renderstate_t *state
|
||||||
void renderstate_apply(const renderstate_t *state) {
|
void renderstate_apply(const renderstate_t *state) {
|
||||||
if (state != NULL) {
|
if (state != NULL) {
|
||||||
// Apply viewport parameters
|
// Apply viewport parameters
|
||||||
glViewport(state->viewportX, state->viewportY, state->viewportWidth, state->viewportHeight);
|
glViewport(state->viewport_x, state->viewport_y, state->viewport_width, state->viewport_height);
|
||||||
|
|
||||||
// Apply clear color
|
// Apply clear color
|
||||||
glClearColor(state->clearColor[0], state->clearColor[1], state->clearColor[2], state->clearColor[3]);
|
glClearColor(state->clear_color[0], state->clear_color[1], state->clear_color[2], state->clear_color[3]);
|
||||||
|
|
||||||
// Apply clear depth
|
// Apply clear depth
|
||||||
glClearDepth(state->clearDepth);
|
glClearDepth(state->clear_depth);
|
||||||
|
|
||||||
// Apply depth test
|
// Apply depth test
|
||||||
if (state->depthTestEnabled) {
|
if (state->depth_test_enabled) {
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
glDepthFunc(state->depthFunc);
|
glDepthFunc(state->depth_func);
|
||||||
} else {
|
} else {
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply blending
|
// Apply blending
|
||||||
if (state->blendEnabled) {
|
if (state->blend_enabled) {
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendEquation(state->blendFunc);
|
glBlendEquation(state->blend_func);
|
||||||
glBlendFunc(state->blendSrc, state->blendDst);
|
glBlendFunc(state->blend_src, state->blend_dst);
|
||||||
} else {
|
} else {
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply culling @fixme
|
// Apply culling @fixme
|
||||||
// if (state->cullFaceEnabled) {
|
// if (state->cull_face_enabled) {
|
||||||
// glEnable(GL_CULL_FACE);
|
// glEnable(GL_CULL_FACE);
|
||||||
// glCullFace(state->cullFaceMode);
|
// glCullFace(state->cull_face_mode);
|
||||||
// } else {
|
// } else {
|
||||||
// glDisable(GL_CULL_FACE);
|
// glDisable(GL_CULL_FACE);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// Apply stencil test
|
// Apply stencil test
|
||||||
if (state->stencilTestEnabled) {
|
if (state->stencil_test_enabled) {
|
||||||
glEnable(GL_STENCIL_TEST);
|
glEnable(GL_STENCIL_TEST);
|
||||||
glStencilFunc(state->stencilFunc, state->stencilRef, state->stencilMask);
|
glStencilFunc(state->stencil_func, state->stencil_ref, state->stencil_mask);
|
||||||
} else {
|
} else {
|
||||||
glDisable(GL_STENCIL_TEST);
|
glDisable(GL_STENCIL_TEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply front face direction @fixme
|
// Apply front face direction @fixme
|
||||||
// glFrontFace(state->frontFace);
|
// glFrontFace(state->front_face);
|
||||||
|
|
||||||
// Apply line width
|
// Apply line width
|
||||||
glLineWidth(state->lineWidth);
|
glLineWidth(state->line_width);
|
||||||
|
|
||||||
// apply smooth lines
|
// Apply smooth lines
|
||||||
if (state->smoothLineEnabled) {
|
if (state->smooth_line_enabled) {
|
||||||
glEnable(GL_LINE_SMOOTH);
|
glEnable(GL_LINE_SMOOTH);
|
||||||
} else {
|
} else {
|
||||||
glDisable(GL_LINE_SMOOTH);
|
glDisable(GL_LINE_SMOOTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply point size
|
// Apply point size
|
||||||
if (state->pointSizeEnabled) {
|
if (state->point_size_enabled) {
|
||||||
glEnable(GL_PROGRAM_POINT_SIZE);
|
glEnable(GL_PROGRAM_POINT_SIZE);
|
||||||
glPointSize(state->pointSize);
|
glPointSize(state->point_size);
|
||||||
} else {
|
} else {
|
||||||
glDisable(GL_PROGRAM_POINT_SIZE);
|
glDisable(GL_PROGRAM_POINT_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply polygon mode
|
// Apply polygon mode
|
||||||
glPolygonMode(state->polygonModeFace, state->polygonModeMode);
|
glPolygonMode(state->polygon_mode_face, state->polygon_mode_mode);
|
||||||
|
|
||||||
// Apply scissor test
|
// Apply scissor test
|
||||||
if (state->scissorTestEnabled) {
|
if (state->scissor_test_enabled) {
|
||||||
glEnable(GL_SCISSOR_TEST);
|
glEnable(GL_SCISSOR_TEST);
|
||||||
glScissor(state->scissorBox[0], state->scissorBox[1], state->scissorBox[2], state->scissorBox[3]);
|
glScissor(state->scissor_box[0], state->scissor_box[1], state->scissor_box[2], state->scissor_box[3]);
|
||||||
} else {
|
} else {
|
||||||
glDisable(GL_SCISSOR_TEST);
|
glDisable(GL_SCISSOR_TEST);
|
||||||
}
|
}
|
||||||
|
@ -372088,10 +372088,10 @@ int skybox_push_state(skybox_t *sky, mat44 proj, mat44 view) {
|
||||||
|
|
||||||
// we have to reset clear color here, because of wrong alpha compositing issues on native transparent windows otherwise
|
// we have to reset clear color here, because of wrong alpha compositing issues on native transparent windows otherwise
|
||||||
vec4 bgcolor = window_getcolor_();
|
vec4 bgcolor = window_getcolor_();
|
||||||
skybox_rs.clearColor[0] = bgcolor.r;
|
skybox_rs.clear_color[0] = bgcolor.r;
|
||||||
skybox_rs.clearColor[1] = bgcolor.g;
|
skybox_rs.clear_color[1] = bgcolor.g;
|
||||||
skybox_rs.clearColor[2] = bgcolor.b;
|
skybox_rs.clear_color[2] = bgcolor.b;
|
||||||
skybox_rs.clearColor[3] = 1; // @transparent
|
skybox_rs.clear_color[3] = 1; // @transparent
|
||||||
|
|
||||||
mat44 mvp; multiply44x2(mvp, proj, view);
|
mat44 mvp; multiply44x2(mvp, proj, view);
|
||||||
|
|
||||||
|
@ -373773,7 +373773,7 @@ model_t model_from_mem(const void *mem, int len, int flags) {
|
||||||
|
|
||||||
{
|
{
|
||||||
m.rs = renderstate();
|
m.rs = renderstate();
|
||||||
m.rs.blendEnabled = 1;
|
m.rs.blend_enabled = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
m.stored_flags = flags;
|
m.stored_flags = flags;
|
||||||
|
@ -374395,7 +374395,7 @@ void ddraw_flush() {
|
||||||
void ddraw_flush_projview(mat44 proj, mat44 view) {
|
void ddraw_flush_projview(mat44 proj, mat44 view) {
|
||||||
do_once dd_rs = renderstate();
|
do_once dd_rs = renderstate();
|
||||||
|
|
||||||
dd_rs.depthTestEnabled = 1;
|
dd_rs.depth_test_enabled = 1;
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
|
||||||
mat44 mvp;
|
mat44 mvp;
|
||||||
|
@ -374410,12 +374410,12 @@ void ddraw_flush_projview(mat44 proj, mat44 view) {
|
||||||
|
|
||||||
glEnableVertexAttribArray(0);
|
glEnableVertexAttribArray(0);
|
||||||
|
|
||||||
dd_rs.pointSizeEnabled = 1;
|
dd_rs.point_size_enabled = 1;
|
||||||
dd_rs.smoothLineEnabled = 1;
|
dd_rs.smooth_line_enabled = 1;
|
||||||
|
|
||||||
for( int i = 0; i < 3; ++i ) { // [0] thin, [1] thick, [2] points
|
for( int i = 0; i < 3; ++i ) { // [0] thin, [1] thick, [2] points
|
||||||
GLenum mode = i < 2 ? GL_LINES : GL_POINTS;
|
GLenum mode = i < 2 ? GL_LINES : GL_POINTS;
|
||||||
dd_rs.lineWidth = (i == 1 ? 1 : 0.3); // 0.625);
|
dd_rs.line_width = (i == 1 ? 1 : 0.3); // 0.625);
|
||||||
for each_map(dd_lists[dd_ontop][i], unsigned, rgb, array(vec3), list) {
|
for each_map(dd_lists[dd_ontop][i], unsigned, rgb, array(vec3), list) {
|
||||||
int count = array_count(list);
|
int count = array_count(list);
|
||||||
if(!count) continue;
|
if(!count) continue;
|
||||||
|
@ -374448,7 +374448,7 @@ void ddraw_flush_projview(mat44 proj, mat44 view) {
|
||||||
glUniformMatrix4fv(glGetUniformLocation(dd_program, "u_MVP"), 1, GL_FALSE, mvp);
|
glUniformMatrix4fv(glGetUniformLocation(dd_program, "u_MVP"), 1, GL_FALSE, mvp);
|
||||||
for( int i = 0; i < 3; ++i ) { // [0] thin, [1] thick, [2] points
|
for( int i = 0; i < 3; ++i ) { // [0] thin, [1] thick, [2] points
|
||||||
GLenum mode = i < 2 ? GL_LINES : GL_POINTS;
|
GLenum mode = i < 2 ? GL_LINES : GL_POINTS;
|
||||||
dd_rs.lineWidth = (i == 1 ? 1 : 0.3); // 0.625);
|
dd_rs.line_width = (i == 1 ? 1 : 0.3); // 0.625);
|
||||||
for each_map(dd_lists[dd_ontop][i], unsigned, rgb, array(vec3), list) {
|
for each_map(dd_lists[dd_ontop][i], unsigned, rgb, array(vec3), list) {
|
||||||
int count = array_count(list);
|
int count = array_count(list);
|
||||||
if(!count) continue;
|
if(!count) continue;
|
||||||
|
@ -379751,14 +379751,14 @@ static renderstate_t window_rs;
|
||||||
void glNewFrame() {
|
void glNewFrame() {
|
||||||
do_once {
|
do_once {
|
||||||
window_rs = renderstate();
|
window_rs = renderstate();
|
||||||
window_rs.blendEnabled = 1;
|
window_rs.blend_enabled = 1;
|
||||||
window_rs.depthTestEnabled = 1;
|
window_rs.depth_test_enabled = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
window_rs.clearColor[0] = winbgcolor.r;
|
window_rs.clear_color[0] = winbgcolor.r;
|
||||||
window_rs.clearColor[1] = winbgcolor.g;
|
window_rs.clear_color[1] = winbgcolor.g;
|
||||||
window_rs.clearColor[2] = winbgcolor.b;
|
window_rs.clear_color[2] = winbgcolor.b;
|
||||||
window_rs.clearColor[3] = window_has_transparent() ? 0 : winbgcolor.a;
|
window_rs.clear_color[3] = window_has_transparent() ? 0 : winbgcolor.a;
|
||||||
|
|
||||||
// @transparent debug
|
// @transparent debug
|
||||||
// if( input_down(KEY_F1) ) window_transparent(window_has_transparent()^1);
|
// if( input_down(KEY_F1) ) window_transparent(window_has_transparent()^1);
|
||||||
|
|
|
@ -1898,13 +1898,13 @@ void font_face_from_mem(const char *tag, const void *ttf_data, unsigned ttf_len,
|
||||||
|
|
||||||
// set up pipeline
|
// set up pipeline
|
||||||
f->rs = renderstate();
|
f->rs = renderstate();
|
||||||
f->rs.blendEnabled = 1;
|
f->rs.blend_enabled = 1;
|
||||||
f->rs.blendFunc = GL_FUNC_ADD;
|
f->rs.blend_func = GL_FUNC_ADD;
|
||||||
f->rs.blendSrc = GL_SRC_ALPHA;
|
f->rs.blend_src = GL_SRC_ALPHA;
|
||||||
f->rs.blendDst = GL_ONE_MINUS_SRC_ALPHA;
|
f->rs.blend_dst = GL_ONE_MINUS_SRC_ALPHA;
|
||||||
f->rs.scissorTestEnabled = 1;
|
f->rs.scissor_test_enabled = 1;
|
||||||
f->rs.depthTestEnabled = 0;
|
f->rs.depth_test_enabled = 0;
|
||||||
f->rs.cullFaceEnabled = 0;
|
f->rs.cull_face_enabled = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void font_face(const char *tag, const char *filename_ttf, float font_size, unsigned flags) {
|
void font_face(const char *tag, const char *filename_ttf, float font_size, unsigned flags) {
|
||||||
|
@ -1935,10 +1935,10 @@ void font_draw_cmd(font_t *f, const float *glyph_data, int glyph_idx, float fact
|
||||||
glActiveTexture(GL_TEXTURE2);
|
glActiveTexture(GL_TEXTURE2);
|
||||||
glGetIntegerv(GL_TEXTURE_BINDING_1D, &last_texture2);
|
glGetIntegerv(GL_TEXTURE_BINDING_1D, &last_texture2);
|
||||||
|
|
||||||
f->rs.scissorBox[0] = rect.x;
|
f->rs.scissor_box[0] = rect.x;
|
||||||
f->rs.scissorBox[1] = window_height() - (rect.y+rect.w);
|
f->rs.scissor_box[1] = window_height() - (rect.y+rect.w);
|
||||||
f->rs.scissorBox[2] = rect.z;
|
f->rs.scissor_box[2] = rect.z;
|
||||||
f->rs.scissorBox[3] = rect.w;
|
f->rs.scissor_box[3] = rect.w;
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
glBindTexture(GL_TEXTURE_2D, f->texture_fontdata);
|
glBindTexture(GL_TEXTURE_2D, f->texture_fontdata);
|
||||||
|
|
|
@ -57,61 +57,61 @@ renderstate_t renderstate() {
|
||||||
renderstate_t state = {0};
|
renderstate_t state = {0};
|
||||||
|
|
||||||
// Set default viewport parameters
|
// Set default viewport parameters
|
||||||
state.viewportX = 0;
|
state.viewport_x = 0;
|
||||||
state.viewportY = 0;
|
state.viewport_y = 0;
|
||||||
state.viewportWidth = window_width();
|
state.viewport_width = window_width();
|
||||||
state.viewportHeight = window_height();
|
state.viewport_height = window_height();
|
||||||
|
|
||||||
// Set default clear color to black
|
// Set default clear color to black
|
||||||
state.clearColor[0] = 0.0f; // Red
|
state.clear_color[0] = 0.0f; // Red
|
||||||
state.clearColor[1] = 0.0f; // Green
|
state.clear_color[1] = 0.0f; // Green
|
||||||
state.clearColor[2] = 0.0f; // Blue
|
state.clear_color[2] = 0.0f; // Blue
|
||||||
state.clearColor[3] = 1.0f; // Alpha
|
state.clear_color[3] = 1.0f; // Alpha
|
||||||
|
|
||||||
// Set default clear depth to maximum distance
|
// Set default clear depth to maximum distance
|
||||||
state.clearDepth = 1.0;
|
state.clear_depth = 1.0;
|
||||||
|
|
||||||
// Enable depth test by default with less or equal function
|
// Enable depth test by default with less or equal function
|
||||||
state.depthTestEnabled = GL_TRUE;
|
state.depth_test_enabled = GL_TRUE;
|
||||||
state.depthFunc = GL_LEQUAL;
|
state.depth_func = GL_LEQUAL;
|
||||||
|
|
||||||
// Disable blending by default
|
// Disable blending by default
|
||||||
state.blendEnabled = GL_FALSE;
|
state.blend_enabled = GL_FALSE;
|
||||||
state.blendFunc = GL_FUNC_ADD;
|
state.blend_func = GL_FUNC_ADD;
|
||||||
state.blendSrc = GL_ONE;
|
state.blend_src = GL_ONE;
|
||||||
state.blendDst = GL_ZERO;
|
state.blend_dst = GL_ZERO;
|
||||||
|
|
||||||
// Enable culling by default and cull back faces
|
// Enable culling by default and cull back faces
|
||||||
state.cullFaceEnabled = GL_TRUE;
|
state.cull_face_enabled = GL_TRUE;
|
||||||
state.cullFaceMode = GL_BACK;
|
state.cull_face_mode = GL_BACK;
|
||||||
|
|
||||||
// Disable stencil test by default
|
// Disable stencil test by default
|
||||||
state.stencilTestEnabled = GL_FALSE;
|
state.stencil_test_enabled = GL_FALSE;
|
||||||
state.stencilFunc = GL_ALWAYS;
|
state.stencil_func = GL_ALWAYS;
|
||||||
state.stencilRef = 0;
|
state.stencil_ref = 0;
|
||||||
state.stencilMask = 0xFFFFFFFF;
|
state.stencil_mask = 0xFFFFFFFF;
|
||||||
|
|
||||||
// Set default front face to counter-clockwise
|
// Set default front face to counter-clockwise
|
||||||
state.frontFace = GL_CCW;
|
state.front_face = GL_CCW;
|
||||||
|
|
||||||
// Set default line width
|
// Set default line width
|
||||||
state.smoothLineEnabled = GL_FALSE;
|
state.smooth_line_enabled = GL_FALSE;
|
||||||
state.lineWidth = 1.0f;
|
state.line_width = 1.0f;
|
||||||
|
|
||||||
// Set default point size
|
// Set default point size
|
||||||
state.pointSizeEnabled = GL_FALSE;
|
state.point_size_enabled = GL_FALSE;
|
||||||
state.pointSize = 1.0f;
|
state.point_size = 1.0f;
|
||||||
|
|
||||||
// Set default polygon mode to fill
|
// Set default polygon mode to fill
|
||||||
state.polygonModeFace = GL_FRONT_AND_BACK;
|
state.polygon_mode_face = GL_FRONT_AND_BACK;
|
||||||
state.polygonModeMode = GL_FILL;
|
state.polygon_mode_mode = GL_FILL;
|
||||||
|
|
||||||
// Disable scissor test by default
|
// Disable scissor test by default
|
||||||
state.scissorTestEnabled = GL_FALSE;
|
state.scissor_test_enabled = GL_FALSE;
|
||||||
state.scissorBox[0] = 0;
|
state.scissor_box[0] = 0;
|
||||||
state.scissorBox[1] = 0;
|
state.scissor_box[1] = 0;
|
||||||
state.scissorBox[2] = window_width();
|
state.scissor_box[2] = window_width();
|
||||||
state.scissorBox[3] = window_height();
|
state.scissor_box[3] = window_height();
|
||||||
|
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
@ -123,75 +123,75 @@ bool renderstate_compare(const renderstate_t *stateA, const renderstate_t *state
|
||||||
void renderstate_apply(const renderstate_t *state) {
|
void renderstate_apply(const renderstate_t *state) {
|
||||||
if (state != NULL) {
|
if (state != NULL) {
|
||||||
// Apply viewport parameters
|
// Apply viewport parameters
|
||||||
glViewport(state->viewportX, state->viewportY, state->viewportWidth, state->viewportHeight);
|
glViewport(state->viewport_x, state->viewport_y, state->viewport_width, state->viewport_height);
|
||||||
|
|
||||||
// Apply clear color
|
// Apply clear color
|
||||||
glClearColor(state->clearColor[0], state->clearColor[1], state->clearColor[2], state->clearColor[3]);
|
glClearColor(state->clear_color[0], state->clear_color[1], state->clear_color[2], state->clear_color[3]);
|
||||||
|
|
||||||
// Apply clear depth
|
// Apply clear depth
|
||||||
glClearDepth(state->clearDepth);
|
glClearDepth(state->clear_depth);
|
||||||
|
|
||||||
// Apply depth test
|
// Apply depth test
|
||||||
if (state->depthTestEnabled) {
|
if (state->depth_test_enabled) {
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
glDepthFunc(state->depthFunc);
|
glDepthFunc(state->depth_func);
|
||||||
} else {
|
} else {
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply blending
|
// Apply blending
|
||||||
if (state->blendEnabled) {
|
if (state->blend_enabled) {
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendEquation(state->blendFunc);
|
glBlendEquation(state->blend_func);
|
||||||
glBlendFunc(state->blendSrc, state->blendDst);
|
glBlendFunc(state->blend_src, state->blend_dst);
|
||||||
} else {
|
} else {
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply culling @fixme
|
// Apply culling @fixme
|
||||||
// if (state->cullFaceEnabled) {
|
// if (state->cull_face_enabled) {
|
||||||
// glEnable(GL_CULL_FACE);
|
// glEnable(GL_CULL_FACE);
|
||||||
// glCullFace(state->cullFaceMode);
|
// glCullFace(state->cull_face_mode);
|
||||||
// } else {
|
// } else {
|
||||||
// glDisable(GL_CULL_FACE);
|
// glDisable(GL_CULL_FACE);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// Apply stencil test
|
// Apply stencil test
|
||||||
if (state->stencilTestEnabled) {
|
if (state->stencil_test_enabled) {
|
||||||
glEnable(GL_STENCIL_TEST);
|
glEnable(GL_STENCIL_TEST);
|
||||||
glStencilFunc(state->stencilFunc, state->stencilRef, state->stencilMask);
|
glStencilFunc(state->stencil_func, state->stencil_ref, state->stencil_mask);
|
||||||
} else {
|
} else {
|
||||||
glDisable(GL_STENCIL_TEST);
|
glDisable(GL_STENCIL_TEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply front face direction @fixme
|
// Apply front face direction @fixme
|
||||||
// glFrontFace(state->frontFace);
|
// glFrontFace(state->front_face);
|
||||||
|
|
||||||
// Apply line width
|
// Apply line width
|
||||||
glLineWidth(state->lineWidth);
|
glLineWidth(state->line_width);
|
||||||
|
|
||||||
// apply smooth lines
|
// Apply smooth lines
|
||||||
if (state->smoothLineEnabled) {
|
if (state->smooth_line_enabled) {
|
||||||
glEnable(GL_LINE_SMOOTH);
|
glEnable(GL_LINE_SMOOTH);
|
||||||
} else {
|
} else {
|
||||||
glDisable(GL_LINE_SMOOTH);
|
glDisable(GL_LINE_SMOOTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply point size
|
// Apply point size
|
||||||
if (state->pointSizeEnabled) {
|
if (state->point_size_enabled) {
|
||||||
glEnable(GL_PROGRAM_POINT_SIZE);
|
glEnable(GL_PROGRAM_POINT_SIZE);
|
||||||
glPointSize(state->pointSize);
|
glPointSize(state->point_size);
|
||||||
} else {
|
} else {
|
||||||
glDisable(GL_PROGRAM_POINT_SIZE);
|
glDisable(GL_PROGRAM_POINT_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply polygon mode
|
// Apply polygon mode
|
||||||
glPolygonMode(state->polygonModeFace, state->polygonModeMode);
|
glPolygonMode(state->polygon_mode_face, state->polygon_mode_mode);
|
||||||
|
|
||||||
// Apply scissor test
|
// Apply scissor test
|
||||||
if (state->scissorTestEnabled) {
|
if (state->scissor_test_enabled) {
|
||||||
glEnable(GL_SCISSOR_TEST);
|
glEnable(GL_SCISSOR_TEST);
|
||||||
glScissor(state->scissorBox[0], state->scissorBox[1], state->scissorBox[2], state->scissorBox[3]);
|
glScissor(state->scissor_box[0], state->scissor_box[1], state->scissor_box[2], state->scissor_box[3]);
|
||||||
} else {
|
} else {
|
||||||
glDisable(GL_SCISSOR_TEST);
|
glDisable(GL_SCISSOR_TEST);
|
||||||
}
|
}
|
||||||
|
@ -2013,10 +2013,10 @@ int skybox_push_state(skybox_t *sky, mat44 proj, mat44 view) {
|
||||||
|
|
||||||
// we have to reset clear color here, because of wrong alpha compositing issues on native transparent windows otherwise
|
// we have to reset clear color here, because of wrong alpha compositing issues on native transparent windows otherwise
|
||||||
vec4 bgcolor = window_getcolor_();
|
vec4 bgcolor = window_getcolor_();
|
||||||
skybox_rs.clearColor[0] = bgcolor.r;
|
skybox_rs.clear_color[0] = bgcolor.r;
|
||||||
skybox_rs.clearColor[1] = bgcolor.g;
|
skybox_rs.clear_color[1] = bgcolor.g;
|
||||||
skybox_rs.clearColor[2] = bgcolor.b;
|
skybox_rs.clear_color[2] = bgcolor.b;
|
||||||
skybox_rs.clearColor[3] = 1; // @transparent
|
skybox_rs.clear_color[3] = 1; // @transparent
|
||||||
|
|
||||||
mat44 mvp; multiply44x2(mvp, proj, view);
|
mat44 mvp; multiply44x2(mvp, proj, view);
|
||||||
|
|
||||||
|
@ -3698,7 +3698,7 @@ model_t model_from_mem(const void *mem, int len, int flags) {
|
||||||
|
|
||||||
{
|
{
|
||||||
m.rs = renderstate();
|
m.rs = renderstate();
|
||||||
m.rs.blendEnabled = 1;
|
m.rs.blend_enabled = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
m.stored_flags = flags;
|
m.stored_flags = flags;
|
||||||
|
|
|
@ -12,55 +12,55 @@ typedef unsigned handle; // GLuint
|
||||||
// renderstate
|
// renderstate
|
||||||
typedef struct renderstate_t {
|
typedef struct renderstate_t {
|
||||||
// Viewport parameters
|
// Viewport parameters
|
||||||
int viewportX;
|
int viewport_x;
|
||||||
int viewportY;
|
int viewport_y;
|
||||||
int viewportWidth;
|
int viewport_width;
|
||||||
int viewportHeight;
|
int viewport_height;
|
||||||
|
|
||||||
// Clear color
|
// Clear color
|
||||||
float clearColor[4];
|
float clear_color[4];
|
||||||
|
|
||||||
// Clear depth
|
// Clear depth
|
||||||
double clearDepth;
|
double clear_depth;
|
||||||
|
|
||||||
// Depth test
|
// Depth test
|
||||||
bool depthTestEnabled;
|
bool depth_test_enabled;
|
||||||
unsigned depthFunc;
|
unsigned depth_func;
|
||||||
|
|
||||||
// Blending
|
// Blending
|
||||||
bool blendEnabled;
|
bool blend_enabled;
|
||||||
unsigned blendFunc;
|
unsigned blend_func;
|
||||||
unsigned blendSrc;
|
unsigned blend_src;
|
||||||
unsigned blendDst;
|
unsigned blend_dst;
|
||||||
|
|
||||||
// Culling
|
// Culling
|
||||||
bool cullFaceEnabled;
|
bool cull_face_enabled;
|
||||||
unsigned cullFaceMode;
|
unsigned cull_face_mode;
|
||||||
|
|
||||||
// Stencil test
|
// Stencil test
|
||||||
bool stencilTestEnabled;
|
bool stencil_test_enabled;
|
||||||
unsigned stencilFunc;
|
unsigned stencil_func;
|
||||||
int stencilRef;
|
int stencil_ref;
|
||||||
unsigned stencilMask;
|
unsigned stencil_mask;
|
||||||
|
|
||||||
// Face culling direction
|
// Face culling direction
|
||||||
unsigned frontFace; // GL_CW or GL_CCW
|
unsigned front_face; // GL_CW or GL_CCW
|
||||||
|
|
||||||
// Line width
|
// Line width
|
||||||
bool smoothLineEnabled;
|
bool smooth_line_enabled;
|
||||||
float lineWidth;
|
float line_width;
|
||||||
|
|
||||||
// Point size
|
// Point size
|
||||||
bool pointSizeEnabled;
|
bool point_size_enabled;
|
||||||
float pointSize;
|
float point_size;
|
||||||
|
|
||||||
// Polygon mode
|
// Polygon mode
|
||||||
unsigned polygonModeFace;
|
unsigned polygon_mode_face;
|
||||||
unsigned polygonModeMode;
|
unsigned polygon_mode_mode;
|
||||||
|
|
||||||
// Scissor test
|
// Scissor test
|
||||||
bool scissorTestEnabled;
|
bool scissor_test_enabled;
|
||||||
int scissorBox[4];
|
int scissor_box[4];
|
||||||
} renderstate_t;
|
} renderstate_t;
|
||||||
|
|
||||||
API renderstate_t renderstate();
|
API renderstate_t renderstate();
|
||||||
|
|
|
@ -69,7 +69,7 @@ void ddraw_flush() {
|
||||||
void ddraw_flush_projview(mat44 proj, mat44 view) {
|
void ddraw_flush_projview(mat44 proj, mat44 view) {
|
||||||
do_once dd_rs = renderstate();
|
do_once dd_rs = renderstate();
|
||||||
|
|
||||||
dd_rs.depthTestEnabled = 1;
|
dd_rs.depth_test_enabled = 1;
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
|
||||||
mat44 mvp;
|
mat44 mvp;
|
||||||
|
@ -84,12 +84,12 @@ void ddraw_flush_projview(mat44 proj, mat44 view) {
|
||||||
|
|
||||||
glEnableVertexAttribArray(0);
|
glEnableVertexAttribArray(0);
|
||||||
|
|
||||||
dd_rs.pointSizeEnabled = 1;
|
dd_rs.point_size_enabled = 1;
|
||||||
dd_rs.smoothLineEnabled = 1;
|
dd_rs.smooth_line_enabled = 1;
|
||||||
|
|
||||||
for( int i = 0; i < 3; ++i ) { // [0] thin, [1] thick, [2] points
|
for( int i = 0; i < 3; ++i ) { // [0] thin, [1] thick, [2] points
|
||||||
GLenum mode = i < 2 ? GL_LINES : GL_POINTS;
|
GLenum mode = i < 2 ? GL_LINES : GL_POINTS;
|
||||||
dd_rs.lineWidth = (i == 1 ? 1 : 0.3); // 0.625);
|
dd_rs.line_width = (i == 1 ? 1 : 0.3); // 0.625);
|
||||||
for each_map(dd_lists[dd_ontop][i], unsigned, rgb, array(vec3), list) {
|
for each_map(dd_lists[dd_ontop][i], unsigned, rgb, array(vec3), list) {
|
||||||
int count = array_count(list);
|
int count = array_count(list);
|
||||||
if(!count) continue;
|
if(!count) continue;
|
||||||
|
@ -122,7 +122,7 @@ void ddraw_flush_projview(mat44 proj, mat44 view) {
|
||||||
glUniformMatrix4fv(glGetUniformLocation(dd_program, "u_MVP"), 1, GL_FALSE, mvp);
|
glUniformMatrix4fv(glGetUniformLocation(dd_program, "u_MVP"), 1, GL_FALSE, mvp);
|
||||||
for( int i = 0; i < 3; ++i ) { // [0] thin, [1] thick, [2] points
|
for( int i = 0; i < 3; ++i ) { // [0] thin, [1] thick, [2] points
|
||||||
GLenum mode = i < 2 ? GL_LINES : GL_POINTS;
|
GLenum mode = i < 2 ? GL_LINES : GL_POINTS;
|
||||||
dd_rs.lineWidth = (i == 1 ? 1 : 0.3); // 0.625);
|
dd_rs.line_width = (i == 1 ? 1 : 0.3); // 0.625);
|
||||||
for each_map(dd_lists[dd_ontop][i], unsigned, rgb, array(vec3), list) {
|
for each_map(dd_lists[dd_ontop][i], unsigned, rgb, array(vec3), list) {
|
||||||
int count = array_count(list);
|
int count = array_count(list);
|
||||||
if(!count) continue;
|
if(!count) continue;
|
||||||
|
|
|
@ -226,14 +226,14 @@ static renderstate_t window_rs;
|
||||||
void glNewFrame() {
|
void glNewFrame() {
|
||||||
do_once {
|
do_once {
|
||||||
window_rs = renderstate();
|
window_rs = renderstate();
|
||||||
window_rs.blendEnabled = 1;
|
window_rs.blend_enabled = 1;
|
||||||
window_rs.depthTestEnabled = 1;
|
window_rs.depth_test_enabled = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
window_rs.clearColor[0] = winbgcolor.r;
|
window_rs.clear_color[0] = winbgcolor.r;
|
||||||
window_rs.clearColor[1] = winbgcolor.g;
|
window_rs.clear_color[1] = winbgcolor.g;
|
||||||
window_rs.clearColor[2] = winbgcolor.b;
|
window_rs.clear_color[2] = winbgcolor.b;
|
||||||
window_rs.clearColor[3] = window_has_transparent() ? 0 : winbgcolor.a;
|
window_rs.clear_color[3] = window_has_transparent() ? 0 : winbgcolor.a;
|
||||||
|
|
||||||
// @transparent debug
|
// @transparent debug
|
||||||
// if( input_down(KEY_F1) ) window_transparent(window_has_transparent()^1);
|
// if( input_down(KEY_F1) ) window_transparent(window_has_transparent()^1);
|
||||||
|
|
162
engine/v4k.c
162
engine/v4k.c
|
@ -10600,13 +10600,13 @@ void font_face_from_mem(const char *tag, const void *ttf_data, unsigned ttf_len,
|
||||||
|
|
||||||
// set up pipeline
|
// set up pipeline
|
||||||
f->rs = renderstate();
|
f->rs = renderstate();
|
||||||
f->rs.blendEnabled = 1;
|
f->rs.blend_enabled = 1;
|
||||||
f->rs.blendFunc = GL_FUNC_ADD;
|
f->rs.blend_func = GL_FUNC_ADD;
|
||||||
f->rs.blendSrc = GL_SRC_ALPHA;
|
f->rs.blend_src = GL_SRC_ALPHA;
|
||||||
f->rs.blendDst = GL_ONE_MINUS_SRC_ALPHA;
|
f->rs.blend_dst = GL_ONE_MINUS_SRC_ALPHA;
|
||||||
f->rs.scissorTestEnabled = 1;
|
f->rs.scissor_test_enabled = 1;
|
||||||
f->rs.depthTestEnabled = 0;
|
f->rs.depth_test_enabled = 0;
|
||||||
f->rs.cullFaceEnabled = 0;
|
f->rs.cull_face_enabled = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void font_face(const char *tag, const char *filename_ttf, float font_size, unsigned flags) {
|
void font_face(const char *tag, const char *filename_ttf, float font_size, unsigned flags) {
|
||||||
|
@ -10637,10 +10637,10 @@ void font_draw_cmd(font_t *f, const float *glyph_data, int glyph_idx, float fact
|
||||||
glActiveTexture(GL_TEXTURE2);
|
glActiveTexture(GL_TEXTURE2);
|
||||||
glGetIntegerv(GL_TEXTURE_BINDING_1D, &last_texture2);
|
glGetIntegerv(GL_TEXTURE_BINDING_1D, &last_texture2);
|
||||||
|
|
||||||
f->rs.scissorBox[0] = rect.x;
|
f->rs.scissor_box[0] = rect.x;
|
||||||
f->rs.scissorBox[1] = window_height() - (rect.y+rect.w);
|
f->rs.scissor_box[1] = window_height() - (rect.y+rect.w);
|
||||||
f->rs.scissorBox[2] = rect.z;
|
f->rs.scissor_box[2] = rect.z;
|
||||||
f->rs.scissorBox[3] = rect.w;
|
f->rs.scissor_box[3] = rect.w;
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
glBindTexture(GL_TEXTURE_2D, f->texture_fontdata);
|
glBindTexture(GL_TEXTURE_2D, f->texture_fontdata);
|
||||||
|
@ -17224,61 +17224,61 @@ renderstate_t renderstate() {
|
||||||
renderstate_t state = {0};
|
renderstate_t state = {0};
|
||||||
|
|
||||||
// Set default viewport parameters
|
// Set default viewport parameters
|
||||||
state.viewportX = 0;
|
state.viewport_x = 0;
|
||||||
state.viewportY = 0;
|
state.viewport_y = 0;
|
||||||
state.viewportWidth = window_width();
|
state.viewport_width = window_width();
|
||||||
state.viewportHeight = window_height();
|
state.viewport_height = window_height();
|
||||||
|
|
||||||
// Set default clear color to black
|
// Set default clear color to black
|
||||||
state.clearColor[0] = 0.0f; // Red
|
state.clear_color[0] = 0.0f; // Red
|
||||||
state.clearColor[1] = 0.0f; // Green
|
state.clear_color[1] = 0.0f; // Green
|
||||||
state.clearColor[2] = 0.0f; // Blue
|
state.clear_color[2] = 0.0f; // Blue
|
||||||
state.clearColor[3] = 1.0f; // Alpha
|
state.clear_color[3] = 1.0f; // Alpha
|
||||||
|
|
||||||
// Set default clear depth to maximum distance
|
// Set default clear depth to maximum distance
|
||||||
state.clearDepth = 1.0;
|
state.clear_depth = 1.0;
|
||||||
|
|
||||||
// Enable depth test by default with less or equal function
|
// Enable depth test by default with less or equal function
|
||||||
state.depthTestEnabled = GL_TRUE;
|
state.depth_test_enabled = GL_TRUE;
|
||||||
state.depthFunc = GL_LEQUAL;
|
state.depth_func = GL_LEQUAL;
|
||||||
|
|
||||||
// Disable blending by default
|
// Disable blending by default
|
||||||
state.blendEnabled = GL_FALSE;
|
state.blend_enabled = GL_FALSE;
|
||||||
state.blendFunc = GL_FUNC_ADD;
|
state.blend_func = GL_FUNC_ADD;
|
||||||
state.blendSrc = GL_ONE;
|
state.blend_src = GL_ONE;
|
||||||
state.blendDst = GL_ZERO;
|
state.blend_dst = GL_ZERO;
|
||||||
|
|
||||||
// Enable culling by default and cull back faces
|
// Enable culling by default and cull back faces
|
||||||
state.cullFaceEnabled = GL_TRUE;
|
state.cull_face_enabled = GL_TRUE;
|
||||||
state.cullFaceMode = GL_BACK;
|
state.cull_face_mode = GL_BACK;
|
||||||
|
|
||||||
// Disable stencil test by default
|
// Disable stencil test by default
|
||||||
state.stencilTestEnabled = GL_FALSE;
|
state.stencil_test_enabled = GL_FALSE;
|
||||||
state.stencilFunc = GL_ALWAYS;
|
state.stencil_func = GL_ALWAYS;
|
||||||
state.stencilRef = 0;
|
state.stencil_ref = 0;
|
||||||
state.stencilMask = 0xFFFFFFFF;
|
state.stencil_mask = 0xFFFFFFFF;
|
||||||
|
|
||||||
// Set default front face to counter-clockwise
|
// Set default front face to counter-clockwise
|
||||||
state.frontFace = GL_CCW;
|
state.front_face = GL_CCW;
|
||||||
|
|
||||||
// Set default line width
|
// Set default line width
|
||||||
state.smoothLineEnabled = GL_FALSE;
|
state.smooth_line_enabled = GL_FALSE;
|
||||||
state.lineWidth = 1.0f;
|
state.line_width = 1.0f;
|
||||||
|
|
||||||
// Set default point size
|
// Set default point size
|
||||||
state.pointSizeEnabled = GL_FALSE;
|
state.point_size_enabled = GL_FALSE;
|
||||||
state.pointSize = 1.0f;
|
state.point_size = 1.0f;
|
||||||
|
|
||||||
// Set default polygon mode to fill
|
// Set default polygon mode to fill
|
||||||
state.polygonModeFace = GL_FRONT_AND_BACK;
|
state.polygon_mode_face = GL_FRONT_AND_BACK;
|
||||||
state.polygonModeMode = GL_FILL;
|
state.polygon_mode_mode = GL_FILL;
|
||||||
|
|
||||||
// Disable scissor test by default
|
// Disable scissor test by default
|
||||||
state.scissorTestEnabled = GL_FALSE;
|
state.scissor_test_enabled = GL_FALSE;
|
||||||
state.scissorBox[0] = 0;
|
state.scissor_box[0] = 0;
|
||||||
state.scissorBox[1] = 0;
|
state.scissor_box[1] = 0;
|
||||||
state.scissorBox[2] = window_width();
|
state.scissor_box[2] = window_width();
|
||||||
state.scissorBox[3] = window_height();
|
state.scissor_box[3] = window_height();
|
||||||
|
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
@ -17290,75 +17290,75 @@ bool renderstate_compare(const renderstate_t *stateA, const renderstate_t *state
|
||||||
void renderstate_apply(const renderstate_t *state) {
|
void renderstate_apply(const renderstate_t *state) {
|
||||||
if (state != NULL) {
|
if (state != NULL) {
|
||||||
// Apply viewport parameters
|
// Apply viewport parameters
|
||||||
glViewport(state->viewportX, state->viewportY, state->viewportWidth, state->viewportHeight);
|
glViewport(state->viewport_x, state->viewport_y, state->viewport_width, state->viewport_height);
|
||||||
|
|
||||||
// Apply clear color
|
// Apply clear color
|
||||||
glClearColor(state->clearColor[0], state->clearColor[1], state->clearColor[2], state->clearColor[3]);
|
glClearColor(state->clear_color[0], state->clear_color[1], state->clear_color[2], state->clear_color[3]);
|
||||||
|
|
||||||
// Apply clear depth
|
// Apply clear depth
|
||||||
glClearDepth(state->clearDepth);
|
glClearDepth(state->clear_depth);
|
||||||
|
|
||||||
// Apply depth test
|
// Apply depth test
|
||||||
if (state->depthTestEnabled) {
|
if (state->depth_test_enabled) {
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
glDepthFunc(state->depthFunc);
|
glDepthFunc(state->depth_func);
|
||||||
} else {
|
} else {
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply blending
|
// Apply blending
|
||||||
if (state->blendEnabled) {
|
if (state->blend_enabled) {
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendEquation(state->blendFunc);
|
glBlendEquation(state->blend_func);
|
||||||
glBlendFunc(state->blendSrc, state->blendDst);
|
glBlendFunc(state->blend_src, state->blend_dst);
|
||||||
} else {
|
} else {
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply culling @fixme
|
// Apply culling @fixme
|
||||||
// if (state->cullFaceEnabled) {
|
// if (state->cull_face_enabled) {
|
||||||
// glEnable(GL_CULL_FACE);
|
// glEnable(GL_CULL_FACE);
|
||||||
// glCullFace(state->cullFaceMode);
|
// glCullFace(state->cull_face_mode);
|
||||||
// } else {
|
// } else {
|
||||||
// glDisable(GL_CULL_FACE);
|
// glDisable(GL_CULL_FACE);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// Apply stencil test
|
// Apply stencil test
|
||||||
if (state->stencilTestEnabled) {
|
if (state->stencil_test_enabled) {
|
||||||
glEnable(GL_STENCIL_TEST);
|
glEnable(GL_STENCIL_TEST);
|
||||||
glStencilFunc(state->stencilFunc, state->stencilRef, state->stencilMask);
|
glStencilFunc(state->stencil_func, state->stencil_ref, state->stencil_mask);
|
||||||
} else {
|
} else {
|
||||||
glDisable(GL_STENCIL_TEST);
|
glDisable(GL_STENCIL_TEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply front face direction @fixme
|
// Apply front face direction @fixme
|
||||||
// glFrontFace(state->frontFace);
|
// glFrontFace(state->front_face);
|
||||||
|
|
||||||
// Apply line width
|
// Apply line width
|
||||||
glLineWidth(state->lineWidth);
|
glLineWidth(state->line_width);
|
||||||
|
|
||||||
// apply smooth lines
|
// Apply smooth lines
|
||||||
if (state->smoothLineEnabled) {
|
if (state->smooth_line_enabled) {
|
||||||
glEnable(GL_LINE_SMOOTH);
|
glEnable(GL_LINE_SMOOTH);
|
||||||
} else {
|
} else {
|
||||||
glDisable(GL_LINE_SMOOTH);
|
glDisable(GL_LINE_SMOOTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply point size
|
// Apply point size
|
||||||
if (state->pointSizeEnabled) {
|
if (state->point_size_enabled) {
|
||||||
glEnable(GL_PROGRAM_POINT_SIZE);
|
glEnable(GL_PROGRAM_POINT_SIZE);
|
||||||
glPointSize(state->pointSize);
|
glPointSize(state->point_size);
|
||||||
} else {
|
} else {
|
||||||
glDisable(GL_PROGRAM_POINT_SIZE);
|
glDisable(GL_PROGRAM_POINT_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply polygon mode
|
// Apply polygon mode
|
||||||
glPolygonMode(state->polygonModeFace, state->polygonModeMode);
|
glPolygonMode(state->polygon_mode_face, state->polygon_mode_mode);
|
||||||
|
|
||||||
// Apply scissor test
|
// Apply scissor test
|
||||||
if (state->scissorTestEnabled) {
|
if (state->scissor_test_enabled) {
|
||||||
glEnable(GL_SCISSOR_TEST);
|
glEnable(GL_SCISSOR_TEST);
|
||||||
glScissor(state->scissorBox[0], state->scissorBox[1], state->scissorBox[2], state->scissorBox[3]);
|
glScissor(state->scissor_box[0], state->scissor_box[1], state->scissor_box[2], state->scissor_box[3]);
|
||||||
} else {
|
} else {
|
||||||
glDisable(GL_SCISSOR_TEST);
|
glDisable(GL_SCISSOR_TEST);
|
||||||
}
|
}
|
||||||
|
@ -19180,10 +19180,10 @@ int skybox_push_state(skybox_t *sky, mat44 proj, mat44 view) {
|
||||||
|
|
||||||
// we have to reset clear color here, because of wrong alpha compositing issues on native transparent windows otherwise
|
// we have to reset clear color here, because of wrong alpha compositing issues on native transparent windows otherwise
|
||||||
vec4 bgcolor = window_getcolor_();
|
vec4 bgcolor = window_getcolor_();
|
||||||
skybox_rs.clearColor[0] = bgcolor.r;
|
skybox_rs.clear_color[0] = bgcolor.r;
|
||||||
skybox_rs.clearColor[1] = bgcolor.g;
|
skybox_rs.clear_color[1] = bgcolor.g;
|
||||||
skybox_rs.clearColor[2] = bgcolor.b;
|
skybox_rs.clear_color[2] = bgcolor.b;
|
||||||
skybox_rs.clearColor[3] = 1; // @transparent
|
skybox_rs.clear_color[3] = 1; // @transparent
|
||||||
|
|
||||||
mat44 mvp; multiply44x2(mvp, proj, view);
|
mat44 mvp; multiply44x2(mvp, proj, view);
|
||||||
|
|
||||||
|
@ -20865,7 +20865,7 @@ model_t model_from_mem(const void *mem, int len, int flags) {
|
||||||
|
|
||||||
{
|
{
|
||||||
m.rs = renderstate();
|
m.rs = renderstate();
|
||||||
m.rs.blendEnabled = 1;
|
m.rs.blend_enabled = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
m.stored_flags = flags;
|
m.stored_flags = flags;
|
||||||
|
@ -21487,7 +21487,7 @@ void ddraw_flush() {
|
||||||
void ddraw_flush_projview(mat44 proj, mat44 view) {
|
void ddraw_flush_projview(mat44 proj, mat44 view) {
|
||||||
do_once dd_rs = renderstate();
|
do_once dd_rs = renderstate();
|
||||||
|
|
||||||
dd_rs.depthTestEnabled = 1;
|
dd_rs.depth_test_enabled = 1;
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
|
||||||
mat44 mvp;
|
mat44 mvp;
|
||||||
|
@ -21502,12 +21502,12 @@ void ddraw_flush_projview(mat44 proj, mat44 view) {
|
||||||
|
|
||||||
glEnableVertexAttribArray(0);
|
glEnableVertexAttribArray(0);
|
||||||
|
|
||||||
dd_rs.pointSizeEnabled = 1;
|
dd_rs.point_size_enabled = 1;
|
||||||
dd_rs.smoothLineEnabled = 1;
|
dd_rs.smooth_line_enabled = 1;
|
||||||
|
|
||||||
for( int i = 0; i < 3; ++i ) { // [0] thin, [1] thick, [2] points
|
for( int i = 0; i < 3; ++i ) { // [0] thin, [1] thick, [2] points
|
||||||
GLenum mode = i < 2 ? GL_LINES : GL_POINTS;
|
GLenum mode = i < 2 ? GL_LINES : GL_POINTS;
|
||||||
dd_rs.lineWidth = (i == 1 ? 1 : 0.3); // 0.625);
|
dd_rs.line_width = (i == 1 ? 1 : 0.3); // 0.625);
|
||||||
for each_map(dd_lists[dd_ontop][i], unsigned, rgb, array(vec3), list) {
|
for each_map(dd_lists[dd_ontop][i], unsigned, rgb, array(vec3), list) {
|
||||||
int count = array_count(list);
|
int count = array_count(list);
|
||||||
if(!count) continue;
|
if(!count) continue;
|
||||||
|
@ -21540,7 +21540,7 @@ void ddraw_flush_projview(mat44 proj, mat44 view) {
|
||||||
glUniformMatrix4fv(glGetUniformLocation(dd_program, "u_MVP"), 1, GL_FALSE, mvp);
|
glUniformMatrix4fv(glGetUniformLocation(dd_program, "u_MVP"), 1, GL_FALSE, mvp);
|
||||||
for( int i = 0; i < 3; ++i ) { // [0] thin, [1] thick, [2] points
|
for( int i = 0; i < 3; ++i ) { // [0] thin, [1] thick, [2] points
|
||||||
GLenum mode = i < 2 ? GL_LINES : GL_POINTS;
|
GLenum mode = i < 2 ? GL_LINES : GL_POINTS;
|
||||||
dd_rs.lineWidth = (i == 1 ? 1 : 0.3); // 0.625);
|
dd_rs.line_width = (i == 1 ? 1 : 0.3); // 0.625);
|
||||||
for each_map(dd_lists[dd_ontop][i], unsigned, rgb, array(vec3), list) {
|
for each_map(dd_lists[dd_ontop][i], unsigned, rgb, array(vec3), list) {
|
||||||
int count = array_count(list);
|
int count = array_count(list);
|
||||||
if(!count) continue;
|
if(!count) continue;
|
||||||
|
@ -26843,14 +26843,14 @@ static renderstate_t window_rs;
|
||||||
void glNewFrame() {
|
void glNewFrame() {
|
||||||
do_once {
|
do_once {
|
||||||
window_rs = renderstate();
|
window_rs = renderstate();
|
||||||
window_rs.blendEnabled = 1;
|
window_rs.blend_enabled = 1;
|
||||||
window_rs.depthTestEnabled = 1;
|
window_rs.depth_test_enabled = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
window_rs.clearColor[0] = winbgcolor.r;
|
window_rs.clear_color[0] = winbgcolor.r;
|
||||||
window_rs.clearColor[1] = winbgcolor.g;
|
window_rs.clear_color[1] = winbgcolor.g;
|
||||||
window_rs.clearColor[2] = winbgcolor.b;
|
window_rs.clear_color[2] = winbgcolor.b;
|
||||||
window_rs.clearColor[3] = window_has_transparent() ? 0 : winbgcolor.a;
|
window_rs.clear_color[3] = window_has_transparent() ? 0 : winbgcolor.a;
|
||||||
|
|
||||||
// @transparent debug
|
// @transparent debug
|
||||||
// if( input_down(KEY_F1) ) window_transparent(window_has_transparent()^1);
|
// if( input_down(KEY_F1) ) window_transparent(window_has_transparent()^1);
|
||||||
|
|
54
engine/v4k.h
54
engine/v4k.h
|
@ -3101,55 +3101,55 @@ typedef unsigned handle; // GLuint
|
||||||
// renderstate
|
// renderstate
|
||||||
typedef struct renderstate_t {
|
typedef struct renderstate_t {
|
||||||
// Viewport parameters
|
// Viewport parameters
|
||||||
int viewportX;
|
int viewport_x;
|
||||||
int viewportY;
|
int viewport_y;
|
||||||
int viewportWidth;
|
int viewport_width;
|
||||||
int viewportHeight;
|
int viewport_height;
|
||||||
|
|
||||||
// Clear color
|
// Clear color
|
||||||
float clearColor[4];
|
float clear_color[4];
|
||||||
|
|
||||||
// Clear depth
|
// Clear depth
|
||||||
double clearDepth;
|
double clear_depth;
|
||||||
|
|
||||||
// Depth test
|
// Depth test
|
||||||
bool depthTestEnabled;
|
bool depth_test_enabled;
|
||||||
unsigned depthFunc;
|
unsigned depth_func;
|
||||||
|
|
||||||
// Blending
|
// Blending
|
||||||
bool blendEnabled;
|
bool blend_enabled;
|
||||||
unsigned blendFunc;
|
unsigned blend_func;
|
||||||
unsigned blendSrc;
|
unsigned blend_src;
|
||||||
unsigned blendDst;
|
unsigned blend_dst;
|
||||||
|
|
||||||
// Culling
|
// Culling
|
||||||
bool cullFaceEnabled;
|
bool cull_face_enabled;
|
||||||
unsigned cullFaceMode;
|
unsigned cull_face_mode;
|
||||||
|
|
||||||
// Stencil test
|
// Stencil test
|
||||||
bool stencilTestEnabled;
|
bool stencil_test_enabled;
|
||||||
unsigned stencilFunc;
|
unsigned stencil_func;
|
||||||
int stencilRef;
|
int stencil_ref;
|
||||||
unsigned stencilMask;
|
unsigned stencil_mask;
|
||||||
|
|
||||||
// Face culling direction
|
// Face culling direction
|
||||||
unsigned frontFace; // GL_CW or GL_CCW
|
unsigned front_face; // GL_CW or GL_CCW
|
||||||
|
|
||||||
// Line width
|
// Line width
|
||||||
bool smoothLineEnabled;
|
bool smooth_line_enabled;
|
||||||
float lineWidth;
|
float line_width;
|
||||||
|
|
||||||
// Point size
|
// Point size
|
||||||
bool pointSizeEnabled;
|
bool point_size_enabled;
|
||||||
float pointSize;
|
float point_size;
|
||||||
|
|
||||||
// Polygon mode
|
// Polygon mode
|
||||||
unsigned polygonModeFace;
|
unsigned polygon_mode_face;
|
||||||
unsigned polygonModeMode;
|
unsigned polygon_mode_mode;
|
||||||
|
|
||||||
// Scissor test
|
// Scissor test
|
||||||
bool scissorTestEnabled;
|
bool scissor_test_enabled;
|
||||||
int scissorBox[4];
|
int scissor_box[4];
|
||||||
} renderstate_t;
|
} renderstate_t;
|
||||||
|
|
||||||
API renderstate_t renderstate();
|
API renderstate_t renderstate();
|
||||||
|
|
Loading…
Reference in New Issue