snake_case renderstate_t

main
Dominik Madarász 2024-04-11 00:42:53 +02:00
parent 1c19c44400
commit 99111665ba
9 changed files with 351 additions and 351 deletions

View File

@ -1033,33 +1033,33 @@ typedef struct reflect_t {
int ui_reflect(const char *mask);
typedef unsigned handle;
typedef struct renderstate_t {
int viewportX;
int viewportY;
int viewportWidth;
int viewportHeight;
float clearColor[4];
double clearDepth;
bool depthTestEnabled;
unsigned depthFunc;
bool blendEnabled;
unsigned blendFunc;
unsigned blendSrc;
unsigned blendDst;
bool cullFaceEnabled;
unsigned cullFaceMode;
bool stencilTestEnabled;
unsigned stencilFunc;
int stencilRef;
unsigned stencilMask;
unsigned frontFace;
bool smoothLineEnabled;
float lineWidth;
bool pointSizeEnabled;
float pointSize;
unsigned polygonModeFace;
unsigned polygonModeMode;
bool scissorTestEnabled;
int scissorBox[4];
int viewport_x;
int viewport_y;
int viewport_width;
int viewport_height;
float clear_color[4];
double clear_depth;
bool depth_test_enabled;
unsigned depth_func;
bool blend_enabled;
unsigned blend_func;
unsigned blend_src;
unsigned blend_dst;
bool cull_face_enabled;
unsigned cull_face_mode;
bool stencil_test_enabled;
unsigned stencil_func;
int stencil_ref;
unsigned stencil_mask;
unsigned front_face;
bool smooth_line_enabled;
float line_width;
bool point_size_enabled;
float point_size;
unsigned polygon_mode_face;
unsigned polygon_mode_mode;
bool scissor_test_enabled;
int scissor_box[4];
} renderstate_t;
renderstate_t renderstate();
bool renderstate_compare(const renderstate_t *stateA, const renderstate_t *stateB);

View File

@ -17034,55 +17034,55 @@ typedef unsigned handle; // GLuint
// renderstate
typedef struct renderstate_t {
// Viewport parameters
int viewportX;
int viewportY;
int viewportWidth;
int viewportHeight;
int viewport_x;
int viewport_y;
int viewport_width;
int viewport_height;
// Clear color
float clearColor[4];
float clear_color[4];
// Clear depth
double clearDepth;
double clear_depth;
// Depth test
bool depthTestEnabled;
unsigned depthFunc;
bool depth_test_enabled;
unsigned depth_func;
// Blending
bool blendEnabled;
unsigned blendFunc;
unsigned blendSrc;
unsigned blendDst;
bool blend_enabled;
unsigned blend_func;
unsigned blend_src;
unsigned blend_dst;
// Culling
bool cullFaceEnabled;
unsigned cullFaceMode;
bool cull_face_enabled;
unsigned cull_face_mode;
// Stencil test
bool stencilTestEnabled;
unsigned stencilFunc;
int stencilRef;
unsigned stencilMask;
bool stencil_test_enabled;
unsigned stencil_func;
int stencil_ref;
unsigned stencil_mask;
// Face culling direction
unsigned frontFace; // GL_CW or GL_CCW
unsigned front_face; // GL_CW or GL_CCW
// Line width
bool smoothLineEnabled;
float lineWidth;
bool smooth_line_enabled;
float line_width;
// Point size
bool pointSizeEnabled;
float pointSize;
bool point_size_enabled;
float point_size;
// Polygon mode
unsigned polygonModeFace;
unsigned polygonModeMode;
unsigned polygon_mode_face;
unsigned polygon_mode_mode;
// Scissor test
bool scissorTestEnabled;
int scissorBox[4];
bool scissor_test_enabled;
int scissor_box[4];
} renderstate_t;
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
f->rs = renderstate();
f->rs.blendEnabled = 1;
f->rs.blendFunc = GL_FUNC_ADD;
f->rs.blendSrc = GL_SRC_ALPHA;
f->rs.blendDst = GL_ONE_MINUS_SRC_ALPHA;
f->rs.scissorTestEnabled = 1;
f->rs.depthTestEnabled = 0;
f->rs.cullFaceEnabled = 0;
f->rs.blend_enabled = 1;
f->rs.blend_func = GL_FUNC_ADD;
f->rs.blend_src = GL_SRC_ALPHA;
f->rs.blend_dst = GL_ONE_MINUS_SRC_ALPHA;
f->rs.scissor_test_enabled = 1;
f->rs.depth_test_enabled = 0;
f->rs.cull_face_enabled = 0;
}
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);
glGetIntegerv(GL_TEXTURE_BINDING_1D, &last_texture2);
f->rs.scissorBox[0] = rect.x;
f->rs.scissorBox[1] = window_height() - (rect.y+rect.w);
f->rs.scissorBox[2] = rect.z;
f->rs.scissorBox[3] = rect.w;
f->rs.scissor_box[0] = rect.x;
f->rs.scissor_box[1] = window_height() - (rect.y+rect.w);
f->rs.scissor_box[2] = rect.z;
f->rs.scissor_box[3] = rect.w;
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, f->texture_fontdata);
@ -370132,61 +370132,61 @@ renderstate_t renderstate() {
renderstate_t state = {0};
// Set default viewport parameters
state.viewportX = 0;
state.viewportY = 0;
state.viewportWidth = window_width();
state.viewportHeight = window_height();
state.viewport_x = 0;
state.viewport_y = 0;
state.viewport_width = window_width();
state.viewport_height = window_height();
// Set default clear color to black
state.clearColor[0] = 0.0f; // Red
state.clearColor[1] = 0.0f; // Green
state.clearColor[2] = 0.0f; // Blue
state.clearColor[3] = 1.0f; // Alpha
state.clear_color[0] = 0.0f; // Red
state.clear_color[1] = 0.0f; // Green
state.clear_color[2] = 0.0f; // Blue
state.clear_color[3] = 1.0f; // Alpha
// 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
state.depthTestEnabled = GL_TRUE;
state.depthFunc = GL_LEQUAL;
state.depth_test_enabled = GL_TRUE;
state.depth_func = GL_LEQUAL;
// Disable blending by default
state.blendEnabled = GL_FALSE;
state.blendFunc = GL_FUNC_ADD;
state.blendSrc = GL_ONE;
state.blendDst = GL_ZERO;
state.blend_enabled = GL_FALSE;
state.blend_func = GL_FUNC_ADD;
state.blend_src = GL_ONE;
state.blend_dst = GL_ZERO;
// Enable culling by default and cull back faces
state.cullFaceEnabled = GL_TRUE;
state.cullFaceMode = GL_BACK;
state.cull_face_enabled = GL_TRUE;
state.cull_face_mode = GL_BACK;
// Disable stencil test by default
state.stencilTestEnabled = GL_FALSE;
state.stencilFunc = GL_ALWAYS;
state.stencilRef = 0;
state.stencilMask = 0xFFFFFFFF;
state.stencil_test_enabled = GL_FALSE;
state.stencil_func = GL_ALWAYS;
state.stencil_ref = 0;
state.stencil_mask = 0xFFFFFFFF;
// Set default front face to counter-clockwise
state.frontFace = GL_CCW;
state.front_face = GL_CCW;
// Set default line width
state.smoothLineEnabled = GL_FALSE;
state.lineWidth = 1.0f;
state.smooth_line_enabled = GL_FALSE;
state.line_width = 1.0f;
// Set default point size
state.pointSizeEnabled = GL_FALSE;
state.pointSize = 1.0f;
state.point_size_enabled = GL_FALSE;
state.point_size = 1.0f;
// Set default polygon mode to fill
state.polygonModeFace = GL_FRONT_AND_BACK;
state.polygonModeMode = GL_FILL;
state.polygon_mode_face = GL_FRONT_AND_BACK;
state.polygon_mode_mode = GL_FILL;
// Disable scissor test by default
state.scissorTestEnabled = GL_FALSE;
state.scissorBox[0] = 0;
state.scissorBox[1] = 0;
state.scissorBox[2] = window_width();
state.scissorBox[3] = window_height();
state.scissor_test_enabled = GL_FALSE;
state.scissor_box[0] = 0;
state.scissor_box[1] = 0;
state.scissor_box[2] = window_width();
state.scissor_box[3] = window_height();
return state;
}
@ -370198,75 +370198,75 @@ bool renderstate_compare(const renderstate_t *stateA, const renderstate_t *state
void renderstate_apply(const renderstate_t *state) {
if (state != NULL) {
// 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
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
glClearDepth(state->clearDepth);
glClearDepth(state->clear_depth);
// Apply depth test
if (state->depthTestEnabled) {
if (state->depth_test_enabled) {
glEnable(GL_DEPTH_TEST);
glDepthFunc(state->depthFunc);
glDepthFunc(state->depth_func);
} else {
glDisable(GL_DEPTH_TEST);
}
// Apply blending
if (state->blendEnabled) {
if (state->blend_enabled) {
glEnable(GL_BLEND);
glBlendEquation(state->blendFunc);
glBlendFunc(state->blendSrc, state->blendDst);
glBlendEquation(state->blend_func);
glBlendFunc(state->blend_src, state->blend_dst);
} else {
glDisable(GL_BLEND);
}
// Apply culling @fixme
// if (state->cullFaceEnabled) {
// if (state->cull_face_enabled) {
// glEnable(GL_CULL_FACE);
// glCullFace(state->cullFaceMode);
// glCullFace(state->cull_face_mode);
// } else {
// glDisable(GL_CULL_FACE);
// }
// Apply stencil test
if (state->stencilTestEnabled) {
if (state->stencil_test_enabled) {
glEnable(GL_STENCIL_TEST);
glStencilFunc(state->stencilFunc, state->stencilRef, state->stencilMask);
glStencilFunc(state->stencil_func, state->stencil_ref, state->stencil_mask);
} else {
glDisable(GL_STENCIL_TEST);
}
// Apply front face direction @fixme
// glFrontFace(state->frontFace);
// glFrontFace(state->front_face);
// Apply line width
glLineWidth(state->lineWidth);
glLineWidth(state->line_width);
// apply smooth lines
if (state->smoothLineEnabled) {
// Apply smooth lines
if (state->smooth_line_enabled) {
glEnable(GL_LINE_SMOOTH);
} else {
glDisable(GL_LINE_SMOOTH);
}
// Apply point size
if (state->pointSizeEnabled) {
if (state->point_size_enabled) {
glEnable(GL_PROGRAM_POINT_SIZE);
glPointSize(state->pointSize);
glPointSize(state->point_size);
} else {
glDisable(GL_PROGRAM_POINT_SIZE);
}
// Apply polygon mode
glPolygonMode(state->polygonModeFace, state->polygonModeMode);
glPolygonMode(state->polygon_mode_face, state->polygon_mode_mode);
// Apply scissor test
if (state->scissorTestEnabled) {
if (state->scissor_test_enabled) {
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 {
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
vec4 bgcolor = window_getcolor_();
skybox_rs.clearColor[0] = bgcolor.r;
skybox_rs.clearColor[1] = bgcolor.g;
skybox_rs.clearColor[2] = bgcolor.b;
skybox_rs.clearColor[3] = 1; // @transparent
skybox_rs.clear_color[0] = bgcolor.r;
skybox_rs.clear_color[1] = bgcolor.g;
skybox_rs.clear_color[2] = bgcolor.b;
skybox_rs.clear_color[3] = 1; // @transparent
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.blendEnabled = 1;
m.rs.blend_enabled = 1;
}
m.stored_flags = flags;
@ -374395,7 +374395,7 @@ void ddraw_flush() {
void ddraw_flush_projview(mat44 proj, mat44 view) {
do_once dd_rs = renderstate();
dd_rs.depthTestEnabled = 1;
dd_rs.depth_test_enabled = 1;
glActiveTexture(GL_TEXTURE0);
mat44 mvp;
@ -374410,12 +374410,12 @@ void ddraw_flush_projview(mat44 proj, mat44 view) {
glEnableVertexAttribArray(0);
dd_rs.pointSizeEnabled = 1;
dd_rs.smoothLineEnabled = 1;
dd_rs.point_size_enabled = 1;
dd_rs.smooth_line_enabled = 1;
for( int i = 0; i < 3; ++i ) { // [0] thin, [1] thick, [2] 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) {
int count = array_count(list);
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);
for( int i = 0; i < 3; ++i ) { // [0] thin, [1] thick, [2] 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) {
int count = array_count(list);
if(!count) continue;
@ -379751,14 +379751,14 @@ static renderstate_t window_rs;
void glNewFrame() {
do_once {
window_rs = renderstate();
window_rs.blendEnabled = 1;
window_rs.depthTestEnabled = 1;
window_rs.blend_enabled = 1;
window_rs.depth_test_enabled = 1;
}
window_rs.clearColor[0] = winbgcolor.r;
window_rs.clearColor[1] = winbgcolor.g;
window_rs.clearColor[2] = winbgcolor.b;
window_rs.clearColor[3] = window_has_transparent() ? 0 : winbgcolor.a;
window_rs.clear_color[0] = winbgcolor.r;
window_rs.clear_color[1] = winbgcolor.g;
window_rs.clear_color[2] = winbgcolor.b;
window_rs.clear_color[3] = window_has_transparent() ? 0 : winbgcolor.a;
// @transparent debug
// if( input_down(KEY_F1) ) window_transparent(window_has_transparent()^1);

View File

@ -1898,13 +1898,13 @@ void font_face_from_mem(const char *tag, const void *ttf_data, unsigned ttf_len,
// set up pipeline
f->rs = renderstate();
f->rs.blendEnabled = 1;
f->rs.blendFunc = GL_FUNC_ADD;
f->rs.blendSrc = GL_SRC_ALPHA;
f->rs.blendDst = GL_ONE_MINUS_SRC_ALPHA;
f->rs.scissorTestEnabled = 1;
f->rs.depthTestEnabled = 0;
f->rs.cullFaceEnabled = 0;
f->rs.blend_enabled = 1;
f->rs.blend_func = GL_FUNC_ADD;
f->rs.blend_src = GL_SRC_ALPHA;
f->rs.blend_dst = GL_ONE_MINUS_SRC_ALPHA;
f->rs.scissor_test_enabled = 1;
f->rs.depth_test_enabled = 0;
f->rs.cull_face_enabled = 0;
}
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);
glGetIntegerv(GL_TEXTURE_BINDING_1D, &last_texture2);
f->rs.scissorBox[0] = rect.x;
f->rs.scissorBox[1] = window_height() - (rect.y+rect.w);
f->rs.scissorBox[2] = rect.z;
f->rs.scissorBox[3] = rect.w;
f->rs.scissor_box[0] = rect.x;
f->rs.scissor_box[1] = window_height() - (rect.y+rect.w);
f->rs.scissor_box[2] = rect.z;
f->rs.scissor_box[3] = rect.w;
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, f->texture_fontdata);

View File

@ -57,61 +57,61 @@ renderstate_t renderstate() {
renderstate_t state = {0};
// Set default viewport parameters
state.viewportX = 0;
state.viewportY = 0;
state.viewportWidth = window_width();
state.viewportHeight = window_height();
state.viewport_x = 0;
state.viewport_y = 0;
state.viewport_width = window_width();
state.viewport_height = window_height();
// Set default clear color to black
state.clearColor[0] = 0.0f; // Red
state.clearColor[1] = 0.0f; // Green
state.clearColor[2] = 0.0f; // Blue
state.clearColor[3] = 1.0f; // Alpha
state.clear_color[0] = 0.0f; // Red
state.clear_color[1] = 0.0f; // Green
state.clear_color[2] = 0.0f; // Blue
state.clear_color[3] = 1.0f; // Alpha
// 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
state.depthTestEnabled = GL_TRUE;
state.depthFunc = GL_LEQUAL;
state.depth_test_enabled = GL_TRUE;
state.depth_func = GL_LEQUAL;
// Disable blending by default
state.blendEnabled = GL_FALSE;
state.blendFunc = GL_FUNC_ADD;
state.blendSrc = GL_ONE;
state.blendDst = GL_ZERO;
state.blend_enabled = GL_FALSE;
state.blend_func = GL_FUNC_ADD;
state.blend_src = GL_ONE;
state.blend_dst = GL_ZERO;
// Enable culling by default and cull back faces
state.cullFaceEnabled = GL_TRUE;
state.cullFaceMode = GL_BACK;
state.cull_face_enabled = GL_TRUE;
state.cull_face_mode = GL_BACK;
// Disable stencil test by default
state.stencilTestEnabled = GL_FALSE;
state.stencilFunc = GL_ALWAYS;
state.stencilRef = 0;
state.stencilMask = 0xFFFFFFFF;
state.stencil_test_enabled = GL_FALSE;
state.stencil_func = GL_ALWAYS;
state.stencil_ref = 0;
state.stencil_mask = 0xFFFFFFFF;
// Set default front face to counter-clockwise
state.frontFace = GL_CCW;
state.front_face = GL_CCW;
// Set default line width
state.smoothLineEnabled = GL_FALSE;
state.lineWidth = 1.0f;
state.smooth_line_enabled = GL_FALSE;
state.line_width = 1.0f;
// Set default point size
state.pointSizeEnabled = GL_FALSE;
state.pointSize = 1.0f;
state.point_size_enabled = GL_FALSE;
state.point_size = 1.0f;
// Set default polygon mode to fill
state.polygonModeFace = GL_FRONT_AND_BACK;
state.polygonModeMode = GL_FILL;
state.polygon_mode_face = GL_FRONT_AND_BACK;
state.polygon_mode_mode = GL_FILL;
// Disable scissor test by default
state.scissorTestEnabled = GL_FALSE;
state.scissorBox[0] = 0;
state.scissorBox[1] = 0;
state.scissorBox[2] = window_width();
state.scissorBox[3] = window_height();
state.scissor_test_enabled = GL_FALSE;
state.scissor_box[0] = 0;
state.scissor_box[1] = 0;
state.scissor_box[2] = window_width();
state.scissor_box[3] = window_height();
return state;
}
@ -123,75 +123,75 @@ bool renderstate_compare(const renderstate_t *stateA, const renderstate_t *state
void renderstate_apply(const renderstate_t *state) {
if (state != NULL) {
// 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
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
glClearDepth(state->clearDepth);
glClearDepth(state->clear_depth);
// Apply depth test
if (state->depthTestEnabled) {
if (state->depth_test_enabled) {
glEnable(GL_DEPTH_TEST);
glDepthFunc(state->depthFunc);
glDepthFunc(state->depth_func);
} else {
glDisable(GL_DEPTH_TEST);
}
// Apply blending
if (state->blendEnabled) {
if (state->blend_enabled) {
glEnable(GL_BLEND);
glBlendEquation(state->blendFunc);
glBlendFunc(state->blendSrc, state->blendDst);
glBlendEquation(state->blend_func);
glBlendFunc(state->blend_src, state->blend_dst);
} else {
glDisable(GL_BLEND);
}
// Apply culling @fixme
// if (state->cullFaceEnabled) {
// if (state->cull_face_enabled) {
// glEnable(GL_CULL_FACE);
// glCullFace(state->cullFaceMode);
// glCullFace(state->cull_face_mode);
// } else {
// glDisable(GL_CULL_FACE);
// }
// Apply stencil test
if (state->stencilTestEnabled) {
if (state->stencil_test_enabled) {
glEnable(GL_STENCIL_TEST);
glStencilFunc(state->stencilFunc, state->stencilRef, state->stencilMask);
glStencilFunc(state->stencil_func, state->stencil_ref, state->stencil_mask);
} else {
glDisable(GL_STENCIL_TEST);
}
// Apply front face direction @fixme
// glFrontFace(state->frontFace);
// glFrontFace(state->front_face);
// Apply line width
glLineWidth(state->lineWidth);
glLineWidth(state->line_width);
// apply smooth lines
if (state->smoothLineEnabled) {
// Apply smooth lines
if (state->smooth_line_enabled) {
glEnable(GL_LINE_SMOOTH);
} else {
glDisable(GL_LINE_SMOOTH);
}
// Apply point size
if (state->pointSizeEnabled) {
if (state->point_size_enabled) {
glEnable(GL_PROGRAM_POINT_SIZE);
glPointSize(state->pointSize);
glPointSize(state->point_size);
} else {
glDisable(GL_PROGRAM_POINT_SIZE);
}
// Apply polygon mode
glPolygonMode(state->polygonModeFace, state->polygonModeMode);
glPolygonMode(state->polygon_mode_face, state->polygon_mode_mode);
// Apply scissor test
if (state->scissorTestEnabled) {
if (state->scissor_test_enabled) {
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 {
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
vec4 bgcolor = window_getcolor_();
skybox_rs.clearColor[0] = bgcolor.r;
skybox_rs.clearColor[1] = bgcolor.g;
skybox_rs.clearColor[2] = bgcolor.b;
skybox_rs.clearColor[3] = 1; // @transparent
skybox_rs.clear_color[0] = bgcolor.r;
skybox_rs.clear_color[1] = bgcolor.g;
skybox_rs.clear_color[2] = bgcolor.b;
skybox_rs.clear_color[3] = 1; // @transparent
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.blendEnabled = 1;
m.rs.blend_enabled = 1;
}
m.stored_flags = flags;

View File

@ -12,55 +12,55 @@ typedef unsigned handle; // GLuint
// renderstate
typedef struct renderstate_t {
// Viewport parameters
int viewportX;
int viewportY;
int viewportWidth;
int viewportHeight;
int viewport_x;
int viewport_y;
int viewport_width;
int viewport_height;
// Clear color
float clearColor[4];
float clear_color[4];
// Clear depth
double clearDepth;
double clear_depth;
// Depth test
bool depthTestEnabled;
unsigned depthFunc;
bool depth_test_enabled;
unsigned depth_func;
// Blending
bool blendEnabled;
unsigned blendFunc;
unsigned blendSrc;
unsigned blendDst;
bool blend_enabled;
unsigned blend_func;
unsigned blend_src;
unsigned blend_dst;
// Culling
bool cullFaceEnabled;
unsigned cullFaceMode;
bool cull_face_enabled;
unsigned cull_face_mode;
// Stencil test
bool stencilTestEnabled;
unsigned stencilFunc;
int stencilRef;
unsigned stencilMask;
bool stencil_test_enabled;
unsigned stencil_func;
int stencil_ref;
unsigned stencil_mask;
// Face culling direction
unsigned frontFace; // GL_CW or GL_CCW
unsigned front_face; // GL_CW or GL_CCW
// Line width
bool smoothLineEnabled;
float lineWidth;
bool smooth_line_enabled;
float line_width;
// Point size
bool pointSizeEnabled;
float pointSize;
bool point_size_enabled;
float point_size;
// Polygon mode
unsigned polygonModeFace;
unsigned polygonModeMode;
unsigned polygon_mode_face;
unsigned polygon_mode_mode;
// Scissor test
bool scissorTestEnabled;
int scissorBox[4];
bool scissor_test_enabled;
int scissor_box[4];
} renderstate_t;
API renderstate_t renderstate();

View File

@ -69,7 +69,7 @@ void ddraw_flush() {
void ddraw_flush_projview(mat44 proj, mat44 view) {
do_once dd_rs = renderstate();
dd_rs.depthTestEnabled = 1;
dd_rs.depth_test_enabled = 1;
glActiveTexture(GL_TEXTURE0);
mat44 mvp;
@ -84,12 +84,12 @@ void ddraw_flush_projview(mat44 proj, mat44 view) {
glEnableVertexAttribArray(0);
dd_rs.pointSizeEnabled = 1;
dd_rs.smoothLineEnabled = 1;
dd_rs.point_size_enabled = 1;
dd_rs.smooth_line_enabled = 1;
for( int i = 0; i < 3; ++i ) { // [0] thin, [1] thick, [2] 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) {
int count = array_count(list);
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);
for( int i = 0; i < 3; ++i ) { // [0] thin, [1] thick, [2] 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) {
int count = array_count(list);
if(!count) continue;

View File

@ -226,14 +226,14 @@ static renderstate_t window_rs;
void glNewFrame() {
do_once {
window_rs = renderstate();
window_rs.blendEnabled = 1;
window_rs.depthTestEnabled = 1;
window_rs.blend_enabled = 1;
window_rs.depth_test_enabled = 1;
}
window_rs.clearColor[0] = winbgcolor.r;
window_rs.clearColor[1] = winbgcolor.g;
window_rs.clearColor[2] = winbgcolor.b;
window_rs.clearColor[3] = window_has_transparent() ? 0 : winbgcolor.a;
window_rs.clear_color[0] = winbgcolor.r;
window_rs.clear_color[1] = winbgcolor.g;
window_rs.clear_color[2] = winbgcolor.b;
window_rs.clear_color[3] = window_has_transparent() ? 0 : winbgcolor.a;
// @transparent debug
// if( input_down(KEY_F1) ) window_transparent(window_has_transparent()^1);

View File

@ -10600,13 +10600,13 @@ void font_face_from_mem(const char *tag, const void *ttf_data, unsigned ttf_len,
// set up pipeline
f->rs = renderstate();
f->rs.blendEnabled = 1;
f->rs.blendFunc = GL_FUNC_ADD;
f->rs.blendSrc = GL_SRC_ALPHA;
f->rs.blendDst = GL_ONE_MINUS_SRC_ALPHA;
f->rs.scissorTestEnabled = 1;
f->rs.depthTestEnabled = 0;
f->rs.cullFaceEnabled = 0;
f->rs.blend_enabled = 1;
f->rs.blend_func = GL_FUNC_ADD;
f->rs.blend_src = GL_SRC_ALPHA;
f->rs.blend_dst = GL_ONE_MINUS_SRC_ALPHA;
f->rs.scissor_test_enabled = 1;
f->rs.depth_test_enabled = 0;
f->rs.cull_face_enabled = 0;
}
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);
glGetIntegerv(GL_TEXTURE_BINDING_1D, &last_texture2);
f->rs.scissorBox[0] = rect.x;
f->rs.scissorBox[1] = window_height() - (rect.y+rect.w);
f->rs.scissorBox[2] = rect.z;
f->rs.scissorBox[3] = rect.w;
f->rs.scissor_box[0] = rect.x;
f->rs.scissor_box[1] = window_height() - (rect.y+rect.w);
f->rs.scissor_box[2] = rect.z;
f->rs.scissor_box[3] = rect.w;
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, f->texture_fontdata);
@ -17224,61 +17224,61 @@ renderstate_t renderstate() {
renderstate_t state = {0};
// Set default viewport parameters
state.viewportX = 0;
state.viewportY = 0;
state.viewportWidth = window_width();
state.viewportHeight = window_height();
state.viewport_x = 0;
state.viewport_y = 0;
state.viewport_width = window_width();
state.viewport_height = window_height();
// Set default clear color to black
state.clearColor[0] = 0.0f; // Red
state.clearColor[1] = 0.0f; // Green
state.clearColor[2] = 0.0f; // Blue
state.clearColor[3] = 1.0f; // Alpha
state.clear_color[0] = 0.0f; // Red
state.clear_color[1] = 0.0f; // Green
state.clear_color[2] = 0.0f; // Blue
state.clear_color[3] = 1.0f; // Alpha
// 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
state.depthTestEnabled = GL_TRUE;
state.depthFunc = GL_LEQUAL;
state.depth_test_enabled = GL_TRUE;
state.depth_func = GL_LEQUAL;
// Disable blending by default
state.blendEnabled = GL_FALSE;
state.blendFunc = GL_FUNC_ADD;
state.blendSrc = GL_ONE;
state.blendDst = GL_ZERO;
state.blend_enabled = GL_FALSE;
state.blend_func = GL_FUNC_ADD;
state.blend_src = GL_ONE;
state.blend_dst = GL_ZERO;
// Enable culling by default and cull back faces
state.cullFaceEnabled = GL_TRUE;
state.cullFaceMode = GL_BACK;
state.cull_face_enabled = GL_TRUE;
state.cull_face_mode = GL_BACK;
// Disable stencil test by default
state.stencilTestEnabled = GL_FALSE;
state.stencilFunc = GL_ALWAYS;
state.stencilRef = 0;
state.stencilMask = 0xFFFFFFFF;
state.stencil_test_enabled = GL_FALSE;
state.stencil_func = GL_ALWAYS;
state.stencil_ref = 0;
state.stencil_mask = 0xFFFFFFFF;
// Set default front face to counter-clockwise
state.frontFace = GL_CCW;
state.front_face = GL_CCW;
// Set default line width
state.smoothLineEnabled = GL_FALSE;
state.lineWidth = 1.0f;
state.smooth_line_enabled = GL_FALSE;
state.line_width = 1.0f;
// Set default point size
state.pointSizeEnabled = GL_FALSE;
state.pointSize = 1.0f;
state.point_size_enabled = GL_FALSE;
state.point_size = 1.0f;
// Set default polygon mode to fill
state.polygonModeFace = GL_FRONT_AND_BACK;
state.polygonModeMode = GL_FILL;
state.polygon_mode_face = GL_FRONT_AND_BACK;
state.polygon_mode_mode = GL_FILL;
// Disable scissor test by default
state.scissorTestEnabled = GL_FALSE;
state.scissorBox[0] = 0;
state.scissorBox[1] = 0;
state.scissorBox[2] = window_width();
state.scissorBox[3] = window_height();
state.scissor_test_enabled = GL_FALSE;
state.scissor_box[0] = 0;
state.scissor_box[1] = 0;
state.scissor_box[2] = window_width();
state.scissor_box[3] = window_height();
return state;
}
@ -17290,75 +17290,75 @@ bool renderstate_compare(const renderstate_t *stateA, const renderstate_t *state
void renderstate_apply(const renderstate_t *state) {
if (state != NULL) {
// 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
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
glClearDepth(state->clearDepth);
glClearDepth(state->clear_depth);
// Apply depth test
if (state->depthTestEnabled) {
if (state->depth_test_enabled) {
glEnable(GL_DEPTH_TEST);
glDepthFunc(state->depthFunc);
glDepthFunc(state->depth_func);
} else {
glDisable(GL_DEPTH_TEST);
}
// Apply blending
if (state->blendEnabled) {
if (state->blend_enabled) {
glEnable(GL_BLEND);
glBlendEquation(state->blendFunc);
glBlendFunc(state->blendSrc, state->blendDst);
glBlendEquation(state->blend_func);
glBlendFunc(state->blend_src, state->blend_dst);
} else {
glDisable(GL_BLEND);
}
// Apply culling @fixme
// if (state->cullFaceEnabled) {
// if (state->cull_face_enabled) {
// glEnable(GL_CULL_FACE);
// glCullFace(state->cullFaceMode);
// glCullFace(state->cull_face_mode);
// } else {
// glDisable(GL_CULL_FACE);
// }
// Apply stencil test
if (state->stencilTestEnabled) {
if (state->stencil_test_enabled) {
glEnable(GL_STENCIL_TEST);
glStencilFunc(state->stencilFunc, state->stencilRef, state->stencilMask);
glStencilFunc(state->stencil_func, state->stencil_ref, state->stencil_mask);
} else {
glDisable(GL_STENCIL_TEST);
}
// Apply front face direction @fixme
// glFrontFace(state->frontFace);
// glFrontFace(state->front_face);
// Apply line width
glLineWidth(state->lineWidth);
glLineWidth(state->line_width);
// apply smooth lines
if (state->smoothLineEnabled) {
// Apply smooth lines
if (state->smooth_line_enabled) {
glEnable(GL_LINE_SMOOTH);
} else {
glDisable(GL_LINE_SMOOTH);
}
// Apply point size
if (state->pointSizeEnabled) {
if (state->point_size_enabled) {
glEnable(GL_PROGRAM_POINT_SIZE);
glPointSize(state->pointSize);
glPointSize(state->point_size);
} else {
glDisable(GL_PROGRAM_POINT_SIZE);
}
// Apply polygon mode
glPolygonMode(state->polygonModeFace, state->polygonModeMode);
glPolygonMode(state->polygon_mode_face, state->polygon_mode_mode);
// Apply scissor test
if (state->scissorTestEnabled) {
if (state->scissor_test_enabled) {
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 {
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
vec4 bgcolor = window_getcolor_();
skybox_rs.clearColor[0] = bgcolor.r;
skybox_rs.clearColor[1] = bgcolor.g;
skybox_rs.clearColor[2] = bgcolor.b;
skybox_rs.clearColor[3] = 1; // @transparent
skybox_rs.clear_color[0] = bgcolor.r;
skybox_rs.clear_color[1] = bgcolor.g;
skybox_rs.clear_color[2] = bgcolor.b;
skybox_rs.clear_color[3] = 1; // @transparent
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.blendEnabled = 1;
m.rs.blend_enabled = 1;
}
m.stored_flags = flags;
@ -21487,7 +21487,7 @@ void ddraw_flush() {
void ddraw_flush_projview(mat44 proj, mat44 view) {
do_once dd_rs = renderstate();
dd_rs.depthTestEnabled = 1;
dd_rs.depth_test_enabled = 1;
glActiveTexture(GL_TEXTURE0);
mat44 mvp;
@ -21502,12 +21502,12 @@ void ddraw_flush_projview(mat44 proj, mat44 view) {
glEnableVertexAttribArray(0);
dd_rs.pointSizeEnabled = 1;
dd_rs.smoothLineEnabled = 1;
dd_rs.point_size_enabled = 1;
dd_rs.smooth_line_enabled = 1;
for( int i = 0; i < 3; ++i ) { // [0] thin, [1] thick, [2] 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) {
int count = array_count(list);
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);
for( int i = 0; i < 3; ++i ) { // [0] thin, [1] thick, [2] 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) {
int count = array_count(list);
if(!count) continue;
@ -26843,14 +26843,14 @@ static renderstate_t window_rs;
void glNewFrame() {
do_once {
window_rs = renderstate();
window_rs.blendEnabled = 1;
window_rs.depthTestEnabled = 1;
window_rs.blend_enabled = 1;
window_rs.depth_test_enabled = 1;
}
window_rs.clearColor[0] = winbgcolor.r;
window_rs.clearColor[1] = winbgcolor.g;
window_rs.clearColor[2] = winbgcolor.b;
window_rs.clearColor[3] = window_has_transparent() ? 0 : winbgcolor.a;
window_rs.clear_color[0] = winbgcolor.r;
window_rs.clear_color[1] = winbgcolor.g;
window_rs.clear_color[2] = winbgcolor.b;
window_rs.clear_color[3] = window_has_transparent() ? 0 : winbgcolor.a;
// @transparent debug
// if( input_down(KEY_F1) ) window_transparent(window_has_transparent()^1);

View File

@ -3101,55 +3101,55 @@ typedef unsigned handle; // GLuint
// renderstate
typedef struct renderstate_t {
// Viewport parameters
int viewportX;
int viewportY;
int viewportWidth;
int viewportHeight;
int viewport_x;
int viewport_y;
int viewport_width;
int viewport_height;
// Clear color
float clearColor[4];
float clear_color[4];
// Clear depth
double clearDepth;
double clear_depth;
// Depth test
bool depthTestEnabled;
unsigned depthFunc;
bool depth_test_enabled;
unsigned depth_func;
// Blending
bool blendEnabled;
unsigned blendFunc;
unsigned blendSrc;
unsigned blendDst;
bool blend_enabled;
unsigned blend_func;
unsigned blend_src;
unsigned blend_dst;
// Culling
bool cullFaceEnabled;
unsigned cullFaceMode;
bool cull_face_enabled;
unsigned cull_face_mode;
// Stencil test
bool stencilTestEnabled;
unsigned stencilFunc;
int stencilRef;
unsigned stencilMask;
bool stencil_test_enabled;
unsigned stencil_func;
int stencil_ref;
unsigned stencil_mask;
// Face culling direction
unsigned frontFace; // GL_CW or GL_CCW
unsigned front_face; // GL_CW or GL_CCW
// Line width
bool smoothLineEnabled;
float lineWidth;
bool smooth_line_enabled;
float line_width;
// Point size
bool pointSizeEnabled;
float pointSize;
bool point_size_enabled;
float point_size;
// Polygon mode
unsigned polygonModeFace;
unsigned polygonModeMode;
unsigned polygon_mode_face;
unsigned polygon_mode_mode;
// Scissor test
bool scissorTestEnabled;
int scissorBox[4];
bool scissor_test_enabled;
int scissor_box[4];
} renderstate_t;
API renderstate_t renderstate();