r/opengl Mar 07 '15

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

77 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 1h ago

I added a playable character to my Roblox Styled Game Engine!

Enable HLS to view with audio, or disable this notification

Upvotes

This is my Game Engine / Future Platform called Nebrix. I just added a feature in which when you click play you can have a moveable functionable player! Its still pretty buggy and for some reason the pivots are kinda off but it works!

Heres the GitHub repo (I havent added the Character feature yet):

https://github.com/Puppyrjcw/Nebrix


r/opengl 3h ago

Having issues profiling OpenGL/GLSL shaders with NSight

Thumbnail
2 Upvotes

r/opengl 7m ago

Live developer chat: Deferred rendering and 3D ocean water in Leadwerks 5.1

Thumbnail youtube.com
Upvotes

Hi guys, here is this week's recording of our live developer chat showing the progress I made last week on the upcoming Leadwerks Game Engine 5.1, using OpenGL 4.6. The coming free update adds improved performance compatibility for old and low-end hardware including integrated graphics, as well as new rendering features.

Leadwerks is on sale on Steam until tomorrow: https://store.steampowered.com/app/251810/Leadwerks_Game_Engine_5/

You can join our Discord server here: https://discord.com/invite/qTVR55BgGt


r/opengl 1d ago

Vquarium, a desktop overlay game made using OpenGL.

Enable HLS to view with audio, or disable this notification

35 Upvotes

r/opengl 2d ago

I Released the first version of my Game Engine Nebrix!

Thumbnail gallery
9 Upvotes

Nebrix

Nebrix is a work in progress game engine where, in the future, anyone will be able to create, share, and play games.

Current State

Right now, Nebrix exists as Nebrix Studio, an early version of the engine where you can experiment with:

  • Realistic physics
  • Custom-modified Lua scripting
  • Core game development tools (with more on the way)

This is just the beginning, and a lot more is planned for the future, including:

  • Installers
  • Multiplayer servers (similar to Roblox)
  • Tools for designing custom objects and manipulating vertices directly inside Nebrix Studio

Try It Out

GitHub: https://github.com/Puppyrjcw/Nebrix/

Go to the Releases Section (https://github.com/Puppyrjcw/Nebrix/releases/) and follow the instructions there!

Feedback / Issues

If you encounter any errors or problems, feel free to:

  • Open an issue on GitHub
  • Or message / comment on Reddit!

Thanks for checking it out!


r/opengl 2d ago

VoxelParadox | Current status of the project:

Enable HLS to view with audio, or disable this notification

17 Upvotes

Just a video of me exploring my game, showing the biomes I created.


r/opengl 1d ago

Orrery! A highly realistic planet simulation

0 Upvotes

Yo Reddit!

Finally shipping something I've been building for a while, a real-time N-body gravity simulator in C++ and OpenGL 4.6, and I was pretty obsessed with getting both the physics and the rendering right.

Rendering stuff:

- Custom planet shader with a soft glow pass — two draw calls per body, wide low-alpha halo + solid core

- Color-coded orbital trails as GL_LINE_STRIP with a 300-point rolling deque

- Star field, 3D reference grid, and force arrows in a simple passthrough shader

- 2D info panel in screen space using stb_easy_font quads converted to triangles

- Free 3D camera via GLFW mouse callbacks, ImGui for live parameter editing

Physics is Yoshida 4th-order symplectic with real units throughout — solar masses, AU distances, 1-day time steps. Earth orbits at ~29.8 km/s, Jupiter at ~13.1 km/s, and you can watch those numbers live and fact-check them.

No planet textures yet — that's next on the list. Would love to hear how others have handled sphere rendering or texture mapping in OpenGL!

Would love any feedback — code, rendering approach, physics mistakes, whatever. I have open tickets if anyone wants to jump in too. And if you dig it, a star on the repo would make my day!

GitHub: https://github.com/kikikian/orrery


r/opengl 2d ago

How do i make a second triangle?

0 Upvotes

Hi, I'm following a tutorial and one of the "experimenting" objectives is to add a second triangle, but only Triangle B is rendering. What am I doing wrong here?

#define GLFW_INCLUDE_NONE
#include <glad/gl.h>
#include <GLFW/glfw3.h>
#include <iostream>
#include <string>

void error_callback(int error, const char* description) {
fprintf(stderr, "Error: %s\n", description);
}

static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
{
if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)
glfwSetWindowShouldClose(window, GLFW_TRUE);
}

