summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2005-07-18 21:28:48 +0000
committerKenneth Russel <[email protected]>2005-07-18 21:28:48 +0000
commit9f3bf8307320cf80f67e0af707614f0304507731 (patch)
tree117f6338d05a00d4fe8687952e53a913bdab2568 /src
parent6f2bdbacf131b05937925fbfe32ac0b603ccbcc6 (diff)
Implemented pbuffer instantiation support in GLDrawableFactory rather
than GLCanvas on Windows. Restructured GLJPanel and jogl-demos to use new APIs. Still needs to be ported to other platforms. git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/../svn-server-sync/jogl-demos/branches/JSR-231@104 3298f667-5e0e-4b4a-8ed4-a3559d26a5f4
Diffstat (limited to 'src')
-rwxr-xr-xsrc/demos/hdr/HDR.java18
-rw-r--r--src/demos/hwShadowmapsSimple/HWShadowmapsSimple.java14
-rw-r--r--src/demos/proceduralTexturePhysics/Water.java15
3 files changed, 31 insertions, 16 deletions
diff --git a/src/demos/hdr/HDR.java b/src/demos/hdr/HDR.java
index 3bf1b49..b499515 100755
--- a/src/demos/hdr/HDR.java
+++ b/src/demos/hdr/HDR.java
@@ -249,15 +249,19 @@ public class HDR {
caps.setAlphaBits(floatAlphaBits);
caps.setDepthBits(floatDepthBits);
int[] tmp = new int[1];
- pbuffer = drawable.createOffscreenDrawable(caps, pbuffer_w, pbuffer_h);
+ if (!GLDrawableFactory.getFactory().canCreateGLPbuffer(caps, pbuffer_w, pbuffer_h)) {
+ unavailableExtension("Can not create pbuffer of size (" + pbuffer_w + ", " + pbuffer_h + ")");
+ }
+ GLContext parentContext = drawable.getContext();
+ pbuffer = GLDrawableFactory.getFactory().createGLPbuffer(caps, pbuffer_w, pbuffer_h, parentContext);
pbuffer.addGLEventListener(new PbufferListener());
gl.glGenTextures(1, tmp, 0);
pbuffer_tex = tmp[0];
- blur_pbuffer = drawable.createOffscreenDrawable(caps, blur_w, blur_h);
+ blur_pbuffer = GLDrawableFactory.getFactory().createGLPbuffer(caps, blur_w, blur_h, parentContext);
blur_pbuffer.addGLEventListener(new BlurPbufferListener());
gl.glGenTextures(1, tmp, 0);
blur_pbuffer_tex = tmp[0];
- blur2_pbuffer = drawable.createOffscreenDrawable(caps, blur_w, blur_h);
+ blur2_pbuffer = GLDrawableFactory.getFactory().createGLPbuffer(caps, blur_w, blur_h, parentContext);
blur2_pbuffer.addGLEventListener(new Blur2PbufferListener());
gl.glGenTextures(1, tmp, 0);
blur2_pbuffer_tex = tmp[0];
@@ -266,7 +270,7 @@ public class HDR {
caps.setGreenBits(8);
caps.setBlueBits(8);
caps.setDepthBits(24);
- tonemap_pbuffer = drawable.createOffscreenDrawable(caps, pbuffer_w, pbuffer_h);
+ tonemap_pbuffer = GLDrawableFactory.getFactory().createGLPbuffer(caps, pbuffer_w, pbuffer_h, parentContext);
tonemap_pbuffer.addGLEventListener(new TonemapPbufferListener());
gl.glGenTextures(1, tmp, 0);
tonemap_pbuffer_tex = tmp[0];
@@ -509,7 +513,7 @@ public class HDR {
class PbufferListener implements GLEventListener {
public void init(GLAutoDrawable drawable) {
- printThreadName("init for PbufferListener");
+ // printThreadName("init for PbufferListener");
// drawable.setGL(new DebugGL(drawable.getGL()));
@@ -700,7 +704,7 @@ public class HDR {
class BlurPbufferListener implements GLEventListener {
public void init(GLAutoDrawable drawable) {
- printThreadName("init for BlurPbufferListener");
+ // printThreadName("init for BlurPbufferListener");
// drawable.setGL(new DebugGL(drawable.getGL()));
@@ -733,7 +737,7 @@ public class HDR {
class Blur2PbufferListener implements GLEventListener {
public void init(GLAutoDrawable drawable) {
- printThreadName("init for Blur2PbufferListener");
+ // printThreadName("init for Blur2PbufferListener");
// drawable.setGL(new DebugGL(drawable.getGL()));
diff --git a/src/demos/hwShadowmapsSimple/HWShadowmapsSimple.java b/src/demos/hwShadowmapsSimple/HWShadowmapsSimple.java
index cd70062..a59b208 100644
--- a/src/demos/hwShadowmapsSimple/HWShadowmapsSimple.java
+++ b/src/demos/hwShadowmapsSimple/HWShadowmapsSimple.java
@@ -234,7 +234,11 @@ public class HWShadowmapsSimple {
// init pbuffer
GLCapabilities caps = new GLCapabilities();
caps.setDoubleBuffered(false);
- pbuffer = drawable.createOffscreenDrawable(caps, TEX_SIZE, TEX_SIZE);
+
+ if (!GLDrawableFactory.getFactory().canCreateGLPbuffer(caps, TEX_SIZE, TEX_SIZE)) {
+ unavailableExtension("Can not create pbuffer");
+ }
+ pbuffer = GLDrawableFactory.getFactory().createGLPbuffer(caps, TEX_SIZE, TEX_SIZE, drawable.getContext());
pbuffer.addGLEventListener(new PbufferListener());
// Register the window with the ManipManager
@@ -344,11 +348,15 @@ public class HWShadowmapsSimple {
private void checkExtension(GL gl, String extensionName) {
if (!gl.isExtensionAvailable(extensionName)) {
String message = "Unable to initialize " + extensionName + " OpenGL extension";
- JOptionPane.showMessageDialog(null, message, "Unavailable extension", JOptionPane.ERROR_MESSAGE);
- throw new GLException(message);
+ unavailableExtension(message);
}
}
+ private void unavailableExtension(String message) {
+ JOptionPane.showMessageDialog(null, message, "Unavailable extension", JOptionPane.ERROR_MESSAGE);
+ throw new GLException(message);
+ }
+
private void dispatchKey(char k) {
switch (k) {
case 27:
diff --git a/src/demos/proceduralTexturePhysics/Water.java b/src/demos/proceduralTexturePhysics/Water.java
index 46d199a..f15fe37 100644
--- a/src/demos/proceduralTexturePhysics/Water.java
+++ b/src/demos/proceduralTexturePhysics/Water.java
@@ -194,14 +194,17 @@ public class Water {
// create the pbuffer. Will use this as an offscreen rendering buffer.
// it allows rendering a texture larger than our window.
- if (!parentWindow.canCreateOffscreenDrawable()) {
- throw new GLException("Parent window doesn't support creation of pbuffers");
- }
GLCapabilities caps = new GLCapabilities();
caps.setDoubleBuffered(false);
- pbuffer = parentWindow.createOffscreenDrawable(caps,
- initialMapDimensions[0],
- initialMapDimensions[1]);
+ if (!GLDrawableFactory.getFactory().canCreateGLPbuffer(caps,
+ initialMapDimensions[0],
+ initialMapDimensions[1])) {
+ throw new GLException("Pbuffers not supported with this graphics card");
+ }
+ pbuffer = GLDrawableFactory.getFactory().createGLPbuffer(caps,
+ initialMapDimensions[0],
+ initialMapDimensions[1],
+ parentWindow.getContext());
pbuffer.addGLEventListener(new Listener());
}