aboutsummaryrefslogtreecommitdiff
path: root/src/rlgl.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/rlgl.h')
-rw-r--r--src/rlgl.h124
1 files changed, 66 insertions, 58 deletions
diff --git a/src/rlgl.h b/src/rlgl.h
index 23ad29fb..2a578a1f 100644
--- a/src/rlgl.h
+++ b/src/rlgl.h
@@ -32,15 +32,15 @@
//#define RLGL_STANDALONE // NOTE: To use rlgl as standalone lib, just uncomment this line
#ifndef RLGL_STANDALONE
- #include "raylib.h" // Required for typedef(s): Model, Shader, Texture2D
- #include "utils.h" // Required for function TraceLog()
+ #include "raylib.h" // Required for: Model, Shader, Texture2D
+ #include "utils.h" // Required for: TraceLog()
#endif
#ifdef RLGL_STANDALONE
#define RAYMATH_STANDALONE
#endif
-#include "raymath.h" // Required for types: Vector3, Matrix
+#include "raymath.h" // Required for: Vector3, Matrix
// Select desired OpenGL version
// NOTE: Those preprocessor defines are only used on rlgl module,
@@ -130,51 +130,43 @@ typedef enum { OPENGL_11 = 1, OPENGL_33, OPENGL_ES_20 } GlVersion;
COMPRESSED_ASTC_4x4_RGBA, // 8 bpp
COMPRESSED_ASTC_8x8_RGBA // 2 bpp
} TextureFormat;
-
- // Bounding box type
- typedef struct BoundingBox {
- Vector3 min;
- Vector3 max;
- } BoundingBox;
// Vertex data definning a mesh
typedef struct Mesh {
- int vertexCount; // number of vertices stored in arrays
- float *vertices; // vertex position (XYZ - 3 components per vertex) (shader-location = 0)
- float *texcoords; // vertex texture coordinates (UV - 2 components per vertex) (shader-location = 1)
- float *texcoords2; // vertex second texture coordinates (useful for lightmaps) (shader-location = 5)
- float *normals; // vertex normals (XYZ - 3 components per vertex) (shader-location = 2)
- float *tangents; // vertex tangents (XYZ - 3 components per vertex) (shader-location = 4)
- unsigned char *colors; // vertex colors (RGBA - 4 components per vertex) (shader-location = 3)
- unsigned short *indices; // vertex indices (in case vertex data comes indexed)
- int triangleCount; // number of triangles stored (indexed or not)
-
- BoundingBox bounds; // mesh limits defined by min and max points
-
- unsigned int vaoId; // OpenGL Vertex Array Object id
- unsigned int vboId[7]; // OpenGL Vertex Buffer Objects id (7 types of vertex data)
+ int vertexCount; // number of vertices stored in arrays
+ int triangleCount; // number of triangles stored (indexed or not)
+ float *vertices; // vertex position (XYZ - 3 components per vertex) (shader-location = 0)
+ float *texcoords; // vertex texture coordinates (UV - 2 components per vertex) (shader-location = 1)
+ float *texcoords2; // vertex second texture coordinates (useful for lightmaps) (shader-location = 5)
+ float *normals; // vertex normals (XYZ - 3 components per vertex) (shader-location = 2)
+ float *tangents; // vertex tangents (XYZ - 3 components per vertex) (shader-location = 4)
+ unsigned char *colors; // vertex colors (RGBA - 4 components per vertex) (shader-location = 3)
+ unsigned short *indices;// vertex indices (in case vertex data comes indexed)
+
+ unsigned int vaoId; // OpenGL Vertex Array Object id
+ unsigned int vboId[7]; // OpenGL Vertex Buffer Objects id (7 types of vertex data)
} Mesh;
// Shader type (generic shader)
typedef struct Shader {
- unsigned int id; // Shader program id
+ unsigned int id; // Shader program id
// Vertex attributes locations (default locations)
- int vertexLoc; // Vertex attribute location point (default-location = 0)
- int texcoordLoc; // Texcoord attribute location point (default-location = 1)
- int normalLoc; // Normal attribute location point (default-location = 2)
- int colorLoc; // Color attibute location point (default-location = 3)
- int tangentLoc; // Tangent attribute location point (default-location = 4)
- int texcoord2Loc; // Texcoord2 attribute location point (default-location = 5)
+ int vertexLoc; // Vertex attribute location point (default-location = 0)
+ int texcoordLoc; // Texcoord attribute location point (default-location = 1)
+ int normalLoc; // Normal attribute location point (default-location = 2)
+ int colorLoc; // Color attibute location point (default-location = 3)
+ int tangentLoc; // Tangent attribute location point (default-location = 4)
+ int texcoord2Loc; // Texcoord2 attribute location point (default-location = 5)
// Uniform locations
- int mvpLoc; // ModelView-Projection matrix uniform location point (vertex shader)
- int tintColorLoc; // Color uniform location point (fragment shader)
+ int mvpLoc; // ModelView-Projection matrix uniform location point (vertex shader)
+ int tintColorLoc; // Color uniform location point (fragment shader)
// Texture map locations (generic for any kind of map)
- int mapTexture0Loc; // Map texture uniform location point (default-texture-unit = 0)
- int mapTexture1Loc; // Map texture uniform location point (default-texture-unit = 1)
- int mapTexture2Loc; // Map texture uniform location point (default-texture-unit = 2)
+ int mapTexture0Loc; // Map texture uniform location point (default-texture-unit = 0)
+ int mapTexture1Loc; // Map texture uniform location point (default-texture-unit = 1)
+ int mapTexture2Loc; // Map texture uniform location point (default-texture-unit = 2)
} Shader;
// Texture2D type
@@ -196,36 +188,46 @@ typedef enum { OPENGL_11 = 1, OPENGL_33, OPENGL_ES_20 } GlVersion;
// Material type
typedef struct Material {
- Shader shader; // Standard shader (supports 3 map types: diffuse, normal, specular)
+ Shader shader; // Standard shader (supports 3 map types: diffuse, normal, specular)
- Texture2D texDiffuse; // Diffuse texture
- Texture2D texNormal; // Normal texture
- Texture2D texSpecular; // Specular texture
-
- Color colTint; // Tint color
- Color colDiffuse; // Diffuse color
- Color colAmbient; // Ambient color
- Color colSpecular; // Specular color
+ Texture2D texDiffuse; // Diffuse texture
+ Texture2D texNormal; // Normal texture
+ Texture2D texSpecular; // Specular texture
+
+ Color colDiffuse; // Diffuse color
+ Color colAmbient; // Ambient color
+ Color colSpecular; // Specular color
- float glossiness; // Glossiness level (Ranges from 0 to 1000)
+ float glossiness; // Glossiness level (Ranges from 0 to 1000)
} Material;
+ // Camera type, defines a camera position/orientation in 3d space
+ typedef struct Camera {
+ Vector3 position; // Camera position
+ Vector3 target; // Camera target it looks-at
+ Vector3 up; // Camera up vector (rotation over its axis)
+ float fovy; // Camera field-of-view apperture in Y (degrees)
+ } Camera;
+
// Light type
typedef struct LightData {
- int id;
- int type; // LIGHT_POINT, LIGHT_DIRECTIONAL, LIGHT_SPOT
- bool enabled;
+ unsigned int id; // Light unique id
+ int type; // Light type: LIGHT_POINT, LIGHT_DIRECTIONAL, LIGHT_SPOT
+ bool enabled; // Light enabled
- Vector3 position;
- Vector3 target; // Used on LIGHT_DIRECTIONAL and LIGHT_SPOT (cone direction target)
- float radius; // Lost of light intensity with distance (world distance)
+ Vector3 position; // Light position
+ Vector3 target; // Light target: LIGHT_DIRECTIONAL and LIGHT_SPOT (cone direction target)
+ float radius; // Light attenuation radius light intensity reduced with distance (world distance)
- Color diffuse; // Use Vector3 diffuse
- float intensity;
+ Color diffuse; // Light diffuse color
+ float intensity; // Light intensity level
- float coneAngle; // Spot light max angle
+ float coneAngle; // Light cone max angle: LIGHT_SPOT
} LightData, *Light;
-
+
+ // Light types
+ typedef enum { LIGHT_POINT, LIGHT_DIRECTIONAL, LIGHT_SPOT } LightType;
+
// Color blending modes (pre-defined)
typedef enum { BLEND_ALPHA = 0, BLEND_ADDITIVE, BLEND_MULTIPLIED } BlendMode;
#endif
@@ -317,9 +319,9 @@ void *rlglReadTexturePixels(Texture2D texture); // Read text
//------------------------------------------------------------------------------------
Shader LoadShader(char *vsFileName, char *fsFileName); // Load a custom shader and bind default locations
void UnloadShader(Shader shader); // Unload a custom shader from memory
-void SetCustomShader(Shader shader); // Set custom shader to be used in batch draw
-void SetDefaultShader(void); // Set default shader to be used in batch draw
+
Shader GetDefaultShader(void); // Get default shader
+Shader GetStandardShader(void); // Get default shader
Texture2D GetDefaultTexture(void); // Get default texture
int GetShaderLocation(Shader shader, const char *uniformName); // Get shader uniform location
@@ -327,7 +329,13 @@ void SetShaderValue(Shader shader, int uniformLoc, float *value, int size); // S
void SetShaderValuei(Shader shader, int uniformLoc, int *value, int size); // Set shader uniform value (int)
void SetShaderValueMatrix(Shader shader, int uniformLoc, Matrix mat); // Set shader uniform value (matrix 4x4)
-void SetBlendMode(int mode); // Set blending mode (alpha, additive, multiplied)
+void SetMatrixProjection(Matrix proj); // Set a custom projection matrix (replaces internal projection matrix)
+void SetMatrixModelview(Matrix view); // Set a custom modelview matrix (replaces internal modelview matrix)
+
+void BeginShaderMode(Shader shader); // Begin custom shader drawing
+void EndShaderMode(void); // End custom shader drawing (use default shader)
+void BeginBlendMode(int mode); // Begin blending mode (alpha, additive, multiplied)
+void EndBlendMode(void); // End blending mode (reset to default: alpha blending)
Light CreateLight(int type, Vector3 position, Color diffuse); // Create a new light, initialize it and add to pool
void DestroyLight(Light light); // Destroy a light and take it out of the list