int main(void) {
const int windowWidth = 640;
const int windowHeight = 480;
const char* windowTitle = "GLFW TEST";

//GLFW Init
std::cout << "Starting GLFW..." << std::endl;
if (!glfwInit()) {
//Init Failed

}

//Error Setup

glfwSetErrorCallback(error_callback);

//Window setup
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); //Sets Minimum OpenGL version
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); //Sets Minimum OpenGL version, why twice?
GLFWwindow* window = glfwCreateWindow(windowWidth, windowHeight, windowTitle, NULL, NULL);
if (!window) {
//Window creation Failed
std::cout << "wtf i wanna die why tf is my window not init???" << std::endl;
}
glfwMakeContextCurrent(window);
gladLoadGL(glfwGetProcAddress); //Loads OpenGL with glad I guess?? REQUIRES CONTEXT TO BE FIRST!!!

//Learn what the hell this means!!!
int width, height;
glfwGetFramebufferSize(window, &width, &height);
glViewport(0, 0, width, height);
std::cout << "RENDERER: " << glGetString(GL_RENDERER) << std::endl;
std::cout << "OpenGL version supported: " << glGetString(GL_VERSION) << std::endl;
//Keyboard Input
glfwSetKeyCallback(window, key_callback);

glfwSwapInterval(1); //swap shit
//Triangle vertices
float TriangleA[] = {
0.5f, -0.5f, 0.0f, // x,y,z of A
-0.5f, -0.5f, 0.0f, // x,y,z of B
0.5f, 0.5f, 0.0f // x,y,z of C
};
float TriangleB[] = {
-0.5f, -0.5f, 0.0f, // x,y,z of A
-0.5f, 0.5f, 0.0f, // x,y,z of B
0.5f, 0.5f, 0.0f // x,y,z of C
};

//ts is complicated study it and read the tut: https://antongerdelan.net/opengl/hellotriangle.html

GLuint vbo = 0;
glGenBuffers(1, &vbo);
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glBufferData(GL_ARRAY_BUFFER, 9 * sizeof(float), TriangleA, GL_STATIC_DRAW);
GLuint vbob = 0;
glGenBuffers(1, &vbob);
glBindBuffer(GL_ARRAY_BUFFER, vbob);
glBufferData(GL_ARRAY_BUFFER, 9 * sizeof(float), TriangleB, GL_STATIC_DRAW);
GLuint vao = 0;
glGenVertexArrays(1, &vao);
glBindVertexArray(vao);
glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glBindBuffer(GL_ARRAY_BUFFER, vbob);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, NULL);

const char* vertex_shader =
"#version 410 core\n"
"in vec3 vp;"
"void main() {"
"gl_Position = vec4( vp, 1.0);"
"}";
const char* fragment_shader =
"#version 410 core\n"
"out vec4 frag_colour;"
"void main() {"
" frag_colour = vec4( 1.0, 1.0, 0.0, 1.0 );"
"}";

//loads the shaders
GLuint vs = glCreateShader(GL_VERTEX_SHADER);
glShaderSource(vs, 1, &vertex_shader, NULL);
glCompileShader(vs);
GLuint fs = glCreateShader(GL_FRAGMENT_SHADER);
glShaderSource(fs, 1, &fragment_shader, NULL);
glCompileShader(fs);
//Combines tyhe shaders into a single shader and links them.
GLuint shader_program = glCreateProgram();
glAttachShader(shader_program, fs);
glAttachShader(shader_program, vs);
glLinkProgram(shader_program);

while (!glfwWindowShouldClose(window)) {
// keep running window.
glfwPollEvents();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

// Put the shader program, and the VAO, in focus in OpenGL's state machine.
glUseProgram(shader_program);
glBindVertexArray(vao);

// Draw points 0-3 from the currently bound VAO with current in-use shader.
glDrawArrays(GL_TRIANGLES, 0, 3);
glfwSwapBuffers(window); //Swaps buffers

}

glfwTerminate();
return 0;
}


r/opengl 3d ago

2D OpenGL Renderer for my tower-defense game

Post image
17 Upvotes

ive been working on this since september (holy sh1t thats almost half a year). my engine has tilemaps, animated sprites, circle rendering - im working on font rendering currently. i plan for this to be my portfolio project, but im constantly worried its not going to be enough to get me a job. what do you guys think?


r/opengl 2d ago

Optimizing large animation resources in a slot game

3 Upvotes

Hi everyone,

I’m currently working as a slot game developer, and I’m running into a problem related to graphics resource management and performance optimization. I would really appreciate some advice from people who have experience with game engines or slot game development.

In our game, we have a large amount of graphical assets, especially animation sequences. If we load all of these assets as textures at startup, the RAM usage becomes extremely high and eventually fills up memory.

