About the size of wxGLCanvas Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: About the size of wxGLCanvas

Post by doublemax »

If you want to center the wxGLCanvas on the wxFrame, the sizer code must be in the wxFrame.

For example, the following code centers a red wxPanel inside a wxFrame:

Code: Select all

// used inside the constructor of a class derived from wxFrame

    wxSizer *mainsizer = new wxBoxSizer(wxVERTICAL);

    wxSizer *hsizer = new wxBoxSizer(wxHORIZONTAL);
    hsizer->AddStretchSpacer(1);
    
    wxPanel *panel = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(64,64));
    panel->SetBackgroundColour(*wxRED);
    hsizer->Add(panel, 0, wxALIGN_CENTER_VERTICAL);

    hsizer->AddStretchSpacer(1);

    mainsizer->Add(hsizer, 0, wxEXPAND);

    SetSizer(hsizer);
There should be no sizer code in the wxGLCanvas.
Use the source, Luke!
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: About the size of wxGLCanvas

Post by doublemax »

Can you try to create a minimal, compilable sample that shows the problem?
Use the source, Luke!
Manolo
Can't get richer than this
Can't get richer than this
Posts: 828
Joined: Mon Apr 30, 2012 11:07 pm

Re: About the size of wxGLCanvas

Post by Manolo »

First, some terminology:
"Resolution" is measured in DPI, "dots per inch". It represents the "density" of the pixels.
"Size" is normally measured in pixels. wxDialog uses "units" instead. OpenGL uses physical size, but a window normally is sized in scaled, "logical" pixels. The factor of the scaling can be queried by GetContentScaleFactor()
A wxSizer controls the position and sizes of the windows it handles.

Now, your case.
Use the wxGLCanvas as any window or control. It has a parent (normally a wxFrame), As doublemax said, use the sizers at the code of the parent of the canvas, not at the canvas itself.

When you want to change the size of the rendering, just change the size of the GLCanvas (SetSize(), not SetMin/Max).
Then you need to call glViewport with the new size of the GLCanvas, avoid weird calculations. This way, the full GLCanvas will fit the Viewport. You know, glViewport can be used to render to a portion (or full) of the window.
WhiteRabbit
Earned a small fee
Earned a small fee
Posts: 17
Joined: Thu Mar 21, 2019 1:54 pm

Re: About the size of wxGLCanvas

Post by WhiteRabbit »

doublemax wrote: Thu Mar 21, 2019 5:11 pm Can you try to create a minimal, compilable sample that shows the problem?
Since I have not solved it yet,
Put the previous code.

MyApp.h

Code: Select all

#pragma once
#include <wx/wxprec.h>
#include "MyFrame.h"
#include "GLContext.h"


class MyApp : public wxApp
{
public:
	MyApp();
	virtual bool OnInit() override;
	virtual int OnExit() override;
	GLContext& GetContext(wxGLCanvas* canvas);

private:
	GLContext* glContext_;
};

wxDECLARE_APP(MyApp);
MyApp.cpp

Code: Select all

#include "MyApp.h"

wxIMPLEMENT_APP(MyApp);

MyApp::MyApp() :
	glContext_(nullptr)
{}

bool MyApp::OnInit()
{
	MyFrame *frame = new MyFrame();
	frame->Show(true);
	return true;
}

int MyApp::OnExit()
{
	delete glContext_;
	return wxApp::OnExit();
}

GLContext & MyApp::GetContext(wxGLCanvas* canvas)
{
	if(!glContext_) glContext_ = new GLContext(canvas);
	glContext_->SetCurrent(*canvas);

	return *glContext_;
}
MyFrame.h

Code: Select all

#pragma once
#include <wx/wxprec.h>

class MyFrame : public wxFrame
{
public:
	MyFrame();
};

MyFrame.cpp

Code: Select all

#include "MyFrame.h"
#include "Window.h"
#include "GLCanvas.h"

