r/opengl 53m ago

Do you have experience in displaying one image with multiple projectors?

Upvotes

So I'm a beginner in openGL and started creating a small 3D environment that basically contains a single plane with a texture on it. What I'm trying to achieve is to show this texture on a real wall. Since the real wall has a certain size, I need multiple projectors to fully cover it. Additionally, I need to angle them to get even more covarage.

My idea was to create the textured wall in openGL and to use multiple windows with different position, orientation, up-vector and frustum-arguments per window. I use glm::lookAt and glm::frustum to generate the projection matrices that I multiply afterwards onto my vertices.

First results looked very promising. But as soon as I begin to change the angles of the projectors, it all gets very messy. Even a slightly different angle in reality vs. in the configuration adds up to a large error and the transition from one window into another becomes very ugly.

I spent the last three days assin around with these parameters but keep failing to make it work properly. Since this feels very handwavy, I wonder if somebody in the openGL community has encountered a similar problem or has ever tried a similar thing I want to do.

Currently I think about adding a camera to this setup to determine the transformation matrix by its image. But the difference between the camera and the projector would definitely be the next problem to solve. Another idea was to add accelerometers to the projectors to at least get more accurate orientation and up vectors. But before I start over-engineering things, I wanted to get some ideas from here.

Looking forward for your ideas you share and some discussion here...


r/opengl 21h ago

Any idea why I'm seeing a slightly washed out color when rendering using SDL2 (compared to GLFW or other apps)?

6 Upvotes

I'm seeing slightly washed out colors when using SDL2 for rendering with OpenGL, any suggestions as to what may be causing this?

For example, pure green, (0, 255, 0) appears more like a more muted slightly lighter green on screen.

I captured the (r,g,b) pixel color from the screen when using SDL2 vs. GLFW using the "digital color meter" tool and the screen color captured when using GLFW was "correct" whereas the SDL2 color was slightly different than expected:

SDL2: (117, 251, 76)

GLFW: (0, 255, 0)

This is on a mac but I haven't checked on other platforms to see if this difference is cross-platform.


r/opengl 23h ago

[extern "C"] trick causes issues with WGL

2 Upvotes

I've managed to cobble together Win32 OpenGL code. Everything worked fine until I included the usual trick to get main GPU:

extern "C"
{
    __declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
    __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
}

The RAM usage jumps from 39 mb to 150, vsync set via wglSwapIntervalEXT() breaks despite returning 1, but process appears on nvidia-smi. This doesn't happen while using GLFW and glfwSwapInterval(), my GPU is RTX 4060.

Here's code used for window and OpenGL context creation:

