提示コードなのですが///
コメント部内部のMSAA実装部のコードで0x500
のエラーが発生する原因がわかりません参考サイト1
を参考にテクスチャとしてMSAAを実装しました、なぜgltexPrameteri()関数の列挙型が無効なのでしょうか?
0x500 : 呼んだ関数の列挙型の引数がその関数で使えない場合
参考サイト4: https://github.com/VictorGordan/opengl-tutorials/blob/main/YoutubeOpenGL%2022%20-%20Anti-Aliasing/Main.cpp#L149
参考サイト3: https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glTexParameter.xhtml
参考サイト1: https://learnopengl.com/Advanced-OpenGL/Anti-Aliasing
参考サイト2: https://blog.techlab-xe.net/opengl%E3%81%A7msaa/
cpp
1 2// ##################################### 初期化 ##################################### 3FrameWork::Camera::Camera() 4{ 5 //カラーバッファ 6 glGenFramebuffers(1, &frameBufferFBO); 7 glBindFramebuffer(GL_FRAMEBUFFER, frameBufferFBO); 8 glViewport(0, 0, windowContext->getSize().x, windowContext->getSize().y); 9 10 /* 11 glGenTextures(1,&frameBuffer); 12 glBindTexture(GL_TEXTURE_2D, frameBuffer); 13 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, windowContext->getSize().x, windowContext->getSize().y, 0, GL_RGBA, GL_FLOAT, NULL); 14 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 15 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 16 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); 17 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); 18 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + frameBufferNumber, GL_TEXTURE_2D, frameBuffer, 0); 19 glBindFramebuffer(GL_FRAMEBUFFER, 0); 20 */ 21 22 //MSAA 23 //glGenFramebuffers(1, &multiSampleFBO); 24 //glBindFramebuffer(GL_FRAMEBUFFER, multiSampleFBO); 25 26 glGenTextures(1, &frameBuffer); 27 glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, frameBuffer); 28 glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 8, GL_RGB, windowContext->getSize().x, windowContext->getSize().y, GL_TRUE); 29 //glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 8, GL_RGBA16F, windowContext->getSize().x, windowContext->getSize().y, GL_TRUE); 30 31//////////////////////////////////////////////////////////////////////////////////////////////////////// 32 glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 33//////////////////////////////////////////////////////////////////////////////////////////////////////// 34 /* 35 glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 36 37 glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); // Prevents edge bleeding 38 glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); // Prevents edge bleeding 39 */ 40 41 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + frameBufferNumber, GL_TEXTURE_2D_MULTISAMPLE, frameBuffer, 0); 42 43 44 //レンダリングバッファ 45 glGenRenderbuffers(1, &rbo); 46 glBindRenderbuffer(GL_RENDERBUFFER, rbo); 47 glRenderbufferStorageMultisample(GL_RENDERBUFFER, 8, GL_DEPTH24_STENCIL8, windowContext->getSize().x, windowContext->getSize().y); 48 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rbo); 49 50 //カラーバッファ アタッチ 51 GLuint attachment = GL_COLOR_ATTACHMENT0 + frameBufferNumber; 52 glDrawBuffers(1,&attachment); 53 //glBindFramebuffer(GL_FRAMEBUFFER,0); 54 55 //深度マップ 56 57 glGenFramebuffers(1, &depthMapFBO); 58 glBindFramebuffer(GL_FRAMEBUFFER, depthMapFBO); 59 glGenTextures(1, &depthMap); 60 glBindTexture(GL_TEXTURE_2D, depthMap); 61 glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, windowContext->getSize().x, windowContext->getSize().y, 0, GL_DEPTH_COMPONENT, GL_FLOAT, NULL); 62 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 63 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 64 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); 65 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); 66 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depthMap, 0); 67 68 if(glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) 69 { 70 std::cerr << "Framebuffer is not complete: 0x"<<glCheckFramebufferStatus(GL_FRAMEBUFFER)<< std::endl; 71 assert(0); 72 } 73 74 75 position = glm::vec3(0,0,10); //座標 76 vecLook = glm::vec3(0,0,-1); //向き 77 78 setPosition(position); 79 setLook(vecLook); 80 81 frameBufferNumber += 1; 82} 83 84 85 86// ##################################### 描画 ##################################### 87void FrameWork::Camera::View(std::shared_ptr<Actor> actor) 88{ 89 glBindFramebuffer(GL_FRAMEBUFFER, depthMapFBO); 90 glViewport(0, 0, windowContext->getSize().x, windowContext->getSize().y); 91 92 actor->Renderer_Depth(getViewPerspective()); 93 94 glBindFramebuffer(GL_FRAMEBUFFER, frameBufferFBO); 95 glViewport(0, 0, windowContext->getSize().x, windowContext->getSize().y); 96 97 glDisable(GL_DEPTH_TEST); 98 actor->Renderer_2D(getViewOrthographic()); 99 100 glEnable(GL_DEPTH_TEST); 101 actor->Renderer(getViewPerspective()); 102 103 glBindFramebuffer(GL_FRAMEBUFFER,0); 104} 105 106// ##################################### フレームバッファ クリア ##################################### 107void FrameWork::Camera::ClearBuffer() 108{ 109 glEnable(GL_DEPTH_TEST); 110 glClearColor(0.0f, 0.0f, 0.0f, 1.0f); 111 glBindFramebuffer(GL_FRAMEBUFFER, depthMapFBO); 112 glClear(GL_DEPTH_BUFFER_BIT); 113 glBindFramebuffer(GL_FRAMEBUFFER, frameBufferFBO); 114 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 115 //glBindFramebuffer(GL_FRAMEBUFFER, 0); 116} 117 118// ##################################### フレームバッファ 描画 ##################################### 119void FrameWork::Camera::RendererBuffer() 120{ 121 122 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 123 124 glDisable(GL_DEPTH_TEST); 125 glBindVertexArray(quadVAO); 126 glBindBuffer(GL_ARRAY_BUFFER, quadVBO); 127 128 shader->setEnable(); 129 130 //shader->setUniformSampler2D("screenTexture", 0, frameBuffer); 131 132 glDrawArrays(GL_TRIANGLES,0,6); 133 134 shader->setDisable(); 135 136 glBindVertexArray(0); 137 glBindBuffer(GL_ARRAY_BUFFER, 0); 138 139} 140
あなたの回答
tips
プレビュー