Home » Community » Newbie corner » [BUG] GL canvas gone missing...
[BUG] GL canvas gone missing... [message #50428] |
Sun, 28 October 2018 06:30 |
ptkacz
Messages: 89 Registered: March 2017
|
Member |
|
|
Below is a simple application where a U++ program displays a main window with a popup context menu. When right clicking on the application window, a popup context menu displays listing the option, "Show GL Dialog". Upon selection of the, "Show GL Dialog" menu item, a dialog window displays with the title, "GL Dialog" and a black background.
When minimizing the main window, both main window and dialog minimize. When selecting the application within the task bar, both main window and dialog window are re-displayed upon the desktop window.
Now if one closes the dialog window and then relaunches the dialog window with the right context menu option (i.e. "Show GL Dialog"), the GL Dialog window re-displays, but the GL canvas no longer displays, just a blank grey area.
Just an update, I've added the virtual method Paint() (i.e. virtual void Paint(Draw& w) { canvasGL.GLPaint(); }) to the DialogGL class, but this just results in a screen shot under where the dialog window is launched, displaying within the dialog window. In addition, I've also attempted to set the size of the GL canvas view port, but with no luck either. It's strange that initially when the dialog window is launched, the canvas is properly sized and displayed, but when the dialog window is closed, it doesn't come back.
Why is this so? How does one get the GL canvas to re-display?
Example U++ App:
GLPlay2.lay layout file:
LAYOUT(GLPlay2Layout, 200, 100)
END_LAYOUT
LAYOUT(GLDialogLayout, 400, 200)
END_LAYOUT
main.cpp:
#include <CtrlLib/CtrlLib.h>
#include <GLDraw/GLDraw.h>
#include <GLCtrl/GLCtrl.h>
using namespace Upp;
#define LAYOUTFILE <GLPlay2/GLPlay2.lay>
#include <CtrlCore/lay.h>
struct CanvasGL : GLCtrl {
typedef CanvasGL CLASSNAME;
virtual void GLPaint() {
StdView();
glLoadIdentity();
glShadeModel(GL_SMOOTH);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// glClearDepth(1.0f);
}
virtual void GLResize(int w, int h) {
glViewport(0, 0, (GLsizei)w, (GLsizei)h);
}
};
struct DialogGL : public WithGLDialogLayout<TopWindow> {
typedef DialogGL CLASSNAME;
DialogGL() {
CtrlLayout(*this, "GL Dialog");
Size sz = GetSize();
canvasGL.SetRect(0, 0, sz.cx-1, sz.cy-1);
Add(canvasGL);
}
void open() {
if(!IsOpen()) {
Open();
}
}
void close() {
if(IsOpen()) {
Close();
}
}
private:
CanvasGL canvasGL;
};
class GLPlay2 : public WithGLPlay2Layout<TopWindow> {
public:
typedef GLPlay2 CLASSNAME;
GLPlay2() {
CtrlLayout(*this, "Main App Window");
dialogGL = new DialogGL();
}
~GLPlay2() {
delete dialogGL;
}
void RightDown(Point, dword) {
MenuBar::Execute(
[=](Bar& bar) {
bar.Add("Show GL Dialog", [=] { displayDialog(); });
}
);
}
void displayDialog() {
dialogGL->open();
}
private:
DialogGL* dialogGL;
};
GUI_APP_MAIN
{
GLPlay2().Run();
}
[Updated on: Sun, 04 November 2018 20:08] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Thu May 16 18:33:31 CEST 2024
Total time taken to generate the page: 0.01787 seconds
|