QOpenGLFramebufferObjectFormat::toImage()Android黑色图像
我正在Android设备上尝试代码 在进行了一些更改以使代码在没有错误的情况下运行之后,我还无法获得正确的映像。在Android上,图像是完全黑色的。我做错了什么?谢谢 以下是第一行中的更改:QOpenGLFramebufferObjectFormat::toImage()Android黑色图像,android,qt,opengl-es,Android,Qt,Opengl Es,我正在Android设备上尝试代码 在进行了一些更改以使代码在没有错误的情况下运行之后,我还无法获得正确的映像。在Android上,图像是完全黑色的。我做错了什么?谢谢 以下是第一行中的更改: QSurfaceFormat format; format.setMajorVersion(2); format.setMinorVersion(2); QOffscreenSurface window; //window.setSurfaceType(QWindow::OpenGLSurface);
QSurfaceFormat format;
format.setMajorVersion(2);
format.setMinorVersion(2);
QOffscreenSurface window;
//window.setSurfaceType(QWindow::OpenGLSurface);
window.setFormat(format);
window.create();
QOpenGLContext* context=(QOpenGLContext::currentContext());
// context.setFormat(format);
/* if (!context.create())
qFatal("Cannot create the requested OpenGL context!");
*/
context->makeCurrent(&window);
const QRect drawRect(0, 0, 400, 400);
const QSize drawRectSize = drawRect.size();
QOpenGLFramebufferObjectFormat fboFormat;
//fboFormat.setSamples(16);
//fboFormat.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
QOpenGLFramebufferObject fbo(drawRectSize, fboFormat);
fbo.bind();
更新1
我把密码改成了
QSurfaceFormat format;
format.setMajorVersion(3);
format.setMinorVersion(0);
char* extensionList = (char*) glGetString(GL_VERSION);
qDebug()<<extensionList;
QOffscreenSurface window;
//QOffscreen is always an OpenGLSurface
//window.setSurfaceType(QWindow::OpenGLSurface);
window.setFormat(format);
window.create();
//QOpenGLContext* context=(QOpenGLContext::currentContext());
QOpenGLContext context;
context.setFormat(format);
if (!context.create())
qFatal("Cannot create the requested OpenGL context!");
if(!context.makeCurrent(&window))
qFatal("Cannot makecurrent(windows)!");
QSurfaceFormat格式;
格式。setMajorVersion(3);
format.setMinorVersion(0);
char*extensionList=(char*)glGetString(GL\u版本);
qDebug()不确定这是否是主要问题,但2.2不是有效的OpenGL版本。OpenGL 2.2从未存在过,2.1之后的版本是3.0。您注释掉的代码似乎至关重要(上下文创建等,设置格式和曲面类型)。你为什么要评论它?还有几个调用没有检查返回值是否有错误,例如makeCurrent()和bind(),谢谢,但它没有解决问题……您能提供更多的代码吗?有几件事可能会出错。