Questions tagged [opengl]

OpenGL is a graphics standard and API which targets the desktop and workstation markets. It is designed to be easy to accelerate with dedicated computer hardware, and hence most implementations give greatly improved performance over traditional software rendering. Currently, OpenGL is used for applications like CAD software and computer games. It is also cross-platform. The OpenGL standard is controlled by the Khronos group, which also controls OpenGL ES.

Filter by
Sorted by
Tagged with
0 votes
1 answer
52 views

Strange flashing cube bug in snake game

I'm trying to make a simple snake game in C and OpenGL, and I have this at the moment, which runs almost perfectly: ...
  • 103
0 votes
0 answers
26 views

How I can compute normals vectors for a tessellated terrain?

I would like compute normals vectors for a tessellated terrain generated procedurally, in order to use them for a basic lighting. I don't know how I could do it. I can do it in the Tessellation ...
0 votes
1 answer
45 views

Graphical issue when using a depth pre-pass

I have implemented the Z pre-pass technique into my engine, leading to a 2x performance improvement in a test scene. However, the technique darkens the objects (but not the skybox), introduces z-...
  • 15
0 votes
1 answer
30 views

glm::eulerAngles gives unexpected output for quaternion

I used the euler->mat4->quat to give the right result, but euler->quat gives the wrong result - is there something I did wrong? ...
0 votes
1 answer
39 views

How to execute early depth test

I have trouble applying early depth test in my engine, to prevent fragment shader to be (fully) executed for fragments that will be overwritten anyway, because other fragments, drawn later, will be in ...
  • 15
1 vote
0 answers
68 views

Are there OpenGL functions that are only available for specific platforms?

I want to load the OpenGL functions for my project myself. Are there any specific functions besides wglGetSwapIntervalEXT that require me to query the spec for its availability? And if there are, ...
0 votes
2 answers
105 views

How to procedurally compose shaders? [closed]

I read several times that shaders can be composed by the engine on the fly, depending on graphical settings. How is this generally done?
  • 15
1 vote
1 answer
24 views

glPatchParameteri(GL_PATCH_VERTICES, 4) causes access violation

I'm trying to create a tessellated terrain, for this purposes I'm following the LearnOpenGL tutorial: https://learnopengl.com/Guest-Articles/2021/Tessellation/Tessellation However, when I set the ...
0 votes
1 answer
50 views

What is the advantage of using Element Buffer Objects, if any?

I'm following the amazing LearnOpenGL tutorials and noticed that Element Buffer Objects, which were mentioned and used in the Hello Triangle chapter, never appear again. So my question is, is using ...
0 votes
1 answer
45 views

ObjFile not properly loading

i am losing my mind. I am trying to create an obj parser has a way to learn opengl but i have ran into a brick wall. with DMGregory help i got the textures to work i think but know the mesh just looks ...
-1 votes
0 answers
150 views

Patch of sphere doesn't render

I successfully converted an octahedron into a sphere, however, only around 80% of the sphere was drawn and I don't know how to fix it. This is the tutorial where I adapted the code from for reference ...
  • 43
0 votes
0 answers
51 views

How can I draw split-screen in OpenGL?

My teacher wants me to compare 2 algorithms. I need to divide my window in half for displaying the code for each version (left for the first and right for the second algorithm). Does ...
  • 1
1 vote
1 answer
267 views

How to subdivide an octahedron into a sphere?

For a game I'm making, I have to tessellate an octahedron into a sphere on the GPU (shaders). What I've done is I've successfully tessellated the faces, but I'm having trouble subdividing more spaces, ...
  • 43
0 votes
0 answers
65 views

How I can compute normals in a tesellated terrain?

I'm trying to generate a terrain using tessellation. I tesselate patches, so the amount of data passed to the GPU is 4 * numberOfPatch * numberOfPatch. My problem ...
1 vote
0 answers
67 views

How to render a block being carved by a milling machine?

I'm making a simulation of a milling machine - something a bit like this diagram: At the top there is a cylinder mesh representing the milling tool. Below it is a cube mesh representing the material ...
0 votes
1 answer
31 views

Tessellation shaders not working, no objects drawing on screen

