Review formating to follow raylib style conventions
This commit is contained in:
parent
4a01139c8d
commit
0fa295c72d
2 changed files with 46 additions and 52 deletions
|
@ -1,6 +1,6 @@
|
||||||
/*******************************************************************************************
|
/*******************************************************************************************
|
||||||
*
|
*
|
||||||
* raylib [shaders] example - Apply an outline to a texture
|
* raylib [shaders] example - Apply an shdrOutline to a texture
|
||||||
*
|
*
|
||||||
* NOTE: This example requires raylib OpenGL 3.3 or ES2 versions for shaders support,
|
* NOTE: This example requires raylib OpenGL 3.3 or ES2 versions for shaders support,
|
||||||
* OpenGL 1.1 does not support shaders, recompile raylib to OpenGL 3.3 version.
|
* OpenGL 1.1 does not support shaders, recompile raylib to OpenGL 3.3 version.
|
||||||
|
@ -31,15 +31,15 @@ int main(void)
|
||||||
const int screenWidth = 800;
|
const int screenWidth = 800;
|
||||||
const int screenHeight = 450;
|
const int screenHeight = 450;
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - Apply an outline to a texture");
|
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - Apply an shdrOutline to a texture");
|
||||||
|
|
||||||
Texture2D egg = LoadTexture("resources/egg.png");
|
Texture2D egg = LoadTexture("resources/egg.png");
|
||||||
Texture2D torus = LoadTexture("resources/torus.png");
|
Texture2D torus = LoadTexture("resources/torus.png");
|
||||||
Shader outline = LoadShader(0, TextFormat("resources/shaders/glsl%i/outline.fs", GLSL_VERSION));
|
Shader shdrOutline = LoadShader(0, TextFormat("resources/shaders/glsl%i/shdrOutline.fs", GLSL_VERSION));
|
||||||
|
|
||||||
float oScale = 16.0;
|
float outlineScale = 16.0f;
|
||||||
float tScale[2] = { 16.0f*4, 16.0f*4 };
|
float textureScale[2] = { 16.0f*4, 16.0f*4 };
|
||||||
SetShaderValue(outline, GetShaderLocation(outline, "texScale"), tScale, SHADER_UNIFORM_VEC2);
|
SetShaderValue(shdrOutline, GetShaderLocation(shdrOutline, "texScale"), textureScale, SHADER_UNIFORM_VEC2);
|
||||||
|
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
@ -58,12 +58,12 @@ int main(void)
|
||||||
|
|
||||||
ClearBackground(RAYWHITE);
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
BeginShaderMode(outline);
|
BeginShaderMode(shdrOutline);
|
||||||
DrawTextureEx(egg, (Vector2){ 0, 230 }, 0.0, oScale, WHITE);
|
DrawTextureEx(egg, (Vector2){ 0, 230 }, 0.0, outlineScale, WHITE);
|
||||||
DrawTextureEx(torus, (Vector2){ 544, 230 }, 0.0, oScale, WHITE);
|
DrawTextureEx(torus, (Vector2){ 544, 230 }, 0.0, outlineScale, WHITE);
|
||||||
EndShaderMode();
|
EndShaderMode();
|
||||||
|
|
||||||
DrawText("Shader-based outlines for textures", 190, 200, 20, LIGHTGRAY);
|
DrawText("Shader-based shdrOutlines for textures", 190, 200, 20, LIGHTGRAY);
|
||||||
|
|
||||||
DrawFPS(710, 10);
|
DrawFPS(710, 10);
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ int main(void)
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
UnloadTexture(egg);
|
UnloadTexture(egg);
|
||||||
UnloadTexture(torus);
|
UnloadTexture(torus);
|
||||||
UnloadShader(outline);
|
UnloadShader(shdrOutline);
|
||||||
|
|
||||||
CloseWindow(); // Close window and OpenGL context
|
CloseWindow(); // Close window and OpenGL context
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
12
src/models.c
12
src/models.c
|
@ -2652,11 +2652,7 @@ BoundingBox GetMeshBoundingBox(Mesh mesh)
|
||||||
// Implementation base don: https://answers.unity.com/questions/7789/calculating-tangents-vector4.html
|
// Implementation base don: https://answers.unity.com/questions/7789/calculating-tangents-vector4.html
|
||||||
void GenMeshTangents(Mesh *mesh)
|
void GenMeshTangents(Mesh *mesh)
|
||||||
{
|
{
|
||||||
|
if (mesh->tangents == NULL) mesh->tangents = (float *)RL_MALLOC(mesh->vertexCount*4*sizeof(float));
|
||||||
if (mesh->tangents == NULL)
|
|
||||||
{
|
|
||||||
mesh->tangents = (float*)RL_MALLOC(mesh->vertexCount*4*sizeof(float));
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
RL_FREE(mesh->tangents);
|
RL_FREE(mesh->tangents);
|
||||||
|
@ -2706,7 +2702,7 @@ void GenMeshTangents(Mesh *mesh)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compute tangents considering normals
|
// Compute tangents considering normals
|
||||||
for (int i = 0; i < mesh->vertexCount; ++i)
|
for (int i = 0; i < mesh->vertexCount; i++)
|
||||||
{
|
{
|
||||||
Vector3 normal = { mesh->normals[i*3 + 0], mesh->normals[i*3 + 1], mesh->normals[i*3 + 2] };
|
Vector3 normal = { mesh->normals[i*3 + 0], mesh->normals[i*3 + 1], mesh->normals[i*3 + 2] };
|
||||||
Vector3 tangent = tan1[i];
|
Vector3 tangent = tan1[i];
|
||||||
|
@ -2731,10 +2727,8 @@ void GenMeshTangents(Mesh *mesh)
|
||||||
RL_FREE(tan1);
|
RL_FREE(tan1);
|
||||||
RL_FREE(tan2);
|
RL_FREE(tan2);
|
||||||
|
|
||||||
|
|
||||||
if (mesh->vboId != NULL)
|
if (mesh->vboId != NULL)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (mesh->vboId[SHADER_LOC_VERTEX_TANGENT] != 0)
|
if (mesh->vboId[SHADER_LOC_VERTEX_TANGENT] != 0)
|
||||||
{
|
{
|
||||||
// Upate existing vertex buffer
|
// Upate existing vertex buffer
|
||||||
|
@ -2752,7 +2746,7 @@ void GenMeshTangents(Mesh *mesh)
|
||||||
rlDisableVertexArray();
|
rlDisableVertexArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
TRACELOG(LOG_INFO, "MESH: Tangents data computed for provided mesh");
|
TRACELOG(LOG_INFO, "MESH: Tangents data computed and uploaded for provided mesh");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compute mesh binormals (aka bitangent)
|
// Compute mesh binormals (aka bitangent)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue