2016-12-15 89 views
0

在我的應用程序中,我的屏幕上有10k〜200k行。這條線是2D效果的2D空間。在Android(和iOS)上使用Qt繪製3D效果與openGL的2D效果

我想通過使用Qt來加快我在iOS和Android上繪圖的速度。 因此,我想嘗試在Qt上使用openGL。

我嘗試一個非常簡單的代碼: https://github.com/mkdh/Qt_QOpenGLWidget_screen_test.git

它應該顯示綠色屏幕上我的Android,但它顯示在我的Android白屏。 你知道爲什麼它會在我的Android上顯示白色屏幕嗎?如果我想在此Android上使用openGL,該怎麼辦?

上創造者的應用程序輸出:

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 

順便說一句,我爲什麼不能繪製在glBegin(GL_LINES)線爲無效MyGLWidget :: initializeGL()評論?

回答

0

我可以通過評論下面的代碼來解決這個問題。

// format.setVersion(3,2);

// format.setProfile(QSurfaceFormat :: CoreProfile)

0

我建議你使用NanoVG而不是純粹的OpenGL,這非常複雜。您在OpenGL上的代碼與特定版本的OpenGL綁定在一起,並且可能導致很多可移植性問題。 NanoVG是在OpenGL(2,es,es2,es3)上支持的畫布繪製API,並且具有類似HTML5的畫布API。另外還有一個與NanoVG Qt整合的QNanoPainter。

此外它支持Linux,Windows和Android。

+0

這不是我想使用的OpenGL的另一個工具是什麼。而QNanoPainter似乎不是Qt的官方功能。我可以通過評論下面的代碼來解決這個問題。 // format.setVersion(3,2); // format.setProfile(QSurfaceFormat :: CoreProfile); – weilun