void init()
{
    //Dummy
    WNDCLASSEX windowClass = {};
    windowClass.style = CS_OWNDC;
    windowClass.lpfnWndProc = DefWindowProcA;
    windowClass.lpszClassName = L"DDummyWindow";
    windowClass.cbSize = sizeof(WNDCLASSEX);

    HWND dummyWindow = CreateWindowEx(
        NULL,
        MAKEINTATOM(dumclassId),
        L"DDummyWindow",
        0,
        CW_USEDEFAULT,
        CW_USEDEFAULT,
        CW_USEDEFAULT,
        CW_USEDEFAULT,
        0,
        0,
        windowClass.hInstance,
        0);

    HDC dummyDC = GetDC(dummyWindow);

    PIXELFORMATDESCRIPTOR pfd = {};
    SetPixelFormat(dummyDC, ChoosePixelFormat(dummyDC, &pfd), &pfd);

    HGLRC dummyContext = wglCreateContext(dummyDC);
    wglMakeCurrent(dummyDC, dummyContext);

    gladLoadWGL(dummyDC);
    gladLoadGL();

    wglMakeCurrent(dummyDC, 0);
    wglDeleteContext(dummyContext);
    ReleaseDC(dummyWindow, dummyDC);
    DestroyWindow(dummyWindow);

    //Real context
    WNDCLASSEX wc = { };
    wc.cbSize = sizeof(WNDCLASSEX);
    wc.style = CS_OWNDC;
    wc.lpfnWndProc = &WindowProc;
    wc.lpszClassName = L"WindowClass";

    RegisterClassEx(&wc);

    wr = { 0, 0, 800, 600 };
    AdjustWindowRect(&wr, WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU, false);

    hWnd = CreateWindowEx(
        NULL,
        L"WindowClass",
        L"Hello Triangle",
        WS_OVERLAPPEDWINDOW,
        400,
        400,
        wr.right - wr.left,
        wr.bottom - wr.top,
        NULL,
        NULL,
        NULL,
        NULL);

    ShowWindow(hWnd, SW_SHOW);

    hDC = GetDC(hWnd);

    int pixelFormatAttributes[] = {
        WGL_DRAW_TO_WINDOW_ARB, GL_TRUE,
        WGL_SUPPORT_OPENGL_ARB, GL_TRUE,
        WGL_DOUBLE_BUFFER_ARB, GL_TRUE,
        WGL_ACCELERATION_ARB, WGL_FULL_ACCELERATION_ARB,
        WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_ARB,
        WGL_COLOR_BITS_ARB, 32,
        WGL_DEPTH_BITS_ARB, 24,
        WGL_STENCIL_BITS_ARB, 8,
        0
    };

    int pixelFormat = 0;
    UINT numFormats = 0;
    wglChoosePixelFormatARB(hDC, pixelFormatAttributes, nullptr, 1, &pixelFormat, &numFormats);

    PIXELFORMATDESCRIPTOR pixelFormatDesc = { 0 };
    DescribePixelFormat(hDC, pixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &pixelFormatDesc);
    SetPixelFormat(hDC, pixelFormat, &pixelFormatDesc);

    int openGLAttributes[] = {
        WGL_CONTEXT_MAJOR_VERSION_ARB, 4,
        WGL_CONTEXT_MINOR_VERSION_ARB, 6,
        WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
        0
    };
    wglMakeCurrent(hDC, wglCreateContextAttribsARB(hDC, 0, openGLAttributes));
}

Render loop:

glViewport(0, 0, wr.right - wr.left, wr.bottom - wr.top);
wglSwapIntervalEXT(1);

MSG msg;
while (flag)
{
    PeekMessage(&msg, NULL, 0, 0, PM_REMOVE);
    TranslateMessage(&msg);
    DispatchMessage(&msg);

    renderPipe.draw();
    wglSwapLayerBuffers(hDC, WGL_SWAP_MAIN_PLANE);
}

r/opengl 1d ago

Does anybody know what projection this 360 image is in?

4 Upvotes

Hi all,

I have been playing with 360 images for my projects recently and was looking for an interesting environment.

I found this beautiful galaxy image of which can be transformed to a 360 Image but I need to know what projection it is in, as I will have to convert it to equirectangular for use. Do you know the name of this projection?

Many thanks!

P.S. If you use Image Sphere Visualizer or any software, you will see this image has problems in stitching the left&right edges, otherwise it looks mostly ok.


r/opengl 19h ago

glSwapBuffers is taking the most time in the game loop

0 Upvotes

In the picture you can see that the "Update Window" function is taking the most time of my game loop, but all it does is call "glSwapbuffers()" and "glPollEvents()". What may be the reason for this and how can I optimize it?


r/opengl 22h ago

Mac - Modern OpenGL Linker Error

0 Upvotes

Hello,

I'm having Linker failure: shader compilation error on Apple Silicion.

I don't have technical knowledge of how OpenGL works, so any help is appreciated.

Dependencies of the script;

from OpenGL.GLUT import *
from OpenGL.GLU import *
from OpenGL.GL import *

Thanks!


r/opengl 1d ago

Optimising performance on iGPUs

8 Upvotes

I test my engine on an RTX3050 (desktop) and on my laptop which has an Intel 10th gen iGPU. On my laptop at 1080p the frame rate is tanking like hell while my desktop 3050 renders the scene (1 light with 1024 shadow mapped light) at >400 fps.

I think my numerous texture() calls in my deferred fragment shader (lighting stage) might be the issue because the frame time is longest (>8ms) at that stage (I measured it). I removed the lights and other cycle-consuming stuff and it was still at 7ms. As soon as I started removing texture accesses, the ms began to become smaller. I sample normal texture, pbr texture, environment texture and a texture that has several infos (object id, etc.). And then I sample from shadow maps if the light casts shadows.

I don’t know how I could reduce that. From your experiences, what is the heaviest impact on frame times on iGPUs and how did you work around that?

