-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[camera] Improvements on camera module #1143
Comments
It would be nice to see right from the bottom up rlgl -> camera etc, raylib using some kind of matrix stack (like the old fixed function GL versions (you're probably too young to remember ;) :p )) |
Following snippet will highlight the issue with the current camera implementation: while (!WindowShouldClose())
{
SetCameraMode(camera, CAMERA_ORBITAL);
UpdateCamera(&camera);
UpdateModelAnimation(character, anims[0], animFrameCounter++);
if (animFrameCounter >= anims[0].frameCount) animFrameCounter = 0;
float cameraPos[3] = { camera.position.x, camera.position.y, camera.position.z };
SetShaderValue(lighShader, lighShader.locs[LOC_VECTOR_VIEW], cameraPos, UNIFORM_VEC3);
BeginDrawing();
ClearBackground(RAYWHITE);
BeginTextureMode(shadowMap);
ClearBackground(WHITE);
/*
SetCameraMode(shadowCamera, CAMERA_CUSTOM);
UpdateCamera(&shadowCamera);
*/
character.materials[0].shader = shadowShader;
BeginMode3D(shadowCamera);
DrawModel(character, Vector3{ 0.0f, 0.0f, 0.0f }, 1.0, GRAY);
EndMode3D();
EndTextureMode();
BeginMode3D(camera);
DrawPlane(Vector3{ 0.0f, 0.0f, 0.0f }, Vector2{ 10.0f, 10.0f }, DARKGREEN);
DrawGrid(10.0f, 1.0f);
character.materials[0].shader = lighShader;
DrawModel(character, Vector3{ 0.0f, 0.0f, 0.0f }, 1.0, GRAY);
EndMode3D();
//DrawTextureRec(shadowMap.texture, Rectangle{ 0.0f, 0.0f, (float)shadowMap.texture.width, (float)shadowMap.texture.height }, Vector2{ 0.0f, 0.0f }, WHITE);
DrawText("Congrats! blah", 190, 200, 20, LIGHTGRAY);
DrawFPS(700, 15);
EndDrawing();
} |
@chriscamacho I'm old enough to remember very well OpenGL 1.1... :P Actually, @las3rlars I see the issue, why not you just |
@raysan5 This may not be the correct issue but I agree with the suggestion to have Something along the lines of I'm happy to make a proof of concept pull request if you feel this is a potentially viable solution |
@HeartofPhos I prefer keeping the |
I'm closing this issue, an alternative and better Camera implementation is provided here. |
camera
module consist basically of two functions:SetCameraMode()
: It setups internal variables for the passed camera and also sets the mode howUpdateCamera()
function behaves.UpdateCamera()
: It updates camera parameters depending on mode and some configurable inputs. Modes are predefined to some standard ones, likeCAMERA_FREE
orCAMERA_FIRST_PERSON
.As previously reported, there are some undesired side effects when user deals with multiple cameras. The expected usage mode is calling
SetCameraMode()
to initialize parameters for a new camera and update mode. Later callUpdateCamera()
on that camera for expected update.There are two possible lines of improvement on the module:
TODO
points on the code defining some possible issues (it should be retested to confirm...)The text was updated successfully, but these errors were encountered: