haxeui / hxWidgets

Haxe externs (and wrappers) for wxWidgets
MIT License
77 stars 22 forks source link

Add GLCanvas. #20

Closed tienery closed 8 years ago

tienery commented 8 years ago

I know it works, because I've tested it (on Windows, anyway):

img

ianharrigan commented 8 years ago

Integration failures: https://travis-ci.org/ianharrigan/hxWidgets/jobs/116421980

ianharrigan commented 8 years ago

ignore the appveyor one- its travis, ie, linux / osx

tienery commented 8 years ago

I've added an "#undef RegisterClass" not sure if that's the culprit.

ianharrigan commented 8 years ago

Nope, thats windows stuff - and might be needed, although, if it compiles without, its better to not undef the macro of course. The failures are below (if you click "Details")

Error: ./src/hx/widgets/GLCanvas.cpp: In member function ‘Void hx::widgets::GLCanvas_obj::__construct(hx::widgets::Window, hx::Null<int>)’:
./src/hx/widgets/GLCanvas.cpp:43:61: error: call of overloaded ‘wxGLCanvas(cpp::Reference<wxWindow>&, int&)’ is ambiguous
./src/hx/widgets/GLCanvas.cpp:43:61: note: candidates are:
/usr/include/wx-3.0/wx/gtk/glcanvas.h:76:5: note: wxGLCanvas::wxGLCanvas(wxWindow*, const wxGLCanvas*, wxWindowID, const wxPoint&, const wxSize&, long int, const wxString&, const int*, const wxPalette&) <near match>
/usr/include/wx-3.0/wx/gtk/glcanvas.h:76:5: note:   no known conversion for argument 2 from ‘int’ to ‘const wxGLCanvas*’
/usr/include/wx-3.0/wx/gtk/glcanvas.h:64:5: note: wxGLCanvas::wxGLCanvas(wxWindow*, const wxGLContext*, wxWindowID, const wxPoint&, const wxSize&, long int, const wxString&, const int*, const wxPalette&) <near match>
/usr/include/wx-3.0/wx/gtk/glcanvas.h:64:5: note:   no known conversion for argument 2 from ‘int’ to ‘const wxGLContext*’
/usr/include/wx-3.0/wx/gtk/glcanvas.h:53:5: note: wxGLCanvas::wxGLCanvas(wxWindow*, wxWindowID, const wxPoint&, const wxSize&, long int, const wxString&, const int*, const wxPalette&)
/usr/include/wx-3.0/wx/gtk/glcanvas.h:23:5: note: wxGLCanvas::wxGLCanvas(wxWindow*, wxWindowID, const int*, const wxPoint&, const wxSize&, long int, const wxString&, const wxPalette&)
Error: Build failed
tienery commented 8 years ago

I added undef due to a build failure on Windows, I'm assuming because glcanvas.h in wx uses windows.h in some way. But I'll try and fix the constructor call.

ianharrigan commented 8 years ago

Well, the undef is needed (in some cases) because hxcpp defines its own RegisterClass function which clashes with the windows macro.

tienery commented 8 years ago

Not entirely sure which version of the docs I was using, but just for reference: http://docs.wxwidgets.org/3.0/classwx_g_l_canvas.html

Is 3.0 the version the Linux/Mac builds on Travis using?

ibilon commented 8 years ago

Yes travis, actually the entire repository, use wxWidgets 3.0.

tienery commented 8 years ago

Hmm, it's curious. I thought I saw a completely different constructor at some point. Not sure what I was looking at that accepted wxGLAttributes. Regardless, I've added it anyway.

Also, I'm a bit confused about the build error:

./src/hx/widgets/GLCanvas.cpp:43:61: error: call of overloaded     ‘wxGLCanvas(cpp::Reference<wxWindow>&, int&)’ is ambiguous
./src/hx/widgets/GLCanvas.cpp:43:61: note: candidates are:
/usr/include/wx-3.0/wx/gtk/glcanvas.h:76:5: note: wxGLCanvas::wxGLCanvas(wxWindow*, const wxGLCanvas*, wxWindowID, const wxPoint&, const wxSize&, long int, const wxString&, const int*, const wxPalette&) <near match>
/usr/include/wx-3.0/wx/gtk/glcanvas.h:76:5: note:   no known conversion for argument 2 from ‘int’ to ‘const wxGLCanvas*’
/usr/include/wx-3.0/wx/gtk/glcanvas.h:64:5: note: wxGLCanvas::wxGLCanvas(wxWindow*, const wxGLContext*, wxWindowID, const wxPoint&, const wxSize&, long int, const wxString&, const int*, const wxPalette&) <near match>
/usr/include/wx-3.0/wx/gtk/glcanvas.h:64:5: note:   no known conversion for argument 2 from ‘int’ to ‘const wxGLContext*’
/usr/include/wx-3.0/wx/gtk/glcanvas.h:53:5: note: wxGLCanvas::wxGLCanvas(wxWindow*, wxWindowID, const wxPoint&, const wxSize&, long int, const wxString&, const int*, const wxPalette&)
/usr/include/wx-3.0/wx/gtk/glcanvas.h:23:5: note: wxGLCanvas::wxGLCanvas(wxWindow*, wxWindowID, const int*, const wxPoint&, const wxSize&, long int, const wxString&, const wxPalette&)
Error: Build failed

