• Advertisement
Sign in to follow this  

OpenGL 10 Beginner's Questions...

This topic is 3001 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Here are 10 basic questions...some are very simple and I could probably find the answers through Google, but I don't have time for this, so I'm asking here. Your help will be highly appreciated, as my project cannot proceed (it already proceeds very slowly) without the answers. 1. http://www.opengl.org/wiki/Tutorial:_OpenGL_3.0_Context_Creation_(GLX) I don't understand something. Before glXGetProcAddress() is called, a dummy context is created, but it is not made current. I thought there has to be a valid current context. Is it a mistake or glXProcAddress() only needs an existing context even if it's not current? And what about WGL? wglgetProcAddress() can be called only after an RC is made current right? Another question: the OpenGL wiki says an RC cannot be recreated for a window, so after destroying the dummy RC I also need to recreate the window. But somewhere else I read a tutorial that doesn't delete the window. So I'm not sure...does the one-wglCreateContext()-per-window exist? 2. What are the definitions of Bool, True, False, XID and None in Xlib? 3. ATI suggests each element in a VBO starts on a 32 byte boundary. Does it mean the offset between the VBO's beginning and the element's beninning should be 32*n or that I can have an element start at offset 7 as long as it's 32 bytes long? (my program uses 16 bytes per element, so I'll probably interleave elements to avoid watsing 16B padding for every 16B vertex. The question is whether I should place more frequently used vertices as even-numbered elements so that they get the boost) 4. When passing data to and from the GPU (vertex arrays, draw pixels, texture image or anything else), at lease in 32-bit systems, the data should be 4Byte-aligned. On 64-bit systems, should the alignment be to 8 bytes instead? In all cases? Do GPUs work in 64-bit mode like CPUs? 5. What happens if I try to read a uint variable using glGetIntegerv()? Is it simply copied into a RAM uint variable? And what if I read an int64 variable? 6. There is a large set of images. An image is drawn as a texture object, using four (vertex, texcoord) pairs. They are written into a VBO. If they are not written as an array but at "random" offsets, which method is faster/recommended: A. Save the four indices in an IBO and draw with glDrawRangeElements B. Save the indices as a ushort array and draw with glDrawRangeElementsIn the first case I need to send the GPU an offset (64-bit integer) while in the second case I send 4 ushort variables (each 16-bit, in total 64 bits). The array length (4) is sent in both cases, so in total the same amount of data is sent. So I'd like to know which method you'd suggest/use... 7. http://www.opengl.org/wiki/Common_Mistakes#Misaligned_vertex_formats Is the VA 4-byte alignment remain 4-byte 64-bit OpenGL? And is the alignment needed in VBO too? 8. Why do I see the parallel axis theorem in all collison detection tutorials? I can't see why it's better/faster than checking for every side of polygon A whether is collides with any side of polygon B. It also works for concave polygons, while the PAT only works for convex ones. If everybody uses PAT I'm probably missing something... 9. Why is dithering enables by default? If I assume the user has a modern video card which support 32-bit colors, is it a good idea to turn off dithering? 10. I read somewhere about texture internal format GL_RGBA being faster than GL_RGB because of memory alignment issues. Is it true for new GPUs (OpenGL 2.1 and above)? Which option will have better performance, a GL_RGB texture or a GL_RGBA texture with all A values equal to 1.0 ?

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by Tom Backton
some are very simple and I could probably find the answers through Google, but I don't have time for this, so I'm asking here.

Wow.

Share this post


Link to post
Share on other sites
Yup, those are ten basic questions. Some are very simple, and I could probably type out the answers without research. But I don't have time for this, so I'm going to close this thread.

You're welcome to repost your questions, after you've done a bit of cursory research yourself (i.e., what have you tried?). Show us some respect for our persons and our time, and we'll show you the same.

Share this post


Link to post
Share on other sites

