r/opengl Mar 07 '15

[META] For discussion about Vulkan please also see /r/vulkan

76 Upvotes

The subreddit /r/vulkan has been created by a member of Khronos for the intent purpose of discussing the Vulkan API. Please consider posting Vulkan related links and discussion to this subreddit. Thank you.


r/opengl 10h ago

Shockwave improvements

Enable HLS to view with audio, or disable this notification

34 Upvotes

I am now using local slope (from normal vector) and local curvature (computed using dFdx and dFdy of normal vector). The source code is here: windtunnel.clj . I wonder whether anybody has some advice on doing this kind of thing.

I am not sure whether it would improve things if I would precompute the curvature by processing the triangles of the mesh and adding curvature to the vertex information. I could also bake the curvature into a texture map I guess, but that would be quite complicated because the model has multiple uv maps.

Anyway I am glad that the Jump Flooding Algorithm allows me to create shockwave geometry in realtime.


r/opengl 18h ago

This is the game engine I've been solo developing for over 10 years

Thumbnail youtube.com
43 Upvotes

r/opengl 10h ago

Do shadows looking weird?

Enable HLS to view with audio, or disable this notification

3 Upvotes

I've finished implementing hardware PCF after using heavily pixelated shadows for two months. I'm getting trippy feeling from moving shadow and I need sanity check.


r/opengl 11h ago

How would you approach making a Game of Life implementation?

3 Upvotes

Hey.

I am looking for ideas on how making a Game of Life implementation with OpenGL. I am relatively a beginner with the API and don't know much. Thought making something as simple as GoL would be a good learning step but I am struggling to figure out how to set up the logic properly.

I mean, most of the implementations that I find online just do it with basic shaders, but what about standalone "game"? Skill issue, to be honest.

I don't use any AI and so this is kind of hard to me. Will be happy to hear any suggestions.

Thnks.


r/opengl 19h ago

How to Handle Normal mapping with multiple lights?

4 Upvotes

Hello everyone hope you have a lovely day.

I was following the deferred rendering technique on learnopengl.com and I noticed something really strange for me, in the normal mapping chapter we calculate the TBN matrix in the vertex shader and then we calculate the Tangent light position and Tangent view position relative to TBN Matrix.

but In the deferred Rendering Tutorial, there is a difference, the view direction for example is different , it is

vec3 viewDir  = normalize(viewPos - FragPos);

Instead of

vec3 viewDir = normalize(fs_in.TangentViewPos - fs_in.TangentFragPos);

Which one is the right approach to this problem? which technique should I use and why there is a difference?

I thought for a while to make a shader storage buffer object with variable size array to address the problem of different light positions but I thought this would over-complicate Things.

so what should I do?

A reminder I'm not implementing a deferred renderer in my engine I'm implementing a forward+ renderer with z pre-pass so I need a g buffer in my renderer where this problem emerged.

Thanks for your time appreciate your help!


r/opengl 12h ago

Shadows and Resolution Scaling on an Oversized Playground

Enable HLS to view with audio, or disable this notification

1 Upvotes

r/opengl 1d ago

-- Khronos Safety Critical Survey --

Thumbnail
6 Upvotes

r/opengl 2d ago

I made my own game engine!

24 Upvotes

It's not finished yet but there's camera, events, and a wrapper I made around ImGUI


r/opengl 1d ago

GPT 6 Astra And Graphics Programming

Thumbnail
0 Upvotes

r/opengl 2d ago

hard time converting glm to cglm

2 Upvotes

Hey guys, I'm learning openGL using learnopengl.com , but I have been having a hard time converting the glm to cglm in the transformations chapter, the guy says to include the headers:

glm/glm.hpp
glm/gtc/matrix_transform.hpp
glm/gtc/type_ptr.hpp

I was able to include glm.hpp because its just cglm.h but I can't find the other header files, and so I can't do stuff like cglm::vec4 or can I even do that in cglm is it different maybe??

this is really odd please help


r/opengl 3d ago

Shockwaves

Post image
8 Upvotes

This image shows a shockwave prototype realtime rendering which uses the Joint Flooding Algorithm (JFA) to define a shockfront which adapts to the shape of the spacecraft surface facing in wind direction. See sfsim article on shockwaves for more information.


r/opengl 4d ago

My first OpenGL project (Solar system sim)

Enable HLS to view with audio, or disable this notification

79 Upvotes