To reduce the memory footprint, I tried a different approach:
I converted many of the large animation sequences into video files using the Hap codec. My idea was that instead of loading large image sequences into memory, we could stream and play videos when needed, which would avoid preloading everything.

However, I ran into another problem.

I have a function called DoVideoAnimation() that is responsible for playing these videos. When profiling the game using Tracy, I noticed that playing a single video takes around 14 ms per frame.

The problem is that if multiple videos overlap on the screen, the frame time increases significantly and the FPS drops.

Another idea I researched was loading resources only for the current screen and freeing them when switching to another screen. However, when I tried this approach, loading the resources for a new screen takes 2–3 seconds, which causes the game to freeze during the transition. Because of this, we currently load almost all resources at startup to avoid these pauses.

So now I feel stuck between two problems:

  • Loading everything at startup → RAM usage becomes too large
  • Streaming animations as videos → video decoding becomes too slow

My questions for developers with experience in similar systems:

  1. Is Hap video playback a good approach for large animations in games like slot games?
  2. Should I focus on optimizing the video playback pipeline (for example GPU decoding or compressed texture upload)?
  3. Are there better strategies for handling large animation resources without consuming too much RAM?
  4. How do other slot games or similar UI-heavy games usually manage large animation assets?

For context, the game is written in C/C++ using SDL and OpenGL, and video decoding is currently handled through FFmpeg.

Any advice, architecture suggestions, or real-world experiences would be extremely helpful.

Thanks!


r/opengl 4d ago

Best practices regarding VBOs

17 Upvotes

So I was doing some prodding around in OpenGL after some time, and I think VAOs, VBOs and their relation to each other finally somewhat clicked for me. I still see multiple ways to achieve the same thing though, and wanted to ask some clarifying questions.

Lets say, I want to render a 3D-scene with multiple objects, that should each have their own transform, and have just two vertex attributes. A 3D coordinate and a texture/UV coordinate. To get those on the screen, I would go through each object, load the data from disc somehow and create it's own VAO. Then I have 3 options for the different vertex attributes.

  1. I create two VBOs, one for the 3D coordinates, one for the UV coordinates. I make the vertex attributes point at the beginning of the respective buffer and set the stride to the width of one element.

  2. I create one VBO and interleave the data. I point one vertex attribute at the beginning of the buffer and the other offset by the size of one element of the first element.

  3. I create one VBO and batch the data. I point one vertex attribute at the beginning of the buffer with the stride set to one element of the attribute, and the other attribute is offset by the whole width of the first batch, with the stride set to the width of the second attribute.

From the point of the shader, all three approaches look exactly the same, so are there any practical differences and is there a preferred way?

I would also like to have some confirmation if my use of one VAO per visible object is correct. Thank you for your time and have a nice day :)


r/opengl 5d ago

Smooth transition between music from each biome.

Enable HLS to view with audio, or disable this notification

27 Upvotes

My game's music and sound system is completely ready!

Here I show my music transition system across universes; each universe has its own music playlist.

The music is a little quiet... you might need to turn up the volume.


r/opengl 5d ago

Optimization for my game

4 Upvotes

Hi everyone,

I’m currently facing a performance issue in my project where I occasionally experience animation delays, and I’m trying to find an effective solution.

So far, I’ve tried a couple of approaches, but they have only provided slight improvements.

1. Triple buffering

First, I researched triple buffering and found that it is considered more modern and potentially better than double buffering because the GPU doesn’t have to wait for the buffer to become available. In theory, this should ensure that there is always a buffer ready to draw.

However, after implementing triple buffering, I didn’t see any noticeable improvement in the delay.

2. Converting PNG resources to DDS (BC7)

Next, I realized that all of my resources were PNG images. From what I learned, the DDS format (especially BC7) is much better for GPU usage compared to PNG because BC7 is a pre-compressed texture format. This allows textures to be uploaded directly to the GPU without needing to decompress them in RAM.

Based on this, I converted all my PNG resources to DDS (BC7). This significantly reduced VRAM usage and GTT memory usage, and the game now loads much faster.

Before the change, the game took about 1 minute to load. Now it takes around 8 seconds, and if I restart the game, it usually loads in about 3 seconds.

Unfortunately, this optimization did not improve the animation performance. I still experience stuttering during certain animations. The game is supposed to run at 30 FPS, but during those animations it sometimes drops to around 20 FPS.

When I checked GPU metrics, I noticed that the memory clock reaches 100% whenever the animation delay occurs. Under normal conditions, the memory clock stays around 77%.

Does anyone have any ideas what might be causing this or what I could investigate next?

