├── LICENSE
├── README.md
├── SceneEditor
├── SceneEditor.pro
├── aboutwidget.cpp
├── aboutwidget.h
├── aboutwidget.ui
├── bottomwidget.cpp
├── bottomwidget.h
├── bottomwidget.ui
├── core.cpp
├── core.h
├── editorwidget.cpp
├── editorwidget.h
├── editorwidget.ui
├── fast2dquad.cpp
├── fast2dquad.h
├── fbo.cpp
├── fbo.h
├── highlighter.cpp
├── highlighter.h
├── main.cpp
├── mainwindow.cpp
├── mainwindow.h
├── mainwindow.ui
├── newshader.cpp
├── newshader.h
├── newshader.ui
├── newwidget.cpp
├── newwidget.h
├── newwidget.ui
├── openwidget.cpp
├── openwidget.h
├── openwidget.ui
├── paramwidget.cpp
├── paramwidget.h
├── paramwidget.ui
├── qdarkstyle
│ ├── rc
│ │ ├── Hmovetoolbar.png
│ │ ├── Hsepartoolbar.png
│ │ ├── Vmovetoolbar.png
│ │ ├── Vsepartoolbar.png
│ │ ├── branch_closed-on.png
│ │ ├── branch_closed.png
│ │ ├── branch_open-on.png
│ │ ├── branch_open.png
│ │ ├── checkbox.png
│ │ ├── close.png
│ │ ├── down_arrow.png
│ │ ├── down_arrow_disabled.png
│ │ ├── left_arrow.png
│ │ ├── left_arrow_disabled.png
│ │ ├── right_arrow.png
│ │ ├── right_arrow_disabled.png
│ │ ├── sizegrip.png
│ │ ├── stylesheet-branch-end.png
│ │ ├── stylesheet-branch-more.png
│ │ ├── stylesheet-vline.png
│ │ ├── transparent.png
│ │ ├── undock.png
│ │ ├── up_arrow.png
│ │ └── up_arrow_disabled.png
│ ├── style.qrc
│ └── style.qss
├── renderwidget.cpp
├── renderwidget.h
├── res.qrc
├── res
│ ├── framework
│ │ ├── DF
│ │ │ ├── Scene.glsl
│ │ │ └── config.xml
│ │ ├── Empty
│ │ │ ├── Scene.glsl
│ │ │ └── config.xml
│ │ ├── Layer
│ │ │ └── layer.glsl
│ │ └── Raytracing
│ │ │ ├── Scene.glsl
│ │ │ └── config.xml
│ ├── img
│ │ ├── camera.png
│ │ ├── filenew.png
│ │ ├── fileopen.png
│ │ ├── filesave.png
│ │ ├── micro.png
│ │ ├── music.png
│ │ ├── new shader.png
│ │ ├── new.png
│ │ ├── open.png
│ │ ├── projector.png
│ │ ├── save.png
│ │ ├── screenshot.png
│ │ ├── setting.png
│ │ ├── setting2.png
│ │ ├── setting_visual.png
│ │ └── vls.png
│ └── logo.ico
├── ressource.rc
├── scene.cpp
├── scene.h
├── shader.cpp
├── shader.h
├── texteditor.cpp
├── texteditor.h
├── texture.cpp
└── texture.h
├── VisualLiveSystem
├── FFTAnalyzer.cpp
├── FFTAnalyzer.h
├── VisualLiveSystem.pro
├── audiovisualizer.cpp
├── audiovisualizer.h
├── channelwidget.cpp
├── channelwidget.h
├── channelwidget.ui
├── core.cpp
├── core.h
├── fast2dquad.cpp
├── fast2dquad.h
├── fbo.cpp
├── fbo.h
├── glscene.cpp
├── glscene.h
├── loadingwidget.cpp
├── loadingwidget.h
├── loadingwidget.ui
├── main.cpp
├── mainwindow.cpp
├── mainwindow.h
├── mainwindow.ui
├── masterwidget.cpp
├── masterwidget.h
├── masterwidget.ui
├── midiwindow.cpp
├── midiwindow.h
├── midiwindow.ui
├── projectorwidget.cpp
├── projectorwidget.h
├── qdarkstyle
│ ├── rc
│ │ ├── Hmovetoolbar.png
│ │ ├── Hsepartoolbar.png
│ │ ├── Vmovetoolbar.png
│ │ ├── Vsepartoolbar.png
│ │ ├── branch_closed-on.png
│ │ ├── branch_closed.png
│ │ ├── branch_open-on.png
│ │ ├── branch_open.png
│ │ ├── checkbox.png
│ │ ├── close.png
│ │ ├── down_arrow.png
│ │ ├── down_arrow_disabled.png
│ │ ├── left_arrow.png
│ │ ├── left_arrow_disabled.png
│ │ ├── right_arrow.png
│ │ ├── right_arrow_disabled.png
│ │ ├── sizegrip.png
│ │ ├── stylesheet-branch-end.png
│ │ ├── stylesheet-branch-more.png
│ │ ├── stylesheet-vline.png
│ │ ├── transparent.png
│ │ ├── undock.png
│ │ ├── up_arrow.png
│ │ └── up_arrow_disabled.png
│ ├── style.qrc
│ └── style.qss
├── qmidisequencer.cpp
├── qmidisequencer.h
├── renderwidget.cpp
├── renderwidget.h
├── res.qrc
├── res
│ ├── img
│ │ ├── micro.png
│ │ ├── music.png
│ │ ├── new.png
│ │ ├── open.png
│ │ ├── projector.png
│ │ ├── save.png
│ │ ├── setting.png
│ │ ├── setting2.png
│ │ ├── setting_visual.png
│ │ └── vls.png
│ ├── logo.ico
│ └── shaders
│ │ ├── audiovisualizer.glsl
│ │ ├── open.glsl
│ │ └── postprocess.glsl
├── ressource.rc
├── scene.cpp
├── scene.h
├── shader.cpp
├── shader.h
├── signal
│ ├── audiopipe.cpp
│ ├── audiopipe.hpp
│ ├── bass.h
│ ├── basserrorhandler.cpp
│ ├── basserrorhandler.hpp
│ ├── bassflac.h
│ ├── decoder.cpp
│ ├── decoder.hpp
│ ├── fft.cpp
│ ├── fft.hpp
│ ├── signal.cpp
│ └── signal.hpp
├── soundmanager.cpp
├── soundmanager.h
├── soundmanager.ui
├── texture.cpp
├── texture.h
├── transition.cpp
├── transition.h
├── visualmanager.cpp
├── visualmanager.h
└── visualmanager.ui
└── release
├── data
├── config
│ └── midi
│ │ ├── Akai LPD8.conf
│ │ └── Akai MPK Mini.conf
├── postFX
│ ├── Invert.glsl
│ ├── Vignetting.glsl
│ ├── green-pink blur.glsl
│ ├── red-blue blur.glsl
│ └── vertical_minibar.glsl
├── scenes
│ └── Open
│ │ ├── config.xml
│ │ └── open.glsl
├── textures
│ ├── noise.png
│ ├── noise16.png
│ ├── noise256.png
│ ├── sky.tga.png
│ ├── sprite.png
│ ├── sprite2.png
│ └── water.png
└── transitions
│ ├── Black fade
│ ├── config.xml
│ └── transition.glsl
│ ├── Black flash
│ ├── config.xml
│ └── transition.glsl
│ ├── Fade
│ ├── config.xml
│ └── transition.glsl
│ ├── None
│ ├── config.xml
│ └── transition.glsl
│ ├── Pyramid
│ ├── config.xml
│ └── transition.glsl
│ ├── White fade
│ ├── config.xml
│ └── transition.glsl
│ └── White flash
│ ├── config.xml
│ └── transition.glsl
└── settings.ini
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 XT95
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # VisualLiveSystem
2 | Visual Live System is a new visual jockey software for professional live performance.
3 | Compatible with Mac and PC, he is able to render complex real time 3D scene fully based on the sound.
4 | He have an intuitive interface thinked like a DJ solution, 2 channels of real time effects and a master pannel for mixing theses.
5 | Midi controllers is supported.
6 |
7 |
8 |
9 |
10 | More details soon.
11 |
12 | ## Setup:
13 |
14 | Dependencies:
15 | * [qt 4.8](http://download.qt.io/archive/qt/4.8/4.8.4/)
16 | * [bass](http://www.un4seen.com/)
17 | * [bassflac](http://www.un4seen.com/)
18 | * [rtaudio](https://www.music.mcgill.ca/~gary/rtaudio/)
19 | * [portmidi](http://portmedia.sourceforge.net/portmidi/)
20 | * [glew](http://glew.sourceforge.net/)
21 |
22 |
23 | Compile:
24 | * Open /VisualLiveSystem/VisualLiveSystem.pro with Qt Creator, setup the binary output to /release and compil it.
25 | * You can do the same thing with /SceneEditor.
26 |
27 |
28 | ## Usage:
29 |
30 | Visual Live System
31 | * If you have a midi controller just go to the midi controller view, make a new profil and assign yours faders like of you want.
32 | * After that, open the visual manager select some few scenes and drag'n'drop of the channels A and B. Apply.
33 | * Go to the post processing tabulation, and add some post fx (the order change the result). Apply.
34 | * Get the output audio of your DJ on input of your computer (if you just want to make a test, the microphone should be correct).
35 | * Now, open the projector's window, move them to the projector screen and double clik for the fullscreen mode.
36 | * Enjoy by making beautiful transition between the channels when you have a drop :) !
37 |
--------------------------------------------------------------------------------
/SceneEditor/SceneEditor.pro:
--------------------------------------------------------------------------------
1 | #-------------------------------------------------
2 | #
3 | # Project created by QtCreator 2014-10-28T22:34:42
4 | #
5 | #-------------------------------------------------
6 |
7 | QT += core gui opengl xml
8 |
9 | TARGET = SceneEditor
10 | TEMPLATE = app
11 |
12 | RC_FILE = ressource.rc
13 |
14 | INCLUDEPATH += C:/Coding/Librarys/include
15 | LIBS += -LC:/Coding/Librarys/lib/32
16 |
17 |
18 | LIBS += -lwinmm -lole32 -lGLEW32 -ldsound
19 |
20 |
21 | SOURCES += main.cpp\
22 | mainwindow.cpp \
23 | texture.cpp \
24 | shader.cpp \
25 | scene.cpp \
26 | fbo.cpp \
27 | fast2dquad.cpp \
28 | core.cpp \
29 | renderwidget.cpp \
30 | texteditor.cpp \
31 | bottomwidget.cpp \
32 | paramwidget.cpp \
33 | editorwidget.cpp \
34 | highlighter.cpp \
35 | newwidget.cpp \
36 | openwidget.cpp \
37 | newshader.cpp \
38 | aboutwidget.cpp
39 |
40 | HEADERS += mainwindow.h \
41 | texture.h \
42 | shader.h \
43 | scene.h \
44 | fbo.h \
45 | fast2dquad.h \
46 | core.h \
47 | renderwidget.h \
48 | texteditor.h \
49 | bottomwidget.h \
50 | paramwidget.h \
51 | editorwidget.h \
52 | highlighter.h \
53 | newwidget.h \
54 | openwidget.h \
55 | newshader.h \
56 | aboutwidget.h
57 |
58 | FORMS += mainwindow.ui \
59 | bottomwidget.ui \
60 | paramwidget.ui \
61 | editorwidget.ui \
62 | newwidget.ui \
63 | openwidget.ui \
64 | newshader.ui \
65 | aboutwidget.ui
66 |
67 | RESOURCES += \
68 | res.qrc \
69 | qdarkstyle/style.qrc
70 |
--------------------------------------------------------------------------------
/SceneEditor/aboutwidget.cpp:
--------------------------------------------------------------------------------
1 | #include "aboutwidget.h"
2 | #include "ui_aboutwidget.h"
3 |
4 | AboutWidget::AboutWidget(QWidget *parent) :
5 | QDialog(parent),
6 | ui(new Ui::AboutWidget)
7 | {
8 | ui->setupUi(this);
9 | }
10 |
11 | AboutWidget::~AboutWidget()
12 | {
13 | delete ui;
14 | }
15 |
--------------------------------------------------------------------------------
/SceneEditor/aboutwidget.h:
--------------------------------------------------------------------------------
1 | #ifndef ABOUTWIDGET_H
2 | #define ABOUTWIDGET_H
3 |
4 | #include
5 |
6 | namespace Ui {
7 | class AboutWidget;
8 | }
9 |
10 | class AboutWidget : public QDialog
11 | {
12 | Q_OBJECT
13 |
14 | public:
15 | explicit AboutWidget(QWidget *parent = 0);
16 | ~AboutWidget();
17 |
18 | private:
19 | Ui::AboutWidget *ui;
20 | };
21 |
22 | #endif // ABOUTWIDGET_H
23 |
--------------------------------------------------------------------------------
/SceneEditor/aboutwidget.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | AboutWidget
4 |
5 |
6 |
7 | 0
8 | 0
9 | 630
10 | 406
11 |
12 |
13 |
14 | Dialog
15 |
16 |
17 | -
18 |
19 |
20 | www.aduprat.com
21 |
22 |
23 | Qt::AlignJustify|Qt::AlignVCenter
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/SceneEditor/bottomwidget.cpp:
--------------------------------------------------------------------------------
1 | #include "bottomwidget.h"
2 | #include "ui_bottomwidget.h"
3 |
4 | BottomWidget::BottomWidget(QWidget *parent) :
5 | QDockWidget(parent),
6 | ui(new Ui::BottomWidget)
7 | {
8 | ui->setupUi(this);
9 | connect(ui->logWidget, SIGNAL(textChanged()), this, SLOT(logChanged()));
10 | }
11 |
12 | BottomWidget::~BottomWidget()
13 | {
14 | delete ui;
15 | }
16 |
17 | QTextEdit* BottomWidget::getLogWidget()
18 | { return ui->logWidget; }
19 |
20 | void BottomWidget::logChanged()
21 | {
22 | ui->logWidget->ensureCursorVisible();
23 | }
24 |
--------------------------------------------------------------------------------
/SceneEditor/bottomwidget.h:
--------------------------------------------------------------------------------
1 | #ifndef BOTTOMWIDGET_H
2 | #define BOTTOMWIDGET_H
3 |
4 | #include
5 | #include
6 |
7 | namespace Ui {
8 | class BottomWidget;
9 | }
10 |
11 | class BottomWidget : public QDockWidget
12 | {
13 | Q_OBJECT
14 |
15 | public:
16 | explicit BottomWidget(QWidget *parent = 0);
17 | ~BottomWidget();
18 |
19 | QTextEdit* getLogWidget();
20 |
21 | private slots:
22 | void logChanged();
23 | private:
24 | Ui::BottomWidget *ui;
25 | };
26 |
27 | #endif // BOTTOMWIDGET_H
28 |
--------------------------------------------------------------------------------
/SceneEditor/bottomwidget.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | BottomWidget
4 |
5 |
6 |
7 | 0
8 | 0
9 | 889
10 | 278
11 |
12 |
13 |
14 |
15 | 0
16 | 0
17 |
18 |
19 |
20 | Logs
21 |
22 |
23 |
24 | -
25 |
26 |
27 |
28 | 0
29 | 0
30 |
31 |
32 |
33 | Qt::ScrollBarAlwaysOn
34 |
35 |
36 | false
37 |
38 |
39 | true
40 |
41 |
42 | Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/SceneEditor/core.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include "core.h"
4 | #include "scene.h"
5 |
6 | Core* Core::m_instance = NULL;
7 | Core* Core::instance()
8 | {
9 | if(m_instance == NULL)
10 | {
11 | m_instance = new Core();
12 | }
13 | return m_instance;
14 | }
15 |
16 | Core::Core()
17 | {
18 | m_resX = 640;
19 | m_resY = 360;
20 |
21 | m_scene = NULL;
22 | }
23 |
24 | static unsigned int mirand = 1;
25 | float sfrand(void)
26 | {
27 | float res;
28 | mirand *= 16807;
29 | *((unsigned int *) &res) = (mirand & 0x007fffff) | 0x40000000;
30 | return( res-3.0f );
31 | }
32 |
33 | void Core::initGL()
34 | {
35 | glMatrixMode(GL_MODELVIEW);
36 | glEnable(GL_TEXTURE_2D);
37 |
38 |
39 | glEnable(GL_TEXTURE_3D);
40 | glGenTextures(1, &m_noise3D);
41 | glBindTexture(GL_TEXTURE_3D, m_noise3D);
42 | glTexParameteri(GL_TEXTURE_3D, GL_GENERATE_MIPMAP_SGIS, GL_TRUE);
43 | glTexParameteri(GL_TEXTURE_3D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR);
44 | glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
45 | glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_REPEAT);
46 | glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_REPEAT);
47 |
48 | const int noiseSize=64;
49 | unsigned char *data = new unsigned char[noiseSize*noiseSize*noiseSize*4];
50 | for(int i=0;isetTextColor( QColor(0,150,0) );
136 | if(time)
137 | txt = getDate() + txt;
138 |
139 | m_log->textCursor().movePosition(QTextCursor::End);
140 | m_log->insertPlainText(txt);
141 | }
142 | void Core::writeWarning( QString txt, bool time)
143 | {
144 | // m_log->clear();
145 | m_log->setTextColor( QColor(255,255,100) );
146 | if(time)
147 | txt = getDate() + txt;
148 |
149 | m_log->textCursor().movePosition(QTextCursor::End);
150 | m_log->insertPlainText(txt);
151 | }
152 | void Core::writeError( QString txt, bool time)
153 | {
154 | // m_log->clear();
155 | m_log->setTextColor( QColor(255,0,0) );
156 | if(time)
157 | txt = getDate() + txt;
158 |
159 | m_log->textCursor().movePosition(QTextCursor::End);
160 | m_log->insertPlainText(txt);
161 | }
162 |
--------------------------------------------------------------------------------
/SceneEditor/core.h:
--------------------------------------------------------------------------------
1 | #ifndef DATA_H
2 | #define DATA_H
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 |
9 | class Scene;
10 | class FBO;
11 |
12 |
13 |
14 | #define BUFFER_OFFSET(a) ((char*)NULL + (a))
15 | struct vec2
16 | {
17 | float x,y;
18 | };
19 |
20 |
21 | class Core : public QObject
22 | {
23 | Q_OBJECT
24 | public:
25 | //Singleton !
26 | static Core* instance();
27 | void initGL();
28 |
29 | //Show !
30 | void setCC(int id, float v);
31 | float getCC(int id);
32 |
33 | //Log
34 | void setLogWidget( QTextEdit *w ) { m_log = w; }
35 | void writeInfo( QString txt, bool time=true);
36 | void writeWarning( QString txt, bool time=true );
37 | void writeError( QString txt, bool time=true );
38 |
39 | //Rendering
40 | Scene* getScene() { return m_scene; }
41 | void setScene( Scene *sc ) { m_scene = sc; }
42 | void setResolution(int x,int y);
43 | int getResX();
44 | int getResY();
45 | int getNoise3D();
46 |
47 |
48 | //Utils
49 | Scene* getDefaultScene();
50 | const char* getVertexShader();
51 | const char* getVertexShaderParticle();
52 | void setEffectName( QString name ) { m_effectName = name; }
53 | QString getEffectName() { return m_effectName; }
54 | QString getDate();
55 |
56 | signals:
57 | void resolutionChanged(int,int);
58 |
59 |
60 | private:
61 | Core();
62 | Scene *m_scene;
63 | static Core *m_instance;
64 | int m_resX,m_resY;
65 | GLuint m_noise3D;
66 | float m_cc[4];
67 | QTextEdit *m_log;
68 | QString m_effectName;
69 |
70 | };
71 |
72 | #endif // DATA_H
73 |
--------------------------------------------------------------------------------
/SceneEditor/editorwidget.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XT95/VisualLiveSystem/e8b5b97718f294cf4d6fa001ff98e0e6d7cbcf74/SceneEditor/editorwidget.cpp
--------------------------------------------------------------------------------
/SceneEditor/editorwidget.h:
--------------------------------------------------------------------------------
1 | #ifndef EDITORWIDGET_H
2 | #define EDITORWIDGET_H
3 |
4 | #include
5 |
6 | namespace Ui {
7 | class EditorWidget;
8 | }
9 |
10 | class EditorWidget : public QDockWidget
11 | {
12 | Q_OBJECT
13 |
14 | public:
15 | explicit EditorWidget(QWidget *parent = 0);
16 | ~EditorWidget();
17 |
18 | void save();
19 | public slots:
20 | void loadScene( QString filename );
21 |
22 | signals:
23 | void recompil(QString,int);
24 | void nameCCChanged(int,QString);
25 | private slots:
26 | void shaderUpdate(QString, int);
27 | private:
28 | Ui::EditorWidget *ui;
29 | };
30 |
31 | #endif // EDITORWIDGET_H
32 |
--------------------------------------------------------------------------------
/SceneEditor/editorwidget.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | EditorWidget
4 |
5 |
6 |
7 | 0
8 | 0
9 | 640
10 | 378
11 |
12 |
13 |
14 |
15 | 0
16 | 0
17 |
18 |
19 |
20 |
21 | 640
22 | 88
23 |
24 |
25 |
26 | Editor
27 |
28 |
29 |
30 | -
31 |
32 |
33 |
34 | 10
35 |
36 |
37 |
38 | -1
39 |
40 |
41 | true
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/SceneEditor/fast2dquad.cpp:
--------------------------------------------------------------------------------
1 |
2 | #include
3 |
4 |
5 |
6 | #define BUFFER_OFFSET(a) ((char*)NULL + (a))
7 | struct vec2
8 | {
9 | float x,y;
10 | };
11 |
12 | static GLuint vbo;
13 |
14 | void Fast2DQuadInit(void)
15 | {
16 | vec2 point[4];
17 | point[0].x =-1.0f; point[1].x = 1.0f; point[2].x =-1.0f; point[3].x = 1.0f;
18 | point[0].y =-1.0f; point[1].y =-1.0f; point[2].y = 1.0f; point[3].y = 1.0f;
19 | vec2 uv[4];
20 | uv[0].x = 0.0f; uv[1].x = 1.0f; uv[2].x = 0.0f; uv[3].x = 1.0f;
21 | uv[0].y = 0.0f; uv[1].y = 0.0f; uv[2].y = 1.0f; uv[3].y = 1.0f;
22 |
23 |
24 | //make the vertex buffer object
25 | glGenBuffers(1, &vbo);
26 | glBindBuffer(GL_ARRAY_BUFFER, vbo);
27 | glBufferData(GL_ARRAY_BUFFER, 4*2*sizeof(float)*2, NULL, GL_STATIC_DRAW);
28 | glBufferSubData(GL_ARRAY_BUFFER, 0, 4*2*sizeof(float), point);
29 | glBufferSubData(GL_ARRAY_BUFFER, 4*2*sizeof(float), 4*2*sizeof(float), uv);
30 | glBindBuffer(GL_ARRAY_BUFFER, 0);
31 |
32 | }
33 |
34 |
35 | void Fast2DQuadDraw(void)
36 | {
37 | glBindBuffer(GL_ARRAY_BUFFER, vbo);
38 | glVertexPointer(2, GL_FLOAT, 0, BUFFER_OFFSET(0));
39 | glTexCoordPointer(2, GL_FLOAT, 0, BUFFER_OFFSET(4*2*sizeof(float)));
40 | glEnableClientState(GL_VERTEX_ARRAY);
41 | glEnableClientState(GL_TEXTURE_COORD_ARRAY);
42 | glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
43 | glDisableClientState(GL_TEXTURE_COORD_ARRAY);
44 | glDisableClientState(GL_VERTEX_ARRAY);
45 | glBindBuffer(GL_ARRAY_BUFFER, 0);
46 | }
47 |
48 |
49 | void Fast2DQuadFree(void)
50 | {
51 | glDeleteBuffers(1,&vbo);
52 | }
53 |
--------------------------------------------------------------------------------
/SceneEditor/fast2dquad.h:
--------------------------------------------------------------------------------
1 | #ifndef DEF_FAST2DQUAD
2 | #define DEF_FAST2DQUAD
3 |
4 |
5 |
6 | void Fast2DQuadInit(void);
7 | void Fast2DQuadDraw(void);
8 | void Fast2DQuadFree(void);
9 |
10 |
11 |
12 | #endif
13 |
--------------------------------------------------------------------------------
/SceneEditor/fbo.cpp:
--------------------------------------------------------------------------------
1 | #include "fbo.h"
2 |
3 | #include
4 |
5 |
6 | //-----------------------------------------------------------------------------
7 | // Constructor
8 | //-----------------------------------------------------------------------------
9 | FBO::FBO()
10 | {
11 | m_FrameBuffer=0;
12 | m_ColorTextureID=0;
13 | m_width = 1280;
14 | m_height = 720;
15 | m_format = GL_RGBA;
16 |
17 | //Create texture.
18 | glGenTextures(1, &m_ColorTextureID);
19 | glBindTexture(GL_TEXTURE_2D, m_ColorTextureID);
20 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
21 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
22 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
23 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
24 |
25 | glTexImage2D(GL_TEXTURE_2D, 0, m_format, m_width, m_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
26 |
27 |
28 | glGenTextures(1, &m_DepthTextureID);
29 | glBindTexture(GL_TEXTURE_2D, m_DepthTextureID);
30 | glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32, m_width, m_height, 0, GL_DEPTH_COMPONENT, GL_FLOAT, NULL);
31 | glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE, GL_LUMINANCE);
32 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
33 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
34 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
35 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
36 | glBindTexture(GL_TEXTURE_2D, 0);
37 |
38 | glTexImage2D(GL_TEXTURE_2D, 0, m_format, m_width, m_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
39 | glBindTexture(GL_TEXTURE_2D, 0);
40 |
41 |
42 | //Make buffer
43 | glGenFramebuffers(1, &m_FrameBuffer);
44 | glBindFramebuffer(GL_FRAMEBUFFER_EXT, m_FrameBuffer);
45 |
46 |
47 |
48 | glGenRenderbuffers(1, &m_DepthRenderBuffer);
49 | glBindRenderbuffer(GL_RENDERBUFFER_EXT, m_DepthRenderBuffer);
50 | glRenderbufferStorage(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, m_width, m_height);
51 | glBindRenderbuffer(GL_RENDERBUFFER_EXT, 0);
52 |
53 | glFramebufferTexture2D(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, m_ColorTextureID, 0);
54 | glFramebufferRenderbuffer(GL_FRAMEBUFFER_EXT,GL_DEPTH_ATTACHMENT_EXT,GL_RENDERBUFFER_EXT, m_DepthRenderBuffer);
55 |
56 |
57 | glBindFramebuffer(GL_FRAMEBUFFER_EXT, 0);
58 |
59 | }
60 |
61 |
62 | //-----------------------------------------------------------------------------
63 | // Destructor
64 | //-----------------------------------------------------------------------------
65 | FBO::~FBO()
66 | {
67 | glDeleteTextures(1, &m_ColorTextureID);
68 | glDeleteTextures(1, &m_DepthTextureID);
69 | glDeleteFramebuffers(1, &m_FrameBuffer);
70 | glDeleteRenderbuffers(1, &m_DepthRenderBuffer);
71 | }
72 |
73 |
74 | //-----------------------------------------------------------------------------
75 | // Enable
76 | //-----------------------------------------------------------------------------
77 | void FBO::enable(void)
78 | {
79 | glPushAttrib(GL_VIEWPORT_BIT);
80 | glViewport(0,0,m_width,m_height);
81 |
82 | glBindFramebuffer(GL_FRAMEBUFFER_EXT, m_FrameBuffer);
83 | glPushMatrix();
84 | }
85 |
86 | //-----------------------------------------------------------------------------
87 | // Disable
88 | //-----------------------------------------------------------------------------
89 | void FBO::disable(void)
90 | {
91 | glPopMatrix();
92 | glBindFramebuffer(GL_FRAMEBUFFER_EXT, 0);
93 | glPopAttrib();
94 | }
95 |
96 |
97 |
98 | //-----------------------------------------------------------------------------
99 | // Set
100 | //-----------------------------------------------------------------------------
101 | void FBO::setSize( int width, int height )
102 | {
103 | m_width = width;
104 | m_height = height;
105 |
106 |
107 | updateTexture();
108 | }
109 | void FBO::setFormat(GLint format)
110 | {
111 | m_format = format;
112 | updateTexture();
113 | }
114 |
115 |
116 | //-----------------------------------------------------------------------------
117 | // Get
118 | //-----------------------------------------------------------------------------
119 | GLuint FBO::getColor(void)
120 | {
121 | return m_ColorTextureID;
122 | }
123 |
124 | //-----------------------------------------------------------------------------
125 | // updateTexture
126 | //-----------------------------------------------------------------------------
127 | void FBO::updateTexture()
128 | {
129 | glBindTexture(GL_TEXTURE_2D, m_ColorTextureID);
130 | glTexImage2D(GL_TEXTURE_2D, 0, m_format, m_width, m_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
131 | glBindTexture(GL_TEXTURE_2D, m_DepthTextureID);
132 | glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32, m_width, m_height, 0, GL_DEPTH_COMPONENT, GL_FLOAT, NULL);
133 |
134 | glBindTexture(GL_TEXTURE_2D, 0);
135 |
136 | }
137 |
138 | //-----------------------------------------------------------------------------
139 | // bind
140 | //-----------------------------------------------------------------------------
141 | void FBO::bind()
142 | {
143 | glBindTexture(GL_TEXTURE_2D, m_ColorTextureID);
144 | }
145 |
--------------------------------------------------------------------------------
/SceneEditor/fbo.h:
--------------------------------------------------------------------------------
1 | #ifndef DEF_CORE_FBO_H
2 | #define DEF_CORE_FBO_H
3 |
4 | #include
5 |
6 | #include "texture.h"
7 |
8 | //-----------------------------------------------------------------------------
9 | // Class Frame Buffer Object
10 | //-----------------------------------------------------------------------------
11 | class FBO : public Texture
12 | {
13 | public:
14 | FBO();
15 | ~FBO();
16 |
17 | void enable(void);
18 | void disable(void);
19 |
20 |
21 | void setSize( int width, int height );
22 | void setFormat(GLint format);
23 |
24 | int getSizeX(){return m_width;}
25 | int getSizeY(){return m_height;}
26 | GLuint getColor(void);
27 | GLenum getFormat(){return m_format;}
28 |
29 | void bind();
30 | private:
31 | void updateTexture();
32 |
33 | GLuint m_FrameBuffer;
34 | GLuint m_DepthRenderBuffer;
35 | GLuint m_ColorTextureID;
36 | GLuint m_DepthTextureID;
37 | int m_width,m_height;
38 | GLint m_format;
39 | };
40 |
41 |
42 | #endif
43 |
--------------------------------------------------------------------------------
/SceneEditor/highlighter.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef HIGHLIGHTER_H
3 | #define HIGHLIGHTER_H
4 |
5 | #include
6 |
7 | #include
8 | #include
9 |
10 | class QTextDocument;
11 |
12 | class Highlighter : public QSyntaxHighlighter
13 | {
14 | Q_OBJECT
15 |
16 | public:
17 | Highlighter(QTextDocument *parent = 0);
18 |
19 | void defineXMLRule();
20 | protected:
21 | void highlightBlock(const QString &text);
22 |
23 | private:
24 | struct HighlightingRule
25 | {
26 | QRegExp pattern;
27 | QTextCharFormat format;
28 | };
29 | QVector highlightingRules;
30 |
31 | QRegExp commentStartExpression;
32 | QRegExp commentEndExpression;
33 |
34 | QTextCharFormat typeFormat;
35 | QTextCharFormat keywordFormat;
36 | QTextCharFormat singleLineCommentFormat;
37 | QTextCharFormat multiLineCommentFormat;
38 | QTextCharFormat quotationFormat;
39 | QTextCharFormat functionFormat;
40 | QTextCharFormat numberFormat;
41 | QTextCharFormat XMLNameFormat;
42 | QTextCharFormat XMLAttributeFormat;
43 | QTextCharFormat XMLParamFormat;
44 | };
45 |
46 | #endif
47 |
--------------------------------------------------------------------------------
/SceneEditor/main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include "mainwindow.h"
5 | #include
6 | #include
7 | #include
8 | #include
9 |
10 | #include "core.h"
11 | int main(int argc, char *argv[])
12 | {
13 | QApplication a(argc, argv);
14 | QFile f(":qdarkstyle/style.qss");
15 | f.open(QFile::ReadOnly | QFile::Text);
16 | QTextStream ts(&f);
17 | a.setStyleSheet(ts.readAll());
18 |
19 | MainWindow w;
20 | w.showMaximized();
21 | return a.exec();
22 | }
23 |
--------------------------------------------------------------------------------
/SceneEditor/mainwindow.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | #include "core.h"
6 | #include "mainwindow.h"
7 | #include "ui_mainwindow.h"
8 | #include "bottomwidget.h"
9 | #include "paramwidget.h"
10 | #include "editorwidget.h"
11 | #include "newwidget.h"
12 | #include "openwidget.h"
13 | #include "newshader.h"
14 |
15 | MainWindow::MainWindow(QWidget *parent) :
16 | QMainWindow(parent),
17 | ui(new Ui::MainWindow)
18 | {
19 | ui->setupUi(this);
20 |
21 | m_info = new BottomWidget(this);
22 | m_param = new ParamWidget(this);
23 | m_editor = new EditorWidget(this);
24 |
25 | m_newShader = new NewShader();
26 | m_newShader->hide();
27 |
28 | m_open = new OpenWidget();
29 | m_open->hide();
30 |
31 | Core::instance()->setLogWidget( m_info->getLogWidget() );
32 | ui->toolBar->addAction(ui->actionNew);
33 | ui->toolBar->addAction(ui->actionOpen);
34 | ui->toolBar->addAction(ui->actionSave);
35 | ui->toolBar->addSeparator();
36 | ui->toolBar->addAction(ui->actionReset_camera);
37 | ui->toolBar->addAction(ui->actionTake_screenshot);
38 | ui->toolBar->addAction(ui->actionProjector_output);
39 | ui->toolBar->addSeparator();
40 | ui->toolBar->addAction(ui->actionAdd_shader);
41 | ui->toolBar->addSeparator();
42 | ui->toolBar->addAction(ui->actionReload);
43 |
44 | addDockWidget(Qt::BottomDockWidgetArea, m_info);
45 | addDockWidget(Qt::LeftDockWidgetArea, m_editor);
46 | addDockWidget(Qt::BottomDockWidgetArea, m_param);
47 |
48 | connect(ui->actionNew,SIGNAL(triggered()), this, SLOT(newScene()));
49 | connect(ui->actionOpen,SIGNAL(triggered()), m_open, SLOT(show()));
50 | connect(ui->actionSave, SIGNAL(triggered()), this, SLOT(save()));
51 | connect(ui->actionQuit, SIGNAL(triggered()), this, SLOT(close()));
52 | connect(ui->actionAdd_shader, SIGNAL(triggered()), m_newShader, SLOT(show()));
53 | connect(ui->actionReset_camera, SIGNAL(triggered()), ui->widget, SLOT(resetCamera()));
54 | connect(ui->actionTake_screenshot, SIGNAL(triggered()), ui->widget, SLOT(takeScreenshot()));
55 | connect(m_editor, SIGNAL(recompil(QString,int)), ui->widget, SLOT(recompilShader( QString, int)));
56 | connect(m_editor, SIGNAL(nameCCChanged(int,QString)), m_param, SLOT(nameCCChanged(int,QString)));
57 | connect(m_open, SIGNAL(open(QString)), this, SLOT(open(QString)));
58 |
59 | connect(m_newShader, SIGNAL(reload()), this, SLOT(reloadEffect()));
60 |
61 | connect(ui->actionReload, SIGNAL(triggered()), this, SLOT(reloadEffect()));
62 | }
63 |
64 | MainWindow::~MainWindow()
65 | {
66 | delete m_info;
67 | delete ui;
68 | }
69 |
70 |
71 |
72 |
73 | void MainWindow::open(QString filename)
74 | {
75 | Core::instance()->setEffectName( filename );
76 | m_param->clearName();
77 | ui->widget->loadScene(filename);
78 | m_editor->loadScene(filename);
79 | }
80 |
81 | void MainWindow::reloadEffect()
82 | {
83 | m_param->clearName();
84 | ui->widget->loadScene( Core::instance()->getEffectName() );
85 | m_editor->loadScene( Core::instance()->getEffectName() );
86 |
87 | }
88 |
89 | void MainWindow::save()
90 | {
91 | m_editor->save();
92 | }
93 |
94 | void MainWindow::newScene()
95 | {
96 | NewWidget *w = new NewWidget();
97 | w->show();
98 | connect(w, SIGNAL(open(QString)), this, SLOT(open(QString)));
99 | }
100 |
101 | void MainWindow::newShader()
102 | {
103 |
104 | }
105 |
--------------------------------------------------------------------------------
/SceneEditor/mainwindow.h:
--------------------------------------------------------------------------------
1 | #ifndef MAINWINDOW_H
2 | #define MAINWINDOW_H
3 |
4 | #include
5 |
6 | namespace Ui {
7 | class MainWindow;
8 | }
9 |
10 | class BottomWidget;
11 | class ParamWidget;
12 | class EditorWidget;
13 | class OpenWidget;
14 | class NewWidget;
15 | class NewShader;
16 |
17 | class MainWindow : public QMainWindow
18 | {
19 | Q_OBJECT
20 |
21 | public:
22 | explicit MainWindow(QWidget *parent = 0);
23 | ~MainWindow();
24 | public slots:
25 | void newScene();
26 | void newShader();
27 | void open(QString);
28 | void save();
29 | void reloadEffect();
30 | private:
31 | Ui::MainWindow *ui;
32 | BottomWidget *m_info;
33 | ParamWidget *m_param;
34 | EditorWidget *m_editor;
35 | OpenWidget *m_open;
36 | NewShader *m_newShader;
37 | };
38 |
39 | #endif // MAINWINDOW_H
40 |
--------------------------------------------------------------------------------
/SceneEditor/newshader.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XT95/VisualLiveSystem/e8b5b97718f294cf4d6fa001ff98e0e6d7cbcf74/SceneEditor/newshader.cpp
--------------------------------------------------------------------------------
/SceneEditor/newshader.h:
--------------------------------------------------------------------------------
1 | #ifndef NEWSHADER_H
2 | #define NEWSHADER_H
3 |
4 | #include
5 | #include
6 | #include
7 |
8 | namespace Ui {
9 | class newShader;
10 | }
11 |
12 | class NewShader : public QWidget
13 | {
14 | Q_OBJECT
15 |
16 | public:
17 | explicit NewShader(QWidget *parent = 0);
18 | ~NewShader();
19 | signals:
20 | void reload();
21 | public slots:
22 | void show();
23 | void ok();
24 | void cancel();
25 | private slots:
26 | void setImageChan1();
27 | void setImageChan2();
28 | void setImageChan3();
29 | void setImageChan4();
30 | void setPassChan1();
31 | void setPassChan2();
32 | void setPassChan3();
33 | void setPassChan4();
34 |
35 | private:
36 | bool writeDomChannel(QLineEdit *name, QLineEdit *value, QDomNode *node, QDomDocument &dom, int id);
37 | Ui::newShader *ui;
38 | };
39 |
40 | #endif // NEWSHADER_H
41 |
--------------------------------------------------------------------------------
/SceneEditor/newwidget.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | #include "newwidget.h"
6 | #include "ui_newwidget.h"
7 |
8 | NewWidget::NewWidget(QWidget *parent) :
9 | QWidget(parent),
10 | ui(new Ui::NewWidget)
11 | {
12 | ui->setupUi(this);
13 | connect(ui->buttonOK, SIGNAL(clicked()), this, SLOT(ok()));
14 | connect(ui->buttonCancel, SIGNAL(clicked()), this, SLOT(cancel()));
15 | }
16 |
17 | NewWidget::~NewWidget()
18 | {
19 | delete ui;
20 | }
21 |
22 | void NewWidget::ok()
23 | {
24 | if( QDir("./data/scenes/"+ui->name->text()).exists() )
25 | {
26 | QMessageBox::critical(NULL, "Error", "The scene "+ui->name->text()+" already exist.");
27 | }
28 | else
29 | {
30 | QDir().mkdir("./data/scenes/"+ui->name->text());
31 | if( ui->empty->isChecked() )
32 | {
33 | QFile::copy(":res/framework/Empty/config.xml", "./data/scenes/"+ui->name->text()+"/config.xml");
34 | QFile::copy(":res/framework/Empty/Scene.glsl", "./data/scenes/"+ui->name->text()+"/Scene.glsl");
35 | }
36 | else if( ui->df->isChecked() )
37 | {
38 | QFile::copy(":res/framework/DF/config.xml", "./data/scenes/"+ui->name->text()+"/config.xml");
39 | QFile::copy(":res/framework/DF/Scene.glsl", "./data/scenes/"+ui->name->text()+"/Scene.glsl");
40 | }
41 | else if( ui->raytrace->isChecked() )
42 | {
43 | QFile::copy(":res/framework/Raytracing/config.xml", "./data/scenes/"+ui->name->text()+"/config.xml");
44 | QFile::copy(":res/framework/Raytracing/Scene.glsl", "./data/scenes/"+ui->name->text()+"/Scene.glsl");
45 | }
46 | emit open(ui->name->text());
47 | cancel();
48 | }
49 |
50 | }
51 |
52 |
53 | void NewWidget::cancel()
54 | {
55 | close();
56 | }
57 |
--------------------------------------------------------------------------------
/SceneEditor/newwidget.h:
--------------------------------------------------------------------------------
1 | #ifndef NEWWIDGET_H
2 | #define NEWWIDGET_H
3 |
4 | #include
5 |
6 | namespace Ui {
7 | class NewWidget;
8 | }
9 |
10 | class NewWidget : public QWidget
11 | {
12 | Q_OBJECT
13 |
14 | public:
15 | explicit NewWidget(QWidget *parent = 0);
16 | ~NewWidget();
17 |
18 | signals:
19 | void open(QString);
20 |
21 | public slots:
22 | void ok();
23 | void cancel();
24 |
25 | private:
26 | Ui::NewWidget *ui;
27 | };
28 |
29 | #endif // NEWWIDGET_H
30 |
--------------------------------------------------------------------------------
/SceneEditor/newwidget.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | NewWidget
4 |
5 |
6 | Qt::ApplicationModal
7 |
8 |
9 |
10 | 0
11 | 0
12 | 570
13 | 308
14 |
15 |
16 |
17 | New effect
18 |
19 |
20 | -
21 |
22 |
23 |
24 |
25 |
26 |
-
27 |
28 |
29 | Name
30 |
31 |
32 |
33 | -
34 |
35 |
36 |
37 |
38 |
39 | -
40 |
41 |
42 |
43 |
44 |
45 |
-
46 |
47 |
48 | Framework
49 |
50 |
51 |
52 | -
53 |
54 |
-
55 |
56 |
57 | Empty
58 |
59 |
60 | true
61 |
62 |
63 |
64 | -
65 |
66 |
67 | Distance field
68 |
69 |
70 |
71 | -
72 |
73 |
74 | Raytracing
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 | -
84 |
85 |
86 | Qt::Vertical
87 |
88 |
89 |
90 | 20
91 | 40
92 |
93 |
94 |
95 |
96 | -
97 |
98 |
-
99 |
100 |
101 | Qt::Horizontal
102 |
103 |
104 |
105 | 40
106 | 20
107 |
108 |
109 |
110 |
111 | -
112 |
113 |
114 | OK
115 |
116 |
117 |
118 | -
119 |
120 |
121 | Cancel
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
--------------------------------------------------------------------------------
/SceneEditor/openwidget.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | #include "openwidget.h"
5 | #include "core.h"
6 | #include "ui_openwidget.h"
7 |
8 | OpenWidget::OpenWidget(QWidget *parent) :
9 | QWidget(parent),
10 | ui(new Ui::OpenWidget)
11 | {
12 | ui->setupUi(this);
13 |
14 | QTimer *timer = new QTimer(this);
15 | connect(timer, SIGNAL(timeout()), this, SLOT(refreshList()));
16 | timer->start(10000);
17 |
18 | connect(ui->cancelButton, SIGNAL(clicked()), this, SLOT(cancel()));
19 | connect(ui->okButton, SIGNAL(clicked()), this, SLOT(ok()));
20 | refreshList();
21 | }
22 |
23 | OpenWidget::~OpenWidget()
24 | {
25 | delete ui;
26 | }
27 |
28 | void OpenWidget::ok()
29 | {
30 | emit open( ui->listWidget->currentItem()->text() );
31 | cancel();
32 | }
33 |
34 |
35 | void OpenWidget::cancel()
36 | {
37 | hide();
38 | }
39 |
40 |
41 | void OpenWidget::refreshList()
42 | {
43 | ui->listWidget->clear();
44 |
45 | QDir dir("./data/scenes");
46 | QStringList files = dir.entryList();
47 | for(int i=0; ilistWidget->addItem(item);
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/SceneEditor/openwidget.h:
--------------------------------------------------------------------------------
1 | #ifndef OPENWIDGET_H
2 | #define OPENWIDGET_H
3 |
4 | #include
5 |
6 | namespace Ui {
7 | class OpenWidget;
8 | }
9 |
10 | class OpenWidget : public QWidget
11 | {
12 | Q_OBJECT
13 |
14 | public:
15 | explicit OpenWidget(QWidget *parent = 0);
16 | ~OpenWidget();
17 |
18 | public slots:
19 | void ok();
20 | void cancel();
21 |
22 | signals:
23 | void open(QString);
24 | private slots:
25 | void refreshList();
26 | private:
27 | Ui::OpenWidget *ui;
28 | };
29 |
30 | #endif // OPENWIDGET_H
31 |
--------------------------------------------------------------------------------
/SceneEditor/openwidget.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | OpenWidget
4 |
5 |
6 | Qt::ApplicationModal
7 |
8 |
9 |
10 | 0
11 | 0
12 | 512
13 | 388
14 |
15 |
16 |
17 | Qt::DefaultContextMenu
18 |
19 |
20 | Open effect
21 |
22 |
23 | -
24 |
25 |
26 | true
27 |
28 |
29 |
30 | -
31 |
32 |
-
33 |
34 |
35 | Qt::Horizontal
36 |
37 |
38 |
39 | 40
40 | 20
41 |
42 |
43 |
44 |
45 | -
46 |
47 |
48 | Open
49 |
50 |
51 |
52 | -
53 |
54 |
55 | Cancel
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/SceneEditor/paramwidget.cpp:
--------------------------------------------------------------------------------
1 | #include "paramwidget.h"
2 | #include "ui_paramwidget.h"
3 | #include "core.h"
4 | ParamWidget::ParamWidget(QWidget *parent) :
5 | QDockWidget(parent),
6 | ui(new Ui::ParamWidget)
7 | {
8 | ui->setupUi(this);
9 |
10 | connect(ui->CC0, SIGNAL(valueChanged(int)), this, SLOT(CC0Changed(int)));
11 | connect(ui->CC1, SIGNAL(valueChanged(int)), this, SLOT(CC1Changed(int)));
12 | connect(ui->CC2, SIGNAL(valueChanged(int)), this, SLOT(CC2Changed(int)));
13 | connect(ui->CC3, SIGNAL(valueChanged(int)), this, SLOT(CC3Changed(int)));
14 | }
15 |
16 | ParamWidget::~ParamWidget()
17 | {
18 | delete ui;
19 | }
20 |
21 | void ParamWidget::clearName()
22 | {
23 | ui->label0->setText("");
24 | ui->label1->setText("");
25 | ui->label2->setText("");
26 | ui->label3->setText("");
27 | }
28 |
29 | void ParamWidget::nameCCChanged(int id, QString name)
30 | {
31 | if(id == 0)
32 | ui->label0->setText(name);
33 | else if(id == 1)
34 | ui->label1->setText(name);
35 | else if(id == 2)
36 | ui->label2->setText(name);
37 | else if(id == 3)
38 | ui->label3->setText(name);
39 | }
40 |
41 | void ParamWidget::CC0Changed(int v)
42 | {
43 | Core::instance()->setCC(0, float(v)/100.f);
44 | }
45 |
46 | void ParamWidget::CC1Changed(int v)
47 | {
48 | Core::instance()->setCC(1, float(v)/100.f);
49 | }
50 | void ParamWidget::CC2Changed(int v)
51 | {
52 | Core::instance()->setCC(2, float(v)/100.f);
53 | }
54 | void ParamWidget::CC3Changed(int v)
55 | {
56 | Core::instance()->setCC(3, float(v)/100.f);
57 | }
58 |
--------------------------------------------------------------------------------
/SceneEditor/paramwidget.h:
--------------------------------------------------------------------------------
1 | #ifndef PARAMWIDGET_H
2 | #define PARAMWIDGET_H
3 |
4 | #include
5 |
6 | namespace Ui {
7 | class ParamWidget;
8 | }
9 |
10 | class ParamWidget : public QDockWidget
11 | {
12 | Q_OBJECT
13 |
14 | public:
15 | explicit ParamWidget(QWidget *parent = 0);
16 | ~ParamWidget();
17 |
18 | void clearName();
19 | public slots:
20 | void nameCCChanged(int id, QString name);
21 |
22 | private slots:
23 | void CC0Changed(int);
24 | void CC1Changed(int);
25 | void CC2Changed(int);
26 | void CC3Changed(int);
27 | private:
28 | Ui::ParamWidget *ui;
29 | };
30 |
31 | #endif // PARAMWIDGET_H
32 |
--------------------------------------------------------------------------------
/SceneEditor/paramwidget.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | ParamWidget
4 |
5 |
6 |
7 | 0
8 | 0
9 | 492
10 | 243
11 |
12 |
13 |
14 |
15 | 0
16 | 0
17 |
18 |
19 |
20 | Scene parameters
21 |
22 |
23 |
24 | -
25 |
26 |
-
27 |
28 |
29 |
30 |
31 |
32 |
33 | -
34 |
35 |
36 | 100
37 |
38 |
39 | Qt::Horizontal
40 |
41 |
42 |
43 |
44 |
45 | -
46 |
47 |
-
48 |
49 |
50 |
51 |
52 |
53 |
54 | -
55 |
56 |
57 | 100
58 |
59 |
60 | Qt::Horizontal
61 |
62 |
63 |
64 |
65 |
66 | -
67 |
68 |
-
69 |
70 |
71 |
72 |
73 |
74 |
75 | -
76 |
77 |
78 | 100
79 |
80 |
81 | Qt::Horizontal
82 |
83 |
84 |
85 |
86 |
87 | -
88 |
89 |
-
90 |
91 |
92 |
93 |
94 |
95 |
96 | -
97 |
98 |
99 | 100
100 |
101 |
102 | Qt::Horizontal
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
--------------------------------------------------------------------------------
/SceneEditor/qdarkstyle/rc/Hmovetoolbar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XT95/VisualLiveSystem/e8b5b97718f294cf4d6fa001ff98e0e6d7cbcf74/SceneEditor/qdarkstyle/rc/Hmovetoolbar.png
--------------------------------------------------------------------------------
/SceneEditor/qdarkstyle/rc/Hsepartoolbar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XT95/VisualLiveSystem/e8b5b97718f294cf4d6fa001ff98e0e6d7cbcf74/SceneEditor/qdarkstyle/rc/Hsepartoolbar.png
--------------------------------------------------------------------------------
/SceneEditor/qdarkstyle/rc/Vmovetoolbar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XT95/VisualLiveSystem/e8b5b97718f294cf4d6fa001ff98e0e6d7cbcf74/SceneEditor/qdarkstyle/rc/Vmovetoolbar.png
--------------------------------------------------------------------------------
/SceneEditor/qdarkstyle/rc/Vsepartoolbar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XT95/VisualLiveSystem/e8b5b97718f294cf4d6fa001ff98e0e6d7cbcf74/SceneEditor/qdarkstyle/rc/Vsepartoolbar.png
--------------------------------------------------------------------------------
/SceneEditor/qdarkstyle/rc/branch_closed-on.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XT95/VisualLiveSystem/e8b5b97718f294cf4d6fa001ff98e0e6d7cbcf74/SceneEditor/qdarkstyle/rc/branch_closed-on.png
--------------------------------------------------------------------------------
/SceneEditor/qdarkstyle/rc/branch_closed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XT95/VisualLiveSystem/e8b5b97718f294cf4d6fa001ff98e0e6d7cbcf74/SceneEditor/qdarkstyle/rc/branch_closed.png
--------------------------------------------------------------------------------
/SceneEditor/qdarkstyle/rc/branch_open-on.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XT95/VisualLiveSystem/e8b5b97718f294cf4d6fa001ff98e0e6d7cbcf74/SceneEditor/qdarkstyle/rc/branch_open-on.png
--------------------------------------------------------------------------------
/SceneEditor/qdarkstyle/rc/branch_open.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XT95/VisualLiveSystem/e8b5b97718f294cf4d6fa001ff98e0e6d7cbcf74/SceneEditor/qdarkstyle/rc/branch_open.png
--------------------------------------------------------------------------------
/SceneEditor/qdarkstyle/rc/checkbox.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XT95/VisualLiveSystem/e8b5b97718f294cf4d6fa001ff98e0e6d7cbcf74/SceneEditor/qdarkstyle/rc/checkbox.png
--------------------------------------------------------------------------------
/SceneEditor/qdarkstyle/rc/close.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XT95/VisualLiveSystem/e8b5b97718f294cf4d6fa001ff98e0e6d7cbcf74/SceneEditor/qdarkstyle/rc/close.png
--------------------------------------------------------------------------------
/SceneEditor/qdarkstyle/rc/down_arrow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XT95/VisualLiveSystem/e8b5b97718f294cf4d6fa001ff98e0e6d7cbcf74/SceneEditor/qdarkstyle/rc/down_arrow.png
--------------------------------------------------------------------------------
/SceneEditor/qdarkstyle/rc/down_arrow_disabled.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XT95/VisualLiveSystem/e8b5b97718f294cf4d6fa001ff98e0e6d7cbcf74/SceneEditor/qdarkstyle/rc/down_arrow_disabled.png
--------------------------------------------------------------------------------
/SceneEditor/qdarkstyle/rc/left_arrow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XT95/VisualLiveSystem/e8b5b97718f294cf4d6fa001ff98e0e6d7cbcf74/SceneEditor/qdarkstyle/rc/left_arrow.png
--------------------------------------------------------------------------------
/SceneEditor/qdarkstyle/rc/left_arrow_disabled.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XT95/VisualLiveSystem/e8b5b97718f294cf4d6fa001ff98e0e6d7cbcf74/SceneEditor/qdarkstyle/rc/left_arrow_disabled.png
--------------------------------------------------------------------------------
/SceneEditor/qdarkstyle/rc/right_arrow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XT95/VisualLiveSystem/e8b5b97718f294cf4d6fa001ff98e0e6d7cbcf74/SceneEditor/qdarkstyle/rc/right_arrow.png
--------------------------------------------------------------------------------
/SceneEditor/qdarkstyle/rc/right_arrow_disabled.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XT95/VisualLiveSystem/e8b5b97718f294cf4d6fa001ff98e0e6d7cbcf74/SceneEditor/qdarkstyle/rc/right_arrow_disabled.png
--------------------------------------------------------------------------------
/SceneEditor/qdarkstyle/rc/sizegrip.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XT95/VisualLiveSystem/e8b5b97718f294cf4d6fa001ff98e0e6d7cbcf74/SceneEditor/qdarkstyle/rc/sizegrip.png
--------------------------------------------------------------------------------
/SceneEditor/qdarkstyle/rc/stylesheet-branch-end.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XT95/VisualLiveSystem/e8b5b97718f294cf4d6fa001ff98e0e6d7cbcf74/SceneEditor/qdarkstyle/rc/stylesheet-branch-end.png
--------------------------------------------------------------------------------
/SceneEditor/qdarkstyle/rc/stylesheet-branch-more.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XT95/VisualLiveSystem/e8b5b97718f294cf4d6fa001ff98e0e6d7cbcf74/SceneEditor/qdarkstyle/rc/stylesheet-branch-more.png
--------------------------------------------------------------------------------
/SceneEditor/qdarkstyle/rc/stylesheet-vline.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XT95/VisualLiveSystem/e8b5b97718f294cf4d6fa001ff98e0e6d7cbcf74/SceneEditor/qdarkstyle/rc/stylesheet-vline.png
--------------------------------------------------------------------------------
/SceneEditor/qdarkstyle/rc/transparent.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XT95/VisualLiveSystem/e8b5b97718f294cf4d6fa001ff98e0e6d7cbcf74/SceneEditor/qdarkstyle/rc/transparent.png
--------------------------------------------------------------------------------
/SceneEditor/qdarkstyle/rc/undock.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XT95/VisualLiveSystem/e8b5b97718f294cf4d6fa001ff98e0e6d7cbcf74/SceneEditor/qdarkstyle/rc/undock.png
--------------------------------------------------------------------------------
/SceneEditor/qdarkstyle/rc/up_arrow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XT95/VisualLiveSystem/e8b5b97718f294cf4d6fa001ff98e0e6d7cbcf74/SceneEditor/qdarkstyle/rc/up_arrow.png
--------------------------------------------------------------------------------
/SceneEditor/qdarkstyle/rc/up_arrow_disabled.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XT95/VisualLiveSystem/e8b5b97718f294cf4d6fa001ff98e0e6d7cbcf74/SceneEditor/qdarkstyle/rc/up_arrow_disabled.png
--------------------------------------------------------------------------------
/SceneEditor/qdarkstyle/style.qrc:
--------------------------------------------------------------------------------
1 |
2 |
3 | rc/up_arrow_disabled.png
4 | rc/Hmovetoolbar.png
5 | rc/stylesheet-branch-end.png
6 | rc/branch_closed-on.png
7 | rc/stylesheet-vline.png
8 | rc/branch_closed.png
9 | rc/branch_open-on.png
10 | rc/transparent.png
11 | rc/right_arrow_disabled.png
12 | rc/sizegrip.png
13 | rc/close.png
14 | rc/down_arrow.png
15 | rc/Vmovetoolbar.png
16 | rc/left_arrow.png
17 | rc/stylesheet-branch-more.png
18 | rc/up_arrow.png
19 | rc/right_arrow.png
20 | rc/left_arrow_disabled.png
21 | rc/Hsepartoolbar.png
22 | rc/checkbox.png
23 | rc/branch_open.png
24 | rc/Vsepartoolbar.png
25 | rc/down_arrow_disabled.png
26 | rc/undock.png
27 |
28 |
29 | style.qss
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/SceneEditor/renderwidget.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 | #include
6 | #include
7 |
8 | #include "fast2dquad.h"
9 | #include "renderwidget.h"
10 | #include "core.h"
11 |
12 |
13 | RenderWidget::RenderWidget(QWidget *parent) : QGLWidget(parent)
14 | {
15 | QTimer *timer = new QTimer(this);
16 | connect(timer, SIGNAL(timeout()), this, SLOT(updateGL()));
17 | timer->start(10);
18 |
19 | resetCamera();
20 |
21 | m_time.restart();
22 | m_fpsTime.restart();
23 | }
24 |
25 | RenderWidget::~RenderWidget()
26 | {
27 | Fast2DQuadFree();
28 | }
29 |
30 |
31 | //-----------------------------------------------------------------------------
32 | // initializeGL
33 | //-----------------------------------------------------------------------------
34 | void RenderWidget::initializeGL()
35 | {
36 | //Glew
37 | GLenum err = glewInit();
38 | if(GLEW_OK != err)
39 | {
40 | QMessageBox::critical(this, "Error", "GLEW Init fail !");
41 | }
42 | if(!GLEW_ARB_vertex_program || !GLEW_ARB_fragment_program)
43 | {
44 | QMessageBox::critical(this, "Error", "GLSL Shader not supported !");
45 | }
46 |
47 | Fast2DQuadInit();
48 | glMatrixMode(GL_PROJECTION);
49 | gluPerspective(90., 16./9., 0.01, 10000.);
50 | glMatrixMode(GL_MODELVIEW);
51 | glLoadIdentity();
52 |
53 |
54 | Core::instance()->initGL();
55 |
56 | }
57 |
58 | //-----------------------------------------------------------------------------
59 | // loadScene
60 | //-----------------------------------------------------------------------------
61 | void RenderWidget::loadScene(QString filename)
62 | {
63 |
64 | Scene *oldS = NULL;
65 | Scene *newS = new Scene();
66 |
67 | newS->read(filename.toStdString().c_str());
68 | if( Core::instance()->getScene() )
69 | {
70 | oldS = Core::instance()->getScene();
71 | }
72 |
73 | Core::instance()->setScene(newS);
74 | delete oldS;
75 | }
76 |
77 | //-----------------------------------------------------------------------------
78 | // recompilShader
79 | //-----------------------------------------------------------------------------
80 | void RenderWidget::recompilShader(QString txt,int id)
81 | {
82 | Core::instance()->getScene()->compilShader(txt.toStdString().c_str(),id);
83 | }
84 |
85 | //-----------------------------------------------------------------------------
86 | // paintGL
87 | //-----------------------------------------------------------------------------
88 | void RenderWidget::paintGL()
89 | {
90 | glClear(GL_COLOR_BUFFER_BIT);
91 |
92 | if( Core::instance()->getScene() )
93 | {
94 | if(m_alpha < 0.005f) m_alpha = 0.005f;
95 | if(m_alpha > 3.14f) m_alpha = 3.14f;
96 | float px = sin(m_theta)*m_rayon*sin(m_alpha);
97 | float py = cos(m_alpha)*m_rayon;
98 | float pz = cos(m_theta)*m_rayon*sin(m_alpha);
99 |
100 | glLoadIdentity();
101 | gluLookAt( px,py,pz, 0.,0.,0., 0.,1.,0.);
102 | Core::instance()->getScene()->compute();
103 |
104 | Core::instance()->getScene()->draw();
105 | }
106 | glFlush();
107 | glFinish();
108 | }
109 |
110 | //-----------------------------------------------------------------------------
111 | // resizeGL
112 | //-----------------------------------------------------------------------------
113 | void RenderWidget::resizeGL(int width, int height)
114 | {
115 | m_w = width;
116 | m_h = height;
117 | glViewport(0,0,m_w,m_h);
118 | }
119 |
120 |
121 | void RenderWidget::resolutionChanged(int x,int y)
122 | {
123 | makeCurrent();
124 | }
125 |
126 |
127 |
128 | void RenderWidget::mousePressEvent(QMouseEvent* event)
129 | {
130 | m_mousePos = event->pos();
131 | if(event->button() == Qt::LeftButton)
132 | m_mousePressed = true;
133 | QWidget::mousePressEvent(event);
134 | }
135 |
136 | void RenderWidget::mouseReleaseEvent(QMouseEvent* event)
137 | {
138 | m_mousePos = event->pos();
139 | if(event->button() == Qt::LeftButton)
140 | m_mousePressed = false;
141 | QWidget::mouseReleaseEvent(event);
142 | }
143 |
144 | void RenderWidget::mouseMoveEvent(QMouseEvent* event)
145 | {
146 | if(m_mousePressed)
147 | {
148 | m_theta -= 0.004f * float(event->pos().x() - m_mousePos.x());
149 | m_alpha -= 0.004f * float(event->pos().y() - m_mousePos.y());
150 | }
151 | m_mousePos = event->pos();
152 |
153 | QWidget::mouseMoveEvent(event);
154 | }
155 |
156 | void RenderWidget::wheelEvent(QWheelEvent* event)
157 | {
158 |
159 | if(event->delta() > 0) m_rayon /= 1.05f;
160 | else m_rayon *= 1.05f;
161 |
162 | QWidget::wheelEvent(event);
163 | }
164 |
165 | void RenderWidget::resetCamera()
166 | {
167 | m_rayon = 10.;
168 | m_theta = 0.f;
169 | m_alpha = 0.f;
170 | m_mousePressed = false;
171 | }
172 |
173 |
174 | void RenderWidget::takeScreenshot()
175 | {
176 | emit updateGL();
177 | QImage imageToSave = grabFrameBuffer(false);
178 | QString filename = QFileDialog::getSaveFileName(this, "Save a screenshot", QString(), "Images (*.png *.jpg)");
179 | imageToSave.save(filename);
180 | }
181 |
--------------------------------------------------------------------------------
/SceneEditor/renderwidget.h:
--------------------------------------------------------------------------------
1 | #ifndef RENDERWIDGET_H
2 | #define RENDERWIDGET_H
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 |
10 | #include "fbo.h"
11 | #include "shader.h"
12 |
13 | class RenderWidget : public QGLWidget
14 | {
15 | Q_OBJECT
16 |
17 | public:
18 | RenderWidget(QWidget *parent = 0);
19 | ~RenderWidget();
20 |
21 | public slots:
22 | void resolutionChanged(int x,int y);
23 | void loadScene( QString filename );
24 | void recompilShader( QString txt, int id);
25 |
26 |
27 | void mousePressEvent(QMouseEvent* event);
28 | void mouseReleaseEvent(QMouseEvent* event);
29 | void mouseMoveEvent(QMouseEvent* event);
30 | void wheelEvent(QWheelEvent* event);
31 |
32 | void resetCamera();
33 | void takeScreenshot();
34 | protected:
35 | void initializeGL();
36 | void paintGL();
37 | void resizeGL(int width, int height);
38 |
39 | QTime m_timer;
40 | QTime m_time;
41 | QTime m_fpsTime;
42 | int m_w,m_h;
43 |
44 | QPoint m_mousePos;
45 | bool m_mousePressed;
46 | float m_rayon;
47 | float m_theta, m_alpha;
48 | };
49 |
50 | #endif // RENDERWIDGET_H
51 |
--------------------------------------------------------------------------------
/SceneEditor/res.qrc:
--------------------------------------------------------------------------------
1 |
2 |
3 | res/img/micro.png
4 | res/img/music.png
5 | res/img/new.png
6 | res/img/open.png
7 | res/img/save.png
8 | res/img/setting.png
9 | res/img/setting2.png
10 | res/img/setting_visual.png
11 | res/img/vls.png
12 | res/img/projector.png
13 | res/framework/Empty/config.xml
14 | res/framework/Empty/Scene.glsl
15 | res/framework/DF/config.xml
16 | res/framework/DF/Scene.glsl
17 | res/framework/Raytracing/config.xml
18 | res/framework/Raytracing/Scene.glsl
19 | res/img/new shader.png
20 | res/img/camera.png
21 | res/img/screenshot.png
22 | res/framework/Layer/layer.glsl
23 |
24 |
25 |
--------------------------------------------------------------------------------
/SceneEditor/res/framework/DF/config.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/SceneEditor/res/framework/Empty/Scene.glsl:
--------------------------------------------------------------------------------
1 | varying vec2 v;
2 | uniform float time;
3 | uniform float CC[4];
4 |
5 |
6 | void main()
7 | {
8 | gl_FragColor = vec4( v*0.5+0.5, 0., 1.);
9 | }
--------------------------------------------------------------------------------
/SceneEditor/res/framework/Empty/config.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/SceneEditor/res/framework/Layer/layer.glsl:
--------------------------------------------------------------------------------
1 | varying vec2 v;
2 | uniform sampler2D lastBuffer;
3 | uniform float time,bassTime,CC[4];
4 |
5 | void main()
6 | {
7 | vec2 uv = v*vec2(.5,.5)+vec2(.5);
8 | vec4 col = texture2D(lastBuffer, uv);
9 |
10 | gl_FragColor = col;
11 | }
12 |
--------------------------------------------------------------------------------
/SceneEditor/res/framework/Raytracing/Scene.glsl:
--------------------------------------------------------------------------------
1 | varying vec2 v;
2 | uniform float time;
3 | uniform float CC[4];
4 |
5 |
6 | void main()
7 | {
8 | gl_FragColor = vec4( v*0.5+0.5, 0., 1.);
9 | }
--------------------------------------------------------------------------------
/SceneEditor/res/framework/Raytracing/config.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/SceneEditor/res/img/camera.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XT95/VisualLiveSystem/e8b5b97718f294cf4d6fa001ff98e0e6d7cbcf74/SceneEditor/res/img/camera.png
--------------------------------------------------------------------------------
/SceneEditor/res/img/filenew.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XT95/VisualLiveSystem/e8b5b97718f294cf4d6fa001ff98e0e6d7cbcf74/SceneEditor/res/img/filenew.png
--------------------------------------------------------------------------------
/SceneEditor/res/img/fileopen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XT95/VisualLiveSystem/e8b5b97718f294cf4d6fa001ff98e0e6d7cbcf74/SceneEditor/res/img/fileopen.png
--------------------------------------------------------------------------------
/SceneEditor/res/img/filesave.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XT95/VisualLiveSystem/e8b5b97718f294cf4d6fa001ff98e0e6d7cbcf74/SceneEditor/res/img/filesave.png
--------------------------------------------------------------------------------
/SceneEditor/res/img/micro.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XT95/VisualLiveSystem/e8b5b97718f294cf4d6fa001ff98e0e6d7cbcf74/SceneEditor/res/img/micro.png
--------------------------------------------------------------------------------
/SceneEditor/res/img/music.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XT95/VisualLiveSystem/e8b5b97718f294cf4d6fa001ff98e0e6d7cbcf74/SceneEditor/res/img/music.png
--------------------------------------------------------------------------------
/SceneEditor/res/img/new shader.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XT95/VisualLiveSystem/e8b5b97718f294cf4d6fa001ff98e0e6d7cbcf74/SceneEditor/res/img/new shader.png
--------------------------------------------------------------------------------
/SceneEditor/res/img/new.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XT95/VisualLiveSystem/e8b5b97718f294cf4d6fa001ff98e0e6d7cbcf74/SceneEditor/res/img/new.png
--------------------------------------------------------------------------------
/SceneEditor/res/img/open.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XT95/VisualLiveSystem/e8b5b97718f294cf4d6fa001ff98e0e6d7cbcf74/SceneEditor/res/img/open.png
--------------------------------------------------------------------------------
/SceneEditor/res/img/projector.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XT95/VisualLiveSystem/e8b5b97718f294cf4d6fa001ff98e0e6d7cbcf74/SceneEditor/res/img/projector.png
--------------------------------------------------------------------------------
/SceneEditor/res/img/save.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XT95/VisualLiveSystem/e8b5b97718f294cf4d6fa001ff98e0e6d7cbcf74/SceneEditor/res/img/save.png
--------------------------------------------------------------------------------
/SceneEditor/res/img/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XT95/VisualLiveSystem/e8b5b97718f294cf4d6fa001ff98e0e6d7cbcf74/SceneEditor/res/img/screenshot.png
--------------------------------------------------------------------------------
/SceneEditor/res/img/setting.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XT95/VisualLiveSystem/e8b5b97718f294cf4d6fa001ff98e0e6d7cbcf74/SceneEditor/res/img/setting.png
--------------------------------------------------------------------------------
/SceneEditor/res/img/setting2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XT95/VisualLiveSystem/e8b5b97718f294cf4d6fa001ff98e0e6d7cbcf74/SceneEditor/res/img/setting2.png
--------------------------------------------------------------------------------
/SceneEditor/res/img/setting_visual.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XT95/VisualLiveSystem/e8b5b97718f294cf4d6fa001ff98e0e6d7cbcf74/SceneEditor/res/img/setting_visual.png
--------------------------------------------------------------------------------
/SceneEditor/res/img/vls.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XT95/VisualLiveSystem/e8b5b97718f294cf4d6fa001ff98e0e6d7cbcf74/SceneEditor/res/img/vls.png
--------------------------------------------------------------------------------
/SceneEditor/res/logo.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XT95/VisualLiveSystem/e8b5b97718f294cf4d6fa001ff98e0e6d7cbcf74/SceneEditor/res/logo.ico
--------------------------------------------------------------------------------
/SceneEditor/ressource.rc:
--------------------------------------------------------------------------------
1 | IDI_ICON1 ICON DISCARDABLE "res/logo.ico"
--------------------------------------------------------------------------------
/SceneEditor/scene.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XT95/VisualLiveSystem/e8b5b97718f294cf4d6fa001ff98e0e6d7cbcf74/SceneEditor/scene.cpp
--------------------------------------------------------------------------------
/SceneEditor/scene.h:
--------------------------------------------------------------------------------
1 | #ifndef SCENE_H
2 | #define SCENE_H
3 |
4 | #include "texture.h"
5 | #include "shader.h"
6 | #include "fbo.h"
7 | #include
8 | #include
9 |
10 | typedef enum {DEFAULT, BLEND_ALPHA, BLEND_ADD, NONE} Mode;
11 | typedef enum {PIXEL,PARTICLE} Type;
12 | typedef struct
13 | {
14 | Shader *shader;
15 | FBO *buffer, *backBuffer, *tmpBuffer;
16 | int width, height;
17 | Type type;
18 | Mode mode;
19 | QString name;
20 | Texture *channel[4];
21 | QString channelName[4];
22 | int iterate;
23 | }Layer;
24 | typedef struct
25 | {
26 | FBO *src,*dest;
27 | }Copy;
28 |
29 | class Scene
30 | {
31 | public:
32 | Scene();
33 | ~Scene();
34 |
35 | void compilShader(const char *txt, int id);
36 | void read(const char *filename = NULL); // Must be call where we are an OGL context
37 |
38 |
39 | void resetTime();
40 | void compute();
41 | void draw();
42 |
43 | QString getParamName(int a) { return m_param[a]; }
44 | Layer getLayer(int id) { return m_layer[id]; }
45 | private:
46 | void generateParticles();
47 | void drawParticles();
48 |
49 | int m_nbParticles;
50 | GLuint m_vboParticle;
51 |
52 | Layer *m_layer;
53 | int m_nbLayer;
54 | Copy *m_copy;
55 | int m_nbCopy;
56 | QString m_param[4];
57 |
58 | QTime m_QTime;
59 | float m_time;
60 | };
61 |
62 | #endif // SCENE_H
63 |
--------------------------------------------------------------------------------
/SceneEditor/shader.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include "shader.h"
3 | #include "core.h"
4 | #include
5 |
6 |
7 |
8 | //-----------------------------------------------------------------------------
9 | // Constructor
10 | //-----------------------------------------------------------------------------
11 | Shader::Shader()
12 | {
13 |
14 | }
15 | //-----------------------------------------------------------------------------
16 | // Destructor
17 | //-----------------------------------------------------------------------------
18 | Shader::~Shader()
19 | {
20 |
21 | }
22 |
23 | //-----------------------------------------------------------------------------
24 | // enable/disable
25 | //-----------------------------------------------------------------------------
26 | void Shader::enable()
27 | {
28 | glUseProgramObjectARB(m_program);
29 | }
30 | void Shader::disable()
31 | {
32 | glUseProgramObjectARB(0);
33 | }
34 |
35 |
36 | //-----------------------------------------------------------------------------
37 | // send uniform
38 | //-----------------------------------------------------------------------------
39 | void Shader::sendi(const char *name, int x)
40 | {
41 | glUniform1i(glGetUniformLocation(m_program,name), x);
42 | }
43 | void Shader::sendf(const char *name, float x)
44 | {
45 | glUniform1f(glGetUniformLocation(m_program,name), x);
46 | }
47 | void Shader::sendf(const char *name, float x, float y)
48 | {
49 | glUniform2f(glGetUniformLocation(m_program,name), x,y);
50 | }
51 | void Shader::sendf(const char *name, float x, float y, float z)
52 | {
53 | glUniform3f(glGetUniformLocation(m_program,name), x,y,z);
54 | }
55 | void Shader::sendf(const char *name, float x, float y, float z, float w)
56 | {
57 | glUniform4f(glGetUniformLocation(m_program,name), x,y,z,w);
58 | }
59 |
60 |
61 | //-----------------------------------------------------------------------------
62 | // compil
63 | //-----------------------------------------------------------------------------
64 | int Shader::compil( const char *vertex, const char *fragment )
65 | {
66 | m_program = glCreateProgramObjectARB();
67 | if( !makeShader(vertex, GL_VERTEX_SHADER_ARB) )
68 | {
69 | //QMessageBox::critical(NULL, "Error", "Can't compil the vertex shader !");
70 | return SHADER_VERTEX_ERROR;
71 | }
72 | if( !makeShader(fragment, GL_FRAGMENT_SHADER_ARB) )
73 | {
74 | //QMessageBox::critical(NULL, "Error", "Can't compil this pixel shader !");
75 | return SHADER_FRAGMENT_ERROR;
76 | }
77 |
78 | glLinkProgram(m_program);
79 |
80 | return SHADER_SUCCESS;
81 | }
82 |
83 |
84 | bool Shader::makeShader(const char *txt, GLuint type)
85 | {
86 | GLuint object = glCreateShaderObjectARB(type);
87 | glShaderSource(object, 1, (const GLchar**)(&txt), NULL);
88 | glCompileShader(object);
89 |
90 | if( checkShader(object) )
91 | {
92 | glAttachObjectARB(m_program, object);
93 | glDeleteObjectARB(object);
94 | }
95 | else
96 | {
97 | return false;
98 | }
99 | return true;
100 | }
101 |
102 | bool Shader::checkShader(int id)
103 | {
104 | GLint ok = 0;
105 |
106 | glGetShaderiv(id, GL_COMPILE_STATUS, &ok);
107 | if( ok != GL_TRUE )
108 | {
109 | GLint logLength = 0;
110 | GLchar* log = NULL;
111 |
112 | glGetShaderiv(id, GL_INFO_LOG_LENGTH, &logLength);
113 | log = new GLchar[logLength];
114 | glGetShaderInfoLog(id, logLength, &logLength, log);
115 |
116 |
117 | Core::instance()->writeError( "\n"+QString(log)+"\n", false );
118 |
119 | delete[] log;
120 |
121 | return false;
122 | }
123 | else
124 | {
125 | GLint logLength = 0;
126 | GLchar* log = NULL;
127 |
128 | glGetShaderiv(id, GL_INFO_LOG_LENGTH, &logLength);
129 | log = new GLchar[logLength];
130 | glGetShaderInfoLog(id, logLength, &logLength, log);
131 |
132 | if(logLength>0)
133 | Core::instance()->writeWarning("\n"+QString(log)+"\n", false );
134 |
135 | delete[] log;
136 | }
137 |
138 | return true;
139 | }
140 |
141 |
142 |
143 |
144 |
--------------------------------------------------------------------------------
/SceneEditor/shader.h:
--------------------------------------------------------------------------------
1 | #ifndef DEF_SHADER
2 | #define DEF_SHADER
3 |
4 |
5 | #include
6 | #include
7 |
8 | #define SHADER_SUCCESS 1
9 | #define SHADER_VERTEX_ERROR 2
10 | #define SHADER_FRAGMENT_ERROR 3
11 |
12 | class Shader
13 | {
14 | public:
15 | Shader();
16 | ~Shader();
17 |
18 | int compil(const char *vertex, const char *fragment);
19 |
20 | void enable();
21 | void disable();
22 |
23 | void sendi(const char *name, int x);
24 | void sendf(const char *name, float x);
25 | void sendf(const char *name, float x, float y);
26 | void sendf(const char *name, float x, float y, float z);
27 | void sendf(const char *name, float x, float y, float z, float w);
28 | private:
29 | bool makeShader(const char *txt, GLuint type);
30 | bool checkShader( int id );
31 | GLuint m_program;
32 | };
33 |
34 |
35 |
36 | #endif
37 |
--------------------------------------------------------------------------------
/SceneEditor/texteditor.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include "texteditor.h"
4 | #include "highlighter.h"
5 |
6 | TextEditor::TextEditor(QWidget *parent) : QPlainTextEdit(parent)
7 | {
8 | lineNumberArea = new LineNumberArea(this);
9 |
10 | connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(updateLineNumberAreaWidth(int)));
11 | connect(this, SIGNAL(updateRequest(QRect,int)), this, SLOT(updateLineNumberArea(QRect,int)));
12 | connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(highlightCurrentLine()));
13 |
14 | updateLineNumberAreaWidth(0);
15 | highlightCurrentLine();
16 |
17 | QFont font("consolas",9);
18 | const int tabStop = 4; // 4 characters
19 | QFontMetrics metrics(font);
20 | setTabStopWidth(tabStop * metrics.width(' '));
21 | setFont(font);
22 | setLineWrapMode(QPlainTextEdit::NoWrap);
23 |
24 | m_highlighter = new Highlighter(document());
25 |
26 | m_autoUpdate = false;
27 | m_timer = new QTimer();
28 | m_timer->setSingleShot(true);
29 | m_timer->setInterval(1000);
30 | connect(m_timer, SIGNAL(timeout()), this, SLOT(updateShader()));
31 | connect(this, SIGNAL(textChanged()), this, SLOT(resetTimer()));
32 | }
33 |
34 | void TextEditor::open(QString filename, int id)
35 | {
36 | if(id < 0)
37 | m_highlighter->defineXMLRule();
38 |
39 | m_id = id;
40 | m_filename = filename;
41 |
42 | QFile f(m_filename);
43 | f.open(QIODevice::ReadOnly | QIODevice::Text);
44 | QTextStream flux(&f);
45 | setPlainText( flux.readAll() );
46 | f.close();
47 |
48 |
49 | m_autoUpdate = false;
50 | }
51 |
52 | void TextEditor::save()
53 | {
54 | QFile f(m_filename);
55 | f.setPermissions(QFile::WriteUser);
56 | f.open(QIODevice::WriteOnly | QIODevice::Text);
57 | QTextStream flux(&f);
58 | flux.setCodec("UTF-8");
59 | flux << toPlainText();
60 | f.close();
61 | }
62 |
63 | int TextEditor::lineNumberAreaWidth()
64 | {
65 | int digits = 1;
66 | int max = qMax(1, blockCount());
67 | while (max >= 10) {
68 | max /= 10;
69 | ++digits;
70 | }
71 |
72 | int space = 5 + fontMetrics().width(QLatin1Char('9')) * digits;
73 |
74 | return space;
75 | }
76 |
77 |
78 |
79 | void TextEditor::updateLineNumberAreaWidth(int /* newBlockCount */)
80 | {
81 | setViewportMargins(lineNumberAreaWidth(), 0, 0, 0);
82 | }
83 |
84 |
85 |
86 | void TextEditor::updateLineNumberArea(const QRect &rect, int dy)
87 | {
88 | if (dy)
89 | lineNumberArea->scroll(0, dy);
90 | else
91 | lineNumberArea->update(0, rect.y(), lineNumberArea->width(), rect.height());
92 |
93 | if (rect.contains(viewport()->rect()))
94 | updateLineNumberAreaWidth(0);
95 | }
96 |
97 |
98 |
99 | void TextEditor::resizeEvent(QResizeEvent *e)
100 | {
101 | QPlainTextEdit::resizeEvent(e);
102 |
103 | QRect cr = contentsRect();
104 | lineNumberArea->setGeometry(QRect(cr.left(), cr.top(), lineNumberAreaWidth(), cr.height()));
105 | }
106 |
107 |
108 |
109 | void TextEditor::highlightCurrentLine()
110 | {
111 | QList extraSelections;
112 |
113 | if (!isReadOnly()) {
114 | QTextEdit::ExtraSelection selection;
115 |
116 | QColor lineColor = QColor(Qt::darkGray).darker(300);
117 |
118 | selection.format.setBackground(lineColor);
119 | selection.format.setProperty(QTextFormat::FullWidthSelection, true);
120 | selection.cursor = textCursor();
121 | selection.cursor.clearSelection();
122 | extraSelections.append(selection);
123 | }
124 |
125 | setExtraSelections(extraSelections);
126 | }
127 |
128 |
129 |
130 | void TextEditor::lineNumberAreaPaintEvent(QPaintEvent *event)
131 | {
132 | QPainter painter(lineNumberArea);
133 | // painter.fillRect(event->rect(), Qt::black);
134 |
135 |
136 | QTextBlock block = firstVisibleBlock();
137 | int blockNumber = block.blockNumber();
138 | int top = (int) blockBoundingGeometry(block).translated(contentOffset()).top();
139 | int bottom = top + (int) blockBoundingRect(block).height();
140 |
141 | while (block.isValid() && top <= event->rect().bottom()) {
142 | if (block.isVisible() && bottom >= event->rect().top()) {
143 | QString number = QString::number(blockNumber + 1);
144 | painter.setPen(Qt::darkGray);
145 | painter.drawText(0, top, lineNumberArea->width(), fontMetrics().height(),
146 | Qt::AlignRight, number);
147 | }
148 |
149 | block = block.next();
150 | top = bottom;
151 | bottom = top + (int) blockBoundingRect(block).height();
152 | ++blockNumber;
153 | }
154 | }
155 |
156 | void TextEditor::resetTimer()
157 | {
158 | m_timer->start();
159 | m_autoUpdate = true;
160 | }
161 |
162 | void TextEditor::updateShader()
163 | {
164 | if( m_autoUpdate )
165 | {
166 | emit shaderUpdate( this->toPlainText(), m_id);
167 | m_autoUpdate = false;
168 | }
169 | }
170 |
171 |
--------------------------------------------------------------------------------
/SceneEditor/texteditor.h:
--------------------------------------------------------------------------------
1 | #ifndef TEXTEDITOR_H
2 | #define TEXTEDITOR_H
3 |
4 | #include
5 | #include
6 |
7 | class QPaintEvent;
8 | class QResizeEvent;
9 | class QSize;
10 | class QWidget;
11 |
12 | class LineNumberArea;
13 | class Highlighter;
14 |
15 | class TextEditor : public QPlainTextEdit
16 | {
17 | Q_OBJECT
18 |
19 | public:
20 | TextEditor(QWidget *parent = 0);
21 |
22 | void lineNumberAreaPaintEvent(QPaintEvent *event);
23 | int lineNumberAreaWidth();
24 | void open( QString filename, int id );
25 | void save();
26 | signals:
27 | void shaderUpdate(QString,int);
28 | void reload();
29 | protected:
30 | void resizeEvent(QResizeEvent *event);
31 |
32 | private slots:
33 | void updateLineNumberAreaWidth(int newBlockCount);
34 | void highlightCurrentLine();
35 | void updateLineNumberArea(const QRect &, int);
36 | void resetTimer();
37 | void updateShader();
38 |
39 | private:
40 | QString colorSyntax(QString in);
41 | QWidget *lineNumberArea;
42 | QString m_filename;
43 | Highlighter *m_highlighter;
44 | int m_id;
45 | QTimer *m_timer;
46 | bool m_autoUpdate;
47 | };
48 |
49 |
50 | class LineNumberArea : public QWidget
51 | {
52 | public:
53 | LineNumberArea(TextEditor *editor) : QWidget(editor) {
54 | codeEditor = editor;
55 | }
56 |
57 | QSize sizeHint() const {
58 | return QSize(codeEditor->lineNumberAreaWidth(), 0);
59 | }
60 |
61 | protected:
62 | void paintEvent(QPaintEvent *event) {
63 | codeEditor->lineNumberAreaPaintEvent(event);
64 | }
65 |
66 | private:
67 | TextEditor *codeEditor;
68 | };
69 |
70 |
71 | #endif // TEXTEDITOR_H
72 |
--------------------------------------------------------------------------------
/SceneEditor/texture.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include "texture.h"
9 |
10 | Texture::Texture()
11 | {
12 | m_id=-1;
13 | }
14 | Texture::~Texture()
15 | {
16 | glDeleteTextures( 1, &m_id );
17 | }
18 |
19 | void Texture::bind()
20 | {
21 | glBindTexture(GL_TEXTURE_2D, m_id);
22 | }
23 |
24 | void Texture::load(const std::string &path)
25 | {
26 | if(m_id != -1)
27 | glDeleteTextures( 1, &m_id );
28 |
29 | QImage t;
30 | QImage b;
31 |
32 | if( !b.load( path.c_str() ) )
33 | {
34 | QMessageBox::critical(NULL, "Error", QString(QString("Can't load image ")+path.c_str()) );
35 | }
36 | t = QGLWidget::convertToGLFormat( b );
37 |
38 |
39 | glGenTextures( 1, &m_id );
40 | glBindTexture( GL_TEXTURE_2D, m_id );
41 | glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, GL_TRUE);
42 | glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR);
43 | glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
44 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
45 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
46 | glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, t.width(), t.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, t.bits() );
47 | }
48 |
--------------------------------------------------------------------------------
/SceneEditor/texture.h:
--------------------------------------------------------------------------------
1 | #ifndef TEXTURE_H
2 | #define TEXTURE_H
3 |
4 | #include
5 | #include
6 |
7 |
8 | class Texture
9 | {
10 | public:
11 | Texture();
12 | ~Texture();
13 |
14 | void load(const std::string &path);
15 | virtual void bind();
16 | private:
17 | GLuint m_id;
18 | };
19 |
20 | #endif // TEXTURE_H
21 |
--------------------------------------------------------------------------------
/VisualLiveSystem/FFTAnalyzer.h:
--------------------------------------------------------------------------------
1 | #ifndef FFTANALYZER_H
2 | #define FFTANALYZER_H
3 |
4 |
5 | #include
6 | #include
7 | #include
8 | #include
9 | #define _USE_MATH_DEFINES
10 | #include
11 |
12 | enum FFTDirection
13 | {
14 | FFT_FORWARD = 0,
15 | FFT_REVERSE = 1
16 | };
17 |
18 |
19 | class Window
20 | {
21 | public:
22 | enum Type
23 | {
24 | TYPE_RECT,
25 | TYPE_HANN
26 | };
27 |
28 | static void generate(Type type, size_t N, float out[]);
29 | static double eval(Type type, size_t n, size_t N);
30 | };
31 |
32 |
33 |
34 | // Send Short term FFT data to a listener.
35 | // Variable overlap.
36 | // Introduced approx. windowSize/2 samples delay.
37 | class FFTAnalyzer
38 | {
39 | public:
40 |
41 | // if zeroPhaseWindowing = true, "zero phase" windowing is used
42 | // (center of window is at first sample, zero-padding happen at center)
43 | FFTAnalyzer(Window::Type windowType, bool zeroPhaseWindowing, bool correctWindowLoss);
44 |
45 | size_t windowSize() const;
46 | size_t analysisPeriod() const;
47 |
48 | // To call at initialization and whenever samplerate changes
49 | // windowSize = size of analysis window, expressed in samples
50 | // fftSize = size of FFT. Must be power-of-two and >= windowSize. Missing samples are zero-padded in time domain.
51 | // analysisPeriod = period of analysis results, allow to be more precise frequentially, expressed in samples
52 | // Basic overlap is achieved with windowSize = 2 * analysisPeriod
53 | void setup(size_t windowSize, size_t fftSize, size_t analysisPeriod);
54 |
55 | // Process one sample, eventually return the result of short-term FFT
56 | // in a given Buffer
57 | bool feed(float x, std::vector< std::complex >* fftData);
58 |
59 |
60 | //Copy/Paste a buffer table
61 | bool pushStereoBuffer(float* buffer , unsigned int size , std::vector< std::complex >* fftData);
62 |
63 | private:
64 | std::vector _audioBuffer;
65 | std::vector _windowBuffer;
66 |
67 | size_t _fftSize; // in samples
68 | size_t _windowSize; // in samples
69 | size_t _analysisPeriod; // in samples
70 |
71 | Window::Type _windowType;
72 | bool _zeroPhaseWindowing;
73 |
74 | size_t _index;
75 | bool _setupWasCalled;
76 |
77 | // should we multiply by _windowGainCorrFactor?
78 | bool _correctWindowLoss;
79 | // the factor by which to multiply transformed data to get in range results
80 | float _windowGainCorrFactor;
81 | };
82 |
83 | #endif // FFTANALYZER_H
84 |
--------------------------------------------------------------------------------
/VisualLiveSystem/VisualLiveSystem.pro:
--------------------------------------------------------------------------------
1 | #-------------------------------------------------
2 | #
3 | # Project created by QtCreator 2013-07-12T18:33:16
4 | #
5 | #-------------------------------------------------
6 |
7 | QT += core gui opengl xml
8 |
9 | TARGET = VisualLiveSystem
10 | TEMPLATE = app
11 |
12 | RC_FILE = ressource.rc
13 |
14 | INCLUDEPATH += C:/Coding/Librarys/include
15 | LIBS += -LC:/Coding/Librarys/lib/32
16 |
17 | LIBS += -lrtaudio -lportmidi -lwinmm -lole32 -lGLEW32 -ldsound -lbass -lbassflac
18 | SOURCES += main.cpp\
19 | mainwindow.cpp \
20 | renderwidget.cpp \
21 | scene.cpp \
22 | shader.cpp \
23 | fast2dquad.cpp \
24 | fbo.cpp \
25 | channelwidget.cpp \
26 | visualmanager.cpp \
27 | core.cpp \
28 | masterwidget.cpp \
29 | glscene.cpp \
30 | projectorwidget.cpp \
31 | loadingwidget.cpp \
32 | texture.cpp \
33 | soundmanager.cpp \
34 | midiwindow.cpp \
35 | qmidisequencer.cpp \
36 | transition.cpp \
37 | FFTAnalyzer.cpp \
38 | audiovisualizer.cpp \
39 | signal/decoder.cpp \
40 | signal/signal.cpp \
41 | signal/basserrorhandler.cpp \
42 | signal/audiopipe.cpp \
43 | signal/fft.cpp
44 |
45 | HEADERS += mainwindow.h \
46 | renderwidget.h \
47 | scene.h \
48 | shader.h \
49 | fast2dquad.h \
50 | fbo.h \
51 | channelwidget.h \
52 | visualmanager.h \
53 | core.h \
54 | masterwidget.h \
55 | glscene.h \
56 | projectorwidget.h \
57 | loadingwidget.h \
58 | texture.h \
59 | soundmanager.h \
60 | midiwindow.h \
61 | qmidisequencer.h \
62 | transition.h \
63 | FFTAnalyzer.h \
64 | audiovisualizer.h \
65 | signal/bass.h \
66 | signal/bassflac.h \
67 | signal/decoder.hpp \
68 | signal/signal.hpp \
69 | signal/basserrorhandler.hpp \
70 | signal/audiopipe.hpp \
71 | signal/fft.hpp
72 |
73 | FORMS += mainwindow.ui \
74 | channelwidget.ui \
75 | visualmanager.ui \
76 | masterwidget.ui \
77 | loadingwidget.ui \
78 | midiwindow.ui \
79 | soundmanager.ui
80 |
81 | RESOURCES += \
82 | res.qrc \
83 | qdarkstyle/style.qrc
84 |
85 | OTHER_FILES += \
86 | res/shaders/open.glsl \
87 | res/shaders/postprocess.glsl
88 |
--------------------------------------------------------------------------------
/VisualLiveSystem/audiovisualizer.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | #include "core.h"
6 | #include "audiovisualizer.h"
7 | #include "core.h"
8 | #include "fast2dquad.h"
9 |
10 |
11 | AudioVisualizer::AudioVisualizer(QGLWidget *share, QWidget *parent) : QGLWidget(parent,share)
12 | {
13 | QTimer *timer = new QTimer(this);
14 | connect(timer, SIGNAL(timeout()), this, SLOT(updateGL()));
15 | timer->start(30);
16 | }
17 |
18 | AudioVisualizer::~AudioVisualizer()
19 | {
20 | delete m_shader;
21 | }
22 |
23 |
24 | //-----------------------------------------------------------------------------
25 | // initializeGL
26 | //-----------------------------------------------------------------------------
27 | void AudioVisualizer::initializeGL()
28 | {
29 | QFile f(":res/shaders/audiovisualizer.glsl");
30 | f.open(QFile::ReadOnly | QFile::Text);
31 | QTextStream ts(&f);
32 | m_shader = new Shader();
33 | m_shader->compil(Core::instance()->getVertexShader(), ts.readAll().toStdString().c_str());
34 | m_shader->enable();
35 | m_shader->sendi("spectrum", 0 );
36 | m_shader->disable();
37 | }
38 |
39 |
40 | //-----------------------------------------------------------------------------
41 | // paintGL
42 | //-----------------------------------------------------------------------------
43 | void AudioVisualizer::paintGL()
44 | {
45 | m_shader->enable();
46 | m_shader->sendf("bassCutoff", (float)Core::instance()->bassCutoff / (float) Core::instance()->pow2Size );
47 | Core::instance()->bindTextureSpectrum();
48 | Fast2DQuadDraw();
49 | m_shader->disable();
50 |
51 | }
52 |
53 | //-----------------------------------------------------------------------------
54 | // resizeGL
55 | //-----------------------------------------------------------------------------
56 | void AudioVisualizer::resizeGL(int width, int height)
57 | {
58 | glViewport(0,0,width,height);
59 | }
60 |
61 |
--------------------------------------------------------------------------------
/VisualLiveSystem/audiovisualizer.h:
--------------------------------------------------------------------------------
1 | #ifndef AUDIOVISUALIZER_H
2 | #define AUDIOVISUALIZER_H
3 |
4 | #include "shader.h"
5 | #include
6 | #include
7 | #include
8 |
9 | class AudioVisualizer : public QGLWidget
10 | {
11 | public:
12 | AudioVisualizer(QGLWidget *share, QWidget *parent);
13 | ~AudioVisualizer();
14 |
15 | protected:
16 | void initializeGL();
17 | void paintGL();
18 | void resizeGL(int width, int height);
19 |
20 | private:
21 | Shader *m_shader;
22 | };
23 |
24 |
25 | #endif // AUDIOVISUALIZER_H
26 |
--------------------------------------------------------------------------------
/VisualLiveSystem/channelwidget.cpp:
--------------------------------------------------------------------------------
1 | #include "channelwidget.h"
2 | #include "ui_channelwidget.h"
3 | #include "glscene.h"
4 | #include "core.h"
5 |
6 |
7 | ChannelWidget::ChannelWidget(int id, QGLWidget *share, QWidget *parent) :
8 | QDockWidget(parent),
9 | ui(new Ui::ChannelWidget),
10 | m_id(id)
11 | {
12 | ui->setupUi(this);
13 | m_glscene = new GLScene(share,id,parent,m_id);
14 | m_scene = NULL;
15 |
16 | if(id==0)
17 | this->setWindowTitle( "Channel A");
18 | else
19 | this->setWindowTitle( "Channel B");
20 | ui->groupBox_3->layout()->addWidget(m_glscene);
21 |
22 | connect(ui->listWidget, SIGNAL(currentRowChanged(int)), this, SLOT(selectChanged(int)));
23 | connect(ui->CC0Bar, SIGNAL(valueChanged(int)), this, SLOT(CCChanged()));
24 | connect(ui->CC1Bar, SIGNAL(valueChanged(int)), this, SLOT(CCChanged()));
25 | connect(ui->CC2Bar, SIGNAL(valueChanged(int)), this, SLOT(CCChanged()));
26 | connect(ui->CC3Bar, SIGNAL(valueChanged(int)), this, SLOT(CCChanged()));
27 | }
28 |
29 | ChannelWidget::~ChannelWidget()
30 | {
31 | delete ui;
32 | }
33 |
34 | void ChannelWidget::updateList( QList list )
35 | {
36 | Core::instance()->getLoadingWidget()->show();
37 | ui->listWidget->clear();
38 | //Copy !
39 | if(list.size())
40 | {
41 | foreach(QListWidgetItem *i, list)
42 | {
43 | ui->listWidget->addItem(i->text());
44 | }
45 | }
46 |
47 | if(m_scene)
48 | {
49 | delete[] m_scene;
50 | m_scene = NULL;
51 | }
52 | if(!list.isEmpty())
53 | {
54 | m_scene = new Scene[list.size()];
55 | m_glscene->compilScenes(m_scene,list);
56 | selectChanged(0);
57 | }
58 | }
59 |
60 | void ChannelWidget::Switch()
61 | {
62 | if( Core::instance()->getCurrentChannel() == m_id && Core::instance()->inLive() )
63 | ui->listWidget->setEnabled(false);
64 | else
65 | ui->listWidget->setEnabled(true);
66 | }
67 |
68 | void ChannelWidget::selectChanged(int a)
69 | {
70 | if(m_id == Core::instance()->getCurrentChannel() && Core::instance()->inLive())
71 | return;
72 |
73 | if( Core::instance()->getLoadingWidget()->isHidden() )
74 | {
75 | m_glscene->setCurrent(a);
76 | m_scene[a].resetTime();
77 | ui->param0Label->setText( m_scene[a].getParamName(0) );
78 | ui->param1Label->setText( m_scene[a].getParamName(1) );
79 | ui->param2Label->setText( m_scene[a].getParamName(2) );
80 | ui->param3Label->setText( m_scene[a].getParamName(3) );
81 | }
82 | }
83 |
84 | void ChannelWidget::CCChanged(int id, float v)
85 | {
86 | if(id == 0)
87 | {
88 | ui->CC0Bar->setValue((int)(v));
89 | Core::instance()->setCC(m_id,0,float(v)/100.f);
90 | }
91 | else if(id == 1)
92 | {
93 | ui->CC1Bar->setValue((int)(v));
94 | Core::instance()->setCC(m_id,1,float(v)/100.f);
95 | }
96 | else if(id == 2)
97 | {
98 | ui->CC2Bar->setValue((int)(v));
99 | Core::instance()->setCC(m_id,2,float(v)/100.f);
100 | }
101 | else if(id == 3)
102 | {
103 | ui->CC3Bar->setValue((int)(v));
104 | Core::instance()->setCC(m_id,3,float(v)/100.f);
105 | }
106 | }
107 |
108 | void ChannelWidget::CCChanged()
109 | {
110 |
111 | Core::instance()->setCC(m_id,0,float(ui->CC0Bar->value())/100.f);
112 | Core::instance()->setCC(m_id,1,float(ui->CC1Bar->value())/100.f);
113 | Core::instance()->setCC(m_id,2,float(ui->CC2Bar->value())/100.f);
114 | Core::instance()->setCC(m_id,3,float(ui->CC3Bar->value())/100.f);
115 | }
116 |
117 | void ChannelWidget::sceneUp()
118 | {
119 | if( ( Core::instance()->getCurrentChannel() != m_id && Core::instance()->inLive() ) || !Core::instance()->inLive() )
120 | {
121 | int n = (ui->listWidget->currentRow()+1)%ui->listWidget->count();
122 | ui->listWidget->setCurrentRow(n);
123 | }
124 |
125 | }
126 |
127 | void ChannelWidget::sceneDown()
128 | {
129 |
130 | if( ( Core::instance()->getCurrentChannel() != m_id && Core::instance()->inLive() ) || !Core::instance()->inLive() )
131 | {
132 | int n = ui->listWidget->currentRow()-1;
133 | if(n == -1)
134 | n = ui->listWidget->count()-1;
135 | ui->listWidget->setCurrentRow(n);
136 | }
137 | }
138 |
--------------------------------------------------------------------------------
/VisualLiveSystem/channelwidget.h:
--------------------------------------------------------------------------------
1 | #ifndef CHANNELWIDGET_H
2 | #define CHANNELWIDGET_H
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include "scene.h"
9 |
10 |
11 | class GLScene;
12 |
13 | namespace Ui {
14 | class ChannelWidget;
15 | }
16 |
17 | class ChannelWidget : public QDockWidget
18 | {
19 | Q_OBJECT
20 |
21 | public:
22 | explicit ChannelWidget(int id, QGLWidget *share = 0, QWidget *parent = 0);
23 | ~ChannelWidget();
24 | public slots:
25 | void updateList( QList list );
26 | void selectChanged(int);
27 | void CCChanged(int, float);
28 | void CCChanged();
29 | void sceneUp();
30 | void sceneDown();
31 | void Switch();
32 | private:
33 | Ui::ChannelWidget *ui;
34 | int m_id;
35 | GLScene *m_glscene;
36 | Scene *m_scene;
37 | };
38 |
39 | #endif // CHANNELWIDGET_H
40 |
--------------------------------------------------------------------------------
/VisualLiveSystem/channelwidget.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | ChannelWidget
4 |
5 |
6 |
7 | 0
8 | 0
9 | 342
10 | 633
11 |
12 |
13 |
14 | Channel
15 |
16 |
17 |
18 | -
19 |
20 |
21 | Scenes
22 |
23 |
24 |
-
25 |
26 |
27 |
28 |
29 |
30 | -
31 |
32 |
33 |
34 | 256
35 | 180
36 |
37 |
38 |
39 | Preview
40 |
41 |
42 |
-
43 |
44 |
45 | 7
46 |
47 |
48 |
49 |
50 |
51 |
52 | -
53 |
54 |
55 | Faders
56 |
57 |
58 |
-
59 |
60 |
-
61 |
62 |
63 | 0 :
64 |
65 |
66 |
67 | -
68 |
69 |
70 | 0
71 |
72 |
73 | 100
74 |
75 |
76 | 0
77 |
78 |
79 | Qt::Horizontal
80 |
81 |
82 |
83 |
84 |
85 | -
86 |
87 |
-
88 |
89 |
90 | 1 :
91 |
92 |
93 |
94 | -
95 |
96 |
97 | 100
98 |
99 |
100 | 0
101 |
102 |
103 | Qt::Horizontal
104 |
105 |
106 |
107 |
108 |
109 | -
110 |
111 |
-
112 |
113 |
114 | 2 :
115 |
116 |
117 |
118 | -
119 |
120 |
121 | 100
122 |
123 |
124 | 0
125 |
126 |
127 | Qt::Horizontal
128 |
129 |
130 |
131 |
132 |
133 | -
134 |
135 |
-
136 |
137 |
138 | 3 :
139 |
140 |
141 |
142 | -
143 |
144 |
145 | 100
146 |
147 |
148 | 0
149 |
150 |
151 | Qt::Horizontal
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
--------------------------------------------------------------------------------
/VisualLiveSystem/core.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/XT95/VisualLiveSystem/e8b5b97718f294cf4d6fa001ff98e0e6d7cbcf74/VisualLiveSystem/core.cpp
--------------------------------------------------------------------------------
/VisualLiveSystem/core.h:
--------------------------------------------------------------------------------
1 | #ifndef DATA_H
2 | #define DATA_H
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 |
9 | #include "loadingwidget.h"
10 | #include "signal/audiopipe.hpp"
11 | #include "signal/decoder.hpp"
12 | #include "signal/fft.hpp"
13 |
14 | class Scene;
15 | class FBO;
16 |
17 | class Core : public QObject
18 | {
19 | Q_OBJECT
20 | public:
21 | //Singleton !
22 | static Core* instance();
23 | void initGL();
24 | void initAudio();
25 | void initWidgets();
26 |
27 | //Show !
28 | bool inLive() { return m_inLive; }
29 | void setBassMotion(float b) { m_bassMotion=b; }
30 | void setCC(int c, int id, float v);
31 | float getCC(int c, int id);
32 |
33 | //Transition
34 | void setCurrentTransition(int id);
35 | int getCurrentTransition();
36 |
37 | //Channel
38 | void Switch();
39 | int getCurrentChannel();
40 |
41 | //Rendering
42 | void setResolution(int x,int y);
43 | int getResX();
44 | int getResY();
45 | int getNoise3D();
46 |
47 | //FBO
48 | void setFBOChan(FBO *fbo, int n);
49 | FBO* getFBOChan(int n);
50 | void setFBOFinal(FBO *fbo);
51 | FBO* getFBOFinal();
52 |
53 | //Spectrum & Time
54 | void bindTextureSpectrum();
55 | void setBass(float bass);
56 | void setTimeSpeed(float t);
57 | void setBassTimeSpeed(float t);
58 | void resetBassTime();
59 | void setNoise(float n);
60 | float getTimeSpeed();
61 | float getBassTimeSpeed();
62 | float getBass();
63 | float getBassTime();
64 | float getNoiseLvl();
65 |
66 |
67 | //Utils
68 | Scene* getDefaultScene();
69 | const char* getVertexShader();
70 | LoadingWidget* getLoadingWidget();
71 |
72 | //Audio
73 | unsigned int bassCutoff;
74 | AudioPipe* audioPipe;
75 | Decoder* decoder;
76 | PlaylistMixer* mixer;
77 | FFT* fft;
78 | VisualSignal* visualSignal;
79 | unsigned int pow2Size;
80 |
81 |
82 | void setPow2Size(unsigned int s);
83 |
84 |
85 | //Infos
86 | int infoChannelA,infoChannelB,infoPostFX,infoFPS,infoSound;
87 |
88 | //Settings
89 | QSettings settings;
90 |
91 |
92 | signals:
93 | void resolutionChanged(int,int);
94 | void channelSwitched();
95 | void pow2Changed(unsigned int);
96 |
97 | public slots:
98 | void liveChanged(bool);
99 |
100 | private:
101 | Core();
102 |
103 | static Core *m_instance;
104 | Scene *m_defaultScene;
105 | int m_currentChannel;
106 | int m_resX,m_resY;
107 | FBO *m_fboChan[2];
108 | FBO *m_fboFinal;
109 | GLuint m_spectrum;
110 | GLuint m_noise3D;
111 |
112 | LoadingWidget *m_loadingw;
113 | float m_bass,m_bassTime, m_timeSpeed, m_bassTimeSpeed, m_bassMotion, m_noiseLvl;
114 | bool m_inLive;
115 | float m_cc[2][4];
116 | int m_transition;
117 |
118 | };
119 |
120 | #endif // DATA_H
121 |
--------------------------------------------------------------------------------
/VisualLiveSystem/fast2dquad.cpp:
--------------------------------------------------------------------------------
1 |
2 | #include
3 |
4 |
5 |
6 | #define BUFFER_OFFSET(a) ((char*)NULL + (a))
7 | struct vec2
8 | {
9 | float x,y;
10 | };
11 |
12 | static GLuint vbo;
13 |
14 | void Fast2DQuadInit(void)
15 | {
16 | vec2 point[4];
17 | point[0].x =-1.0f; point[1].x = 1.0f; point[2].x =-1.0f; point[3].x = 1.0f;
18 | point[0].y =-1.0f; point[1].y =-1.0f; point[2].y = 1.0f; point[3].y = 1.0f;
19 | vec2 uv[4];
20 | uv[0].x = 0.0f; uv[1].x = 1.0f; uv[2].x = 0.0f; uv[3].x = 1.0f;
21 | uv[0].y = 0.0f; uv[1].y = 0.0f; uv[2].y = 1.0f; uv[3].y = 1.0f;
22 |
23 |
24 | //make the vertex buffer object
25 | glGenBuffers(1, &vbo);
26 | glBindBuffer(GL_ARRAY_BUFFER, vbo);
27 | glBufferData(GL_ARRAY_BUFFER, 4*2*sizeof(float)*2, NULL, GL_STATIC_DRAW);
28 | glBufferSubData(GL_ARRAY_BUFFER, 0, 4*2*sizeof(float), point);
29 | glBufferSubData(GL_ARRAY_BUFFER, 4*2*sizeof(float), 4*2*sizeof(float), uv);
30 | glBindBuffer(GL_ARRAY_BUFFER, 0);
31 |
32 | }
33 |
34 |
35 | void Fast2DQuadDraw(void)
36 | {
37 | glBindBuffer(GL_ARRAY_BUFFER, vbo);
38 | glVertexPointer(2, GL_FLOAT, 0, BUFFER_OFFSET(0));
39 | glTexCoordPointer(2, GL_FLOAT, 0, BUFFER_OFFSET(4*2*sizeof(float)));
40 | glEnableClientState(GL_VERTEX_ARRAY);
41 | glEnableClientState(GL_TEXTURE_COORD_ARRAY);
42 | glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
43 | glDisableClientState(GL_TEXTURE_COORD_ARRAY);
44 | glDisableClientState(GL_VERTEX_ARRAY);
45 | glBindBuffer(GL_ARRAY_BUFFER, 0);
46 | }
47 |
48 |
49 | void Fast2DQuadFree(void)
50 | {
51 | glDeleteBuffers(1,&vbo);
52 | }
53 |
--------------------------------------------------------------------------------
/VisualLiveSystem/fast2dquad.h:
--------------------------------------------------------------------------------
1 | #ifndef DEF_FAST2DQUAD
2 | #define DEF_FAST2DQUAD
3 |
4 |
5 |
6 | void Fast2DQuadInit(void);
7 | void Fast2DQuadDraw(void);
8 | void Fast2DQuadFree(void);
9 |
10 |
11 |
12 | #endif
13 |
--------------------------------------------------------------------------------
/VisualLiveSystem/fbo.cpp:
--------------------------------------------------------------------------------
1 | #include "fbo.h"
2 |
3 |
4 |
5 | //-----------------------------------------------------------------------------
6 | // Constructor
7 | //-----------------------------------------------------------------------------
8 | FBO::FBO()
9 | {
10 | m_FrameBuffer=0;
11 | m_ColorTextureID=0;
12 | m_width = 1280;
13 | m_height = 720;
14 | m_format = GL_RGBA;
15 |
16 | //Create texture.
17 | glGenTextures(1, &m_ColorTextureID);
18 | glBindTexture(GL_TEXTURE_2D, m_ColorTextureID);
19 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
20 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
21 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
22 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
23 | glTexImage2D(GL_TEXTURE_2D, 0, m_format, m_width, m_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
24 | glBindTexture(GL_TEXTURE_2D, 0);
25 |
26 |
27 | //Make buffer
28 | glGenFramebuffers(1, &m_FrameBuffer);
29 | glBindFramebuffer(GL_FRAMEBUFFER_EXT, m_FrameBuffer);
30 |
31 |
32 | glFramebufferTexture2D(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, m_ColorTextureID, 0);
33 |
34 |
35 | glBindFramebuffer(GL_FRAMEBUFFER_EXT, 0);
36 |
37 | }
38 |
39 |
40 | //-----------------------------------------------------------------------------
41 | // Destructor
42 | //-----------------------------------------------------------------------------
43 | FBO::~FBO()
44 | {
45 | glDeleteTextures(1, &m_ColorTextureID);
46 | glDeleteFramebuffers(1, &m_FrameBuffer);
47 | }
48 |
49 |
50 | //-----------------------------------------------------------------------------
51 | // Enable
52 | //-----------------------------------------------------------------------------
53 | void FBO::enable(void)
54 | {
55 | glPushAttrib(GL_VIEWPORT_BIT);
56 | glViewport(0,0,m_width,m_height);
57 |
58 | glBindFramebuffer(GL_FRAMEBUFFER_EXT, m_FrameBuffer);
59 | glPushMatrix();
60 | }
61 |
62 | //-----------------------------------------------------------------------------
63 | // Disable
64 | //-----------------------------------------------------------------------------
65 | void FBO::disable(void)
66 | {
67 | glPopMatrix();
68 | glBindFramebuffer(GL_FRAMEBUFFER_EXT, 0);
69 | glPopAttrib();
70 | }
71 |
72 |
73 |
74 | //-----------------------------------------------------------------------------
75 | // Set
76 | //-----------------------------------------------------------------------------
77 | void FBO::setSize( int width, int height )
78 | {
79 | m_width = width;
80 | m_height = height;
81 |
82 |
83 | updateTexture();
84 | }
85 | void FBO::setFormat(GLint format)
86 | {
87 | m_format = format;
88 | updateTexture();
89 | }
90 |
91 |
92 | //-----------------------------------------------------------------------------
93 | // Get
94 | //-----------------------------------------------------------------------------
95 | GLuint FBO::getColor(void)
96 | {
97 | return m_ColorTextureID;
98 | }
99 |
100 | //-----------------------------------------------------------------------------
101 | // updateTexture
102 | //-----------------------------------------------------------------------------
103 | void FBO::updateTexture()
104 | {
105 | glBindTexture(GL_TEXTURE_2D, m_ColorTextureID);
106 | glTexImage2D(GL_TEXTURE_2D, 0, m_format, m_width, m_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
107 | glBindTexture(GL_TEXTURE_2D, 0);
108 |
109 |
110 | glBindFramebuffer(GL_FRAMEBUFFER_EXT, m_FrameBuffer);
111 | glFramebufferTexture2D(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, m_ColorTextureID, 0);
112 | glBindRenderbuffer(GL_RENDERBUFFER_EXT, 0);
113 |
114 |
115 |
116 | glBindFramebuffer(GL_FRAMEBUFFER_EXT, 0);
117 |
118 | }
119 |
120 | //-----------------------------------------------------------------------------
121 | // bind
122 | //-----------------------------------------------------------------------------
123 | void FBO::bind()
124 | {
125 | glBindTexture(GL_TEXTURE_2D, m_ColorTextureID);
126 | }
127 |
--------------------------------------------------------------------------------
/VisualLiveSystem/fbo.h:
--------------------------------------------------------------------------------
1 | #ifndef DEF_CORE_FBO_H
2 | #define DEF_CORE_FBO_H
3 |
4 | #include
5 | #include "texture.h"
6 |
7 | //-----------------------------------------------------------------------------
8 | // Class Frame Buffer Object
9 | //-----------------------------------------------------------------------------
10 | class FBO : public Texture
11 | {
12 | public:
13 | FBO();
14 | ~FBO();
15 |
16 | void enable(void);
17 | void disable(void);
18 |
19 |
20 | void setSize( int width, int height );
21 | void setFormat(GLint format);
22 |
23 | int getSizeX(){return m_width;}
24 | int getSizeY(){return m_height;}
25 | GLuint getColor(void);
26 | GLenum getFormat(){return m_format;}
27 |
28 | void bind();
29 | private:
30 | void updateTexture();
31 |
32 | GLuint m_FrameBuffer;
33 | GLuint m_ColorTextureID;
34 | int m_width,m_height;
35 | GLint m_format;
36 | };
37 |
38 |
39 | #endif
40 |
--------------------------------------------------------------------------------
/VisualLiveSystem/glscene.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include "core.h"
4 | #include "fast2dquad.h"
5 | #include "glscene.h"
6 |
7 |
8 | GLScene::GLScene(QGLWidget *share, int channel, QWidget *parent, bool chanID) :
9 | QGLWidget(parent,share),
10 | m_id(channel),
11 | m_chanID(chanID)
12 | {
13 | m_scene = NULL;
14 | m_selectID = 0;
15 | m_nbScene = 0;
16 |
17 | QTimer *timer = new QTimer(this);
18 | connect(timer, SIGNAL(timeout()), this, SLOT(updateGL()));
19 | timer->start(1);
20 |
21 | connect(Core::instance(), SIGNAL(resolutionChanged(int,int)), this, SLOT(resolutionChanged(int,int)));
22 | }
23 |
24 |
25 |
26 | //-----------------------------------------------------------------------------
27 | // compilScenes
28 | //-----------------------------------------------------------------------------
29 | void GLScene::compilScenes( Scene *scene, QList list )
30 | {
31 | makeCurrent();
32 | m_scene = scene;
33 | m_nbScene = list.size();
34 | LoadingWidget* loading = Core::instance()->getLoadingWidget();
35 | loading->setTitle(QString("Scenes..."));
36 | if(m_id == 0)
37 | {
38 | loading->set(0);
39 | }
40 | else
41 | loading->set(45);
42 |
43 | for(int i=0; iset(i*45/list.size());
47 | else
48 | loading->set(45+i*45/list.size());
49 | m_scene[i].setChannel(m_id);
50 | m_scene[i].read(list.at(i)->text().toStdString().c_str());
51 | }
52 | loading->hide();
53 | }
54 | void GLScene::setCurrent(int a)
55 | {
56 | m_selectID = a;
57 | }
58 |
59 | //-----------------------------------------------------------------------------
60 | // initializeGL
61 | //-----------------------------------------------------------------------------
62 | void GLScene::initializeGL()
63 | {
64 | m_rtt = new FBO();
65 | Core::instance()->setFBOChan(m_rtt,m_id);
66 | if(m_id == Core::instance()->getCurrentChannel())
67 | {
68 | m_rtt->setSize(Core::instance()->getResX(), Core::instance()->getResY());
69 | }
70 | else
71 | {
72 | m_rtt->setSize(Core::instance()->getResX()/6, Core::instance()->getResY()/6);
73 | }
74 | }
75 |
76 |
77 | //-----------------------------------------------------------------------------
78 | // paintGL
79 | //-----------------------------------------------------------------------------
80 | void GLScene::paintGL()
81 | {
82 | QTime time;
83 | time.restart();
84 |
85 | if(m_scene)
86 | {
87 | m_scene[m_selectID].compute();
88 | m_rtt->enable();
89 | m_scene[m_selectID].draw();
90 | m_rtt->disable();
91 | }
92 | else
93 | {
94 | Core::instance()->getDefaultScene()->compute();
95 | m_rtt->enable();
96 | Core::instance()->getDefaultScene()->draw();
97 | m_rtt->disable();
98 | }
99 | glViewport(0,0,m_w,m_h);
100 |
101 | glEnable(GL_TEXTURE_2D);
102 | glBindTexture(GL_TEXTURE_2D, m_rtt->getColor());
103 | Fast2DQuadDraw();
104 |
105 | glFlush();
106 | glFinish();
107 |
108 | if(m_chanID==0)
109 | Core::instance()->infoChannelA = time.elapsed();
110 | else
111 | Core::instance()->infoChannelB = time.elapsed();
112 | }
113 |
114 | //-----------------------------------------------------------------------------
115 | // resizeGL
116 | //-----------------------------------------------------------------------------
117 | void GLScene::resizeGL(int width, int height)
118 | {
119 | m_w = width;
120 | m_h = height;
121 | }
122 |
123 |
124 |
125 | void GLScene::resolutionChanged(int x,int y)
126 | {
127 | makeCurrent();
128 | if(m_id == Core::instance()->getCurrentChannel())
129 | {
130 | m_rtt->setSize(Core::instance()->getResX(), Core::instance()->getResY());
131 | for(int i=0; isetSize(Core::instance()->getResX()/8, Core::instance()->getResY()/8);
137 | for(int i=0; i
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include "scene.h"
10 | #include "fbo.h"
11 |
12 |
13 |
14 | //Mini widget de prévisu situé dans les channels widgets
15 | class GLScene : public QGLWidget
16 | {
17 | Q_OBJECT
18 | public:
19 | GLScene(QGLWidget *share, int channel, QWidget *parent, bool chanID);
20 |
21 | void compilScenes( Scene *scene, QList list );
22 | void setCurrent( int a );
23 |
24 | void initializeGL();
25 | void paintGL();
26 | void resizeGL(int width, int height);
27 |
28 | private slots:
29 | void resolutionChanged(int,int);
30 | private:
31 | QTime m_timer;
32 | int m_w,m_h, m_id;
33 |
34 | FBO *m_rtt;
35 | Scene *m_scene;
36 | int m_nbScene;
37 | int m_selectID;
38 | bool m_chanID;
39 | };
40 |
41 | #endif // GLSCENE_H
42 |
--------------------------------------------------------------------------------
/VisualLiveSystem/loadingwidget.cpp:
--------------------------------------------------------------------------------
1 | #include "loadingwidget.h"
2 | #include "ui_loadingwidget.h"
3 |
4 | LoadingWidget::LoadingWidget(QWidget *parent) :
5 | QWidget(parent),
6 | ui(new Ui::LoadingWidget)
7 | {
8 | ui->setupUi(this);
9 | }
10 |
11 | LoadingWidget::~LoadingWidget()
12 | {
13 | delete ui;
14 | }
15 |
16 | void LoadingWidget::set(int a)
17 | {
18 | ui->progressBar->setValue(a);
19 | }
20 |
21 | void LoadingWidget::setTitle(QString t)
22 | {
23 | ui->groupBox->setTitle(t);
24 | }
25 |
--------------------------------------------------------------------------------
/VisualLiveSystem/loadingwidget.h:
--------------------------------------------------------------------------------
1 | #ifndef LOADINGWIDGET_H
2 | #define LOADINGWIDGET_H
3 |
4 | #include
5 |
6 | namespace Ui {
7 | class LoadingWidget;
8 | }
9 |
10 | class LoadingWidget : public QWidget
11 | {
12 | Q_OBJECT
13 |
14 | public:
15 | explicit LoadingWidget(QWidget *parent = 0);
16 | ~LoadingWidget();
17 |
18 | void setTitle(QString t);
19 | void set(int a);
20 | private:
21 | Ui::LoadingWidget *ui;
22 | };
23 |
24 | #endif // LOADINGWIDGET_H
25 |
--------------------------------------------------------------------------------
/VisualLiveSystem/loadingwidget.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | LoadingWidget
4 |
5 |
6 | Qt::ApplicationModal
7 |
8 |
9 |
10 | 0
11 | 0
12 | 356
13 | 150
14 |
15 |
16 |
17 | Loading
18 |
19 |
20 |
21 | :/res/img/vls.png:/res/img/vls.png
22 |
23 |
24 | -
25 |
26 |
27 | Loading ....
28 |
29 |
30 |
-
31 |
32 |
33 | 0
34 |
35 |
36 |
37 | -
38 |
39 |
-
40 |
41 |
42 | Qt::Horizontal
43 |
44 |
45 |
46 | 40
47 | 20
48 |
49 |
50 |
51 |
52 | -
53 |
54 |
55 | false
56 |
57 |
58 | Cancel
59 |
60 |
61 | false
62 |
63 |
64 | false
65 |
66 |
67 |
68 | -
69 |
70 |
71 | Qt::Horizontal
72 |
73 |
74 |
75 | 40
76 | 20
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
--------------------------------------------------------------------------------
/VisualLiveSystem/main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include "mainwindow.h"
5 | #include "core.h"
6 |
7 | #include
8 | #include