Newer
Older
invertedlogic / invertedlogic / iLFramework / toolkit / include / GL / ImmediateMode.h
@John Ryland John Ryland on 10 Nov 2019 3 KB add framework
#ifndef IMMEDIATE_MODE_H
#define IMMEDIATE_MODE_H


// Windows Headers
#define Rectangle WinRectangle
#define WIN32_LEAN_AND_MEAN             // Exclude rarely-used stuff from Windows headers
#include <windows.h>
#undef Rectangle


#include <cstdint>
#include <GL/gl.h>
#include <GL/glext.h>
#include "Graphics.h"


#include "Namespace.h"
BEGIN_NAMESPACE


// Helper
unsigned nextPowerOfTwo(unsigned int a_value);
void glCheckErrors();
void glSetColor(uint32_t a_color);


// Lines
void glDrawLine(float x1, float y1, float x2, float y2, uint32_t a_color);
void glDrawBezierCurve(float p1[2], float cp1[2], float cp2[2], float p2[2], uint32_t a_color);
void glDrawCurvedLine(int x1, int y1, int x2, int y2, uint32_t a_color);
void glDrawStyledCurvedLine(float x1, float y1, float x2, float y2, float scale, bool highlighted=false);

// Rectangles
void glDrawRect(int x1, int y1, int x2, int y2, uint32_t a_color);
void glDrawFillRect(float x1, float y1, float x2, float y2, uint32_t a_color);
void glDrawRoundedRect(float x1, float y1, float x2, float y2, float radius, uint32_t a_color);
void glDrawFillRoundedRect(float x1, float y1, float x2, float y2, float radius, uint32_t a_color);
void glDrawFillTitleBar(float x1, float y1, float x2, float y2, float radius, uint32_t a_color);

// Circles
void glDrawCircle(float x1, float y1, float size, uint32_t a_color);
void glDrawFilledCircle(float x1, float y1, float size, uint32_t a_color);

// Text
void glDrawText(int x, int y, const char* text, uint32_t a_color, uint32_t a_dropColor, int32_t a_fontSize, bool a_invertColors=false);
void glDrawShadowText(int x, int y, const char* text);

// Other
void glDrawTarget(int x, int y, CUTE::CUTE_PaintTarget a_target, GLuint a_texture);
void glDrawDot(float x, float y);


// Add the various GL extension functions in to this namespace
#define DECLARE_ALL_GL_FUNCTIONS \
			DECLARE_GL_FUNCTION(PFNGLBINDBUFFERPROC				 , glBindBuffer			   	   ) \
			DECLARE_GL_FUNCTION(PFNGLGENBUFFERSPROC				 , glGenBuffers			   	   ) \
			DECLARE_GL_FUNCTION(PFNGLBUFFERDATAPROC				 , glBufferData			   	   ) \
			DECLARE_GL_FUNCTION(PFNGLATTACHSHADERPROC			 , glAttachShader			   ) \
			DECLARE_GL_FUNCTION(PFNGLCOMPILESHADERPROC			 , glCompileShader			   ) \
			DECLARE_GL_FUNCTION(PFNGLCREATEPROGRAMPROC			 , glCreateProgram			   ) \
			DECLARE_GL_FUNCTION(PFNGLCREATESHADERPROC			 , glCreateShader			   ) \
			DECLARE_GL_FUNCTION(PFNGLENABLEVERTEXATTRIBARRAYPROC , glEnableVertexAttribArray   ) \
			DECLARE_GL_FUNCTION(PFNGLGETATTRIBLOCATIONPROC		 , glGetAttribLocation		   ) \
			DECLARE_GL_FUNCTION(PFNGLGETSHADERIVPROC			 , glGetShaderiv			   ) \
			DECLARE_GL_FUNCTION(PFNGLGETSHADERINFOLOGPROC		 , glGetShaderInfoLog		   ) \
			DECLARE_GL_FUNCTION(PFNGLLINKPROGRAMPROC			 , glLinkProgram			   ) \
			DECLARE_GL_FUNCTION(PFNGLSHADERSOURCEPROC			 , glShaderSource			   ) \
			DECLARE_GL_FUNCTION(PFNGLUSEPROGRAMPROC				 , glUseProgram			   	   ) \
			DECLARE_GL_FUNCTION(PFNGLVERTEXATTRIBPOINTERPROC	 , glVertexAttribPointer	   ) \
			DECLARE_GL_FUNCTION(PFNGLBINDFRAGDATALOCATIONPROC	 , glBindFragDataLocation      ) \
			DECLARE_GL_FUNCTION(PFNGLBINDVERTEXARRAYPROC		 , glBindVertexArray		   ) \
			DECLARE_GL_FUNCTION(PFNGLGENVERTEXARRAYSPROC		 , glGenVertexArrays		   ) \
			DECLARE_GL_FUNCTION(PFNGLDELETEPROGRAMPROC		     , glDeleteProgram		       ) \
			DECLARE_GL_FUNCTION(PFNGLDELETESHADERPROC		     , glDeleteShader		       ) \
			DECLARE_GL_FUNCTION(PFNGLDELETEBUFFERSPROC		     , glDeleteBuffers		       ) \
			DECLARE_GL_FUNCTION(PFNGLDELETEVERTEXARRAYSPROC      , glDeleteVertexArrays        )

#define DECLARE_GL_FUNCTION(type, name) \
			extern type name;

DECLARE_ALL_GL_FUNCTIONS

#undef DECLARE_GL_FUNCTION


// Call this to load these extensions
void glLoadExtensions();


END_NAMESPACE


#endif // IMMEDIATE_MODE_H