WARNING: BREAKING: REDESIGNED: rlgl module
- Many functions renamed to follow rl*() convention - Some internal functions exposed in the API - Some functionality moved to other modules - Reorganized all functions by categories - Make sure it keeps working with OpenGL 1.1 and 2.1
This commit is contained in:
parent
24dae29a03
commit
2ce28f75ad
4 changed files with 997 additions and 979 deletions
50
src/core.c
50
src/core.c
|
@ -2034,7 +2034,37 @@ Shader LoadShader(const char *vsFileName, const char *fsFileName)
|
|||
if (fShaderStr != NULL) RL_FREE(fShaderStr);
|
||||
|
||||
// After shader loading, we TRY to set default location names
|
||||
if (shader.id > 0) SetShaderDefaultLocations(&shader);
|
||||
if (shader.id > 0)
|
||||
{
|
||||
// Default shader attrib locations have been fixed before linking:
|
||||
// vertex position location = 0
|
||||
// vertex texcoord location = 1
|
||||
// vertex normal location = 2
|
||||
// vertex color location = 3
|
||||
// vertex tangent location = 4
|
||||
// vertex texcoord2 location = 5
|
||||
|
||||
// NOTE: If any location is not found, loc point becomes -1
|
||||
|
||||
// Get handles to GLSL input attibute locations
|
||||
shader.locs[SHADER_LOC_VERTEX_POSITION] = rlGetLocationAttrib(shader.id, DEFAULT_SHADER_ATTRIB_NAME_POSITION);
|
||||
shader.locs[SHADER_LOC_VERTEX_TEXCOORD01] = rlGetLocationAttrib(shader.id, DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD);
|
||||
shader.locs[SHADER_LOC_VERTEX_TEXCOORD02] = rlGetLocationAttrib(shader.id, DEFAULT_SHADER_ATTRIB_NAME_TEXCOORD2);
|
||||
shader.locs[SHADER_LOC_VERTEX_NORMAL] = rlGetLocationAttrib(shader.id, DEFAULT_SHADER_ATTRIB_NAME_NORMAL);
|
||||
shader.locs[SHADER_LOC_VERTEX_TANGENT] = rlGetLocationAttrib(shader.id, DEFAULT_SHADER_ATTRIB_NAME_TANGENT);
|
||||
shader.locs[SHADER_LOC_VERTEX_COLOR] = rlGetLocationAttrib(shader.id, DEFAULT_SHADER_ATTRIB_NAME_COLOR);
|
||||
|
||||
// Get handles to GLSL uniform locations (vertex shader)
|
||||
shader.locs[SHADER_LOC_MATRIX_MVP] = rlGetLocationUniform(shader.id, "mvp");
|
||||
shader.locs[SHADER_LOC_MATRIX_PROJECTION] = rlGetLocationUniform(shader.id, "projection");
|
||||
shader.locs[SHADER_LOC_MATRIX_VIEW] = rlGetLocationUniform(shader.id, "view");
|
||||
|
||||
// Get handles to GLSL uniform locations (fragment shader)
|
||||
shader.locs[SHADER_LOC_COLOR_DIFFUSE] = rlGetLocationUniform(shader.id, "colDiffuse");
|
||||
shader.locs[SHADER_LOC_MAP_DIFFUSE] = rlGetLocationUniform(shader.id, "texture0");
|
||||
shader.locs[SHADER_LOC_MAP_SPECULAR] = rlGetLocationUniform(shader.id, "texture1");
|
||||
shader.locs[SHADER_LOC_MAP_NORMAL] = rlGetLocationUniform(shader.id, "texture2");
|
||||
}
|
||||
|
||||
return shader;
|
||||
}
|
||||
|
@ -2046,15 +2076,13 @@ void UnloadShader(Shader shader)
|
|||
{
|
||||
rlUnloadShaderProgram(shader.id);
|
||||
RL_FREE(shader.locs);
|
||||
|
||||
TRACELOG(LOG_INFO, "SHADER: [ID %i] Unloaded shader program data from VRAM (GPU)", shader.id);
|
||||
}
|
||||
}
|
||||
|
||||
// Begin custom shader mode
|
||||
void BeginShaderMode(Shader shader)
|
||||
{
|
||||
rlSetShaderCurrent(shader);
|
||||
rlSetShaderActive(shader);
|
||||
}
|
||||
|
||||
// End custom shader mode (returns to default shader)
|
||||
|
@ -2066,23 +2094,13 @@ void EndShaderMode(void)
|
|||
// Get shader uniform location
|
||||
int GetShaderLocation(Shader shader, const char *uniformName)
|
||||
{
|
||||
int location = rlGetLocationUniform(shader.id, uniformName);
|
||||
|
||||
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);
|
||||
|
||||
return location;
|
||||
return rlGetLocationUniform(shader.id, uniformName);
|
||||
}
|
||||
|
||||
// Get shader attribute location
|
||||
int GetShaderLocationAttrib(Shader shader, const char *attribName)
|
||||
{
|
||||
int location = rlGetLocationAttrib(shader.id, attribName);
|
||||
|
||||
if (location == -1) TRACELOG(LOG_WARNING, "SHADER: [ID %i] Failed to find shader attribute: %s", shader.id, attribName);
|
||||
else TRACELOG(LOG_INFO, "SHADER: [ID %i] Shader attribute (%s) set at location: %i", shader.id, attribName, location);
|
||||
|
||||
return location;
|
||||
return rlGetLocationAttrib(shader.id, attribName);
|
||||
}
|
||||
|
||||
// Set shader uniform value
|
||||
|
|
|
@ -1244,6 +1244,7 @@ RLAPI void UpdateTexture(Texture2D texture, const void *pixels);
|
|||
RLAPI void UpdateTextureRec(Texture2D texture, Rectangle rec, const void *pixels); // Update GPU texture rectangle with new data
|
||||
RLAPI Image GetTextureData(Texture2D texture); // Get pixel data from GPU texture and return an Image
|
||||
RLAPI Image GetScreenData(void); // Get pixel data from screen buffer and return an Image (screenshot)
|
||||
RLAPI void SetShapesTexture(Texture2D texture, Rectangle source); // Define default texture used to draw shapes
|
||||
|
||||
// Texture configuration functions
|
||||
RLAPI void GenTextureMipmaps(Texture2D *texture); // Generate GPU mipmaps for a texture
|
||||
|
|
1909
src/rlgl.h
1909
src/rlgl.h
File diff suppressed because it is too large
Load diff
|
@ -2950,6 +2950,12 @@ Image GetScreenData(void)
|
|||
return image;
|
||||
}
|
||||
|
||||
// Define default texture used to draw shapes
|
||||
void SetShapesTexture(Texture2D texture, Rectangle source)
|
||||
{
|
||||
rlSetShapesTexture(texture, source);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Texture configuration functions
|
||||
//------------------------------------------------------------------------------------
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue