White-Oak / qml-rust

QML (Qt Quick) bindings for Rust language
MIT License
205 stars 18 forks source link

2D game graphics #3

Open kdar opened 8 years ago

kdar commented 8 years ago

I'm currently writing a gameboy emulator and I was debating on using Qt. Just in case you can save me time in my research, is it possible for qml-rust to render 2d graphics maybe using qt3d or opengl? I'm currently using glium and not sure if that can easily be tied into qml-rust. Thank you!

White-Oak commented 8 years ago

@kdar that's a hard question!
As a short answer: no, currently qml-rust does not provide what you are looking for. In the future -- maybe (maybe in a far future).

What you are looking for is essentialy this: https://blog.qt.io/blog/2015/05/11/integrating-custom-opengl-rendering-with-qt-quick-via-qquickframebufferobject/. In short, OpenGL context is binded to a certain area in the window, and everything is drawn there, while you can still use qml for other parts of the UI (second example in the linked article perfectly illustrates your use-case), However, although QQuickFramebufferObject is a part of QtQuick, it is not provided by these bindings. What we'd need is to have bindings/wrappers over QQuickFramebufferObject, QQuickFramebufferObject::Renderer, QOpenGLFramebufferObjectFormat (that's the tricky part, imo) and nearest classes. And I'm not sure if it's feasible to provide them (probably it would require a lot of work).

cc @filcuc , he is the author of C bindings that are base of these and a better expert on Qt.

filcuc commented 8 years ago

@kdar @White-Oak Honestly the hard part to me is wrapping the QQuickItem. I'm not saying that it's not feasable but it would take some time (given that QQuickFramebufferObject inherits QQuickItem). Given that i would fill a new issue for wrapping QQuickItem after that we can talk about other parts.

filcuc commented 8 years ago

i filled this one https://github.com/filcuc/DOtherSide/issues/44

kdar commented 8 years ago

Wondering if I could possibly use a qml Canvas, and use signal/slots to draw to it sending over the pixel data. I think I would need qml-rust to support lists for meta types. Not sure what kind of performance I would get from this.

[edit] Nevermind, I did a test and this is pretty slow.