Added new matrix location points and extra functions

- New model and view transformation matrix added, useful for shaders.
Modelview matrix not deleted to keep opengl 1.1 pipeline compatibility.

- New extra function added DrawModelWiresEx() to set a rotation and
scale transformations to a wire model drawing.

- Other writing and little audio.c bug fixed.
This commit is contained in:
victorfisac 2015-12-21 16:42:13 +01:00
parent 1b39b2e261
commit 4db2da9185
6 changed files with 114 additions and 92 deletions

View file

@ -92,7 +92,7 @@ typedef enum { INFO = 0, ERROR, WARNING, DEBUG, OTHER } TraceLogType;
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Global Variables Definition // Global Variables Definition
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
bool musicEnabled = false; static bool musicEnabled = false;
static Music currentMusic; // Current music loaded static Music currentMusic; // Current music loaded
// NOTE: Only one music file playing at a time // NOTE: Only one music file playing at a time

BIN
src/libraylib.a Normal file

Binary file not shown.

View file

@ -64,7 +64,7 @@ static VertexData LoadOBJ(const char *fileName);
// Draw cube // Draw cube
// NOTE: Cube position is the center position // NOTE: Cube position is the center position
void DrawCube(Vector3 position, float width, float height, float lenght, Color color) void DrawCube(Vector3 position, float width, float height, float length, Color color)
{ {
float x = 0.0f; float x = 0.0f;
float y = 0.0f; float y = 0.0f;
@ -81,58 +81,58 @@ void DrawCube(Vector3 position, float width, float height, float lenght, Color c
rlColor4ub(color.r, color.g, color.b, color.a); rlColor4ub(color.r, color.g, color.b, color.a);
// Front Face ----------------------------------------------------- // Front Face -----------------------------------------------------
rlVertex3f(x-width/2, y-height/2, z+lenght/2); // Bottom Left rlVertex3f(x-width/2, y-height/2, z+length/2); // Bottom Left
rlVertex3f(x+width/2, y-height/2, z+lenght/2); // Bottom Right rlVertex3f(x+width/2, y-height/2, z+length/2); // Bottom Right
rlVertex3f(x-width/2, y+height/2, z+lenght/2); // Top Left rlVertex3f(x-width/2, y+height/2, z+length/2); // Top Left
rlVertex3f(x+width/2, y+height/2, z+lenght/2); // Top Right rlVertex3f(x+width/2, y+height/2, z+length/2); // Top Right
rlVertex3f(x-width/2, y+height/2, z+lenght/2); // Top Left rlVertex3f(x-width/2, y+height/2, z+length/2); // Top Left
rlVertex3f(x+width/2, y-height/2, z+lenght/2); // Bottom Right rlVertex3f(x+width/2, y-height/2, z+length/2); // Bottom Right
// Back Face ------------------------------------------------------ // Back Face ------------------------------------------------------
rlVertex3f(x-width/2, y-height/2, z-lenght/2); // Bottom Left rlVertex3f(x-width/2, y-height/2, z-length/2); // Bottom Left
rlVertex3f(x-width/2, y+height/2, z-lenght/2); // Top Left rlVertex3f(x-width/2, y+height/2, z-length/2); // Top Left
rlVertex3f(x+width/2, y-height/2, z-lenght/2); // Bottom Right rlVertex3f(x+width/2, y-height/2, z-length/2); // Bottom Right
rlVertex3f(x+width/2, y+height/2, z-lenght/2); // Top Right rlVertex3f(x+width/2, y+height/2, z-length/2); // Top Right
rlVertex3f(x+width/2, y-height/2, z-lenght/2); // Bottom Right rlVertex3f(x+width/2, y-height/2, z-length/2); // Bottom Right
rlVertex3f(x-width/2, y+height/2, z-lenght/2); // Top Left rlVertex3f(x-width/2, y+height/2, z-length/2); // Top Left
// Top Face ------------------------------------------------------- // Top Face -------------------------------------------------------
rlVertex3f(x-width/2, y+height/2, z-lenght/2); // Top Left rlVertex3f(x-width/2, y+height/2, z-length/2); // Top Left
rlVertex3f(x-width/2, y+height/2, z+lenght/2); // Bottom Left rlVertex3f(x-width/2, y+height/2, z+length/2); // Bottom Left
rlVertex3f(x+width/2, y+height/2, z+lenght/2); // Bottom Right rlVertex3f(x+width/2, y+height/2, z+length/2); // Bottom Right
rlVertex3f(x+width/2, y+height/2, z-lenght/2); // Top Right rlVertex3f(x+width/2, y+height/2, z-length/2); // Top Right
rlVertex3f(x-width/2, y+height/2, z-lenght/2); // Top Left rlVertex3f(x-width/2, y+height/2, z-length/2); // Top Left
rlVertex3f(x+width/2, y+height/2, z+lenght/2); // Bottom Right rlVertex3f(x+width/2, y+height/2, z+length/2); // Bottom Right
// Bottom Face ---------------------------------------------------- // Bottom Face ----------------------------------------------------
rlVertex3f(x-width/2, y-height/2, z-lenght/2); // Top Left rlVertex3f(x-width/2, y-height/2, z-length/2); // Top Left
rlVertex3f(x+width/2, y-height/2, z+lenght/2); // Bottom Right rlVertex3f(x+width/2, y-height/2, z+length/2); // Bottom Right
rlVertex3f(x-width/2, y-height/2, z+lenght/2); // Bottom Left rlVertex3f(x-width/2, y-height/2, z+length/2); // Bottom Left
rlVertex3f(x+width/2, y-height/2, z-lenght/2); // Top Right rlVertex3f(x+width/2, y-height/2, z-length/2); // Top Right
rlVertex3f(x+width/2, y-height/2, z+lenght/2); // Bottom Right rlVertex3f(x+width/2, y-height/2, z+length/2); // Bottom Right
rlVertex3f(x-width/2, y-height/2, z-lenght/2); // Top Left rlVertex3f(x-width/2, y-height/2, z-length/2); // Top Left
// Right face ----------------------------------------------------- // Right face -----------------------------------------------------
rlVertex3f(x+width/2, y-height/2, z-lenght/2); // Bottom Right rlVertex3f(x+width/2, y-height/2, z-length/2); // Bottom Right
rlVertex3f(x+width/2, y+height/2, z-lenght/2); // Top Right rlVertex3f(x+width/2, y+height/2, z-length/2); // Top Right
rlVertex3f(x+width/2, y+height/2, z+lenght/2); // Top Left rlVertex3f(x+width/2, y+height/2, z+length/2); // Top Left
rlVertex3f(x+width/2, y-height/2, z+lenght/2); // Bottom Left rlVertex3f(x+width/2, y-height/2, z+length/2); // Bottom Left
rlVertex3f(x+width/2, y-height/2, z-lenght/2); // Bottom Right rlVertex3f(x+width/2, y-height/2, z-length/2); // Bottom Right
rlVertex3f(x+width/2, y+height/2, z+lenght/2); // Top Left rlVertex3f(x+width/2, y+height/2, z+length/2); // Top Left
// Left Face ------------------------------------------------------ // Left Face ------------------------------------------------------
rlVertex3f(x-width/2, y-height/2, z-lenght/2); // Bottom Right rlVertex3f(x-width/2, y-height/2, z-length/2); // Bottom Right
rlVertex3f(x-width/2, y+height/2, z+lenght/2); // Top Left rlVertex3f(x-width/2, y+height/2, z+length/2); // Top Left
rlVertex3f(x-width/2, y+height/2, z-lenght/2); // Top Right rlVertex3f(x-width/2, y+height/2, z-length/2); // Top Right
rlVertex3f(x-width/2, y-height/2, z+lenght/2); // Bottom Left rlVertex3f(x-width/2, y-height/2, z+length/2); // Bottom Left
rlVertex3f(x-width/2, y+height/2, z+lenght/2); // Top Left rlVertex3f(x-width/2, y+height/2, z+length/2); // Top Left
rlVertex3f(x-width/2, y-height/2, z-lenght/2); // Bottom Right rlVertex3f(x-width/2, y-height/2, z-length/2); // Bottom Right
rlEnd(); rlEnd();
rlPopMatrix(); rlPopMatrix();
} }
@ -144,7 +144,7 @@ void DrawCubeV(Vector3 position, Vector3 size, Color color)
} }
// Draw cube wires // Draw cube wires
void DrawCubeWires(Vector3 position, float width, float height, float lenght, Color color) void DrawCubeWires(Vector3 position, float width, float height, float length, Color color)
{ {
float x = 0.0f; float x = 0.0f;
float y = 0.0f; float y = 0.0f;
@ -160,62 +160,62 @@ void DrawCubeWires(Vector3 position, float width, float height, float lenght, Co
// Front Face ----------------------------------------------------- // Front Face -----------------------------------------------------
// Bottom Line // Bottom Line
rlVertex3f(x-width/2, y-height/2, z+lenght/2); // Bottom Left rlVertex3f(x-width/2, y-height/2, z+length/2); // Bottom Left
rlVertex3f(x+width/2, y-height/2, z+lenght/2); // Bottom Right rlVertex3f(x+width/2, y-height/2, z+length/2); // Bottom Right
// Left Line // Left Line
rlVertex3f(x+width/2, y-height/2, z+lenght/2); // Bottom Right rlVertex3f(x+width/2, y-height/2, z+length/2); // Bottom Right
rlVertex3f(x+width/2, y+height/2, z+lenght/2); // Top Right rlVertex3f(x+width/2, y+height/2, z+length/2); // Top Right
// Top Line // Top Line
rlVertex3f(x+width/2, y+height/2, z+lenght/2); // Top Right rlVertex3f(x+width/2, y+height/2, z+length/2); // Top Right
rlVertex3f(x-width/2, y+height/2, z+lenght/2); // Top Left rlVertex3f(x-width/2, y+height/2, z+length/2); // Top Left
// Right Line // Right Line
rlVertex3f(x-width/2, y+height/2, z+lenght/2); // Top Left rlVertex3f(x-width/2, y+height/2, z+length/2); // Top Left
rlVertex3f(x-width/2, y-height/2, z+lenght/2); // Bottom Left rlVertex3f(x-width/2, y-height/2, z+length/2); // Bottom Left
// Back Face ------------------------------------------------------ // Back Face ------------------------------------------------------
// Bottom Line // Bottom Line
rlVertex3f(x-width/2, y-height/2, z-lenght/2); // Bottom Left rlVertex3f(x-width/2, y-height/2, z-length/2); // Bottom Left
rlVertex3f(x+width/2, y-height/2, z-lenght/2); // Bottom Right rlVertex3f(x+width/2, y-height/2, z-length/2); // Bottom Right
// Left Line // Left Line
rlVertex3f(x+width/2, y-height/2, z-lenght/2); // Bottom Right rlVertex3f(x+width/2, y-height/2, z-length/2); // Bottom Right
rlVertex3f(x+width/2, y+height/2, z-lenght/2); // Top Right rlVertex3f(x+width/2, y+height/2, z-length/2); // Top Right
// Top Line // Top Line
rlVertex3f(x+width/2, y+height/2, z-lenght/2); // Top Right rlVertex3f(x+width/2, y+height/2, z-length/2); // Top Right
rlVertex3f(x-width/2, y+height/2, z-lenght/2); // Top Left rlVertex3f(x-width/2, y+height/2, z-length/2); // Top Left
// Right Line // Right Line
rlVertex3f(x-width/2, y+height/2, z-lenght/2); // Top Left rlVertex3f(x-width/2, y+height/2, z-length/2); // Top Left
rlVertex3f(x-width/2, y-height/2, z-lenght/2); // Bottom Left rlVertex3f(x-width/2, y-height/2, z-length/2); // Bottom Left
// Top Face ------------------------------------------------------- // Top Face -------------------------------------------------------
// Left Line // Left Line
rlVertex3f(x-width/2, y+height/2, z+lenght/2); // Top Left Front rlVertex3f(x-width/2, y+height/2, z+length/2); // Top Left Front
rlVertex3f(x-width/2, y+height/2, z-lenght/2); // Top Left Back rlVertex3f(x-width/2, y+height/2, z-length/2); // Top Left Back
// Right Line // Right Line
rlVertex3f(x+width/2, y+height/2, z+lenght/2); // Top Right Front rlVertex3f(x+width/2, y+height/2, z+length/2); // Top Right Front
rlVertex3f(x+width/2, y+height/2, z-lenght/2); // Top Right Back rlVertex3f(x+width/2, y+height/2, z-length/2); // Top Right Back
// Bottom Face --------------------------------------------------- // Bottom Face ---------------------------------------------------
// Left Line // Left Line
rlVertex3f(x-width/2, y-height/2, z+lenght/2); // Top Left Front rlVertex3f(x-width/2, y-height/2, z+length/2); // Top Left Front
rlVertex3f(x-width/2, y-height/2, z-lenght/2); // Top Left Back rlVertex3f(x-width/2, y-height/2, z-length/2); // Top Left Back
// Right Line // Right Line
rlVertex3f(x+width/2, y-height/2, z+lenght/2); // Top Right Front rlVertex3f(x+width/2, y-height/2, z+length/2); // Top Right Front
rlVertex3f(x+width/2, y-height/2, z-lenght/2); // Top Right Back rlVertex3f(x+width/2, y-height/2, z-length/2); // Top Right Back
rlEnd(); rlEnd();
rlPopMatrix(); rlPopMatrix();
} }
// Draw cube // Draw cube
// NOTE: Cube position is the center position // NOTE: Cube position is the center position
void DrawCubeTexture(Texture2D texture, Vector3 position, float width, float height, float lenght, Color color) void DrawCubeTexture(Texture2D texture, Vector3 position, float width, float height, float length, Color color)
{ {
float x = position.x; float x = position.x;
float y = position.y; float y = position.y;
@ -233,40 +233,40 @@ void DrawCubeTexture(Texture2D texture, Vector3 position, float width, float hei
rlColor4ub(color.r, color.g, color.b, color.a); rlColor4ub(color.r, color.g, color.b, color.a);
// Front Face // Front Face
rlNormal3f(0.0f, 0.0f, 1.0f); // Normal Pointing Towards Viewer rlNormal3f(0.0f, 0.0f, 1.0f); // Normal Pointing Towards Viewer
rlTexCoord2f(0.0f, 0.0f); rlVertex3f(x-width/2, y-height/2, z+lenght/2); // Bottom Left Of The Texture and Quad rlTexCoord2f(0.0f, 0.0f); rlVertex3f(x-width/2, y-height/2, z+length/2); // Bottom Left Of The Texture and Quad
rlTexCoord2f(1.0f, 0.0f); rlVertex3f(x+width/2, y-height/2, z+lenght/2); // Bottom Right Of The Texture and Quad rlTexCoord2f(1.0f, 0.0f); rlVertex3f(x+width/2, y-height/2, z+length/2); // Bottom Right Of The Texture and Quad
rlTexCoord2f(1.0f, 1.0f); rlVertex3f(x+width/2, y+height/2, z+lenght/2); // Top Right Of The Texture and Quad rlTexCoord2f(1.0f, 1.0f); rlVertex3f(x+width/2, y+height/2, z+length/2); // Top Right Of The Texture and Quad
rlTexCoord2f(0.0f, 1.0f); rlVertex3f(x-width/2, y+height/2, z+lenght/2); // Top Left Of The Texture and Quad rlTexCoord2f(0.0f, 1.0f); rlVertex3f(x-width/2, y+height/2, z+length/2); // Top Left Of The Texture and Quad
// Back Face // Back Face
rlNormal3f( 0.0f, 0.0f,-1.0f); // Normal Pointing Away From Viewer rlNormal3f( 0.0f, 0.0f,-1.0f); // Normal Pointing Away From Viewer
rlTexCoord2f(1.0f, 0.0f); rlVertex3f(x-width/2, y-height/2, z-lenght/2); // Bottom Right Of The Texture and Quad rlTexCoord2f(1.0f, 0.0f); rlVertex3f(x-width/2, y-height/2, z-length/2); // Bottom Right Of The Texture and Quad
rlTexCoord2f(1.0f, 1.0f); rlVertex3f(x-width/2, y+height/2, z-lenght/2); // Top Right Of The Texture and Quad rlTexCoord2f(1.0f, 1.0f); rlVertex3f(x-width/2, y+height/2, z-length/2); // Top Right Of The Texture and Quad
rlTexCoord2f(0.0f, 1.0f); rlVertex3f(x+width/2, y+height/2, z-lenght/2); // Top Left Of The Texture and Quad rlTexCoord2f(0.0f, 1.0f); rlVertex3f(x+width/2, y+height/2, z-length/2); // Top Left Of The Texture and Quad
rlTexCoord2f(0.0f, 0.0f); rlVertex3f(x+width/2, y-height/2, z-lenght/2); // Bottom Left Of The Texture and Quad rlTexCoord2f(0.0f, 0.0f); rlVertex3f(x+width/2, y-height/2, z-length/2); // Bottom Left Of The Texture and Quad
// Top Face // Top Face
rlNormal3f( 0.0f, 1.0f, 0.0f); // Normal Pointing Up rlNormal3f( 0.0f, 1.0f, 0.0f); // Normal Pointing Up
rlTexCoord2f(0.0f, 1.0f); rlVertex3f(x-width/2, y+height/2, z-lenght/2); // Top Left Of The Texture and Quad rlTexCoord2f(0.0f, 1.0f); rlVertex3f(x-width/2, y+height/2, z-length/2); // Top Left Of The Texture and Quad
rlTexCoord2f(0.0f, 0.0f); rlVertex3f(x-width/2, y+height/2, z+lenght/2); // Bottom Left Of The Texture and Quad rlTexCoord2f(0.0f, 0.0f); rlVertex3f(x-width/2, y+height/2, z+length/2); // Bottom Left Of The Texture and Quad
rlTexCoord2f(1.0f, 0.0f); rlVertex3f(x+width/2, y+height/2, z+lenght/2); // Bottom Right Of The Texture and Quad rlTexCoord2f(1.0f, 0.0f); rlVertex3f(x+width/2, y+height/2, z+length/2); // Bottom Right Of The Texture and Quad
rlTexCoord2f(1.0f, 1.0f); rlVertex3f(x+width/2, y+height/2, z-lenght/2); // Top Right Of The Texture and Quad rlTexCoord2f(1.0f, 1.0f); rlVertex3f(x+width/2, y+height/2, z-length/2); // Top Right Of The Texture and Quad
// Bottom Face // Bottom Face
rlNormal3f( 0.0f,-1.0f, 0.0f); // Normal Pointing Down rlNormal3f( 0.0f,-1.0f, 0.0f); // Normal Pointing Down
rlTexCoord2f(1.0f, 1.0f); rlVertex3f(x-width/2, y-height/2, z-lenght/2); // Top Right Of The Texture and Quad rlTexCoord2f(1.0f, 1.0f); rlVertex3f(x-width/2, y-height/2, z-length/2); // Top Right Of The Texture and Quad
rlTexCoord2f(0.0f, 1.0f); rlVertex3f(x+width/2, y-height/2, z-lenght/2); // Top Left Of The Texture and Quad rlTexCoord2f(0.0f, 1.0f); rlVertex3f(x+width/2, y-height/2, z-length/2); // Top Left Of The Texture and Quad
rlTexCoord2f(0.0f, 0.0f); rlVertex3f(x+width/2, y-height/2, z+lenght/2); // Bottom Left Of The Texture and Quad rlTexCoord2f(0.0f, 0.0f); rlVertex3f(x+width/2, y-height/2, z+length/2); // Bottom Left Of The Texture and Quad
rlTexCoord2f(1.0f, 0.0f); rlVertex3f(x-width/2, y-height/2, z+lenght/2); // Bottom Right Of The Texture and Quad rlTexCoord2f(1.0f, 0.0f); rlVertex3f(x-width/2, y-height/2, z+length/2); // Bottom Right Of The Texture and Quad
// Right face // Right face
rlNormal3f( 1.0f, 0.0f, 0.0f); // Normal Pointing Right rlNormal3f( 1.0f, 0.0f, 0.0f); // Normal Pointing Right
rlTexCoord2f(1.0f, 0.0f); rlVertex3f(x+width/2, y-height/2, z-lenght/2); // Bottom Right Of The Texture and Quad rlTexCoord2f(1.0f, 0.0f); rlVertex3f(x+width/2, y-height/2, z-length/2); // Bottom Right Of The Texture and Quad
rlTexCoord2f(1.0f, 1.0f); rlVertex3f(x+width/2, y+height/2, z-lenght/2); // Top Right Of The Texture and Quad rlTexCoord2f(1.0f, 1.0f); rlVertex3f(x+width/2, y+height/2, z-length/2); // Top Right Of The Texture and Quad
rlTexCoord2f(0.0f, 1.0f); rlVertex3f(x+width/2, y+height/2, z+lenght/2); // Top Left Of The Texture and Quad rlTexCoord2f(0.0f, 1.0f); rlVertex3f(x+width/2, y+height/2, z+length/2); // Top Left Of The Texture and Quad
rlTexCoord2f(0.0f, 0.0f); rlVertex3f(x+width/2, y-height/2, z+lenght/2); // Bottom Left Of The Texture and Quad rlTexCoord2f(0.0f, 0.0f); rlVertex3f(x+width/2, y-height/2, z+length/2); // Bottom Left Of The Texture and Quad
// Left Face // Left Face
rlNormal3f(-1.0f, 0.0f, 0.0f); // Normal Pointing Left rlNormal3f(-1.0f, 0.0f, 0.0f); // Normal Pointing Left
rlTexCoord2f(0.0f, 0.0f); rlVertex3f(x-width/2, y-height/2, z-lenght/2); // Bottom Left Of The Texture and Quad rlTexCoord2f(0.0f, 0.0f); rlVertex3f(x-width/2, y-height/2, z-length/2); // Bottom Left Of The Texture and Quad
rlTexCoord2f(1.0f, 0.0f); rlVertex3f(x-width/2, y-height/2, z+lenght/2); // Bottom Right Of The Texture and Quad rlTexCoord2f(1.0f, 0.0f); rlVertex3f(x-width/2, y-height/2, z+length/2); // Bottom Right Of The Texture and Quad
rlTexCoord2f(1.0f, 1.0f); rlVertex3f(x-width/2, y+height/2, z+lenght/2); // Top Right Of The Texture and Quad rlTexCoord2f(1.0f, 1.0f); rlVertex3f(x-width/2, y+height/2, z+length/2); // Top Right Of The Texture and Quad
rlTexCoord2f(0.0f, 1.0f); rlVertex3f(x-width/2, y+height/2, z-lenght/2); // Top Left Of The Texture and Quad rlTexCoord2f(0.0f, 1.0f); rlVertex3f(x-width/2, y+height/2, z-length/2); // Top Left Of The Texture and Quad
rlEnd(); rlEnd();
//rlPopMatrix(); //rlPopMatrix();
@ -534,12 +534,12 @@ void DrawGrid(int slices, float spacing)
void DrawGizmo(Vector3 position) void DrawGizmo(Vector3 position)
{ {
// NOTE: RGB = XYZ // NOTE: RGB = XYZ
float lenght = 1.0f; float length = 1.0f;
rlPushMatrix(); rlPushMatrix();
rlTranslatef(position.x, position.y, position.z); rlTranslatef(position.x, position.y, position.z);
//rlRotatef(rotation, 0, 1, 0); //rlRotatef(rotation, 0, 1, 0);
rlScalef(lenght, lenght, lenght); rlScalef(length, length, length);
rlBegin(RL_LINES); rlBegin(RL_LINES);
rlColor3f(1.0f, 0.0f, 0.0f); rlVertex3f(0.0f, 0.0f, 0.0f); rlColor3f(1.0f, 0.0f, 0.0f); rlVertex3f(0.0f, 0.0f, 0.0f);
@ -1164,6 +1164,13 @@ void DrawModelWires(Model model, Vector3 position, float scale, Color color)
rlglDrawModel(model, position, 0.0f, rotationAxis, vScale, color, true); rlglDrawModel(model, position, 0.0f, rotationAxis, vScale, color, true);
} }
// Draw a model wires (with texture if set) with extended parameters
void DrawModelWiresEx(Model model, Vector3 position, float rotationAngle, Vector3 rotationAxis, Vector3 scale, Color tint)
{
// NOTE: Rotation must be provided in degrees, it's converted to radians inside rlglDrawModel()
rlglDrawModel(model, position, rotationAngle, rotationAxis, scale, tint, true);
}
// Draw a billboard // Draw a billboard
void DrawBillboard(Camera camera, Texture2D texture, Vector3 center, float size, Color tint) void DrawBillboard(Camera camera, Texture2D texture, Vector3 center, float size, Color tint)
{ {

View file

@ -329,7 +329,9 @@ typedef struct Shader {
// Uniforms // Uniforms
int projectionLoc; // Projection matrix uniform location point (vertex shader) int projectionLoc; // Projection matrix uniform location point (vertex shader)
int modelviewLoc; // ModeView matrix uniform location point (vertex shader) int modelviewLoc; // ModelView matrix uniform location point (vertex shader)
int modelLoc; // Model transformation matrix uniform location point (vertex shader)
int viewLoc; // View transformation matrix uniform location point (vertex shader)
int tintColorLoc; // Color uniform location point (fragment shader) int tintColorLoc; // Color uniform location point (fragment shader)
int mapDiffuseLoc; // Diffuse map texture uniform location point (fragment shader) int mapDiffuseLoc; // Diffuse map texture uniform location point (fragment shader)
@ -666,6 +668,7 @@ void SetModelTexture(Model *model, Texture2D texture);
void DrawModel(Model model, Vector3 position, float scale, Color tint); // Draw a model (with texture if set) void DrawModel(Model model, Vector3 position, float scale, Color tint); // Draw a model (with texture if set)
void DrawModelEx(Model model, Vector3 position, float rotationAngle, Vector3 rotationAxis, Vector3 scale, Color tint); // Draw a model with extended parameters void DrawModelEx(Model model, Vector3 position, float rotationAngle, Vector3 rotationAxis, Vector3 scale, Color tint); // Draw a model with extended parameters
void DrawModelWires(Model model, Vector3 position, float scale, Color color); // Draw a model wires (with texture if set) void DrawModelWires(Model model, Vector3 position, float scale, Color color); // Draw a model wires (with texture if set)
void DrawModelWiresEx(Model model, Vector3 position, float rotationAngle, Vector3 rotationAxis, Vector3 scale, Color tint); // Draw a model wires (with texture if set) with extended parameters
void DrawBillboard(Camera camera, Texture2D texture, Vector3 center, float size, Color tint); // Draw a billboard texture void DrawBillboard(Camera camera, Texture2D texture, Vector3 center, float size, Color tint); // Draw a billboard texture
void DrawBillboardRec(Camera camera, Texture2D texture, Rectangle sourceRec, Vector3 center, float size, Color tint); // Draw a billboard texture defined by sourceRec void DrawBillboardRec(Camera camera, Texture2D texture, Rectangle sourceRec, Vector3 center, float size, Color tint); // Draw a billboard texture defined by sourceRec

View file

@ -1498,6 +1498,8 @@ void rlglDrawModel(Model model, Vector3 position, float rotationAngle, Vector3 r
glUseProgram(model.shader.id); glUseProgram(model.shader.id);
// Apply transformation provided in model.transform matrix // Apply transformation provided in model.transform matrix
// TODO: review if at this point the modelview matrix just contains view matrix values
Matrix viewworld = modelview; // Store view matrix before applying model transformations
Matrix modelviewworld = MatrixMultiply(model.transform, modelview); // World-space transformation Matrix modelviewworld = MatrixMultiply(model.transform, modelview); // World-space transformation
// Apply transformations provided in function // Apply transformations provided in function
@ -1513,6 +1515,8 @@ void rlglDrawModel(Model model, Vector3 position, float rotationAngle, Vector3 r
// NOTE: Drawing in OpenGL 3.3+, transform is passed to shader // NOTE: Drawing in OpenGL 3.3+, transform is passed to shader
glUniformMatrix4fv(model.shader.projectionLoc, 1, false, GetMatrixVector(projection)); glUniformMatrix4fv(model.shader.projectionLoc, 1, false, GetMatrixVector(projection));
glUniformMatrix4fv(model.shader.modelLoc, 1, false, GetMatrixVector(transform));
glUniformMatrix4fv(model.shader.viewLoc, 1, false, GetMatrixVector(viewworld));
glUniformMatrix4fv(model.shader.modelviewLoc, 1, false, GetMatrixVector(modelviewworld)); glUniformMatrix4fv(model.shader.modelviewLoc, 1, false, GetMatrixVector(modelviewworld));
// Apply color tinting to model // Apply color tinting to model
@ -2242,6 +2246,8 @@ Shader LoadShader(char *vsFileName, char *fsFileName)
// Get handles to GLSL uniform locations (vertex shader) // Get handles to GLSL uniform locations (vertex shader)
shader.modelviewLoc = glGetUniformLocation(shader.id, "modelviewMatrix"); shader.modelviewLoc = glGetUniformLocation(shader.id, "modelviewMatrix");
shader.modelLoc = glGetUniformLocation(shader.id, "modelMatrix");
shader.viewLoc = glGetUniformLocation(shader.id, "viewMatrix");
shader.projectionLoc = glGetUniformLocation(shader.id, "projectionMatrix"); shader.projectionLoc = glGetUniformLocation(shader.id, "projectionMatrix");
// Get handles to GLSL uniform locations (fragment shader) // Get handles to GLSL uniform locations (fragment shader)
@ -2781,6 +2787,8 @@ static Shader LoadDefaultShader(void)
// Get handles to GLSL uniform locations (vertex shader) // Get handles to GLSL uniform locations (vertex shader)
shader.modelviewLoc = glGetUniformLocation(shader.id, "modelviewMatrix"); shader.modelviewLoc = glGetUniformLocation(shader.id, "modelviewMatrix");
shader.modelLoc = glGetUniformLocation(shader.id, "modelMatrix");
shader.viewLoc = glGetUniformLocation(shader.id, "viewMatrix");
shader.projectionLoc = glGetUniformLocation(shader.id, "projectionMatrix"); shader.projectionLoc = glGetUniformLocation(shader.id, "projectionMatrix");
// Get handles to GLSL uniform locations (fragment shader) // Get handles to GLSL uniform locations (fragment shader)
@ -2861,6 +2869,8 @@ static Shader LoadSimpleShader(void)
// Get handles to GLSL uniform locations (vertex shader) // Get handles to GLSL uniform locations (vertex shader)
shader.modelviewLoc = glGetUniformLocation(shader.id, "modelviewMatrix"); shader.modelviewLoc = glGetUniformLocation(shader.id, "modelviewMatrix");
shader.modelLoc = glGetUniformLocation(shader.id, "modelMatrix");
shader.viewLoc = glGetUniformLocation(shader.id, "viewMatrix");
shader.projectionLoc = glGetUniformLocation(shader.id, "projectionMatrix"); shader.projectionLoc = glGetUniformLocation(shader.id, "projectionMatrix");
// Get handles to GLSL uniform locations (fragment shader) // Get handles to GLSL uniform locations (fragment shader)

View file

@ -160,7 +160,9 @@ typedef enum { OPENGL_11 = 1, OPENGL_33, OPENGL_ES_20 } GlVersion;
// Uniforms // Uniforms
int projectionLoc; // Projection matrix uniform location point (vertex shader) int projectionLoc; // Projection matrix uniform location point (vertex shader)
int modelviewLoc; // ModeView matrix uniform location point (vertex shader) int modelviewLoc; // ModelView matrix uniform location point (vertex shader)
int modelLoc; // Model transformation matrix uniform location point (vertex shader)
int viewLoc; // View transformation matrix uniform location point (vertex shader)
int tintColorLoc; // Color uniform location point (fragment shader) int tintColorLoc; // Color uniform location point (fragment shader)
int mapDiffuseLoc; // Diffuse map texture uniform location point (fragment shader) int mapDiffuseLoc; // Diffuse map texture uniform location point (fragment shader)