Try to support stack matrices on models drawing
Not working yet... :(
This commit is contained in:
parent
7c05e498fc
commit
8e870f0eda
1 changed files with 13 additions and 5 deletions
18
src/rlgl.h
18
src/rlgl.h
|
@ -735,7 +735,7 @@ typedef struct DrawCall {
|
||||||
int mode; // Drawing mode: LINES, TRIANGLES, QUADS
|
int mode; // Drawing mode: LINES, TRIANGLES, QUADS
|
||||||
int vertexCount; // Number of vertex of the draw
|
int vertexCount; // Number of vertex of the draw
|
||||||
int vertexAlignment; // Number of vertex required for index alignment (LINES, TRIANGLES)
|
int vertexAlignment; // Number of vertex required for index alignment (LINES, TRIANGLES)
|
||||||
//unsigned int vaoId; // Vertex Array id to be used on the draw
|
//unsigned int vaoId; // Vertex array id to be used on the draw
|
||||||
//unsigned int shaderId; // Shader id to be used on the draw
|
//unsigned int shaderId; // Shader id to be used on the draw
|
||||||
unsigned int textureId; // Texture id to be used on the draw
|
unsigned int textureId; // Texture id to be used on the draw
|
||||||
// TODO: Support additional texture units?
|
// TODO: Support additional texture units?
|
||||||
|
@ -1140,8 +1140,8 @@ void rlEnd(void)
|
||||||
{
|
{
|
||||||
// WARNING: If we are between rlPushMatrix() and rlPopMatrix() and we need to force a rlglDraw(),
|
// WARNING: If we are between rlPushMatrix() and rlPopMatrix() and we need to force a rlglDraw(),
|
||||||
// we need to call rlPopMatrix() before to recover *currentMatrix (modelview) for the next forced draw call!
|
// we need to call rlPopMatrix() before to recover *currentMatrix (modelview) for the next forced draw call!
|
||||||
// Also noted that if we had multiple matrix pushed, it will require "stackCounter" pops before launching the draw
|
// If we have multiple matrix pushed, it will require "stackCounter" pops before launching the draw
|
||||||
rlPopMatrix();
|
for (int i = stackCounter; i >= 0; i--) rlPopMatrix();
|
||||||
rlglDraw();
|
rlglDraw();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2622,9 +2622,17 @@ void rlDrawMesh(Mesh mesh, Material material, Matrix transform)
|
||||||
// That's because BeginMode3D() sets it an no model-drawing function modifies it, all use rlPushMatrix() and rlPopMatrix()
|
// That's because BeginMode3D() sets it an no model-drawing function modifies it, all use rlPushMatrix() and rlPopMatrix()
|
||||||
Matrix matView = modelview; // View matrix (camera)
|
Matrix matView = modelview; // View matrix (camera)
|
||||||
Matrix matProjection = projection; // Projection matrix (perspective)
|
Matrix matProjection = projection; // Projection matrix (perspective)
|
||||||
|
|
||||||
|
// TODO: Matrix nightmare! Trying to combine stack matrices with view matrix and local model transform matrix..
|
||||||
|
// There is some problem in the order matrices are multiplied... it requires some time to figure out...
|
||||||
|
Matrix matStackTransform = MatrixIdentity();
|
||||||
|
|
||||||
|
// TODO: Consider possible transform matrices in the stack
|
||||||
|
// Is this the right order? or should we start with the first stored matrix instead of the last one?
|
||||||
|
//for (int i = stackCounter; i > 0; i--) matStackTransform = MatrixMultiply(stack[i], matStackTransform);
|
||||||
|
|
||||||
// Calculate model-view matrix combining matModel and matView
|
Matrix matModel = MatrixMultiply(transform, matStackTransform); // Apply local model transformation
|
||||||
Matrix matModelView = MatrixMultiply(transform, matView); // Transform to camera-space coordinates
|
Matrix matModelView = MatrixMultiply(matModel, matView); // Transform to camera-space coordinates
|
||||||
//-----------------------------------------------------
|
//-----------------------------------------------------
|
||||||
|
|
||||||
// Bind active texture maps (if available)
|
// Bind active texture maps (if available)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue