parent
97cb212bf0
commit
5013830647
7 changed files with 62 additions and 50 deletions
24
lib/rlgl.h
vendored
24
lib/rlgl.h
vendored
|
|
@ -56,8 +56,8 @@
|
|||
*
|
||||
* #define RL_MAX_MATRIX_STACK_SIZE 32 // Maximum size of internal Matrix stack
|
||||
* #define RL_MAX_SHADER_LOCATIONS 32 // Maximum number of shader locations supported
|
||||
* #define RL_CULL_DISTANCE_NEAR 0.001 // Default projection matrix near cull distance
|
||||
* #define RL_CULL_DISTANCE_FAR 10000.0 // Default projection matrix far cull distance
|
||||
* #define RL_CULL_DISTANCE_NEAR 0.05 // Default projection matrix near cull distance
|
||||
* #define RL_CULL_DISTANCE_FAR 4000.0 // Default projection matrix far cull distance
|
||||
*
|
||||
* When loading a shader, the following vertex attributes and uniform
|
||||
* location names are tried to be set automatically:
|
||||
|
|
@ -234,10 +234,10 @@
|
|||
|
||||
// Projection matrix culling
|
||||
#ifndef RL_CULL_DISTANCE_NEAR
|
||||
#define RL_CULL_DISTANCE_NEAR 0.001 // Default near cull distance
|
||||
#define RL_CULL_DISTANCE_NEAR 0.05 // Default near cull distance
|
||||
#endif
|
||||
#ifndef RL_CULL_DISTANCE_FAR
|
||||
#define RL_CULL_DISTANCE_FAR 10000.0 // Default far cull distance
|
||||
#define RL_CULL_DISTANCE_FAR 4000.0 // Default far cull distance
|
||||
#endif
|
||||
|
||||
// Texture parameters (equivalent to OpenGL defines)
|
||||
|
|
@ -1748,7 +1748,6 @@ void rlTextureParameters(unsigned int id, int param, int value)
|
|||
#endif
|
||||
}
|
||||
else glTexParameteri(GL_TEXTURE_2D, param, value);
|
||||
|
||||
} break;
|
||||
case RL_TEXTURE_MAG_FILTER:
|
||||
case RL_TEXTURE_MIN_FILTER: glTexParameteri(GL_TEXTURE_2D, param, value); break;
|
||||
|
|
@ -1793,7 +1792,6 @@ void rlCubemapParameters(unsigned int id, int param, int value)
|
|||
else TRACELOG(RL_LOG_WARNING, "GL: Clamp mirror wrap mode not supported (GL_MIRROR_CLAMP_EXT)");
|
||||
}
|
||||
else glTexParameteri(GL_TEXTURE_CUBE_MAP, param, value);
|
||||
|
||||
} break;
|
||||
case RL_TEXTURE_MAG_FILTER:
|
||||
case RL_TEXTURE_MIN_FILTER: glTexParameteri(GL_TEXTURE_CUBE_MAP, param, value); break;
|
||||
|
|
@ -2112,14 +2110,12 @@ void rlSetBlendMode(int mode)
|
|||
{
|
||||
// NOTE: Using GL blend src/dst factors and GL equation configured with rlSetBlendFactors()
|
||||
glBlendFunc(RLGL.State.glBlendSrcFactor, RLGL.State.glBlendDstFactor); glBlendEquation(RLGL.State.glBlendEquation);
|
||||
|
||||
} break;
|
||||
case RL_BLEND_CUSTOM_SEPARATE:
|
||||
{
|
||||
// NOTE: Using GL blend src/dst factors and GL equation configured with rlSetBlendFactorsSeparate()
|
||||
glBlendFuncSeparate(RLGL.State.glBlendSrcFactorRGB, RLGL.State.glBlendDestFactorRGB, RLGL.State.glBlendSrcFactorAlpha, RLGL.State.glBlendDestFactorAlpha);
|
||||
glBlendEquationSeparate(RLGL.State.glBlendEquationRGB, RLGL.State.glBlendEquationAlpha);
|
||||
|
||||
} break;
|
||||
default: break;
|
||||
}
|
||||
|
|
@ -2429,7 +2425,7 @@ void rlLoadExtensions(void *loader)
|
|||
|
||||
// Get supported extensions list
|
||||
GLint numExt = 0;
|
||||
const char **extList = RL_MALLOC(512*sizeof(const char *)); // Allocate 512 strings pointers (2 KB)
|
||||
const char **extList = (const char **)RL_MALLOC(512*sizeof(const char *)); // Allocate 512 strings pointers (2 KB)
|
||||
const char *extensions = (const char *)glGetString(GL_EXTENSIONS); // One big const string
|
||||
|
||||
// NOTE: We have to duplicate string because glGetString() returns a const string
|
||||
|
|
@ -3311,7 +3307,7 @@ unsigned int rlLoadTexture(const void *data, int width, int height, int format,
|
|||
// Activate Trilinear filtering if mipmaps are available
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, mipmapCount); // user defined mip count would break without this.
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, mipmapCount); // Required for user-defined mip count
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -3684,7 +3680,7 @@ unsigned char *rlReadScreenPixels(int width, int height)
|
|||
|
||||
// Flip image vertically!
|
||||
// NOTE: Alpha value has already been applied to RGB in framebuffer, we don't need it!
|
||||
for (int y = height - 1; y >= height / 2; y--)
|
||||
for (int y = height - 1; y >= height/2; y--)
|
||||
{
|
||||
for (int x = 0; x < (width*4); x += 4)
|
||||
{
|
||||
|
|
@ -3747,19 +3743,16 @@ void rlFramebufferAttach(unsigned int fboId, unsigned int texId, int attachType,
|
|||
if (texType == RL_ATTACHMENT_TEXTURE2D) glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + attachType, GL_TEXTURE_2D, texId, mipLevel);
|
||||
else if (texType == RL_ATTACHMENT_RENDERBUFFER) glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + attachType, GL_RENDERBUFFER, texId);
|
||||
else if (texType >= RL_ATTACHMENT_CUBEMAP_POSITIVE_X) glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + attachType, GL_TEXTURE_CUBE_MAP_POSITIVE_X + texType, texId, mipLevel);
|
||||
|
||||
} break;
|
||||
case RL_ATTACHMENT_DEPTH:
|
||||
{
|
||||
if (texType == RL_ATTACHMENT_TEXTURE2D) glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, texId, mipLevel);
|
||||
else if (texType == RL_ATTACHMENT_RENDERBUFFER) glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, texId);
|
||||
|
||||
} break;
|
||||
case RL_ATTACHMENT_STENCIL:
|
||||
{
|
||||
if (texType == RL_ATTACHMENT_TEXTURE2D) glFramebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, texId, mipLevel);
|
||||
else if (texType == RL_ATTACHMENT_RENDERBUFFER) glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, texId);
|
||||
|
||||
} break;
|
||||
default: break;
|
||||
}
|
||||
|
|
@ -4185,6 +4178,9 @@ unsigned int rlCompileShader(const char *shaderCode, int type)
|
|||
RL_FREE(log);
|
||||
}
|
||||
|
||||
// Unload object allocated by glCreateShader(),
|
||||
// despite failing in the compilation process
|
||||
glDeleteShader(shader);
|
||||
shader = 0;
|
||||
}
|
||||
else
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue