harfang3d / tutorials-hg1

These tutorials demonstrate the usage of the Harfang API
12 stars 1 forks source link

Qt Integration Tutorial Error - Does not Work #3

Open Pebaz opened 5 years ago

Pebaz commented 5 years ago

The Qt Integration Tutorial: https://www.harfang3d.com/doc/1.2.0/man.TutorialGuiIntegration.html

Throws an error:

AttributeError: module 'harfang' has no attribute 'VideoWindowedQuiet'

Which is indeed the case. My guess is the tutorial is outdated.

However, I am extremely interested in embedding Harfang with PyQt5 and would appreciate if someone could give me an absolutely bare-bones demonstration of how to do so.

The code I have so far:

import harfang as hg
hg.LoadPlugins()
hg.MountFileDriver(hg.StdFileDriver())

renderer = hg.CreateRenderer()
if not renderer.Open(8, 8, 32, hg.VideoWindowedQuiet):
    sys.exit(0)

from PyQt5.QtWidgets import QMainWindow

class WindowPlotter(QMainWindow):
    def __init__(self, renderer, render_system):
        super().__init__()
        self.renderer, self.render_system = renderer, render_system
        self.viewport_widget = QWidget()
        self.view_handle = hg.int_to_voidp(int(self.viewport_widget.winId()))
        self.window = renderer.NewOutputWindow(16, 16, 32, hg.VideoWindowed, self.view_handle)
        self.aspect_ratio = hg.Vector2(1, 1)

I basically copy-and-pasted this code from the referenced tutorial and it appears to be incomplete.

Again, if someone could just post a minimal Harfang-PyQt5 example, that would be amazing. Fixing the tutorial itself would be even better! ;)

astrofra commented 5 years ago

Hi! This tutorial is indeed outdated, as you understood quite easily. One of my colleague did a quick fix a couple of weeks ago, to make it work again, but it is not public yet. Could you please tell us on what platform you'd like to use that HARFANG/Qt bridge ? Windows ? Linux ? Both platforms ?

Pebaz commented 5 years ago

Hello!

I would ideally like to use Harfang + Qt on Windows and Linux but primarily Windows.

If possible, I would like to embed Harfang in a QWidget. This would allow maximum flexibility with regard to layout. However, I would be thrilled to be able to embed Harfang in any capacity.

Thank you for the quick reply!

astrofra commented 5 years ago

Ok, fine. This is the level of integration we have so far Give us a couple of days, I need to check some details with my teammates.

Pebaz commented 5 years ago

That would be great! I look forward to your response 😀

astrofra commented 5 years ago

Can you send me an email to contact@harfang3d.com and I'll take it from there.