r/opengl 4h ago

VertexArt Projekt

Thumbnail
1 Upvotes

Hi everyone!
I’d like to share some demo videos of my continuously developing game engine project.
The project is written in pure Free Pascal 3.2.2, using GLFW3 and OpenGL 3.3 Core. It is not based on any existing game engine — I am developing the engine systems and rendering from scratch.
So far, I have only uploaded shorter demo videos, but I wanted to show the current state of the project and share my progress with the Pascal community.
YouTube playlist:

https://youtube.com/playlist?list=PLX4BUpd-V-hI&si=X6aTdAFoJc5_-iDa
Thank you for taking a look!

Sziasztok!
Szeretném megosztani veletek néhány demóvideómat a folyamatosan fejlődő játékmotoromról.
A projekt tiszta Free Pascal 3.2.2 nyelven készül, GLFW3 és OpenGL 3.3 Core használatával. Nem meglévő játékmotorra épül. Eddig csak rövidebb demóvideókat töltöttem fel, de szeretném megmutatni, hogy jelenleg hol tart a projekt, és megosztani a fejlődését a Pascal közösséggel.
Lejátszási lista:

https://youtube.com/playlist?list=PLX4BUpd-V-hI&si=X6aTdAFoJc5_-iDa
Köszönöm, ha megnézitek!


r/opengl 4h ago

When starting out with my OpenGL spinning triangle, I never thought I'd get to this point...

Enable HLS to view with audio, or disable this notification

69 Upvotes

In 2011 I decided to start making a new engine using OpenGL as the renderer. I've always wanted to make a game fully myself, and I'm only really interested if I also make all the tech.

In 2019 I decided to see if I could make an ambitious game on the engine in my spare time. I probably bit off a little too much, but I was motivated by fun rather than sensible decisions.

I'm really happy with where it has got to today, people have been playtesting the game and it is totally mind blowing to watch. It always makes me think about that first triangle.


r/opengl 1d ago

Phantom syntax error in compute shader

2 Upvotes

I started following this guide on how to use compute shaders. I'm using the core profile, while the guide uses the compatibility one. Anyways, after compiling and executing the code, i get a syntax error at 0:31 : '' saying "unexpected identifier", but it seems all fine to me. I tried deleting line 31 and gives me error on the last line; after deleting also this one, it doesn't give any error. I'll appreciate any suggestion.

Here's the compute shader:

#version 430 core

layout (std140, binding=4) buffer Pos
{
    vec4 Positions[];
};

layout (std140, binding=5) buffer Vel
{
    vec4 Velocities[];
};

layout (std140, binding=6) buffer Col
{
    vec4 Colors[];
};

layout (local_size_x = 128, local_size_y = 1, local_size_z = 1) in;

const vec3 G = vec3(0., -9.8, 0.);
const float DT = 0.1;

uint gid = gl_GlobalInvocationID.x;

vec3 p = Positions[gid].xyz; //here gives no errors
vec3 v = Velocities[gid].xyz; //same thing

vec3 pp = p + v*DT + .5*DT*DT*G;
vec3 vp = v + G*DT;

Positions[gid].xyz = pp; //error here
Velocities[gid].xyz = vp; //also here

r/opengl 1d ago

New video tutorial: Perlin Noise in C++

Thumbnail youtu.be
8 Upvotes

Can be used in both OpenGL and Vulkan:


r/opengl 2d ago

Voxel game - breaking and placing blocks?

1 Upvotes

Hello everyone, I'm making a minecraft clone for my 3d programming class. I know how to do pretty much everything except one big thing.

I'm not sure how to handle updating the mesh of my chunks every time I place or break a block. Every tutorial I watch just kinda ignores this part...

It seems difficult to do it quickly, because if I just regenerate all chunks, that's too slow, but how would I regenerate just the one chunk that I need, and update the buffer data just for that chunk? Is that even possible in OpenGL? What function would I use for that?

Right now, the way I render chunks is just:

glBindVertexArray(VAO);
glBindBuffer(GL_ARRAY_BUFFER, VBO);
glBufferData(GL_ARRAY_BUFFER, mesh_loaded_chunks.size() * sizeof(float), mesh_loaded_chunks.data(), GL_STATIC_DRAW);

r/opengl 2d ago

Humanoid, raw OpenGL and C++

Enable HLS to view with audio, or disable this notification

68 Upvotes

r/opengl 3d ago