It requires a raw pointer to Window, which works for others but not this. How are overloads handled in Haxe? @:overload? I would have thought the compiler would just know what arguments to use considering everything else after parent is optional.

tienery commented 8 years ago

I think I had this same problem before when writing my SFML extern, just not sure how I fixed it...

tienery commented 8 years ago

Oh, lol... I'm using version 3.1 of wxWidgets on Windows... Should I test against 3.0?

ianharrigan commented 8 years ago

I dont think that is your issue. I think the issue is the ambiguity to the constructor call.

ibilon commented 8 years ago

Yeah all 3.X is compatible since 3.1+ would only contains additions to the api not modifications.

tienery commented 8 years ago

3.1.1 (Dev version): http://docs.wxwidgets.org/trunk/classwx_g_l_canvas.html#af63e54ebdb6a8564444d65b673e540fa

3.0.1 (Stable): http://docs.wxwidgets.org/3.0/classwx_g_l_canvas.html

I think it is... the ambiguity is as a result of using different versions. I'm using the dev build. I need to reinstall wxwidgets with 3.0.

ianharrigan commented 8 years ago

No the ambiguity is because its ambiguous. The compiler doesnt know which constructor you are trying to use.

ibilon commented 8 years ago

That's a weird modification for a minor version, but anyway we can't be compatible with the dev version, too many changes all the time.

ianharrigan commented 8 years ago
wxGLCanvas::wxGLCanvas(wxWindow*, wxWindowID, const wxPoint&, const wxSize&, long int, const wxString&, const int*, const wxPalette&)
wxGLCanvas::wxGLCanvas(wxWindow*, wxWindowID, const int*, const wxPoint&, const wxSize&, long int, const wxString&, const wxPalette&)

And you are calling wxGLCanvas(something, -1)

tienery commented 8 years ago

Well... I've added the wxPoint and wxSize parameters into the constructor.

But I can't test because 3.1 doesn't have a signature matching that XD It's stupid, it really is.

My fault for using the dev version, really.

ianharrigan commented 8 years ago

Right, then yeah you are using the wrong version. as @ibilon said, we should be using the latest stable release.

tienery commented 8 years ago

Well, I shouldn't really say the "dev" version, the Linux/Mac version you're using to test against is 3.0, which has a major change in API when you move over to 3.1, which is insane and makes testing very difficult for these APIs.

ibilon commented 8 years ago

Also I'm not against merging the GLAttribute class, after fixing it, but unless it's in the sample travis isn't trying to build it and we can't be sure it works.

3.1 is dev since 3.0.2 is the latest stable.

ianharrigan commented 8 years ago

Actually, im using 3.1 on my machine too. Going to look at the header file

tienery commented 8 years ago

I'm no longer using the GLAttribute class in the test to get it working on 3.0, not 3.1, which is the version of the constructor signature GLAttributes is needed.

There's also a difference in folder names between version 3.0 and 3.1 on Windows... lol... wxwidgets maintainers really do make life difficult, don't they?

ianharrigan commented 8 years ago

Constructors look fine

class WXDLLIMPEXP_GL wxGLCanvas : public wxGLCanvasBase
{
public:
    wxEXPLICIT // avoid implicitly converting a wxWindow* to wxGLCanvas
    wxGLCanvas(wxWindow *parent,
               const wxGLAttributes& dispAttrs,
               wxWindowID id = wxID_ANY,
               const wxPoint& pos = wxDefaultPosition,
               const wxSize& size = wxDefaultSize,
               long style = 0,
               const wxString& name = wxGLCanvasName,
               const wxPalette& palette = wxNullPalette);

    wxEXPLICIT
    wxGLCanvas(wxWindow *parent,
               wxWindowID id = wxID_ANY,
               const int *attribList = NULL,
               const wxPoint& pos = wxDefaultPosition,
               const wxSize& size = wxDefaultSize,
               long style = 0,
               const wxString& name = wxGLCanvasName,
               const wxPalette& palette = wxNullPalette);