MyFrame::MyFrame() :
	wxFrame(NULL, wxID_ANY, Window::kTitle, wxPoint(2200, 200), wxSize(Window::kWidth, Window::kHeight))
{
	GLCanvas *glCanvas = new GLCanvas(this, wxSize(800, 500));

	wxMenu *menuDisplay = new wxMenu;

	wxMenu *menuSubDisplay = new wxMenu;
	menuSubDisplay->AppendRadioItem(ItemID::kScaling_Radio25, "25%");
	menuSubDisplay->AppendRadioItem(ItemID::kScaling_Radio50, "50%");
	menuSubDisplay->AppendRadioItem(ItemID::kScaling_Radio100, "100%");
	menuSubDisplay->AppendRadioItem(ItemID::kScaling_Radio200, "200%");
	menuSubDisplay->AppendRadioItem(ItemID::kScaling_RadioWindow, "WindowSize")->Check(true);
	menuDisplay->AppendSubMenu(menuSubDisplay, "&Scale");

	wxMenuBar *menuBar = new wxMenuBar;
	menuBar->Append(menuDisplay, "&Display");
	SetMenuBar(menuBar);

	CreateStatusBar();
	SetStatusText("Welcome to wxWidgets!");

	Bind(wxEVT_MENU, &GLCanvas::ScalingEvent, glCanvas, ItemID::kScaling_Radio25);
	Bind(wxEVT_MENU, &GLCanvas::ScalingEvent, glCanvas, ItemID::kScaling_Radio50);
	Bind(wxEVT_MENU, &GLCanvas::ScalingEvent, glCanvas, ItemID::kScaling_Radio100);
	Bind(wxEVT_MENU, &GLCanvas::ScalingEvent, glCanvas, ItemID::kScaling_Radio200);
	Bind(wxEVT_MENU, &GLCanvas::ScalingEvent, glCanvas, ItemID::kScaling_RadioWindow);
}

GLContext.h

Code: Select all

#pragma once
#include <wx/wxprec.h>
#include "wx/glcanvas.h"

class GLContext : public wxGLContext
{
public:
	GLContext(wxGLCanvas* canvas);
	~GLContext();
};

GLContext.cpp

Code: Select all

#include "GLContext.h"

GLContext::GLContext(wxGLCanvas * canvas) :
	wxGLContext(canvas)
{
	SetCurrent(*canvas);
}

GLContext::~GLContext()
{}

GLCanvas.h

Code: Select all

#pragma once
#include <wx/wxprec.h>
#include "wx/glcanvas.h"

class GLCanvas : public wxGLCanvas
{
public:
	GLCanvas(wxWindow* parent, const wxSize& windowSize);
	void ScalingEvent(wxCommandEvent& event);

private:
	void OnPaint(wxPaintEvent& event);
	void Draw();

	void WindowSizeInitialize();
	void ViewportMatrixInitialize();
	void ProjectionMatrixInitialize();
	void ModelViewMatrixInitialize();

	float GetRaito();

private:
	const wxSize kResolutionSize_;
	const wxSize kHalfResolutionSize_;

	enum CanvasType
	{
		kScaling25,
		kScaling50,
		kScaling100,
		kScaling200,
		kScalingWindow
	};
	CanvasType currentCanvasType;
};
GLCanvas.cpp

Code: Select all

#include "GLCanvas.h"
#include "GLContext.h"
#include "MyApp.h"
#include "Window.h"

GLCanvas::GLCanvas(wxWindow * parent, const wxSize & resolutionSize) :
	wxGLCanvas(parent, wxID_ANY, nullptr, wxDefaultPosition, resolutionSize, wxBORDER_SIMPLE | wxNO_FULL_REPAINT_ON_RESIZE),
	kResolutionSize_(resolutionSize),
	kHalfResolutionSize_(resolutionSize.x / 2.0f, resolutionSize.y / 2.0f),
	currentCanvasType(CanvasType::kScalingWindow)
{
	GLContext& canvas = wxGetApp().GetContext(this);

	Bind(wxEVT_PAINT, &GLCanvas::OnPaint, this);

	wxBoxSizer *sizer1 = new wxBoxSizer(wxVERTICAL);
	wxBoxSizer *sizer2 = new wxBoxSizer(wxHORIZONTAL);
	sizer1->Add(this, 1, wxALIGN_CENTER);
	sizer2->Add(sizer1, 1, wxALIGN_CENTER);
	SetSizer(sizer2);
	SetAutoLayout(true);
	Center();
}

