Improved ResolveCollisionCubicmap()

Now it supports multiple maps one next to the other
This commit is contained in:
raysan5 2015-06-02 09:54:51 +02:00
parent fd851d1d8b
commit 6a4afae5cc
2 changed files with 205 additions and 161 deletions

View file

@ -1171,7 +1171,10 @@ void DrawBillboard(Camera camera, Texture2D texture, Vector3 center, float size,
MatrixTranspose(&viewMatrix); MatrixTranspose(&viewMatrix);
Vector3 right = { viewMatrix.m0, viewMatrix.m4, viewMatrix.m8 }; Vector3 right = { viewMatrix.m0, viewMatrix.m4, viewMatrix.m8 };
Vector3 up = { viewMatrix.m1, viewMatrix.m5, viewMatrix.m9 }; //Vector3 up = { viewMatrix.m1, viewMatrix.m5, viewMatrix.m9 };
// NOTE: Billboard locked to axis-Y
Vector3 up = { 0, 1, 0 };
/* /*
a-------b a-------b
| | | |
@ -1351,183 +1354,222 @@ Vector3 ResolveCollisionCubicmap(Image cubicmap, Vector3 mapPosition, Vector3 *p
int locationCellX = 0; int locationCellX = 0;
int locationCellY = 0; int locationCellY = 0;
locationCellX = floor(playerPosition->x + mapPosition.x + CUBIC_MAP_HALF_BLOCK_SIZE); locationCellX = floor(playerPosition->x - mapPosition.x + CUBIC_MAP_HALF_BLOCK_SIZE);
locationCellY = floor(playerPosition->z + mapPosition.z + CUBIC_MAP_HALF_BLOCK_SIZE); locationCellY = floor(playerPosition->z - mapPosition.z + CUBIC_MAP_HALF_BLOCK_SIZE);
if (locationCellX >= 0 && locationCellY >= 0 && locationCellX < cubicmap.width && locationCellY < cubicmap.height)
{
// Multiple Axis -------------------------------------------------------------------------------------------- // Multiple Axis --------------------------------------------------------------------------------------------
// Axis x-, y- // Axis x-, y-
if (locationCellX > 0 && locationCellY > 0)
{
if ((cubicmapPixels[locationCellY * cubicmap.width + (locationCellX - 1)].r != 0) && if ((cubicmapPixels[locationCellY * cubicmap.width + (locationCellX - 1)].r != 0) &&
(cubicmapPixels[(locationCellY - 1) * cubicmap.width + (locationCellX)].r != 0)) (cubicmapPixels[(locationCellY - 1) * cubicmap.width + (locationCellX)].r != 0))
{ {
if (((playerPosition->x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX < radius) && if (((playerPosition->x - mapPosition.x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX < radius) &&
((playerPosition->z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY < radius)) ((playerPosition->z - mapPosition.z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY < radius))
{ {
playerPosition->x = locationCellX - (CUBIC_MAP_HALF_BLOCK_SIZE - radius); playerPosition->x = locationCellX + mapPosition.x - (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
playerPosition->z = locationCellY - (CUBIC_MAP_HALF_BLOCK_SIZE - radius); playerPosition->z = locationCellY + mapPosition.z - (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
impactDirection = (Vector3) { 1, 0, 1}; impactDirection = (Vector3) { 1, 0, 1};
} }
} }
}
// Axis x-, y+ // Axis x-, y+
if (locationCellX > 0 && locationCellY < cubicmap.height - 1)
{
if ((cubicmapPixels[locationCellY * cubicmap.width + (locationCellX - 1)].r != 0) && if ((cubicmapPixels[locationCellY * cubicmap.width + (locationCellX - 1)].r != 0) &&
(cubicmapPixels[(locationCellY + 1) * cubicmap.width + (locationCellX)].r != 0)) (cubicmapPixels[(locationCellY + 1) * cubicmap.width + (locationCellX)].r != 0))
{ {
if (((playerPosition->x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX < radius) && if (((playerPosition->x - mapPosition.x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX < radius) &&
((playerPosition->z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY > 1 - radius)) ((playerPosition->z - mapPosition.z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY > 1 - radius))
{ {
playerPosition->x = locationCellX - (CUBIC_MAP_HALF_BLOCK_SIZE - radius); playerPosition->x = locationCellX + mapPosition.x - (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
playerPosition->z = locationCellY + (CUBIC_MAP_HALF_BLOCK_SIZE - radius); playerPosition->z = locationCellY + mapPosition.z + (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
impactDirection = (Vector3) { 1, 0, 1}; impactDirection = (Vector3) { 1, 0, 1};
} }
} }
}
// Axis x+, y- // Axis x+, y-
if (locationCellX < cubicmap.width - 1 && locationCellY > 0)
{
if ((cubicmapPixels[locationCellY * cubicmap.width + (locationCellX + 1)].r != 0) && if ((cubicmapPixels[locationCellY * cubicmap.width + (locationCellX + 1)].r != 0) &&
(cubicmapPixels[(locationCellY - 1) * cubicmap.width + (locationCellX)].r != 0)) (cubicmapPixels[(locationCellY - 1) * cubicmap.width + (locationCellX)].r != 0))
{ {
if (((playerPosition->x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX > 1 - radius) && if (((playerPosition->x - mapPosition.x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX > 1 - radius) &&
((playerPosition->z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY < radius)) ((playerPosition->z - mapPosition.z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY < radius))
{ {
playerPosition->x = locationCellX + (CUBIC_MAP_HALF_BLOCK_SIZE - radius); playerPosition->x = locationCellX + mapPosition.x + (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
playerPosition->z = locationCellY - (CUBIC_MAP_HALF_BLOCK_SIZE - radius); playerPosition->z = locationCellY + mapPosition.z - (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
impactDirection = (Vector3) { 1, 0, 1}; impactDirection = (Vector3) { 1, 0, 1};
} }
} }
}
// Axis x+, y+ // Axis x+, y+
if (locationCellX < cubicmap.width - 1 && locationCellY < cubicmap.height - 1)
{
if ((cubicmapPixels[locationCellY * cubicmap.width + (locationCellX + 1)].r != 0) && if ((cubicmapPixels[locationCellY * cubicmap.width + (locationCellX + 1)].r != 0) &&
(cubicmapPixels[(locationCellY + 1) * cubicmap.width + (locationCellX)].r != 0)) (cubicmapPixels[(locationCellY + 1) * cubicmap.width + (locationCellX)].r != 0))
{ {
if (((playerPosition->x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX > 1 - radius) && if (((playerPosition->x - mapPosition.x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX > 1 - radius) &&
((playerPosition->z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY > 1 - radius)) ((playerPosition->z - mapPosition.z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY > 1 - radius))
{ {
playerPosition->x = locationCellX + (CUBIC_MAP_HALF_BLOCK_SIZE - radius); playerPosition->x = locationCellX + mapPosition.x + (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
playerPosition->z = locationCellY + (CUBIC_MAP_HALF_BLOCK_SIZE - radius); playerPosition->z = locationCellY + mapPosition.z + (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
impactDirection = (Vector3) { 1, 0, 1}; impactDirection = (Vector3) { 1, 0, 1};
} }
} }
}
// Single Axis --------------------------------------------------------------------------------------------------- // Single Axis ---------------------------------------------------------------------------------------------------
// Axis x- // Axis x-
if (locationCellX > 0)
{
if (cubicmapPixels[locationCellY * cubicmap.width + (locationCellX - 1)].r != 0) if (cubicmapPixels[locationCellY * cubicmap.width + (locationCellX - 1)].r != 0)
{ {
if ((playerPosition->x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX < radius) if ((playerPosition->x - mapPosition.x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX < radius)
{ {
playerPosition->x = locationCellX - (CUBIC_MAP_HALF_BLOCK_SIZE - radius); playerPosition->x = locationCellX + mapPosition.x - (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
impactDirection = (Vector3) { 1, 0, 0}; impactDirection = (Vector3) { 1, 0, 0};
} }
} }
}
// Axis x+ // Axis x+
if (locationCellX < cubicmap.width - 1)
{
if (cubicmapPixels[locationCellY * cubicmap.width + (locationCellX + 1)].r != 0) if (cubicmapPixels[locationCellY * cubicmap.width + (locationCellX + 1)].r != 0)
{ {
if ((playerPosition->x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX > 1 - radius) if ((playerPosition->x - mapPosition.x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX > 1 - radius)
{ {
playerPosition->x = locationCellX + (CUBIC_MAP_HALF_BLOCK_SIZE - radius); playerPosition->x = locationCellX + mapPosition.x + (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
impactDirection = (Vector3) { 1, 0, 0}; impactDirection = (Vector3) { 1, 0, 0};
} }
} }
}
// Axis y- // Axis y-
if (locationCellY > 0)
{
if (cubicmapPixels[(locationCellY - 1) * cubicmap.width + (locationCellX)].r != 0) if (cubicmapPixels[(locationCellY - 1) * cubicmap.width + (locationCellX)].r != 0)
{ {
if ((playerPosition->z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY < radius) if ((playerPosition->z - mapPosition.z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY < radius)
{ {
playerPosition->z = locationCellY - (CUBIC_MAP_HALF_BLOCK_SIZE - radius); playerPosition->z = locationCellY + mapPosition.z - (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
impactDirection = (Vector3) { 0, 0, 1}; impactDirection = (Vector3) { 0, 0, 1};
} }
} }
}
// Axis y+ // Axis y+
if (locationCellY < cubicmap.height - 1)
{
if (cubicmapPixels[(locationCellY + 1) * cubicmap.width + (locationCellX)].r != 0) if (cubicmapPixels[(locationCellY + 1) * cubicmap.width + (locationCellX)].r != 0)
{ {
if ((playerPosition->z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY > 1 - radius) if ((playerPosition->z - mapPosition.z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY > 1 - radius)
{ {
playerPosition->z = locationCellY + (CUBIC_MAP_HALF_BLOCK_SIZE - radius); playerPosition->z = locationCellY + mapPosition.z + (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
impactDirection = (Vector3) { 0, 0, 1}; impactDirection = (Vector3) { 0, 0, 1};
} }
} }
}
// Diagonals ------------------------------------------------------------------------------------------------------- // Diagonals -------------------------------------------------------------------------------------------------------
// Axis x-, y- // Axis x-, y-
if (locationCellX > 0 && locationCellY > 0)
{
if ((cubicmapPixels[locationCellY * cubicmap.width + (locationCellX - 1)].r == 0) && if ((cubicmapPixels[locationCellY * cubicmap.width + (locationCellX - 1)].r == 0) &&
(cubicmapPixels[(locationCellY - 1) * cubicmap.width + (locationCellX)].r == 0) && (cubicmapPixels[(locationCellY - 1) * cubicmap.width + (locationCellX)].r == 0) &&
(cubicmapPixels[(locationCellY - 1) * cubicmap.width + (locationCellX - 1)].r != 0)) (cubicmapPixels[(locationCellY - 1) * cubicmap.width + (locationCellX - 1)].r != 0))
{ {
if (((playerPosition->x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX < radius) && if (((playerPosition->x - mapPosition.x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX < radius) &&
((playerPosition->z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY < radius)) ((playerPosition->z - mapPosition.z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY < radius))
{ {
if (((playerPosition->x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX) > ((playerPosition->z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY)) playerPosition->x = locationCellX - (CUBIC_MAP_HALF_BLOCK_SIZE - radius); if (((playerPosition->x - mapPosition.x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX) > ((playerPosition->z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY)) playerPosition->x = locationCellX + mapPosition.x - (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
else playerPosition->z = locationCellY - (CUBIC_MAP_HALF_BLOCK_SIZE - radius); else playerPosition->z = locationCellY + mapPosition.z - (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
// Return ricochet // Return ricochet
if (((playerPosition->x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX < radius / 3) && if (((playerPosition->x - mapPosition.x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX < radius / 3) &&
((playerPosition->z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY < radius / 3)) ((playerPosition->z - mapPosition.z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY < radius / 3))
{ {
impactDirection = (Vector3) { 1, 0, 1}; impactDirection = (Vector3) { 1, 0, 1};
} }
} }
} }
}
// Axis x-, y+ // Axis x-, y+
if (locationCellX > 0 && locationCellY < cubicmap.height - 1)
{
if ((cubicmapPixels[locationCellY * cubicmap.width + (locationCellX - 1)].r == 0) && if ((cubicmapPixels[locationCellY * cubicmap.width + (locationCellX - 1)].r == 0) &&
(cubicmapPixels[(locationCellY + 1) * cubicmap.width + (locationCellX)].r == 0) && (cubicmapPixels[(locationCellY + 1) * cubicmap.width + (locationCellX)].r == 0) &&
(cubicmapPixels[(locationCellY + 1) * cubicmap.width + (locationCellX - 1)].r != 0)) (cubicmapPixels[(locationCellY + 1) * cubicmap.width + (locationCellX - 1)].r != 0))
{ {
if (((playerPosition->x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX < radius) && if (((playerPosition->x - mapPosition.x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX < radius) &&
((playerPosition->z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY > 1 - radius)) ((playerPosition->z - mapPosition.z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY > 1 - radius))
{ {
if (((playerPosition->x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX) > (1 - ((playerPosition->z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY))) playerPosition->x = locationCellX - (CUBIC_MAP_HALF_BLOCK_SIZE - radius); if (((playerPosition->x - mapPosition.x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX) > (1 - ((playerPosition->z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY))) playerPosition->x = locationCellX + mapPosition.x - (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
else playerPosition->z = locationCellY + (CUBIC_MAP_HALF_BLOCK_SIZE - radius); else playerPosition->z = locationCellY + mapPosition.z + (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
// Return ricochet // Return ricochet
if (((playerPosition->x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX < radius / 3) && if (((playerPosition->x - mapPosition.x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX < radius / 3) &&
((playerPosition->z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY > 1 - radius / 3)) ((playerPosition->z - mapPosition.z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY > 1 - radius / 3))
{ {
impactDirection = (Vector3) { 1, 0, 1}; impactDirection = (Vector3) { 1, 0, 1};
} }
} }
} }
}
// Axis x+, y- // Axis x+, y-
if (locationCellX < cubicmap.width - 1 && locationCellY > 0)
{
if ((cubicmapPixels[locationCellY * cubicmap.width + (locationCellX + 1)].r == 0) && if ((cubicmapPixels[locationCellY * cubicmap.width + (locationCellX + 1)].r == 0) &&
(cubicmapPixels[(locationCellY - 1) * cubicmap.width + (locationCellX)].r == 0) && (cubicmapPixels[(locationCellY - 1) * cubicmap.width + (locationCellX)].r == 0) &&
(cubicmapPixels[(locationCellY - 1) * cubicmap.width + (locationCellX + 1)].r != 0)) (cubicmapPixels[(locationCellY - 1) * cubicmap.width + (locationCellX + 1)].r != 0))
{ {
if (((playerPosition->x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX > 1 - radius) && if (((playerPosition->x - mapPosition.x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX > 1 - radius) &&
((playerPosition->z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY < radius)) ((playerPosition->z - mapPosition.z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY < radius))
{ {
if (((playerPosition->x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX) < (1 - ((playerPosition->z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY))) playerPosition->x = locationCellX + (CUBIC_MAP_HALF_BLOCK_SIZE - radius); if (((playerPosition->x - mapPosition.x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX) < (1 - ((playerPosition->z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY))) playerPosition->x = locationCellX + mapPosition.x + (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
else playerPosition->z = locationCellY - (CUBIC_MAP_HALF_BLOCK_SIZE - radius); else playerPosition->z = locationCellY + mapPosition.z - (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
// Return ricochet // Return ricochet
if (((playerPosition->x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX > 1 - radius / 3) && if (((playerPosition->x - mapPosition.x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX > 1 - radius / 3) &&
((playerPosition->z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY < radius / 3)) ((playerPosition->z - mapPosition.z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY < radius / 3))
{ {
impactDirection = (Vector3) { 1, 0, 1}; impactDirection = (Vector3) { 1, 0, 1};
} }
} }
} }
}
// Axis x+, y+ // Axis x+, y+
if (locationCellX < cubicmap.width - 1 && locationCellY < cubicmap.height - 1)
{
if ((cubicmapPixels[locationCellY * cubicmap.width + (locationCellX + 1)].r == 0) && if ((cubicmapPixels[locationCellY * cubicmap.width + (locationCellX + 1)].r == 0) &&
(cubicmapPixels[(locationCellY + 1) * cubicmap.width + (locationCellX)].r == 0) && (cubicmapPixels[(locationCellY + 1) * cubicmap.width + (locationCellX)].r == 0) &&
(cubicmapPixels[(locationCellY + 1) * cubicmap.width + (locationCellX + 1)].r != 0)) (cubicmapPixels[(locationCellY + 1) * cubicmap.width + (locationCellX + 1)].r != 0))
{ {
if (((playerPosition->x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX > 1 - radius) && if (((playerPosition->x - mapPosition.x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX > 1 - radius) &&
((playerPosition->z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY > 1 - radius)) ((playerPosition->z - mapPosition.z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY > 1 - radius))
{ {
if (((playerPosition->x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX) < ((playerPosition->z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY)) playerPosition->x = locationCellX + (CUBIC_MAP_HALF_BLOCK_SIZE - radius); if (((playerPosition->x - mapPosition.x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX) < ((playerPosition->z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY)) playerPosition->x = locationCellX + mapPosition.x + (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
else playerPosition->z = locationCellY + (CUBIC_MAP_HALF_BLOCK_SIZE - radius); else playerPosition->z = locationCellY + mapPosition.z + (CUBIC_MAP_HALF_BLOCK_SIZE - radius);
// Return ricochet // Return ricochet
if (((playerPosition->x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX > 1 - radius / 3) && if (((playerPosition->x - mapPosition.x + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellX > 1 - radius / 3) &&
((playerPosition->z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY > 1 - radius / 3)) ((playerPosition->z - mapPosition.z + CUBIC_MAP_HALF_BLOCK_SIZE) - locationCellY > 1 - radius / 3))
{ {
impactDirection = (Vector3) { 1, 0, 1}; impactDirection = (Vector3) { 1, 0, 1};
} }
} }
} }
}
}
// Floor collision // Floor collision
if (playerPosition->y <= radius) if (playerPosition->y <= radius)

View file

@ -877,7 +877,7 @@ void rlglInit(void)
TraceLog(INFO, "Number of supported extensions: %i", numExt); TraceLog(INFO, "Number of supported extensions: %i", numExt);
// Show supported extensions // Show supported extensions
for (int i = 0; i < numExt; i++) TraceLog(INFO, "Supported extension: %s", ext[i]); //for (int i = 0; i < numExt; i++) TraceLog(INFO, "Supported extension: %s", ext[i]);
// Check required extensions // Check required extensions
for (int i = 0; i < numExt; i++) for (int i = 0; i < numExt; i++)
@ -1377,11 +1377,15 @@ void rlglDrawModel(Model model, Vector3 position, float rotationAngle, Vector3 r
glEnableVertexAttribArray(model.shader.normalLoc); glEnableVertexAttribArray(model.shader.normalLoc);
} }
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, model.texture.id); glBindTexture(GL_TEXTURE_2D, model.texture.id);
//glActiveTexture(GL_TEXTURE1);
//glBindTexture(GL_TEXTURE_2D, 4);
glDrawArrays(GL_TRIANGLES, 0, model.mesh.vertexCount); glDrawArrays(GL_TRIANGLES, 0, model.mesh.vertexCount);
glBindTexture(GL_TEXTURE_2D, 0); // Unbind textures glBindTexture(GL_TEXTURE_2D, 0); // Unbind textures
glActiveTexture(GL_TEXTURE0);
if (vaoSupported) glBindVertexArray(0); // Unbind VAO if (vaoSupported) glBindVertexArray(0); // Unbind VAO
else glBindBuffer(GL_ARRAY_BUFFER, 0); // Unbind VBOs else glBindBuffer(GL_ARRAY_BUFFER, 0); // Unbind VBOs
@ -2128,11 +2132,9 @@ void rlglSetDefaultShader(void)
int GetShaderLocation(Shader shader, const char *uniformName) int GetShaderLocation(Shader shader, const char *uniformName)
{ {
int location = 0; int location = glGetUniformLocation(shader.id, uniformName);
location = glGetUniformLocation(shader.id, uniformName); if (location == -1) TraceLog(WARNING, "[SHDR ID %i] Shader location for %s could not be found", shader.id, uniformName);
if (location == 0) TraceLog(WARNING, "[SHDR %i] Shader location for %s could not be found", shader.id, uniformName);
return location; return location;
} }