简体   繁体   English

通过在Android(和iOS)上使用Qt用openGL绘制具有3d效果的2d线

[英]draw 2d line with 3d effect with openGL by using Qt on Android (and iOS)

In my app, there are 10k ~ 200k lines on my screen. 在我的应用中,屏幕上有1万〜20万行。 And the line is drawn in 2d space with 3d effect. 并在具有3d效果的2d空间中绘制线条。

I want to speed my drawing's speed on iOS and Android by using Qt. 我想使用Qt加快我的绘图在iOS和Android上的速度。 Hence, I want to try openGL on Qt. 因此,我想在Qt上尝试openGL。

I try a pretty simple code: https://github.com/mkdh/Qt_QOpenGLWidget_screen_test.git 我尝试了一个非常简单的代码: https : //github.com/mkdh/Qt_QOpenGLWidget_screen_test.git

It should show green screen on my Android but it shows white screen on my Android. 它应该在我的Android上显示绿屏,但是在我的Android上显示白屏。 Do you know why it shows white screen on my Android? 您知道为什么它在我的Android上显示白屏吗? And what should I do if I want to use openGL on this Android? 如果要在此Android上使用openGL,该怎么办?

The Application Output on creator: 创建者的应用程序输出:

InputMethodManagerService( 536): Enabling: SessionState{uid 10287 pid 25474 method 224d6020 session 2250c900 channel ClientState{22861db8 uid 10287 pid 25474} (server)}
W/My First openGL Widget(25474): (null):0 ((null)): Cannot find EGLConfig, returning null config
W/My First openGL Widget(25474): (null):0 ((null)): QEGLPlatformContext: Failed to create context: 3005
W/My First openGL Widget(25474): (null):0 ((null)): Cannot find EGLConfig, returning null config
W/My First openGL Widget(25474): (null):0 ((null)): QEGLPlatformContext: Failed to create context: 3005
W/My First openGL Widget(25474): (null):0 ((null)): QOpenGLWidget: Failed to create context
W/My First openGL Widget(25474): (null):0 ((null)): Cannot find EGLConfig, returning null config
W/My First openGL Widget(25474): (null):0 ((null)): QEGLPlatformContext: Failed to create context: 3005
W/My First openGL Widget(25474): (null):0 ((null)): QOpenGLWidget: Failed to create context
W/My First openGL Widget(25474): (null):0 ((null)): Cannot find EGLConfig, returning null config
W/My First openGL Widget(25474): (null):0 ((null)): QEGLPlatformContext: Failed to create context: 3005
W/My First openGL Widget(25474): (null):0 ((null)): QOpenGLWidget: Failed to create context
W/My First openGL Widget(25474): (null):0 ((null)): composeAndFlush: makeCurrent() failed
W/My First openGL Widget(25474): (null):0 ((null)): composeAndFlush: makeCurrent() failed

By the way, why can't I draw line with glBegin(GL_LINES) as the comment in void MyGLWidget::initializeGL()? 顺便说一句,为什么我不能在void MyGLWidget :: initializeGL()中用glBegin(GL_LINES)作为注释来画线?

I suggest you to use NanoVG instead of pure OpenGL which is very complicated. 我建议您使用NanoVG代替非常复杂的纯OpenGL。 Your codes on OpenGL are tied to specific version of OpenGL and it can cause many portability issues. 您在OpenGL上的代码与特定版本的OpenGL相关联,并且可能导致许多可移植性问题。 NanoVG is canvas drawing API backed on OpenGL(2,es,es2,es3) and have similar canvas API like HTML5. NanoVG是基于OpenGL(2,es,es2,es3)的画布绘图API,并且具有类似HTML5的画布API。 Also there is a Qt integration with NanoVG which is QNanoPainter. 还有与NanoVG的Qt集成,即QNanoPainter。

Also its supported on linux, windows and android as well. 它还在Linux,Windows和Android上受支持。

I can fix this problem by comment the code below. 我可以通过注释以下代码来解决此问题。

// format.setVersion(3, 2); // format.setVersion(3,2);

// format.setProfile(QSurfaceFormat::CoreProfile) // format.setProfile(QSurfaceFormat :: CoreProfile)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM