Jump to content
  • Advertisement

TheStudent111

Member
  • Content Count

    90
  • Joined

  • Last visited

Community Reputation

645 Good

About TheStudent111

  • Rank
    Member

Personal Information

  • Interests
    Art
    Programming

Recent Profile Visitors

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

  1. TheStudent111

    Does each vector have its own basis vector?

    alvaro, I thought affine spaces lack an origin. The OpenGL graphics API has an origin in NDC and screen coordinates.
  2. TheStudent111

    Does each vector have its own basis vector?

    So in regards to a cube in model space, each of the vertices are part of a set in a span? Is it accurate to say 3D model space is a subspace of 3D world space?
  3. Does each vector in a given vector space have its own basis vector. Are basis vectors essentially just the components of a given vector? Do all vertices in model space (subspace) have a basis vector?
  4. I'm curious as to how one calculates position coordinates for the terrain; specifically the height coordinates. My understanding of Terrain generation with height maps is iterating through the heightmap and retrieving pixel data. The pixel data, depending on its greyscale color (white or black), will determine its height. However, I'm unsure of the practical implementation of this, specifically the equation used to convert pixel data to new height coordinates. In addition to the Y coordinates, how do I determine the values in the X and Z plane. Do I just pick a range of values (ex. [-30, 30]) in X and Z? Lastly, I'm sure indices will have to be used in order to make an efficient program. My prior experience with Index is manually entering values for simple geometric shapes (Cubes and triangles). This seems more involved than before. I was wondering if there exists an algorithm that handles indices when dealing with terrain.
  5. TheStudent111

    How many VAO can OpenGL bind at the same time?

    Thanks TheChubu, Though I have to ask how is there no flickering occurring. Wouldn't the second drawing, bindVAO2 // Cube draw overrwrite what was there before. Does glDrawArray maintain state from previous renderings?
  6. How many VAOs are allowed to be bound to OpenGL at one time. I'm asking this because I recently saw code that looked like the following while(running){ bindVAO1 // Cube with lighting draw bindVAO2 // Cube draw } When I ran the program, both rendered without problems. My previous understanding was that OpenGL was restricted to one VAO at a time (Being a state machine). I originally expected to be some flickering between the two VAOs, as glDrawArray wouldn't have the other VAO binding to it for drawing. So how many VAO does OpenGL allow? Does glDrawArray keep track of previous renderings of objects?
  7. While reading someone else code, I noticed that they were using hexadecimal numbers instead of regular base 10. What is the added benefit of using hexadecimal in code (or even binary for that matter).   For example:   enum Behavior {     Flee     = 0x00001,     Seek     = 0x00002,     Wander = 0x00003   }  
  8. TheStudent111

    Clarification on how OpenGL draws entities

    So as long as the number of glDrawArray commands match the number of VAO, OpenGL will know internally which VAO you are referring to and draw to the display?   So I do not need to glBindVertexArray every frame?
  9. Not exactly sure how OpenGL draws individual geometric meshes with glDrawArray and glDrawElement. When you call glDrawArray, how exactly does OpenGL know which geometric mesh you are referring to? I used to think it was through VAO, but now I'm not sure.    As shown in the attached image, I have two cubes, one acting as a lamp and another acting like a regular entity in a scene. I'm hazy as to how one draws each individual entity, I know the programmer would have to write the glDrawArray command, but does OpenGL know which one I'm referring to.   Initialization:     GLfloat vertices[] = {         -0.5f, -0.5f, -0.5f,  0.0f,  0.0f, -1.0f,          0.5f, -0.5f, -0.5f,  0.0f,  0.0f, -1.0f,          0.5f,  0.5f, -0.5f,  0.0f,  0.0f, -1.0f,          0.5f,  0.5f, -0.5f,  0.0f,  0.0f, -1.0f,         -0.5f,  0.5f, -0.5f,  0.0f,  0.0f, -1.0f,         -0.5f, -0.5f, -0.5f,  0.0f,  0.0f, -1.0f,         -0.5f, -0.5f,  0.5f,  0.0f,  0.0f,  1.0f,          0.5f, -0.5f,  0.5f,  0.0f,  0.0f,  1.0f,          0.5f,  0.5f,  0.5f,  0.0f,  0.0f,  1.0f,          0.5f,  0.5f,  0.5f,  0.0f,  0.0f,  1.0f,         -0.5f,  0.5f,  0.5f,  0.0f,  0.0f,  1.0f,         -0.5f, -0.5f,  0.5f,  0.0f,  0.0f,  1.0f,         -0.5f,  0.5f,  0.5f, -1.0f,  0.0f,  0.0f,         -0.5f,  0.5f, -0.5f, -1.0f,  0.0f,  0.0f,         -0.5f, -0.5f, -0.5f, -1.0f,  0.0f,  0.0f,         -0.5f, -0.5f, -0.5f, -1.0f,  0.0f,  0.0f,         -0.5f, -0.5f,  0.5f, -1.0f,  0.0f,  0.0f,         -0.5f,  0.5f,  0.5f, -1.0f,  0.0f,  0.0f,          0.5f,  0.5f,  0.5f,  1.0f,  0.0f,  0.0f,          0.5f,  0.5f, -0.5f,  1.0f,  0.0f,  0.0f,          0.5f, -0.5f, -0.5f,  1.0f,  0.0f,  0.0f,          0.5f, -0.5f, -0.5f,  1.0f,  0.0f,  0.0f,          0.5f, -0.5f,  0.5f,  1.0f,  0.0f,  0.0f,          0.5f,  0.5f,  0.5f,  1.0f,  0.0f,  0.0f,         -0.5f, -0.5f, -0.5f,  0.0f, -1.0f,  0.0f,          0.5f, -0.5f, -0.5f,  0.0f, -1.0f,  0.0f,          0.5f, -0.5f,  0.5f,  0.0f, -1.0f,  0.0f,          0.5f, -0.5f,  0.5f,  0.0f, -1.0f,  0.0f,         -0.5f, -0.5f,  0.5f,  0.0f, -1.0f,  0.0f,         -0.5f, -0.5f, -0.5f,  0.0f, -1.0f,  0.0f,         -0.5f,  0.5f, -0.5f,  0.0f,  1.0f,  0.0f,          0.5f,  0.5f, -0.5f,  0.0f,  1.0f,  0.0f,          0.5f,  0.5f,  0.5f,  0.0f,  1.0f,  0.0f,          0.5f,  0.5f,  0.5f,  0.0f,  1.0f,  0.0f,         -0.5f,  0.5f,  0.5f,  0.0f,  1.0f,  0.0f,         -0.5f,  0.5f, -0.5f,  0.0f,  1.0f,  0.0f     };     GLuint VBO1, containerVAO;     glGenVertexArrays(1, &containerVAO);     glGenBuffers(1, &VBO1);     glBindBuffer(GL_ARRAY_BUFFER, VBO1);     glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);    glBindVertexArray(containerVAO);     // Position attribute     glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 6 * sizeof(GLfloat), (GLvoid*)0);     glEnableVertexAttribArray(0);     // Normal attribute     glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 6 * sizeof(GLfloat), (GLvoid*)(3 * sizeof(GLfloat)));     glEnableVertexAttribArray(1);     GLuint VBO2;     GLuint lampVAO;     glGenVertexArrays(1, &lampVAO);    glBindVertexArray(lampVAO);         glGenBuffers(1, &VBO2);         glBindBuffer(GL_ARRAY_BUFFER, VBO2);         glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);     glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 6 * sizeof(GLfloat), (GLvoid*)0);     glEnableVertexAttribArray(0);   Loop:         glClearColor(0.1f, 0.1f, 0.1f, 1.0f);         glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);         lightingShader.Use();         GLint objectColorLoc = glGetUniformLocation(lightingShader.Program, "objectColor");         GLint lightColorLoc  = glGetUniformLocation(lightingShader.Program, "lightColor");         GLint lightPosLoc    = glGetUniformLocation(lightingShader.Program, "lightPos");         GLint viewPosLoc     = glGetUniformLocation(lightingShader.Program, "viewPos");         glUniform3f(objectColorLoc, 1.0f, 0.5f, 0.31f);         glUniform3f(lightColorLoc,  1.0f, 1.0f, 1.0f);         glUniform3f(lightPosLoc,    lightPos.x, lightPos.y, lightPos.z);         glUniform3f(viewPosLoc,     camera.Position.x, camera.Position.y, camera.Position.z);            glm::mat4 view;         view = camera.GetViewMatrix();         glm::mat4 projection = glm::perspective(camera.Zoom, (GLfloat)WIDTH / (GLfloat)HEIGHT, 0.1f, 100.0f);         GLint modelLoc = glGetUniformLocation(lightingShader.Program, "model");         GLint viewLoc  = glGetUniformLocation(lightingShader.Program, "view");         GLint projLoc  = glGetUniformLocation(lightingShader.Program, "projection");         glUniformMatrix4fv(viewLoc, 1, GL_FALSE, glm::value_ptr(view));         glUniformMatrix4fv(projLoc, 1, GL_FALSE, glm::value_ptr(projection));        glBindVertexArray(containerVAO);         glm::mat4 model;         glUniformMatrix4fv(modelLoc, 1, GL_FALSE, glm::value_ptr(model));         glDrawArrays(GL_TRIANGLES, 0, 36);         lampShader.Use();         modelLoc = glGetUniformLocation(lampShader.Program, "model");         viewLoc  = glGetUniformLocation(lampShader.Program, "view");         projLoc  = glGetUniformLocation(lampShader.Program, "projection");         // Set matrices         glUniformMatrix4fv(viewLoc, 1, GL_FALSE, glm::value_ptr(view));         glUniformMatrix4fv(projLoc, 1, GL_FALSE, glm::value_ptr(projection));         model = glm::mat4();         model = glm::translate(model, lightPos);         model = glm::scale(model, glm::vec3(1.0f));         glUniformMatrix4fv(modelLoc, 1, GL_FALSE, glm::value_ptr(model));         glBindVertexArray(lampVAO);         glDrawArrays(GL_TRIANGLES, 0, 36);     Vertex Shader (Regular Entity): #version 330 core layout (location = 0) in vec3 position; layout (location = 1) in vec3 normal; out vec3 Normal; out vec3 FragPos; uniform mat4 model; uniform mat4 view; uniform mat4 projection; void main() {     gl_Position = projection * view *  model * vec4(position, 1.0f);     FragPos = vec3(model * vec4(position, 1.0f));     Normal = mat3(transpose(inverse(model))) * normal;   } Fragment Shader (Regular Entity) #version 330 core out vec4 color; in vec3 FragPos;   in vec3 Normal;     uniform vec3 lightPos; uniform vec3 viewPos; uniform vec3 lightColor; uniform vec3 objectColor; void main() {     // Ambient     float ambientStrength = 0.1f;     vec3 ambient = ambientStrength * lightColor;            // Diffuse     vec3 norm = normalize(Normal);     vec3 lightDir = normalize(lightPos - FragPos);     float diff = max(dot(norm, lightDir), 0.0);     vec3 diffuse = diff * lightColor;          // Specular     float specularStrength = 0.5f;     vec3 viewDir = normalize(viewPos - FragPos);     vec3 reflectDir = reflect(-lightDir, norm);       float spec = pow(max(dot(viewDir, reflectDir), 0.0), 32);     vec3 specular = specularStrength * spec * lightColor;                vec3 result = (ambient + diffuse + specular) * objectColor;     color = vec4(result, 1.0f); } Vertex Shader (Lamp): #version 330 core layout (location = 0) in vec3 position; uniform mat4 model; uniform mat4 view; uniform mat4 projection; void main() {     gl_Position = projection * view * model * vec4(position, 1.0f); } Fragment Shader (Lamp): #version 330 core out vec4 color; void main() {     color = vec4(1.0f); }   I used to think it was   Loop: glbindVertexArray(lampVAO);        // <-- where glDrawArray would draw VAO that was last bound? glDrawArray(GL_TRIANGLES, 0, 36); But then I started tinkering with the above code and commented out both glbindVertexArray commands (lamp and regular entity) in loop and commented out the lamp vertex array during initialization in order to remove it from the scene.         //   glBindVertexArray(containerVAO);         glm::mat4 model;         glUniformMatrix4fv(modelLoc, 1, GL_FALSE, glm::value_ptr(model));        glDrawArrays(GL_TRIANGLES, 0, 36);         lampShader.Use();         modelLoc = glGetUniformLocation(lampShader.Program, "model");         viewLoc  = glGetUniformLocation(lampShader.Program, "view");         projLoc  = glGetUniformLocation(lampShader.Program, "projection");         // Set matrices         glUniformMatrix4fv(viewLoc, 1, GL_FALSE, glm::value_ptr(view));         glUniformMatrix4fv(projLoc, 1, GL_FALSE, glm::value_ptr(projection));         model = glm::mat4();         model = glm::translate(model, lightPos);         model = glm::scale(model, glm::vec3(1.0f));         glUniformMatrix4fv(modelLoc, 1, GL_FALSE, glm::value_ptr(model));      //   glBindVertexArray(lampVAO);         glDrawArrays(GL_TRIANGLES, 0, 36); However, both cubes still rendered.     In a nutshell, I'm trying to understand the OpenGL equivalent of the following SFML code sf::RenderWindow Window(); sf::RectangleShape rect;   while(Window.isOpen()){   Window.draw(rect); // <-- SFML knows to draw the rect entity to the display due to this command. }   Note: I understand OpenGL does not have Window.draw(rect); The above code has wrapped around the OpenGL commands. Looking for the GL equivalent of draw this entity.  
  10. TheStudent111

    Difference between Light casters and Lighting models

    So are phong, gourang, global illumination the only major lighting models available (Or used by triple AAA titles).  I've tried googling and these are the only ones that a the most common. If you could compile a list or link me to the right destination that would be appreciated.
  11. I'm confused has to what the difference between light casters (point, spotlight, directional) and lighting models (phong, gourang, global illumination). From what I understand both emit light in a scene. When would I choice spotlight over phong lighting. Whats the defining differences between the two concepts (light casters and lighting models)?.      
  12. So by default OpenGL uses rasterization to render objects. So I'm guessing the rasterization algorithm is written in a lower level language by GPU manufactures. So when I write a ray tracer, and run it, does the GPU process the ray tracing algorithm and override the rasterization algorithm?
  13. How have I been able to render images with OpenGL without using the ray tracing method. I've been able to render cubes and cubes with lighting without using the ray tracing implementation.What cases is ray tracing used that would make it apparent? From my understanding ray tracing is a rendering method for generating computer generated images on the image plane. It is used to generate illumination on the object based on whether or not the light ray has intersected with the object.   Apparently ray tracing is not the only rendering algorithm out there as there are different alternatives. What is meant by "rendering algorithm" is my point? Doesn't OpenGL and Direct3D allow the programmer to render objects without needing to use a rendering algorithm to render objects on screen.
  14. TheStudent111

    OpenGL why unbind VAO

    While reading other peoples code I'm confused as to why a programmer will have to unbind VAO before the game loop, then having to bind and unbinding the VAO repeatedly every frame. Whats the point in doing this?   For example, basic lighting for a scene: GLuint lightVAO; glGenVertexArrays(1, &lightVAO); glBindVertexArray(lightVAO); glBindBuffer(GL_ARRAY_BUFFER, VBO); glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 6 * sizeof(GLfloat), (GLvoid*)0); glEnableVertexAttribArray(0); glBindVertexArray(0);   GAME LOOP: glBindVertexArray(lightVAO); glDrawArrays(GL_TRIANGLES, 0, 36); glBindVertexArray(0);
  15. Does OpenGL use active or passive transformations. I saw a video that said GLM::lookat used passive transformation were the camera moves the world, not the objects in themselves.
  • 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!