Added functions to customize internal matrix
Internal modelview and projection matrices can be replaced before drawing.
This commit is contained in:
parent
2168d8aa1a
commit
0bc71d84f8
@ -868,6 +868,9 @@ void SetShaderValue(Shader shader, int uniformLoc, float *value, int size); // S
|
||||
void SetShaderValuei(Shader shader, int uniformLoc, int *value, int size); // Set shader uniform value (int)
|
||||
void SetShaderValueMatrix(Shader shader, int uniformLoc, Matrix mat); // Set shader uniform value (matrix 4x4)
|
||||
|
||||
void SetMatrixProjection(Matrix proj); // Set a custom projection matrix (replaces internal projection matrix)
|
||||
void SetMatrixModelview(Matrix view); // Set a custom modelview matrix (replaces internal modelview matrix)
|
||||
|
||||
void BeginShaderMode(Shader shader); // Begin custom shader drawing
|
||||
void EndShaderMode(void); // End custom shader drawing (use default shader)
|
||||
void BeginBlendMode(int mode); // Begin blending mode (alpha, additive, multiplied)
|
||||
|
@ -339,15 +339,14 @@ RMDEF Vector3 VectorReflect(Vector3 vector, Vector3 normal)
|
||||
return result;
|
||||
}
|
||||
|
||||
// Transforms a Vector3 with a given Matrix
|
||||
// Transforms a Vector3 by a given Matrix
|
||||
// TODO: Review math (matrix transpose required?)
|
||||
RMDEF void VectorTransform(Vector3 *v, Matrix mat)
|
||||
{
|
||||
float x = v->x;
|
||||
float y = v->y;
|
||||
float z = v->z;
|
||||
|
||||
//MatrixTranspose(&mat);
|
||||
|
||||
v->x = mat.m0*x + mat.m4*y + mat.m8*z + mat.m12;
|
||||
v->y = mat.m1*x + mat.m5*y + mat.m9*z + mat.m13;
|
||||
v->z = mat.m2*x + mat.m6*y + mat.m10*z + mat.m14;
|
||||
|
25
src/rlgl.c
25
src/rlgl.c
@ -28,7 +28,7 @@
|
||||
|
||||
#include "rlgl.h"
|
||||
|
||||
#include <stdio.h> // Standard input / output lib
|
||||
#include <stdio.h> // Required for: fopen(), fclose(), fread()... [Used only on ReadTextFile()]
|
||||
#include <stdlib.h> // Required for: malloc(), free(), rand()
|
||||
#include <string.h> // Required for: strcmp(), strlen(), strtok()
|
||||
|
||||
@ -59,8 +59,8 @@
|
||||
#endif
|
||||
|
||||
#if defined(RLGL_STANDALONE)
|
||||
#include <stdarg.h> // Required for: va_list, va_start(), vfprintf(), va_end()
|
||||
#endif // NOTE: Used on TraceLog()
|
||||
#include <stdarg.h> // Required for: va_list, va_start(), vfprintf(), va_end() [Used only on TraceLog()]
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Defines and Macros
|
||||
@ -355,7 +355,6 @@ void rlRotatef(float angleDeg, float x, float y, float z)
|
||||
Vector3 axis = (Vector3){ x, y, z };
|
||||
VectorNormalize(&axis);
|
||||
matRotation = MatrixRotate(axis, angleDeg*DEG2RAD);
|
||||
|
||||
MatrixTranspose(&matRotation);
|
||||
|
||||
*currentMatrix = MatrixMultiply(*currentMatrix, matRotation);
|
||||
@ -2153,7 +2152,7 @@ void UnloadShader(Shader shader)
|
||||
}
|
||||
}
|
||||
|
||||
// Set custom shader to be used on batch draw
|
||||
// Begin custom shader mode
|
||||
void BeginShaderMode(Shader shader)
|
||||
{
|
||||
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
|
||||
@ -2165,7 +2164,7 @@ void BeginShaderMode(Shader shader)
|
||||
#endif
|
||||
}
|
||||
|
||||
// Set default shader to be used in batch draw
|
||||
// End custom shader mode (returns to default shader)
|
||||
void EndShaderMode(void)
|
||||
{
|
||||
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
|
||||
@ -2251,6 +2250,18 @@ void SetShaderValueMatrix(Shader shader, int uniformLoc, Matrix mat)
|
||||
#endif
|
||||
}
|
||||
|
||||
// Set a custom projection matrix (replaces internal projection matrix)
|
||||
void SetMatrixProjection(Matrix proj)
|
||||
{
|
||||
projection = proj;
|
||||
}
|
||||
|
||||
// Set a custom modelview matrix (replaces internal modelview matrix)
|
||||
void SetMatrixModelview(Matrix view)
|
||||
{
|
||||
modelview = view;
|
||||
}
|
||||
|
||||
// Begin blending mode (alpha, additive, multiplied)
|
||||
// NOTE: Only 3 blending modes supported, default blend mode is alpha
|
||||
void BeginBlendMode(int mode)
|
||||
@ -3068,7 +3079,7 @@ static void UnloadDefaultBuffers(void)
|
||||
free(quads.indices);
|
||||
}
|
||||
|
||||
// Sets shader uniform values for lights array
|
||||
// Setup shader uniform values for lights array
|
||||
// NOTE: It would be far easier with shader UBOs but are not supported on OpenGL ES 2.0f
|
||||
static void SetShaderLights(Shader shader)
|
||||
{
|
||||
|
@ -329,6 +329,9 @@ void SetShaderValue(Shader shader, int uniformLoc, float *value, int size); // S
|
||||
void SetShaderValuei(Shader shader, int uniformLoc, int *value, int size); // Set shader uniform value (int)
|
||||
void SetShaderValueMatrix(Shader shader, int uniformLoc, Matrix mat); // Set shader uniform value (matrix 4x4)
|
||||
|
||||
void SetMatrixProjection(Matrix proj); // Set a custom projection matrix (replaces internal projection matrix)
|
||||
void SetMatrixModelview(Matrix view); // Set a custom modelview matrix (replaces internal modelview matrix)
|
||||
|
||||
void BeginShaderMode(Shader shader); // Begin custom shader drawing
|
||||
void EndShaderMode(void); // End custom shader drawing (use default shader)
|
||||
void BeginBlendMode(int mode); // Begin blending mode (alpha, additive, multiplied)
|
||||
|
Loading…
Reference in New Issue
Block a user