View | Details | Raw Unified | Return to bug 776
Collapse All | Expand All

(-)JOGLTabbedPaneUsage.java (-12 / +32 lines)
Lines 2-7 Link Here
2
 * Copyright (C) 2013 United States Government as represented by the Administrator of the
2
 * Copyright (C) 2013 United States Government as represented by the Administrator of the
3
 * National Aeronautics and Space Administration.
3
 * National Aeronautics and Space Administration.
4
 * All Rights Reserved.
4
 * All Rights Reserved.
5
 * 
6
 * Copyright (C) 2013 JogAmp Community. All rights reserved.
7
 *
8
 * If you guys send me code w/o further declaration it is
9
 * under the 'BSD License' !
5
 */
10
 */
6
11
7
// package gov.nasa.worldwindx.examples.multiwindow;
12
// package gov.nasa.worldwindx.examples.multiwindow;
Lines 18-24 Link Here
18
 * @author tag
23
 * @author tag
19
 * @version $Id$
24
 * @version $Id$
20
 */
25
 */
21
public class JOGLTabbedPaneUsage extends JFrame
26
public class JOGLTabbedPaneUsageFixed extends JFrame
22
{
27
{
23
    int[] bufferId;
28
    int[] bufferId;
24
29
Lines 28-34 Link Here
28
33
29
        public WWPanel(GLCanvas shareWith, int width, int height)
34
        public WWPanel(GLCanvas shareWith, int width, int height)
30
        {
35
        {
31
            canvas = shareWith != null ? new GLCanvas(getCaps(), shareWith.getContext()) : new GLCanvas();
36
            GLContext sharedCtx = shareWith != null ? shareWith.getContext() : null;
37
            System.err.println("XXX WWPanel: shareWith "+shareWith+", sharedCtx "+sharedCtx);
38
            canvas = new GLCanvas(getCaps(), sharedCtx); // same caps for 1st and 2nd shared ctx !
32
            canvas.setSize(new java.awt.Dimension(width, height));
39
            canvas.setSize(new java.awt.Dimension(width, height));
33
40
34
            setLayout(new BorderLayout(5, 5));
41
            setLayout(new BorderLayout(5, 5));
Lines 42-48 Link Here
42
        @Override
49
        @Override
43
        public void init(GLAutoDrawable glAutoDrawable)
50
        public void init(GLAutoDrawable glAutoDrawable)
44
        {
51
        {
45
//            glAutoDrawable.setGL(new DebugGL2(glAutoDrawable.getGL().getGL2()));
52
            if (bufferId == null) {
53
                makeVBO(glAutoDrawable);
54
                System.err.println("XXX Create Buffer "+bufferId[0]);
55
            } else {
56
                System.err.println("XXX Reuse Buffer "+bufferId[0]);
57
            }
46
        }
58
        }
47
59
48
        @Override
60
        @Override
Lines 53-61 Link Here
53
        @Override
65
        @Override
54
        public void display(GLAutoDrawable glAutoDrawable)
66
        public void display(GLAutoDrawable glAutoDrawable)
55
        {
67
        {
56
            if (bufferId == null)
57
                makeVBO(glAutoDrawable);
58
59
            drawFrame(glAutoDrawable);
68
            drawFrame(glAutoDrawable);
60
            glAutoDrawable.swapBuffers();
69
            glAutoDrawable.swapBuffers();
61
        }
70
        }
Lines 88-95 Link Here
88
            gl.glColor3f(1, 1, 1);
97
            gl.glColor3f(1, 1, 1);
89
98
90
            gl.glEnableClientState(GL2.GL_VERTEX_ARRAY);
99
            gl.glEnableClientState(GL2.GL_VERTEX_ARRAY);
91
            gl.glVertexPointer(3, GL2.GL_FLOAT, 0, 0);
100
            gl.glBindBuffer(GL2.GL_ARRAY_BUFFER, bufferId[0]); // 1st bind the VBO
92
            gl.glBindBuffer(GL2.GL_ARRAY_BUFFER, bufferId[0]);
101
            gl.glVertexPointer(3, GL2.GL_FLOAT, 0, 0);         // 2nd use it - duh!
93
            gl.glDrawArrays(GL2.GL_LINES, 0, 2);
102
            gl.glDrawArrays(GL2.GL_LINES, 0, 2);
94
103
95
            gl.glFlush();
104
            gl.glFlush();
Lines 110-129 Link Here
110
        gl.glBufferData(GL2.GL_ARRAY_BUFFER, vertices.capacity() * 4, vertices.rewind(), GL2.GL_STATIC_DRAW);
119
        gl.glBufferData(GL2.GL_ARRAY_BUFFER, vertices.capacity() * 4, vertices.rewind(), GL2.GL_STATIC_DRAW);
111
    }
120
    }
112
121
113
    public JOGLTabbedPaneUsage()
122
    public JOGLTabbedPaneUsageFixed()
114
    {
123
    {
115
        try
124
        try
116
        {
125
        {
126
            GLProfile.initSingleton(); // Lets have init debug messages above below marker
127
            System.err.println("XXX START DEMO XXX");
128
117
            // Create the application frame and the tabbed pane and add the pane to the frame.
129
            // Create the application frame and the tabbed pane and add the pane to the frame.
118
            JTabbedPane tabbedPanel = new JTabbedPane();
130
            JTabbedPane tabbedPanel = new JTabbedPane();
119
            this.add(tabbedPanel, BorderLayout.CENTER);
131
            this.add(tabbedPanel, BorderLayout.CENTER);
120
132
121
            // Create two World Windows that share resources.
133
            // Create two World Windows that share resources.
122
            WWPanel wwpA = new WWPanel(null, 600, 600);
134
            WWPanel wwpA = new WWPanel(null, 600, 600);
123
            WWPanel wwpB = new WWPanel(wwpA.canvas, wwpA.getWidth(), wwpA.getHeight());
135
            // ctx of wwpA is 'born' @ addNotify !
136
            // WWPanel wwpB = new WWPanel(wwpA.canvas, wwpA.getWidth(), wwpA.getHeight());
124
137
125
            tabbedPanel.add(wwpA, "Window A");
138
            tabbedPanel.add(wwpA, "Window A");
126
            tabbedPanel.add(wwpB, "Window B");
139
            // tabbedPanel.add(wwpB, "Window B");
127
140
128
            // Add the card panel to the frame.
141
            // Add the card panel to the frame.
129
            this.add(tabbedPanel, BorderLayout.CENTER);
142
            this.add(tabbedPanel, BorderLayout.CENTER);
Lines 133-139 Link Here
133
            setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
146
            setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
134
            pack();
147
            pack();
135
            setResizable(true);
148
            setResizable(true);
149
            System.err.println("XXX SetVisible XXX");
136
            setVisible(true);
150
            setVisible(true);
151
152
            // Now we shall be ready for wwpB - Assuming all sequential on EDT
153
            WWPanel wwpB = new WWPanel(wwpA.canvas, wwpA.getWidth(), wwpA.getHeight());
154
            tabbedPanel.add(wwpB, "Window B");
155
            pack();
156
            validate();
137
        }
157
        }
138
        catch (Exception e)
158
        catch (Exception e)
139
        {
159
        {
Lines 161-167 Link Here
161
        {
181
        {
162
            public void run()
182
            public void run()
163
            {
183
            {
164
                new JOGLTabbedPaneUsage();
184
                new JOGLTabbedPaneUsageFixed();
165
            }
185
            }
166
        });
186
        });
167
    }
187
    }

Return to bug 776