Hot answers tagged

3

You get the error because there is no operator*= for vec4 that takes a matrix as a parameter. It then tries to convert the matrix to a float, but just can't. To work around this, you should try to not use the operator*= and write it all in the long form: Off = Off * Util::createTransform(offset); Also, as pointed out in the comments to the OP, what you ...


3

user1118321's answer will provide you the correct answer, though it is more general than necessary. Since we're dealing with a right triangle, the easiest solution is to use the definition of the tangent function: tan(α) = A / B Substituting half the height of the screen, the z coordinate of the camera, and half the vertical field of view gets us: ...


2

Check out the Law of Cosines. It allows you to calculate any side or angle in a triangle if you have the opposite 2 angles or sides. Or alternately, use the law of sines (described at the bottom of the above link). In your case, you know that vertical field of view is 45 degrees and that the base side you want is the height of the screen. You can think of ...


2

You should probably use glm::angleAxis() (documentation here): glm::quat &rot = glm::angleAxis(glm::radians(90.f), glm::vec3(0.f, 1.f, 0.f));


2

One way is to disable GL_DEPTH_TEST for rendering 2D stuff. So draw everything of the 3D world like normal, then disable depth testing and then draw your UI at last. Another approach would make use of the depth test by setting the z-component of the vertices for the 2D stuff to 0 (and the near plane in the prohection matrix to something greater than 0) to ...


2

Short answer: To store position, use a single vec3. To store rotation, use a quaternion and normalize it after every multiplication or after every n (1-1000) multiplications. You shall only use mat4s when it comes to drawing or transforming lots of vertices: Convert vec3+quaternion pair to mat4 and pass it to your shader or use it to transform vertices ...


1

It's unclear where your issue lies. To rotate a vector about the origin, you create a rotation matrix, and then you multiply the vertex by the matrix. In order to create the rotation matrix, you need a rotation axis and an angle. With glm, you can do it this way: glm::vec3 v3RotAxis( 0.0f, 0.0f, 1.0f ); // Rotate about z+ float angleRad = ...


1

I did several changes to the code and something of the following fixed my problem: changed the order so that all the block binding was done before initializing the uniform buffer added "layout (std140)" to the uniform block in the vertex shader i made sure that i unbound everything after binding and executing series of commands thanks wondra for the ...


1

If you have v-sync enabled ( SDL_GL_SetSwapInterval(1) ), SDL_GL_SwapWindow will wait until your monitor refreshes.


1

When you rotate your camera you should apply the same rotation matrix to your up vector. That should result in an up vector in the same direction as your view matrix's up direction.



Only top voted, non community-wiki answers of a minimum length are eligible