Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

16 Neutral

About calioranged

  • Rank

Personal Information

  • Interests

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. calioranged

    Drawing Circles in OpenGL

    I want to draw a circle in OpenGL. I have looked for examples of how to do this, but the only ones I can find use deprecated functions such as glBegin(), glEnd() and glVertex(). Can somebody provide an example of how this can be done using modern OpenGL? Thanks.
  2. My question is regarding element array buffer (IBO) binding. I have heard it said that (providing a VAO is already bound) an IBO binding will be saved to the current state of the VAO. Does this mean that instead of binding the IBO henceforth, we can just bind the VAO instead? i.e. as long as the VAO is bound before calling glDrawElements(), the draw call will always work? I have provided an annotated code example below, for clarity: // ... // VBO: glGenBuffers(1, &VBO); glBindBuffer(GL_ARRAY_BUFFER, VBO); glNamedBufferData(VBO, sizeof(data), &data, draw_method) // VAO: glGenVertexArrays(1, VAO); glBindVertexArray(VAO); // Enable and input attributes etc... // IBO: glGenBuffers(1, IBO); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, IBO); glNamedBufferData(IBO, sizeof(data), &data, draw_method) /* index buffer binding saved to VAO state? as long as VAO is bound prior to draw call, glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, IBO) does not need to be called again? */ // ... while (!display.WindowShouldClose()) { display.ClearBuffers(); // ... glBindVertexArray(VAO); // index buffer binding not necessary? Only VAO binding required? glDrawElements(GL_TRIANGLES, elements, GL_UNSIGNED_SHORT, nullptr); // ... display.SwapBuffers(); }
  3. This question is based on a completely hypothetical situation which has occurred to me. It is not a problem I am actually having, just one that I think could potentially occur in the future. Suppose that we have two vertex array objects - Squares_VAO and Trapezium_VAO: std::array<float, 18> square_vertices { -0.75F, 1.0F , 1.0F , // Position (Attribute 0) 0.5F , 0.0F , 0.0F , // Colour (Attribute 1) -1.0F , 1.0F , 1.0F , 0.5F , 0.0F , 0.0F , -1.0F , 1.0F , 0.75F, 0.5F , 0.0F , 0.0F , -0.75F, 1.0F , 0.75F, 0.5F , 0.0F , 0.0F }; Squares_VBO(squares_vertices); // sets up squares vbo... Squares_VAO; // sets up squares vao... std::array<float, 18> trapezium_vertices { -0.75F, 1.01F, 1.0F , // Colour (Attribute 0) 0.5F , 0.0F , 0.0F , // Position (Attribute 1) -1.0F , 1.0F , 1.0F , 0.5F , 0.0F , 0.0F , -1.0F , 1.0F , 0.75F, 0.5F , 0.0F , 0.0F , -0.75F, 1.0F , 0.75F, 0.5F , 0.0F , 0.0F }; Trapezium_VBO(trapezium_vertices); // sets up trapezium vbo... Trapezium_VAO; // sets up trapezium vao... The only difference between square_vertices and trapezium_vertices is that the position and colour attributes have swapped positions; in square_vertices, position and colour are attributes 0 and 1 respectively, and then vice versa for trapezium_vertices. Suppose that the shader looks something like this: #vertex shader #version 330 core layout(location = 0) in vec4 position; layout(location = 1) in vec4 colours; //... There would obviously be an issue here where for the Trapezium_VAO, the attributes are going to be fetched the wrong way round (i.e. position will be attribute 0 and colour will be attribute 1). Obviously you could just correct this in trapezium_vertices (by swapping the location of the attributes), but suppose that for whatever reason this isn't possible - what would one do to solve this? There could be other scenarios similar to this, for example the attribute at a given location being a vec3 in one VAO and a vec4 in another VAO: std::array<float, 8> square_vertices { -0.75F, 1.0F, 1.0F, 0.5F // Position (Attribute 0) ... 0.5F , 0.0F, 0.0F, 0.0F }; std::array<float, 6> triangle_vertices { -0.75F, 1.0F, 1.0F, // Position (Attribute 0) ... 0.5F , 0.0F, 0.0F }; ... #vertex shader #version 330 core layout(location = 0) in vec4 position; // will only work for square_vertices, since has 4 components per vertex.. // whereas triangle_vertices has 3 components per vertex... How could one get around this?
  4. calioranged

    Understanding glDrawElementsInstanced

    Thanks a lot for that clarification!
  5. calioranged

    Learning About Rotation

    Sorry I should have been clearer with my language. In the glm documentation this is referred to as the 'axis of 3 scalars'. I think the correct terminology would be rotation axis. // matrix angle 'rotation vector' / axis glm::rotate(glm::mat4(1.0F), glm::radians(Movement.y) / 2, glm::vec3(Rotation.x, Rotation.y, Rotation.z) That was probably the best possible explanation I ever could have hoped for, thanks so much for taking the time to go through that example with me. I followed the instructions you gave all the way through and I feel I now have a basic level of understanding. For some reason I just couldn't conceptualise the idea of rotating around an axis that was represented by its distance from the centre/origin of the camera, but thanks to your example, I am now able to visualise this. Thank you @DerTroll and @Green_Baron for the endless patience you have both shown towards me.
  6. calioranged

    Learning About Rotation

    Thanks for the extra detail you just went into just there. I can picture all this just fine. What I cannot picture is a situation where there would be more than one non-zero value in the rotation vector - and how this would affect the viewing direction. Sorry that I am having a harder time grasping this than you would expect. If it is frustrating to you then I wouldn't be at all offended if you didn't write back, you have tried to help as much as you can. I am trying my best but I appreciate that I am a slow learner without much intuition. Sorry.
  7. calioranged

    Learning About Rotation

    Thanks for all of your help.
  8. calioranged

    Learning About Rotation

    In OpenGL; +X is to the right, +Y is up and +Z is coming out of the screen towards the viewer. That makes it rather difficult for me to picture what you have just explained being that the axes would all be in a different order. When you say 'please rotate by 90 degrees left', I'm not sure what you mean. From my understanding, rotation occurs on a particular axis so maybe you mean rotate on the y-axis (OpenGL y-axis) but I'm not sure. I am very grateful for your explanations but to be honest I am just not grasping them at all. I think I need to do much more on the basics before reviewing what you have said again. P.S. How can an axis be 3D?
  9. calioranged

    Learning About Rotation

    Right. So { 1.0F, 0.5F, 0.0F } represents an axis rather than the value that the angle should be multiplied by to get the final angle of rotation on each axis. Again I cannot conceptualise how a 3D vector could represent an axis. To me it seems that an axis is 1D, you need 3 axes (x, y, z) to represent 3 dimensions. Anyway I am gonna spend the next few months working through some Khan Academy linear algebra and the interactive tutorial you provided. Maybe I will be able to understand your explanations a bit better!
  10. calioranged

    Learning About Rotation

    Yes sorry I have my terminology wrong there. What I mean is that if you have the following rotate matrix: glm::mat4 rotator { glm::rotate(glm::mat4(1.0F), glm::radians(degrees), glm::vec3(rotation.x, rotation.y, rotation.z)) }; MVP.view.direction = rotator * MVP.view.direction; Where: degrees = 90 rotation.x = 1.0F rotation.y = 0.5F rotation.z = 0.0F Then the view direction will be rotated by: 90° on the x-axis (90 * 1.0) 45° on the y-axis (90 * 0.5) 0° on the z-axis (90 * 0.0) [Please correct me if the above is wrong] So rotation is not happening by the specified amount on one axis, it is happening by the specified amount on each axis. Of course I agree. I am just trying to select a starting point for learning the basics of the relevant mathematics.
  11. calioranged

    Learning About Rotation

    Not really sure what you mean by 'front' and 'right' vector (the front of what vector..? the right of what vector..?). From my understanding, the view matrix (matrix produced by glm::lookAt()) is composed of the 3D vectors; position, view direction and orientation. In the example there it is the cross product of the view direction and orientation that is used as a scalar for camera rotation. I just cannot grasp the concept of this. I probably need to gain a more fundamental understanding of the mathematics behind this because when I listen to people explain the concepts it just goes straight over my head to be honest. I have found that whenever I start reading an article or watching a video which explains a particular concept, they assume a base level of understanding about certain related concepts which I don't really have. For example in the introduction of http://immersivemath.com/ila/index.html (section 1.1) there are already notational conventions that I am having to look elsewhere for explanations of. In section 1.2 trigonometry is discussed where the authors assume that the reader already understands the basics. Because of this I then have to research the related concepts where prior knowledge was assumed by the tutorial, and then I end up down a rabbit hole further and further away from the actual subject I want to learn about. This may all be necessary but finding a starting point for learning about these concepts from my experience is rather difficult.
  12. calioranged

    Learning About Rotation

    The idea of rotating by x amount of radians/degrees around a given axis is easy enough to grasp, but my understanding completely breaks down when the scalar values for rotation are not 1.0F or 0.0F. See here regarding a topic I posted on Stack Overflow: https://stackoverflow.com/questions/56313743/cross-product-confusion Thanks for the resources you have provided.
  13. It is quickly dawning upon me that understanding how rotations work in OpenGL is a rather different beast to anything that I have encountered before. The mathematics involved is complex and has easily overwhelmed me as a beginner. Where does one start from when trying to gain an understanding of the mathematics that goes into rotation calculations? There are lots of resources online for beginners to learn about rotation from, but they all assume a base level of understanding which I certainly do not posses at this point. Where should the starting point be for someone like me who only has an average understanding of secondary/high school mathematics?
  14. calioranged

    GLFW Callbacks From Inside Class/Struct

    What is the 'Display' class you are using?
  15. calioranged

    GLFW Callbacks From Inside Class/Struct

    My GLFW is totally messed up. I will try that if I am able to restore it back to its previous state.
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!