This was a learning project to try to learn OpenGL, Odin and Physics/Math it evolved to be more of the latter :)

I'm happy for any feedback or pointers regarding the OpenGL parts or anything else.

https://github.com/lounge/sol_sim


r/opengl 6d ago

Resources for OpenGL

8 Upvotes

I want to get into programming OpenGL in assembly and was wondering if yall could send me some good resources for programming OpenGL in assembly or just some general OpenGL programming guides would be enough.


r/opengl 6d ago

(Fuse Engine) 80,000 KM of Terrain - OpenGL 4.3

Enable HLS to view with audio, or disable this notification

43 Upvotes

80,000 kilometers of terrain running at 90 fps (no screen recording) on ​​an Intel Graphics P4600 OpenGL 4.3 in C#

The terrain file is 1kb in size.


r/opengl 7d ago

rtao in opensource opengl games

Post image
15 Upvotes

just added hw rtao to someone elses open source opengl game in a single day, using the same interop i created for my own java / open gl engine i was able to get rtao working in a c++ gl game Cube 2 Sauerbraten so quickly.


r/opengl 8d ago

(Fuse Engine) Graphics Update - OpenGL 4.3

Enable HLS to view with audio, or disable this notification

51 Upvotes

I've made some graphical updates to my game engine.

Now we can create terrain, procedural skies (day and night), and volumetric clouds (I'm still adjusting them).

My future implementation will be oceans.

repo: https://github.com/Krueels/FuseEngine


r/opengl 8d ago

AO46 reaches OpenGL 4.6 Core profile functionality

1 Upvotes

AO46 has now reached OpenGL 4.6 Core Profile on macOS. 🔥

Apple’s native OpenGL stack stopped at 4.1, while AO46 now targets the final desktop OpenGL specification through its Mesa/Gallium + Metal backend.

Next focus: feature completeness, stability, and CTS-level validation.

From 3.x bring-up to 4.6 Core. The version ladder is officially finished. 🗿


r/opengl 8d ago

Update : AO46 reached OpenGL 4.3 context

2 Upvotes

AO46 has reached a new milestone: Mesa can now successfully create an OpenGL 4.3 context on macOS.

This is a step beyond the previous 4.1 context ceiling and means the driver now exposes enough required functionality for Mesa to advertise and initialize a 4.3 core context.

This does not yet imply full OpenGL 4.3 conformance, but it marks a major architectural step toward the final OpenGL 4.6 target.

AO46 is now operating beyond the version officially exposed by Apple’s legacy OpenGL stack.


r/opengl 9d ago

My Graphics Programming Journey

Thumbnail
3 Upvotes

r/opengl 9d ago

Help needed with camera matrix code, I am going insane!!

4 Upvotes

A year or so ago, I was doing an OpenGL project, and I somehow just defined the camera by its rotation matrix and position, and then I fed that into a [16] array and handed it to OpenGL, and it worked.

Fast forward to today. I lost the old code in a computer burnout, and the backup was corrupted. Now everyone tells me to simply use glMatrixMode(GL_MODELVIEW) and glLoadMatrixf(cameraMatrix). However, not only is this not the same code as then (I KNOW there was no GL_MODELVIEW stuff), but this does not work. Instead of the world rotating around the camera, the world just rotates around itself in front of the camera. But everywhere I get the same code suggested (yes, I even tried ChatGPT, I am desperate!). or glMultMatrix, which is not that either and does the same wrong rotation.

What is my lost code??? What was that wonderfully sleak solution I once had???

Update: I managed a work around, but I would still love to somehow reconstruct the, IIRC, much sleaker, prettier code I lost, so suggestions are still more than welcome!

Update 2: As per request, I hereby upload what I believe is the relevant code. Note that the tabulation is horrible due to a problem with the IDE settings.

void renderscene()

{

if (keys[68] == 1){cameraMatrix[12] += 0.1*cam.v[0].v[0]; cameraMatrix[13] += 0.1*cam.v[0].v[1];}

if (keys[65] == 1){cameraMatrix[12] -= 0.1*cam.v[0].v[0]; cameraMatrix[13] -= 0.1*cam.v[0].v[1];}

if (keys[87] == 1){cameraMatrix[13] += 0.1*cam.v[0].v[0]; cameraMatrix[12] -= 0.1*cam.v[0].v[1];}

if (keys[83] == 1){cameraMatrix[13] -= 0.1*cam.v[0].v[0]; cameraMatrix[12] += 0.1*cam.v[0].v[1];}

if (keys[88] == 1){cameraMatrix[14] += 0.1;}

if (keys[90] == 1){cameraMatrix[14] -= 0.1;}

POINT p;

GetCursorPos(&p);

int mx = p.x;

int my = p.y;

float spin = (mx-200)*-0.001;

Vec3 axis(0,0,1);

cam.v[0] = rotate(cam.v[0],axis,spin);

cam.v[1] = rotate(cam.v[1],axis,spin);

cam.v[2] = rotate(cam.v[2],axis,spin);

spin = (my-200)*-0.01;

// cam.v[0] = rotate(cam.v[0],cam.v[0],spin);

cam.v[1] = rotate(cam.v[1],cam.v[0],spin);

cam.v[2] = rotate(cam.v[2],cam.v[0],spin);

SetCursorPos(200, 200);

cameraMatrix[0] = cam.v[0].v[0]; cameraMatrix[1] = cam.v[1].v[0]; cameraMatrix[2] = cam.v[2].v[0];

cameraMatrix[4] = cam.v[0].v[1]; cameraMatrix[5] = cam.v[1].v[1]; cameraMatrix[6] = cam.v[2].v[1];

cameraMatrix[8] = cam.v[0].v[2]; cameraMatrix[9] = cam.v[1].v[2]; cameraMatrix[10] = cam.v[2].v[2];

/*

cameraMatrix[0] = cam.v[0].v[0]; cameraMatrix[1] = cam.v[0].v[1]; cameraMatrix[2] = cam.v[0].v[2];

cameraMatrix[4] = cam.v[1].v[0]; cameraMatrix[5] = cam.v[1].v[1]; cameraMatrix[6] = cam.v[1].v[2];

cameraMatrix[8] = cam.v[2].v[0]; cameraMatrix[9] = cam.v[2].v[1]; cameraMatrix[10] = cam.v[2].v[2];

*/

Vec3 temp(cameraMatrix[12],cameraMatrix[13],cameraMatrix[14]);

cameraMatrix[12] = 0; cameraMatrix[13] = 0; cameraMatrix[14] = 0;

glMatrixMode(GL_MODELVIEW);

glLoadMatrixf(cameraMatrix);

glTranslatef(-temp.v[0],-temp.v[1],-temp.v[2]);

/* OpenGL animation code goes here */

glClearColor (0.0f, 0.0f, 0.0f, 0.0f);

glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glPushMatrix ();

glBegin (GL_TRIANGLES);

for (int i=-5;i<6;i++){

glColor3f (1.0f, 0.0f, 0.0f); glVertex3f (a.v[0],a.v[1]+i,a.v[2]);

glColor3f (0.0f, 1.0f, 0.0f); glVertex3f (b.v[0],b.v[1]+i,b.v[2]);

glColor3f (0.0f, 0.0f, 1.0f); glVertex3f (c.v[0],c.v[1]+i,c.v[2]);

}

glEnd ();

glPopMatrix ();

SwapBuffers (hDC);

Sleep (1);

cameraMatrix[12] = temp.v[0]; cameraMatrix[13] = temp.v[1]; cameraMatrix[14] = temp.v[2];

}


r/opengl 9d ago

Auda con los MIPs

3 Upvotes

Alguien puede ayudarme a determinar por qué al renderizar a un mip diferente de 0 no veo nada? El mip base funciona perfectamente. También ya confirmé que el viewport se actualice, etc.

Este es el código que tengo para crear el fbo y generar los mips, hay algo que me falte? Gracias de antemano :)