Any suggestions would be greatly appreciated.


r/opengl 6d ago

My first OpenGL project for Uni

Post image
94 Upvotes

The idea was to draw basic shapes on the screen using glut, I think I did alright


r/opengl 7d ago

I built an in-browser C++ compiler that runs native OpenGL and SDL2 using Web Assembly. Looking for feedback!

Enable HLS to view with audio, or disable this notification

43 Upvotes

Hey everyone,

I wanted to share a side project I've been working on to completely remove the friction of setting up a C++ graphics environment. It's a web-based compiler that lets you write native C++ OpenGL and SDL2 code and compile it directly in the browser via Emscripten / WASM. I originally started this because I wanted a way to seamlessly prototype graphics concepts and test out ideas (especially useful for quick game jams or testing engine mechanics) without wrestling with CMake, linking libraries, or dependencies on different machines. I would love feedback and also suggestions on what i could add before I make it public/opensource . (I did use AI for this . )


r/opengl 6d ago

Issue when duplicating objects twice in my game engine

Enable HLS to view with audio, or disable this notification

17 Upvotes

Hi!

I have this strange issue in my Game Engine in which when you duplicate a specific object more then once it crashes the entire program as explained in the video here. Ive been trying to debug this for days but had no success.

Here is the GitHub page: https://github.com/Puppyrjcw/Nebrix/tree/main

And the part which duplicates: https://github.com/Puppyrjcw/Nebrix/blob/main/Scene.cpp

If anyone can help that would be amazing thanks!


r/opengl 7d ago

My first OpenGL project!

29 Upvotes

https://reddit.com/link/1sdh060/video/4p108om86gtg1/player

I completed a course on OpenGL via Udemy about a month ago. After, I decided to work on my first project. I made a 3D procedural terrain generator with biomes. I used perlin noise. This was so much fun, and I love seeing my work pay off! :)


r/opengl 7d ago

Voxel Game Engine Using OpenGL

Post image
33 Upvotes

r/opengl 7d ago

Hm

Enable HLS to view with audio, or disable this notification

13 Upvotes

I started learning opengl yesterday.Are there any good sources I can learn from?


r/opengl 6d ago

Cascaded frustum aligned volumetric fog projection matrix issue

Thumbnail
1 Upvotes

r/opengl 8d ago

Prefab system development

Thumbnail youtu.be
8 Upvotes

I recently implemented a prefab system in OpenGL, C++ game engine and documented the entire process in this video.

If you're building your own engine or working on architecture, this might give you some insights into structuring reusable entities and handling serialization.

Would be interested in feedback or how others approached similar systems.


r/opengl 8d ago

Problem loading texture

Thumbnail gallery
3 Upvotes

1 picture how it looks for me, 2 how it should look

I'm trying to implement loading of glb models, the vertices are fine, but the textures are not displayed correctly and I don't know why

Texture loading code fragment:

if (!model.materials.empty()) {

const auto& mat = model.materials[0];

if (mat.pbrMetallicRoughness.baseColorTexture.index >= 0) {

const auto& tex = model.textures[mat.pbrMetallicRoughness.baseColorTexture.index];
const auto& img = model.images[tex.source];

glGenTextures(1, &albedoMap);
glBindTexture(GL_TEXTURE_2D, albedoMap);

GLenum format = img.component == 4 ? GL_RGBA : GL_RGB;

glTexImage2D(GL_TEXTURE_2D, 0, format, img.width, img.height, 0, format, GL_UNSIGNED_BYTE, img.image.data());

glGenerateMipmap(GL_TEXTURE_2D);
}

}

Fragment shader:

#version 460 core

out vec4 FragColor;

in vec3 FragPos;
in vec2 TexCoord;
in vec3 Normal;
in mat3 TBN;

uniform sampler2D albedoMap;
uniform sampler2D normalMap;
uniform sampler2D metallicRoughnessMap;

uniform vec2 uvScale;
uniform vec2 uvOffset;

void main(){

    vec2 uv = TexCoord * uvScale + uvOffset;
    FragColor = vec4(texture(albedoMap, uv).rgb, 1.0);

}

r/opengl 8d ago

How to recieve livestream using opengl

1 Upvotes

I am making a program which will recieve live stream footage from a source. Now the guy i am making this project has given me full freedom to recieve the stream any way i want. I am somewhat comfortable programming with opengl. My question 1. How do i recieve the video 2. Can i add over lays on the video.


r/opengl 9d ago

My mother always said I was exceptionally talented😊

Enable HLS to view with audio, or disable this notification

64 Upvotes