void GLCanvas::ScalingEvent(wxCommandEvent & event)
{
	switch(event.GetId())
	{
	case ItemID::kScaling_Radio25:
		currentCanvasType = CanvasType::kScaling25;
		break;
	case ItemID::kScaling_Radio50:
		currentCanvasType = CanvasType::kScaling50;
		break;
	case ItemID::kScaling_Radio100:
		currentCanvasType = CanvasType::kScaling100;
		break;
	case ItemID::kScaling_Radio200:
		currentCanvasType = CanvasType::kScaling200;
		break;
	case ItemID::kScaling_RadioWindow:
		currentCanvasType = CanvasType::kScalingWindow;
		break;
	}

	Refresh();
	Update();

	Layout();
	Center();
}

void GLCanvas::OnPaint(wxPaintEvent & event)
{
	wxPaintDC dc(this);

	Draw();
}

void GLCanvas::Draw()
{
	WindowSizeInitialize();

	ViewportMatrixInitialize();
	ModelViewMatrixInitialize();
	ProjectionMatrixInitialize();

	glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	glColor3f(1.0, 0.0, 0.0);
	glBegin(GL_TRIANGLES);
	glVertex2f(-100, 100);
	glVertex2f(0, -100);
	glVertex2i(100, 100);
	glEnd();

	glFlush();
	SwapBuffers();
}

void GLCanvas::WindowSizeInitialize()
{
	if(currentCanvasType == CanvasType::kScalingWindow)
	{
		wxSize parentSize = this->GetParent()->GetClientSize();

		float parentAspect = (float)parentSize.x / parentSize.y;
		float aspect = (float)kResolutionSize_.x / kResolutionSize_.y;

		if(parentAspect < aspect)
		{
			//this->SetClientSize(wxSize(parentSize.x, (float)parentSize.x / aspect));
			this->SetMinClientSize(wxSize(parentSize.x, (float)parentSize.x / aspect));
			this->SetMaxClientSize(wxSize(parentSize.x, (float)parentSize.x / aspect));
		}
		
		else
		{
			//this->SetClientSize(wxSize((float)parentSize.y * aspect, parentSize.y));
			this->SetMinClientSize(wxSize((float)parentSize.y * aspect, parentSize.y));
			this->SetMaxClientSize(wxSize((float)parentSize.y * aspect, parentSize.y));
		}
	}
	else
	{
		//this->SetClientSize(kResolutionSize_ * GetRaito());
	    this->SetMinClientSize(kResolutionSize_ * GetRaito());
	    this->SetMaxClientSize(kResolutionSize_ * GetRaito());
	}

	Center();
}

void GLCanvas::ViewportMatrixInitialize()
{
	float raito = GetRaito();
	glViewport(0, 0, kResolutionSize_.x * raito, kResolutionSize_.y * raito);
}

void GLCanvas::ProjectionMatrixInitialize()
{
	float raito = GetRaito();
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	glOrtho(-kHalfResolutionSize_.x * raito, kHalfResolutionSize_.x * raito, kHalfResolutionSize_.y * raito, -kHalfResolutionSize_.y * raito, 0.0f, 1.0f);
}

void GLCanvas::ModelViewMatrixInitialize()
{
	float raito = GetRaito();
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

	const wxSize parentSize = this->GetParent()->GetClientSize();
	if(currentCanvasType != CanvasType::kScalingWindow)
	{
		float difference = kResolutionSize_.y * raito - parentSize.y;
		if(difference < 0.0f) difference = 0.0f;
		glTranslatef(0.0f, difference, 0.0f);
	}

	glScalef(raito, raito, raito);
}

float GLCanvas::GetRaito()
{
	float raito = 0.0f;
	switch(currentCanvasType)
	{
	case CanvasType::kScaling25:
		raito = 0.25f;
		break;
	case CanvasType::kScaling50:
		raito = 0.5f;
		break;
	case CanvasType::kScaling100:
		raito = 1.0f;
		break;
	case CanvasType::kScaling200:
		raito = 2.0f;
		break;
	case CanvasType::kScalingWindow:
		raito = (float)this->GetSize().x / kResolutionSize_.x;
		break;
	}

	return raito;
}
WhiteRabbit
Earned a small fee
Earned a small fee
Posts: 17
Joined: Thu Mar 21, 2019 1:54 pm

Re: About the size of wxGLCanvas

Post by WhiteRabbit »