    bool Create(wxWindow *parent,
                const wxGLAttributes& dispAttrs,
                wxWindowID id = wxID_ANY,
                const wxPoint& pos = wxDefaultPosition,
                const wxSize& size = wxDefaultSize,
                long style = 0,
                const wxString& name = wxGLCanvasName,
                const wxPalette& palette = wxNullPalette);

    bool Create(wxWindow *parent,
                wxWindowID id = wxID_ANY,
                const wxPoint& pos = wxDefaultPosition,
                const wxSize& size = wxDefaultSize,
                long style = 0,
                const wxString& name = wxGLCanvasName,
                const int *attribList = NULL,
                const wxPalette& palette = wxNullPalette);
tienery commented 8 years ago

Actually, the create function is what would be needed for Windows, versus the actual constructor.

ianharrigan commented 8 years ago

Erm, so how are you going to call a function on a class without constructing it? The 3rd contstructor looks like the correct candidate.

ianharrigan commented 8 years ago

actually, sorry, i meant the second constructor

tienery commented 8 years ago

Well, the first two functions appear to be constructors, then the next two are member functions of the class, being "Create". The first of which I used to test for Windows using version 3.1 of wxWidgets. But in order for the test to work on Linux and Mac, either travis-ci build config needs to change to make sure it's tested against 3.1 instead of 3.0, or I revert to version 3.0 locally and test against that instead, and tell people to use GLCanvas with care and use it only using version 3.0.

Not sure what the best solution is.

The second constructor requires const int* as the third parameter, which looks a bit out of my comfort zone to try and implement in Haxe.

ianharrigan commented 8 years ago

try something like:

.createInstance(parent != null ? parent._ref : Window.nullWindowRef, untyped __cpp__("((wxWindowID)id)"), Point.defaultPositionRef, Size.defaultSizeRef, style);

Or whatever the other params are, the important bit is the untyped __cpp__("((wxWindowID)id)") so that it uses the correct constructor

tienery commented 8 years ago

I've tested against 3.0, which works. Do you want me to commit those changes and go from there? (I've changed Build.xml to link to the correct versions of the libs because I'm not sure how to check between versions)

ianharrigan commented 8 years ago

I dont see why you cant use this constructor, which seems to be available on 3.0 and 3.1:

    wxGLCanvas(wxWindow *parent,
               wxWindowID id = wxID_ANY,
               const int *attribList = NULL,
               const wxPoint& pos = wxDefaultPosition,
               const wxSize& size = wxDefaultSize,
               long style = 0,
               const wxString& name = wxGLCanvasName,
               const wxPalette& palette = wxNullPalette);
tienery commented 8 years ago

Well, as far as I am concerned, compiler's don't lie:

img

It's requiring wxGLAttributes... If I add that it then becomes incompatible with 3.0 to test on Linux/Mac.

It's up to you. Do you want me to send over the latest commits, which I'm sure will work on Linux and Mac on travis this time?

ianharrigan commented 8 years ago

You are right, compilers dont lie.

No constructor could take the source type, or the constructor overload resolution was ambiguous

There are two constructors one takes an const wxGLAttributes& dispAttrs as a second parameter, the other takes wxWindowID id as the second.

ianharrigan commented 8 years ago

3.0 and 3.1 have the latter version (wxWindowID). So you just need to use the right one. untyped __cpp__("((wxWindowID)id)") as the second param in your createInstance will probably work.

tienery commented 8 years ago

Well, I tried.

ianharrigan commented 8 years ago

Its not an const int * (IntPtr) - its a cpp::Reference<int>

But apart from that - you are using the right constructor now it seems.

ianharrigan commented 8 years ago

Actually, i take that back - it is a const int *

ianharrigan commented 8 years ago

why dont you try and do away with all params and try:

WxGLCanvas.createInstance(parent == null ? cast 0 : parent._ref, untyped __cpp__("((wxWindowID)id)"))
tienery commented 8 years ago

Hmm... That does work, actually. I'll commit and see if it builds successfully on Travis.

tienery commented 8 years ago

Hmm... Thought so. Just the same error as before. Ambiguity in the constructor overload.

Time to use wxwidgets 3.1 on travis do you think? :)

ianharrigan commented 8 years ago

I dont, no. Esp. when its not needed and 3.0 and 3.1 have viable constructors. So now you have:

WxGLCanvas.createInstance(parent == null ? cast 0 : parent._ref, untyped __cpp__("((wxWindowID)id)"))

and it didnt work, try:

WxGLCanvas.createInstance(parent == null ? cast 0 : parent._ref, untyped __cpp__("((wxWindowID)id)"), Point.defaultPositionRef)
tienery commented 8 years ago

You know what, just forget. I'm just getting the same errors over and over again because of ambiguous constructor calls. I'll go back to C# with my editor, and people can use Wine/Crossover if they need to use it on Linux or Mac.