2011-07-11 17 views
0

私は、Ubuntu 10.10でPVRSDKを使用してOpenGL-ES 2.0でコードを書いていますが、今は何が必要なのかは分かりませんが、 私はブレークポイントを置くと、私は私が欲しいものを得ています。しかし、私はなぜ窓が消えたのか理解していない。OpenGL-es 2.0コードでのメモリエラー

私はvalgrindのとメモリチェックを行うと、私はこれらのエラーました:

==5997== Memcheck, a memory error detector 
==5997== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al. 
==5997== Using Valgrind-3.6.0.SVN-Debian and LibVEX; rerun with -h for copyright info 
==5997== Command: ./cube 
==5997== 
libEGL warning: use software fallback 
==5997== 
==5997== HEAP SUMMARY: 
==5997==  in use at exit: 12,126 bytes in 94 blocks 
==5997== total heap usage: 97,499 allocs, 97,405 frees, 197,353,970 bytes allocated 
==5997== 
==5997== 8 bytes in 1 blocks are definitely lost in loss record 3 of 57 
==5997== at 0x4024F12: calloc (vg_replace_malloc.c:467) 
==5997== by 0x486CE90: __glXInitialize (glxinit.c:584) 
==5997== by 0x486AA61: x11_screen_support (x11_screen.c:133) 
==5997== by 0x486DEEB: x11_create_dri2_display (native_dri2.c:700) 
==5997== by 0x4869AEA: native_create_display (native_x11.c:42) 
==5997== by 0x4866A2A: egl_g3d_initialize (egl_g3d.c:498) 
==5997== by 0x4176F36: _eglMatchDriver (egldriver.c:580) 
==5997== by 0x4170BBF: eglInitialize (eglapi.c:294) 
==5997== by 0x8049EFF: main (Hello.cpp:231) 
==5997== 
==5997== 40 bytes in 1 blocks are definitely lost in loss record 31 of 57 
==5997== at 0x4026351: operator new(unsigned int) (vg_replace_malloc.c:255) 
==5997== by 0x8049CE3: main (Hello.cpp:206) 
==5997== 
==5997== 72 bytes in 1 blocks are definitely lost in loss record 34 of 57 
==5997== at 0x4024F12: calloc (vg_replace_malloc.c:467) 
==5997== by 0x4A50C7C: st_bufferobj_alloc (st_cb_bufferobjects.c:56) 
==5997== by 0x49A1B78: _mesa_alloc_shared_state (shared.c:94) 
==5997== by 0x498860F: _mesa_initialize_context_for_api (context.c:904) 
==5997== by 0x49886DB: _mesa_create_context_for_api (context.c:1050) 
==5997== by 0x49C7479: st_create_context (st_context.c:176) 
==5997== by 0x4985A80: st_api_create_context (st_manager.c:646) 
==5997== by 0x4868843: egl_g3d_create_context (egl_g3d_api.c:131) 
==5997== by 0x4173127: eglCreateContext (eglapi.c:413) 
==5997== by 0x804A039: main (Hello.cpp:261) 
==5997== 
==5997== 1,546 (48 direct, 1,498 indirect) bytes in 1 blocks are definitely lost in loss record 55 of 57 
==5997== at 0x4025BD3: malloc (vg_replace_malloc.c:236) 
==5997== by 0x4BABD13: talloc_enable_null_tracking (in /usr/lib/libtalloc.so.2.0.1) 
==5997== by 0x4BABE28: talloc_init (in /usr/lib/libtalloc.so.2.0.1) 
==5997== by 0x49F48B5: glsl_symbol_table::glsl_symbol_table() (glsl_symbol_table.cpp:60) 
==5997== by 0x49F2566: _mesa_glsl_parse_state::_mesa_glsl_parse_state(__GLcontextRec*, unsigned int, void*) (glsl_parser_extras.cpp:50) 
==5997== by 0x49D68B3: _mesa_glsl_compile_shader (ir_to_mesa.cpp:2815) 
==5997== by 0x49A0486: _mesa_CompileShaderARB (shaderapi.c:807) 
==5997== by 0x804A0E1: main (Hello.cpp:280) 
==5997== 
==5997== LEAK SUMMARY: 
==5997== definitely lost: 168 bytes in 4 blocks 
==5997== indirectly lost: 1,498 bytes in 28 blocks 
==5997==  possibly lost: 0 bytes in 0 blocks 
==5997== still reachable: 10,460 bytes in 62 blocks 
==5997==   suppressed: 0 bytes in 0 blocks 
==5997== Reachable blocks (those to which a pointer was found) are not shown. 
==5997== To see them, rerun with: --leak-check=full --show-reachable=yes 
==5997== 
==5997== For counts of detected and suppressed errors, rerun with: -v 
==5997== ERROR SUMMARY: 4 errors from 4 contexts (suppressed: 54 from 11) 

は今、彼らが言及されているこれらの行:

206   x11Visual = new XVisualInfo; 
207   XMatchVisualInfo(x11Display, x11Screen, i32Depth, TrueColor, x11Vis ual); 
208   if (!x11Visual) 
209   { 
210     printf("Error: Unable to acquire visual\n"); 
211     goto cleanup; 
212   } 

=========================================================================================== 

230   EGLint iMajorVersion, iMinorVersion; 
231   if (!eglInitialize(eglDisplay, &iMajorVersion, &iMinorVersion)) 
232   { 
233     printf("Error: eglInitialize() failed.\n"); 
234   } 

========================================================================================== 

eglContext = eglCreateContext(eglDisplay, eglConfig, NULL, ai32Conte xtAttribs); 
262   if (!TestEGLError("eglCreateContext")) 
263   { 
264     goto cleanup; 
265   } 

============================================================================================ 

279   glShaderSource(uiFragShader, 1, (const char**)&pszFragShader, NULL); 
280   glCompileShader(uiFragShader); 

は、だから私はちょうどそれそのため、これらのかを知りたいですエラー私はその画面が消えるか、何か他の理由があるかもしれません。

答えて

1

私はちょうどそのため、これらのエラーの私はその画面が消えたり何か他のものが

理由後者であるかもしれない取得していますことを知ってほしいです。リークはプログラム実行時間に影響しません(プログラムが必要なときにメモリを割り当てられないほど大きくないが、リークは少ない)。

Xイベントループを入力するのを忘れましたか?

更新:

int i32NumMessages = XPending(x11Display); 
for(int i = 0; i < i32NumMessages; i++) 
{ 
    XEvent event; 
    XNextEvent(x11Display, &event); 
} 

ループが実際にアプリケーションが(ほぼ)すぐに

を終了

    • 明らか間違っ理由であることこれまでにキューに入れられたイベントのみを処理しています(イベントの数は非常に少ない可能性があります)。あなたは実際にそれらを捨てています。あなたはおそらくthisのようなものを書きたいと思うでしょう。 \t \t { \t \t \tたXEvent \tイベント(; iがi32NumMessagesを
    +0

    '。 \t \t \t XNextEvent(x11Display、&event); \t \t あなたはこのループについて話しています。そこには私の描画機能があります。しかし、出力を与えた後にスクリーンの消滅の理由が何であるか教えていただけますか... –

    +0

    こんにちは、全体のコードを見たいのですか?[リンク](http://stackoverflow.com/questions/6622872/opengl -es-2-0-code-runtime-error) –

    +0

    こんにちは、ありがとう、しかし、私はループで私の描画機能を導入することで、正しい(フレーム内の三角形を描くことを意味する) –

    関連する問題