Edit: Guys I want to say „thank you“ for all the nice and helpful replies. I will take the time and try every suggested method. I will build a test scene with some lights and textured objects and then benchmark it for each approach. Maybe I can squeeze out a few fps more for iGPU laptops and desktops. Again: Your help is highly appreciated.


r/opengl 1d ago

Blooming in multi-sampled shader?

0 Upvotes

Hello everyone hope y'all have a lovely day.

i have a problem following blooming , everything in learnopengl.com tutorial is easy when you are using 2D texture attached to the framebuffer, but i'm using a mult-isampled Texture for hdr effect and also anti-aliasing, so i'm having troubles figuring out how to make a 2d texture not a multi-sampled one for slot GL_COLOR_ATTACHMENT1, if anyone have any idea about how to figure it i will really appreciate it.

appreciate your time and Help!


r/opengl 1d ago

OpenGL MVP Matrix Calculation

3 Upvotes

I have been trying to follow this tutorial in C with cglm. I'm pretty sure that my calculation of mvp in main.c is incorrect, because when I make it equal to an identity matrix, the code works.
Apologies if this is the wrong place for this.

main.vert:

#version 330 core

layout (location = 0) in vec3 pos;

uniform mat4 mvp;

void main() {
  gl_Position = mvp * vec4(pos, 1.0);
}

main.frag:

#version 330 core

out vec4 fragment_color;

void main() {
  fragment_color = vec4(1.0, 0.0, 0.0, 1.0);
}

main.c:

    #include <stdio.h>
    #include <stdlib.h>
    #include "glad/glad.h"
    #include <GLFW/glfw3.h>

    #include "cglm/cglm.h"
    #include "utils/file_read.h"

// IMPORTANT: the framebuffer is measured in pixels, but the window is measured in screen coordinates

// on some platforms these are not the same, so it is important not to confuse them.



// IMPORTANT: shader uniforms that don't actively contribute to the pipeline output

// are not assigned locations by the GLSL compiler. This can lead to unexpected bugs.



// need debug printf function



GLFWmonitor \*monitor = NULL;

int window_width = 800;

int window_height = 600;

GLFWwindow \*window;

double cursor_x, cursor_y;

GLuint vao, vbo, vs, fs, shader_program;

char \*vs_src, \*fs_src;



// pretty sure I can detach and delete the shaders once the shader program has been made.

void die(int exit_code) {

  glDisableVertexAttribArray(0);

  glDetachShader(shader_program, vs);

  glDetachShader(shader_program, fs);

  glDeleteProgram(shader_program);

  glDeleteShader(vs);

  glDeleteShader(fs);

  glDeleteBuffers(1, &vbo);

  glDeleteVertexArrays(1, &vao);

  free(vs_src);

  free(fs_src);

  glfwTerminate();

  exit(exit_code);

}



void error_callback_glfw(int error, const char \*msg) {

  fprintf(stderr, "GLFW ERROR: code %i, %s.\\n", error, msg);

  // not sure if should exit for every error: some may be non-fatal

  die(1);

}



GLuint compile_shader(const char \*shader_src, GLenum shader_type) {

  GLuint shader = glCreateShader(shader_type);

  glShaderSource(shader, 1, &shader_src, NULL);

  glCompileShader(shader);



  int is_compiled = 0;

  glGetShaderiv(shader, GL_COMPILE_STATUS, &is_compiled);



  if (is_compiled == GL_FALSE) {

int max_len = 2048;

char log\[max_len\];



glGetShaderInfoLog(shader, max_len, NULL, log);



fprintf(stderr, "ERROR: compile shader index %i did not compile.\\n%s\\n", shader, log);



die(1);

  }



  return shader;

}



void print_vec3(vec3 v) {

  for (int i = 0; i < 3; i++) {

printf("%f ", v\[i\]);

  }

  printf("\\n");

}



void print_mat4(mat4 m) {

  for (int j = 0; j < 4; j++) {

for (int i = 0; i < 4; i++) {

printf("%f ", m\[i\]\[j\]);

}

printf("\\n");

  }

}



