在纹理openGL顶部绘制点

时间:2013-03-13 10:37:21

标签: c++ winforms opengl opentk

我在GLcontrol中绘制了一个纹理,我想在它上面绘制点。相反,我将完整的纹理设置为我想要绘制的点的颜色。我想我必须禁用纹理格式并启用点图,但无法达到解决方案......

这是绘图功能: 基本上绘制的点是ROI [0],而是仅绘制我得到下图所示的点(图像在绘制“点”之前是灰度)。

private: void drawImg(int img){

         int w=this->glControl_create_grid->Width;
         int h=this->glControl_create_grid->Height;
         GL::MatrixMode(MatrixMode::Projection);

         GL::LoadIdentity();
         GL::Ortho(0, w, 0, h, -1, 1); // Bottom-left corner pixel has coordinate (0, 0)
         GL::Viewport(0, 0, w, h); // Use all of the glControl painting area

         GL::Clear(ClearBufferMask::ColorBufferBit | ClearBufferMask::DepthBufferBit);
         GL::ClearColor(Color::LightGray);
         GL::MatrixMode(MatrixMode::Modelview);
         GL::LoadIdentity();

         GL::Enable(EnableCap::Texture2D);
         GL::BindTexture(TextureTarget::Texture2D, img);
         OpenTK::Graphics::OpenGL::ErrorCode error=GL::GetError();
             GL::Begin(BeginMode::Quads);
                GL::TexCoord2(0, 0);
                GL::Vertex2(0 ,h);

                GL::TexCoord2(1, 0);
                GL::Vertex2(w, h);

                GL::TexCoord2(1, 1);
                GL::Vertex2(w, 0);

                GL::TexCoord2(0, 1);
                GL::Vertex2(0, 0);
            GL::End();
            GL::Disable(EnableCap::Texture2D);
            if (ROI[0].x!=0||ROI[0].y!=0){
                GL::Color3(Color::Red);
                GL::Begin(BeginMode::Points);
                GL::Vertex2(ROI[0].x,ROI[0].y);
                GL::End();
            }


    }

enter image description here

我的代码应该更改什么?我似乎无法实现它......

1 个答案:

答案 0 :(得分:3)

我找到了答案。在绑定纹理时,颜色似乎也适用于纹理,所以我只需要在绘制纹理之前添加GL::Color3(Color::White)

相关问题