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:
parent
1b39b2e261
commit
4db2da9185
6 changed files with 114 additions and 92 deletions
|
@ -92,7 +92,7 @@ typedef enum { INFO = 0, ERROR, WARNING, DEBUG, OTHER } TraceLogType;
|
|||
//----------------------------------------------------------------------------------
|
||||
// Global Variables Definition
|
||||
//----------------------------------------------------------------------------------
|
||||
bool musicEnabled = false;
|
||||
static bool musicEnabled = false;
|
||||
static Music currentMusic; // Current music loaded
|
||||
// NOTE: Only one music file playing at a time
|
||||
|
||||
|
|
BIN
src/libraylib.a
Normal file
BIN
src/libraylib.a
Normal file
Binary file not shown.
185
src/models.c
185
src/models.c
|
@ -64,7 +64,7 @@ static VertexData LoadOBJ(const char *fileName);
|
|||
|
||||
// Draw cube
|
||||
// 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 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);
|
||||
|
||||
// Front Face -----------------------------------------------------
|
||||
rlVertex3f(x-width/2, y-height/2, z+lenght/2); // Bottom Left
|
||||
rlVertex3f(x+width/2, y-height/2, z+lenght/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); // Bottom Left
|
||||
rlVertex3f(x+width/2, y-height/2, z+length/2); // Bottom Right
|
||||
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+lenght/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); // Top Right
|
||||
rlVertex3f(x-width/2, y+height/2, z+length/2); // Top Left
|
||||
rlVertex3f(x+width/2, y-height/2, z+length/2); // Bottom Right
|
||||
|
||||
// Back Face ------------------------------------------------------
|
||||
rlVertex3f(x-width/2, y-height/2, z-lenght/2); // Bottom Left
|
||||
rlVertex3f(x-width/2, y+height/2, z-lenght/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 Left
|
||||
rlVertex3f(x-width/2, y+height/2, z-length/2); // Top Left
|
||||
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-lenght/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 Right
|
||||
rlVertex3f(x+width/2, y-height/2, z-length/2); // Bottom Right
|
||||
rlVertex3f(x-width/2, y+height/2, z-length/2); // Top Left
|
||||
|
||||
// Top Face -------------------------------------------------------
|
||||
rlVertex3f(x-width/2, y+height/2, z-lenght/2); // Top Left
|
||||
rlVertex3f(x-width/2, y+height/2, z+lenght/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); // Top Left
|
||||
rlVertex3f(x-width/2, y+height/2, z+length/2); // Bottom Left
|
||||
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-lenght/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); // Top Right
|
||||
rlVertex3f(x-width/2, y+height/2, z-length/2); // Top Left
|
||||
rlVertex3f(x+width/2, y+height/2, z+length/2); // Bottom Right
|
||||
|
||||
// Bottom Face ----------------------------------------------------
|
||||
rlVertex3f(x-width/2, y-height/2, z-lenght/2); // Top Left
|
||||
rlVertex3f(x+width/2, y-height/2, z+lenght/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); // Top Left
|
||||
rlVertex3f(x+width/2, y-height/2, z+length/2); // Bottom Right
|
||||
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+lenght/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 Right
|
||||
rlVertex3f(x+width/2, y-height/2, z+length/2); // Bottom Right
|
||||
rlVertex3f(x-width/2, y-height/2, z-length/2); // Top Left
|
||||
|
||||
// Right face -----------------------------------------------------
|
||||
rlVertex3f(x+width/2, y-height/2, z-lenght/2); // Bottom Right
|
||||
rlVertex3f(x+width/2, y+height/2, z-lenght/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); // Bottom Right
|
||||
rlVertex3f(x+width/2, y+height/2, z-length/2); // Top Right
|
||||
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-lenght/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); // Bottom Left
|
||||
rlVertex3f(x+width/2, y-height/2, z-length/2); // Bottom Right
|
||||
rlVertex3f(x+width/2, y+height/2, z+length/2); // Top Left
|
||||
|
||||
// Left Face ------------------------------------------------------
|
||||
rlVertex3f(x-width/2, y-height/2, z-lenght/2); // Bottom Right
|
||||
rlVertex3f(x-width/2, y+height/2, z+lenght/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); // Bottom Right
|
||||
rlVertex3f(x-width/2, y+height/2, z+length/2); // Top Left
|
||||
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+lenght/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 Left
|
||||
rlVertex3f(x-width/2, y+height/2, z+length/2); // Top Left
|
||||
rlVertex3f(x-width/2, y-height/2, z-length/2); // Bottom Right
|
||||
rlEnd();
|
||||
rlPopMatrix();
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ void DrawCubeV(Vector3 position, Vector3 size, Color color)
|
|||
}
|
||||
|
||||
// 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 y = 0.0f;
|
||||
|
@ -160,62 +160,62 @@ void DrawCubeWires(Vector3 position, float width, float height, float lenght, Co
|
|||
|
||||
// Front Face -----------------------------------------------------
|
||||
// Bottom Line
|
||||
rlVertex3f(x-width/2, y-height/2, z+lenght/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 Left
|
||||
rlVertex3f(x+width/2, y-height/2, z+length/2); // Bottom Right
|
||||
|
||||
// Left Line
|
||||
rlVertex3f(x+width/2, y-height/2, z+lenght/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); // Bottom Right
|
||||
rlVertex3f(x+width/2, y+height/2, z+length/2); // Top Right
|
||||
|
||||
// Top Line
|
||||
rlVertex3f(x+width/2, y+height/2, z+lenght/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 Right
|
||||
rlVertex3f(x-width/2, y+height/2, z+length/2); // Top Left
|
||||
|
||||
// Right Line
|
||||
rlVertex3f(x-width/2, y+height/2, z+lenght/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); // Top Left
|
||||
rlVertex3f(x-width/2, y-height/2, z+length/2); // Bottom Left
|
||||
|
||||
// Back Face ------------------------------------------------------
|
||||
// Bottom Line
|
||||
rlVertex3f(x-width/2, y-height/2, z-lenght/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 Left
|
||||
rlVertex3f(x+width/2, y-height/2, z-length/2); // Bottom Right
|
||||
|
||||
// Left Line
|
||||
rlVertex3f(x+width/2, y-height/2, z-lenght/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); // Bottom Right
|
||||
rlVertex3f(x+width/2, y+height/2, z-length/2); // Top Right
|
||||
|
||||
// Top Line
|
||||
rlVertex3f(x+width/2, y+height/2, z-lenght/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 Right
|
||||
rlVertex3f(x-width/2, y+height/2, z-length/2); // Top Left
|
||||
|
||||
// Right Line
|
||||
rlVertex3f(x-width/2, y+height/2, z-lenght/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); // Top Left
|
||||
rlVertex3f(x-width/2, y-height/2, z-length/2); // Bottom Left
|
||||
|
||||
// Top Face -------------------------------------------------------
|
||||
// Left Line
|
||||
rlVertex3f(x-width/2, y+height/2, z+lenght/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 Front
|
||||
rlVertex3f(x-width/2, y+height/2, z-length/2); // Top Left Back
|
||||
|
||||
// Right Line
|
||||
rlVertex3f(x+width/2, y+height/2, z+lenght/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 Front
|
||||
rlVertex3f(x+width/2, y+height/2, z-length/2); // Top Right Back
|
||||
|
||||
// Bottom Face ---------------------------------------------------
|
||||
// Left Line
|
||||
rlVertex3f(x-width/2, y-height/2, z+lenght/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 Front
|
||||
rlVertex3f(x-width/2, y-height/2, z-length/2); // Top Left Back
|
||||
|
||||
// Right Line
|
||||
rlVertex3f(x+width/2, y-height/2, z+lenght/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 Front
|
||||
rlVertex3f(x+width/2, y-height/2, z-length/2); // Top Right Back
|
||||
rlEnd();
|
||||
rlPopMatrix();
|
||||
}
|
||||
|
||||
// Draw cube
|
||||
// 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 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);
|
||||
// Front Face
|
||||
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(1.0f, 0.0f); rlVertex3f(x+width/2, y-height/2, z+lenght/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(0.0f, 1.0f); rlVertex3f(x-width/2, y+height/2, z+lenght/2); // Top 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+length/2); // Bottom 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+length/2); // Top Left Of The Texture and Quad
|
||||
// Back Face
|
||||
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, 1.0f); rlVertex3f(x-width/2, y+height/2, z-lenght/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, 0.0f); rlVertex3f(x+width/2, y-height/2, z-lenght/2); // Bottom Left 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-length/2); // Top Right 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-length/2); // Bottom Left Of The Texture and Quad
|
||||
// Top Face
|
||||
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, 0.0f); rlVertex3f(x-width/2, y+height/2, z+lenght/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, 1.0f); rlVertex3f(x+width/2, y+height/2, z-lenght/2); // Top Right 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+length/2); // Bottom Left 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-length/2); // Top Right Of The Texture and Quad
|
||||
// Bottom Face
|
||||
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(0.0f, 1.0f); rlVertex3f(x+width/2, y-height/2, z-lenght/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(1.0f, 0.0f); rlVertex3f(x-width/2, y-height/2, z+lenght/2); // Bottom 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-length/2); // Top 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+length/2); // Bottom Right Of The Texture and Quad
|
||||
// Right face
|
||||
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, 1.0f); rlVertex3f(x+width/2, y+height/2, z-lenght/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, 0.0f); rlVertex3f(x+width/2, y-height/2, z+lenght/2); // Bottom Left 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-length/2); // Top Right 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+length/2); // Bottom Left Of The Texture and Quad
|
||||
// Left Face
|
||||
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(1.0f, 0.0f); rlVertex3f(x-width/2, y-height/2, z+lenght/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(0.0f, 1.0f); rlVertex3f(x-width/2, y+height/2, z-lenght/2); // Top 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+length/2); // Bottom 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-length/2); // Top Left Of The Texture and Quad
|
||||
rlEnd();
|
||||
//rlPopMatrix();
|
||||
|
||||
|
@ -534,12 +534,12 @@ void DrawGrid(int slices, float spacing)
|
|||
void DrawGizmo(Vector3 position)
|
||||
{
|
||||
// NOTE: RGB = XYZ
|
||||
float lenght = 1.0f;
|
||||
float length = 1.0f;
|
||||
|
||||
rlPushMatrix();
|
||||
rlTranslatef(position.x, position.y, position.z);
|
||||
//rlRotatef(rotation, 0, 1, 0);
|
||||
rlScalef(lenght, lenght, lenght);
|
||||
rlScalef(length, length, length);
|
||||
|
||||
rlBegin(RL_LINES);
|
||||
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);
|
||||
}
|
||||
|
||||
// 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
|
||||
void DrawBillboard(Camera camera, Texture2D texture, Vector3 center, float size, Color tint)
|
||||
{
|
||||
|
|
|
@ -329,7 +329,9 @@ typedef struct Shader {
|
|||
|
||||
// Uniforms
|
||||
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 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 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 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 DrawBillboardRec(Camera camera, Texture2D texture, Rectangle sourceRec, Vector3 center, float size, Color tint); // Draw a billboard texture defined by sourceRec
|
||||
|
|
10
src/rlgl.c
10
src/rlgl.c
|
@ -1498,6 +1498,8 @@ void rlglDrawModel(Model model, Vector3 position, float rotationAngle, Vector3 r
|
|||
glUseProgram(model.shader.id);
|
||||
|
||||
// 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
|
||||
|
||||
// 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
|
||||
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));
|
||||
|
||||
// Apply color tinting to model
|
||||
|
@ -2242,6 +2246,8 @@ Shader LoadShader(char *vsFileName, char *fsFileName)
|
|||
|
||||
// Get handles to GLSL uniform locations (vertex shader)
|
||||
shader.modelviewLoc = glGetUniformLocation(shader.id, "modelviewMatrix");
|
||||
shader.modelLoc = glGetUniformLocation(shader.id, "modelMatrix");
|
||||
shader.viewLoc = glGetUniformLocation(shader.id, "viewMatrix");
|
||||
shader.projectionLoc = glGetUniformLocation(shader.id, "projectionMatrix");
|
||||
|
||||
// Get handles to GLSL uniform locations (fragment shader)
|
||||
|
@ -2781,6 +2787,8 @@ static Shader LoadDefaultShader(void)
|
|||
|
||||
// Get handles to GLSL uniform locations (vertex shader)
|
||||
shader.modelviewLoc = glGetUniformLocation(shader.id, "modelviewMatrix");
|
||||
shader.modelLoc = glGetUniformLocation(shader.id, "modelMatrix");
|
||||
shader.viewLoc = glGetUniformLocation(shader.id, "viewMatrix");
|
||||
shader.projectionLoc = glGetUniformLocation(shader.id, "projectionMatrix");
|
||||
|
||||
// Get handles to GLSL uniform locations (fragment shader)
|
||||
|
@ -2861,6 +2869,8 @@ static Shader LoadSimpleShader(void)
|
|||
|
||||
// Get handles to GLSL uniform locations (vertex shader)
|
||||
shader.modelviewLoc = glGetUniformLocation(shader.id, "modelviewMatrix");
|
||||
shader.modelLoc = glGetUniformLocation(shader.id, "modelMatrix");
|
||||
shader.viewLoc = glGetUniformLocation(shader.id, "viewMatrix");
|
||||
shader.projectionLoc = glGetUniformLocation(shader.id, "projectionMatrix");
|
||||
|
||||
// Get handles to GLSL uniform locations (fragment shader)
|
||||
|
|
|
@ -160,7 +160,9 @@ typedef enum { OPENGL_11 = 1, OPENGL_33, OPENGL_ES_20 } GlVersion;
|
|||
|
||||
// Uniforms
|
||||
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 mapDiffuseLoc; // Diffuse map texture uniform location point (fragment shader)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue