diff options
author | Mike Erwin <significant.bit@gmail.com> | 2016-10-01 02:51:04 +0300 |
---|---|---|
committer | Mike Erwin <significant.bit@gmail.com> | 2016-10-01 02:51:04 +0300 |
commit | d1b21d1278b3f91643fb52ed67320c064e28a0d4 (patch) | |
tree | 2c9827a1391756aa30f2ef2462cb398fa709e88d /source/blender | |
parent | 82648a8f919cf42355c3be3d1feabab0c5889508 (diff) |
OpenGL: add support for programmable point size
And enable point sprites always. Fragment shaders can use gl_PointCoord now.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/gpu/GPU_draw.h | 7 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_draw.c | 32 |
2 files changed, 36 insertions, 3 deletions
diff --git a/source/blender/gpu/GPU_draw.h b/source/blender/gpu/GPU_draw.h index 90b65af87c8..91d436557f0 100644 --- a/source/blender/gpu/GPU_draw.h +++ b/source/blender/gpu/GPU_draw.h @@ -59,6 +59,13 @@ struct DupliObject; void GPU_state_init(void); +/* Programmable point size + * - shaders set their own point size when enabled + * - use glPointSize when disabled */ + +void GPU_enable_program_point_size(void); +void GPU_disable_program_point_size(void); + /* Material drawing * - first the state is initialized by a particular object and * it's materials diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index 25b28b1f7d2..96a35f093fa 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -2247,7 +2247,13 @@ void GPU_state_init(void) glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE); GPU_default_lights(); - + + GPU_disable_program_point_size(); +#ifdef __APPLE__ + /* TODO: remove this when we switch to core profile */ + glEnable(GL_POINT_SPRITE); +#endif + glDepthFunc(GL_LEQUAL); /* scaling matrices */ glEnable(GL_NORMALIZE); @@ -2269,7 +2275,7 @@ void GPU_state_init(void) glDisableClientState(GL_NORMAL_ARRAY); glDisableClientState(GL_COLOR_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY); - + glPixelTransferi(GL_MAP_COLOR, GL_FALSE); glPixelTransferi(GL_RED_SCALE, 1); glPixelTransferi(GL_RED_BIAS, 0); @@ -2279,7 +2285,7 @@ void GPU_state_init(void) glPixelTransferi(GL_BLUE_BIAS, 0); glPixelTransferi(GL_ALPHA_SCALE, 1); glPixelTransferi(GL_ALPHA_BIAS, 0); - + glPixelTransferi(GL_DEPTH_BIAS, 0); glPixelTransferi(GL_DEPTH_SCALE, 1); glDepthRange(0.0, 1.0); @@ -2297,6 +2303,26 @@ void GPU_state_init(void) GPU_basic_shader_bind(GPU_SHADER_USE_COLOR); } +void GPU_enable_program_point_size() +{ +#ifdef __APPLE__ + /* TODO: remove this when we switch to core profile */ + glEnable(GL_VERTEX_PROGRAM_POINT_SIZE); +#else + glEnable(GL_PROGRAM_POINT_SIZE); +#endif +} + +void GPU_disable_program_point_size() +{ +#ifdef __APPLE__ + /* TODO: remove this when we switch to core profile */ + glDisable(GL_VERTEX_PROGRAM_POINT_SIZE); +#else + glDisable(GL_PROGRAM_POINT_SIZE); +#endif +} + #ifdef WITH_OPENSUBDIV /* Update face-varying variables offset which might be * different from mesh to mesh sharing the same material. |