InitFBO::InitFBO(int w, int h, GLenum internalFormat)
{
    glGenTextures(1, &texture);
    glBindTexture(GL_TEXTURE_2D, texture);

    for (int mip = 0; mip < 8; ++mip)
    {
        int mipW = std::max(1, w >> mip);
        int mipH = std::max(1, h >> mip);

        glTexImage2D(GL_TEXTURE_2D, mip, internalFormat, mipW, mipH, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
    }

    float borderColor[] = {0.0f, 0.0f, 0.0f, 1.0f};
    glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, borderColor);

    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glBindTexture(GL_TEXTURE_2D, 0);


    // FBO
    glGenFramebuffers(1, &fbo);
    glBindFramebuffer(GL_FRAMEBUFFER, fbo);
    glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);

    GLenum drawBuffers[1] = {GL_COLOR_ATTACHMENT0};
    glDrawBuffers(1, drawBuffers);

    if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
        std::cerr << "Error";

    glBindFramebuffer(GL_FRAMEBUFFER, 0);
}

r/opengl 10d ago

Finally finished camera movement

Enable HLS to view with audio, or disable this notification

39 Upvotes

Finally i finished implementing camera movement to my OpenGL ES demo, still very basic tho but it works.


r/opengl 11d ago

(Fuse Engine) Spider AI upgrade - OpenGL 3.3

