0

I am trying to display an image in full window using two simple GLSL shaders:

Vertex Shader:

#version 330

layout (location = 0) in vec3 aPos;
layout (location = 1) in vec2 aTexCoord;

out vec3 ourColor;
out vec2 TexCoord;

void main()
{
    TexCoord = aTexCoord;
    gl_Position = vec4(aPos, 1.0);
}

and fragment shader:

#version 330

uniform sampler2D tex0; // loading the texture here

in vec3 TexCoord; // texture coordinates
out vec4 fColor; // fragment shader output

void main(){
   fColor = texture2D(tex0,TexCoord);
}

In the OpenGL code, during OpenGL properties setting, I perform

glEnable(GL_MULTISAMPLE);

I read online that the OpenGL will ONLY perform Multisampling if the drivers support this.

Is there anyway in OpenGL we can confirm that the above call is working ? Or is there anyway we can find out if my machine graphics card supports this call ?

4
  • I wouldn't be aware that this depends on the driver capabilities. It definitely depends on whether your render target supports multisampling, but that's not directly related to the driver. Commented Aug 8, 2017 at 14:05
  • I was checking some example codes to perform this and I came across this file: example code In this search for glEnable(GL_MULTISAMPLE) . There is a comment mentioning its driver based. Is there a way to confirm if the render target supports Multisampling ? Commented Aug 8, 2017 at 14:07
  • From a first view, I see nothing that states something similar than your bold text in your link. The only note I see is about whether multi-sampling is enabled by default or not. If your windowing system can give you a multisampled window/backbuffer and a OpenGL context > 1.3 then multisampling has to work. Commented Aug 8, 2017 at 14:16
  • Having multisampling enabled or not does not relate to whether multisampling is supported or not. It just specifies if multisampling should be used or not. Commented Aug 8, 2017 at 14:17

1 Answer 1

4

In the general case, seeing if your implementation supports multisampling is easy.

You can get multisampling in two ways: a multisampled default framebuffer, or a multisampled FBO. The latter can only happen by you explicitly creating multisampled images for your FBO. I think you can tell when you're calling glRenderbufferStorageMultisample or glTexStorage2DMultisample, but that doesn't matter, because you can ask any framebuffer (FBO or default) if it has multiple samples.

To do that, you can bind the framebuffer to the GL_DRAW_FRAMEBUFFER and call glGetIntegerv with GL_SAMPLE_BUFFERS. If that value is 1, then the buffer is mulitsampled. You can get the number of samples by querying GL_SAMPLES.

Note that GL 4.5 and above allow you to use glGet(Named)FramebufferParameteriv to query these parameters, so that you don't have to bind the FBO.


All that being said, you have one big problem. Nothing you've done in your rendering will be multisampled. Multisampling cannot anti-alias a textured quad. It only performs anti-aliasing at the edges of triangles. Unless you turn on per-sample shading (which you shouldn't unless you don't like performance), data fetched from texels will not be affected.

So even if multisampling is going on, your specific rendering operation will not see the effects of it.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.