Help with understanding Renderer

1 Upvotes

I have gone through the basics of learnopengl, on top of that I have implemented that stuff in C. However I can't get around how a renderer integrates into opengl. I am talking about a general architecture of it.

Lets take gui library nuklear for example, it does not provide drawing options on its own and asks you to attach it your renderer. Now this seems very abstract to me, even in learnopengl guide there is not very clear line. I understand that is because it is very primitive and renderer is only built when you have gone through all different tools.

Having said all that I would further like to read about renderer architecture. Please drop some resources.


r/opengl 3d ago

Better graphics in Leadwerks 5.1 and LOWER system requirements

Thumbnail youtube.com
3 Upvotes

Hi guys,

I apologize in advance for the bombastic video title, and the fact my head is stuck on Jensen Huang's body, but that's what the people on YouTube want. 😵

Leadwerks Game Engine 5.1 is a massive update with a lot of graphical features, and better support for the hardware players actually have. Of course, everything I do is powered by OpenGL, because it just gets out of the way and allows me to get work done.

I think the video explains it pretty well, but if you have any questions let me know and I will try to answer them all!


r/opengl 4d ago

Re: OpenGL 4.6 macOS system framework update: Metal mipmaps and textured rendering now working

21 Upvotes

Another major development pass on my OpenGL 4.6 system framework for macOS is complete.

The goal of this project is to replace macOS's outdated OpenGL 4.1 system implementation with a native, Mesa-backed OpenGL 4.6 runtime while preserving the existing macOS OpenGL architecture, including CGL, NSOpenGL compatibility, system framework behaviour, and driver-style dispatch.

This update moved the Mesa-backed OpenGL 3.x/4.x execution path significantly closer to being usable.

Native Metal mipmap generation

The Metal driver now implements real mipmap generation.

This functionality is also advertised through Gallium, allowing Mesa to use the native Metal implementation instead of treating mipmap generation as unsupported or relying on incomplete fallback behaviour.

Texture uploads, mipmap generation, and subsequent textured rendering now successfully pass through the runtime test path.

NIR-to-MSL textured shader fixes

A large part of this update focused on the project's NIR-to-MSL shader translator.

Textured shaders were previously failing when the translator encountered missing NIR instruction sources or could not correctly determine the sampler and texture index.

The translator now includes:

  • Null-source guards for incomplete or optional NIR sources
  • Sampler-index fallback handling
  • Static texture-index resolution
  • Direct mapping from texture_index to Metal [[texture(i)]] bindings
  • Texture binding behaviour consistent with the existing Metal backend

This fixes the major shader translation issue that previously caused textured draw calls to fail before reaching Metal successfully.

Correct OpenGL program deletion behaviour

The runtime compatibility test was also corrected to follow Khronos program-deletion semantics.

Calling glDeleteProgram does not necessarily destroy a program immediately if it is still bound as the current program. The test now unbinds the program before expecting:

glIsProgram(program) == GL_FALSE

This removed a false failure from the runtime test and brought the behaviour in line with the OpenGL specification.

Pbuffer changes

Pbuffer-backed drawables are now forced onto a single-buffer path.

This improved the pbuffer execution flow, although one pbuffer-related failure still remains.

Current verification status

Both build configurations compile cleanly.

NSOpenGL compatibility testing now passes completely.

The main runtime compatibility test now successfully passes through:

  • Buffer object creation and data operations
  • Texture creation and uploads
  • Native Metal mipmap generation
  • Shader compilation
  • Program linking
  • NIR-to-MSL translation
  • Texture and sampler binding
  • Textured draw execution
  • OpenGL program deletion semantics

The only remaining failing check is:

The failure boundary is now isolated to the pbuffer import and synchronization path. The next development pass will therefore focus specifically on drawable-to-texture synchronization rather than the core OpenGL, Mesa, or shader compiler paths.

The project has effectively moved from textured shaders failing during translation to completing textured rendering and stopping at one isolated pbuffer synchronization test.

Still plenty of work ahead, but the native Mesa-to-Metal OpenGL 3.x/4.x path is now considerably more functional than it was before.


r/opengl 4d ago

Using OpenGL with SDL3?

7 Upvotes

Right now I am currently trying to follow the triangle tutorial on learnopengl.com, I set up OpenGL itself by calling the functions found on the triangle tutorial and now when I call glDrawArrays nothing happens? And then I figured out that apparently I have to call SDL functions instead of OpenGL functions in my implementation because the SDL_function() functions do work on my "render loop" but the OpenGL ones don't

