Merge branch 'raysan5:master' into master
1
.gitignore
vendored
|
|
@ -45,6 +45,7 @@ ipch/
|
||||||
*.db
|
*.db
|
||||||
*.opendb
|
*.opendb
|
||||||
packages/
|
packages/
|
||||||
|
!examples/models/resources/models/obj/
|
||||||
|
|
||||||
# Ignore compiled binaries
|
# Ignore compiled binaries
|
||||||
*.o
|
*.o
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
raylib is highly inspired by Borland BGI graphics lib and by XNA framework and it's specially well suited for prototyping, tooling, graphical applications, embedded systems and education.
|
raylib is highly inspired by Borland BGI graphics lib and by XNA framework and it's specially well suited for prototyping, tooling, graphical applications, embedded systems and education.
|
||||||
|
|
||||||
*NOTE for ADVENTURERS: raylib is a programming library to enjoy videogames programming; no fancy interface, no visual helpers, no auto-debugging... just coding in the most pure spartan-programmers way.*
|
*NOTE for ADVENTURERS: raylib is a programming library to enjoy videogames programming; no fancy interface, no visual helpers, no debug button... just coding in the most pure spartan-programmers way.*
|
||||||
|
|
||||||
Ready to learn? Jump to [code examples!](http://www.raylib.com/examples.html)
|
Ready to learn? Jump to [code examples!](http://www.raylib.com/examples.html)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,13 +39,13 @@ int main(void)
|
||||||
camera.fovy = 45.0f; // Camera field-of-view Y
|
camera.fovy = 45.0f; // Camera field-of-view Y
|
||||||
camera.projection = CAMERA_PERSPECTIVE; // Camera mode type
|
camera.projection = CAMERA_PERSPECTIVE; // Camera mode type
|
||||||
|
|
||||||
Model model = LoadModel("resources/models/castle.obj"); // Load model
|
Model model = LoadModel("resources/models/obj/castle.obj"); // Load model
|
||||||
Texture2D texture = LoadTexture("resources/models/castle_diffuse.png"); // Load model texture
|
Texture2D texture = LoadTexture("resources/models/obj/castle_diffuse.png"); // Load model texture
|
||||||
model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture; // Set map diffuse texture
|
model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture; // Set map diffuse texture
|
||||||
|
|
||||||
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
|
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
|
||||||
|
|
||||||
BoundingBox bounds = GetMeshBoundingBox(model.meshes[0]); // Set model bounds
|
BoundingBox bounds = GetMeshBoundingBox(model.meshes[0]); // Set model bounds
|
||||||
|
|
||||||
// NOTE: bounds are calculated from the original size of the model,
|
// NOTE: bounds are calculated from the original size of the model,
|
||||||
// if model is scaled on drawing, bounds must be also scaled
|
// if model is scaled on drawing, bounds must be also scaled
|
||||||
|
|
|
||||||
1725
examples/models/resources/models/obj/bridge.obj
Normal file
BIN
examples/models/resources/models/obj/bridge_diffuse.png
Normal file
|
After Width: | Height: | Size: 311 KiB |
12919
examples/models/resources/models/obj/castle.obj
Normal file
BIN
examples/models/resources/models/obj/castle_diffuse.png
Normal file
|
After Width: | Height: | Size: 434 KiB |
68
examples/models/resources/models/obj/cube.obj
Normal file
|
|
@ -0,0 +1,68 @@
|
||||||
|
# reference material
|
||||||
|
#mtllib cube.mtl
|
||||||
|
|
||||||
|
# object box
|
||||||
|
|
||||||
|
# vertex (XZY)
|
||||||
|
v 5.5 0 1.5
|
||||||
|
v 8.5 0 1.5
|
||||||
|
v 5.5 0 -1.5
|
||||||
|
v 8.5 0 -1.5
|
||||||
|
v 5.5 3 1.5
|
||||||
|
v 8.5 3 1.5
|
||||||
|
v 5.5 3 -1.5
|
||||||
|
v 8.5 3 -1.5
|
||||||
|
|
||||||
|
# normals (XYZ)
|
||||||
|
vn 0 -1 0
|
||||||
|
vn 0 1 0
|
||||||
|
vn 0 0 1
|
||||||
|
vn 1 0 0
|
||||||
|
vn 0 0 -1
|
||||||
|
vn -1 0 0
|
||||||
|
|
||||||
|
# UVs (XY)
|
||||||
|
vt 0.5 0 0
|
||||||
|
vt 1 0 0
|
||||||
|
vt 1 0.5 0
|
||||||
|
vt 0.5 0.5 0
|
||||||
|
vt 0.5 0.5 0
|
||||||
|
vt 1 0.5 0
|
||||||
|
vt 0.5 1 0
|
||||||
|
vt 1 1 0
|
||||||
|
vt 0 0.5 0
|
||||||
|
vt 1 0.5 0
|
||||||
|
vt 1 0 0
|
||||||
|
vt 0 0 0
|
||||||
|
vt 0 0.5 0
|
||||||
|
vt 1 0.5 0
|
||||||
|
vt 1 1 0
|
||||||
|
vt 0 1 0
|
||||||
|
vt 0.5 0 0
|
||||||
|
vt 0 0 0
|
||||||
|
vt 0 0.5 0
|
||||||
|
vt 0.5 0.5 0
|
||||||
|
vt 0 0.5 0
|
||||||
|
vt 0.5 0.5 0
|
||||||
|
vt 0.5 1 0
|
||||||
|
vt 0 1 0
|
||||||
|
|
||||||
|
# merger
|
||||||
|
g box
|
||||||
|
|
||||||
|
# reference material
|
||||||
|
#usemtl mat01
|
||||||
|
|
||||||
|
# faces
|
||||||
|
f 1/9/1 3/10/1 4/11/1
|
||||||
|
f 4/11/1 2/12/1 1/9/1
|
||||||
|
f 5/13/2 6/14/2 8/15/2
|
||||||
|
f 8/15/2 7/16/2 5/13/2
|
||||||
|
f 1/17/6 2/18/6 6/19/6
|
||||||
|
f 6/19/6 5/20/6 1/17/6
|
||||||
|
f 2/6/1 4/5/1 8/7/1
|
||||||
|
f 8/7/1 6/8/1 2/6/1
|
||||||
|
f 4/2/3 3/1/3 7/4/3
|
||||||
|
f 7/4/3 8/3/3 4/2/3
|
||||||
|
f 3/22/5 1/21/5 5/24/5
|
||||||
|
f 5/24/5 7/23/5 3/22/5
|
||||||
BIN
examples/models/resources/models/obj/cube_diffuse.png
Normal file
|
After Width: | Height: | Size: 23 KiB |
4564
examples/models/resources/models/obj/house.obj
Normal file
BIN
examples/models/resources/models/obj/house_diffuse.png
Normal file
|
After Width: | Height: | Size: 383 KiB |
7301
examples/models/resources/models/obj/market.obj
Normal file
BIN
examples/models/resources/models/obj/market_diffuse.png
Normal file
|
After Width: | Height: | Size: 380 KiB |
1888
examples/models/resources/models/obj/turret.obj
Normal file
BIN
examples/models/resources/models/obj/turret_diffuse.png
Normal file
|
After Width: | Height: | Size: 371 KiB |
1030
examples/models/resources/models/obj/well.obj
Normal file
BIN
examples/models/resources/models/obj/well_diffuse.png
Normal file
|
After Width: | Height: | Size: 334 KiB |
6
projects/VSCode/.vscode/tasks.json
vendored
|
|
@ -9,7 +9,9 @@
|
||||||
"command": "make",
|
"command": "make",
|
||||||
"args": [
|
"args": [
|
||||||
"PLATFORM=PLATFORM_DESKTOP",
|
"PLATFORM=PLATFORM_DESKTOP",
|
||||||
"BUILD_MODE=DEBUG"
|
"BUILD_MODE=DEBUG",
|
||||||
|
"PROJECT_NAME=${fileBasenameNoExtension}",
|
||||||
|
"OBJS=${fileBasenameNoExtension}.c"
|
||||||
],
|
],
|
||||||
"windows": {
|
"windows": {
|
||||||
"command": "C:/raylib/mingw/bin/mingw32-make.exe",
|
"command": "C:/raylib/mingw/bin/mingw32-make.exe",
|
||||||
|
|
@ -42,6 +44,8 @@
|
||||||
"command": "make",
|
"command": "make",
|
||||||
"args": [
|
"args": [
|
||||||
"PLATFORM=PLATFORM_DESKTOP",
|
"PLATFORM=PLATFORM_DESKTOP",
|
||||||
|
"PROJECT_NAME=${fileBasenameNoExtension}",
|
||||||
|
"OBJS=${fileBasenameNoExtension}.c"
|
||||||
],
|
],
|
||||||
"windows": {
|
"windows": {
|
||||||
"command": "C:/raylib/mingw/bin/mingw32-make.exe",
|
"command": "C:/raylib/mingw/bin/mingw32-make.exe",
|
||||||
|
|
|
||||||
|
|
@ -1054,8 +1054,11 @@ RLAPI char **GetDroppedFiles(int *count); // Get dropped
|
||||||
RLAPI void ClearDroppedFiles(void); // Clear dropped files paths buffer (free memory)
|
RLAPI void ClearDroppedFiles(void); // Clear dropped files paths buffer (free memory)
|
||||||
RLAPI long GetFileModTime(const char *fileName); // Get file modification time (last write time)
|
RLAPI long GetFileModTime(const char *fileName); // Get file modification time (last write time)
|
||||||
|
|
||||||
|
// Compression/Encoding functionality
|
||||||
RLAPI unsigned char *CompressData(unsigned char *data, int dataLength, int *compDataLength); // Compress data (DEFLATE algorithm)
|
RLAPI unsigned char *CompressData(unsigned char *data, int dataLength, int *compDataLength); // Compress data (DEFLATE algorithm)
|
||||||
RLAPI unsigned char *DecompressData(unsigned char *compData, int compDataLength, int *dataLength); // Decompress data (DEFLATE algorithm)
|
RLAPI unsigned char *DecompressData(unsigned char *compData, int compDataLength, int *dataLength); // Decompress data (DEFLATE algorithm)
|
||||||
|
RLAPI char *EncodeDataBase64(const unsigned char *data, int dataLength, int *outputLength); // Encode data to Base64 string
|
||||||
|
RLAPI unsigned char *DecodeDataBase64(unsigned char *data, int *outputLength); // Decode Base64 string data
|
||||||
|
|
||||||
// Persistent storage management
|
// Persistent storage management
|
||||||
RLAPI bool SaveStorageValue(unsigned int position, int value); // Save integer value to storage file (to defined position), returns true on success
|
RLAPI bool SaveStorageValue(unsigned int position, int value); // Save integer value to storage file (to defined position), returns true on success
|
||||||
|
|
|
||||||
206
src/rcore.c
|
|
@ -2223,71 +2223,71 @@ VrStereoConfig LoadVrStereoConfig(VrDeviceInfo device)
|
||||||
{
|
{
|
||||||
VrStereoConfig config = { 0 };
|
VrStereoConfig config = { 0 };
|
||||||
|
|
||||||
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
|
if ((rlGetVersion() == OPENGL_33) || (rlGetVersion() == OPENGL_ES_20))
|
||||||
// Compute aspect ratio
|
{
|
||||||
float aspect = ((float)device.hResolution*0.5f)/(float)device.vResolution;
|
// Compute aspect ratio
|
||||||
|
float aspect = ((float)device.hResolution*0.5f)/(float)device.vResolution;
|
||||||
|
|
||||||
// Compute lens parameters
|
// Compute lens parameters
|
||||||
float lensShift = (device.hScreenSize*0.25f - device.lensSeparationDistance*0.5f)/device.hScreenSize;
|
float lensShift = (device.hScreenSize*0.25f - device.lensSeparationDistance*0.5f)/device.hScreenSize;
|
||||||
config.leftLensCenter[0] = 0.25f + lensShift;
|
config.leftLensCenter[0] = 0.25f + lensShift;
|
||||||
config.leftLensCenter[1] = 0.5f;
|
config.leftLensCenter[1] = 0.5f;
|
||||||
config.rightLensCenter[0] = 0.75f - lensShift;
|
config.rightLensCenter[0] = 0.75f - lensShift;
|
||||||
config.rightLensCenter[1] = 0.5f;
|
config.rightLensCenter[1] = 0.5f;
|
||||||
config.leftScreenCenter[0] = 0.25f;
|
config.leftScreenCenter[0] = 0.25f;
|
||||||
config.leftScreenCenter[1] = 0.5f;
|
config.leftScreenCenter[1] = 0.5f;
|
||||||
config.rightScreenCenter[0] = 0.75f;
|
config.rightScreenCenter[0] = 0.75f;
|
||||||
config.rightScreenCenter[1] = 0.5f;
|
config.rightScreenCenter[1] = 0.5f;
|
||||||
|
|
||||||
// Compute distortion scale parameters
|
// Compute distortion scale parameters
|
||||||
// NOTE: To get lens max radius, lensShift must be normalized to [-1..1]
|
// NOTE: To get lens max radius, lensShift must be normalized to [-1..1]
|
||||||
float lensRadius = fabsf(-1.0f - 4.0f*lensShift);
|
float lensRadius = fabsf(-1.0f - 4.0f*lensShift);
|
||||||
float lensRadiusSq = lensRadius*lensRadius;
|
float lensRadiusSq = lensRadius*lensRadius;
|
||||||
float distortionScale = device.lensDistortionValues[0] +
|
float distortionScale = device.lensDistortionValues[0] +
|
||||||
device.lensDistortionValues[1]*lensRadiusSq +
|
device.lensDistortionValues[1]*lensRadiusSq +
|
||||||
device.lensDistortionValues[2]*lensRadiusSq*lensRadiusSq +
|
device.lensDistortionValues[2]*lensRadiusSq*lensRadiusSq +
|
||||||
device.lensDistortionValues[3]*lensRadiusSq*lensRadiusSq*lensRadiusSq;
|
device.lensDistortionValues[3]*lensRadiusSq*lensRadiusSq*lensRadiusSq;
|
||||||
|
|
||||||
float normScreenWidth = 0.5f;
|
float normScreenWidth = 0.5f;
|
||||||
float normScreenHeight = 1.0f;
|
float normScreenHeight = 1.0f;
|
||||||
config.scaleIn[0] = 2.0f/normScreenWidth;
|
config.scaleIn[0] = 2.0f/normScreenWidth;
|
||||||
config.scaleIn[1] = 2.0f/normScreenHeight/aspect;
|
config.scaleIn[1] = 2.0f/normScreenHeight/aspect;
|
||||||
config.scale[0] = normScreenWidth*0.5f/distortionScale;
|
config.scale[0] = normScreenWidth*0.5f/distortionScale;
|
||||||
config.scale[1] = normScreenHeight*0.5f*aspect/distortionScale;
|
config.scale[1] = normScreenHeight*0.5f*aspect/distortionScale;
|
||||||
|
|
||||||
// Fovy is normally computed with: 2*atan2f(device.vScreenSize, 2*device.eyeToScreenDistance)
|
// Fovy is normally computed with: 2*atan2f(device.vScreenSize, 2*device.eyeToScreenDistance)
|
||||||
// ...but with lens distortion it is increased (see Oculus SDK Documentation)
|
// ...but with lens distortion it is increased (see Oculus SDK Documentation)
|
||||||
//float fovy = 2.0f*atan2f(device.vScreenSize*0.5f*distortionScale, device.eyeToScreenDistance); // Really need distortionScale?
|
//float fovy = 2.0f*atan2f(device.vScreenSize*0.5f*distortionScale, device.eyeToScreenDistance); // Really need distortionScale?
|
||||||
float fovy = 2.0f*(float)atan2f(device.vScreenSize*0.5f, device.eyeToScreenDistance);
|
float fovy = 2.0f*(float)atan2f(device.vScreenSize*0.5f, device.eyeToScreenDistance);
|
||||||
|
|
||||||
// Compute camera projection matrices
|
// Compute camera projection matrices
|
||||||
float projOffset = 4.0f*lensShift; // Scaled to projection space coordinates [-1..1]
|
float projOffset = 4.0f*lensShift; // Scaled to projection space coordinates [-1..1]
|
||||||
Matrix proj = MatrixPerspective(fovy, aspect, RL_CULL_DISTANCE_NEAR, RL_CULL_DISTANCE_FAR);
|
Matrix proj = MatrixPerspective(fovy, aspect, RL_CULL_DISTANCE_NEAR, RL_CULL_DISTANCE_FAR);
|
||||||
|
|
||||||
config.projection[0] = MatrixMultiply(proj, MatrixTranslate(projOffset, 0.0f, 0.0f));
|
config.projection[0] = MatrixMultiply(proj, MatrixTranslate(projOffset, 0.0f, 0.0f));
|
||||||
config.projection[1] = MatrixMultiply(proj, MatrixTranslate(-projOffset, 0.0f, 0.0f));
|
config.projection[1] = MatrixMultiply(proj, MatrixTranslate(-projOffset, 0.0f, 0.0f));
|
||||||
|
|
||||||
// Compute camera transformation matrices
|
// Compute camera transformation matrices
|
||||||
// NOTE: Camera movement might seem more natural if we model the head.
|
// NOTE: Camera movement might seem more natural if we model the head.
|
||||||
// Our axis of rotation is the base of our head, so we might want to add
|
// Our axis of rotation is the base of our head, so we might want to add
|
||||||
// some y (base of head to eye level) and -z (center of head to eye protrusion) to the camera positions.
|
// some y (base of head to eye level) and -z (center of head to eye protrusion) to the camera positions.
|
||||||
config.viewOffset[0] = MatrixTranslate(-device.interpupillaryDistance*0.5f, 0.075f, 0.045f);
|
config.viewOffset[0] = MatrixTranslate(-device.interpupillaryDistance*0.5f, 0.075f, 0.045f);
|
||||||
config.viewOffset[1] = MatrixTranslate(device.interpupillaryDistance*0.5f, 0.075f, 0.045f);
|
config.viewOffset[1] = MatrixTranslate(device.interpupillaryDistance*0.5f, 0.075f, 0.045f);
|
||||||
|
|
||||||
// Compute eyes Viewports
|
// Compute eyes Viewports
|
||||||
/*
|
/*
|
||||||
config.eyeViewportRight[0] = 0;
|
config.eyeViewportRight[0] = 0;
|
||||||
config.eyeViewportRight[1] = 0;
|
config.eyeViewportRight[1] = 0;
|
||||||
config.eyeViewportRight[2] = device.hResolution/2;
|
config.eyeViewportRight[2] = device.hResolution/2;
|
||||||
config.eyeViewportRight[3] = device.vResolution;
|
config.eyeViewportRight[3] = device.vResolution;
|
||||||
|
|
||||||
config.eyeViewportLeft[0] = device.hResolution/2;
|
config.eyeViewportLeft[0] = device.hResolution/2;
|
||||||
config.eyeViewportLeft[1] = 0;
|
config.eyeViewportLeft[1] = 0;
|
||||||
config.eyeViewportLeft[2] = device.hResolution/2;
|
config.eyeViewportLeft[2] = device.hResolution/2;
|
||||||
config.eyeViewportLeft[3] = device.vResolution;
|
config.eyeViewportLeft[3] = device.vResolution;
|
||||||
*/
|
*/
|
||||||
#else
|
}
|
||||||
TRACELOG(LOG_WARNING, "RLGL: VR Simulator not supported on OpenGL 1.1");
|
else TRACELOG(LOG_WARNING, "RLGL: VR Simulator not supported on OpenGL 1.1");
|
||||||
#endif
|
|
||||||
|
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
@ -3038,6 +3038,100 @@ unsigned char *DecompressData(unsigned char *compData, int compDataLength, int *
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Encode data to Base64 string
|
||||||
|
char *EncodeDataBase64(const unsigned char *data, int dataLength, int *outputLength)
|
||||||
|
{
|
||||||
|
static const unsigned char base64encodeTable[] = {
|
||||||
|
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
|
||||||
|
'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
|
||||||
|
'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/'
|
||||||
|
};
|
||||||
|
|
||||||
|
static const int modTable[] = { 0, 2, 1 };
|
||||||
|
|
||||||
|
*outputLength = 4*((dataLength + 2)/3);
|
||||||
|
|
||||||
|
char *encodedData = RL_MALLOC(*outputLength);
|
||||||
|
|
||||||
|
if (encodedData == NULL) return NULL;
|
||||||
|
|
||||||
|
for (int i = 0, j = 0; i < dataLength;)
|
||||||
|
{
|
||||||
|
unsigned int octetA = (i < dataLength)? (unsigned char)data[i++] : 0;
|
||||||
|
unsigned int octetB = (i < dataLength)? (unsigned char)data[i++] : 0;
|
||||||
|
unsigned int octetC = (i < dataLength)? (unsigned char)data[i++] : 0;
|
||||||
|
|
||||||
|
unsigned int triple = (octetA << 0x10) + (octetB << 0x08) + octetC;
|
||||||
|
|
||||||
|
encodedData[j++] = base64encodeTable[(triple >> 3*6) & 0x3F];
|
||||||
|
encodedData[j++] = base64encodeTable[(triple >> 2*6) & 0x3F];
|
||||||
|
encodedData[j++] = base64encodeTable[(triple >> 1*6) & 0x3F];
|
||||||
|
encodedData[j++] = base64encodeTable[(triple >> 0*6) & 0x3F];
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < modTable[dataLength%3]; i++) encodedData[*outputLength - 1 - i] = '=';
|
||||||
|
|
||||||
|
return encodedData;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decode Base64 string data
|
||||||
|
unsigned char *DecodeDataBase64(unsigned char *data, int *outputLength)
|
||||||
|
{
|
||||||
|
static const unsigned char base64decodeTable[] = {
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 62, 0, 0, 0, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
|
||||||
|
11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 0, 0, 0, 0, 0, 0, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
|
||||||
|
37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51
|
||||||
|
};
|
||||||
|
|
||||||
|
// Get output size of Base64 input data
|
||||||
|
int outLength = 0;
|
||||||
|
for (int i = 0; data[4*i] != 0; i++)
|
||||||
|
{
|
||||||
|
if (data[4*i + 3] == '=')
|
||||||
|
{
|
||||||
|
if (data[4*i + 2] == '=') outLength += 1;
|
||||||
|
else outLength += 2;
|
||||||
|
}
|
||||||
|
else outLength += 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Allocate memory to store decoded Base64 data
|
||||||
|
unsigned char *decodedData = (unsigned char *)RL_MALLOC(outLength);
|
||||||
|
|
||||||
|
for (int i = 0; i < outLength/3; i++)
|
||||||
|
{
|
||||||
|
unsigned char a = base64decodeTable[(int)data[4*i]];
|
||||||
|
unsigned char b = base64decodeTable[(int)data[4*i + 1]];
|
||||||
|
unsigned char c = base64decodeTable[(int)data[4*i + 2]];
|
||||||
|
unsigned char d = base64decodeTable[(int)data[4*i + 3]];
|
||||||
|
|
||||||
|
decodedData[3*i] = (a << 2) | (b >> 4);
|
||||||
|
decodedData[3*i + 1] = (b << 4) | (c >> 2);
|
||||||
|
decodedData[3*i + 2] = (c << 6) | d;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (outLength%3 == 1)
|
||||||
|
{
|
||||||
|
int n = outLength/3;
|
||||||
|
unsigned char a = base64decodeTable[(int)data[4*n]];
|
||||||
|
unsigned char b = base64decodeTable[(int)data[4*n + 1]];
|
||||||
|
decodedData[outLength - 1] = (a << 2) | (b >> 4);
|
||||||
|
}
|
||||||
|
else if (outLength%3 == 2)
|
||||||
|
{
|
||||||
|
int n = outLength/3;
|
||||||
|
unsigned char a = base64decodeTable[(int)data[4*n]];
|
||||||
|
unsigned char b = base64decodeTable[(int)data[4*n + 1]];
|
||||||
|
unsigned char c = base64decodeTable[(int)data[4*n + 2]];
|
||||||
|
decodedData[outLength - 2] = (a << 2) | (b >> 4);
|
||||||
|
decodedData[outLength - 1] = (b << 4) | (c >> 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
*outputLength = outLength;
|
||||||
|
return decodedData;
|
||||||
|
}
|
||||||
|
|
||||||
// Save integer value to storage file (to defined position)
|
// Save integer value to storage file (to defined position)
|
||||||
// NOTE: Storage positions is directly related to file memory layout (4 bytes each integer)
|
// NOTE: Storage positions is directly related to file memory layout (4 bytes each integer)
|
||||||
bool SaveStorageValue(unsigned int position, int value)
|
bool SaveStorageValue(unsigned int position, int value)
|
||||||
|
|
|
||||||
18
src/rlgl.h
|
|
@ -1495,7 +1495,6 @@ void rlDisableTexture(void)
|
||||||
void rlEnableTextureCubemap(unsigned int id)
|
void rlEnableTextureCubemap(unsigned int id)
|
||||||
{
|
{
|
||||||
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
|
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
|
||||||
glEnable(GL_TEXTURE_CUBE_MAP); // Core in OpenGL 1.4
|
|
||||||
glBindTexture(GL_TEXTURE_CUBE_MAP, id);
|
glBindTexture(GL_TEXTURE_CUBE_MAP, id);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
@ -1504,7 +1503,6 @@ void rlEnableTextureCubemap(unsigned int id)
|
||||||
void rlDisableTextureCubemap(void)
|
void rlDisableTextureCubemap(void)
|
||||||
{
|
{
|
||||||
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
|
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
|
||||||
glDisable(GL_TEXTURE_CUBE_MAP);
|
|
||||||
glBindTexture(GL_TEXTURE_CUBE_MAP, 0);
|
glBindTexture(GL_TEXTURE_CUBE_MAP, 0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
@ -2322,17 +2320,23 @@ void rlUnloadRenderBatch(rlRenderBatch batch)
|
||||||
{
|
{
|
||||||
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
|
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
|
||||||
// Unbind everything
|
// Unbind everything
|
||||||
if (RLGL.ExtSupported.vao) glBindVertexArray(0);
|
|
||||||
glDisableVertexAttribArray(0);
|
|
||||||
glDisableVertexAttribArray(1);
|
|
||||||
glDisableVertexAttribArray(2);
|
|
||||||
glDisableVertexAttribArray(3);
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||||
|
|
||||||
// Unload all vertex buffers data
|
// Unload all vertex buffers data
|
||||||
for (int i = 0; i < batch.bufferCount; i++)
|
for (int i = 0; i < batch.bufferCount; i++)
|
||||||
{
|
{
|
||||||
|
// Unbind VAO attribs data
|
||||||
|
if (RLGL.ExtSupported.vao)
|
||||||
|
{
|
||||||
|
glBindVertexArray(batch.vertexBuffer[i].vaoId);
|
||||||
|
glDisableVertexAttribArray(0);
|
||||||
|
glDisableVertexAttribArray(1);
|
||||||
|
glDisableVertexAttribArray(2);
|
||||||
|
glDisableVertexAttribArray(3);
|
||||||
|
glBindVertexArray(0);
|
||||||
|
}
|
||||||
|
|
||||||
// Delete VBOs from GPU (VRAM)
|
// Delete VBOs from GPU (VRAM)
|
||||||
glDeleteBuffers(1, &batch.vertexBuffer[i].vboId[0]);
|
glDeleteBuffers(1, &batch.vertexBuffer[i].vboId[0]);
|
||||||
glDeleteBuffers(1, &batch.vertexBuffer[i].vboId[1]);
|
glDeleteBuffers(1, &batch.vertexBuffer[i].vboId[1]);
|
||||||
|
|
|
||||||