diff options
Diffstat (limited to 'source/blender/editors/include/BIF_gl.h')
-rw-r--r-- | source/blender/editors/include/BIF_gl.h | 54 |
1 files changed, 38 insertions, 16 deletions
diff --git a/source/blender/editors/include/BIF_gl.h b/source/blender/editors/include/BIF_gl.h index 9fa603966b6..e2a24b9fed7 100644 --- a/source/blender/editors/include/BIF_gl.h +++ b/source/blender/editors/include/BIF_gl.h @@ -33,18 +33,8 @@ #ifndef __BIF_GL_H__ #define __BIF_GL_H__ -#include "GL/glew.h" - -#ifdef __APPLE__ - -/* hacking pointsize and linewidth */ -# define glPointSize(f) glPointSize(U.pixelsize * (f)) -# define glLineWidth(f) glLineWidth(U.pixelsize * (f)) -#else - /* avoid include mismatch by referencing 'U' from both */ -# define glPointSize(f) glPointSize(((void)U.pixelsize, (f))) -# define glLineWidth(f) glLineWidth(((void)U.pixelsize, (f))) -#endif +#include "GPU_glew.h" +#include "BLI_utildefines.h" /* * these should be phased out. cpack should be replaced in @@ -58,26 +48,58 @@ * */ void cpack(unsigned int x); - +#ifdef WITH_GL_PROFILE_COMPAT #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) # define glMultMatrixf(x) \ glMultMatrixf(_Generic((x), \ float *: (float *)(x), \ + float [16]: (float *)(x), \ float (*)[4]: (float *)(x), \ + float [4][4]: (float *)(x), \ const float *: (float *)(x), \ - const float (*)[4]: (float *)(x)) \ + const float [16]: (float *)(x), \ + const float (*)[4]: (float *)(x), \ + const float [4][4]: (float *)(x)) \ ) # define glLoadMatrixf(x) \ glLoadMatrixf(_Generic((x), \ float *: (float *)(x), \ - float (*)[4]: (float *)(x)) \ + float [16]: (float *)(x), \ + float (*)[4]: (float *)(x), \ + float [4][4]: (float *)(x)) \ ) #else # define glMultMatrixf(x) glMultMatrixf((float *)(x)) # define glLoadMatrixf(x) glLoadMatrixf((float *)(x)) -#endif +#endif /* C11 */ +#endif /* WITH_GL_PROFILE_COMPAT */ + + +/* hacking pointsize and linewidth */ +#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) +# define glPointSize(f) glPointSize(U.pixelsize * _Generic((f), double: (float)(f), default: (f))) +# define glLineWidth(f) glLineWidth(U.pixelsize * _Generic((f), double: (float)(f), default: (f))) +#else +# define glPointSize(f) glPointSize(U.pixelsize * (f)) +# define glLineWidth(f) glLineWidth(U.pixelsize * (f)) +#endif /* C11 */ #define GLA_PIXEL_OFS 0.375f + +BLI_INLINE void glTranslate3fv(const float vec[3]) { glTranslatef(UNPACK3(vec)); } +BLI_INLINE void glTranslate2fv(const float vec[2]) { glTranslatef(UNPACK2(vec), 0.0f); } +BLI_INLINE void glTranslate3dv(const double vec[3]) { glTranslated(UNPACK3(vec)); } +BLI_INLINE void glTranslate2dv(const double vec[2]) { glTranslated(UNPACK2(vec), 0.0f); } + +BLI_INLINE void glScale3fv(const float vec[3]) { glScalef(UNPACK3(vec)); } +BLI_INLINE void glScale2fv(const float vec[2]) { glScalef(UNPACK2(vec), 0.0); } +BLI_INLINE void glScale3dv(const double vec[3]) { glScaled(UNPACK3(vec)); } +BLI_INLINE void glScale2dv(const double vec[2]) { glScaled(UNPACK2(vec), 0.0); } + +/* v2 versions don't make much sense for rotation */ +BLI_INLINE void glRotate3fv(const float angle, const float vec[3]) { glRotatef(angle, UNPACK3(vec)); } +BLI_INLINE void glRotate3dv(const double angle, const double vec[3]) { glRotated(angle, UNPACK3(vec)); } + #endif /* #ifdef __BIF_GL_H__ */ |