r/opengl • • 3h ago

gl_DrawID as SSBO array index produces incorrect results.

1 Upvotes

Hey everyone,

I'm working on some OpenGL code that is producing strange results and I'm starting to wonder if it's a driver bug. I'm trying to render line segments with two SSBOs, one containing line parameters (e.g. color, width, base_point) and one containing the points of all the line segments I want to render. I'm trying to do this using glMultiDrawArrays since segments can have a different number of points which I can control with the count parameter. In the shader I use gl_DrawID as an index to get the line parameters and a combination of base_point (from the line parameters) and gl_VertexID as an index to get the segment point.

The problem is that when I hit ~60 draw calls, the output is not what I expect. I'm trying to render a grid using line segments and the first 59 lines are correct but after that the behavior is unpredictable. Sometimes they seem to overlap existing lines or just draw in the incorrect place.

I'm not sure how clear this will be but I've attached screenshots of the RenderDoc output for draw calls 58, 59, and 60. Between 58 and 59 you can see an extra grid line being added at the correct spacing but for draw call 60 the line is in the incorrect place. The weird thing is RenderDoc shows the correct gl_Position for these different draw calls (i.e. the MeshViewer shows the line segment in the correct VS Out location) but the actual output in the framebuffer is not right. I've also tried debugging by using gl_DrawID as an increasing color parameter and everything looks right in RenderDoc.

Additionally, if I switch to using glDrawArraysInstanced and index in the SSBOs using gl_InstanceID, everything works correctly. Note that I would prefer to use a multi draw since instancing requires that each line segment have the same number of points (which is true for this grid but not true for what I want to do generally).

Anyone have any ideas? Anything else I can provide to help debug? I'm wondering if it's a driver bug because this problem only happens on my Linux laptop but works fine on my Windows desktop. Thanks!

Draw call 58
Draw call 59
Draw call 60

r/opengl • • 15h ago

Am I a fraud for using AI boilerplate code?

0 Upvotes

I had tried the learnopengl tutorials about a year ago and the reason i got fed up was the build process with CMake. Is it bad that I asked claude to generate me all the CMake boilerplate? It also made me a GLFW window wrapper. Should I start over? I just needed to build on mac and windows so I can code when I’m not home at my PC.


r/opengl • • 21h ago

using fragment shader as compute shader in GLES 2

2 Upvotes

This is just a concept I wanted to share and possibly receive feedback on. I have this idea to calculate rotations of things by passing a texture specifying the current animation frame, initial position, and rotation limits of each thing.

#version 100
precision float mediump;
uniform sampler2D RotHints;
varying mediump Coords;
void main(){
vec4 Hints = texture2D(RotHints,Coords);
Hints.g=Hints.g-Hints.b;
Hints.a=Hints.g*Hints.r+Hints.a;
gl_FragColor = Hints.a;
}

r/opengl • • 1d ago

Building an interactive 2D surveillance map with PyOpenGL, live video textures and dynamic camera visibility

1 Upvotes

r/opengl • • 1d ago

Fragmentshader-raycaster renders from quite a few years ago

Thumbnail gallery
51 Upvotes

Heyo!

Searched through my USB-sticks to find a fragmentshader-raycaster I made like at the end of the 2010s. The actual version, I was looking for, is nowhere to be found though, which likely means, it is (or was) on that one SSD, that seems bricked and refuses to boot, or do anything at all. ..Apparently SSDs can get damaged by laying around..

But not much is lost, iirc.

Those images are from different earlier versions, rendered just yesterday.

Those are mostly tests of different techniques - the usual suspects, like texture-materials, bump-maps, reflections (ofc), different shadows, fog, or blur.

And it was a whole lot of fun programming this by hand!

Lastly I'd like to ask: Which image causes brain-tickling the most to you?

Cheers


r/opengl • • 1d ago

Built a parametric V8 engine assembly inside a custom C++20 + OpenGL CAD/physics engine I wrote from scratch — runs offline on an Intel UHD iGPU

18 Upvotes

r/opengl • • 2d ago

Cigarette game (WIP)

37 Upvotes

r/opengl • • 2d ago

How hard is it actually to get that initial rainbow triangle?

4 Upvotes

i know literally nothing about graphics programming, im a game dev and im honestly considering learning c++

how long does it take to get that rainbow triangle?

is getting the triangle a beginner c++ thing or a intermediate thing?

how much harder is it to do in vulkan?


r/opengl • • 4d ago

Nueva version de Open3d Game engine

33 Upvotes

Open3d es un motor de juegos para linux con opengl hecho en c++ open3d incluye lenguaje propio

codigo fuente en: https://github.com/ciroparada81-boop/Open3D-game-engine.git


r/opengl • • 5d ago

Started Learning OpenGL

297 Upvotes

