Jump to content
  • Advertisement

mushroomfire

Member
  • Content Count

    6
  • Joined

  • Last visited

Community Reputation

120 Neutral

About mushroomfire

  • Rank
    Newbie

Personal Information

  • Interests
    Programming
  1. mushroomfire

    MSAA help

    Yeah, here's the updated code: // Create framebuffer glGenFramebuffers(1, &fbo); glBindFramebuffer(GL_FRAMEBUFFER, fbo); // Create multisampled color texture glGenTextures(1, &prim); glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, prim); glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, aasamples, GL_RGBA8, window->getSize().x(), window->getSize().y(), GL_TRUE); GLuint rbo; glGenRenderbuffers(1, &rbo); glBindRenderbuffer(GL_RENDERBUFFER, rbo); glRenderbufferStorageMultisample(GL_RENDERBUFFER, aasamples, GL_DEPTH24_STENCIL8, width, height); glBindRenderbuffer(GL_RENDERBUFFER, 0); //glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rbo); glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, prim, 0); if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { return; } and the draw: glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo); glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glDrawElements(prim, size, GL_UNSIGNED_INT, 0); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); glBlitFramebuffer(0, 0, width, height, 0, 0, width, height, GL_COLOR_BUFFER_BIT, GL_LINEAR); SwapBuffers(hdc);
  2. mushroomfire

    MSAA help

    @Osbios Would I still need a renderbuffer? It doesn't seem like it's being used anywhere. It seems like it's working but only if I comment out this line: glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rbo); otherwise it just gives me a black screen.   Also it seems like some objects aren't rendering... Not sure what might be causing it.
  3. mushroomfire

    MSAA help

      Alright, so I took a look at Section 3.2 and added the attributes code they have to mine. It looks like: PIXELFORMATDESCRIPTOR pfd = { sizeof(PIXELFORMATDESCRIPTOR), // Size of this structure 1, // Version of this structure PFD_DRAW_TO_WINDOW | // Draw to Window (not to bitmap) PFD_SUPPORT_OPENGL | // Support OpenGL calls in window PFD_DOUBLEBUFFER | // Double buffered mode PFD_STEREO_DONTCARE, PFD_TYPE_RGBA, // RGBA Color mode 32, // Want the display bit depth 0, 0, 0, 0, 0, 0, // Not used to select mode 0, 0, // Not used to select mode 0, 0, 0, 0, 0, // Not used to select mode 24, // Size of depth buffer 8, // bit stencil 0, // Not used to select mode PFD_MAIN_PLANE, // Draw in main plane 0, // Not used to select mode 0, 0, 0 }; int pixFmt = ChoosePixelFormat(hdc, &pfd); SetPixelFormat(hdc, pixFmt, &pfd); // Make temp context auto tc = wglCreateContext(hdc); wglMakeCurrent(hdc, tc); glewInit(); UINT numpf; int piAttributes[] = { WGL_DRAW_TO_WINDOW_ARB, GL_TRUE, WGL_SUPPORT_OPENGL_ARB, GL_TRUE, WGL_DOUBLE_BUFFER_ARB, GL_TRUE, WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_ARB, WGL_COLOR_BITS_ARB, 32, WGL_DEPTH_BITS_ARB, 24, WGL_STENCIL_BITS_ARB, 8, WGL_SAMPLE_BUFFERS_ARB, 1, //Number of buffers (must be 1 at time of writing) WGL_SAMPLES_ARB, 4, //Number of samples 0 }; wglChoosePixelFormatARB = (PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB"); wglChoosePixelFormatARB(hdc, piAttributes, 0, 1, &pixFmt, &numpf); DescribePixelFormat(hdc, pixFmt, sizeof(PIXELFORMATDESCRIPTOR), &pfd); SetPixelFormat(hdc, pixFmt, &pfd); int attribs[] = { WGL_CONTEXT_MAJOR_VERSION_ARB, 4, WGL_CONTEXT_MINOR_VERSION_ARB, 3, WGL_CONTEXT_FLAGS_ARB, 0, 0 }; context = wglCreateContextAttribsARB(hdc, 0, attribs); wglMakeCurrent(0, 0); wglDeleteContext(tc); wglMakeCurrent(hdc, context); Is this right? I'm still getting aliased lines on my objects, so the problem doesn't seem to be here.
  4. mushroomfire

    OpenGL MSAA help

    I am trying to enable MSAA for my game, and I'm trying to understand how it works in OpenGL, its a bit confusing. I am looking at https://www.opengl.org/wiki/Multisampling attempting to make sense of it. This is what I have so far:   Creating framebuffer: // Create framebuffer glGenFramebuffers(1, &fbo); glBindFramebuffer(GL_FRAMEBUFFER, fbo); // Create multisampled texture glGenTextures(1, &prim); glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, prim); glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, aasamples, GL_RGBA8, width, height, GL_TRUE); GLuint rbo; glGenRenderbuffers(1, &rbo); glBindRenderbuffer(GL_RENDERBUFFER, rbo); glRenderbufferStorageMultisample(GL_RENDERBUFFER, 4, GL_DEPTH24_STENCIL8, width, height); glBindRenderbuffer(GL_RENDERBUFFER, 0); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rbo); if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { return; } glBindFramebuffer(GL_FRAMEBUFFER, 0); Drawing: glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo); glDrawBuffer(GL_BACK); glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);             glDrawElements(prim, size, GL_UNSIGNED_INT, 0);             glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo);              glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);              glBlitFramebuffer(0, 0, width, height, 0, 0, width, height, GL_COLOR_BUFFER_BIT, GL_NEAREST);              SwapBuffers(hdc); Can anyone point me in the right direction? or just list the steps needed to render an object with multisampling enabled? The code above is really messy, and is really just things I threw together based on what I could find online.
  5. Alright, so I tried using CheckMultisampleQualityLevels(), it looks like this: D3D11CreateDevice(0, D3D_DRIVER_TYPE_HARDWARE, 0, 0, &level, 1, D3D11_SDK_VERSION, &device, 0, &context); UINT samplecount = 8; UINT samplequality; device->CheckMultisampleQualityLevels(DXGI_FORMAT_R8G8B8A8_UNORM, samplecount, &samplequality); And when I run the debugger, it says that samplequality has a value of 1, which should mean it is supported right?   Would anyone also know why this effect happens when the Quality is 0? This effect only happens in window mode, when I run the game in fullscreen it looks antialiased properly. The green part is just the background so that you can see the effect, but as you can see, there is still some jaggy-ness to the lines in window mode.
  6. Hello I am having a problem with trying to enable MSAA for my game. When I set the Swapchain description's SampleDesc.Quality to 0 the game runs fine and everything renders, but once I set it to a value greater than 0, for example 1, it fails to create the Swapchain.   Here is my swapchain description: DXGI_SWAP_CHAIN_DESC scdesc; ZeroMemory(&scdesc, sizeof(DXGI_SWAP_CHAIN_DESC)); scdesc.BufferDesc = { width, height, { 1, 60 }, DXGI_FORMAT_R8G8B8A8_UNORM }; scdesc.SampleDesc = aasettings; scdesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; scdesc.BufferCount = 1; scdesc.OutputWindow = window; scdesc.Windowed = !(isFullScreen()); scdesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD; scdesc.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH; D3D_FEATURE_LEVEL level = D3D_FEATURE_LEVEL_11_0; D3D11CreateDeviceAndSwapChain(0, D3D_DRIVER_TYPE_HARDWARE, 0, 0, &level, 1, D3D11_SDK_VERSION, &scdesc, &swapchain, &device, 0, &context)); The variable aasettings basically looks like: DXGI_SAMPLE_DESC aasettings{ 8, 1 }; Where 8 is the SampleDesc.Count, and 1 is SampleDesc.Quality.   Would anyone happen to know why its failing when I increase the Quality value?
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!