2014-09-17 00:51:31 +04:00
|
|
|
/**********************************************************************************************
|
2014-09-03 18:51:28 +04:00
|
|
|
*
|
2014-03-25 15:40:35 +04:00
|
|
|
* rlgl - raylib OpenGL abstraction layer
|
2014-09-03 18:51:28 +04:00
|
|
|
*
|
2014-03-25 15:40:35 +04:00
|
|
|
* raylib now uses OpenGL 1.1 style functions (rlVertex) that are mapped to selected OpenGL version:
|
|
|
|
* OpenGL 1.1 - Direct map rl* -> gl*
|
2015-08-29 21:20:28 +03:00
|
|
|
* OpenGL 3.3 - Vertex data is stored in VAOs, call rlglDraw() to render
|
2015-01-02 22:58:06 +03:00
|
|
|
* OpenGL ES 2 - Vertex data is stored in VBOs or VAOs (when available), call rlglDraw() to render
|
2014-09-03 18:51:28 +04:00
|
|
|
*
|
2015-07-29 22:43:30 +03:00
|
|
|
* Copyright (c) 2014 Ramon Santamaria (@raysan5)
|
2014-09-03 18:51:28 +04:00
|
|
|
*
|
|
|
|
* This software is provided "as-is", without any express or implied warranty. In no event
|
2014-03-25 15:40:35 +04:00
|
|
|
* will the authors be held liable for any damages arising from the use of this software.
|
|
|
|
*
|
2014-09-03 18:51:28 +04:00
|
|
|
* Permission is granted to anyone to use this software for any purpose, including commercial
|
2014-03-25 15:40:35 +04:00
|
|
|
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
|
|
|
|
*
|
2014-09-03 18:51:28 +04:00
|
|
|
* 1. The origin of this software must not be misrepresented; you must not claim that you
|
|
|
|
* wrote the original software. If you use this software in a product, an acknowledgment
|
2014-03-25 15:40:35 +04:00
|
|
|
* in the product documentation would be appreciated but is not required.
|
|
|
|
*
|
|
|
|
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
|
|
|
|
* as being the original software.
|
|
|
|
*
|
|
|
|
* 3. This notice may not be removed or altered from any source distribution.
|
|
|
|
*
|
|
|
|
**********************************************************************************************/
|
|
|
|
|
|
|
|
#ifndef RLGL_H
|
|
|
|
#define RLGL_H
|
|
|
|
|
2014-04-04 22:11:57 +04:00
|
|
|
//#define RLGL_STANDALONE // NOTE: To use rlgl as standalone lib, just uncomment this line
|
|
|
|
|
|
|
|
#ifndef RLGL_STANDALONE
|
2016-06-02 02:26:44 +03:00
|
|
|
#include "raylib.h" // Required for: Model, Shader, Texture2D
|
|
|
|
#include "utils.h" // Required for: TraceLog()
|
2014-04-04 22:11:57 +04:00
|
|
|
#endif
|
|
|
|
|
2016-03-20 15:39:27 +03:00
|
|
|
#ifdef RLGL_STANDALONE
|
|
|
|
#define RAYMATH_STANDALONE
|
|
|
|
#endif
|
|
|
|
|
2016-06-02 02:26:44 +03:00
|
|
|
#include "raymath.h" // Required for: Vector3, Matrix
|
2015-08-05 20:18:40 +03:00
|
|
|
|
2014-03-25 15:40:35 +04:00
|
|
|
// Select desired OpenGL version
|
2014-09-17 00:51:31 +04:00
|
|
|
// NOTE: Those preprocessor defines are only used on rlgl module,
|
|
|
|
// if OpenGL version is required by any other module, it uses rlGetVersion()
|
|
|
|
|
|
|
|
// Choose opengl version here or just define it at compile time: -DGRAPHICS_API_OPENGL_33
|
|
|
|
//#define GRAPHICS_API_OPENGL_11 // Only available on PLATFORM_DESKTOP
|
2016-06-19 20:12:47 +03:00
|
|
|
//#define GRAPHICS_API_OPENGL_33 // Only available on PLATFORM_DESKTOP and RLGL_OCULUS_SUPPORT
|
2014-12-15 03:08:30 +03:00
|
|
|
//#define GRAPHICS_API_OPENGL_ES2 // Only available on PLATFORM_ANDROID or PLATFORM_RPI or PLATFORM_WEB
|
2014-09-17 00:51:31 +04:00
|
|
|
|
|
|
|
// Security check in case no GRAPHICS_API_OPENGL_* defined
|
2016-06-16 21:25:50 +03:00
|
|
|
#if !defined(GRAPHICS_API_OPENGL_11) && !defined(GRAPHICS_API_OPENGL_21) && !defined(GRAPHICS_API_OPENGL_33) && !defined(GRAPHICS_API_OPENGL_ES2)
|
2014-09-17 00:51:31 +04:00
|
|
|
#define GRAPHICS_API_OPENGL_11
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Security check in case multiple GRAPHICS_API_OPENGL_* defined
|
|
|
|
#if defined(GRAPHICS_API_OPENGL_11)
|
2016-06-16 21:25:50 +03:00
|
|
|
#if defined(GRAPHICS_API_OPENGL_21)
|
|
|
|
#undef GRAPHICS_API_OPENGL_21
|
|
|
|
#endif
|
2014-09-17 00:51:31 +04:00
|
|
|
#if defined(GRAPHICS_API_OPENGL_33)
|
|
|
|
#undef GRAPHICS_API_OPENGL_33
|
|
|
|
#endif
|
|
|
|
#if defined(GRAPHICS_API_OPENGL_ES2)
|
|
|
|
#undef GRAPHICS_API_OPENGL_ES2
|
|
|
|
#endif
|
|
|
|
#endif
|
2014-03-25 15:40:35 +04:00
|
|
|
|
2016-06-16 21:25:50 +03:00
|
|
|
#if defined(GRAPHICS_API_OPENGL_21)
|
|
|
|
#define GRAPHICS_API_OPENGL_33
|
|
|
|
#endif
|
|
|
|
|
2014-03-25 15:40:35 +04:00
|
|
|
//----------------------------------------------------------------------------------
|
|
|
|
// Defines and Macros
|
|
|
|
//----------------------------------------------------------------------------------
|
2014-09-17 00:51:31 +04:00
|
|
|
#if defined(GRAPHICS_API_OPENGL_11) || defined(GRAPHICS_API_OPENGL_33)
|
|
|
|
// NOTE: This is the maximum amount of lines, triangles and quads per frame, be careful!
|
|
|
|
#define MAX_LINES_BATCH 8192
|
|
|
|
#define MAX_TRIANGLES_BATCH 4096
|
|
|
|
#define MAX_QUADS_BATCH 4096
|
|
|
|
#elif defined(GRAPHICS_API_OPENGL_ES2)
|
2014-12-31 20:03:32 +03:00
|
|
|
// NOTE: Reduce memory sizes for embedded systems (RPI and HTML5)
|
|
|
|
// NOTE: On HTML5 (emscripten) this is allocated on heap, by default it's only 16MB!...just take care...
|
|
|
|
#define MAX_LINES_BATCH 1024 // Critical for wire shapes (sphere)
|
2014-09-17 00:51:31 +04:00
|
|
|
#define MAX_TRIANGLES_BATCH 2048 // Critical for some shapes (sphere)
|
|
|
|
#define MAX_QUADS_BATCH 1024 // Be careful with text, every letter maps a quad
|
|
|
|
#endif
|
2014-03-25 15:40:35 +04:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------------------
|
|
|
|
// Types and Structures Definition
|
|
|
|
//----------------------------------------------------------------------------------
|
|
|
|
typedef enum { RL_PROJECTION, RL_MODELVIEW, RL_TEXTURE } MatrixMode;
|
|
|
|
|
|
|
|
typedef enum { RL_LINES, RL_TRIANGLES, RL_QUADS } DrawMode;
|
|
|
|
|
2016-06-16 21:25:50 +03:00
|
|
|
typedef enum { OPENGL_11 = 1, OPENGL_21, OPENGL_33, OPENGL_ES_20 } GlVersion;
|
2014-09-17 00:51:31 +04:00
|
|
|
|
2016-01-20 20:20:05 +03:00
|
|
|
#if defined(RLGL_STANDALONE)
|
2015-08-05 20:18:40 +03:00
|
|
|
#ifndef __cplusplus
|
|
|
|
// Boolean type
|
|
|
|
typedef enum { false, true } bool;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// byte type
|
|
|
|
typedef unsigned char byte;
|
|
|
|
|
|
|
|
// Color type, RGBA (32bit)
|
|
|
|
typedef struct Color {
|
|
|
|
unsigned char r;
|
|
|
|
unsigned char g;
|
|
|
|
unsigned char b;
|
|
|
|
unsigned char a;
|
|
|
|
} Color;
|
|
|
|
|
2015-04-06 15:02:29 +03:00
|
|
|
// Texture formats (support depends on OpenGL version)
|
|
|
|
typedef enum {
|
|
|
|
UNCOMPRESSED_GRAYSCALE = 1, // 8 bit per pixel (no alpha)
|
2015-08-05 20:18:40 +03:00
|
|
|
UNCOMPRESSED_GRAY_ALPHA,
|
2015-04-06 15:02:29 +03:00
|
|
|
UNCOMPRESSED_R5G6B5, // 16 bpp
|
|
|
|
UNCOMPRESSED_R8G8B8, // 24 bpp
|
|
|
|
UNCOMPRESSED_R5G5B5A1, // 16 bpp (1 bit alpha)
|
|
|
|
UNCOMPRESSED_R4G4B4A4, // 16 bpp (4 bit alpha)
|
|
|
|
UNCOMPRESSED_R8G8B8A8, // 32 bpp
|
|
|
|
COMPRESSED_DXT1_RGB, // 4 bpp (no alpha)
|
|
|
|
COMPRESSED_DXT1_RGBA, // 4 bpp (1 bit alpha)
|
|
|
|
COMPRESSED_DXT3_RGBA, // 8 bpp
|
|
|
|
COMPRESSED_DXT5_RGBA, // 8 bpp
|
|
|
|
COMPRESSED_ETC1_RGB, // 4 bpp
|
|
|
|
COMPRESSED_ETC2_RGB, // 4 bpp
|
|
|
|
COMPRESSED_ETC2_EAC_RGBA, // 8 bpp
|
2015-04-13 21:15:28 +03:00
|
|
|
COMPRESSED_PVRT_RGB, // 4 bpp
|
|
|
|
COMPRESSED_PVRT_RGBA, // 4 bpp
|
2015-08-05 20:18:40 +03:00
|
|
|
COMPRESSED_ASTC_4x4_RGBA, // 8 bpp
|
|
|
|
COMPRESSED_ASTC_8x8_RGBA // 2 bpp
|
2015-04-06 15:02:29 +03:00
|
|
|
} TextureFormat;
|
|
|
|
|
2016-05-11 20:25:51 +03:00
|
|
|
// Vertex data definning a mesh
|
2016-01-18 15:36:18 +03:00
|
|
|
typedef struct Mesh {
|
2016-05-31 20:12:37 +03:00
|
|
|
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)
|
2016-01-18 15:36:18 +03:00
|
|
|
} Mesh;
|
2015-03-01 18:00:52 +03:00
|
|
|
|
2016-05-11 20:25:51 +03:00
|
|
|
// Shader type (generic shader)
|
2015-03-01 18:00:52 +03:00
|
|
|
typedef struct Shader {
|
2016-05-31 20:12:37 +03:00
|
|
|
unsigned int id; // Shader program id
|
2016-05-11 20:25:51 +03:00
|
|
|
|
|
|
|
// Vertex attributes locations (default locations)
|
2016-05-31 20:12:37 +03:00
|
|
|
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)
|
2016-05-11 20:25:51 +03:00
|
|
|
|
|
|
|
// Uniform locations
|
2016-05-31 20:12:37 +03:00
|
|
|
int mvpLoc; // ModelView-Projection matrix uniform location point (vertex shader)
|
|
|
|
int tintColorLoc; // Color uniform location point (fragment shader)
|
2015-08-05 20:18:40 +03:00
|
|
|
|
2016-05-25 17:19:57 +03:00
|
|
|
// Texture map locations (generic for any kind of map)
|
2016-05-31 20:12:37 +03:00
|
|
|
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)
|
2015-03-01 18:00:52 +03:00
|
|
|
} Shader;
|
|
|
|
|
2015-08-05 20:18:40 +03:00
|
|
|
// Texture2D type
|
2016-01-21 03:03:43 +03:00
|
|
|
// NOTE: Data stored in GPU memory
|
2015-08-05 20:18:40 +03:00
|
|
|
typedef struct Texture2D {
|
2016-01-21 03:03:43 +03:00
|
|
|
unsigned int id; // OpenGL texture id
|
|
|
|
int width; // Texture base width
|
|
|
|
int height; // Texture base height
|
|
|
|
int mipmaps; // Mipmap levels, 1 by default
|
|
|
|
int format; // Data format (TextureFormat)
|
2015-08-05 20:18:40 +03:00
|
|
|
} Texture2D;
|
|
|
|
|
2016-03-30 21:09:16 +03:00
|
|
|
// RenderTexture2D type, for texture rendering
|
|
|
|
typedef struct RenderTexture2D {
|
|
|
|
unsigned int id; // Render texture (fbo) id
|
|
|
|
Texture2D texture; // Color buffer attachment texture
|
|
|
|
Texture2D depth; // Depth buffer attachment texture
|
|
|
|
} RenderTexture2D;
|
|
|
|
|
2016-03-06 04:05:16 +03:00
|
|
|
// Material type
|
|
|
|
typedef struct Material {
|
2016-05-31 20:12:37 +03:00
|
|
|
Shader shader; // Standard shader (supports 3 map types: diffuse, normal, specular)
|
2016-03-06 04:05:16 +03:00
|
|
|
|
2016-05-31 20:12:37 +03:00
|
|
|
Texture2D texDiffuse; // Diffuse texture
|
|
|
|
Texture2D texNormal; // Normal texture
|
|
|
|
Texture2D texSpecular; // Specular texture
|
2016-05-31 19:15:53 +03:00
|
|
|
|
2016-05-31 20:12:37 +03:00
|
|
|
Color colDiffuse; // Diffuse color
|
|
|
|
Color colAmbient; // Ambient color
|
|
|
|
Color colSpecular; // Specular color
|
2016-03-06 04:05:16 +03:00
|
|
|
|
2016-05-31 20:12:37 +03:00
|
|
|
float glossiness; // Glossiness level (Ranges from 0 to 1000)
|
2016-03-06 04:05:16 +03:00
|
|
|
} Material;
|
2016-05-20 13:28:07 +03:00
|
|
|
|
2016-05-31 20:12:37 +03:00
|
|
|
// 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;
|
|
|
|
|
2016-05-20 13:28:07 +03:00
|
|
|
// Light type
|
|
|
|
typedef struct LightData {
|
2016-05-31 20:12:37 +03:00
|
|
|
unsigned int id; // Light unique id
|
|
|
|
bool enabled; // Light enabled
|
2016-07-06 21:33:46 +03:00
|
|
|
int type; // Light type: LIGHT_POINT, LIGHT_DIRECTIONAL, LIGHT_SPOT
|
|
|
|
|
2016-05-31 20:12:37 +03:00
|
|
|
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)
|
2016-05-20 13:28:07 +03:00
|
|
|
|
2016-05-31 20:12:37 +03:00
|
|
|
Color diffuse; // Light diffuse color
|
|
|
|
float intensity; // Light intensity level
|
2016-05-20 13:28:07 +03:00
|
|
|
|
2016-05-31 20:12:37 +03:00
|
|
|
float coneAngle; // Light cone max angle: LIGHT_SPOT
|
2016-05-20 13:28:07 +03:00
|
|
|
} LightData, *Light;
|
2016-05-31 20:12:37 +03:00
|
|
|
|
|
|
|
// Light types
|
|
|
|
typedef enum { LIGHT_POINT, LIGHT_DIRECTIONAL, LIGHT_SPOT } LightType;
|
|
|
|
|
2015-08-07 18:24:28 +03:00
|
|
|
// Color blending modes (pre-defined)
|
|
|
|
typedef enum { BLEND_ALPHA = 0, BLEND_ADDITIVE, BLEND_MULTIPLIED } BlendMode;
|
2016-06-08 00:44:53 +03:00
|
|
|
|
|
|
|
// TraceLog message types
|
|
|
|
typedef enum { INFO = 0, ERROR, WARNING, DEBUG, OTHER } TraceLogType;
|
2016-07-16 20:25:15 +03:00
|
|
|
|
|
|
|
// Head Mounted Display devices
|
|
|
|
typedef enum {
|
|
|
|
HMD_DEFAULT_DEVICE = 0,
|
|
|
|
HMD_OCULUS_RIFT_DK2,
|
|
|
|
HMD_OCULUS_RIFT_CV1,
|
|
|
|
HMD_VALVE_HTC_VIVE,
|
|
|
|
HMD_SAMSUNG_GEAR_VR,
|
|
|
|
HMD_GOOGLE_CARDBOARD,
|
|
|
|
HMD_SONY_PLAYSTATION_VR,
|
|
|
|
HMD_RAZER_OSVR,
|
|
|
|
HMD_FOVE_VR,
|
|
|
|
} HmdDevice;
|
2014-04-04 22:11:57 +04:00
|
|
|
#endif
|
|
|
|
|
2014-03-25 15:40:35 +04:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" { // Prevents name mangling of functions
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------------
|
|
|
|
// Functions Declaration - Matrix operations
|
|
|
|
//------------------------------------------------------------------------------------
|
|
|
|
void rlMatrixMode(int mode); // Choose the current matrix to be transformed
|
2014-09-03 19:06:10 +04:00
|
|
|
void rlPushMatrix(void); // Push the current matrix to stack
|
|
|
|
void rlPopMatrix(void); // Pop lattest inserted matrix from stack
|
|
|
|
void rlLoadIdentity(void); // Reset current matrix to identity matrix
|
2014-03-25 15:40:35 +04:00
|
|
|
void rlTranslatef(float x, float y, float z); // Multiply the current matrix by a translation matrix
|
|
|
|
void rlRotatef(float angleDeg, float x, float y, float z); // Multiply the current matrix by a rotation matrix
|
|
|
|
void rlScalef(float x, float y, float z); // Multiply the current matrix by a scaling matrix
|
|
|
|
void rlMultMatrixf(float *mat); // Multiply the current matrix by another matrix
|
|
|
|
void rlFrustum(double left, double right, double bottom, double top, double near, double far);
|
|
|
|
void rlOrtho(double left, double right, double bottom, double top, double near, double far);
|
2016-05-29 12:49:13 +03:00
|
|
|
void rlViewport(int x, int y, int width, int height); // Set the viewport area
|
2014-03-25 15:40:35 +04:00
|
|
|
|
|
|
|
//------------------------------------------------------------------------------------
|
|
|
|
// Functions Declaration - Vertex level operations
|
|
|
|
//------------------------------------------------------------------------------------
|
|
|
|
void rlBegin(int mode); // Initialize drawing mode (how to organize vertex)
|
2014-09-03 19:06:10 +04:00
|
|
|
void rlEnd(void); // Finish vertex providing
|
2014-03-25 15:40:35 +04:00
|
|
|
void rlVertex2i(int x, int y); // Define one vertex (position) - 2 int
|
|
|
|
void rlVertex2f(float x, float y); // Define one vertex (position) - 2 float
|
|
|
|
void rlVertex3f(float x, float y, float z); // Define one vertex (position) - 3 float
|
|
|
|
void rlTexCoord2f(float x, float y); // Define one vertex (texture coordinate) - 2 float
|
|
|
|
void rlNormal3f(float x, float y, float z); // Define one vertex (normal) - 3 float
|
|
|
|
void rlColor4ub(byte r, byte g, byte b, byte a); // Define one vertex (color) - 4 byte
|
|
|
|
void rlColor3f(float x, float y, float z); // Define one vertex (color) - 3 float
|
|
|
|
void rlColor4f(float x, float y, float z, float w); // Define one vertex (color) - 4 float
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------------
|
|
|
|
// Functions Declaration - OpenGL equivalent functions (common to 1.1, 3.3+, ES2)
|
|
|
|
// NOTE: This functions are used to completely abstract raylib code from OpenGL layer
|
|
|
|
//------------------------------------------------------------------------------------
|
2014-09-17 00:51:31 +04:00
|
|
|
void rlEnableTexture(unsigned int id); // Enable texture usage
|
|
|
|
void rlDisableTexture(void); // Disable texture usage
|
2016-03-30 21:09:16 +03:00
|
|
|
void rlEnableRenderTexture(unsigned int id); // Enable render texture (fbo)
|
|
|
|
void rlDisableRenderTexture(void); // Disable render texture (fbo), return to default framebuffer
|
2016-03-17 15:51:48 +03:00
|
|
|
void rlEnableDepthTest(void); // Enable depth test
|
|
|
|
void rlDisableDepthTest(void); // Disable depth test
|
2016-05-18 14:22:14 +03:00
|
|
|
void rlEnableWireMode(void); // Enable wire mode
|
|
|
|
void rlDisableWireMode(void); // Disable wire mode
|
2014-09-17 00:51:31 +04:00
|
|
|
void rlDeleteTextures(unsigned int id); // Delete OpenGL texture from GPU
|
2016-03-30 21:09:16 +03:00
|
|
|
void rlDeleteRenderTextures(RenderTexture2D target); // Delete render textures (fbo) from GPU
|
2015-02-02 02:57:08 +03:00
|
|
|
void rlDeleteShader(unsigned int id); // Delete OpenGL shader program from GPU
|
2014-09-17 00:51:31 +04:00
|
|
|
void rlDeleteVertexArrays(unsigned int id); // Unload vertex data (VAO) from GPU memory
|
|
|
|
void rlDeleteBuffers(unsigned int id); // Unload vertex data (VBO) from GPU memory
|
2014-03-25 15:40:35 +04:00
|
|
|
void rlClearColor(byte r, byte g, byte b, byte a); // Clear color buffer with color
|
2014-09-17 00:51:31 +04:00
|
|
|
void rlClearScreenBuffers(void); // Clear used screen buffers (color and depth)
|
|
|
|
int rlGetVersion(void); // Returns current OpenGL version
|
2014-03-25 15:40:35 +04:00
|
|
|
|
|
|
|
//------------------------------------------------------------------------------------
|
|
|
|
// Functions Declaration - rlgl functionality
|
|
|
|
//------------------------------------------------------------------------------------
|
2016-06-26 15:13:11 +03:00
|
|
|
void rlglInit(int width, int height); // Initialize rlgl (buffers, shaders, textures, states)
|
2014-09-03 19:06:10 +04:00
|
|
|
void rlglClose(void); // De-init rlgl
|
2014-09-17 00:51:31 +04:00
|
|
|
void rlglDraw(void); // Draw VAO/VBO
|
2016-06-14 16:42:04 +03:00
|
|
|
void rlglLoadExtensions(void *loader); // Load OpenGL extensions
|
2014-09-17 00:51:31 +04:00
|
|
|
|
2015-11-04 20:33:46 +03:00
|
|
|
unsigned int rlglLoadTexture(void *data, int width, int height, int textureFormat, int mipmapCount); // Load texture in GPU
|
2016-03-30 21:09:16 +03:00
|
|
|
RenderTexture2D rlglLoadRenderTexture(int width, int height); // Load a texture to be used for rendering (fbo with color and depth attachments)
|
2015-11-04 20:33:46 +03:00
|
|
|
void rlglUpdateTexture(unsigned int id, int width, int height, int format, void *data); // Update GPU texture with new data
|
2016-01-04 17:09:44 +03:00
|
|
|
void rlglGenerateMipmaps(Texture2D texture); // Generate mipmap data for selected texture
|
2016-05-18 14:22:14 +03:00
|
|
|
|
2016-05-20 10:36:02 +03:00
|
|
|
void rlglLoadMesh(Mesh *mesh, bool dynamic); // Upload vertex data into GPU and provided VAO/VBO ids
|
2016-05-18 14:22:14 +03:00
|
|
|
void rlglUpdateMesh(Mesh mesh, int buffer, int numVertex); // Update vertex data on GPU (upload new data to one buffer)
|
|
|
|
void rlglDrawMesh(Mesh mesh, Material material, Matrix transform); // Draw a 3d mesh with material and transform
|
|
|
|
void rlglUnloadMesh(Mesh *mesh); // Unload mesh data from CPU and GPU
|
2014-04-19 18:36:49 +04:00
|
|
|
|
2015-11-05 14:32:47 +03:00
|
|
|
Vector3 rlglUnproject(Vector3 source, Matrix proj, Matrix view); // Get world coordinates from screen coordinates
|
2015-04-06 15:02:29 +03:00
|
|
|
|
2015-11-05 14:32:47 +03:00
|
|
|
unsigned char *rlglReadScreenPixels(int width, int height); // Read screen pixel data (color buffer)
|
|
|
|
void *rlglReadTexturePixels(Texture2D texture); // Read texture pixel data
|
2014-03-25 15:40:35 +04:00
|
|
|
|
2016-05-07 19:07:15 +03:00
|
|
|
// NOTE: There is a set of shader related functions that are available to end user,
|
|
|
|
// to avoid creating function wrappers through core module, they have been directly declared in raylib.h
|
|
|
|
|
2015-08-05 20:18:40 +03:00
|
|
|
#if defined(RLGL_STANDALONE)
|
|
|
|
//------------------------------------------------------------------------------------
|
|
|
|
// Shaders System Functions (Module: rlgl)
|
|
|
|
// NOTE: This functions are useless when using OpenGL 1.1
|
|
|
|
//------------------------------------------------------------------------------------
|
|
|
|
Shader LoadShader(char *vsFileName, char *fsFileName); // Load a custom shader and bind default locations
|
|
|
|
void UnloadShader(Shader shader); // Unload a custom shader from memory
|
2016-05-31 18:11:02 +03:00
|
|
|
|
2016-05-07 19:07:15 +03:00
|
|
|
Shader GetDefaultShader(void); // Get default shader
|
2016-05-31 18:11:02 +03:00
|
|
|
Shader GetStandardShader(void); // Get default shader
|
2016-05-07 19:07:15 +03:00
|
|
|
Texture2D GetDefaultTexture(void); // Get default texture
|
2015-08-05 20:18:40 +03:00
|
|
|
|
2016-05-03 20:20:25 +03:00
|
|
|
int GetShaderLocation(Shader shader, const char *uniformName); // Get shader uniform location
|
|
|
|
void SetShaderValue(Shader shader, int uniformLoc, float *value, int size); // Set shader uniform value (float)
|
|
|
|
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)
|
2015-08-07 18:24:28 +03:00
|
|
|
|
2016-06-02 21:23:09 +03:00
|
|
|
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)
|
|
|
|
|
2016-05-31 18:11:02 +03:00
|
|
|
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)
|
2016-05-20 13:28:07 +03:00
|
|
|
|
|
|
|
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
|
2016-06-08 00:44:53 +03:00
|
|
|
|
|
|
|
void TraceLog(int msgType, const char *text, ...);
|
2016-07-16 23:41:13 +03:00
|
|
|
float *MatrixToFloat(Matrix mat);
|
2015-08-05 20:18:40 +03:00
|
|
|
|
2016-07-06 01:54:38 +03:00
|
|
|
void InitVrDevice(int hmdDevice); // Init VR device
|
|
|
|
void CloseVrDevice(void); // Close VR device
|
|
|
|
void UpdateVrTracking(void); // Update VR tracking (position and orientation)
|
|
|
|
void BeginVrDrawing(void); // Begin VR drawing configuration
|
|
|
|
void EndVrDrawing(void); // End VR drawing process (and desktop mirror)
|
|
|
|
bool IsVrDeviceReady(void); // Detect if VR device (or simulator) is ready
|
|
|
|
void ToggleVrMode(void); // Enable/Disable VR experience (device or simulator)
|
2016-07-16 23:41:13 +03:00
|
|
|
|
|
|
|
// Oculus Rift API for direct access the device (no simulator)
|
|
|
|
bool InitOculusDevice(void); // Initialize Oculus device (returns true if success)
|
|
|
|
void CloseOculusDevice(void); // Close Oculus device
|
|
|
|
void UpdateOculusTracking(void); // Update Oculus head position-orientation tracking
|
|
|
|
void BeginOculusDrawing(void); // Setup Oculus buffers for drawing
|
|
|
|
void EndOculusDrawing(void); // Finish Oculus drawing and blit framebuffer to mirror
|
2016-07-06 01:54:38 +03:00
|
|
|
#endif
|
2016-06-14 18:16:20 +03:00
|
|
|
|
2014-03-25 15:40:35 +04:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif // RLGL_H
|