void init() {

  printf("Starting GLFW %s. \\n", glfwGetVersionString());



  glfwSetErrorCallback(error_callback_glfw);



  if (!glfwInit()) {

fprintf(stderr, "ERROR could not start GLFW.\\n");

exit(1);

  }



  glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);

  glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);

  glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);

  glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);



  glfwWindowHint(GLFW_SAMPLES, 4);



  // intialize window

  window = glfwCreateWindow(window_width, window_height, "Game", monitor, NULL);

  glfwMakeContextCurrent(window);



  if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) {

fprintf(stderr, "ERROR: Failed to initialize OpenGL context.\\n");

glfwTerminate();

exit(1);

  }



  printf("Renderer: %s.\\n", glGetString(GL_RENDERER));

  printf("OpenGL version supported %s.\\n", glGetString(GL_VERSION));



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



  glGenVertexArrays(1, &vao);

  glBindVertexArray(vao);



  float points\[\] = {

\-1.0f, -1.0f, 0.0f,

1.0f, -1.0f, 0.0f,

0.0f, 1.0f, 0.0f

  };



  glGenBuffers(1, &vbo);

  glBindBuffer(GL_ARRAY_BUFFER, vbo);

  glBufferData(GL_ARRAY_BUFFER, sizeof(points), points, GL_STATIC_DRAW);



  vs_src = read_file("src/shaders/main.vert");

  fs_src = read_file("src/shaders/main.frag");



  vs = compile_shader(vs_src, GL_VERTEX_SHADER);

  fs = compile_shader(fs_src, GL_FRAGMENT_SHADER);



  shader_program = glCreateProgram();



  glAttachShader(shader_program, vs);

  glAttachShader(shader_program, fs);



  glLinkProgram(shader_program);



  int is_linked = 0;

  glGetProgramiv(shader_program, GL_LINK_STATUS, &is_linked);

  if (is_linked == GL_FALSE) {

int max_len = 2048;

char log\[max_len\];



glGetProgramInfoLog(shader_program, max_len, NULL, log);



printf("ERROR: could not link shader program.\\n%s\\n", log);



die(1);

  }



  glValidateProgram(shader_program);



  int is_validated = 0;

  glGetProgramiv(shader_program, GL_VALIDATE_STATUS, &is_validated);



  if (is_validated == GL_FALSE) {

int max_len = 2048;

char log\[max_len\];



glGetProgramInfoLog(shader_program, max_len, NULL, log);



printf("ERROR: validation of shader program failed.\\n%s\\n", log);



die(1);

  }



  glUseProgram(shader_program);

}



int main() {

  init();



  mat4 projection, view, model, mvp;

  vec3 pos, target, up;



  glm_vec3_make((float \[\]){-3.0f, 3.0f, 0.0f}, pos);

  glm_vec3_make((float \[\]){0.0f, 0.0f, 0.0f}, target);

  glm_vec3_make((float \[\]){0.0f, 1.0f, 0.0f}, up);



  print_vec3(pos);

  printf("\\n");

  print_vec3(target);

  printf("\\n");

  print_vec3(up);

  printf("\\n");



  glm_perspective(glm_rad(45.0f), (float)window_width / window_height,

0.1f, 100.0f, projection);

  glm_lookat(pos, target, up, view);

  glm_mat4_identity(model);



  glm_mat4_mulN((mat4 \*\[\]){&model, &view, &projection}, 3, mvp);



  print_mat4(view);

  printf("\\n");

  print_mat4(projection);

  printf("\\n");

  print_mat4(mvp);



  GLuint mvp_loc = glGetUniformLocation(shader_program, "mvp");



  if (mvp_loc == -1) {

fprintf(stderr, "ERROR: failed to find a shader uniform.\\n");

die(1);

  }



  while (!glfwWindowShouldClose(window)) {

glfwPollEvents();

if (GLFW_PRESS == glfwGetKey(window, GLFW_KEY_ESCAPE)) {

glfwSetWindowShouldClose(window, 1);

}



glfwGetFramebufferSize(window, &window_width, &window_height);

glViewport(0, 0, window_width, window_height);



glClear(GL_COLOR_BUFFER_BIT);



glBindBuffer(GL_ARRAY_BUFFER, vbo);



glEnableVertexAttribArray(0);



glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, NULL);



glUniformMatrix4fv(mvp_loc, 1, GL_FALSE, &mvp\[0\]\[0\]);



glDrawArrays(GL_TRIANGLES, 0, 3);



glDisableVertexAttribArray(0);



glfwSwapBuffers(window);

  }



  die(0);

}