This topic is 3001 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Guest
This topic is now closed to further replies.
Sign in to follow this  

  • Advertisement
  • Advertisement
  • Popular Tags

  • Advertisement
  • Popular Now

  • Similar Content

    • By LifeArtist
      Good Evening,
      I want to make a 2D game which involves displaying some debug information. Especially for collision, enemy sights and so on ...
      First of I was thinking about all those shapes which I need will need for debugging purposes: circles, rectangles, lines, polygons.
      I am really stucked right now because of the fundamental question:
      Where do I store my vertices positions for each line (object)? Currently I am not using a model matrix because I am using orthographic projection and set the final position within the VBO. That means that if I add a new line I would have to expand the "points" array and re-upload (recall glBufferData) it every time. The other method would be to use a model matrix and a fixed vbo for a line but it would be also messy to exactly create a line from (0,0) to (100,20) calculating the rotation and scale to make it fit.
      If I proceed with option 1 "updating the array each frame" I was thinking of having 4 draw calls every frame for the lines vao, polygons vao and so on. 
      In addition to that I am planning to use some sort of ECS based architecture. So the other question would be:
      Should I treat those debug objects as entities/components?
      For me it would make sense to treat them as entities but that's creates a new issue with the previous array approach because it would have for example a transform and render component. A special render component for debug objects (no texture etc) ... For me the transform component is also just a matrix but how would I then define a line?
      Treating them as components would'nt be a good idea in my eyes because then I would always need an entity. Well entity is just an id !? So maybe its a component?
      Regards,
      LifeArtist
    • By QQemka
      Hello. I am coding a small thingy in my spare time. All i want to achieve is to load a heightmap (as the lowest possible walking terrain), some static meshes (elements of the environment) and a dynamic character (meaning i can move, collide with heightmap/static meshes and hold a varying item in a hand ). Got a bunch of questions, or rather problems i can't find solution to myself. Nearly all are deal with graphics/gpu, not the coding part. My c++ is on high enough level.
      Let's go:
      Heightmap - i obviously want it to be textured, size is hardcoded to 256x256 squares. I can't have one huge texture stretched over entire terrain cause every pixel would be enormous. Thats why i decided to use 2 specified textures. First will be a tileset consisting of 16 square tiles (u v range from 0 to 0.25 for first tile and so on) and second a 256x256 buffer with 0-15 value representing index of the tile from tileset for every heigtmap square. Problem is, how do i blend the edges nicely and make some computationally cheap changes so its not obvious there are only 16 tiles? Is it possible to generate such terrain with some existing program?
      Collisions - i want to use bounding sphere and aabb. But should i store them for a model or entity instance? Meaning i have 20 same trees spawned using the same tree model, but every entity got its own transformation (position, scale etc). Storing collision component per instance grats faster access + is precalculated and transformed (takes additional memory, but who cares?), so i stick with this, right? What should i do if object is dynamically rotated? The aabb is no longer aligned and calculating per vertex min/max everytime object rotates/scales is pretty expensive, right?
      Drawing aabb - problem similar to above (storing aabb data per instance or model). This time in my opinion per model is enough since every instance also does not have own vertex buffer but uses the shared one (so 20 trees share reference to one tree model). So rendering aabb is about taking the model's aabb, transforming with instance matrix and voila. What about aabb vertex buffer (this is more of a cosmetic question, just curious, bumped onto it in time of writing this). Is it better to make it as 8 points and index buffer (12 lines), or only 2 vertices with min/max x/y/z and having the shaders dynamically generate 6 other vertices and draw the box? Or maybe there should be just ONE 1x1x1 cube box template moved/scaled per entity?
      What if one model got a diffuse texture and a normal map, and other has only diffuse? Should i pass some bool flag to shader with that info, or just assume that my game supports only diffuse maps without fancy stuff?
      There were several more but i forgot/solved them at time of writing
      Thanks in advance
    • By RenanRR
      Hi All,
      I'm reading the tutorials from learnOpengl site (nice site) and I'm having a question on the camera (https://learnopengl.com/Getting-started/Camera).
      I always saw the camera being manipulated with the lookat, but in tutorial I saw the camera being changed through the MVP arrays, which do not seem to be camera, but rather the scene that changes:
      Vertex Shader:
      #version 330 core layout (location = 0) in vec3 aPos; layout (location = 1) in vec2 aTexCoord; out vec2 TexCoord; uniform mat4 model; uniform mat4 view; uniform mat4 projection; void main() { gl_Position = projection * view * model * vec4(aPos, 1.0f); TexCoord = vec2(aTexCoord.x, aTexCoord.y); } then, the matrix manipulated:
      ..... glm::mat4 projection = glm::perspective(glm::radians(fov), (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f); ourShader.setMat4("projection", projection); .... glm::mat4 view = glm::lookAt(cameraPos, cameraPos + cameraFront, cameraUp); ourShader.setMat4("view", view); .... model = glm::rotate(model, glm::radians(angle), glm::vec3(1.0f, 0.3f, 0.5f)); ourShader.setMat4("model", model);  
      So, some doubts:
      - Why use it like that?
      - Is it okay to manipulate the camera that way?
      -in this way, are not the vertex's positions that changes instead of the camera?
      - I need to pass MVP to all shaders of object in my scenes ?
       
      What it seems, is that the camera stands still and the scenery that changes...
      it's right?
       
       
      Thank you
       
    • By dpadam450
      Sampling a floating point texture where the alpha channel holds 4-bytes of packed data into the float. I don't know how to cast the raw memory to treat it as an integer so I can perform bit-shifting operations.

      int rgbValue = int(textureSample.w);//4 bytes of data packed as color
      // algorithm might not be correct and endianness might need switching.
      vec3 extractedData = vec3(  rgbValue & 0xFF000000,  (rgbValue << 8) & 0xFF000000, (rgbValue << 16) & 0xFF000000);
      extractedData /= 255.0f;
    • By Devashish Khandelwal
      While writing a simple renderer using OpenGL, I faced an issue with the glGetUniformLocation function. For some reason, the location is coming to be -1.
      Anyone has any idea .. what should I do?
  • Advertisement