rlgl.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500
  1. /**********************************************************************************************
  2. *
  3. * rlgl - raylib OpenGL abstraction layer
  4. *
  5. * rlgl is a wrapper for multiple OpenGL versions (1.1, 2.1, 3.3 Core, ES 2.0) to
  6. * pseudo-OpenGL 1.1 style functions (rlVertex, rlTranslate, rlRotate...).
  7. *
  8. * When chosing an OpenGL version greater than OpenGL 1.1, rlgl stores vertex data on internal
  9. * VBO buffers (and VAOs if available). It requires calling 3 functions:
  10. * rlglInit() - Initialize internal buffers and auxiliar resources
  11. * rlglDraw() - Process internal buffers and send required draw calls
  12. * rlglClose() - De-initialize internal buffers data and other auxiliar resources
  13. *
  14. * CONFIGURATION:
  15. *
  16. * #define GRAPHICS_API_OPENGL_11
  17. * #define GRAPHICS_API_OPENGL_21
  18. * #define GRAPHICS_API_OPENGL_33
  19. * #define GRAPHICS_API_OPENGL_ES2
  20. * Use selected OpenGL graphics backend, should be supported by platform
  21. * Those preprocessor defines are only used on rlgl module, if OpenGL version is
  22. * required by any other module, use rlGetVersion() tocheck it
  23. *
  24. * #define RLGL_STANDALONE
  25. * Use rlgl as standalone library (no raylib dependency)
  26. *
  27. * #define SUPPORT_VR_SIMULATOR
  28. * Support VR simulation functionality (stereo rendering)
  29. *
  30. * #define SUPPORT_DISTORTION_SHADER
  31. * Include stereo rendering distortion shader (shader_distortion.h)
  32. *
  33. * DEPENDENCIES:
  34. * raymath - 3D math functionality (Vector3, Matrix, Quaternion)
  35. * GLAD - OpenGL extensions loading (OpenGL 3.3 Core only)
  36. *
  37. *
  38. * LICENSE: zlib/libpng
  39. *
  40. * Copyright (c) 2014-2017 Ramon Santamaria (@raysan5)
  41. *
  42. * This software is provided "as-is", without any express or implied warranty. In no event
  43. * will the authors be held liable for any damages arising from the use of this software.
  44. *
  45. * Permission is granted to anyone to use this software for any purpose, including commercial
  46. * applications, and to alter it and redistribute it freely, subject to the following restrictions:
  47. *
  48. * 1. The origin of this software must not be misrepresented; you must not claim that you
  49. * wrote the original software. If you use this software in a product, an acknowledgment
  50. * in the product documentation would be appreciated but is not required.
  51. *
  52. * 2. Altered source versions must be plainly marked as such, and must not be misrepresented
  53. * as being the original software.
  54. *
  55. * 3. This notice may not be removed or altered from any source distribution.
  56. *
  57. **********************************************************************************************/
  58. #ifndef RLGL_H
  59. #define RLGL_H
  60. #if defined(RLGL_STANDALONE)
  61. #define RAYMATH_STANDALONE
  62. #else
  63. #include "raylib.h" // Required for: Model, Shader, Texture2D, TraceLog()
  64. #endif
  65. #include "raymath.h" // Required for: Vector3, Matrix
  66. // Security check in case no GRAPHICS_API_OPENGL_* defined
  67. #if !defined(GRAPHICS_API_OPENGL_11) && !defined(GRAPHICS_API_OPENGL_21) && !defined(GRAPHICS_API_OPENGL_33) && !defined(GRAPHICS_API_OPENGL_ES2)
  68. #define GRAPHICS_API_OPENGL_33
  69. #endif
  70. // Security check in case multiple GRAPHICS_API_OPENGL_* defined
  71. #if defined(GRAPHICS_API_OPENGL_11)
  72. #if defined(GRAPHICS_API_OPENGL_21)
  73. #undef GRAPHICS_API_OPENGL_21
  74. #endif
  75. #if defined(GRAPHICS_API_OPENGL_33)
  76. #undef GRAPHICS_API_OPENGL_33
  77. #endif
  78. #if defined(GRAPHICS_API_OPENGL_ES2)
  79. #undef GRAPHICS_API_OPENGL_ES2
  80. #endif
  81. #endif
  82. #if defined(GRAPHICS_API_OPENGL_21)
  83. #define GRAPHICS_API_OPENGL_33
  84. #endif
  85. //----------------------------------------------------------------------------------
  86. // Defines and Macros
  87. //----------------------------------------------------------------------------------
  88. #if defined(GRAPHICS_API_OPENGL_11) || defined(GRAPHICS_API_OPENGL_33)
  89. // NOTE: This is the maximum amount of lines, triangles and quads per frame, be careful!
  90. #define MAX_LINES_BATCH 8192
  91. #define MAX_TRIANGLES_BATCH 4096
  92. #define MAX_QUADS_BATCH 8192
  93. #elif defined(GRAPHICS_API_OPENGL_ES2)
  94. // NOTE: Reduce memory sizes for embedded systems (RPI and HTML5)
  95. // NOTE: On HTML5 (emscripten) this is allocated on heap, by default it's only 16MB!...just take care...
  96. #define MAX_LINES_BATCH 1024 // Critical for wire shapes (sphere)
  97. #define MAX_TRIANGLES_BATCH 2048 // Critical for some shapes (sphere)
  98. #define MAX_QUADS_BATCH 1024 // Be careful with text, every letter maps a quad
  99. #endif
  100. // Texture parameters (equivalent to OpenGL defines)
  101. #define RL_TEXTURE_WRAP_S 0x2802 // GL_TEXTURE_WRAP_S
  102. #define RL_TEXTURE_WRAP_T 0x2803 // GL_TEXTURE_WRAP_T
  103. #define RL_TEXTURE_MAG_FILTER 0x2800 // GL_TEXTURE_MAG_FILTER
  104. #define RL_TEXTURE_MIN_FILTER 0x2801 // GL_TEXTURE_MIN_FILTER
  105. #define RL_TEXTURE_ANISOTROPIC_FILTER 0x3000 // Anisotropic filter (custom identifier)
  106. #define RL_FILTER_NEAREST 0x2600 // GL_NEAREST
  107. #define RL_FILTER_LINEAR 0x2601 // GL_LINEAR
  108. #define RL_FILTER_MIP_NEAREST 0x2700 // GL_NEAREST_MIPMAP_NEAREST
  109. #define RL_FILTER_NEAREST_MIP_LINEAR 0x2702 // GL_NEAREST_MIPMAP_LINEAR
  110. #define RL_FILTER_LINEAR_MIP_NEAREST 0x2701 // GL_LINEAR_MIPMAP_NEAREST
  111. #define RL_FILTER_MIP_LINEAR 0x2703 // GL_LINEAR_MIPMAP_LINEAR
  112. #define RL_WRAP_REPEAT 0x2901 // GL_REPEAT
  113. #define RL_WRAP_CLAMP 0x812F // GL_CLAMP_TO_EDGE
  114. #define RL_WRAP_CLAMP_MIRROR 0x8742 // GL_MIRROR_CLAMP_EXT
  115. // Matrix modes (equivalent to OpenGL)
  116. #define RL_MODELVIEW 0x1700 // GL_MODELVIEW
  117. #define RL_PROJECTION 0x1701 // GL_PROJECTION
  118. #define RL_TEXTURE 0x1702 // GL_TEXTURE
  119. // Primitive assembly draw modes
  120. #define RL_LINES 0x0001 // GL_LINES
  121. #define RL_TRIANGLES 0x0004 // GL_TRIANGLES
  122. #define RL_QUADS 0x0007 // GL_QUADS
  123. //----------------------------------------------------------------------------------
  124. // Types and Structures Definition
  125. //----------------------------------------------------------------------------------
  126. typedef enum { OPENGL_11 = 1, OPENGL_21, OPENGL_33, OPENGL_ES_20 } GlVersion;
  127. typedef unsigned char byte;
  128. #if defined(RLGL_STANDALONE)
  129. #ifndef __cplusplus
  130. // Boolean type
  131. typedef enum { false, true } bool;
  132. #endif
  133. // Color type, RGBA (32bit)
  134. typedef struct Color {
  135. unsigned char r;
  136. unsigned char g;
  137. unsigned char b;
  138. unsigned char a;
  139. } Color;
  140. // Rectangle type
  141. typedef struct Rectangle {
  142. int x;
  143. int y;
  144. int width;
  145. int height;
  146. } Rectangle;
  147. // Texture2D type
  148. // NOTE: Data stored in GPU memory
  149. typedef struct Texture2D {
  150. unsigned int id; // OpenGL texture id
  151. int width; // Texture base width
  152. int height; // Texture base height
  153. int mipmaps; // Mipmap levels, 1 by default
  154. int format; // Data format (PixelFormat)
  155. } Texture2D;
  156. // RenderTexture2D type, for texture rendering
  157. typedef struct RenderTexture2D {
  158. unsigned int id; // Render texture (fbo) id
  159. Texture2D texture; // Color buffer attachment texture
  160. Texture2D depth; // Depth buffer attachment texture
  161. } RenderTexture2D;
  162. // Vertex data definning a mesh
  163. typedef struct Mesh {
  164. int vertexCount; // number of vertices stored in arrays
  165. int triangleCount; // number of triangles stored (indexed or not)
  166. float *vertices; // vertex position (XYZ - 3 components per vertex) (shader-location = 0)
  167. float *texcoords; // vertex texture coordinates (UV - 2 components per vertex) (shader-location = 1)
  168. float *texcoords2; // vertex second texture coordinates (useful for lightmaps) (shader-location = 5)
  169. float *normals; // vertex normals (XYZ - 3 components per vertex) (shader-location = 2)
  170. float *tangents; // vertex tangents (XYZW - 4 components per vertex) (shader-location = 4)
  171. unsigned char *colors; // vertex colors (RGBA - 4 components per vertex) (shader-location = 3)
  172. unsigned short *indices;// vertex indices (in case vertex data comes indexed)
  173. unsigned int vaoId; // OpenGL Vertex Array Object id
  174. unsigned int vboId[7]; // OpenGL Vertex Buffer Objects id (7 types of vertex data)
  175. } Mesh;
  176. // Shader and material limits
  177. #define MAX_SHADER_LOCATIONS 32
  178. #define MAX_MATERIAL_MAPS 12
  179. // Shader type (generic)
  180. typedef struct Shader {
  181. unsigned int id; // Shader program id
  182. int locs[MAX_SHADER_LOCATIONS]; // Shader locations array
  183. } Shader;
  184. // Material texture map
  185. typedef struct MaterialMap {
  186. Texture2D texture; // Material map texture
  187. Color color; // Material map color
  188. float value; // Material map value
  189. } MaterialMap;
  190. // Material type (generic)
  191. typedef struct Material {
  192. Shader shader; // Material shader
  193. MaterialMap maps[MAX_MATERIAL_MAPS]; // Material maps
  194. float *params; // Material generic parameters (if required)
  195. } Material;
  196. // Camera type, defines a camera position/orientation in 3d space
  197. typedef struct Camera {
  198. Vector3 position; // Camera position
  199. Vector3 target; // Camera target it looks-at
  200. Vector3 up; // Camera up vector (rotation over its axis)
  201. float fovy; // Camera field-of-view apperture in Y (degrees)
  202. } Camera;
  203. // Head-Mounted-Display device parameters
  204. typedef struct VrDeviceInfo {
  205. int hResolution; // HMD horizontal resolution in pixels
  206. int vResolution; // HMD vertical resolution in pixels
  207. float hScreenSize; // HMD horizontal size in meters
  208. float vScreenSize; // HMD vertical size in meters
  209. float vScreenCenter; // HMD screen center in meters
  210. float eyeToScreenDistance; // HMD distance between eye and display in meters
  211. float lensSeparationDistance; // HMD lens separation distance in meters
  212. float interpupillaryDistance; // HMD IPD (distance between pupils) in meters
  213. float lensDistortionValues[4]; // HMD lens distortion constant parameters
  214. float chromaAbCorrection[4]; // HMD chromatic aberration correction parameters
  215. } VrDeviceInfo;
  216. // TraceLog message types
  217. typedef enum {
  218. LOG_INFO = 0,
  219. LOG_ERROR,
  220. LOG_WARNING,
  221. LOG_DEBUG,
  222. LOG_OTHER
  223. } TraceLogType;
  224. // Texture formats (support depends on OpenGL version)
  225. typedef enum {
  226. UNCOMPRESSED_GRAYSCALE = 1, // 8 bit per pixel (no alpha)
  227. UNCOMPRESSED_GRAY_ALPHA,
  228. UNCOMPRESSED_R5G6B5, // 16 bpp
  229. UNCOMPRESSED_R8G8B8, // 24 bpp
  230. UNCOMPRESSED_R5G5B5A1, // 16 bpp (1 bit alpha)
  231. UNCOMPRESSED_R4G4B4A4, // 16 bpp (4 bit alpha)
  232. UNCOMPRESSED_R8G8B8A8, // 32 bpp
  233. UNCOMPRESSED_R32, // 32 bpp (1 channel - float)
  234. UNCOMPRESSED_R32G32B32, // 32*3 bpp (3 channels - float)
  235. UNCOMPRESSED_R32G32B32A32, // 32*4 bpp (4 channels - float)
  236. COMPRESSED_DXT1_RGB, // 4 bpp (no alpha)
  237. COMPRESSED_DXT1_RGBA, // 4 bpp (1 bit alpha)
  238. COMPRESSED_DXT3_RGBA, // 8 bpp
  239. COMPRESSED_DXT5_RGBA, // 8 bpp
  240. COMPRESSED_ETC1_RGB, // 4 bpp
  241. COMPRESSED_ETC2_RGB, // 4 bpp
  242. COMPRESSED_ETC2_EAC_RGBA, // 8 bpp
  243. COMPRESSED_PVRT_RGB, // 4 bpp
  244. COMPRESSED_PVRT_RGBA, // 4 bpp
  245. COMPRESSED_ASTC_4x4_RGBA, // 8 bpp
  246. COMPRESSED_ASTC_8x8_RGBA // 2 bpp
  247. } PixelFormat;
  248. // Texture parameters: filter mode
  249. // NOTE 1: Filtering considers mipmaps if available in the texture
  250. // NOTE 2: Filter is accordingly set for minification and magnification
  251. typedef enum {
  252. FILTER_POINT = 0, // No filter, just pixel aproximation
  253. FILTER_BILINEAR, // Linear filtering
  254. FILTER_TRILINEAR, // Trilinear filtering (linear with mipmaps)
  255. FILTER_ANISOTROPIC_4X, // Anisotropic filtering 4x
  256. FILTER_ANISOTROPIC_8X, // Anisotropic filtering 8x
  257. FILTER_ANISOTROPIC_16X, // Anisotropic filtering 16x
  258. } TextureFilterMode;
  259. // Texture parameters: wrap mode
  260. typedef enum {
  261. WRAP_REPEAT = 0,
  262. WRAP_CLAMP,
  263. WRAP_MIRROR
  264. } TextureWrapMode;
  265. // Color blending modes (pre-defined)
  266. typedef enum {
  267. BLEND_ALPHA = 0,
  268. BLEND_ADDITIVE,
  269. BLEND_MULTIPLIED
  270. } BlendMode;
  271. // Shader location point type
  272. typedef enum {
  273. LOC_VERTEX_POSITION = 0,
  274. LOC_VERTEX_TEXCOORD01,
  275. LOC_VERTEX_TEXCOORD02,
  276. LOC_VERTEX_NORMAL,
  277. LOC_VERTEX_TANGENT,
  278. LOC_VERTEX_COLOR,
  279. LOC_MATRIX_MVP,
  280. LOC_MATRIX_MODEL,
  281. LOC_MATRIX_VIEW,
  282. LOC_MATRIX_PROJECTION,
  283. LOC_VECTOR_VIEW,
  284. LOC_COLOR_DIFFUSE,
  285. LOC_COLOR_SPECULAR,
  286. LOC_COLOR_AMBIENT,
  287. LOC_MAP_ALBEDO, // LOC_MAP_DIFFUSE
  288. LOC_MAP_METALNESS, // LOC_MAP_SPECULAR
  289. LOC_MAP_NORMAL,
  290. LOC_MAP_ROUGHNESS,
  291. LOC_MAP_OCCLUSION,
  292. LOC_MAP_EMISSION,
  293. LOC_MAP_HEIGHT,
  294. LOC_MAP_CUBEMAP,
  295. LOC_MAP_IRRADIANCE,
  296. LOC_MAP_PREFILTER,
  297. LOC_MAP_BRDF
  298. } ShaderLocationIndex;
  299. #define LOC_MAP_DIFFUSE LOC_MAP_ALBEDO
  300. #define LOC_MAP_SPECULAR LOC_MAP_METALNESS
  301. // Material map type
  302. typedef enum {
  303. MAP_ALBEDO = 0, // MAP_DIFFUSE
  304. MAP_METALNESS = 1, // MAP_SPECULAR
  305. MAP_NORMAL = 2,
  306. MAP_ROUGHNESS = 3,
  307. MAP_OCCLUSION,
  308. MAP_EMISSION,
  309. MAP_HEIGHT,
  310. MAP_CUBEMAP, // NOTE: Uses GL_TEXTURE_CUBE_MAP
  311. MAP_IRRADIANCE, // NOTE: Uses GL_TEXTURE_CUBE_MAP
  312. MAP_PREFILTER, // NOTE: Uses GL_TEXTURE_CUBE_MAP
  313. MAP_BRDF
  314. } TexmapIndex;
  315. #define MAP_DIFFUSE MAP_ALBEDO
  316. #define MAP_SPECULAR MAP_METALNESS
  317. // VR Head Mounted Display devices
  318. typedef enum {
  319. HMD_DEFAULT_DEVICE = 0,
  320. HMD_OCULUS_RIFT_DK2,
  321. HMD_OCULUS_RIFT_CV1,
  322. HMD_OCULUS_GO,
  323. HMD_VALVE_HTC_VIVE,
  324. HMD_SONY_PSVR
  325. } VrDevice;
  326. #endif
  327. #ifdef __cplusplus
  328. extern "C" { // Prevents name mangling of functions
  329. #endif
  330. //------------------------------------------------------------------------------------
  331. // Functions Declaration - Matrix operations
  332. //------------------------------------------------------------------------------------
  333. void rlMatrixMode(int mode); // Choose the current matrix to be transformed
  334. void rlPushMatrix(void); // Push the current matrix to stack
  335. void rlPopMatrix(void); // Pop lattest inserted matrix from stack
  336. void rlLoadIdentity(void); // Reset current matrix to identity matrix
  337. void rlTranslatef(float x, float y, float z); // Multiply the current matrix by a translation matrix
  338. void rlRotatef(float angleDeg, float x, float y, float z); // Multiply the current matrix by a rotation matrix
  339. void rlScalef(float x, float y, float z); // Multiply the current matrix by a scaling matrix
  340. void rlMultMatrixf(float *matf); // Multiply the current matrix by another matrix
  341. void rlFrustum(double left, double right, double bottom, double top, double near, double far);
  342. void rlOrtho(double left, double right, double bottom, double top, double near, double far);
  343. void rlViewport(int x, int y, int width, int height); // Set the viewport area
  344. //------------------------------------------------------------------------------------
  345. // Functions Declaration - Vertex level operations
  346. //------------------------------------------------------------------------------------
  347. void rlBegin(int mode); // Initialize drawing mode (how to organize vertex)
  348. void rlEnd(void); // Finish vertex providing
  349. void rlVertex2i(int x, int y); // Define one vertex (position) - 2 int
  350. void rlVertex2f(float x, float y); // Define one vertex (position) - 2 float
  351. void rlVertex3f(float x, float y, float z); // Define one vertex (position) - 3 float
  352. void rlTexCoord2f(float x, float y); // Define one vertex (texture coordinate) - 2 float
  353. void rlNormal3f(float x, float y, float z); // Define one vertex (normal) - 3 float
  354. void rlColor4ub(byte r, byte g, byte b, byte a); // Define one vertex (color) - 4 byte
  355. void rlColor3f(float x, float y, float z); // Define one vertex (color) - 3 float
  356. void rlColor4f(float x, float y, float z, float w); // Define one vertex (color) - 4 float
  357. //------------------------------------------------------------------------------------
  358. // Functions Declaration - OpenGL equivalent functions (common to 1.1, 3.3+, ES2)
  359. // NOTE: This functions are used to completely abstract raylib code from OpenGL layer
  360. //------------------------------------------------------------------------------------
  361. void rlEnableTexture(unsigned int id); // Enable texture usage
  362. void rlDisableTexture(void); // Disable texture usage
  363. void rlTextureParameters(unsigned int id, int param, int value); // Set texture parameters (filter, wrap)
  364. void rlEnableRenderTexture(unsigned int id); // Enable render texture (fbo)
  365. void rlDisableRenderTexture(void); // Disable render texture (fbo), return to default framebuffer
  366. void rlEnableDepthTest(void); // Enable depth test
  367. void rlDisableDepthTest(void); // Disable depth test
  368. void rlEnableWireMode(void); // Enable wire mode
  369. void rlDisableWireMode(void); // Disable wire mode
  370. void rlDeleteTextures(unsigned int id); // Delete OpenGL texture from GPU
  371. void rlDeleteRenderTextures(RenderTexture2D target); // Delete render textures (fbo) from GPU
  372. void rlDeleteShader(unsigned int id); // Delete OpenGL shader program from GPU
  373. void rlDeleteVertexArrays(unsigned int id); // Unload vertex data (VAO) from GPU memory
  374. void rlDeleteBuffers(unsigned int id); // Unload vertex data (VBO) from GPU memory
  375. void rlClearColor(byte r, byte g, byte b, byte a); // Clear color buffer with color
  376. void rlClearScreenBuffers(void); // Clear used screen buffers (color and depth)
  377. //------------------------------------------------------------------------------------
  378. // Functions Declaration - rlgl functionality
  379. //------------------------------------------------------------------------------------
  380. void rlglInit(int width, int height); // Initialize rlgl (buffers, shaders, textures, states)
  381. void rlglClose(void); // De-inititialize rlgl (buffers, shaders, textures)
  382. void rlglDraw(void); // Update and Draw default buffers (lines, triangles, quads)
  383. int rlGetVersion(void); // Returns current OpenGL version
  384. bool rlCheckBufferLimit(int type, int vCount); // Check internal buffer overflow for a given number of vertex
  385. void rlSetDebugMarker(const char *text); // Set debug marker for analysis
  386. void rlLoadExtensions(void *loader); // Load OpenGL extensions
  387. Vector3 rlUnproject(Vector3 source, Matrix proj, Matrix view); // Get world coordinates from screen coordinates
  388. // Textures data management
  389. unsigned int rlLoadTexture(void *data, int width, int height, int format, int mipmapCount); // Load texture in GPU
  390. void rlUpdateTexture(unsigned int id, int width, int height, int format, const void *data); // Update GPU texture with new data
  391. void rlUnloadTexture(unsigned int id);
  392. void rlGenerateMipmaps(Texture2D *texture); // Generate mipmap data for selected texture
  393. void *rlReadTexturePixels(Texture2D texture); // Read texture pixel data
  394. unsigned char *rlReadScreenPixels(int width, int height); // Read screen pixel data (color buffer)
  395. RenderTexture2D rlLoadRenderTexture(int width, int height); // Load a texture to be used for rendering (fbo with color and depth attachments)
  396. // Vertex data management
  397. void rlLoadMesh(Mesh *mesh, bool dynamic); // Upload vertex data into GPU and provided VAO/VBO ids
  398. void rlUpdateMesh(Mesh mesh, int buffer, int numVertex); // Update vertex data on GPU (upload new data to one buffer)
  399. void rlDrawMesh(Mesh mesh, Material material, Matrix transform); // Draw a 3d mesh with material and transform
  400. void rlUnloadMesh(Mesh *mesh); // Unload mesh data from CPU and GPU
  401. // NOTE: There is a set of shader related functions that are available to end user,
  402. // to avoid creating function wrappers through core module, they have been directly declared in raylib.h
  403. #if defined(RLGL_STANDALONE)
  404. //------------------------------------------------------------------------------------
  405. // Shaders System Functions (Module: rlgl)
  406. // NOTE: This functions are useless when using OpenGL 1.1
  407. //------------------------------------------------------------------------------------
  408. Shader LoadShader(char *vsFileName, char *fsFileName); // Load a custom shader and bind default locations
  409. void UnloadShader(Shader shader); // Unload a custom shader from memory
  410. Shader GetShaderDefault(void); // Get default shader
  411. Texture2D GetTextureDefault(void); // Get default texture
  412. // Shader configuration functions
  413. int GetShaderLocation(Shader shader, const char *uniformName); // Get shader uniform location
  414. void SetShaderValue(Shader shader, int uniformLoc, const float *value, int size); // Set shader uniform value (float)
  415. void SetShaderValuei(Shader shader, int uniformLoc, const int *value, int size); // Set shader uniform value (int)
  416. void SetShaderValueMatrix(Shader shader, int uniformLoc, Matrix mat); // Set shader uniform value (matrix 4x4)
  417. void SetMatrixProjection(Matrix proj); // Set a custom projection matrix (replaces internal projection matrix)
  418. void SetMatrixModelview(Matrix view); // Set a custom modelview matrix (replaces internal modelview matrix)
  419. Matrix GetMatrixModelview(); // Get internal modelview matrix
  420. // Texture maps generation (PBR)
  421. // NOTE: Required shaders should be provided
  422. Texture2D GenTextureCubemap(Shader shader, Texture2D skyHDR, int size); // Generate cubemap texture from HDR texture
  423. Texture2D GenTextureIrradiance(Shader shader, Texture2D cubemap, int size); // Generate irradiance texture using cubemap data
  424. Texture2D GenTexturePrefilter(Shader shader, Texture2D cubemap, int size); // Generate prefilter texture using cubemap data
  425. Texture2D GenTextureBRDF(Shader shader, Texture2D cubemap, int size); // Generate BRDF texture using cubemap data
  426. // Shading and blending
  427. void BeginShaderMode(Shader shader); // Begin custom shader drawing
  428. void EndShaderMode(void); // End custom shader drawing (use default shader)
  429. void BeginBlendMode(int mode); // Begin blending mode (alpha, additive, multiplied)
  430. void EndBlendMode(void); // End blending mode (reset to default: alpha blending)
  431. // VR simulator functionality
  432. VrDeviceInfo GetVrDeviceInfo(int vrDeviceType); // Get VR device information for some standard devices
  433. void InitVrSimulator(VrDeviceInfo info); // Init VR simulator for selected device parameters
  434. void CloseVrSimulator(void); // Close VR simulator for current device
  435. void UpdateVrTracking(Camera *camera); // Update VR tracking (position and orientation) and camera
  436. void ToggleVrMode(void); // Enable/Disable VR experience (device or simulator)
  437. void BeginVrDrawing(void); // Begin VR stereo rendering
  438. void EndVrDrawing(void); // End VR stereo rendering
  439. void TraceLog(int msgType, const char *text, ...); // Show trace log messages (LOG_INFO, LOG_WARNING, LOG_ERROR, LOG_DEBUG)
  440. #endif
  441. #ifdef __cplusplus
  442. }
  443. #endif
  444. #endif // RLGL_H