Improved library consistency
Functions renamed to improve library consistency
This commit is contained in:
parent
caa7bc366b
commit
cac2a66deb
7 changed files with 59 additions and 42 deletions
|
@ -33,7 +33,7 @@ int main()
|
||||||
Camera camera = {{ 3.0f, 3.0f, 3.0f }, { 0.0f, 1.5f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f };
|
Camera camera = {{ 3.0f, 3.0f, 3.0f }, { 0.0f, 1.5f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f };
|
||||||
|
|
||||||
Model dwarf = LoadModel("resources/model/dwarf.obj"); // Load OBJ model
|
Model dwarf = LoadModel("resources/model/dwarf.obj"); // Load OBJ model
|
||||||
Texture2D texture = LoadTexture("resources/model/dwarf_diffuse.png"); // Load model texture
|
Texture2D texture = LoadTexture("resources/model/dwarf_diffuse.png"); // Load model texture (diffuse map)
|
||||||
SetModelTexture(&dwarf, texture); // Bind texture to model
|
SetModelTexture(&dwarf, texture); // Bind texture to model
|
||||||
|
|
||||||
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
|
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
|
||||||
|
@ -94,10 +94,12 @@ int main()
|
||||||
|
|
||||||
EndTextureMode(); // End drawing to texture (now we have a texture available for next passes)
|
EndTextureMode(); // End drawing to texture (now we have a texture available for next passes)
|
||||||
|
|
||||||
SetCustomShader(shader);
|
BeginShaderMode(shader);
|
||||||
// NOTE: Render texture must be y-flipped due to default OpenGL coordinates (left-bottom)
|
|
||||||
DrawTextureRec(target.texture, (Rectangle){ 0, 0, target.texture.width, -target.texture.height }, (Vector2){ 0, 0 }, WHITE);
|
// NOTE: Render texture must be y-flipped due to default OpenGL coordinates (left-bottom)
|
||||||
SetDefaultShader();
|
DrawTextureRec(target.texture, (Rectangle){ 0, 0, target.texture.width, -target.texture.height }, (Vector2){ 0, 0 }, WHITE);
|
||||||
|
|
||||||
|
EndShaderMode();
|
||||||
|
|
||||||
DrawText("(c) Dwarf 3D model by David Moreno", screenWidth - 200, screenHeight - 20, 10, GRAY);
|
DrawText("(c) Dwarf 3D model by David Moreno", screenWidth - 200, screenHeight - 20, 10, GRAY);
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ int main()
|
||||||
Camera camera = {{ 3.0f, 3.0f, 3.0f }, { 0.0f, 1.5f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f };
|
Camera camera = {{ 3.0f, 3.0f, 3.0f }, { 0.0f, 1.5f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f };
|
||||||
|
|
||||||
Model dwarf = LoadModel("resources/model/dwarf.obj"); // Load OBJ model
|
Model dwarf = LoadModel("resources/model/dwarf.obj"); // Load OBJ model
|
||||||
Texture2D texture = LoadTexture("resources/model/dwarf_diffuse.png"); // Load model texture
|
Texture2D texture = LoadTexture("resources/model/dwarf_diffuse.png"); // Load model texture (diffuse map)
|
||||||
SetModelTexture(&dwarf, texture); // Bind texture to model
|
SetModelTexture(&dwarf, texture); // Bind texture to model
|
||||||
|
|
||||||
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
|
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
|
||||||
|
@ -80,10 +80,12 @@ int main()
|
||||||
|
|
||||||
EndTextureMode(); // End drawing to texture (now we have a texture available for next passes)
|
EndTextureMode(); // End drawing to texture (now we have a texture available for next passes)
|
||||||
|
|
||||||
SetCustomShader(shader);
|
BeginShaderMode(shader);
|
||||||
// NOTE: Render texture must be y-flipped due to default OpenGL coordinates (left-bottom)
|
|
||||||
DrawTextureRec(target.texture, (Rectangle){ 0, 0, target.texture.width, -target.texture.height }, (Vector2){ 0, 0 }, WHITE);
|
// NOTE: Render texture must be y-flipped due to default OpenGL coordinates (left-bottom)
|
||||||
SetDefaultShader();
|
DrawTextureRec(target.texture, (Rectangle){ 0, 0, target.texture.width, -target.texture.height }, (Vector2){ 0, 0 }, WHITE);
|
||||||
|
|
||||||
|
EndShaderMode();
|
||||||
|
|
||||||
DrawText("(c) Dwarf 3D model by David Moreno", screenWidth - 200, screenHeight - 20, 10, DARKGRAY);
|
DrawText("(c) Dwarf 3D model by David Moreno", screenWidth - 200, screenHeight - 20, 10, DARKGRAY);
|
||||||
|
|
||||||
|
|
|
@ -65,16 +65,16 @@ int main()
|
||||||
|
|
||||||
|
|
||||||
// Activate our custom shader to be applied on next shapes/textures drawings
|
// Activate our custom shader to be applied on next shapes/textures drawings
|
||||||
SetCustomShader(shader);
|
BeginShaderMode(shader);
|
||||||
|
|
||||||
DrawText("USING CUSTOM SHADER", 190, 40, 10, RED);
|
DrawText("USING CUSTOM SHADER", 190, 40, 10, RED);
|
||||||
|
|
||||||
DrawRectangle(250 - 60, 90, 120, 60, RED);
|
DrawRectangle(250 - 60, 90, 120, 60, RED);
|
||||||
DrawRectangleGradient(250 - 90, 170, 180, 130, MAROON, GOLD);
|
DrawRectangleGradient(250 - 90, 170, 180, 130, MAROON, GOLD);
|
||||||
DrawRectangleLines(250 - 40, 320, 80, 60, ORANGE);
|
DrawRectangleLines(250 - 40, 320, 80, 60, ORANGE);
|
||||||
|
|
||||||
// Activate our default shader for next drawings
|
// Activate our default shader for next drawings
|
||||||
SetDefaultShader();
|
EndShaderMode();
|
||||||
|
|
||||||
DrawText("USING DEFAULT SHADER", 370, 40, 10, RED);
|
DrawText("USING DEFAULT SHADER", 370, 40, 10, RED);
|
||||||
|
|
||||||
|
@ -89,12 +89,12 @@ int main()
|
||||||
DrawPoly((Vector2){430, 320}, 6, 80, 0, BROWN);
|
DrawPoly((Vector2){430, 320}, 6, 80, 0, BROWN);
|
||||||
|
|
||||||
// Activate our custom shader to be applied on next shapes/textures drawings
|
// Activate our custom shader to be applied on next shapes/textures drawings
|
||||||
SetCustomShader(shader);
|
BeginShaderMode(shader);
|
||||||
|
|
||||||
DrawTexture(sonic, 380, -10, WHITE); // Using custom shader
|
DrawTexture(sonic, 380, -10, WHITE); // Using custom shader
|
||||||
|
|
||||||
// Activate our default shader for next drawings
|
// Activate our default shader for next drawings
|
||||||
SetDefaultShader();
|
EndShaderMode();
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
|
@ -102,20 +102,22 @@ int main()
|
||||||
|
|
||||||
ClearBackground(DARKGRAY);
|
ClearBackground(DARKGRAY);
|
||||||
|
|
||||||
SetBlendMode(blending);
|
BeginBlendMode(blending);
|
||||||
|
|
||||||
// Draw active particles
|
// Draw active particles
|
||||||
for (int i = 0; i < MAX_PARTICLES; i++)
|
for (int i = 0; i < MAX_PARTICLES; i++)
|
||||||
{
|
{
|
||||||
if (mouseTail[i].active) DrawTexturePro(smoke, (Rectangle){ 0, 0, smoke.width, smoke.height },
|
if (mouseTail[i].active) DrawTexturePro(smoke, (Rectangle){ 0, 0, smoke.width, smoke.height },
|
||||||
(Rectangle){ mouseTail[i].position.x, mouseTail[i].position.y, smoke.width*mouseTail[i].size, smoke.height*mouseTail[i].size },
|
(Rectangle){ mouseTail[i].position.x, mouseTail[i].position.y, smoke.width*mouseTail[i].size, smoke.height*mouseTail[i].size },
|
||||||
(Vector2){ smoke.width*mouseTail[i].size/2, smoke.height*mouseTail[i].size/2 }, mouseTail[i].rotation,
|
(Vector2){ smoke.width*mouseTail[i].size/2, smoke.height*mouseTail[i].size/2 }, mouseTail[i].rotation,
|
||||||
Fade(mouseTail[i].color, mouseTail[i].alpha));
|
Fade(mouseTail[i].color, mouseTail[i].alpha));
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawText("PRESS SPACE to CHANGE BLENDING MODE", 180, 20, 20, RAYWHITE);
|
EndBlendMode();
|
||||||
|
|
||||||
if (blending == BLEND_ALPHA) DrawText("ALPHA BLENDING", 290, screenHeight - 40, 20, RAYWHITE);
|
DrawText("PRESS SPACE to CHANGE BLENDING MODE", 180, 20, 20, BLACK);
|
||||||
|
|
||||||
|
if (blending == BLEND_ALPHA) DrawText("ALPHA BLENDING", 290, screenHeight - 40, 20, BLACK);
|
||||||
else DrawText("ADDITIVE BLENDING", 280, screenHeight - 40, 20, RAYWHITE);
|
else DrawText("ADDITIVE BLENDING", 280, screenHeight - 40, 20, RAYWHITE);
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
|
|
|
@ -860,8 +860,7 @@ Vector3 ResolveCollisionCubicmap(Image cubicmap, Vector3 mapPosition, Vector3 *p
|
||||||
//------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------
|
||||||
Shader LoadShader(char *vsFileName, char *fsFileName); // Load a custom shader and bind default locations
|
Shader LoadShader(char *vsFileName, char *fsFileName); // Load a custom shader and bind default locations
|
||||||
void UnloadShader(Shader shader); // Unload a custom shader from memory
|
void UnloadShader(Shader shader); // Unload a custom shader from memory
|
||||||
void SetDefaultShader(void); // Set default shader to be used in batch draw
|
|
||||||
void SetCustomShader(Shader shader); // Set custom shader to be used in batch draw
|
|
||||||
Shader GetDefaultShader(void); // Get default shader
|
Shader GetDefaultShader(void); // Get default shader
|
||||||
Shader GetStandardShader(void); // Get default shader
|
Shader GetStandardShader(void); // Get default shader
|
||||||
Texture2D GetDefaultTexture(void); // Get default texture
|
Texture2D GetDefaultTexture(void); // Get default texture
|
||||||
|
@ -871,7 +870,10 @@ void SetShaderValue(Shader shader, int uniformLoc, float *value, int size); // S
|
||||||
void SetShaderValuei(Shader shader, int uniformLoc, int *value, int size); // Set shader uniform value (int)
|
void SetShaderValuei(Shader shader, int uniformLoc, int *value, int size); // Set shader uniform value (int)
|
||||||
void SetShaderValueMatrix(Shader shader, int uniformLoc, Matrix mat); // Set shader uniform value (matrix 4x4)
|
void SetShaderValueMatrix(Shader shader, int uniformLoc, Matrix mat); // Set shader uniform value (matrix 4x4)
|
||||||
|
|
||||||
void SetBlendMode(int mode); // Set blending mode (alpha, additive, multiplied)
|
void BeginShaderMode(Shader shader); // Begin custom shader drawing
|
||||||
|
void EndShaderMode(void); // End custom shader drawing (use default shader)
|
||||||
|
void BeginBlendMode(int mode); // Begin blending mode (alpha, additive, multiplied)
|
||||||
|
void EndBlendMode(void); // End blending mode (reset to default: alpha blending)
|
||||||
|
|
||||||
Light CreateLight(int type, Vector3 position, Color diffuse); // Create a new light, initialize it and add to pool
|
Light CreateLight(int type, Vector3 position, Color diffuse); // Create a new light, initialize it and add to pool
|
||||||
void DestroyLight(Light light); // Destroy a light and take it out of the list
|
void DestroyLight(Light light); // Destroy a light and take it out of the list
|
||||||
|
|
18
src/rlgl.c
18
src/rlgl.c
|
@ -2157,7 +2157,7 @@ void UnloadShader(Shader shader)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set custom shader to be used on batch draw
|
// Set custom shader to be used on batch draw
|
||||||
void SetCustomShader(Shader shader)
|
void BeginShaderMode(Shader shader)
|
||||||
{
|
{
|
||||||
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
|
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
|
||||||
if (currentShader.id != shader.id)
|
if (currentShader.id != shader.id)
|
||||||
|
@ -2169,10 +2169,10 @@ void SetCustomShader(Shader shader)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set default shader to be used in batch draw
|
// Set default shader to be used in batch draw
|
||||||
void SetDefaultShader(void)
|
void EndShaderMode(void)
|
||||||
{
|
{
|
||||||
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
|
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
|
||||||
SetCustomShader(defaultShader);
|
BeginShaderMode(defaultShader);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2254,9 +2254,9 @@ void SetShaderValueMatrix(Shader shader, int uniformLoc, Matrix mat)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set blending mode (alpha, additive, multiplied)
|
// Begin blending mode (alpha, additive, multiplied)
|
||||||
// NOTE: Only 3 blending modes predefined
|
// NOTE: Only 3 blending modes supported, default blend mode is alpha
|
||||||
void SetBlendMode(int mode)
|
void BeginBlendMode(int mode)
|
||||||
{
|
{
|
||||||
if ((blendMode != mode) && (mode < 3))
|
if ((blendMode != mode) && (mode < 3))
|
||||||
{
|
{
|
||||||
|
@ -2274,6 +2274,12 @@ void SetBlendMode(int mode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// End blending mode (reset to default: alpha blending)
|
||||||
|
void EndBlendMode(void)
|
||||||
|
{
|
||||||
|
BeginBlendMode(BLEND_ALPHA);
|
||||||
|
}
|
||||||
|
|
||||||
// Create a new light, initialize it and add to pool
|
// Create a new light, initialize it and add to pool
|
||||||
Light CreateLight(int type, Vector3 position, Color diffuse)
|
Light CreateLight(int type, Vector3 position, Color diffuse)
|
||||||
{
|
{
|
||||||
|
|
|
@ -317,9 +317,9 @@ void *rlglReadTexturePixels(Texture2D texture); // Read text
|
||||||
//------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------
|
||||||
Shader LoadShader(char *vsFileName, char *fsFileName); // Load a custom shader and bind default locations
|
Shader LoadShader(char *vsFileName, char *fsFileName); // Load a custom shader and bind default locations
|
||||||
void UnloadShader(Shader shader); // Unload a custom shader from memory
|
void UnloadShader(Shader shader); // Unload a custom shader from memory
|
||||||
void SetCustomShader(Shader shader); // Set custom shader to be used in batch draw
|
|
||||||
void SetDefaultShader(void); // Set default shader to be used in batch draw
|
|
||||||
Shader GetDefaultShader(void); // Get default shader
|
Shader GetDefaultShader(void); // Get default shader
|
||||||
|
Shader GetStandardShader(void); // Get default shader
|
||||||
Texture2D GetDefaultTexture(void); // Get default texture
|
Texture2D GetDefaultTexture(void); // Get default texture
|
||||||
|
|
||||||
int GetShaderLocation(Shader shader, const char *uniformName); // Get shader uniform location
|
int GetShaderLocation(Shader shader, const char *uniformName); // Get shader uniform location
|
||||||
|
@ -327,7 +327,10 @@ void SetShaderValue(Shader shader, int uniformLoc, float *value, int size); // S
|
||||||
void SetShaderValuei(Shader shader, int uniformLoc, int *value, int size); // Set shader uniform value (int)
|
void SetShaderValuei(Shader shader, int uniformLoc, int *value, int size); // Set shader uniform value (int)
|
||||||
void SetShaderValueMatrix(Shader shader, int uniformLoc, Matrix mat); // Set shader uniform value (matrix 4x4)
|
void SetShaderValueMatrix(Shader shader, int uniformLoc, Matrix mat); // Set shader uniform value (matrix 4x4)
|
||||||
|
|
||||||
void SetBlendMode(int mode); // Set blending mode (alpha, additive, multiplied)
|
void BeginShaderMode(Shader shader); // Begin custom shader drawing
|
||||||
|
void EndShaderMode(void); // End custom shader drawing (use default shader)
|
||||||
|
void BeginBlendMode(int mode); // Begin blending mode (alpha, additive, multiplied)
|
||||||
|
void EndBlendMode(void); // End blending mode (reset to default: alpha blending)
|
||||||
|
|
||||||
Light CreateLight(int type, Vector3 position, Color diffuse); // Create a new light, initialize it and add to pool
|
Light CreateLight(int type, Vector3 position, Color diffuse); // Create a new light, initialize it and add to pool
|
||||||
void DestroyLight(Light light); // Destroy a light and take it out of the list
|
void DestroyLight(Light light); // Destroy a light and take it out of the list
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue