Help? GTK events do/dont's for dummies (nothing works)

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Mick P.
Experienced Solver
Experienced Solver
Posts: 76
Joined: Thu Jun 06, 2019 3:41 am
Contact:

Re: Help? GTK events do/dont's for dummies (nothing works)

Post by Mick P. » Mon Jun 17, 2019 4:50 pm

FWIW the paid (non-opensource) version of Xming is able to run the cube demo without the surface corruption issue exhibited by the Cygwin X server.

It can also run my software, mostly... it still occasionally goes into non-communicative mode. I'm trying to find superior ways to debug these things, but I'm pretty new to the scene. The generally recommended technique of using "--sync" is getting me nowhere. GTK refuses to consume it, and I cannot see a difference, on both Ubuntu and Cygwin. Though oddly Cygwin aborts on "sync" as unrecognized (command-line parsing system I've not yet dug into) but Ubuntu strangely does not. But it doesn't strip it from the arguments either. So I assume it's doing nothing.

If I had to bet, I'm thinking the corruption problem is the GTK2 path again. Xming is not a better server than Cygwin's I'd say overall in terms of visual compatibility. The Cygwin server has some true annoyances, like it cannot hide windows without destroying them. I tried to get them to fix this so glutHideWindow would work, but they still haven't. Since I'm writing my own GLUT layer I can now pseudo-hide the windows in various ways. Xming can't raise/lower windows or change their order. Generally these limitations probably only apply to "subwindows".

wxGLCanvas has an x11Direct member that appears to not be used:

https://github.com/wxWidgets/wxWidgets/ ... =x11Direct

It's a problem that it assumes direct connections. One X server I have (X410) flat refuses direct (DRI) connections. Part of the problem is lack of solid server options on Windows. I've written some user-agent code for them, but I have a filling there may be many more server options in the world outside Windows by comparison. It's a little unsettling to have to write code against unreliable agents, but it's not so different from web design.

User avatar
doublemax
Moderator
Moderator
Posts: 13909
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Help? GTK events do/dont's for dummies (nothing works)

Post by doublemax » Mon Jun 17, 2019 6:23 pm

Do you know if wxGLCanvas is a critical part of any major software with a large user base?
I don't know. There are a few applications listed at http://www.wxwidgets.org/about/screenshots/ that look like they would use wxGLCanvas. But they probably won't have "large" user bases.
The opengl examples (wx3.0-examples) should be adequate for that?
So you're saying the same issues are visible in the unmodified samples? In that case that would be a case for a bug report at http://trac.wxwidgets.org
Use the source, Luke!

Manolo
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 691
Joined: Mon Apr 30, 2012 11:07 pm

Re: Help? GTK events do/dont's for dummies (nothing works)

Post by Manolo » Tue Jun 18, 2019 12:33 am

MickP, I see a lot of complains from you, never with enough code (or even worst: no code at all) that justifies your issues. That's not good if you want to get help. People may try to guess, or may try to correct some wrong comments. but that's all. Most of people will skip to other questions where they can be more helpful.

I taken a look at the code you posted on Thursday 13. It's difficult to follow. Too C-ish; and no "autoselfexplanatory" names. Can you write more pure C++? Can you avoid those nasty castings, specially (void*)?

What I would do in your case:
+ Put code for wxWidgets and glut in different files; and don't mix them, that's a can of worms.
+ Don't abuse "#define". Don't #define some already defined, like _() (which in wx is used for translations). Why do you create an operator named wxSize()? wxWidgets already have that name as a class.
+ Prefer names distinct not only in the uppercase.
And on top of that:
+ Start with a simple wxFrame. Put a wxGLCanvas inside it. Create a wxGLContext.
+ Add events handlers and draw something easy, just to check OpenGL and your handles work.
+ Study docs and samples for every feature you need.
Then, add progressively the complexity you wish.

If you do so, it's easy to narrow an issue, and it's also easier for people to help you, if you post the relevant code an the errors you get.

Mick P.
Experienced Solver
Experienced Solver
Posts: 76
Joined: Thu Jun 06, 2019 3:41 am
Contact:

Re: Help? GTK events do/dont's for dummies (nothing works)

Post by Mick P. » Tue Jun 18, 2019 12:11 pm

Manolo, https://github.com/isocpp/CppCoreGuidelines is a good source for where current thinking is on best practices. Programmers have a lot of bad instincts. but the consensus is slowly getting better. Orthodoxies change. These are diametrically opposite of the prevailing wisdom of a decade ago, which still lingers.
Manolo wrote:
Tue Jun 18, 2019 12:33 am
MickP, I see a lot of complains from you, never with enough code (or even worst: no code at all) that justifies your issues. That's not good if you want to get help. People may try to guess, or may try to correct some wrong comments. but that's all. Most of people will skip to other questions where they can be more helpful.
You won't glean much from studying other peoples code. I don't recommend it. English is better! Though If you look closely at the code you'll see it is implementing virtually the entire GLUT framework in terms of wxWidgets, which thanks to wxWidgets can be done in one brief definition file. That's amazing =D>

I didn't make this topic to get assistance. I made it because the GTK side doesn't work. So I was looking for some advice on what works. I've since had a lot of time to massage the GTK code (edited: I mean "pathways" dedicated to GTK/GLX; not literally modifying wxGTK) to make it more-or-less work. It's not because the code is wrong. The foundation is wrong. But the real world is messy, and so code can be messy too. If we are too caught up in the intricacies of code it's a little loony tunes, like taking a broom outside to sweep up dirt off the ground!

Like I said somewhere in here (I apologize for the chaos) it's really not wxWidget's job to make GTK work. So it's not a criticism of wxWidgets. At least not if it's doing the best it can do. Which I don't know if it is or is not. But don't take criticism personally. They don't have to be emotionally weighty things. They can just be matter of fact acknowledgement of reality too.


EDITED: To clarify, when I say GTK "doesn't work" I mean that it doesn't operate like software, or like a machine. It operates more like a human being. In other words, it's completely chaotic, unreliable, error prone; you must check its work, and follow-up if it doesn't produce the desired work, etc. Which I suppose is kind of what you'd expect given the fact the free-software world is basically a jungle, and the system it's built on is a communication protocol. It's more like UDP than TCP. I.e. unreliable. So the same wxWidgets code that works for Windows--or other systems maybe too--massively doesn't work for GTK. So it needs lots of trial-and-error conditions to help it have acceptable outcomes. That's when you're glad wxWidgets is giving you a lingua-franca to write code in, even if these systems you're talking to have completely different "personalities' so-to-speak.
Last edited by Mick P. on Wed Jun 19, 2019 2:00 pm, edited 2 times in total.

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 3366
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Help? GTK events do/dont's for dummies (nothing works)

Post by ONEEYEMAN » Tue Jun 18, 2019 3:14 pm

Hi,
First of all I can assure you that when you talking software plain English is the worst language you can talk.
Second, remember GTK+ is written in pure C. Which means that there is no "nice" stuff C++ can give you - especially not C++11. So you should do a lot of stuff manually.

Thank you.

Mick P.
Experienced Solver
Experienced Solver
Posts: 76
Joined: Thu Jun 06, 2019 3:41 am
Contact:

Re: Help? GTK events do/dont's for dummies (nothing works)

Post by Mick P. » Wed Jun 19, 2019 1:34 pm

doublemax wrote:
Mon Jun 17, 2019 6:23 pm
I don't know. There are a few applications listed at http://www.wxwidgets.org/about/screenshots/ that look like they would use wxGLCanvas. But they probably won't have "large" user bases.
CopperCube (http://www.wxwidgets.org/about/screenshots/) looks interesting for something I'd never heard about. Thanks.

https://www.ambiera.com/coppercube/
ONEEYEMAN wrote:
Tue Jun 18, 2019 3:14 pm
Hi,
First of all I can assure you that when you talking software plain English is the worst language you can talk.
Second, remember GTK+ is written in pure C. Which means that there is no "nice" stuff C++ can give you - especially not C++11. So you should do a lot of stuff manually.

Thank you.
Uh, maybe when it comes to "comments" in code code speaks louder than English, but not when it comes to discussions between people. Copy/pasting code is one step up from bleep-blooping at each other. On point #2 what language code is written in doesn't matter. It just matters if the code is sound. But what matters most is maintenance and maintainability. Usually less code is easier to maintain. That's cardinal rule #1.

EDITED: For the record, if by name-checking GTK+ your impression is I'm suggesting working with GTK or glib that's not what I mean to suggest. At least to make wxGLCanvas based windows work, pretty much every event handler has to branch based on what is the underlying system, since they have to all be handled differently. In a perfect world there would be no branches. And that's what a high-level system should deliver. Since it's easier to maintain code that doesn't have mixed logic embedded in it. And a high-level system can be written once, reused by many. But wxWidgets isn't high-level. So it's outside of its problem domain.

Ironically the UI library I'm developing on top of wxWidgets is called Widgets 95, and I ended up using the nickname XCV for it, because that's 95 in Roman numerals. It also happens to be the Querty keyboard sequence for cut/copy/paste and easy to type, so I don't know, it's interesting. If you make it an acronym it is WX (Widgets XCV) Or XW (XCV Widgets) which happens to be the same digraph wxWidgets uses. I'm maintaining a simplified version based on GLUI that I called GLUI Library, which in acronym form is GL, which is also in line with the traditional libraries attached to OpenGL. But the original GLUI library is an absolute birds nest of a mess. So it's not really the caliber of other libraries, but it integrates with GLUT, but it probably never worked well. My rewritten version (https://github.com/mick-p1982/glui) works perfectly, but is more or a stepping stone. My instincts attracted me to it because it reminded me of Win32, which I've spent a lot of time with. I saw it as potentially a way to port some Win32 classic style apps to cross-platform later on. That's why the successor is called "Widgets 95" too, a la Windows 95: https://sourceforge.net/projects/widgets-95/

Post Reply