VeTaL Posted April 20, 2011 Share Posted April 20, 2011 Original post is here ( http://www.ogre3d.org/addonforums/viewtopic.php?f=17&t=13968 ), maybe someone from this forum had already tried to use MyGUI with LE and faced the same problem: Have 2 questions: 1) when i'm trying to render something (single button or simple example), i got this: Is it familiar to you? What can be the reason? 2) i catch exception when shuting down MyGui. Call stack: > Test_d.exe!MyGUI::OpenGLVertexBuffer::create() Line 100 + 0x12d bytes C++ Test_d.exe!MyGUI::OpenGLVertexBuffer::setVertexCount(unsigned int _count=384) Line 40 C++ MyGUIEngine_d.dll!MyGUI::RenderItem::removeDrawItem(MyGUI::ISubWidget * _item=0x08bcd5b0) Line 123 + 0x1c bytes C++ MyGUIEngine_d.dll!MyGUI::EditText::destroyDrawItem() Line 386 C++ MyGUIEngine_d.dll!MyGUI::LayerItem::detachFromLayerItemNode(bool _deep=true) Line 203 + 0x25 bytes C++ MyGUIEngine_d.dll!MyGUI::LayerItem::detachFromLayerItemNode(bool _deep=true) Line 180 + 0x14 bytes C++ MyGUIEngine_d.dll!MyGUI::LayerItem::detachFromLayerItemNode(bool _deep=true) Line 180 + 0x14 bytes C++ MyGUIEngine_d.dll!MyGUI::LayerItem::detachFromLayer() Line 138 C++ MyGUIEngine_d.dll!MyGUI::LayerManager::detachFromLayer(MyGUI::Widget * _item=0x08bc9b38) Line 161 + 0x19 bytes C++ MyGUIEngine_d.dll!MyGUI::LayerManager::_unlinkWidget(MyGUI::Widget * _widget=0x08bc9b38) Line 132 C++ MyGUIEngine_d.dll!MyGUI::WidgetManager::unlinkFromUnlinkers(MyGUI::Widget * _widget=0x08bc9b38) Line 170 + 0x20 bytes C++ MyGUIEngine_d.dll!MyGUI::Gui::_destroyAllChildWidget() Line 258 C++ MyGUIEngine_d.dll!MyGUI::Gui::shutdown() Line 154 C++ Test_d.exe!MyGuiManager::~MyGuiManager() Line 61 + 0xe bytes C++ Test_d.exe!`Singleton<MyGuiManager>::getInstance'::`2'::`dynamic atexit destructor for '_instance''() + 0x28 bytes C++ msvcr90d.dll!doexit(int code=0, int quick=0, int retcaller=0) Line 591 C msvcr90d.dll!exit(int code=0) Line 412 + 0xd bytes C Test_d.exe!__tmainCRTStartup() Line 599 C Test_d.exe!mainCRTStartup() Line 403 C kernel32.dll!756bf4e8() [Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll] ntdll.dll!7729af77() ntdll.dll!7729af4a() 1) i got something like that on my laptop even when i was trying to launch your examples. When i tried them on computer, examples works fine, but when i tried to launch mygui in my engine, this happens again. Constructor is: MyGuiManager::MyGuiManager(void) { Gdiplus::GdiplusStartupInput m_gdiplusStartupInput; Gdiplus::GdiplusStartup(&m_pGdiToken, &m_gdiplusStartupInput, NULL); mPlatform = new MyGUI::OpenGLPlatform(); mPlatform->initialise(this); mPlatform->getDataManagerPtr()->addResourceLocation("..//Assets//MyGUI_Media", false); mGUI = new MyGUI::Gui(); mGUI->initialise("MyGUI_Core.xml"); mInfo = new diagnostic::StatisticInfo(); mFocusInfo = new diagnostic::InputFocusInfo(); MyGUI::ButtonPtr button = mGUI->createWidget<MyGUI::Button>( "Button", 10, 10, 300, 26, MyGUI::Align::Center, "Main"); button->setCaption("exit"); button->setVisible(true); So i hope to see a simple button, not a halfly-blurred screen. 2) Text of exception: Test_d.exe has triggered a breakpoint It happens here: if (mSizeInBytes != (size_t)bufferSize) { destroy(); MYGUI_PLATFORM_EXCEPT("Data size is mismatch with input array"); } MyGUI::OpenGLVertexBuffer::create() Line 100 MyGUI_OpenGLVertexBuffer.cpp //because you are trying to shut down MyGUI after render or in the middle of render process. Quite strange. the main structure is like this: while(!AppTerminate() && !_isQuit) { TimeManager.Update(); InputManager.Update(); *** MyGUImanager.Render(); } So it shouldn't want to destruct while rendering. Destructor is: MyGuiManager::~MyGuiManager(void) { mGUI->shutdown(); delete mGUI; mGUI = 0; mPlatform->shutdown(); delete mPlatform; mPlatform = 0; Gdiplus::GdiplusShutdown(m_pGdiToken); } Update function is: void MyGuiManager::Render() { if (mPlatform) mPlatform->getRenderManagerPtr()->drawOneFrame(); } Quote Working on LeaFAQ Link to comment Share on other sites More sharing options...
klepto2 Posted April 21, 2011 Share Posted April 21, 2011 You may have to change the OpenGL states to fit the needs of MyGui. try something like this: leglBegin(GetLayerCamera(background), cameraZoom); MyGUImanager.Render(); leglEnd(true); // End and specify that we used 3D projection legl.h // Includes, libs #pragma comment(lib,"opengl32.lib") #pragma comment(lib,"glu32.lib") #include "engine.h" #include <gl/gl.h> // Standard opengl include. #include <gl/glu.h> // GLU include. // Constants enum CullMode { CULL_NONE, // Both sides of faces are drawn. CULL_DRAW_CCW, // Only faces defined by vertices declared in ccw order will be drawn (default). CULL_DRAW_CW // Same as above but cw. }; // Commands (declarations) void leglBegin (TCamera camera = NULL, float zoom = 1.0f, CullMode cm = CULL_DRAW_CCW); void leglEnd (bool was3D = false); void leglBindTexture(TTexture texture); // Implementations (definitions) // Use NULL for the camera to set up 2D drawing instead of 3D. // The "zoom" parameter is only required because there's no GetCameraZoom() function. void leglBegin(TCamera camera, float zoom, CullMode cm) { // Setup projetion according to argument if (NULL != camera) { // Save current projection matrix. Then reset glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); // Calculate the view frustum float nearRange, farRange; GetCameraRange(camera, nearRange, farRange); float theta = 1.0f / zoom; // tan(45°) = 1.0f float aspect = float(BufferWidth(CurrentBuffer()))/BufferHeight(CurrentBuffer()); glFrustum (-nearRange*theta, nearRange*theta, -nearRange/aspect*theta, nearRange/aspect*theta, nearRange,farRange); // Reset transformation glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); // LE uses a differently handed coordinate system than ogl does glScalef(1.0f, 1.0f, -1.0f); // Calculate the LookAt vectors (camera direction and up vector)... TVec3 from = EntityPosition(camera, true); TVec3 to = {0,0,-1}; to = TFormVector(to, camera, NULL); to += from; TVec3 up = {0,1,0}; up = TFormVector(up, camera, NULL); // Set LookAt gluLookAt(from.X, from.Y, from.Z, to.X, to.Y , to.Z, up.X, up.Y, up.Z); } else { glPushMatrix(); // Set orthographic projection (used for 2D drawing) // Get the current viewport/buffer size. int vPort[4]; glGetIntegerv(GL_VIEWPORT, vPort); // Set the projection gluOrtho2D(0, vPort[2], vPort[3], 0); // like glOrtho(0, vPort[2], vPort[3], 0, -1, 1); // Reset transformation glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); } // Setup default drawing settings. // Alpha blending. glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Backface culling. if (CULL_NONE != cm)glEnable(GL_CULL_FACE); if (NULL != camera)glCullFace((CULL_DRAW_CCW == cm) ? GL_BACK : GL_FRONT); else glCullFace((CULL_DRAW_CCW == cm) ? GL_FRONT : GL_BACK); // Depth test for 3D projection if (NULL != camera)glEnable(GL_DEPTH_TEST); // Drawing color. glColor4f(1.0f, 1.0f, 1.0f, 1.0f); } // Use NULL (0) for the texture to reset (bind no texture) void leglBindTexture(TTexture texture) { if(NULL != texture) { glEnable(GL_TEXTURE_2D); BindTexture(texture, 0); // LE command. } else { glBindTexture(GL_TEXTURE_2D, NULL); glDisable(GL_TEXTURE_2D); } } // End drawing. Set "was3D" to true if you specified a camera at leglBegin (= used 3D projection). void leglEnd(bool was3D) { // Undo changes only made in 3D mode (camera != NULL) if (was3D) { glMatrixMode(GL_PROJECTION); glPopMatrix(); glDisable(GL_DEPTH_TEST); } else glPopMatrix(); // Reset transformation. glMatrixMode(GL_MODELVIEW); glPopMatrix(); // Undo changed settings. glDisable(GL_BLEND); glCullFace(GL_BACK); glDisable(GL_CULL_FACE); glColor4f(1.0f, 1.0f, 1.0f, 1.0f); leglBindTexture(NULL); } Quote Windows 10 Pro 64-Bit-Version NVIDIA Geforce 1080 TI Link to comment Share on other sites More sharing options...
VeTaL Posted April 21, 2011 Author Share Posted April 21, 2011 Wow, you had almost saved my day! Extremelly simple and well-commented code. Okay, now i have clear picture without gray blooring (but without button: for now i used "leglBegin(NULL); *** leglEnd(false);") But i still handle exception if (mSizeInBytes != (size_t)bufferSize) { destroy(); MYGUI_PLATFORM_EXCEPT("Data size is mismatch with input array"); } Edited: i think, i need to do something in constructor, as const MyGUI::IntSize& siz = mPlatform->getRenderManagerPtr()->getViewSize(); returns 0,0 to me Edited2: yeaah I added mPlatform->getRenderManagerPtr()->setViewSize(1024,768); to the constructor and now i can see text now xD now, i need to enable textures and fix crash in destructor Edited3: and what is leglBindTexture() for? Edited4: Looking like i'm closer and closer: just need to debug void OpenGLRenderManager::drawOneFrame() and compare my and working version Quote Working on LeaFAQ Link to comment Share on other sites More sharing options...
VeTaL Posted April 22, 2011 Author Share Posted April 22, 2011 Tried DevIL loader (http://www.ogre3d.org/tikiwiki/OpenGL+Image+Loader+Using+DevIL+Image+Library ) - still the same result: have an exception and cant see button picture, only text Quote Working on LeaFAQ Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.