Add SceneInterface
+ Renames binaries qtk_main->qtk_app and example->example_app
This commit is contained in:
@@ -65,6 +65,6 @@ set(
|
||||
examplewidget.cpp examplewidget.h
|
||||
)
|
||||
|
||||
add_executable(example ${EXAMPLE_SOURCES})
|
||||
target_link_libraries(example PUBLIC Qt6::Widgets Qt6::OpenGLWidgets Qt6::Core)
|
||||
target_link_libraries(example PUBLIC Qtk::qtk_library)
|
||||
add_executable(example_app ${EXAMPLE_SOURCES})
|
||||
target_link_libraries(example_app PUBLIC Qt6::Widgets Qt6::OpenGLWidgets Qt6::Core)
|
||||
target_link_libraries(example_app PUBLIC Qtk::qtk_library)
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
|
||||
This is an example application that is using the Qtk API to create custom Qt
|
||||
OpenGL widgets. This is very similar to `QtkWidget` in the Qtk desktop
|
||||
application, but could be modified for different uses if needed.
|
||||
application source code, but could be modified for different uses if needed.
|
||||
|
||||
There are no camera controls supported in this example. The camera is fixed.
|
||||
If these controls are desired, they can be implemented by the client.
|
||||
|
||||
You can import your own models within `examplescene.cpp`, inside the
|
||||
`ExampleScene::init()` function. Rotations and translations
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
using namespace Qtk;
|
||||
|
||||
ExampleScene::ExampleScene() {
|
||||
ExampleScene::ExampleScene(Qtk::Scene * scene) : Qtk::SceneInterface(scene) {
|
||||
setSceneName("Example Scene");
|
||||
getCamera().getTransform().setTranslation(-8.0f, 0.0f, 10.0f);
|
||||
getCamera().getTransform().setRotation(-5.0f, 0.0f, 1.0f, 0.0f);
|
||||
|
||||
@@ -11,9 +11,9 @@
|
||||
|
||||
#include <qtk/scene.h>
|
||||
|
||||
class ExampleScene : public Qtk::Scene {
|
||||
class ExampleScene : public Qtk::SceneInterface {
|
||||
public:
|
||||
ExampleScene();
|
||||
ExampleScene(Qtk::Scene * scene);
|
||||
|
||||
~ExampleScene();
|
||||
|
||||
|
||||
@@ -11,7 +11,12 @@
|
||||
#include "examplewidget.h"
|
||||
|
||||
ExampleWidget::ExampleWidget(QWidget * parent) :
|
||||
QOpenGLWidget(parent), mScene(new ExampleScene) {
|
||||
QOpenGLWidget(parent), mScene(new ExampleScene(new Qtk::SceneEmpty)) {
|
||||
// NOTE: The decorator pattern is used to save / load scenes in Qtk currently.
|
||||
// The initializer above sets mScene to the concrete decorator ExampleScene.
|
||||
// Qtk::SceneEmpty provides an empty scene as the concrete component.
|
||||
// ExampleScene is defined in client source, deriving Qtk::SceneInterface.
|
||||
|
||||
QSurfaceFormat format;
|
||||
format.setRenderableType(QSurfaceFormat::OpenGL);
|
||||
format.setProfile(QSurfaceFormat::CoreProfile);
|
||||
|
||||
@@ -32,7 +32,7 @@ class ExampleWidget : public QOpenGLWidget, protected QOpenGLFunctions {
|
||||
void update();
|
||||
|
||||
private:
|
||||
ExampleScene * mScene;
|
||||
Qtk::Scene * mScene;
|
||||
};
|
||||
|
||||
#endif // QTKCLIENT_EXAMPLEWIDGET_H
|
||||
|
||||
Reference in New Issue
Block a user