Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8969287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:34:16+00:00 2026-06-15T17:34:16+00:00

I’m attempting to create a Camera class for a 3D OpenGL project. However I

  • 0

I’m attempting to create a Camera class for a 3D OpenGL project. However I cannot figure out how to actually apply the camera to my scene. I have these Camera functions (amongst others):

void Camera::update(){
    glm::vec3 direction(cos(_verticalAngle) * sin(_horizontalAngle), sin(_verticalAngle), cos(_verticalAngle) * cos(_horizontalAngle));

    glm::vec3 right = glm::vec3(sin(_horizontalAngle - 3.14f/2.0f), 0, cos(_horizontalAngle - 3.14f/2.0f));

    glm::vec3 up = glm::cross(right, direction);

    _projectionMatrix = glm::perspective(_FoV, float(VIEWPORT_X) / float(VIEWPORT_Y), 0.1f, 250.0f);
    _viewMatrix = glm::lookAt(_position, _position + direction, up);
}
glm::mat4 Camera::getProjectionMatrix(){
    return _projectionMatrix;
}
glm::mat4 Camera::getViewMatrix(){
    return _viewMatrix;
}

They were created from a tutorial, I’m not sure if they work though since I can’t test them. What I want to do is get OpenGL to use the view and projection matrices to simulate a camera. How exactly do I tell OpenGL to use those projection and view matrices, so that it properly simulates a camera separate from model’s transformations? I’m aware OpenGL will not accept glm matrices by default, but I have seen this type of thing in a few tutorials:

glm::mat4 ProjectionMatrix = getProjectionMatrix();
glm::mat4 ViewMatrix = getViewMatrix();
glm::mat4 ModelMatrix = glm::mat4(1.0);
glm::mat4 MVP = ProjectionMatrix * ViewMatrix * ModelMatrix;

glUniformMatrix4fv(MatrixID, 1, GL_FALSE, &MVP[0][0]);

but glUniformMatrix4fv (which I think applies the camera transforms?) makes no sense to me. It always has something to do with shaders, which I have none of. I simply have a wireframe test mesh currently. Could someone provide me a code snippet for this problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T17:34:17+00:00Added an answer on June 15, 2026 at 5:34 pm

    I don’t know about using GLM, but I can help with the regular OpenGL part.

    glUniformMatrix4fv updates a 4×4 uniform matrix at the location specified by MatrixID in a particular shader program.

    I recommend working through Learning Modern 3D Graphics Programming, which is excellent as both a reference and guide.

    For a discussion of how these uniforms are used within the GLSL shader program see:
    Learning Modern 3D Graphics Programming – Chapter 3

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
Seemingly simple, but I cannot find anything relevant on the web. What is the
this is what i have right now Drawing an RSS feed into the php,
I have a small JavaScript validation script that validates inputs based on Regex. I
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.