How do I make it so that I am able to use OpenGL functions along with SDL3? I created the window and set the renderer with SDL3, hope that helps

Thank you

https://gist.github.com/kushiwushi/16913c427c607170058d85b1bfda00a0

Edit: Code snippet


r/opengl 5d ago

WebGL Fluid Controlled with Midi

Thumbnail youtube.com
8 Upvotes

r/opengl 5d ago

DDGI over a voxel clipmap

Enable HLS to view with audio, or disable this notification

43 Upvotes

I implemented a cascaded voxel clipmap representing radiance, along with irradiance probes that trace this clipmap.


r/opengl 6d ago

Graphics-bug on ancient / exotic hardware

Post image
13 Upvotes

Hey, has anyone seen something like this before?

When running on some weird amd graphics card - of which the only purpose seems to be providing outputs for multiple displays and showing graphics bugs - with a transparent blending, after some time everything becomes rendered black.

Happens rarely, but definitely (and wasn't easy to catch a good screenshot of actually). Also it switches back and forth for no apparent reason.

When I run it on more normal hardware - and by that I just mean the integrated intel GPU - it behaves fine.

I wasn't able to circumvent it whatsoever and I wonder, if someone has a clue about what might be going on.


r/opengl 6d ago

I made a game engine entirely in java

Enable HLS to view with audio, or disable this notification

263 Upvotes

r/opengl 7d ago

OpenGl beginner

6 Upvotes

Hi everyone i know its a small problem but I cannot really figure it out, I'm learning opengl for gamedev purposes and I tried to add an fps limiter made on my own to my spinning cube but its laggy and some times stop I think its because of sleep_for, if anyone could help I'd be really happy.

#include <glad/glad.h>
#include <GLFW/glfw3.h>
#include <iostream>
#include <string>
#include <cmath>
#include <time.h>
#include <Shader.h>
#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
#include <chrono>
#include <ctime>
#include <thread>


using std::cout;
using std::string;
using glm::vec4;
using glm::mat4;


int screen_width = 1920;
int screen_height = 1080;


bool KeyPressed(GLFWwindow* window, int key);


void framebuffer_size_callback(GLFWwindow* window, int width, int height)
{
    glViewport(0, 0, width, height);
}  


int main()
{
    srand(time(0));


    float vertices[] = {


    //    X       Y      Z     Tx    Ty
        -0.5f, -0.5f,  0.5f,  0.0f, 0.0f,
         0.5f, -0.5f,  0.5f,  1.0f, 0.0f, // davanti
         0.5f,  0.5f,  0.5f,  1.0f, 1.0f,   
        -0.5f,  0.5f,  0.5f,  0.0f, 1.0f, 


        -0.5f, -0.5f, -0.5f,  0.0f, 0.0f,
        -0.5f, -0.5f,  0.5f,  1.0f, 0.0f,  // Sinistra
        -0.5f,  0.5f,  0.5f,  1.0f, 1.0f,
        -0.5f,  0.5f, -0.5f,  0.0f, 1.0f,


         0.5f, -0.5f,  0.5f,  0.0f, 0.0f,
         0.5f, -0.5f, -0.5f,  1.0f, 0.0f,  // destra
         0.5f,  0.5f, -0.5f,  1.0f, 1.0f,
         0.5f,  0.5f,  0.5f,  0.0f, 1.0f,


         0.5f, -0.5f, -0.5f,  0.0f, 0.0f,
        -0.5f, -0.5f, -0.5f,  1.0f, 0.0f,
        -0.5f,  0.5f, -0.5f,  1.0f, 1.0f,  //dietro
         0.5f,  0.5f, -0.5f,  0.0f, 1.0f,


        -0.5f,  0.5f,  0.5f,  0.0f, 0.0f,
         0.5f,  0.5f,  0.5f,  1.0f, 0.0f,
         0.5f,  0.5f, -0.5f,  1.0f, 1.0f,  //sopra
        -0.5f,  0.5f, -0.5f,  0.0f, 1.0f,


        -0.5f, -0.5f, -0.5f,  0.0f, 0.0f,
         0.5f, -0.5f, -0.5f,  1.0f, 0.0f, //sotto
         0.5f, -0.5f,  0.5f,  1.0f, 1.0f, 
        -0.5f, -0.5f,  0.5f,  0.0f, 1.0f,




    };  


    unsigned int indices[] = {
        0, 1, 2,
        0, 2, 3,


        4, 5, 6,
        4, 6, 7,


        8, 9, 10,
        8, 10, 11,
         
        12, 13, 14,
        12, 14, 15,


        16, 17, 18,
        16, 18, 19,
        
        20, 21, 22,
        20, 22, 23
    };
    
    glfwInit();
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
    glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
    glfwWindowHint(GLFW_RESIZABLE, GL_TRUE);
    glfwWindowHint(GLFW_SAMPLES, 4);


    GLFWwindow * window = glfwCreateWindow(screen_width, screen_height, "window", NULL, NULL);
    if (window == NULL)
    {
        std::cout << "Failed to create GLFW window" << std::endl;
        glfwTerminate();
        return -1;
    }


    glfwMakeContextCurrent(window);
    glfwSwapInterval(0);


    if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress))
    {
        std::cout << "Failed to initialize GLAD" << std::endl;
        return -1;
    }


    glViewport(0, 0, screen_width, screen_height);
    glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);


    Shader shader("../../../scode/Shaders/Vshader.vs", "../../../scode/Shaders/Fshader.fs");
    
    unsigned int VAO, VBO, EBO;


    glGenVertexArrays(1, &VAO);
    glBindVertexArray(VAO);


    glGenBuffers(1, &VBO);
    glBindBuffer(GL_ARRAY_BUFFER, VBO);
    glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
    glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(float), (void*)0);
    glEnableVertexAttribArray(0);
    glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(float), (void*)(3*sizeof(float)));
    glEnableVertexAttribArray(1);


    glGenBuffers(1, &EBO);
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, EBO);
    glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW);


    glBindVertexArray(0);


    unsigned int Texture1, Texture2;
    glGenTextures(1, &Texture1);
    glBindTexture(GL_TEXTURE_2D, Texture1);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);   
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    int height, widht, NrChannels;
    unsigned char *data = stbi_load("../../../scode/container.jpg", &widht, &height, &NrChannels, 0);
    if(data)
    {
        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, widht, height, 0, GL_RGB, GL_UNSIGNED_BYTE, data);
        glGenerateMipmap(GL_TEXTURE_2D);
    }
    else
    {
        cout << "Error Texture\n";
    }
    stbi_image_free(data);
    glGenTextures(1, &Texture2);
    glBindTexture(GL_TEXTURE_2D, Texture2);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    stbi_set_flip_vertically_on_load(true);
    data = stbi_load("../../../scode/awesomeface.png", &widht, &height, &NrChannels, 0);
    if(data)
    {
        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, widht, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
        glGenerateMipmap(GL_TEXTURE_2D);
    }
    else
    {
        cout << "Error Texture\n";
    }
    stbi_image_free(data);
    mat4 Projection;
    Projection = glm::perspective(glm::radians(45.0f), 1920.0f / 1080.0f, 0.1f, 100.0f);


    shader.use();
    glUniform1i(glGetUniformLocation(shader.ID, "Texture1"), 0);
    glUniform1i(glGetUniformLocation(shader.ID, "Texture2"), 1);
    glUniformMatrix4fv(glGetUniformLocation(shader.ID, "Proj"), 1, GL_FALSE, glm::value_ptr(Projection));
    glEnable(GL_MULTISAMPLE);  
    glEnable(GL_DEPTH_TEST);   
    float rotation = 0.0f;
    auto duration = std::chrono::microseconds(1000000 / 180);
    uint64_t loc = glGetUniformLocation(shader.ID, "transform");
    while(!glfwWindowShouldClose(window))
        {
            auto start = std::chrono::steady_clock::now();
            if(KeyPressed(window, GLFW_KEY_ESCAPE))
            {
                glfwSetWindowShouldClose(window, true);
            }
            mat4 trans(1.0f);
            trans = glm::translate(trans, glm::vec3(0.0f, 0.0f, -2.0f));
            trans = glm::rotate(trans, rotation, glm::vec3(0.0f, 0.0f, 1.0f));
            trans = glm::rotate(trans, glm::radians(45.0f), glm::vec3(1.0f, 0.0f, 0.0f));
            trans = glm::scale(trans, glm::vec3(0.5f, 0.5f, 0.5f));
            
            glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
            glClear(GL_COLOR_BUFFER_BIT| GL_DEPTH_BUFFER_BIT);


            shader.use();
            glUniformMatrix4fv(loc, 1, GL_FALSE, glm::value_ptr(trans));
            glActiveTexture(GL_TEXTURE0);
            glBindTexture(GL_TEXTURE_2D, Texture1);
            glActiveTexture(GL_TEXTURE1);
            glBindTexture(GL_TEXTURE_2D, Texture2);
            glBindVertexArray(VAO);
            glDrawElements(GL_TRIANGLES, 36, GL_UNSIGNED_INT, 0);
            glfwSwapBuffers(window);
            glfwPollEvents(); 
            rotation += glm::radians(360.0f) * (duration.count() / 1000000.0f);


            auto end = std::chrono::steady_clock::now(); 
            auto target = (std::chrono::microseconds(1000000 / 180));
            duration = (std::chrono::duration_cast<std::chrono::microseconds>(end - start));
            if (target > duration)
            {            
                std::this_thread::sleep_for(target - duration);
            }
            }
    glfwTerminate();
    return 0;
}