Using this tutorial https://learnopengl.com/Guest-Articles/2021/Tessellation/Tessellation and this tutorial https://www.youtube.com/watch?v=21gfE-zUym8 I implemented tessellation shaders that I haven'...
  • 43
0 votes
0 answers
37 views

Can we place a middleman on whatever functions are returned by WGL, EGL, or CGL?

I find myself wondering whether our PC games from the 2000s will continue to operate without a VM. To the present, GPU manufacturers have generously kept pre-3.2 OpenGL in their drivers. I'm amazed ...
0 votes
1 answer
67 views

How to create an octahedron for sphere subdivision?

I have vertices that generate the first out of two pyramids. However, I want to have the second pyramid facing downwards as to make an octahedron. What are the correct vertices to use, because I've ...
  • 43
0 votes
1 answer
45 views

Help understanding the math to position sphere vertices by latitude and longitude

For a project of mine, I need to render spheres without loading a pre-made model or using built-in functions. I found this bit of code on the internet that seems to work but I really want to ...
  • 43
1 vote
1 answer
124 views

Implementing a Maya-like orbit camera in Vulkan/OpenGL

I want to create an orbit camera with zooming, panning, and rotation. I used the following examples to create cameras: https://stackoverflow.com/questions/54400422/how-to-implement-altmmb-camera-...
1 vote
1 answer
129 views

No vertex shader bound at draw?

I tried asking this on reddit but I didn't get any answers so I might as well try here So I'm making a program to generate some terrain and it's not giving me the results I expected. It's drawing ...
  • 43
0 votes
1 answer
102 views

How to safely store opengl vertices in a c++ struct

Instead of using a vector of floats, i want to use a struct, so that it can store different types and is easier. ...
  • 73
0 votes
0 answers
41 views

OpenGL rendering a specific color attachment to the screen

Current fragment shader: layout(location=0) out vec4 output_0; layout(location=1) out vec4 output_1; Here I want to render the output_1 to the screen instead of ...
1 vote
1 answer
84 views

Alpha blending only working on 5 of 6 sides on a cube

