r/opengl

▲ 6 r/opengl

C# .NET 10 OpenTK - Video Scheduler Internal Error on Resize

I'm using OGL to output a BGRA surface to screen. Nothing else.

OpenTK + Intel ARC iGPU. I'm extending GameWindow.

Behavior is inconsistent. Sometimes it resizes instantly. Sometimes there is a delay. If the delay is too long, then BSOD.

I believe its related to how free the CPU is. For example, silent profile is more likely to crash due to timeout. High fan profile is way less likely to exhibit issues. Original version avoided OGL code directly in favor of SkiaSharp doing the rendering. That was slower and crashed more often.

The resize code is this, done in OnFrameBufferResize event hook,

            GL.DeleteTexture(_texture);

            _texture = GL.GenTexture();
            GL.ActiveTexture(TextureUnit.Texture0);
            GL.BindTexture(TextureTarget.Texture2D, _texture);

            // No mipmaps needed for a 1:1 pixel display.
            GL.TexParameter(TextureTarget.Texture2D,
                TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Nearest);
            GL.TexParameter(TextureTarget.Texture2D,
                TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Nearest);
            GL.TexParameter(TextureTarget.Texture2D,
                TextureParameterName.TextureWrapS, (int)TextureWrapMode.ClampToEdge);
            GL.TexParameter(TextureTarget.Texture2D,
                TextureParameterName.TextureWrapT, (int)TextureWrapMode.ClampToEdge);

            // Allocate GPU storage with the initial pixel data.
            GL.TexImage2D(
                TextureTarget.Texture2D,
                level: 0,
                internalformat: PixelInternalFormat.Rgba8,  // GPU stores RGBA8
                width: ClientSize.X,
                height: ClientSize.Y,
                border: 0,
                format: PixelFormat.Bgra,           // CPU supplies BGRA
                type: PixelType.UnsignedByte,
                pixels: ptr);

In OnResize hook,

GL.Viewport(0, 0, e.Width, e.Height);
u/NoisyJalapeno — 9 hours ago
▲ 15 r/opengl

Is OpenGL dead?

What should I learn instead? I liked how OpenGL was so widely supported. It ran on both windows and macos, it was GPU agnostic, it even had Python wrappers!

Should I begin migrating to Vulkan? I heard Vulkan is horribly verbose and much more involved than OpenGL.

What is the rest of the community doing?

reddit.com
u/vxntedits — 22 hours ago
▲ 2 r/opengl+1 crossposts

Stencil buffer size is always 0 bits

Hey ! I'm currently building an game engine with SDL3 + OpenGL of my own, and now that I'm implementing effects using the stencil buffer, now matter what I do, I cannot seem to initialise it correctly, here is my method tasked of initialising my window. Did I miss something ?

SDL_AppResult Window::SDL_AppInit()
{
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);


    // Profil OpenGL
    SDL_GL_SetAttribute(
        SDL_GL_CONTEXT_PROFILE_MASK,
        SDL_GL_CONTEXT_PROFILE_CORE
    );


    SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
    SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
    SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
    SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
    SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
    SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);
    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);


    SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
    SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8); // 8 bits stencil buffer


    wind = SDL_CreateWindow("SMT", SDL_WINDOW_WIDTH, SDL_WINDOW_HEIGHT, SDL_WINDOW_OPENGL);
    if (wind == NULL)
    {
        cout << "Window creation failed !";
        return SDL_APP_FAILURE;
    }
    this->context = SDL_GL_CreateContext(wind);
    SDL_GL_MakeCurrent(wind, this->context);


    if (!gladLoadGLLoader( (GLADloadproc)SDL_GL_GetProcAddress ) )
    {
        cout << "glad init failed" << endl;
        return SDL_APP_FAILURE;
    }
    
    glViewport(0,0,SDL_WINDOW_WIDTH,SDL_WINDOW_HEIGHT);
    return SDL_APP_CONTINUE;
}
reddit.com
u/Economy-Dig3969 — 12 hours ago
▲ 1 r/opengl+1 crossposts

Which Rust libraries should I use for OpenGL engine (beginner)

Hello, I'm totally new in graphics programming, I would like to make a 3D graphics engine in Rust but I d'ont know which library I should use ;

- Glow

- Kiss3D

- Bevy

- GL crate

- Glium

I d'ont know which one choose, if you can give an advice !

Thanks

reddit.com
u/Louloubiwan — 24 hours ago
▲ 8 r/opengl

Suggestion with setup Project

I've been learning computer graphics for about a year and have built projects like rendering triangles, loading textures, creating 3D objects, implementing cameras, and a basic lighting model in WebGL.

My biggest issue is that every time I want to learn a new graphics concept, I have to rebuild the same setup from scratch (renderer, objects, camera, lighting, shaders, etc.), which takes a lot of time.

Because of that, I'm thinking of building a reusable base project that handles all of those common systems so I can focus on experimenting with new rendering techniques instead of rewriting the foundation each time.

Is this the right approach, or am I likely to over-engineer it? I'd appreciate any advice or suggestions from people who've gone through this learning process.

reddit.com
u/Most_Passenger_2937 — 3 days ago
▲ 22 r/opengl+3 crossposts

Floor Editor for Video Management System in 3Vial OS

u/Rayterex — 4 days ago
▲ 75 r/opengl

