rlgl usable as standalone library
This commit is contained in:
parent
84aff31973
commit
980d9d4cd4
@ -91,7 +91,7 @@ int main(void)
|
||||
glfwSwapInterval(1);
|
||||
|
||||
// Load OpenGL 3.3 supported extensions
|
||||
rlglLoadExtensions(glfwGetProcAddress);
|
||||
rlLoadExtensions(glfwGetProcAddress);
|
||||
//--------------------------------------------------------
|
||||
|
||||
// Initialize OpenGL context (states and resources)
|
||||
@ -130,7 +130,7 @@ int main(void)
|
||||
rlClearScreenBuffers(); // Clear current framebuffer
|
||||
|
||||
// Calculate projection matrix (from perspective) and view matrix from camera look at
|
||||
Matrix matProj = MatrixPerspective(camera.fovy, (double)screenWidth/(double)screenHeight, 0.01, 1000.0);
|
||||
Matrix matProj = MatrixPerspective(camera.fovy*DEG2RAD, (double)screenWidth/(double)screenHeight, 0.01, 1000.0);
|
||||
MatrixTranspose(&matProj);
|
||||
Matrix matView = MatrixLookAt(camera.position, camera.target, camera.up);
|
||||
|
||||
|
16
src/rlgl.c
16
src/rlgl.c
@ -2548,7 +2548,7 @@ Texture2D GenTextureCubemap(Shader shader, Texture2D skyHDR, int size)
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
||||
// Create projection (transposed) and different views for each face
|
||||
Matrix fboProjection = MatrixPerspective(90.0, 1.0, 0.01, 1000.0);
|
||||
Matrix fboProjection = MatrixPerspective(90.0*DEG2RAD, 1.0, 0.01, 1000.0);
|
||||
MatrixTranspose(&fboProjection);
|
||||
Matrix fboViews[6] = {
|
||||
MatrixLookAt((Vector3){ 0.0f, 0.0f, 0.0f }, (Vector3){ 1.0f, 0.0f, 0.0f }, (Vector3){ 0.0f, -1.0f, 0.0f }),
|
||||
@ -2581,7 +2581,7 @@ Texture2D GenTextureCubemap(Shader shader, Texture2D skyHDR, int size)
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
|
||||
// Reset viewport dimensions to default
|
||||
glViewport(0, 0, GetScreenWidth(), GetScreenHeight());
|
||||
glViewport(0, 0, screenWidth, screenHeight);
|
||||
//glEnable(GL_CULL_FACE);
|
||||
|
||||
cubemap.width = size;
|
||||
@ -2620,7 +2620,7 @@ Texture2D GenTextureIrradiance(Shader shader, Texture2D cubemap, int size)
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
||||
// Create projection (transposed) and different views for each face
|
||||
Matrix fboProjection = MatrixPerspective(90.0, 1.0, 0.01, 1000.0);
|
||||
Matrix fboProjection = MatrixPerspective(90.0*DEG2RAD, 1.0, 0.01, 1000.0);
|
||||
MatrixTranspose(&fboProjection);
|
||||
Matrix fboViews[6] = {
|
||||
MatrixLookAt((Vector3){ 0.0f, 0.0f, 0.0f }, (Vector3){ 1.0f, 0.0f, 0.0f }, (Vector3){ 0.0f, -1.0f, 0.0f }),
|
||||
@ -2653,7 +2653,7 @@ Texture2D GenTextureIrradiance(Shader shader, Texture2D cubemap, int size)
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
|
||||
// Reset viewport dimensions to default
|
||||
glViewport(0, 0, GetScreenWidth(), GetScreenHeight());
|
||||
glViewport(0, 0, screenWidth, screenHeight);
|
||||
|
||||
irradiance.width = size;
|
||||
irradiance.height = size;
|
||||
@ -2696,7 +2696,7 @@ Texture2D GenTexturePrefilter(Shader shader, Texture2D cubemap, int size)
|
||||
glGenerateMipmap(GL_TEXTURE_CUBE_MAP);
|
||||
|
||||
// Create projection (transposed) and different views for each face
|
||||
Matrix fboProjection = MatrixPerspective(90.0, 1.0, 0.01, 1000.0);
|
||||
Matrix fboProjection = MatrixPerspective(90.0*DEG2RAD, 1.0, 0.01, 1000.0);
|
||||
MatrixTranspose(&fboProjection);
|
||||
Matrix fboViews[6] = {
|
||||
MatrixLookAt((Vector3){ 0.0f, 0.0f, 0.0f }, (Vector3){ 1.0f, 0.0f, 0.0f }, (Vector3){ 0.0f, -1.0f, 0.0f }),
|
||||
@ -2743,7 +2743,7 @@ Texture2D GenTexturePrefilter(Shader shader, Texture2D cubemap, int size)
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
|
||||
// Reset viewport dimensions to default
|
||||
glViewport(0, 0, GetScreenWidth(), GetScreenHeight());
|
||||
glViewport(0, 0, screenWidth, screenHeight);
|
||||
|
||||
prefilter.width = size;
|
||||
prefilter.height = size;
|
||||
@ -2783,7 +2783,7 @@ Texture2D GenTextureBRDF(Shader shader, Texture2D cubemap, int size)
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
|
||||
// Reset viewport dimensions to default
|
||||
glViewport(0, 0, GetScreenWidth(), GetScreenHeight());
|
||||
glViewport(0, 0, screenWidth, screenHeight);
|
||||
|
||||
brdf.width = size;
|
||||
brdf.height = size;
|
||||
@ -3985,7 +3985,7 @@ static void SetStereoConfig(VrDeviceInfo hmd)
|
||||
|
||||
// Compute camera projection matrices
|
||||
float projOffset = 4.0f*lensShift; // Scaled to projection space coordinates [-1..1]
|
||||
Matrix proj = MatrixPerspective(fovy, aspect, 0.01, 1000.0);
|
||||
Matrix proj = MatrixPerspective(fovy*DEG2RAD, aspect, 0.01, 1000.0);
|
||||
vrConfig.eyesProjection[0] = MatrixMultiply(proj, MatrixTranslate(projOffset, 0.0f, 0.0f));
|
||||
vrConfig.eyesProjection[1] = MatrixMultiply(proj, MatrixTranslate(-projOffset, 0.0f, 0.0f));
|
||||
|
||||
|
15
src/rlgl.h
15
src/rlgl.h
@ -435,19 +435,20 @@ void UnloadShader(Shader shader); // Unload a custom shade
|
||||
Shader GetShaderDefault(void); // Get default shader
|
||||
Texture2D GetTextureDefault(void); // Get default texture
|
||||
|
||||
// Shader configuration functions
|
||||
int GetShaderLocation(Shader shader, const char *uniformName); // Get shader uniform location
|
||||
void SetShaderValue(Shader shader, int uniformLoc, float *value, int size); // Set shader uniform value (float)
|
||||
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 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)
|
||||
|
||||
// Texture maps generation (PBR)
|
||||
Texture2D GenTextureCubemap(Texture2D skyHDR, int size); // Generate cubemap texture map from HDR texture
|
||||
Texture2D GenTextureIrradiance(Texture2D cubemap, int size); // Generate irradiance texture map
|
||||
Texture2D GenTexturePrefilter(Texture2D cubemap, int size); // Generate prefilter texture map
|
||||
Texture2D GenTextureBRDF(Texture2D cubemap, int size); // Generate BRDF texture map
|
||||
// NOTE: Required shaders should be provided
|
||||
Texture2D GenTextureCubemap(Shader shader, Texture2D skyHDR, int size); // Generate cubemap texture from HDR texture
|
||||
Texture2D GenTextureIrradiance(Shader shader, Texture2D cubemap, int size); // Generate irradiance texture using cubemap data
|
||||
Texture2D GenTexturePrefilter(Shader shader, Texture2D cubemap, int size); // Generate prefilter texture using cubemap data
|
||||
Texture2D GenTextureBRDF(Shader shader, Texture2D cubemap, int size); // Generate BRDF texture using cubemap data
|
||||
|
||||
// Shading and blending
|
||||
void BeginShaderMode(Shader shader); // Begin custom shader drawing
|
||||
|
Loading…
Reference in New Issue
Block a user