|
Matthias@224
|
1 |
/* |
|
Matthias@224
|
2 |
* Copyright (c) 2008-2010, Matthias Mann |
|
Matthias@224
|
3 |
* |
|
Matthias@224
|
4 |
* All rights reserved. |
|
Matthias@224
|
5 |
* |
|
Matthias@224
|
6 |
* Redistribution and use in source and binary forms, with or without |
|
Matthias@224
|
7 |
* modification, are permitted provided that the following conditions are met: |
|
Matthias@224
|
8 |
* |
|
Matthias@224
|
9 |
* * Redistributions of source code must retain the above copyright notice, |
|
Matthias@224
|
10 |
* this list of conditions and the following disclaimer. |
|
Matthias@224
|
11 |
* * Redistributions in binary form must reproduce the above copyright |
|
Matthias@224
|
12 |
* notice, this list of conditions and the following disclaimer in the |
|
Matthias@224
|
13 |
* documentation and/or other materials provided with the distribution. |
|
Matthias@224
|
14 |
* * Neither the name of Matthias Mann nor the names of its contributors may |
|
Matthias@224
|
15 |
* be used to endorse or promote products derived from this software |
|
Matthias@224
|
16 |
* without specific prior written permission. |
|
Matthias@224
|
17 |
* |
|
Matthias@224
|
18 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
Matthias@224
|
19 |
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
Matthias@224
|
20 |
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|
Matthias@224
|
21 |
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
|
Matthias@224
|
22 |
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
|
Matthias@224
|
23 |
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
|
Matthias@224
|
24 |
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
|
Matthias@224
|
25 |
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
|
Matthias@224
|
26 |
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
|
Matthias@224
|
27 |
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
|
Matthias@224
|
28 |
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
Matthias@224
|
29 |
*/ |
|
Matthias@224
|
30 |
package nodes; |
|
Matthias@224
|
31 |
|
|
Matthias@224
|
32 |
import de.matthiasmann.twl.GUI; |
|
Matthias@224
|
33 |
import de.matthiasmann.twl.ScrollPane; |
|
Matthias@224
|
34 |
import de.matthiasmann.twl.renderer.lwjgl.LWJGLRenderer; |
|
Matthias@224
|
35 |
import de.matthiasmann.twl.theme.ThemeManager; |
|
Matthias@224
|
36 |
import org.lwjgl.opengl.Display; |
|
Matthias@224
|
37 |
import org.lwjgl.opengl.DisplayMode; |
|
Matthias@224
|
38 |
import org.lwjgl.opengl.GL11; |
|
Matthias@253
|
39 |
import test.TestUtils; |
|
Matthias@224
|
40 |
|
|
Matthias@224
|
41 |
/** |
|
Matthias@224
|
42 |
* @author Matthias Mann |
|
Matthias@224
|
43 |
*/ |
|
Matthias@224
|
44 |
public class NodeDemo { |
|
Matthias@224
|
45 |
|
|
Matthias@224
|
46 |
public static void main(String[] args) { |
|
Matthias@224
|
47 |
try { |
|
Matthias@225
|
48 |
Display.setDisplayMode(new DisplayMode(1024, 600)); |
|
Matthias@224
|
49 |
Display.create(); |
|
Matthias@224
|
50 |
Display.setTitle("TWL Node Demo"); |
|
Matthias@224
|
51 |
Display.setVSyncEnabled(true); |
|
Matthias@224
|
52 |
|
|
Matthias@224
|
53 |
NodeArea nodeArea = new NodeArea(); |
|
Matthias@224
|
54 |
ScrollPane scrollPane = new ScrollPane(nodeArea); |
|
Matthias@224
|
55 |
scrollPane.setExpandContentSize(true); |
|
Matthias@224
|
56 |
|
|
Matthias@224
|
57 |
LWJGLRenderer renderer = new LWJGLRenderer(); |
|
Matthias@230
|
58 |
//renderer.setUseQuadsForLines(true); |
|
Matthias@224
|
59 |
GUI gui = new GUI(scrollPane, renderer); |
|
Matthias@224
|
60 |
|
|
Matthias@224
|
61 |
ThemeManager theme = ThemeManager.createThemeManager( |
|
Matthias@224
|
62 |
NodeDemo.class.getResource("nodes.xml"), renderer); |
|
Matthias@224
|
63 |
gui.applyTheme(theme); |
|
Matthias@226
|
64 |
gui.update(); |
|
Matthias@226
|
65 |
|
|
Matthias@226
|
66 |
Node nodeSource = nodeArea.addNode("Source"); |
|
Matthias@226
|
67 |
nodeSource.setPosition(50, 50); |
|
Matthias@226
|
68 |
Pad nodeSourceColor = nodeSource.addPad("Color", false); |
|
Matthias@226
|
69 |
Pad nodeSourceAlpha = nodeSource.addPad("Alpha", false); |
|
Matthias@226
|
70 |
|
|
Matthias@226
|
71 |
Node nodeSink = nodeArea.addNode("Sink"); |
|
Matthias@226
|
72 |
nodeSink.setPosition(350, 200); |
|
Matthias@226
|
73 |
Pad nodeSinkColor = nodeSink.addPad("Color", true); |
|
Matthias@226
|
74 |
|
|
Matthias@226
|
75 |
nodeArea.addConnection(nodeSourceColor, nodeSinkColor); |
|
Matthias@224
|
76 |
|
|
Matthias@224
|
77 |
while(!Display.isCloseRequested()) { |
|
Matthias@224
|
78 |
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); |
|
Matthias@224
|
79 |
|
|
Matthias@224
|
80 |
gui.update(); |
|
Matthias@224
|
81 |
Display.update(); |
|
Matthias@224
|
82 |
} |
|
Matthias@224
|
83 |
|
|
Matthias@224
|
84 |
gui.destroy(); |
|
Matthias@224
|
85 |
theme.destroy(); |
|
Matthias@224
|
86 |
} catch (Exception ex) { |
|
Matthias@253
|
87 |
TestUtils.showErrMsg(ex); |
|
Matthias@224
|
88 |
} |
|
Matthias@224
|
89 |
Display.destroy(); |
|
Matthias@224
|
90 |
} |
|
Matthias@224
|
91 |
|
|
Matthias@224
|
92 |
} |