Timelapse level design in my game engine (Fuse Engine - OpenGL 3.3)

Here's a simple video of me practicing level design in my game engine.
The functions are still very basic, only allowing square objects, but I will soon add objects of other shapes.

Source code: https://github.com/SaitoxBeats/FuseEngine

u/NIkoNI776 — 4 days ago
▲ 58 r/opengl+2 crossposts

Reverse-Z is the perfect hack

I shelved a Reverse-Z branch in my engine (stuck on OpenGL 4.1 for macOS, no glClipControl), and the roadblock sent me down the rabbit hole of actually understanding why it works instead of just how to implement it.

I ended up writing about what I learned with interactive graphs and all:
https://www.shlom.dev/articles/reverse-z-perfect-hack/

Happy to hear where I got things wrong or imprecise.

Hopefully this helps someone else :)

reddit.com
u/shlomnissan — 5 days ago
▲ 6 r/opengl+1 crossposts

Open GL and CL still not working even with the compatibilty pack

i am at a loss this is my seccond post, i have a lenovo ideapad slim 3x, its great an amazing upgrade over the chromebook i used to have, but i have no open gl or cl past version 1.1, i have installed repaired and remove and reinstallled the compatibilty pack from microsft and downgrade the drivers upgraded the drives and reinstalled the drivers and NOTHING is making it show any higher than 1.1. i have done every trick you can think of to get it to work and nothng changes, downloaded opengl view thing and it shows it as 1.1 as well

any help appriciated thanks

edit: yes i updated windows.

https://preview.redd.it/ttdntqr61hah1.png?width=1290&format=png&auto=webp&s=d09dbf764a1c3bf62490ccdc7ca0851114f69d07

reddit.com
u/LegitimateVisit7850 — 6 days ago
▲ 2 r/opengl

Multiple passes with different shaders? How to insert a new "step" after all frag shaders?

Sorry if the title is confusing. Hopefully I can explain it better:

Let's say you have a project that already has numerous shaders and things being done. You want to add color correction via a frag shader. You could go in and add the color correction frag shader logic to each and every existing frag shader. But that's a lot of effort and adds much complexity to all shaders. Is there a way to do multiple passes? So do everything as it's currently being done, but then also pass what's being rendered through this new shader, the color correction shader, before being displayed on the screen?

reddit.com
u/ProgrammingQuestio — 5 days ago
▲ 181 r/opengl+1 crossposts

Feel like it's impossible to learn graphics programming, need help

Yesterday I finished the third episode of Victor Gordan's OpenGL tutorial, and made my first triangle. I also learned how to modify it (like changing vertex positions, color, etc).

But when I look at the code I wrote, it feels impossible to remember like I could write any of this without looking at the tutorial. When I was learning C++, mostly everything instantly stuck with me, but graphics programming seems like I'll never memorize 80% of it

How did you guys get decent at this and actually retain the knowledge and be able to write it independently? Or am I judging too early? I started 3 days ago

u/CorruptedSciencep — 10 days ago
▲ 75 r/opengl

I "tried" to add surfing to my engine (Fuse Engine - OpenGL 3.3).

After about 20 attempts, I finally got a surf result similar to CS:GO.

It's still not the same and is very poorly functional. I tried to study the CS:GO source code as much as possible, but this is the best I could do.

For anyone willing to help recreate the CS:GO surfing system in my game, here is the source code: https://github.com/SaitoxBeats/FuseEngine

u/NIkoNI776 — 8 days ago
▲ 87 r/opengl

I successfully swapped over my Engine's UI library from ImGui to Qt

Hello everyone!

For the past 6 months I've been working on my Platform Nebrix and I've been using the UI library ImGui although recently I've been working to switch to Qt.

The reason I did this is because in the future I want to add Mobile Support to Nebrix. Although ImGui does not natively support ImGui and from what I've heard it's really not designed for Mobile while Qt does natively support it.

I had to rewrite a lot of the engine's code because Qt keeps UI elements in memory and updates them when they change, rather than rebuilding and drawing the entire UI every frame.

I've been working really hard on this project and it is planned to release in 2027! Im currently working on Ray tracing so if you want to see more check out our discord or website :)

u/Puppyrjcw — 9 days ago
▲ 1 r/opengl

Good afternoon. I'm learning OpenTK and having a lot of trouble; I'm thinking about switching to C++.

(I know how to speak English, so I used Google Translate.) Good afternoon. I'm learning OpenTK and having some trouble grasping certain concepts; I've basically turned to AI for help—I ask what a buffer is, and it gives me a ton of information. On top of that, all the online resources aren't in my native language, which makes it even harder to understand. So, I was thinking about switching to C++ and learning OpenGL directly, but I'm not sure if that's a good idea. Does anyone have any tips?

reddit.com
u/equitos0101101 — 6 days ago
▲ 1.2k r/opengl+1 crossposts

Screenshots from my game, uses OpenGL 3.0

The game is called Diffusion (available only on Itchio, absolutely for free) - story-driven FPS that I spent around 10 years on. The project started as a Half-Life 1 mod and moved to Xash3D engine at some point. It runs as low as 8600GT but the VRAM there is not enough. Personally I played the whole game on 9800GTX+ without problems. Released last year.

u/Aynekko — 13 days ago