首页 > 解决方案 > OpenGL着色器和绘图命令的共存

问题描述

在我的应用程序中,我使用 OpenGL 使用经典的 Shader + VAO + many VBO 绘制许多形状并调用 glDrawArrays(...)

它运行良好,但为了实现轴可视化,我尝试使用 OpenGL 命令。

我想出了这段代码:

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

WhenPaint(); //The function which loop around all object and draw using proper VAO and shaders

//Here I start use OpenGL draw commands to draw my axis
glMatrixMode(GL_PROJECTION);
glLoadMatrixf(&(camera.GetProjectionMatrix(Upp::Sizef{sizeW,sizeH})[0][0])); //Setting up projection

glMatrixMode(GL_MODELVIEW);
glLoadMatrixf(&(camera.GetViewMatrix()[0][0])); //Setting up viewMatrix

if(ShowAxis)GLDrawFunction::PaintAxis(0, 0, 0,200); //a function that draw axis

这项工作,但只有当我评论WhenPaint()函数......

在这里,您可以看到没有 WhenPaint() 函数的视图:

没有WhenPaint()

当我使用WhenPaint() 时,您可以看到这里的视图(在OpenGL Draw 命令之前或之后无关紧要):

在此处输入图像描述

是否有可能使这两种绘制事物的方式一起工作?

标签: c++opengl

解决方案


推荐阅读