Manolo wrote: Thu Mar 21, 2019 6:40 pm First, some terminology:
"Resolution" is measured in DPI, "dots per inch". It represents the "density" of the pixels.
"Size" is normally measured in pixels. wxDialog uses "units" instead. OpenGL uses physical size, but a window normally is sized in scaled, "logical" pixels. The factor of the scaling can be queried by GetContentScaleFactor()
A wxSizer controls the position and sizes of the windows it handles.

Now, your case.
Use the wxGLCanvas as any window or control. It has a parent (normally a wxFrame), As doublemax said, use the sizers at the code of the parent of the canvas, not at the canvas itself.

When you want to change the size of the rendering, just change the size of the GLCanvas (SetSize(), not SetMin/Max).
Then you need to call glViewport with the new size of the GLCanvas, avoid weird calculations. This way, the full GLCanvas will fit the Viewport. You know, glViewport can be used to render to a portion (or full) of the window.
understood. I'll try to do my best.
Thankyou.
WhiteRabbit
Earned a small fee
Earned a small fee
Posts: 17
Joined: Thu Mar 21, 2019 1:54 pm

Re: About the size of wxGLCanvas

Post by WhiteRabbit »

doublemax wrote: Thu Mar 21, 2019 4:08 pm If you want to center the wxGLCanvas on the wxFrame, the sizer code must be in the wxFrame.

For example, the following code centers a red wxPanel inside a wxFrame:

Code: Select all

// used inside the constructor of a class derived from wxFrame

    wxSizer *mainsizer = new wxBoxSizer(wxVERTICAL);

    wxSizer *hsizer = new wxBoxSizer(wxHORIZONTAL);
    hsizer->AddStretchSpacer(1);
    
    wxPanel *panel = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(64,64));
    panel->SetBackgroundColour(*wxRED);
    hsizer->Add(panel, 0, wxALIGN_CENTER_VERTICAL);

    hsizer->AddStretchSpacer(1);

    mainsizer->Add(hsizer, 0, wxEXPAND);

    SetSizer(hsizer);
There should be no sizer code in the wxGLCanvas.

I created wxPanel and put wxGLCanvas under it. However, the phenomenon that drawing is not done will occur.

This is the difference from the code we posted earlier.
GLCanvas.h and GLCanvas.cpp are not used

MyFrame.cpp

Code: Select all

#include "MyFrame.h"
#include "Window.h"
#include "GLPanel.h"

MyFrame::MyFrame() :
	wxFrame(NULL, wxID_ANY, Window::kTitle, wxPoint(2200, 200), wxSize(Window::kWidth, Window::kHeight))
{
	wxSizer *mainsizer = new wxBoxSizer(wxVERTICAL);
	wxSizer *hsizer = new wxBoxSizer(wxHORIZONTAL);
	hsizer->AddStretchSpacer(1);
	GLPanel *glPanel = new GLPanel(this, wxSize(800, 500));
	hsizer->Add(glPanel, 0, wxALIGN_CENTER_VERTICAL);
	hsizer->AddStretchSpacer(1);
	mainsizer->Add(hsizer, 0, wxEXPAND);
	SetSizer(hsizer);

	wxMenu *menuDisplay = new wxMenu;

	wxMenu *menuSubDisplay = new wxMenu;
	menuSubDisplay->AppendRadioItem(ItemID::kScaling_Radio25, "25%");
	menuSubDisplay->AppendRadioItem(ItemID::kScaling_Radio50, "50%");
	menuSubDisplay->AppendRadioItem(ItemID::kScaling_Radio100, "100%");
	menuSubDisplay->AppendRadioItem(ItemID::kScaling_Radio200, "200%");
	menuSubDisplay->AppendRadioItem(ItemID::kScaling_RadioWindow, "WindowSize")->Check(true);
	menuDisplay->AppendSubMenu(menuSubDisplay, "&Scale");

	wxMenuBar *menuBar = new wxMenuBar;
	menuBar->Append(menuDisplay, "&Display");
	SetMenuBar(menuBar);

	CreateStatusBar();
	SetStatusText("Welcome to wxWidgets!");

	Bind(wxEVT_MENU, &GLPanel::ScalingEvent, glPanel, ItemID::kScaling_Radio25);
	Bind(wxEVT_MENU, &GLPanel::ScalingEvent, glPanel, ItemID::kScaling_Radio50);
	Bind(wxEVT_MENU, &GLPanel::ScalingEvent, glPanel, ItemID::kScaling_Radio100);
	Bind(wxEVT_MENU, &GLPanel::ScalingEvent, glPanel, ItemID::kScaling_Radio200);
	Bind(wxEVT_MENU, &GLPanel::ScalingEvent, glPanel, ItemID::kScaling_RadioWindow);
}
GLPanel.h

