Cleanup: GPU: Encapsulate Backface culling
This commit is contained in:
parent
c14e6cdd56
commit
5993c53a6d
|
@ -84,7 +84,7 @@ void wm_gizmo_geometryinfo_draw(const GizmoGeomInfo *info,
|
|||
/* We may want to re-visit this, for now disable
|
||||
* since it causes issues leaving the GL state modified. */
|
||||
#if 0
|
||||
glEnable(GL_CULL_FACE);
|
||||
GPU_face_culling(GPU_CULL_BACK);
|
||||
GPU_depth_test(true);
|
||||
#endif
|
||||
|
||||
|
@ -92,7 +92,7 @@ void wm_gizmo_geometryinfo_draw(const GizmoGeomInfo *info,
|
|||
|
||||
#if 0
|
||||
GPU_depth_test(false);
|
||||
glDisable(GL_CULL_FACE);
|
||||
GPU_face_culling(GPU_CULL_NONE);
|
||||
#endif
|
||||
|
||||
GPU_batch_discard(batch);
|
||||
|
|
|
@ -1783,8 +1783,7 @@ void ui_draw_but_UNITVEC(uiBut *but, const uiWidgetColors *wcol, const rcti *rec
|
|||
UI_draw_roundbox_3ub_alpha(
|
||||
true, rect->xmin, rect->ymin, rect->xmax, rect->ymax, 5.0f, wcol->inner, 255);
|
||||
|
||||
glCullFace(GL_BACK);
|
||||
glEnable(GL_CULL_FACE);
|
||||
GPU_face_culling(GPU_CULL_BACK);
|
||||
|
||||
/* setup lights */
|
||||
ui_but_v3_get(but, light);
|
||||
|
@ -1809,7 +1808,7 @@ void ui_draw_but_UNITVEC(uiBut *but, const uiWidgetColors *wcol, const rcti *rec
|
|||
GPU_batch_draw(sphere);
|
||||
|
||||
/* restore */
|
||||
glDisable(GL_CULL_FACE);
|
||||
GPU_face_culling(GPU_CULL_NONE);
|
||||
|
||||
/* AA circle */
|
||||
GPUVertFormat *format = immVertexFormat();
|
||||
|
|
|
@ -40,6 +40,12 @@ typedef enum eGPUFilterFunction {
|
|||
GPU_LINEAR,
|
||||
} eGPUFilterFunction;
|
||||
|
||||
typedef enum eGPUFaceCull {
|
||||
GPU_CULL_NONE = 0, /* Culling disabled. */
|
||||
GPU_CULL_FRONT,
|
||||
GPU_CULL_BACK,
|
||||
} eGPUFaceCull;
|
||||
|
||||
/* Initialize
|
||||
* - sets the default Blender opengl state, if in doubt, check
|
||||
* the contents of this function
|
||||
|
@ -52,6 +58,7 @@ void GPU_blend_set_func_separate(eGPUBlendFunction src_rgb,
|
|||
eGPUBlendFunction dst_rgb,
|
||||
eGPUBlendFunction src_alpha,
|
||||
eGPUBlendFunction dst_alpha);
|
||||
void GPU_face_culling(eGPUFaceCull culling);
|
||||
void GPU_depth_range(float near, float far);
|
||||
void GPU_depth_test(bool enable);
|
||||
bool GPU_depth_test_enabled(void);
|
||||
|
|
|
@ -78,6 +78,17 @@ void GPU_blend_set_func_separate(eGPUBlendFunction src_rgb,
|
|||
gpu_get_gl_blendfunction(dst_alpha));
|
||||
}
|
||||
|
||||
void GPU_face_culling(eGPUFaceCull culling)
|
||||
{
|
||||
if (culling == GPU_CULL_NONE) {
|
||||
glDisable(GL_CULL_FACE);
|
||||
}
|
||||
else {
|
||||
glEnable(GL_CULL_FACE);
|
||||
glCullFace((culling == GPU_CULL_FRONT) ? GL_FRONT : GL_BACK);
|
||||
}
|
||||
}
|
||||
|
||||
void GPU_depth_range(float near, float far)
|
||||
{
|
||||
/* glDepthRangef is only for OpenGL 4.1 or higher */
|
||||
|
|
Loading…
Reference in New Issue