I'm rendering a cube with a texture mapped to all sides of it and somehow the alpha channel from the texture isn't being applied on one side of the cube. all other sides are rendered properly (...
3 votes
1 answer
214 views

How do I implement HP bar using OpenGL?

I got simple hp bar container from open game art, rendered the texture and now I am wondering how to fill it and change the amount of filling. I decided to render red rectangle over the container and ...
  • 137
0 votes
0 answers
58 views

Screen Space Reflections bug in OpenGL

I tried to implement screen space reflections in my OpenGL project using a raytracing algorithm. But something is wrong in it. Here's a video of the visual results so far. As you see, when I try to ...
0 votes
0 answers
35 views

Can't load the textures when using Mac's .app format with stb_image & OpenGL

When I test the game, I run the game with $./main, it loads the textures and everything is fine. However, when I put the executable in MacOS's Apps folder and the ...
2 votes
1 answer
163 views

How to abstract VAO as a class in c++

I read the khronos docs on Vertex Array Objects, and it says that VAOs do not copy any data but refer to VBOs and EBOs/IBOs. So i created an abstraction class vbo which creates a vertex buffer from a ...
  • 73
0 votes
1 answer
60 views

How can I calculate the translation used for rotating an object with a quaternion in Unity, to use for OpenGL?

In Unity, whenever I rotate an object, it also performs a translation. If I simply try to draw a quad with the quaternion used in Unity, it appears off because of that missing translation unity ...
  • 5
0 votes
0 answers
25 views

Tessellation Shader is not correctly detecting the camera's position

I am working on developing a LOD for spherical objects in my game, but the tessellation shader is not correctly tessellating the sphere relative to the camera's position. The near faces of the sphere ...
0 votes
0 answers
62 views

How do I resize an OpenGL texture created using new DSA?

My texture class uses new function glTextureStorage2d() (which OpenGL recommends), but the problem here is that this function makes the texture size immutable, ...
  • 73
0 votes
0 answers
48 views

How can I correctly draw semi transparent textures in a VBO in C++/openGL

I am using C++ glew/glfw to make a game, and I currently have different areas of the map and different entity classes using their own VBO's. So far this decision has been informed from a large part of ...
1 vote
1 answer
84 views

Simple GLSL shader results in "1: '€' : unexpected token" compilation error

I have a very simple shader here: ...
  • 31
1 vote
0 answers
46 views

Garbled text and music - due to Steam Linux runtime change?

My team and I released our game on Steam last year for Windows, Mac, and Linux. The game is written in C++ and uses SDL2, including SDL2_image, SDL2_ttf, and OpenGL for graphics. Around the middle of ...
0 votes
0 answers
124 views

ImGui docking window flickers when dragged out

I'm having problems when every time my ImGui docking window is dragged out it starts to flicker and malfunctions. Is there any ways I can get rid of this problem? Thank you! ...
-1 votes
1 answer
113 views

Batch rendering model matrix to shader

I'm working on a batch renderer. I'm limited to using one shader per batch (one draw call for everything). I want to use a TBN matrix for my lighting. To calculate the TBN matrix for each object I ...
  • 101
0 votes
1 answer
163 views

How to implement collision detection using opengl and c++

I am trying to implement collision detection system in opengl and c++ and I have a few qustions about best directions. I will just explain my ideas. So, I have a cube and a sphere as a basic collision ...
0 votes
1 answer
38 views

How to apply shadows on an animated model

I have followed the learnopengl.com tutorial on skeletal animation, but it does not apply shadow on the animated model. Here is the vertex shader that is used to display the character. I suspect that <...
  • 15
0 votes
0 answers
58 views

What is a good way to optimize lighting while keeping it accurate?

I have a lighting shader that currently has two lighting calculation methods. I have a PBR based model and a regular lighting model. I understand that lighting is going to be taxing, but I am getting ...
0 votes
1 answer
96 views

OpenGL 4 tracers

We have implemented a glow map into our renderer. It basically uses a blur filter on the glow map pass. But, I cannot figure out how to do tracers in OpenGL. Someone suggested using a couple of ...
0 votes
1 answer
124 views

OpenGL 4 depth of field

I am implementing depth of field. My fragment shader has the following code in it: ...
0 votes
1 answer
88 views

OpenGL 4 hidden line removal

I'm having trouble with hidden line removal in OpenGL 4. I use a vertex/geometry/fragment shader to draw the lines. I call glDepthRange(0.01, 1.0); before I draw ...
0 votes
0 answers
62 views

Gaussian blur only blurs the interior of primitive?

I cannot work out why my blur shader based on this example affects only what's inside the illuminated sphere. Below is the loop I'm using to blur an HDR framebuffer 5 times horizontally and vertically ...
0 votes
0 answers
45 views

Skeletal Mesh with Assimp and OpenGL

I'm trying to animate a skeletal mesh using opengl and assimp and I'm having trouble understanding what transforms I need to apply for it to work. From what I understand, each vertices have bone ...
0 votes
0 answers
96 views

C++ Problem With Separating Axis Theorem When Using Rotations

I started writing small game that uses some collision detection. I have been able to implement a working SAT collision detection prototype, but I figured out that it stops working properly, when some ...
0 votes
1 answer
146 views

Is it a good idea to detect collisions in 2D game on different thread?

I am writing simple tiled map based game using LWJGL and Kotlin. I am testing out different collision detection algorithms and avoid using out of box solutions for personal reasons. I figured out that ...
  • 137
0 votes
1 answer
40 views

Yaw rotation not translating to Quaternion

I'm trying to implement the gimbal lock fix described in this question, but I end up getting weird behavior where when I rotate on the X axis (or try to at least) it rotates on both the X and Y axis ...
0 votes
0 answers
42 views

How to calculate angles after subsequent rotations?

I have a class that manipulates a model matrix in opengl: ...
0 votes
1 answer
98 views

Efficiently pass one uniform value per polygon or quad to the fragment shader in a single batched draw call in WebGL?

I want to render multiple colored quads, with one solid color per quad, using WebGL 2.0 and Javascript. However, this question is probably generalisable to other OpenGL implementations as well. The ...
  • 243
0 votes
0 answers
50 views

How to allow objects in a list to access the object that owns the list?

I'm trying to make a voxel game while learning about OpenGL. The world is made up of many chunks of voxels. Therefore there is a Chunk class, containing an array of ...

1
2 3 4 5
85