Simplify a bit GenTexture*() functions

Still shader dependant, locations set should be moved out
This commit is contained in:
raysan5 2017-07-20 14:27:59 +02:00
parent 4c06725461
commit 63fd96354e

View File

@ -2519,10 +2519,9 @@ Texture2D GenTextureCubemap(Shader shader, Texture2D skyHDR, int size)
{ {
Texture2D cubemap = { 0 }; Texture2D cubemap = { 0 };
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
// Get cubemap shader locations // NOTE: SetShaderDefaultLocations() already setups locations for projection and view Matrix in shader
//int projectionLoc = GetShaderLocation(shader, "projection"); // Already set at SetShaderDefaultLocations() // TODO: Locations should be taken out of this function... too shader dependant...
//int viewLoc = GetShaderLocation(shader, "view"); // Already set at SetShaderDefaultLocations() SetShaderValuei(shader, GetShaderLocation(shader, "environmentMap"), (int[1]){ 0 }, 1);
int texmapLoc = GetShaderLocation(shader, "equirectangularMap");
SetShaderValuei(shader, texmapLoc, (int[1]){ 0 }, 1); // Set default active texture to 0 SetShaderValuei(shader, texmapLoc, (int[1]){ 0 }, 1); // Set default active texture to 0
@ -2598,14 +2597,11 @@ Texture2D GenTextureCubemap(Shader shader, Texture2D skyHDR, int size)
Texture2D GenTextureIrradiance(Shader shader, Texture2D cubemap, int size) Texture2D GenTextureIrradiance(Shader shader, Texture2D cubemap, int size)
{ {
Texture2D irradiance = { 0 }; Texture2D irradiance = { 0 };
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
// Get irradiance shader locations
//int projectionLoc = GetShaderLocation(shader, "projection"); // Already set at SetShaderDefaultLocations()
//int viewLoc = GetShaderLocation(shader, "view"); // Already set at SetShaderDefaultLocations()
int texmapLoc = GetShaderLocation(shader, "environmentMap");
// Set up shaders constant values #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
SetShaderValuei(shader, texmapLoc, (int[1]){ 0 }, 1); // NOTE: SetShaderDefaultLocations() already setups locations for projection and view Matrix in shader
// TODO: Locations should be taken out of this function... too shader dependant...
SetShaderValuei(shader, GetShaderLocation(shader, "environmentMap"), (int[1]){ 0 }, 1);
// Setup framebuffer // Setup framebuffer
unsigned int fbo, rbo; unsigned int fbo, rbo;
@ -2673,14 +2669,12 @@ Texture2D GenTextureIrradiance(Shader shader, Texture2D cubemap, int size)
Texture2D GenTexturePrefilter(Shader shader, Texture2D cubemap, int size) Texture2D GenTexturePrefilter(Shader shader, Texture2D cubemap, int size)
{ {
Texture2D prefilter = { 0 }; Texture2D prefilter = { 0 };
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
// Get prefilter shader locations
//int projectionLoc = GetShaderLocation(shader, "projection"); // Already set at SetShaderDefaultLocations()
//int viewLoc = GetShaderLocation(shader, "view"); // Already set at SetShaderDefaultLocations()
int roughnessLoc = GetShaderLocation(shader, "roughness");
int texmapLoc = GetShaderLocation(shader, "environmentMap");
SetShaderValuei(shader, texmapLoc, (int[1]){ 0 }, 1); #if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
// NOTE: SetShaderDefaultLocations() already setups locations for projection and view Matrix in shader
// TODO: Locations should be taken out of this function... too shader dependant...
int roughnessLoc = GetShaderLocation(shader, "roughness");
SetShaderValuei(shader, GetShaderLocation(shader, "environmentMap"), (int[1]){ 0 }, 1);
// Setup framebuffer // Setup framebuffer
unsigned int fbo, rbo; unsigned int fbo, rbo;