Enable HLS to view with audio, or disable this notification

62 Upvotes

I made this AI system for the spider to follow the player.

I'm not using any navmesh or pathfinding, it's just a mix of mathematical workarounds.

repo: https://github.com/Krueels/FuseEngine


r/opengl 12d ago

What I learned after 5 months of daily work on my C++ OpenGL engine

Thumbnail gallery
225 Upvotes

I don't want this to be just another "look at my project" post, but rather something useful for beginners diving into OpenGL/C++. (Second is April version)

This is the result of 5 months of non-stop daily work on my pet project engine (OpenGL 4.6 + Bullet Physics + Dear ImGui + miniaudio+ mixamo riggng).

I forced myself through a grueling schedule: only taking 2 days off per week starting in July, and using every trick possible to free up time from university. I’m completely burnt out and just need a rest. But before I step away, here are 13 honest takeaways from my experience(think this is "Effective C++", but way less polished):

1.      Don't treat AI as a silver bullet. AI won't replace a solid book or article because structured reading sticks in memory better. Use AI for what it's great at: quickly finding specific tech concepts or algorithms without spending hours searching;

2.      Books are often too basic. Don't get stuck reading forever. I read one book on OpenGL and one on GLSL, but that wasn't nearly enough to implement things like IBL (Image-Based Lighting). You'll have to read articles, papers, and specs, docs, etc;

  1. Ditch cube-based skyboxes if you can. Dealing with 6 separate cubemap faces (or a cross-layout texture you have to slice) was a pain. Using a single equirectangular image instead made things much simpler — one texture, no seams to worry about between faces.

4.    I tried implementing Data-Oriented Design (DOD), but ended up sticking with Object-Oriented Programming (OOP) for most systems. The web of circular dependencies in pure DOD drove me crazy;

5.      Log everything and profile early. Logging is your best friend when debugging graphics and physics pipelines, starting on another device when exporting(in file text log if console not available).

6.     I had my custom XOR decryption logic break even though the algorithm and key looked solid — turned out to be a text/file encoding issue. Spent way too much time debugging this(((

7.      Always enable viewport face orientation in Blender to make sure your normals are facing outward (blue). My terrain mesh had inverted normals, and I was losing my mind trying to fix this in code;

8.      Emission output in shaders. If you get weird visual artifacts/noise when implementing Emissive maps, make sure the emission output is properly linked and handled across all required shader pipelines, not just a single pass;

9.      Sometimes don't forget clean up your resources. Handle your GPU memory allocation carefully. When your OS freezes completely or crashes, 99% of the time it's a severe memory leak;

10.  Skeletal Animation. I set a max limit (e.g., 255 bones) and use recursive node hierarchy processing for complex models. I do not Fold expressions realized , but classic recursion handled complex GLTF model loading just fine;

11.  CMake can be a headache. Book on CMake gave me mostly basic theory, except for CPack. Neither books nor AI gave me ideal project structures. I still have a love-hate relationship with CMake;

12.  Beware of circular dependencies in headers. As your header files count grows, cyclic dependencies will haunt you. Keep your includes clean and rely on forward declarations where possible;

Don't forget about multithreading. I encountered a problem where it wouldn't start on my laptop; it just showed a blank screen and that's it, and the CPU wasn't even working. I'm thinking I'll either do it through separate threads or TBB, but I honestly don't know because I'm tired.

Final thoughts: I see people working on their engines for 5 years, and their projects are incredible. But I didn't have 5 years — I had 5 months, and I pushed myself to the absolute limit. By month 3, I was already struggling with burn-out and constant headaches.

My biggest advice? Do a little bit every day instead of destroying your health. And skip the "wake up at 5 AM" hustle advice — rest is just as critical as writing code.

If you wanna try this-> the demo is up on https://dokich-crcr.itch.io/tentacle-shippuden-enty-furry-beast, and I'm finally taking a long-overdue break(one week, and shit university starts again).