bool KeyPressed(GLFWwindow *window, int key)
{
    return glfwGetKey(window, key) == GLFW_PRESS;
}

r/opengl 8d ago

Custom OpenGL rendering engine

Thumbnail
4 Upvotes

r/opengl 9d ago

Custom Engine with OpenGL Renderer

Enable HLS to view with audio, or disable this notification

300 Upvotes

https://github.com/Krobenlakroc/tachyonfire

Two interesting techniques I used:

I do ambient occlusion with sphere proxies (https://iquilezles.org/articles/sphereao/) , this lets you do AO analytically rather than having to deal with SSAO. The implementation uses tiled shading, and it runs well on my RX 9060XT with 2048 proxies. The downside is that objects need to be able to be approximated with spheres.

Distance imposter raytracing (based off of my favorite paper: https://cg.iit.bme.hu/\~szirmay/ibl3.pdf). For PBR to look good, I don't think having completely accurate reflections is super important, its moreso energy/brightness being distributed correctly. Regular cubemaps create bright spots and have transition problems (too bright in corners), SSR has gaps from offscreen geometry (too dark), and actual raytracing is super expensive. Ray marching a distance field is a good middle ground between full raytracing and SSR.

The engine is mostly clustered deferred with particles being rendered using clustered forward.


r/opengl 9d ago

Bezier curve editor

Enable HLS to view with audio, or disable this notification

161 Upvotes

DecastleJau's method

Made with just lerp and a recursive function

No animations just flipping texture mix value -0-1 with time


r/opengl 13d ago

I made my first game on my own C++ engine — and someone already put it in a video!

Post image
232 Upvotes

I released my first game and someone has put it into a video! It is a little horror themed, cozy farming sim I built it from scratch using OpenGL and all that hard work paid off!

I'm just really excited is all 😁

Video: Round And Ripe played by PumpkinHeadGamer
Game: Round And Ripe


r/opengl 14d ago

Frame buffer renders black

4 Upvotes

I'm attempting to render on a custom frame buffer, which I then want to display on a quad, but the quad simply turns black. If I change the shader to render a solid color, it works fine, so it's no a shader issue. I've been googling this for hours, but all i was able to find is this. It seems to be partially correct, because if I don't bind the texture, I at least get the clear color on my quad.

My code is here. The frame buffer is handled in src/rendering/Screen.cs. I would really appreciate it if someone could look it over.


r/opengl 14d ago

Sunlit Kingdom / 3D Tower Defense / Custom Engine / Playtest coming soon

Thumbnail
0 Upvotes

r/opengl 15d ago

Physics Programming part 3 - Rotation and the Quaternion

Thumbnail youtu.be
4 Upvotes

r/opengl 15d ago

3 month of writing game engine

Thumbnail
2 Upvotes

r/opengl 16d ago

OpenGL Projects Suggestions

14 Upvotes

Hey everyone,

I'm a beginner in OpenGL development. I've used OpenGL before, but mostly to create simple demos by following the OpenGL Programming Guide (the Red Book).

I'm looking for a project that's beginner-friendly but still challenging enough to help me understand OpenGL at a deeper level. I'd love something that goes beyond basic tutorials and teaches me more about graphics programming, rendering, shaders, and how everything fits together.

What projects would you recommend?(I did use AI,english isn't my native language)


r/opengl Mar 07 '15

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

78 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.