Coder Social home page Coder Social logo

fietiger / qt3d-widget Goto Github PK

View Code? Open in Web Editor NEW

This project forked from florianblume/qt3d-widget

0.0 0.0 0.0 6.3 MB

Qt3D Widget. Works by rendering to an offscreen texture in Qt3D and using that texture in a QOpenGLWidget.

License: GNU General Public License v3.0

C++ 95.68% QMake 4.32%

qt3d-widget's Introduction

Qt3D Widget

An attempt at implementing a subclass of QWidget for Qt3D. The only options to embedd Qt3D into an application with widgets is to use QML (which is not always feasible) or to use a Qt3DWindow and embedd it using QWidget::createWindowContainer. This unfortunatley draws the window's content over everything else, even neighboring widgets. This widget is supposed to be a native widget which is embeddable and usable like any other widget.

Requirements

  • Qt >= 5.13
  • OpenGL >= 3.0

Although it doesn't use any Qt3D internals anymore it needs QAbstractTexutre's function handle() to get a handle to the OpenGL texture. This function is only available from Qt >= 5.13. Any suggestions how to avoid this dependency are welcome.

Usage

IMPORTANT: You need to add

QSurfaceFormat format = QSurfaceFormat::defaultFormat();
format.setSamples(4);
format.setVersion(3, 0);
QSurfaceFormat::setDefaultFormat(format);
QApplication::setAttribute(Qt::AA_ShareOpenGLContexts);

to the main of your project BEFORE calling QApplication(x, y) or in whatever way you construct your application. This enables context sharing (we need this because Qt3D shares its context wit the native QOpenGLWidget). I left setting the appropriate format to the user so that they can define the desired number of samples (1 for no multisampling, up to whatever floats your boat, Qt3DWidget will use as many samples as you supply) and set your preferred version (at least 3.0!).

You can either use the static library (libqt3d-widget.a) in your project, which will be compiled into the executable. Or you use the dynamic linked library (libqt3d-widget.so).

Note:

If you want to use the dynamic linked library specify

LIBS += -L../path/to/your/libs/folder/ -lqt3d-widget

If you want to use the static library but keep the dynamic library in the same folder you must specify the full file name like so:

LIBS += ../path/to/your/libs/folder/libqt3d-widget.a

Implementation

Update: The implementation is now not using Qt3D internals anymore but renders to a texture which is then used by OpenGL. Should be compatible with many Qt3D versions.

  • If you want to disable the fps output simply build the library for release
  • If you build the library yourself and alter qt3dwidget.h don't forget to copy it to the include folder, this doesn't happen automatically

Screenshot

With QPushButton inside to show that it's now possible to add widgets inside Qt3D.

Imgur

qt3d-widget's People

Contributors

florianblume avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.