-1

The program only renders the framebuffer with Nvidia graphic cards. I have tested the same release with AMD and Intel, and it shows black.

I create the framebuffer:

enum FBOIDS
{
    FBO,
    FBO_MS,
    TEXTURE,
    TEXTURE_MS,
    RBO,
    RBO_MS
};
unsigned int ID[6];

glGenFramebuffers(1, &ID[FBO_MS]);
glBindFramebuffer(GL_FRAMEBUFFER, ID[FBO_MS]);

// generate texture
glGenTextures(1, &ID[TEXTURE_MS]);
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, ID[TEXTURE_MS]);
glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, smaa, GL_RGBA, 1, 1, GL_TRUE);
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, 0);

// attach it to currently bound framebuffer object
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D_MULTISAMPLE, ID[TEXTURE_MS], 0);

glGenRenderbuffers(1, &ID[RBO_MS]);
glBindRenderbuffer(GL_RENDERBUFFER, ID[RBO_MS]);
glRenderbufferStorageMultisample(GL_RENDERBUFFER, smaa, GL_DEPTH24_STENCIL8, 1, 1);
glBindRenderbuffer(GL_RENDERBUFFER, 0);

glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, ID[RBO_MS]);

//========================================================================

glGenFramebuffers(1, &ID[FBO]);
glBindFramebuffer(GL_FRAMEBUFFER, ID[FBO]);

// generate texture
glGenTextures(1, &ID[TEXTURE]);
glBindTexture(GL_TEXTURE_2D, ID[TEXTURE]);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glBindTexture(GL_TEXTURE_2D, 0);

glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, ID[TEXTURE], 0);

glGenRenderbuffers(1, &ID[RBO]);
glBindRenderbuffer(GL_RENDERBUFFER, ID[RBO]);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 1, 1);
glBindRenderbuffer(GL_RENDERBUFFER, 0);

glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, ID[RBO]);

And I draw it like that:

// =========================================
//=== Update tex
glBindFramebuffer(GL_FRAMEBUFFER, ID[FBO_MS]);

glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, ID[TEXTURE_MS]);
glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, smaa, GL_RGB8, size.x, size.y, GL_TRUE);
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, 0);

// attach it to currently bound framebuffer object
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D_MULTISAMPLE, ID[TEXTURE_MS], 0);

glBindRenderbuffer(GL_RENDERBUFFER, ID[RBO_MS]);
glRenderbufferStorageMultisample(GL_RENDERBUFFER, smaa, GL_DEPTH24_STENCIL8, size.x, size.y);
glBindRenderbuffer(GL_RENDERBUFFER, 0);

glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, ID[RBO_MS]);

//========================================================================

glBindFramebuffer(GL_FRAMEBUFFER, ID[FBO]);

// generate texture
glBindTexture(GL_TEXTURE_2D, ID[TEXTURE]);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, size.x, size.y, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
glBindTexture(GL_TEXTURE_2D, 0);

glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, ID[TEXTURE], 0);

glBindRenderbuffer(GL_RENDERBUFFER, ID[RBO]);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, size.x, size.y);
glBindRenderbuffer(GL_RENDERBUFFER, 0);

glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, ID[RBO]);

glBindFramebuffer(GL_FRAMEBUFFER, ID[FBO_MS]);

glBindFramebuffer(GL_READ_FRAMEBUFFER, ID[FBO_MS]);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, ID[FBO]);
glBlitFramebuffer(0, 0, size.x, size.y, 0, 0, size.x, size.y, GL_COLOR_BUFFER_BIT, GL_NEAREST);

glBindFramebuffer(GL_FRAMEBUFFER, 0);

A link to the Github issue with images: https://github.com/christt105/Elit3D/issues/40

Program on AMD or Intel HD Graphics Program on Nvidia

genpfault
  • 51,148
  • 11
  • 85
  • 139
  • 2
    `GL_RGB` is not a required image format for color buffers. (See [Required formats](https://www.khronos.org/opengl/wiki/Image_Format#Required_formats)). Use `GL_RGBA` instead. – Rabbid76 May 26 '21 at 14:43
  • Possible the issue is related to the format of the depth buffer. Try `GL_DEPTH32_STENCIL8` (AMD) – Rabbid76 Jun 07 '21 at 11:38
  • The problem is fixed. The problem was that I set more samples that the GPU can afford. I have used `glGetIntegerv(GL_MAX_SAMPLES, &maxSamples);` to get the max number of samples. Thank you so much for your answers and your time! – christt105 Jun 07 '21 at 19:10
  • Please answer the question yourself. Your last comment is the answer. Just copy it to an answer. – Rabbid76 Jun 07 '21 at 19:13

1 Answers1

0

The problem is fixed. The problem was that I set more samples that the GPU can afford. I have used glGetIntegerv(GL_MAX_SAMPLES, &maxSamples); to get the max number of samples.