aboutsummaryrefslogtreecommitdiff
path: root/src/rlgl.h
diff options
context:
space:
mode:
authorraysan5 <raysan5@gmail.com>2015-03-01 16:00:52 +0100
committerraysan5 <raysan5@gmail.com>2015-03-01 16:00:52 +0100
commitc062f8d4fe3b600ea63a7a7f783963cf3d6aca84 (patch)
treebe3e4eb5e73c66a3bc26cc5b8c3c2da07afdbf2c /src/rlgl.h
parentee4b553c2a7bb0784b53583988c60e023f340220 (diff)
downloadraylib-c062f8d4fe3b600ea63a7a7f783963cf3d6aca84.tar.gz
raylib-c062f8d4fe3b600ea63a7a7f783963cf3d6aca84.zip
Redesign shader system and more
Shader system has been completely redesigned Added support for multiple texture color modes
Diffstat (limited to 'src/rlgl.h')
-rw-r--r--src/rlgl.h42
1 files changed, 37 insertions, 5 deletions
diff --git a/src/rlgl.h b/src/rlgl.h
index 94cf6072..ff2bcd4e 100644
--- a/src/rlgl.h
+++ b/src/rlgl.h
@@ -32,7 +32,7 @@
//#define RLGL_STANDALONE // NOTE: To use rlgl as standalone lib, just uncomment this line
#ifndef RLGL_STANDALONE
- #include "raylib.h" // Required for typedef: Model
+ #include "raylib.h" // Required for typedef(s): Model, Shader, Texture2D
#include "utils.h" // Required for function TraceLog()
#endif
@@ -88,20 +88,50 @@ typedef enum { RL_LINES, RL_TRIANGLES, RL_QUADS } DrawMode;
typedef enum { OPENGL_11 = 1, OPENGL_33, OPENGL_ES_20 } GlVersion;
+typedef enum { GRAYSCALE = 0, R5G6B5, R8G8B8, R5G5B5A1, R4G4B4A4, R8G8B8A8 } ColorMode;
+
#ifdef RLGL_STANDALONE
- typedef struct {
+ // VertexData type
+ typedef struct VertexData {
int vertexCount;
float *vertices; // 3 components per vertex
float *texcoords; // 2 components per vertex
float *normals; // 3 components per vertex
unsigned char *colors;
} VertexData;
-
+
+ // Texture2D type
+ typedef struct Texture2D {
+ unsigned int id; // Texture id
+ int width;
+ int height;
+ } Texture2D;
+
+ // Shader type
+ typedef struct Shader {
+ unsigned int id; // Shader program id
+
+ // Variable attributes
+ unsigned int vertexLoc; // Vertex attribute location point (vertex shader)
+ unsigned int texcoordLoc; // Texcoord attribute location point (vertex shader)
+ unsigned int normalLoc; // Normal attribute location point (vertex shader)
+ unsigned int colorLoc; // Color attibute location point (vertex shader)
+
+ // Uniforms
+ unsigned int projectionLoc; // Projection matrix uniform location point (vertex shader)
+ unsigned int modelviewLoc; // ModeView matrix uniform location point (vertex shader)
+ unsigned int textureLoc; // Texture uniform location point (fragment shader)
+ unsigned int tintColorLoc; // Color uniform location point (fragment shader)
+ } Shader;
+
+ // 3d Model type
+ // NOTE: If using OpenGL 1.1, loaded in CPU (mesh); if OpenGL 3.3+ loaded in GPU (vaoId)
typedef struct Model {
VertexData mesh;
unsigned int vaoId;
unsigned int vboId[4];
- unsigned int textureId;
+ Texture2D texture;
+ Shader shader;
//Matrix transform;
} Model;
#endif
@@ -163,9 +193,11 @@ void rlglDraw(void); // Draw VAO/VBO
void rlglDrawPostpro(unsigned int shaderId); // Draw with postpro shader
void rlglInitGraphics(int offsetX, int offsetY, int width, int height); // Initialize Graphics (OpenGL stuff)
-unsigned int rlglLoadTexture(unsigned char *data, int width, int height, bool genMipmaps); // Load in GPU OpenGL texture
+unsigned int rlglLoadTexture(unsigned char *data, int width, int height, int colorMode, bool genMipmaps); // Load in GPU OpenGL texture
unsigned int rlglLoadCompressedTexture(unsigned char *data, int width, int height, int mipmapCount, int format);
+#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
unsigned int rlglLoadShader(char *vShaderStr, char *fShaderStr); // Load a shader from text data
+#endif
Model rlglLoadModel(VertexData mesh); // Upload vertex data into GPU and provided VAO/VBO ids
void rlglDrawModel(Model model, Vector3 position, Vector3 rotation, Vector3 scale, Color color, bool wires);