Code: Select all

#pragma once
#include <wx/wxprec.h>
#include <wx/glcanvas.h>

class GLPanel : public wxPanel
{
public:
	GLPanel(wxWindow * parent, const wxSize & resolutionSize);
	void ScalingEvent(wxCommandEvent& event);

private:
	void OnPaint(wxPaintEvent& event);
	void Draw();

	void WindowSizeInitialize();
	void ViewportMatrixInitialize();
	void ProjectionMatrixInitialize();
	void ModelViewMatrixInitialize();

	float GetRaito();

private:
	wxGLCanvas* glCanvas_;
	const wxSize kResolutionSize_;
	const wxSize kHalfResolutionSize_;

	enum CanvasType
	{
		kScaling25,
		kScaling50,
		kScaling100,
		kScaling200,
		kScalingWindow
	};
	CanvasType currentCanvasType;
};

GLPanel.cpp

Code: Select all

#include "GLPanel.h"
#include "GLContext.h"
#include "MyApp.h"
#include "Window.h"

GLPanel::GLPanel(wxWindow * parent, const wxSize & resolutionSize) :
	wxPanel(parent, wxID_ANY, wxDefaultPosition, resolutionSize, wxBORDER_SIMPLE | wxFULL_REPAINT_ON_RESIZE),
	glCanvas_(new wxGLCanvas(this, wxID_ANY, nullptr, wxDefaultPosition, resolutionSize)),
	kResolutionSize_(resolutionSize),
	kHalfResolutionSize_(resolutionSize.x / 2.0f, resolutionSize.y / 2.0f),
	currentCanvasType(CanvasType::kScalingWindow)
{
	GLContext& canvas = wxGetApp().GetContext(glCanvas_);
	glCanvas_->SetCurrent(canvas);
	Bind(wxEVT_PAINT, &GLPanel::OnPaint, this);

	SetBackgroundColour(*wxGREEN);
}

void GLPanel::ScalingEvent(wxCommandEvent & event)
{
	switch(event.GetId())
	{
	case ItemID::kScaling_Radio25:
		currentCanvasType = CanvasType::kScaling25;
		break;
	case ItemID::kScaling_Radio50:
		currentCanvasType = CanvasType::kScaling50;
		break;
	case ItemID::kScaling_Radio100:
		currentCanvasType = CanvasType::kScaling100;
		break;
	case ItemID::kScaling_Radio200:
		currentCanvasType = CanvasType::kScaling200;
		break;
	case ItemID::kScaling_RadioWindow:
		currentCanvasType = CanvasType::kScalingWindow;
		break;
	}

	Refresh();
	Update();
}

void GLPanel::OnPaint(wxPaintEvent & event)
{
	wxPaintDC dc(this);

	Draw();
}

void GLPanel::Draw()
{
	WindowSizeInitialize();

	ViewportMatrixInitialize();
	ModelViewMatrixInitialize();
	ProjectionMatrixInitialize();

	glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	glColor3f(1.0, 0.0, 0.0);
	glBegin(GL_TRIANGLES);
	glVertex2f(-100, 100);
	glVertex2f(0, -100);
	glVertex2i(100, 100);
	glEnd();

	glFlush();
	glCanvas_->SwapBuffers();
}

void GLPanel::WindowSizeInitialize()
{
	if(currentCanvasType == CanvasType::kScalingWindow)
	{
		wxSize parentSize = GetParent()->GetClientSize();

		float parentAspect = (float)parentSize.x / parentSize.y;
		float aspect = (float)kResolutionSize_.x / kResolutionSize_.y;

		if(parentAspect < aspect)
		{
			SetClientSize(wxSize(parentSize.x, (float)parentSize.x / aspect));
			SetMinClientSize(wxSize(parentSize.x, (float)parentSize.x / aspect));
			SetMaxClientSize(wxSize(parentSize.x, (float)parentSize.x / aspect));
		}

		else
		{
			SetClientSize(wxSize((float)parentSize.y * aspect, parentSize.y));
			SetMinClientSize(wxSize((float)parentSize.y * aspect, parentSize.y));
			SetMaxClientSize(wxSize((float)parentSize.y * aspect, parentSize.y));
		}
	}
	else
	{
		SetClientSize(kResolutionSize_ * GetRaito());
		SetMinClientSize(kResolutionSize_ * GetRaito());
		SetMaxClientSize(kResolutionSize_ * GetRaito());
	}

	Center();
}

