|
@ -943,7 +943,7 @@ void rlMatrixMode(int mode) |
|
|
// Push the current matrix into RLGL.State.stack |
|
|
// Push the current matrix into RLGL.State.stack |
|
|
void rlPushMatrix(void) |
|
|
void rlPushMatrix(void) |
|
|
{ |
|
|
{ |
|
|
if (RLGL.State.stackCounter >= MAX_MATRIX_STACK_SIZE) TRACELOG(LOG_ERROR, "Matrix RLGL.State.stack overflow"); |
|
|
|
|
|
|
|
|
if (RLGL.State.stackCounter >= MAX_MATRIX_STACK_SIZE) TRACELOG(LOG_ERROR, "RLGL: Matrix stack overflow (MAX_MATRIX_STACK_SIZE)"); |
|
|
|
|
|
|
|
|
if (RLGL.State.currentMatrixMode == RL_MODELVIEW) |
|
|
if (RLGL.State.currentMatrixMode == RL_MODELVIEW) |
|
|
{ |
|
|
{ |
|
@ -1185,7 +1185,7 @@ void rlVertex3f(float x, float y, float z) |
|
|
|
|
|
|
|
|
RLGL.State.draws[RLGL.State.drawsCounter - 1].vertexCount++; |
|
|
RLGL.State.draws[RLGL.State.drawsCounter - 1].vertexCount++; |
|
|
} |
|
|
} |
|
|
else TRACELOG(LOG_ERROR, "MAX_BATCH_ELEMENTS overflow"); |
|
|
|
|
|
|
|
|
else TRACELOG(LOG_ERROR, "RLGL: Batch elements overflow (MAX_BATCH_ELEMENTS)"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// Define one vertex (position) |
|
|
// Define one vertex (position) |
|
@ -1313,7 +1313,7 @@ void rlTextureParameters(unsigned int id, int param, int value) |
|
|
{ |
|
|
{ |
|
|
#if !defined(GRAPHICS_API_OPENGL_11) |
|
|
#if !defined(GRAPHICS_API_OPENGL_11) |
|
|
if (RLGL.ExtSupported.texMirrorClamp) glTexParameteri(GL_TEXTURE_2D, param, value); |
|
|
if (RLGL.ExtSupported.texMirrorClamp) glTexParameteri(GL_TEXTURE_2D, param, value); |
|
|
else TRACELOG(LOG_WARNING, "Clamp mirror wrap mode not supported"); |
|
|
|
|
|
|
|
|
else TRACELOG(LOG_WARNING, "GL: Clamp mirror wrap mode not supported (GL_MIRROR_CLAMP_EXT)"); |
|
|
#endif |
|
|
#endif |
|
|
} |
|
|
} |
|
|
else glTexParameteri(GL_TEXTURE_2D, param, value); |
|
|
else glTexParameteri(GL_TEXTURE_2D, param, value); |
|
@ -1327,10 +1327,10 @@ void rlTextureParameters(unsigned int id, int param, int value) |
|
|
if (value <= RLGL.ExtSupported.maxAnisotropicLevel) glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, (float)value); |
|
|
if (value <= RLGL.ExtSupported.maxAnisotropicLevel) glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, (float)value); |
|
|
else if (RLGL.ExtSupported.maxAnisotropicLevel > 0.0f) |
|
|
else if (RLGL.ExtSupported.maxAnisotropicLevel > 0.0f) |
|
|
{ |
|
|
{ |
|
|
TRACELOG(LOG_WARNING, "[TEX ID %i] Maximum anisotropic filter level supported is %iX", id, RLGL.ExtSupported.maxAnisotropicLevel); |
|
|
|
|
|
|
|
|
TRACELOG(LOG_WARNING, "GL: Maximum anisotropic filter level supported is %iX", id, RLGL.ExtSupported.maxAnisotropicLevel); |
|
|
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, (float)value); |
|
|
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, (float)value); |
|
|
} |
|
|
} |
|
|
else TRACELOG(LOG_WARNING, "Anisotropic filtering not supported"); |
|
|
|
|
|
|
|
|
else TRACELOG(LOG_WARNING, "GL: Anisotropic filtering not supported"); |
|
|
#endif |
|
|
#endif |
|
|
} break; |
|
|
} break; |
|
|
default: break; |
|
|
default: break; |
|
@ -1419,7 +1419,7 @@ void rlDeleteRenderTextures(RenderTexture2D target) |
|
|
|
|
|
|
|
|
if (target.id > 0) glDeleteFramebuffers(1, &target.id); |
|
|
if (target.id > 0) glDeleteFramebuffers(1, &target.id); |
|
|
|
|
|
|
|
|
TRACELOG(LOG_INFO, "[FBO ID %i] Unloaded render texture data from VRAM (GPU)", target.id); |
|
|
|
|
|
|
|
|
TRACELOG(LOG_INFO, "FBO: [ID %i] Unloaded render texture data from VRAM (GPU)", target.id); |
|
|
#endif |
|
|
#endif |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -1438,7 +1438,7 @@ void rlDeleteVertexArrays(unsigned int id) |
|
|
if (RLGL.ExtSupported.vao) |
|
|
if (RLGL.ExtSupported.vao) |
|
|
{ |
|
|
{ |
|
|
if (id != 0) glDeleteVertexArrays(1, &id); |
|
|
if (id != 0) glDeleteVertexArrays(1, &id); |
|
|
TRACELOG(LOG_INFO, "[VAO ID %i] Unloaded model data from VRAM (GPU)", id); |
|
|
|
|
|
|
|
|
TRACELOG(LOG_INFO, "VAO: [ID %i] Unloaded vertex data from VRAM (GPU)", id); |
|
|
} |
|
|
} |
|
|
#endif |
|
|
#endif |
|
|
} |
|
|
} |
|
@ -1450,7 +1450,7 @@ void rlDeleteBuffers(unsigned int id) |
|
|
if (id != 0) |
|
|
if (id != 0) |
|
|
{ |
|
|
{ |
|
|
glDeleteBuffers(1, &id); |
|
|
glDeleteBuffers(1, &id); |
|
|
if (!RLGL.ExtSupported.vao) TRACELOG(LOG_INFO, "[VBO ID %i] Unloaded model vertex data from VRAM (GPU)", id); |
|
|
|
|
|
|
|
|
if (!RLGL.ExtSupported.vao) TRACELOG(LOG_INFO, "VBO: [ID %i] Unloaded vertex data from VRAM (GPU)", id); |
|
|
} |
|
|
} |
|
|
#endif |
|
|
#endif |
|
|
} |
|
|
} |
|
@ -1492,30 +1492,30 @@ void rlglInit(int width, int height) |
|
|
{ |
|
|
{ |
|
|
// Check OpenGL information and capabilities |
|
|
// Check OpenGL information and capabilities |
|
|
//------------------------------------------------------------------------------ |
|
|
//------------------------------------------------------------------------------ |
|
|
|
|
|
|
|
|
// Print current OpenGL and GLSL version |
|
|
// Print current OpenGL and GLSL version |
|
|
TRACELOG(LOG_INFO, "GPU: Vendor: %s", glGetString(GL_VENDOR)); |
|
|
|
|
|
TRACELOG(LOG_INFO, "GPU: Renderer: %s", glGetString(GL_RENDERER)); |
|
|
|
|
|
TRACELOG(LOG_INFO, "GPU: Version: %s", glGetString(GL_VERSION)); |
|
|
|
|
|
TRACELOG(LOG_INFO, "GPU: GLSL: %s", glGetString(GL_SHADING_LANGUAGE_VERSION)); |
|
|
|
|
|
|
|
|
TRACELOG(LOG_INFO, "GPU: OpenGL device information:"); |
|
|
|
|
|
TRACELOG(LOG_INFO, " > Vendor: %s", glGetString(GL_VENDOR)); |
|
|
|
|
|
TRACELOG(LOG_INFO, " > Renderer: %s", glGetString(GL_RENDERER)); |
|
|
|
|
|
TRACELOG(LOG_INFO, " > Version: %s", glGetString(GL_VERSION)); |
|
|
|
|
|
TRACELOG(LOG_INFO, " > GLSL: %s", glGetString(GL_SHADING_LANGUAGE_VERSION)); |
|
|
|
|
|
|
|
|
// NOTE: We can get a bunch of extra information about GPU capabilities (glGet*) |
|
|
// NOTE: We can get a bunch of extra information about GPU capabilities (glGet*) |
|
|
//int maxTexSize; |
|
|
//int maxTexSize; |
|
|
//glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTexSize); |
|
|
//glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTexSize); |
|
|
//TRACELOG(LOG_INFO, "GL_MAX_TEXTURE_SIZE: %i", maxTexSize); |
|
|
|
|
|
|
|
|
//TRACELOG(LOG_INFO, "GL: Maximum texture size: %i", maxTexSize); |
|
|
|
|
|
|
|
|
//GL_MAX_TEXTURE_IMAGE_UNITS |
|
|
//GL_MAX_TEXTURE_IMAGE_UNITS |
|
|
//GL_MAX_VIEWPORT_DIMS |
|
|
//GL_MAX_VIEWPORT_DIMS |
|
|
|
|
|
|
|
|
//int numAuxBuffers; |
|
|
//int numAuxBuffers; |
|
|
//glGetIntegerv(GL_AUX_BUFFERS, &numAuxBuffers); |
|
|
//glGetIntegerv(GL_AUX_BUFFERS, &numAuxBuffers); |
|
|
//TRACELOG(LOG_INFO, "GL_AUX_BUFFERS: %i", numAuxBuffers); |
|
|
|
|
|
|
|
|
//TRACELOG(LOG_INFO, "GL: Number of aixiliar buffers: %i", numAuxBuffers); |
|
|
|
|
|
|
|
|
//GLint numComp = 0; |
|
|
//GLint numComp = 0; |
|
|
//GLint format[32] = { 0 }; |
|
|
//GLint format[32] = { 0 }; |
|
|
//glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, &numComp); |
|
|
//glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, &numComp); |
|
|
//glGetIntegerv(GL_COMPRESSED_TEXTURE_FORMATS, format); |
|
|
//glGetIntegerv(GL_COMPRESSED_TEXTURE_FORMATS, format); |
|
|
//for (int i = 0; i < numComp; i++) TRACELOG(LOG_INFO, "Supported compressed format: 0x%x", format[i]); |
|
|
|
|
|
|
|
|
//for (int i = 0; i < numComp; i++) TRACELOG(LOG_INFO, "GL: Supported compressed format: 0x%x", format[i]); |
|
|
|
|
|
|
|
|
// NOTE: We don't need that much data on screen... right now... |
|
|
// NOTE: We don't need that much data on screen... right now... |
|
|
|
|
|
|
|
@ -1573,7 +1573,7 @@ void rlglInit(int width, int height) |
|
|
// NOTE: Duplicated string (extensionsDup) must be deallocated |
|
|
// NOTE: Duplicated string (extensionsDup) must be deallocated |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
TRACELOG(LOG_INFO, "Number of supported extensions: %i", numExt); |
|
|
|
|
|
|
|
|
TRACELOG(LOG_INFO, "GL: Supported extensions count: %i", numExt); |
|
|
|
|
|
|
|
|
// Show supported extensions |
|
|
// Show supported extensions |
|
|
//for (int i = 0; i < numExt; i++) TRACELOG(LOG_INFO, "Supported extension: %s", extList[i]); |
|
|
//for (int i = 0; i < numExt; i++) TRACELOG(LOG_INFO, "Supported extension: %s", extList[i]); |
|
@ -1648,23 +1648,23 @@ void rlglInit(int width, int height) |
|
|
#if defined(GRAPHICS_API_OPENGL_ES2) |
|
|
#if defined(GRAPHICS_API_OPENGL_ES2) |
|
|
RL_FREE(extensionsDup); // Duplicated string must be deallocated |
|
|
RL_FREE(extensionsDup); // Duplicated string must be deallocated |
|
|
|
|
|
|
|
|
if (RLGL.ExtSupported.vao) TRACELOG(LOG_INFO, "[EXTENSION] VAO extension detected, VAO functions initialized successfully"); |
|
|
|
|
|
else TRACELOG(LOG_WARNING, "[EXTENSION] VAO extension not found, VAO usage not supported"); |
|
|
|
|
|
|
|
|
if (RLGL.ExtSupported.vao) TRACELOG(LOG_INFO, "GL: VAO extension detected, VAO functions initialized successfully"); |
|
|
|
|
|
else TRACELOG(LOG_WARNING, "GL: VAO extension not found, VAO usage not supported"); |
|
|
|
|
|
|
|
|
if (RLGL.ExtSupported.texNPOT) TRACELOG(LOG_INFO, "[EXTENSION] NPOT textures extension detected, full NPOT textures supported"); |
|
|
|
|
|
else TRACELOG(LOG_WARNING, "[EXTENSION] NPOT textures extension not found, limited NPOT support (no-mipmaps, no-repeat)"); |
|
|
|
|
|
|
|
|
if (RLGL.ExtSupported.texNPOT) TRACELOG(LOG_INFO, "GL: NPOT textures extension detected, full NPOT textures supported"); |
|
|
|
|
|
else TRACELOG(LOG_WARNING, "GL: NPOT textures extension not found, limited NPOT support (no-mipmaps, no-repeat)"); |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
if (RLGL.ExtSupported.texCompDXT) TRACELOG(LOG_INFO, "[EXTENSION] DXT compressed textures supported"); |
|
|
|
|
|
if (RLGL.ExtSupported.texCompETC1) TRACELOG(LOG_INFO, "[EXTENSION] ETC1 compressed textures supported"); |
|
|
|
|
|
if (RLGL.ExtSupported.texCompETC2) TRACELOG(LOG_INFO, "[EXTENSION] ETC2/EAC compressed textures supported"); |
|
|
|
|
|
if (RLGL.ExtSupported.texCompPVRT) TRACELOG(LOG_INFO, "[EXTENSION] PVRT compressed textures supported"); |
|
|
|
|
|
if (RLGL.ExtSupported.texCompASTC) TRACELOG(LOG_INFO, "[EXTENSION] ASTC compressed textures supported"); |
|
|
|
|
|
|
|
|
if (RLGL.ExtSupported.texCompDXT) TRACELOG(LOG_INFO, "GL: DXT compressed textures supported"); |
|
|
|
|
|
if (RLGL.ExtSupported.texCompETC1) TRACELOG(LOG_INFO, "GL: ETC1 compressed textures supported"); |
|
|
|
|
|
if (RLGL.ExtSupported.texCompETC2) TRACELOG(LOG_INFO, "GL: ETC2/EAC compressed textures supported"); |
|
|
|
|
|
if (RLGL.ExtSupported.texCompPVRT) TRACELOG(LOG_INFO, "GL: PVRT compressed textures supported"); |
|
|
|
|
|
if (RLGL.ExtSupported.texCompASTC) TRACELOG(LOG_INFO, "GL: ASTC compressed textures supported"); |
|
|
|
|
|
|
|
|
if (RLGL.ExtSupported.texAnisoFilter) TRACELOG(LOG_INFO, "[EXTENSION] Anisotropic textures filtering supported (max: %.0fX)", RLGL.ExtSupported.maxAnisotropicLevel); |
|
|
|
|
|
if (RLGL.ExtSupported.texMirrorClamp) TRACELOG(LOG_INFO, "[EXTENSION] Mirror clamp wrap texture mode supported"); |
|
|
|
|
|
|
|
|
if (RLGL.ExtSupported.texAnisoFilter) TRACELOG(LOG_INFO, "GL: Anisotropic textures filtering supported (max: %.0fX)", RLGL.ExtSupported.maxAnisotropicLevel); |
|
|
|
|
|
if (RLGL.ExtSupported.texMirrorClamp) TRACELOG(LOG_INFO, "GL: Mirror clamp wrap texture mode supported"); |
|
|
|
|
|
|
|
|
if (RLGL.ExtSupported.debugMarker) TRACELOG(LOG_INFO, "[EXTENSION] Debug Marker supported"); |
|
|
|
|
|
|
|
|
if (RLGL.ExtSupported.debugMarker) TRACELOG(LOG_INFO, "GL: Debug Marker supported"); |
|
|
|
|
|
|
|
|
// Initialize buffers, default shaders and default textures |
|
|
// Initialize buffers, default shaders and default textures |
|
|
//---------------------------------------------------------- |
|
|
//---------------------------------------------------------- |
|
@ -1672,8 +1672,8 @@ void rlglInit(int width, int height) |
|
|
unsigned char pixels[4] = { 255, 255, 255, 255 }; // 1 pixel RGBA (4 bytes) |
|
|
unsigned char pixels[4] = { 255, 255, 255, 255 }; // 1 pixel RGBA (4 bytes) |
|
|
RLGL.State.defaultTextureId = rlLoadTexture(pixels, 1, 1, UNCOMPRESSED_R8G8B8A8, 1); |
|
|
RLGL.State.defaultTextureId = rlLoadTexture(pixels, 1, 1, UNCOMPRESSED_R8G8B8A8, 1); |
|
|
|
|
|
|
|
|
if (RLGL.State.defaultTextureId != 0) TRACELOG(LOG_INFO, "[TEX ID %i] Base white texture loaded successfully", RLGL.State.defaultTextureId); |
|
|
|
|
|
else TRACELOG(LOG_WARNING, "Base white texture could not be loaded"); |
|
|
|
|
|
|
|
|
if (RLGL.State.defaultTextureId != 0) TRACELOG(LOG_INFO, "TEXTURE: [ID %i] Default texture loaded successfully", RLGL.State.defaultTextureId); |
|
|
|
|
|
else TRACELOG(LOG_WARNING, "TEXTURE: Failed to load default texture"); |
|
|
|
|
|
|
|
|
// Init default Shader (customized for GL 3.3 and ES2) |
|
|
// Init default Shader (customized for GL 3.3 and ES2) |
|
|
RLGL.State.defaultShader = LoadShaderDefault(); |
|
|
RLGL.State.defaultShader = LoadShaderDefault(); |
|
@ -1746,7 +1746,7 @@ void rlglInit(int width, int height) |
|
|
RLGL.State.shapesTexture = GetTextureDefault(); |
|
|
RLGL.State.shapesTexture = GetTextureDefault(); |
|
|
RLGL.State.shapesTextureRec = (Rectangle){ 0.0f, 0.0f, 1.0f, 1.0f }; |
|
|
RLGL.State.shapesTextureRec = (Rectangle){ 0.0f, 0.0f, 1.0f, 1.0f }; |
|
|
|
|
|
|
|
|
TRACELOG(LOG_INFO, "OpenGL default states initialized successfully"); |
|
|
|
|
|
|
|
|
TRACELOG(LOG_INFO, "GL: Default state initialized successfully"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// Vertex Buffer Object deinitialization (memory free) |
|
|
// Vertex Buffer Object deinitialization (memory free) |
|
@ -1757,7 +1757,7 @@ void rlglClose(void) |
|
|
UnloadBuffersDefault(); // Unload default buffers |
|
|
UnloadBuffersDefault(); // Unload default buffers |
|
|
glDeleteTextures(1, &RLGL.State.defaultTextureId); // Unload default texture |
|
|
glDeleteTextures(1, &RLGL.State.defaultTextureId); // Unload default texture |
|
|
|
|
|
|
|
|
TRACELOG(LOG_INFO, "[TEX ID %i] Unloaded texture data (base white texture) from VRAM", RLGL.State.defaultTextureId); |
|
|
|
|
|
|
|
|
TRACELOG(LOG_INFO, "TEXTURE: [ID %i] Unloaded default texture data from VRAM (GPU)", RLGL.State.defaultTextureId); |
|
|
|
|
|
|
|
|
RL_FREE(RLGL.State.draws); |
|
|
RL_FREE(RLGL.State.draws); |
|
|
#endif |
|
|
#endif |
|
@ -1823,10 +1823,10 @@ void rlLoadExtensions(void *loader) |
|
|
else TRACELOG(LOG_INFO, "GLAD: OpenGL extensions loaded successfully"); |
|
|
else TRACELOG(LOG_INFO, "GLAD: OpenGL extensions loaded successfully"); |
|
|
|
|
|
|
|
|
#if defined(GRAPHICS_API_OPENGL_21) |
|
|
#if defined(GRAPHICS_API_OPENGL_21) |
|
|
if (GLAD_GL_VERSION_2_1) TRACELOG(LOG_INFO, "OpenGL 2.1 profile supported"); |
|
|
|
|
|
|
|
|
if (GLAD_GL_VERSION_2_1) TRACELOG(LOG_INFO, "GL: OpenGL 2.1 profile supported"); |
|
|
#elif defined(GRAPHICS_API_OPENGL_33) |
|
|
#elif defined(GRAPHICS_API_OPENGL_33) |
|
|
if (GLAD_GL_VERSION_3_3) TRACELOG(LOG_INFO, "OpenGL 3.3 Core profile supported"); |
|
|
|
|
|
else TRACELOG(LOG_ERROR, "OpenGL 3.3 Core profile not supported"); |
|
|
|
|
|
|
|
|
if (GLAD_GL_VERSION_3_3) TRACELOG(LOG_INFO, "GL: OpenGL 3.3 Core profile supported"); |
|
|
|
|
|
else TRACELOG(LOG_ERROR, "GL: OpenGL 3.3 Core profile not supported"); |
|
|
#endif |
|
|
#endif |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
@ -1869,38 +1869,38 @@ unsigned int rlLoadTexture(void *data, int width, int height, int format, int mi |
|
|
#if defined(GRAPHICS_API_OPENGL_11) |
|
|
#if defined(GRAPHICS_API_OPENGL_11) |
|
|
if (format >= COMPRESSED_DXT1_RGB) |
|
|
if (format >= COMPRESSED_DXT1_RGB) |
|
|
{ |
|
|
{ |
|
|
TRACELOG(LOG_WARNING, "OpenGL 1.1 does not support GPU compressed texture formats"); |
|
|
|
|
|
|
|
|
TRACELOG(LOG_WARNING, "GL: OpenGL 1.1 does not support GPU compressed texture formats"); |
|
|
return id; |
|
|
return id; |
|
|
} |
|
|
} |
|
|
#else |
|
|
#else |
|
|
if ((!RLGL.ExtSupported.texCompDXT) && ((format == COMPRESSED_DXT1_RGB) || (format == COMPRESSED_DXT1_RGBA) || |
|
|
if ((!RLGL.ExtSupported.texCompDXT) && ((format == COMPRESSED_DXT1_RGB) || (format == COMPRESSED_DXT1_RGBA) || |
|
|
(format == COMPRESSED_DXT3_RGBA) || (format == COMPRESSED_DXT5_RGBA))) |
|
|
(format == COMPRESSED_DXT3_RGBA) || (format == COMPRESSED_DXT5_RGBA))) |
|
|
{ |
|
|
{ |
|
|
TRACELOG(LOG_WARNING, "DXT compressed texture format not supported"); |
|
|
|
|
|
|
|
|
TRACELOG(LOG_WARNING, "GL: DXT compressed texture format not supported"); |
|
|
return id; |
|
|
return id; |
|
|
} |
|
|
} |
|
|
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
|
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
|
if ((!RLGL.ExtSupported.texCompETC1) && (format == COMPRESSED_ETC1_RGB)) |
|
|
if ((!RLGL.ExtSupported.texCompETC1) && (format == COMPRESSED_ETC1_RGB)) |
|
|
{ |
|
|
{ |
|
|
TRACELOG(LOG_WARNING, "ETC1 compressed texture format not supported"); |
|
|
|
|
|
|
|
|
TRACELOG(LOG_WARNING, "GL: ETC1 compressed texture format not supported"); |
|
|
return id; |
|
|
return id; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if ((!RLGL.ExtSupported.texCompETC2) && ((format == COMPRESSED_ETC2_RGB) || (format == COMPRESSED_ETC2_EAC_RGBA))) |
|
|
if ((!RLGL.ExtSupported.texCompETC2) && ((format == COMPRESSED_ETC2_RGB) || (format == COMPRESSED_ETC2_EAC_RGBA))) |
|
|
{ |
|
|
{ |
|
|
TRACELOG(LOG_WARNING, "ETC2 compressed texture format not supported"); |
|
|
|
|
|
|
|
|
TRACELOG(LOG_WARNING, "GL: ETC2 compressed texture format not supported"); |
|
|
return id; |
|
|
return id; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if ((!RLGL.ExtSupported.texCompPVRT) && ((format == COMPRESSED_PVRT_RGB) || (format == COMPRESSED_PVRT_RGBA))) |
|
|
if ((!RLGL.ExtSupported.texCompPVRT) && ((format == COMPRESSED_PVRT_RGB) || (format == COMPRESSED_PVRT_RGBA))) |
|
|
{ |
|
|
{ |
|
|
TRACELOG(LOG_WARNING, "PVRT compressed texture format not supported"); |
|
|
|
|
|
|
|
|
TRACELOG(LOG_WARNING, "GL: PVRT compressed texture format not supported"); |
|
|
return id; |
|
|
return id; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if ((!RLGL.ExtSupported.texCompASTC) && ((format == COMPRESSED_ASTC_4x4_RGBA) || (format == COMPRESSED_ASTC_8x8_RGBA))) |
|
|
if ((!RLGL.ExtSupported.texCompASTC) && ((format == COMPRESSED_ASTC_4x4_RGBA) || (format == COMPRESSED_ASTC_8x8_RGBA))) |
|
|
{ |
|
|
{ |
|
|
TRACELOG(LOG_WARNING, "ASTC compressed texture format not supported"); |
|
|
|
|
|
|
|
|
TRACELOG(LOG_WARNING, "GL: ASTC compressed texture format not supported"); |
|
|
return id; |
|
|
return id; |
|
|
} |
|
|
} |
|
|
#endif |
|
|
#endif |
|
@ -1920,7 +1920,7 @@ unsigned int rlLoadTexture(void *data, int width, int height, int format, int mi |
|
|
int mipHeight = height; |
|
|
int mipHeight = height; |
|
|
int mipOffset = 0; // Mipmap data offset |
|
|
int mipOffset = 0; // Mipmap data offset |
|
|
|
|
|
|
|
|
TRACELOGD("Load texture from data memory address: 0x%x", data); |
|
|
|
|
|
|
|
|
TRACELOGD("TEXTURE: Load texture from data memory address: 0x%x", data); |
|
|
|
|
|
|
|
|
// Load the different mipmap levels |
|
|
// Load the different mipmap levels |
|
|
for (int i = 0; i < mipmapCount; i++) |
|
|
for (int i = 0; i < mipmapCount; i++) |
|
@ -1930,7 +1930,7 @@ unsigned int rlLoadTexture(void *data, int width, int height, int format, int mi |
|
|
unsigned int glInternalFormat, glFormat, glType; |
|
|
unsigned int glInternalFormat, glFormat, glType; |
|
|
rlGetGlTextureFormats(format, &glInternalFormat, &glFormat, &glType); |
|
|
rlGetGlTextureFormats(format, &glInternalFormat, &glFormat, &glType); |
|
|
|
|
|
|
|
|
TRACELOGD("Load mipmap level %i (%i x %i), size: %i, offset: %i", i, mipWidth, mipHeight, mipSize, mipOffset); |
|
|
|
|
|
|
|
|
TRACELOGD("TEXTURE: Load mipmap level %i (%i x %i), size: %i, offset: %i", i, mipWidth, mipHeight, mipSize, mipOffset); |
|
|
|
|
|
|
|
|
if (glInternalFormat != -1) |
|
|
if (glInternalFormat != -1) |
|
|
{ |
|
|
{ |
|
@ -2006,8 +2006,8 @@ unsigned int rlLoadTexture(void *data, int width, int height, int format, int mi |
|
|
// Unbind current texture |
|
|
// Unbind current texture |
|
|
glBindTexture(GL_TEXTURE_2D, 0); |
|
|
glBindTexture(GL_TEXTURE_2D, 0); |
|
|
|
|
|
|
|
|
if (id > 0) TRACELOG(LOG_INFO, "[TEX ID %i] Texture created successfully (%ix%i - %i mipmaps)", id, width, height, mipmapCount); |
|
|
|
|
|
else TRACELOG(LOG_WARNING, "Texture could not be created"); |
|
|
|
|
|
|
|
|
if (id > 0) TRACELOG(LOG_INFO, "TEXTURE: [ID %i] Texture created successfully (%ix%i - %i mipmaps)", id, width, height, mipmapCount); |
|
|
|
|
|
else TRACELOG(LOG_WARNING, "TEXTURE: Failed to load texture"); |
|
|
|
|
|
|
|
|
return id; |
|
|
return id; |
|
|
} |
|
|
} |
|
@ -2140,7 +2140,7 @@ void rlUpdateTexture(unsigned int id, int width, int height, int format, const v |
|
|
{ |
|
|
{ |
|
|
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, glFormat, glType, (unsigned char *)data); |
|
|
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, glFormat, glType, (unsigned char *)data); |
|
|
} |
|
|
} |
|
|
else TRACELOG(LOG_WARNING, "Texture format updating not supported"); |
|
|
|
|
|
|
|
|
else TRACELOG(LOG_WARNING, "TEXTURE: [ID %i] Failed to update for current texture format (%i)", id, format); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// Get OpenGL internal formats and data type from raylib PixelFormat |
|
|
// Get OpenGL internal formats and data type from raylib PixelFormat |
|
@ -2191,7 +2191,7 @@ void rlGetGlTextureFormats(int format, unsigned int *glInternalFormat, unsigned |
|
|
case COMPRESSED_ASTC_4x4_RGBA: if (RLGL.ExtSupported.texCompASTC) *glInternalFormat = GL_COMPRESSED_RGBA_ASTC_4x4_KHR; break; // NOTE: Requires OpenGL ES 3.1 or OpenGL 4.3 |
|
|
case COMPRESSED_ASTC_4x4_RGBA: if (RLGL.ExtSupported.texCompASTC) *glInternalFormat = GL_COMPRESSED_RGBA_ASTC_4x4_KHR; break; // NOTE: Requires OpenGL ES 3.1 or OpenGL 4.3 |
|
|
case COMPRESSED_ASTC_8x8_RGBA: if (RLGL.ExtSupported.texCompASTC) *glInternalFormat = GL_COMPRESSED_RGBA_ASTC_8x8_KHR; break; // NOTE: Requires OpenGL ES 3.1 or OpenGL 4.3 |
|
|
case COMPRESSED_ASTC_8x8_RGBA: if (RLGL.ExtSupported.texCompASTC) *glInternalFormat = GL_COMPRESSED_RGBA_ASTC_8x8_KHR; break; // NOTE: Requires OpenGL ES 3.1 or OpenGL 4.3 |
|
|
#endif |
|
|
#endif |
|
|
default: TRACELOG(LOG_WARNING, "Texture format not supported"); break; |
|
|
|
|
|
|
|
|
default: TRACELOG(LOG_WARNING, "TEXTURE: Current format not supported (%i)", format); break; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -2247,7 +2247,7 @@ RenderTexture2D rlLoadRenderTexture(int width, int height, int format, int depth |
|
|
|
|
|
|
|
|
// Check if fbo is complete with attachments (valid) |
|
|
// Check if fbo is complete with attachments (valid) |
|
|
//----------------------------------------------------------------------------------------------------- |
|
|
//----------------------------------------------------------------------------------------------------- |
|
|
if (rlRenderTextureComplete(target)) TRACELOG(LOG_INFO, "[FBO ID %i] Framebuffer object created successfully", target.id); |
|
|
|
|
|
|
|
|
if (rlRenderTextureComplete(target)) TRACELOG(LOG_INFO, "FBO: [ID %i] Framebuffer object created successfully", target.id); |
|
|
//----------------------------------------------------------------------------------------------------- |
|
|
//----------------------------------------------------------------------------------------------------- |
|
|
|
|
|
|
|
|
glBindFramebuffer(GL_FRAMEBUFFER, 0); |
|
|
glBindFramebuffer(GL_FRAMEBUFFER, 0); |
|
@ -2288,12 +2288,12 @@ bool rlRenderTextureComplete(RenderTexture target) |
|
|
{ |
|
|
{ |
|
|
switch (status) |
|
|
switch (status) |
|
|
{ |
|
|
{ |
|
|
case GL_FRAMEBUFFER_UNSUPPORTED: TRACELOG(LOG_WARNING, "Framebuffer is unsupported"); break; |
|
|
|
|
|
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT: TRACELOG(LOG_WARNING, "Framebuffer has incomplete attachment"); break; |
|
|
|
|
|
|
|
|
case GL_FRAMEBUFFER_UNSUPPORTED: TRACELOG(LOG_WARNING, "FBO: [ID %i] Framebuffer is unsupported", target.id); break; |
|
|
|
|
|
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT: TRACELOG(LOG_WARNING, "FBO: [ID %i] Framebuffer has incomplete attachment", target.id); break; |
|
|
#if defined(GRAPHICS_API_OPENGL_ES2) |
|
|
#if defined(GRAPHICS_API_OPENGL_ES2) |
|
|
case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS: TRACELOG(LOG_WARNING, "Framebuffer has incomplete dimensions"); break; |
|
|
|
|
|
|
|
|
case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS: TRACELOG(LOG_WARNING, "FBO: [ID %i] Framebuffer has incomplete dimensions", target.id); break; |
|
|
#endif |
|
|
#endif |
|
|
case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: TRACELOG(LOG_WARNING, "Framebuffer has a missing attachment"); break; |
|
|
|
|
|
|
|
|
case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: TRACELOG(LOG_WARNING, "FBO: [ID %i] Framebuffer has a missing attachment", target.id); break; |
|
|
default: break; |
|
|
default: break; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -2351,16 +2351,15 @@ void rlGenerateMipmaps(Texture2D *texture) |
|
|
texture->mipmaps = mipmapCount + 1; |
|
|
texture->mipmaps = mipmapCount + 1; |
|
|
RL_FREE(data); // Once mipmaps have been generated and data has been uploaded to GPU VRAM, we can discard RAM data |
|
|
RL_FREE(data); // Once mipmaps have been generated and data has been uploaded to GPU VRAM, we can discard RAM data |
|
|
|
|
|
|
|
|
TRACELOG(LOG_WARNING, "[TEX ID %i] Mipmaps [%i] generated manually on CPU side", texture->id, texture->mipmaps); |
|
|
|
|
|
|
|
|
TRACELOG(LOG_WARNING, "TEXTURE: [ID %i] Mipmaps generated manually on CPU side, total: %i", texture->id, texture->mipmaps); |
|
|
} |
|
|
} |
|
|
else TRACELOG(LOG_WARNING, "[TEX ID %i] Mipmaps could not be generated for texture format", texture->id); |
|
|
|
|
|
|
|
|
else TRACELOG(LOG_WARNING, "TEXTURE: [ID %i] Failed to generate mipmaps for provided texture format", texture->id); |
|
|
} |
|
|
} |
|
|
#elif defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
|
#elif defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
|
if ((texIsPOT) || (RLGL.ExtSupported.texNPOT)) |
|
|
if ((texIsPOT) || (RLGL.ExtSupported.texNPOT)) |
|
|
{ |
|
|
{ |
|
|
//glHint(GL_GENERATE_MIPMAP_HINT, GL_DONT_CARE); // Hint for mipmaps generation algorythm: GL_FASTEST, GL_NICEST, GL_DONT_CARE |
|
|
//glHint(GL_GENERATE_MIPMAP_HINT, GL_DONT_CARE); // Hint for mipmaps generation algorythm: GL_FASTEST, GL_NICEST, GL_DONT_CARE |
|
|
glGenerateMipmap(GL_TEXTURE_2D); // Generate mipmaps automatically |
|
|
glGenerateMipmap(GL_TEXTURE_2D); // Generate mipmaps automatically |
|
|
TRACELOG(LOG_INFO, "[TEX ID %i] Mipmaps generated automatically", texture->id); |
|
|
|
|
|
|
|
|
|
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); // Activate Trilinear filtering for mipmaps |
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); // Activate Trilinear filtering for mipmaps |
|
@ -2369,9 +2368,10 @@ void rlGenerateMipmaps(Texture2D *texture) |
|
|
#define MAX(a,b) (((a)>(b))?(a):(b)) |
|
|
#define MAX(a,b) (((a)>(b))?(a):(b)) |
|
|
|
|
|
|
|
|
texture->mipmaps = 1 + (int)floor(log(MAX(texture->width, texture->height))/log(2)); |
|
|
texture->mipmaps = 1 + (int)floor(log(MAX(texture->width, texture->height))/log(2)); |
|
|
|
|
|
TRACELOG(LOG_INFO, "TEXTURE: [ID %i] Mipmaps generated automatically, total: %i", texture->id, texture->mipmaps); |
|
|
} |
|
|
} |
|
|
#endif |
|
|
#endif |
|
|
else TRACELOG(LOG_WARNING, "[TEX ID %i] Mipmaps can not be generated", texture->id); |
|
|
|
|
|
|
|
|
else TRACELOG(LOG_WARNING, "TEXTURE: [ID %i] Failed to generate mipmaps", texture->id); |
|
|
|
|
|
|
|
|
glBindTexture(GL_TEXTURE_2D, 0); |
|
|
glBindTexture(GL_TEXTURE_2D, 0); |
|
|
} |
|
|
} |
|
@ -2382,7 +2382,7 @@ void rlLoadMesh(Mesh *mesh, bool dynamic) |
|
|
if (mesh->vaoId > 0) |
|
|
if (mesh->vaoId > 0) |
|
|
{ |
|
|
{ |
|
|
// Check if mesh has already been loaded in GPU |
|
|
// Check if mesh has already been loaded in GPU |
|
|
TRACELOG(LOG_WARNING, "Trying to re-load an already loaded mesh"); |
|
|
|
|
|
|
|
|
TRACELOG(LOG_WARNING, "VAO: [ID %i] Trying to re-load an already loaded mesh", mesh->vaoId); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -2495,12 +2495,12 @@ void rlLoadMesh(Mesh *mesh, bool dynamic) |
|
|
|
|
|
|
|
|
if (RLGL.ExtSupported.vao) |
|
|
if (RLGL.ExtSupported.vao) |
|
|
{ |
|
|
{ |
|
|
if (mesh->vaoId > 0) TRACELOG(LOG_INFO, "[VAO ID %i] Mesh uploaded successfully to VRAM (GPU)", mesh->vaoId); |
|
|
|
|
|
else TRACELOG(LOG_WARNING, "Mesh could not be uploaded to VRAM (GPU)"); |
|
|
|
|
|
|
|
|
if (mesh->vaoId > 0) TRACELOG(LOG_INFO, "VAO: [ID %i] Mesh uploaded successfully to VRAM (GPU)", mesh->vaoId); |
|
|
|
|
|
else TRACELOG(LOG_WARNING, "VAO: Failed to load mesh to VRAM (GPU)"); |
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
|
{ |
|
|
{ |
|
|
TRACELOG(LOG_INFO, "[VBOs] Mesh uploaded successfully to VRAM (GPU)"); |
|
|
|
|
|
|
|
|
TRACELOG(LOG_INFO, "VBO: Mesh uploaded successfully to VRAM (GPU)"); |
|
|
} |
|
|
} |
|
|
#endif |
|
|
#endif |
|
|
} |
|
|
} |
|
@ -2898,7 +2898,7 @@ void *rlReadTexturePixels(Texture2D texture) |
|
|
pixels = (unsigned char *)RL_MALLOC(size); |
|
|
pixels = (unsigned char *)RL_MALLOC(size); |
|
|
glGetTexImage(GL_TEXTURE_2D, 0, glFormat, glType, pixels); |
|
|
glGetTexImage(GL_TEXTURE_2D, 0, glFormat, glType, pixels); |
|
|
} |
|
|
} |
|
|
else TRACELOG(LOG_WARNING, "Texture data retrieval not suported for pixel format"); |
|
|
|
|
|
|
|
|
else TRACELOG(LOG_WARNING, "TEXTURE: [ID %i] Data retrieval not suported for pixel format (%i)", texture.id, texture.format); |
|
|
|
|
|
|
|
|
glBindTexture(GL_TEXTURE_2D, 0); |
|
|
glBindTexture(GL_TEXTURE_2D, 0); |
|
|
#endif |
|
|
#endif |
|
@ -3034,7 +3034,7 @@ Shader LoadShaderCode(const char *vsCode, const char *fsCode) |
|
|
|
|
|
|
|
|
if (shader.id == 0) |
|
|
if (shader.id == 0) |
|
|
{ |
|
|
{ |
|
|
TRACELOG(LOG_WARNING, "Custom shader could not be loaded"); |
|
|
|
|
|
|
|
|
TRACELOG(LOG_WARNING, "SHADER: Failed to load custom shader code"); |
|
|
shader = RLGL.State.defaultShader; |
|
|
shader = RLGL.State.defaultShader; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -3060,7 +3060,7 @@ Shader LoadShaderCode(const char *vsCode, const char *fsCode) |
|
|
|
|
|
|
|
|
name[namelen] = 0; |
|
|
name[namelen] = 0; |
|
|
|
|
|
|
|
|
TRACELOGD("[SHDR ID %i] Active uniform [%s] set at location: %i", shader.id, name, glGetUniformLocation(shader.id, name)); |
|
|
|
|
|
|
|
|
TRACELOGD("SHADER: [ID %i] Active uniform (%s) set at location: %i", shader.id, name, glGetUniformLocation(shader.id, name)); |
|
|
} |
|
|
} |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
@ -3073,7 +3073,7 @@ void UnloadShader(Shader shader) |
|
|
if (shader.id > 0) |
|
|
if (shader.id > 0) |
|
|
{ |
|
|
{ |
|
|
rlDeleteShader(shader.id); |
|
|
rlDeleteShader(shader.id); |
|
|
TRACELOG(LOG_INFO, "[SHDR ID %i] Unloaded shader program data", shader.id); |
|
|
|
|
|
|
|
|
TRACELOG(LOG_INFO, "SHADER: [ID %i] Unloaded shader program data from VRAM (GPU)", shader.id); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
RL_FREE(shader.locs); |
|
|
RL_FREE(shader.locs); |
|
@ -3106,8 +3106,8 @@ int GetShaderLocation(Shader shader, const char *uniformName) |
|
|
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
|
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
|
location = glGetUniformLocation(shader.id, uniformName); |
|
|
location = glGetUniformLocation(shader.id, uniformName); |
|
|
|
|
|
|
|
|
if (location == -1) TRACELOG(LOG_WARNING, "[SHDR ID %i][%s] Shader uniform could not be found", shader.id, uniformName); |
|
|
|
|
|
else TRACELOG(LOG_INFO, "[SHDR ID %i][%s] Shader uniform set at location: %i", shader.id, uniformName, location); |
|
|
|
|
|
|
|
|
if (location == -1) TRACELOG(LOG_WARNING, "SHADER: [ID %i] Failed to find shader uniform: %s", shader.id, uniformName); |
|
|
|
|
|
else TRACELOG(LOG_INFO, "SHADER: [ID %i] Shader uniform (%s) set at location: %i", shader.id, uniformName, location); |
|
|
#endif |
|
|
#endif |
|
|
return location; |
|
|
return location; |
|
|
} |
|
|
} |
|
@ -3135,7 +3135,7 @@ void SetShaderValueV(Shader shader, int uniformLoc, const void *value, int unifo |
|
|
case UNIFORM_IVEC3: glUniform3iv(uniformLoc, count, (int *)value); break; |
|
|
case UNIFORM_IVEC3: glUniform3iv(uniformLoc, count, (int *)value); break; |
|
|
case UNIFORM_IVEC4: glUniform4iv(uniformLoc, count, (int *)value); break; |
|
|
case UNIFORM_IVEC4: glUniform4iv(uniformLoc, count, (int *)value); break; |
|
|
case UNIFORM_SAMPLER2D: glUniform1iv(uniformLoc, count, (int *)value); break; |
|
|
case UNIFORM_SAMPLER2D: glUniform1iv(uniformLoc, count, (int *)value); break; |
|
|
default: TRACELOG(LOG_WARNING, "Shader uniform could not be set data type not recognized"); |
|
|
|
|
|
|
|
|
default: TRACELOG(LOG_WARNING, "SHADER: [ID %i] Failed to set uniform, data type not recognized", shader.id); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//glUseProgram(0); // Avoid reseting current shader program, in case other uniforms are set |
|
|
//glUseProgram(0); // Avoid reseting current shader program, in case other uniforms are set |
|
@ -3579,7 +3579,7 @@ void InitVrSimulator(void) |
|
|
|
|
|
|
|
|
RLGL.Vr.simulatorReady = true; |
|
|
RLGL.Vr.simulatorReady = true; |
|
|
#else |
|
|
#else |
|
|
TRACELOG(LOG_WARNING, "VR Simulator not supported on OpenGL 1.1"); |
|
|
|
|
|
|
|
|
TRACELOG(LOG_WARNING, "RLGL: VR Simulator not supported on OpenGL 1.1"); |
|
|
#endif |
|
|
#endif |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -3627,17 +3627,18 @@ void SetVrConfiguration(VrDeviceInfo hmd, Shader distortion) |
|
|
hmd.lensDistortionValues[2]*lensRadiusSq*lensRadiusSq + |
|
|
hmd.lensDistortionValues[2]*lensRadiusSq*lensRadiusSq + |
|
|
hmd.lensDistortionValues[3]*lensRadiusSq*lensRadiusSq*lensRadiusSq; |
|
|
hmd.lensDistortionValues[3]*lensRadiusSq*lensRadiusSq*lensRadiusSq; |
|
|
|
|
|
|
|
|
TRACELOGD("VR: Distortion Scale: %f", distortionScale); |
|
|
|
|
|
|
|
|
TRACELOGD("RLGL: VR device configuration:"); |
|
|
|
|
|
TRACELOGD(" > Distortion Scale: %f", distortionScale); |
|
|
|
|
|
|
|
|
float normScreenWidth = 0.5f; |
|
|
float normScreenWidth = 0.5f; |
|
|
float normScreenHeight = 1.0f; |
|
|
float normScreenHeight = 1.0f; |
|
|
float scaleIn[2] = { 2.0f/normScreenWidth, 2.0f/normScreenHeight/aspect }; |
|
|
float scaleIn[2] = { 2.0f/normScreenWidth, 2.0f/normScreenHeight/aspect }; |
|
|
float scale[2] = { normScreenWidth*0.5f/distortionScale, normScreenHeight*0.5f*aspect/distortionScale }; |
|
|
float scale[2] = { normScreenWidth*0.5f/distortionScale, normScreenHeight*0.5f*aspect/distortionScale }; |
|
|
|
|
|
|
|
|
TRACELOGD("VR: Distortion Shader: LeftLensCenter = { %f, %f }", leftLensCenter[0], leftLensCenter[1]); |
|
|
|
|
|
TRACELOGD("VR: Distortion Shader: RightLensCenter = { %f, %f }", rightLensCenter[0], rightLensCenter[1]); |
|
|
|
|
|
TRACELOGD("VR: Distortion Shader: Scale = { %f, %f }", scale[0], scale[1]); |
|
|
|
|
|
TRACELOGD("VR: Distortion Shader: ScaleIn = { %f, %f }", scaleIn[0], scaleIn[1]); |
|
|
|
|
|
|
|
|
TRACELOGD(" > Distortion Shader: LeftLensCenter = { %f, %f }", leftLensCenter[0], leftLensCenter[1]); |
|
|
|
|
|
TRACELOGD(" > Distortion Shader: RightLensCenter = { %f, %f }", rightLensCenter[0], rightLensCenter[1]); |
|
|
|
|
|
TRACELOGD(" > Distortion Shader: Scale = { %f, %f }", scale[0], scale[1]); |
|
|
|
|
|
TRACELOGD(" > Distortion Shader: ScaleIn = { %f, %f }", scaleIn[0], scaleIn[1]); |
|
|
|
|
|
|
|
|
// Fovy is normally computed with: 2*atan2f(hmd.vScreenSize, 2*hmd.eyeToScreenDistance) |
|
|
// Fovy is normally computed with: 2*atan2f(hmd.vScreenSize, 2*hmd.eyeToScreenDistance) |
|
|
// ...but with lens distortion it is increased (see Oculus SDK Documentation) |
|
|
// ...but with lens distortion it is increased (see Oculus SDK Documentation) |
|
@ -3816,7 +3817,7 @@ static unsigned int CompileShader(const char *shaderStr, int type) |
|
|
|
|
|
|
|
|
if (success != GL_TRUE) |
|
|
if (success != GL_TRUE) |
|
|
{ |
|
|
{ |
|
|
TRACELOG(LOG_WARNING, "[SHDR ID %i] Failed to compile shader...", shader); |
|
|
|
|
|
|
|
|
TRACELOG(LOG_WARNING, "SHADER: [ID %i] Failed to compile shader code", shader); |
|
|
int maxLength = 0; |
|
|
int maxLength = 0; |
|
|
int length; |
|
|
int length; |
|
|
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &maxLength); |
|
|
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &maxLength); |
|
@ -3828,13 +3829,13 @@ static unsigned int CompileShader(const char *shaderStr, int type) |
|
|
#endif |
|
|
#endif |
|
|
glGetShaderInfoLog(shader, maxLength, &length, log); |
|
|
glGetShaderInfoLog(shader, maxLength, &length, log); |
|
|
|
|
|
|
|
|
TRACELOG(LOG_INFO, "%s", log); |
|
|
|
|
|
|
|
|
TRACELOG(LOG_WARNING, "SHADER: [ID %i] Compile error: %s", shader, log); |
|
|
|
|
|
|
|
|
#if defined(_MSC_VER) |
|
|
#if defined(_MSC_VER) |
|
|
RL_FREE(log); |
|
|
RL_FREE(log); |
|
|
#endif |
|
|
#endif |
|
|
} |
|
|
} |
|
|
else TRACELOG(LOG_INFO, "[SHDR ID %i] Shader compiled successfully", shader); |
|
|
|
|
|
|
|
|
else TRACELOG(LOG_INFO, "SHADER: [ID %i] Compiled successfully", shader); |
|
|
|
|
|
|
|
|
return shader; |
|
|
return shader; |
|
|
} |
|
|
} |
|
@ -3870,7 +3871,7 @@ static unsigned int LoadShaderProgram(unsigned int vShaderId, unsigned int fShad |
|
|
|
|
|
|
|
|
if (success == GL_FALSE) |
|
|
if (success == GL_FALSE) |
|
|
{ |
|
|
{ |
|
|
TRACELOG(LOG_WARNING, "[SHDR ID %i] Failed to link shader program...", program); |
|
|
|
|
|
|
|
|
TRACELOG(LOG_WARNING, "SHADER: [ID %i] Failed to link shader program", program); |
|
|
|
|
|
|
|
|
int maxLength = 0; |
|
|
int maxLength = 0; |
|
|
int length; |
|
|
int length; |
|
@ -3884,7 +3885,7 @@ static unsigned int LoadShaderProgram(unsigned int vShaderId, unsigned int fShad |
|
|
#endif |
|
|
#endif |
|
|
glGetProgramInfoLog(program, maxLength, &length, log); |
|
|
glGetProgramInfoLog(program, maxLength, &length, log); |
|
|
|
|
|
|
|
|
TRACELOG(LOG_INFO, "%s", log); |
|
|
|
|
|
|
|
|
TRACELOG(LOG_WARNING, "SHADER: [ID %i] Link error: %s", program, log); |
|
|
|
|
|
|
|
|
#if defined(_MSC_VER) |
|
|
#if defined(_MSC_VER) |
|
|
RL_FREE(log); |
|
|
RL_FREE(log); |
|
@ -3893,7 +3894,7 @@ static unsigned int LoadShaderProgram(unsigned int vShaderId, unsigned int fShad |
|
|
|
|
|
|
|
|
program = 0; |
|
|
program = 0; |
|
|
} |
|
|
} |
|
|
else TRACELOG(LOG_INFO, "[SHDR ID %i] Shader program loaded successfully", program); |
|
|
|
|
|
|
|
|
else TRACELOG(LOG_INFO, "SHADER: [ID %i] Program loaded successfully", program); |
|
|
#endif |
|
|
#endif |
|
|
return program; |
|
|
return program; |
|
|
} |
|
|
} |
|
@ -3976,7 +3977,7 @@ static Shader LoadShaderDefault(void) |
|
|
|
|
|
|
|
|
if (shader.id > 0) |
|
|
if (shader.id > 0) |
|
|
{ |
|
|
{ |
|
|
TRACELOG(LOG_INFO, "[SHDR ID %i] Default shader loaded successfully", shader.id); |
|
|
|
|
|
|
|
|
TRACELOG(LOG_INFO, "SHADER: [ID %i] Default shader loaded successfully", shader.id); |
|
|
|
|
|
|
|
|
// Set default shader locations: attributes locations |
|
|
// Set default shader locations: attributes locations |
|
|
shader.locs[LOC_VERTEX_POSITION] = glGetAttribLocation(shader.id, "vertexPosition"); |
|
|
shader.locs[LOC_VERTEX_POSITION] = glGetAttribLocation(shader.id, "vertexPosition"); |
|
@ -3992,7 +3993,7 @@ static Shader LoadShaderDefault(void) |
|
|
// changed for external custom shaders, we just use direct bindings above |
|
|
// changed for external custom shaders, we just use direct bindings above |
|
|
//SetShaderDefaultLocations(&shader); |
|
|
//SetShaderDefaultLocations(&shader); |
|
|
} |
|
|
} |
|
|
else TRACELOG(LOG_WARNING, "[SHDR ID %i] Default shader could not be loaded", shader.id); |
|
|
|
|
|
|
|
|
else TRACELOG(LOG_WARNING, "SHADER: [ID %i] Failed to load default shader", shader.id); |
|
|
|
|
|
|
|
|
return shader; |
|
|
return shader; |
|
|
} |
|
|
} |
|
@ -4082,7 +4083,7 @@ static void LoadBuffersDefault(void) |
|
|
RLGL.State.vertexData[i].cCounter = 0; |
|
|
RLGL.State.vertexData[i].cCounter = 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
TRACELOG(LOG_INFO, "Internal buffers initialized successfully (CPU)"); |
|
|
|
|
|
|
|
|
TRACELOG(LOG_INFO, "RLGL: Internal vertex buffers initialized successfully in RAM (CPU)"); |
|
|
//-------------------------------------------------------------------------------------------- |
|
|
//-------------------------------------------------------------------------------------------- |
|
|
|
|
|
|
|
|
// Upload to GPU (VRAM) vertex data and initialize VAOs/VBOs |
|
|
// Upload to GPU (VRAM) vertex data and initialize VAOs/VBOs |
|
@ -4128,7 +4129,7 @@ static void LoadBuffersDefault(void) |
|
|
#endif |
|
|
#endif |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
TRACELOG(LOG_INFO, "Internal buffers uploaded successfully (GPU)"); |
|
|
|
|
|
|
|
|
TRACELOG(LOG_INFO, "RLGL: Internal vertex buffers uploaded successfully to VRAM (GPU)"); |
|
|
|
|
|
|
|
|
// Unbind the current VAO |
|
|
// Unbind the current VAO |
|
|
if (RLGL.ExtSupported.vao) glBindVertexArray(0); |
|
|
if (RLGL.ExtSupported.vao) glBindVertexArray(0); |
|
@ -4488,20 +4489,20 @@ static int GenerateMipmaps(unsigned char *data, int baseWidth, int baseHeight) |
|
|
if (width != 1) width /= 2; |
|
|
if (width != 1) width /= 2; |
|
|
if (height != 1) height /= 2; |
|
|
if (height != 1) height /= 2; |
|
|
|
|
|
|
|
|
TRACELOGD("Next mipmap size: %i x %i", width, height); |
|
|
|
|
|
|
|
|
TRACELOGD("TEXTURE: Next mipmap size: %i x %i", width, height); |
|
|
|
|
|
|
|
|
mipmapCount++; |
|
|
mipmapCount++; |
|
|
|
|
|
|
|
|
size += (width*height*4); // Add mipmap size (in bytes) |
|
|
size += (width*height*4); // Add mipmap size (in bytes) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
TRACELOGD("Total mipmaps required: %i", mipmapCount); |
|
|
|
|
|
TRACELOGD("Total size of data required: %i", size); |
|
|
|
|
|
|
|
|
TRACELOGD("TEXTURE: Total mipmaps required: %i", mipmapCount); |
|
|
|
|
|
TRACELOGD("TEXTURE: Total size of data required: %i", size); |
|
|
|
|
|
|
|
|
unsigned char *temp = RL_REALLOC(data, size); |
|
|
unsigned char *temp = RL_REALLOC(data, size); |
|
|
|
|
|
|
|
|
if (temp != NULL) data = temp; |
|
|
if (temp != NULL) data = temp; |
|
|
else TRACELOG(LOG_WARNING, "Mipmaps required memory could not be allocated"); |
|
|
|
|
|
|
|
|
else TRACELOG(LOG_WARNING, "TEXTURE: Failed to allocate required mipmaps memory"); |
|
|
|
|
|
|
|
|
width = baseWidth; |
|
|
width = baseWidth; |
|
|
height = baseHeight; |
|
|
height = baseHeight; |
|
@ -4523,7 +4524,7 @@ static int GenerateMipmaps(unsigned char *data, int baseWidth, int baseHeight) |
|
|
j++; |
|
|
j++; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
TRACELOGD("Mipmap base (%ix%i)", width, height); |
|
|
|
|
|
|
|
|
TRACELOGD("TEXTURE: Mipmap base size (%ix%i)", width, height); |
|
|
|
|
|
|
|
|
for (int mip = 1; mip < mipmapCount; mip++) |
|
|
for (int mip = 1; mip < mipmapCount; mip++) |
|
|
{ |
|
|
{ |
|
@ -4594,7 +4595,7 @@ static Color *GenNextMipmap(Color *srcData, int srcWidth, int srcHeight) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
TRACELOGD("Mipmap generated successfully (%ix%i)", width, height); |
|
|
|
|
|
|
|
|
TRACELOGD("TEXTURE: Mipmap generated successfully (%ix%i)", width, height); |
|
|
|
|
|
|
|
|
return mipmap; |
|
|
return mipmap; |
|
|
} |
|
|
} |
|
@ -4632,15 +4633,15 @@ char *LoadFileText(const char *fileName) |
|
|
// Zero-terminate the string |
|
|
// Zero-terminate the string |
|
|
text[count] = '\0'; |
|
|
text[count] = '\0'; |
|
|
|
|
|
|
|
|
TRACELOG(LOG_INFO, "[%s] Text file loaded successfully", fileName); |
|
|
|
|
|
|
|
|
TRACELOG(LOG_INFO, "FILEIO: [%s] Text file loaded successfully", fileName); |
|
|
} |
|
|
} |
|
|
else TRACELOG(LOG_WARNING, "[%s] Text file could not be read", fileName); |
|
|
|
|
|
|
|
|
else TRACELOG(LOG_WARNING, "FILEIO: [%s] Failed to read text file", fileName); |
|
|
|
|
|
|
|
|
fclose(textFile); |
|
|
fclose(textFile); |
|
|
} |
|
|
} |
|
|
else TRACELOG(LOG_WARNING, "[%s] Text file could not be opened", fileName); |
|
|
|
|
|
|
|
|
else TRACELOG(LOG_WARNING, "FILEIO: [%s] Failed to open text file", fileName); |
|
|
} |
|
|
} |
|
|
else TRACELOG(LOG_WARNING, "File name provided is not valid"); |
|
|
|
|
|
|
|
|
else TRACELOG(LOG_WARNING, "FILEIO: File name provided is not valid"); |
|
|
|
|
|
|
|
|
return text; |
|
|
return text; |
|
|
} |
|
|
} |
|
|