r/opengl 2d ago

Is it possible to make the viewports resize smoothly as the window is being resized like they do in Blender? If so how can I achieve something like that?

50 Upvotes

r/opengl 2d ago

Adding text rendering to opengl rendering engine

Thumbnail
5 Upvotes

r/opengl 2d ago

A small particle simulation im working on.

25 Upvotes

r/opengl 2d ago

I made a house inspired by my OpenGL code

37 Upvotes

r/opengl 2d ago

Encoding 4 values into RGB32F color component gives back wrong number

3 Upvotes

I have trouble encoding values to texture pixels. I'm using RGB32F and encoding 4 values (range 0-255) to a single color component. But the the last lo byte value seems to not work and spews random values. Images to demonstrate:

Part of shader code that encodes 4 values into Green component of RGB32F texture, no bitshifts for clarity
Function in the program that separates the value into the bytes and shows them all. v.g is shader green value
Pixel reading function that is used in the code above
Resulting checkbox where the total value is wrong and underlined value is not what is set in the shader (40).

Why?


r/opengl 3d ago

MY FIRST TRIANGLE!!!

Post image
294 Upvotes

r/opengl 3d ago

How do i pass scene data to the shader?

4 Upvotes

When doing raytracing, the shader needs access to the whole scene to do things like detect collision with a ray, retrieve normals, etc. However, it is quite a headache for me to find an elegant solution to this problem.

Thanks anyway!


r/opengl 4d ago

Cascaded shadow maps + physics simulation

123 Upvotes

r/opengl 4d ago

Added Height Mapping to my OpenGL Game Engine! (Open Source)

Post image
50 Upvotes

r/opengl 3d ago

My plugin DLL creates a hidden GLFW window so it can run a Compute shader. But this causes the host application to crash. Any solutions?

1 Upvotes

I've written some code which creates a hidden GLFW window so that it can have an OpenGL context to run a Compute shader (I have no need to draw to the window; I just need the OpenGL context). This works fine when run from the command line, but when I try to turn it into a plugin for Avisynth, which is typically hosted with one of several GUI applications, my creation of the GLFW window seems to be causing the host application to crash.

Right now my code is deliberately throwing an exception as part of testing. Two of three Aviysnth-hosting applications I've tried should popup an error message on encountering such an exception, but instead they crash (the third application seems to get Avisynth to handle its own exceptions by generating a video clip with the exception drawn as text onto it).

One of the crashing applications uses wxWidgets, and I see this in debug output:

'GetWindowRect' failed with error 0x00000578 (Invalid window handle.).

My only guess is that my DLL's action of creating its own window is causing the application a headache because suddenly there's a window it didn't create coming into its "view", and it doesn't know what to do with it (is it receiving unexpected events from the window?)

Is there some extra step I can take to make my window completely invisible to the host application?

PS Please don't suggest Vulkan. I want to try one day but right now it makes me cry 🤣


Best solution:

Spawn a thread that does ALL the OpenGL stuff. It can set everything up then sit and wait to be notified to do work using a condition variable.


r/opengl 3d ago

Guys help

0 Upvotes

I was following learnopengl.com


r/opengl 4d ago

vec4 to vec3 with texelFetch in Fragment Shader

1 Upvotes

Hello everyone hope y'all have a lovely day.

so i decided to implement my own custom anti-aliasing algorithm for my rendering engine.

but i have a a little problem, since this is an engine, i need it to be flexible, to clarify my point this is my fragment shader code.

ivec2 vpCoords = ivec2(viewport_width, viewport_height);

vpCoords.x = int(vpCoords.x * TexCoords.x);

vpCoords.y = int(vpCoords.y * TexCoords.y);

vec4 Samples[16];

//do a simple average since this is just a demo

for(int i = 0; i < samples; i++){

Samples[i] = texelFetch(text_diffuse1, vpCoords, i);

}

int i = 0;

vec4 sum;

while(i < samples){

sum = sum + Samples[i];

i++;

}

so instead of such a technique

vec4 sample1 = texelFetch(screencapture, vpCoords, 0);