I started Learning OpenGL recently. I took me so goddam time to just make a triangle and I don't even remember why I stared this. Oh, I remember. To make a Boids simulation. Yeah, learning OpenGL, just to make a Boids simulation. Now, you may wondering, is this guy stupid? yes. And very delusional. This is basically the story of every project I ever stared.
Okay, I know there are much more simpler ways to make a Boids simulation. But what if I want to make lots of boids. I mean a lot.
And the next question is, Why you need boids? Idk. I will think about it after I made it. Wish me luck.

Any advice?


r/opengl • • 7d ago

OpenGL vs Vulkan: Which API Is Better for Gaming?

Thumbnail codexdeal.com
0 Upvotes

r/opengl • • 9d ago

New video tutorial: Row Major VS Column Major

Thumbnail youtu.be
5 Upvotes

r/opengl • • 9d ago

4k balls, single threaded

Thumbnail youtu.be
8 Upvotes

r/opengl • • 11d ago

Physics Programming Part 5: Spring Physics

Thumbnail youtu.be
9 Upvotes

I explain the mathematics underpinning spring mechanics then implement a solution in C++ using a net as an example. Implementation begins at 10:05. Feedback is welcome.


r/opengl • • 11d ago

Newbie here, studying open gl and shaders. I have to make *something* in a couple of weeks. I was thinking a cloud with different light scenarios, but I'd love some suggestions for starter projects!

Thumbnail reddit.com
2 Upvotes

r/opengl • • 11d ago

Rendering text through ImGui?

2 Upvotes

I'm hoping to get a basic repl running with ImGui, OpenGL, and GLFW. I'm comfortable with GLfW and OpenGL rendering but not the ImGui portion.

My question is, can I use the OpenGL context and the GLFW window and then get basic text editing functionality with just ImGui? No opengl buffers, no custom shaders. I think the opengl context needs a default vertex and fragment shader to function but I'm looking to keep that very minimal and handle basic repl input and text rendering between imgui::begin() and imgui::end(). A basic per keypress render loop where each GLFW key event updates a string and then ImGui renders a new frame for the window. I haven't worked with ImGui before. Do you think this is possible?


r/opengl • • 12d ago

I did my first triangle, what now?

17 Upvotes

Yes, I created an orange and horrible triangle but what now? I didn't understand anything! I'm so confuse. Yes maybe I did understand some basics basics things but if you ask me to create a triangle with no tutorials I will stop at declaring the VBO and VAO!

I saw people creating games, the universe, AI robots in OpenGL and I? A stupid triangle did with a tutorial 😭.


r/opengl • • 12d ago

Interactive Video Feature Is Now Available

37 Upvotes

Get your lifetime engine for just $39.
Enjoy lifetime access to multiple systems with powerful features that make it stand out from other engines.
Discover its unique capabilities, explore its advantages, and learn what makes it different from other engines. Compare the features and see the difference for yourself.
Explore the documentation to learn more about all available features and system

https://documents.nexiorgame.workers.dev/


r/opengl • • 12d ago

SimpleX Engine Development (Continued)

5 Upvotes

I originally had a string of posts with various other reddit communities regarding game and game engine development and finally felt confident enough to post to this community! I went dark in my development logging/blogging(?) for awhile due to lifestyle responsibilities taking precedance over developing an engine or at least at the moment what is considered heavy boilerplate engine development.

Current development components/systems:

Three graphics backends - DirectX 11, DirectX 12, and OpenGL (WGL on Windows, GLX on Linux) behind an IRenderer interface. Vulkan is scaffolded but not implemented yet. Shadow maps, cubemaps, bloom, IBL/irradiance convolution, and instancing are supported at the moment.

HLSL as single source of truth compiling offline via DXC to DXBX/DXIL/SIPR-V with SIPRV-Cross transpiling to GLSL for the GL backend. Compiled byte code is also cached on disk and keyed by source hash as filename.

Three windowing backends - Win32, GLFW, and SDL3, with a fallback chain. Win32 is default for Windows and GLFW is default for Linux, but will fallback to GLFW and if GLFW fails fallback to SDL3; if DX fails on any window type under Windows platform fallback to OpenGL (if Vulkan would work with me DX would fallback to Vulkan then back to OpenGL) - similar results would also occur for Linux if Vulkan failed fallback to OpenGL but that requires Vulkan to be developed and not be a stub at the moment...

Fiber-based Job System - Win32 fibers and Linux ucontext behind one class - a worker thread has a dedicated dispatcher fiber that never runs job code, so fibers are pooled to switch back rather than to each other - no fiber needs to know any other fiber's state.

I went with no cross-thread fiber migration in my first attempt - less load-balancing from the inspirational full Naughty Dog design, but it buys a genuinely nice property: since a job's whole execution stays pinned to one thread, a pool allocator allocates inside a job function automatically thread-safe with zero sync.

Custom allocators - arena, pool, and a frame allocator with N rotating arenas.

BC texture compression with no on-disk cache - BC1 for opaque color, BC3 for color with alpha, and BC5 for normal maps.

