Jogamp
Fix Window destroyNotify() -> QUIT
[users/sgothel/jake2.git] / src / jake2 / render / opengl / JoglDummyDriver.java
CommitLineData
78e90cd4
SG
1/*
2 * JoglDriver.java
3 * Copyright (C) 2004
4 *
5 */
6/*
7Copyright (C) 1997-2001 Id Software, Inc.
8
9This program is free software; you can redistribute it and/or
10modify it under the terms of the GNU General Public License
11as published by the Free Software Foundation; either version 2
12of the License, or (at your option) any later version.
13
14This program is distributed in the hope that it will be useful,
15but WITHOUT ANY WARRANTY; without even the implied warranty of
16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17
18See the GNU General Public License for more details.
19
20You should have received a copy of the GNU General Public License
21along with this program; if not, write to the Free Software
22Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23
24 */
25
26package jake2.render.opengl;
27
0d353c8b
SG
28import java.util.List;
29
78e90cd4
SG
30import jake2.qcommon.xcommand_t;
31import jake2.render.Base;
32
33import javax.media.nativewindow.util.Dimension;
34import javax.media.opengl.*;
35
5611eeb8 36import com.jogamp.newt.MonitorMode;
78e90cd4
SG
37
38/**
39 * JoglCommon
40 */
41public abstract class JoglDummyDriver extends DummyGL implements GLDriver {
42
43 protected static GLProfile glp = GLProfile.getGL2ES2(); // exception if n/a is desired
44
45 protected JoglDummyDriver() {
46 super();
47 // singleton
48 }
49
50 private NEWTWin newtWin = null;
51
52 public abstract String getName();
53
5611eeb8 54 public List<MonitorMode> getModeList() {
78e90cd4
SG
55 if(null == newtWin) {
56 throw new RuntimeException("NEWTWin not yet initialized.");
57 }
58 return newtWin.getModeList();
59 }
60
61 public int setMode(Dimension dim, int mode, boolean fullscreen) {
62 if(null == newtWin) {
63 newtWin = new NEWTWin();
64 }
65 int res = newtWin.setMode(glp, dim, mode, fullscreen, getName());
66 if( Base.rserr_ok == res ) {
78e90cd4
SG
67 init(0, 0);
68
69 return Base.rserr_ok;
70 }
71 return res;
72 }
73
74 public void shutdown() {
75 if(null != newtWin) {
76 newtWin.shutdown();
77 }
78 }
79
80 /**
81 * @return true
82 */
83 public boolean init(int xpos, int ypos) {
84 // clear the screen
85 // first buffer
86 beginFrame(0.0f);
87 glViewport(0, 0, newtWin.window.getWidth(), newtWin.window.getHeight());
88 glClearColor(0, 0, 0, 0);
89 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
90 endFrame();
91 // second buffer
92 beginFrame(0.0f);
93 glViewport(0, 0, newtWin.window.getWidth(), newtWin.window.getHeight());
94 glClearColor(0, 0, 0, 0);
95 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
96 endFrame();
97 return true;
98 }
99
100 public void beginFrame(float camera_separation) {
0d353c8b 101 activateGLContext();
78e90cd4
SG
102 }
103
104 public void endFrame() {
c15865e0
SG
105 newtWin.checkQuit();
106 // newtWin.swapBuffers();
0e0ab268 107 // deactivate();
78e90cd4
SG
108 }
109
110 public void appActivate(boolean activate) {
111 // do nothing
112 }
113
114 public void enableLogging(boolean enable) {
115 // do nothing
116 }
117
118 public void logNewFrame() {
119 // do nothing
120 }
121
122 /*
123 * @see jake2.client.refexport_t#updateScreen()
124 */
125 public void updateScreen(xcommand_t callback) {
126 callback.execute();
127 }
128
0d353c8b
SG
129 protected final void activateGLContext() {
130 newtWin.activateGLContext();
78e90cd4
SG
131 }
132
0d353c8b
SG
133 protected final void deactivateGLContext() {
134 newtWin.activateGLContext();
0e0ab268
SG
135 }
136
78e90cd4
SG
137 // --------------------------------------------------------------------------
138}
http://JogAmp.org git info: FAQ, tutorial and man pages.