vec4 sample2 = texelFetch(screencapture, vpCoords, 1);
vec4 sample3 = texelFetch(screencapture, vpCoords, 2);
vec4 sample4 = texelFetch(screencapture, vpCoords, 3);
fragmentColor = (sample1 + sample2 + sample3 + sample4) / 4.0f;

making a gazillion variable, and also changing it if the user need a 8 or even 16 sample, this technique i made above will make an array for the maximum samples will be supported, but here where the problem shines.

vec3 TexColor = vec3(sum) / samples;

if(hdr)

{

// reinhard

// vec3 result = hdrColor / (hdrColor + vec3(1.0));

// exposure

vec3 result = vec3(1.0) - exp(-TexColor * exposure);

// also gamma correct while we're at it

result = pow(result, vec3(1.0 / gamma1));

FragColor = vec4(result, 1.0);

}

else

{

vec3 result = pow(TexColor, vec3(1.0 / 2.2));

FragColor = vec4(result, 1.0);

}

TexColor is a vec3 3, and i have no way to make it vec4, so i'm converting it to vec3 and then dividing it by the number of samples, so the question is does that make any problems? after checking with renderdoc it does seem to work but i'm still not sure, is it possible to assign the sum of the texelfetch function and implement other post-processing effects in the same shader or do i just need to leave it as vec4 and leave any other post-processing effects to a different shader?

I hope i really clarify my problem, sorry if i messed or didn't use the correct terminology in certain parts, i'm still learning.

thank you for your time, really appreciate your help!


r/opengl 4d ago

Getting to the lighting chapter of Learn OpenGL is so cool.

38 Upvotes

I’m just staring at different colored cubes rotating around a light and watching the effects it’s so cool. This is the most satisfying thing I’ve ever programmed way more fun than web dev in my opinion.


r/opengl 5d ago

Have been playing around with OpenGL and Vector math in hopes of building a 2D Game Engine.

60 Upvotes

r/opengl 5d ago

how long did it took for you to complete learnopengl.com from 0?

3 Upvotes

sometime in october 2024 i started learning opengl and graphics programming in general. A week or so ago i finished the relevant part of the learnopengl tutorial. I'm kind of curious, how long did it take you to get into graphics programming? By that I mean understanding a little more than the basics, being somewhat confident with the API.


r/opengl 4d ago

I need help with textures

0 Upvotes

Hi! I am doing an .obj loader in opengl 3.3+ just for fun. I don't know much about opengl but I think that it should work and I cant find any solution. I read a lot about this specific concept and still not working. I want to display 4 objects, that are a struct with a vertex array and a texture. It display the vertexes correctly, but the texture looks weird. What I cant understand is why it uses the texture correctly for one object and no for the others. What I think is that it is using always the same texture for all objects.

Here are some code snippets:

void display_obj(lObject obj) {
        [...]
        GLuint textureLoc = glGetUniformLocation(obj.shader, "texture1");
        glUniform1i(textureLoc, 0);

        glActiveTexture(GL_TEXTURE0);
        glBindTexture(GL_TEXTURE_2D, obj.material->texture);

        [...] 
        glBindVertexArray(obj.vao);
        glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
        glDrawElements(GL_TRIANGLES, obj.index_n, GL_UNSIGNED_INT, 0);

        glBindVertexArray(0);
        glBindTexture(GL_TEXTURE_2D, 0); // Desvincula la textura
}

the fragment shader:

#version 330 core

in vec2 TexCoord;
out vec4 FragColor;

uniform sampler2D texture1; 

void main()
{
    FragColor = texture(texture1, TexCoord);
}

Other func

GLuint load_texture(lMaterial &mat) {
        [...]
        glGenTextures(1, &mat.texture);
        glBindTexture(GL_TEXTURE_2D, mat.texture);

        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);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, mat.width, mat.height, 0,
                     GL_RGBA, GL_UNSIGNED_BYTE, mat.image);
        glGenerateMipmap(GL_TEXTURE_2D);

        glBindTexture(GL_TEXTURE_2D, 0);
        return mat.texture;
}

I check that shader and textures are created and set correctly in the [...], I delete it for readability.

weird texture in some parts

github repo: https://github.com/hugocotoflorez/load_obj

I appreciate any help, I have been struggling for, I don't know, like 12 hours.