TLDR; I've tested the boilerplate logic against the Sponza Palace model from Intel's site GPU Research Samples (https://www.intel.com/content/www/us/en/developer/topic-technology/graphics-research/samples.html) with the Colorful Curtains and Ivy extensions at 4K texture resolutions. The original load time took around 5.5 minutes (unbearable to test shader changes and object additions to the scene), but I cut it down to 4.6 seconds after texture compression, precompiled shader code, and submesh merging. The model (as an \.obj - I haven't implemented third-party vendor model software to utilize every model type just yet...) is 995MB on disk with nearly 2730MB of textures (4K per texture for the conjoining material \.mtl file) after texture compression all textures were compressed to 501MB on disk which originally took 933ms average to load cutting down to 259ms average.

Edit: grammar and spelling.

Edit 2: I've recently decided to rebuild what I later found out was more of a rendering framework into an actual engine. I haven't yet begun developing beyond an Application, Runtime, and Core module of an engine (each is self explanatory besides core being a mix of low level utilities and core engine components: reworked the threading and fibers for Linux using pThreads)


r/opengl • • 13d ago

Welcome to the Hellavator

4 Upvotes

Welcome to Hellavator Desktoy

Powered by Gear3D

**Three minutes of disco. One elevator. Absolutely no explanation.**

So, what the fuck are you looking at?

An elevator.

A perfectly functional, procedurally generated elevator with stainless-steel walls, working doors, buttons, lighting, a scrolling LED marquee, questionable announcements, and a soundtrack that has absolutely no business being here.

Someone decided it needed a disco ball.

Things escalated.

What you're watching is three minutes of **Hellavator: Disco Days**, captured directly from a running Gear3D build. No prerendered animation, no composited video effects, and no AI-generated imagery. Just the engine doing increasingly unnecessary things to an innocent elevator.

**Now, what the fuck are you REALLY looking at?**

Gear3D is my long-running, Delphi/Object Pascal game-engine project. It powers several different games and applications, and this elevator is one of its procedural demonstration scenes.

The cabin is assembled from engine geometry and materials. The lighting, reflections, disco ball, illuminated dance floor, controls, and moving doors are rendered in real time.

The music comes through the engine's playlist and audio system, complete with the live spectrum display.

The three-minute sequence is driven by a timed show controller that uses the same registered console commands and scene interfaces available elsewhere in the engine. It triggers effects, changes states, moves the camera, and restores the cabin.

The elevator scene's geometry and behavior are separated from its OpenGL renderer, with the goal of keeping the content reusable as Gear3D's other rendering backends mature.

**And yes, I'm sharing the elevator scene source.**

Not because this is a polished technology demo or a finished game. Because it's an example of what happens when years of engine development reach the point where ridiculous ideas can be assembled from existing parts.

There's more here than an elevator.

There are also considerably worse ideas.

I'm not explaining them.

For now, enjoy the disco.

**Hellavator: The World's Most Obnoxious Desk Toy.**

ThisOldCPU / deschutescore

See less


r/opengl • • 13d ago

New update 1.1Day and night mode

42 Upvotes

More improvements are coming to the engine!
Want to try it out? Join our Discord through the link below and get a free, limited-time trial version, along with full documentation.
Explore the features, test the engine, and see how it works before making a purchase.
Get your free trial before the offer ends!

https://discord.gg/Ts6MTVeAt


r/opengl • • 14d ago

Curso de OpenGL (Episodio 1) - Configuración de la API en Visual Studio.

Thumbnail youtube.com
2 Upvotes

r/opengl • • 14d ago

Same shaders on GL 3.3 core, GLES 3.0 and WebGL2: what worked for our party game

Post image
8 Upvotes

Hi there! A friend and I just released Orbit Rivals, a 3D party board game, on our own small C++ engine over SDL3. We wanted one renderer for desktop, Android and the browser, so from day one we stuck to what GL 3.3 core, GLES 3.0 and WebGL2 have in common.

Shaders are written once. A tiny function adds #version 330 core or #version 300 es plus the precision lines at the top, and we only use what all three support: layout(location), texture(), textureLod, fwidth, gl_VertexID and sampler2DShadow. All GL functions come from one X-macro list loaded with SDL_GL_GetProcAddress, no system GL headers at all.

Things that saved us time:

- shading everything in linear and encoding sRGB by hand at the end, so it looks the same everywhere without sRGB framebuffers

- checking GL_MAX_TEXTURE_SIZE and halving anything over the limit, since ES 3.0 and WebGL2 only promise 2048

- creating an ES 3.0 context on desktop to catch shader errors without a phone

What bit us hardest was phones. At native res with MSAA and bloom they couldn't hold 60 fps and started throttling. Now the 3D scene renders smaller (it drops step by step from 720 to 480 on the short side if fps falls) while the UI stays native, so text is still sharp. On Android we also use GL_EXT_multisampled_render_to_texture so MSAA resolves on-tile without an extra blit.

You can see the WebGL2 build running here: https://armaisdiaz.itch.io/orbitrivals

How do you handle the GL/GLES split? One shader source like us, or do you generate variants?