void GLPanel::ViewportMatrixInitialize()
{
	float raito = GetRaito();
	glViewport(0, 0, kResolutionSize_.x * raito, kResolutionSize_.y * raito);
}

void GLPanel::ProjectionMatrixInitialize()
{
	float raito = GetRaito();
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	glOrtho(-kHalfResolutionSize_.x * raito, kHalfResolutionSize_.x * raito, kHalfResolutionSize_.y * raito, -kHalfResolutionSize_.y * raito, 0.0f, 1.0f);
}

void GLPanel::ModelViewMatrixInitialize()
{
	float raito = GetRaito();
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

	const wxSize parentSize = this->GetParent()->GetClientSize();
	if(currentCanvasType != CanvasType::kScalingWindow)
	{
		float difference = kResolutionSize_.y * raito - parentSize.y;
		if(difference < 0.0f) difference = 0.0f;
		glTranslatef(0.0f, difference, 0.0f);
	}

	glScalef(raito, raito, raito);
}

float GLPanel::GetRaito()
{
	float raito = 0.0f;
	switch(currentCanvasType)
	{
	case CanvasType::kScaling25:
		raito = 0.25f;
		break;
	case CanvasType::kScaling50:
		raito = 0.5f;
		break;
	case CanvasType::kScaling100:
		raito = 1.0f;
		break;
	case CanvasType::kScaling200:
		raito = 2.0f;
		break;
	case CanvasType::kScalingWindow:
		raito = (float)this->GetSize().x / kResolutionSize_.x;
		break;
	}

	return raito;
}
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: About the size of wxGLCanvas

Post by doublemax »

I played around with your code a bit. I think the code in WindowSizeInitialize was the root problem as it collided with the sizer code. After i understood what it does, i though this should be possible with sizers alone. Unfortunately the sizer flag combination for this does work, but causes an assert at run-time.

As the file "window.h" was missing, i replaced it with my own version and replaced a few variables with hard coded values. BTW: The filename "window.h" for one of your own headers is a bad idea, as wxWidgets itself also has an include file with the same name.
Attachments
glcanvas.zip
(4.2 KiB) Downloaded 59 times
Use the source, Luke!
WhiteRabbit
Earned a small fee
Earned a small fee
Posts: 17
Joined: Thu Mar 21, 2019 1:54 pm

Re: About the size of wxGLCanvas

Post by WhiteRabbit »

doublemax wrote: Fri Mar 22, 2019 9:11 am I played around with your code a bit. I think the code in WindowSizeInitialize was the root problem as it collided with the sizer code. After i understood what it does, i though this should be possible with sizers alone. Unfortunately the sizer flag combination for this does work, but causes an assert at run-time.

As the file "window.h" was missing, i replaced it with my own version and replaced a few variables with hard coded values. BTW: The filename "window.h" for one of your own headers is a bad idea, as wxWidgets itself also has an include file with the same name.

I'm sorry, I forgot to show Window.cpp, .h.
I will change the name this time.

Well, before this post is done
I thought and made it myself.
It works for a while. (Only the code is dirty and there is flicker.
Attachments
MyApp.zip
(4.25 KiB) Downloaded 54 times
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: About the size of wxGLCanvas

Post by doublemax »

Did you check the code i posted? I think it does what you intended.
Use the source, Luke!
WhiteRabbit
Earned a small fee
Earned a small fee
Posts: 17
Joined: Thu Mar 21, 2019 1:54 pm

Re: About the size of wxGLCanvas

Post by WhiteRabbit »

doublemax wrote: Fri Mar 22, 2019 11:44 am Did you check the code i posted? I think it does what you intended.
I'm sorry. I misunderstood the previous topic. It went well!
Thank you very much.
Post Reply