aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com/jogamp/opengl/impl/windows
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl/classes/com/jogamp/opengl/impl/windows')
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsBitmapWGLContext.java (renamed from src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsOffscreenWGLContext.java)6
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsBitmapWGLDrawable.java (renamed from src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java)6
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java13
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java80
4 files changed, 65 insertions, 40 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsOffscreenWGLContext.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsBitmapWGLContext.java
index 25d93b50e..7b769d971 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsOffscreenWGLContext.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsBitmapWGLContext.java
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010 JogAmp Community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -40,10 +41,9 @@
package com.jogamp.opengl.impl.windows.wgl;
import javax.media.opengl.*;
-import com.jogamp.opengl.impl.*;
-public class WindowsOffscreenWGLContext extends WindowsWGLContext {
- public WindowsOffscreenWGLContext(WindowsOffscreenWGLDrawable drawable,
+public class WindowsBitmapWGLContext extends WindowsWGLContext {
+ public WindowsBitmapWGLContext(WindowsBitmapWGLDrawable drawable,
GLContext shareWith) {
super(drawable, shareWith);
}
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsBitmapWGLDrawable.java
index 3452d3b55..0d360b339 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsOffscreenWGLDrawable.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsBitmapWGLDrawable.java
@@ -51,11 +51,11 @@ import com.jogamp.nativewindow.impl.windows.BITMAPINFOHEADER;
import com.jogamp.nativewindow.impl.windows.GDI;
import javax.media.opengl.GLCapabilitiesImmutable;
-public class WindowsOffscreenWGLDrawable extends WindowsWGLDrawable {
+public class WindowsBitmapWGLDrawable extends WindowsWGLDrawable {
private long origbitmap;
private long hbitmap;
- protected WindowsOffscreenWGLDrawable(GLDrawableFactory factory, NativeSurface target) {
+ protected WindowsBitmapWGLDrawable(GLDrawableFactory factory, NativeSurface target) {
super(factory, target, true);
create();
}
@@ -69,7 +69,7 @@ public class WindowsOffscreenWGLDrawable extends WindowsWGLDrawable {
}
public GLContext createContext(GLContext shareWith) {
- return new WindowsOffscreenWGLContext(this, shareWith);
+ return new WindowsBitmapWGLContext(this, shareWith);
}
private void create() {
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java
index 53badb25e..e85308371 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java
@@ -111,10 +111,15 @@ public class WindowsWGLContext extends GLContextImpl {
WindowsWGLDrawableFactory factory = (WindowsWGLDrawableFactory)drawable.getFactoryImpl();
AbstractGraphicsConfiguration config = drawable.getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration();
AbstractGraphicsDevice device = config.getScreen().getDevice();
- WindowsWGLDrawableFactory.SharedResource sr = factory.getOrCreateShared(device);
- if(null != sr) {
- wglMakeContextCurrentAvailable = factory.isReadDrawableAvailable(device);
- wglMakeContextCurrentInitialized=true;
+ switch( factory.isReadDrawableAvailable(device) ) {
+ case 1:
+ wglMakeContextCurrentAvailable = true;
+ wglMakeContextCurrentInitialized=true;
+ break;
+ case 0:
+ wglMakeContextCurrentAvailable = false;
+ wglMakeContextCurrentInitialized=true;
+ break;
}
}
return wglMakeContextCurrentAvailable;
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java
index 99e78b184..903e1af81 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java
@@ -69,6 +69,7 @@ import com.jogamp.opengl.impl.DesktopGLDynamicLookupHelper;
import com.jogamp.opengl.impl.GLDrawableFactoryImpl;
import com.jogamp.opengl.impl.GLDrawableImpl;
import com.jogamp.opengl.impl.GLDynamicLookupHelper;
+import javax.media.nativewindow.AbstractGraphicsConfiguration;
import javax.media.opengl.GLCapabilitiesImmutable;
public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl {
@@ -110,17 +111,21 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl {
}
static class SharedResource {
+ private WindowsGraphicsDevice device;
private WindowsDummyWGLDrawable drawable;
private WindowsWGLContext context;
private boolean canCreateGLPbuffer;
private boolean readDrawableAvailable;
- SharedResource(WindowsDummyWGLDrawable draw, WindowsWGLContext ctx, boolean readBufferAvail, boolean canPbuffer) {
+ SharedResource(WindowsGraphicsDevice dev, WindowsDummyWGLDrawable draw, WindowsWGLContext ctx,
+ boolean readBufferAvail, boolean canPbuffer) {
+ device = dev;
drawable = draw;
context = ctx;
canCreateGLPbuffer = canPbuffer;
readDrawableAvailable = readBufferAvail;
}
+ WindowsGraphicsDevice getDevice() { return device; }
WindowsWGLContext getContext() { return context; }
boolean canCreateGLPbuffer() { return canCreateGLPbuffer; }
boolean isReadDrawableAvailable() { return readDrawableAvailable; }
@@ -156,7 +161,7 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl {
final static String WGL_ARB_make_current_read = "WGL_ARB_make_current_read";
final static String wglMakeContextCurrent = "wglMakeContextCurrent";
- protected final SharedResource getOrCreateShared(AbstractGraphicsDevice device) {
+ private SharedResource getOrCreateShared(AbstractGraphicsDevice device) {
String connection = device.getConnection();
SharedResource sr;
synchronized(sharedMap) {
@@ -166,16 +171,19 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl {
addDeviceTried(connection);
NativeWindowFactory.getDefaultToolkitLock().lock(); // OK
try {
- WindowsDummyWGLDrawable sharedDrawable = WindowsDummyWGLDrawable.create(this, null);
+ WindowsGraphicsDevice sharedDevice = new WindowsGraphicsDevice(connection, AbstractGraphicsDevice.DEFAULT_UNIT);
+ GLProfile glp = GLProfile.getDefault(/*sharedDevice*/); // can't fetch device profile, which shared resource we create here
+ AbstractGraphicsScreen absScreen = new DefaultGraphicsScreen(sharedDevice, 0);
+ WindowsDummyWGLDrawable sharedDrawable = WindowsDummyWGLDrawable.create(this, glp, absScreen);
WindowsWGLContext ctx = (WindowsWGLContext) sharedDrawable.createContext(null);
ctx.makeCurrent();
boolean canCreateGLPbuffer = ctx.getGL().isExtensionAvailable(GL_ARB_pbuffer);
boolean readDrawableAvailable = ctx.isExtensionAvailable(WGL_ARB_make_current_read) &&
ctx.isFunctionAvailable(wglMakeContextCurrent);
ctx.release();
- sr = new SharedResource(sharedDrawable, ctx, readDrawableAvailable, canCreateGLPbuffer);
+ sr = new SharedResource(sharedDevice, sharedDrawable, ctx, readDrawableAvailable, canCreateGLPbuffer);
synchronized(sharedMap) {
- sharedMap.put(device.getConnection(), sr);
+ sharedMap.put(connection, sr);
}
if (DEBUG) {
System.err.println("!!! SharedContext: "+ctx+", pbuffer supported "+canCreateGLPbuffer+
@@ -199,6 +207,14 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl {
return null;
}
+ protected AbstractGraphicsDevice getOrCreateSharedDeviceImpl(AbstractGraphicsDevice device) {
+ SharedResource sr = getOrCreateShared(device);
+ if(null!=sr) {
+ return sr.getDevice();
+ }
+ return null;
+ }
+
protected final void shutdownInstance() {
if (DEBUG) {
Exception e = new Exception("Debug");
@@ -238,38 +254,22 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl {
return new WindowsOnscreenWGLDrawable(this, target);
}
- protected final GLDrawableImpl createOffscreenDrawableImpl(NativeSurface target) {
+ protected final GLDrawableImpl createOffscreenDrawableImpl(final NativeSurface target) {
if (target == null) {
throw new IllegalArgumentException("Null target");
}
- return new WindowsOffscreenWGLDrawable(this, target);
- }
-
- public final boolean isReadDrawableAvailable(AbstractGraphicsDevice device) {
- SharedResource sr = getOrCreateShared((null!=device)?device:defaultDevice);
- if(null!=sr) {
- return sr.isReadDrawableAvailable();
- }
- return false;
- }
-
- public final boolean canCreateGLPbuffer(AbstractGraphicsDevice device) {
- SharedResource sr = getOrCreateShared((null!=device)?device:defaultDevice);
- if(null!=sr) {
- return sr.canCreateGLPbuffer();
+ AbstractGraphicsConfiguration config = target.getGraphicsConfiguration().getNativeGraphicsConfiguration();
+ GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable) config.getChosenCapabilities();
+ if(!caps.isPBuffer()) {
+ return new WindowsBitmapWGLDrawable(this, target);
}
- return false;
- }
- protected final GLDrawableImpl createGLPbufferDrawableImpl(final NativeSurface target) {
- if (target == null) {
- throw new IllegalArgumentException("Null target");
- }
- final AbstractGraphicsDevice device = target.getGraphicsConfiguration().getNativeGraphicsConfiguration().getScreen().getDevice();
+ // PBuffer GLDrawable Creation
+ final AbstractGraphicsDevice device = config.getScreen().getDevice();
final SharedResource sr = getOrCreateShared(device);
if(null==sr) {
- return null;
+ throw new IllegalArgumentException("No shared resource for "+device);
}
final List returnList = new ArrayList();
Runnable r = new Runnable() {
@@ -298,7 +298,27 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl {
return (GLDrawableImpl) returnList.get(0);
}
- protected final NativeSurface createOffscreenSurfaceImpl(GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser, int width, int height) {
+ /**
+ * @return 1 if read drawable extension is available, 0 if not
+ * and -1 if undefined yet, ie no shared device exist at this point.
+ */
+ public final int isReadDrawableAvailable(AbstractGraphicsDevice device) {
+ SharedResource sr = getOrCreateShared((null!=device)?device:defaultDevice);
+ if(null!=sr) {
+ return sr.isReadDrawableAvailable() ? 1 : 0 ;
+ }
+ return -1; // undefined
+ }
+
+ public final boolean canCreateGLPbuffer(AbstractGraphicsDevice device) {
+ SharedResource sr = getOrCreateShared((null!=device)?device:defaultDevice);
+ if(null!=sr) {
+ return sr.canCreateGLPbuffer();
+ }
+ return false;
+ }
+
+ protected final NativeSurface createOffscreenSurfaceImpl(AbstractGraphicsDevice device,GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser, int width, int height) {
AbstractGraphicsScreen screen = DefaultGraphicsScreen.createDefault(NativeWindowFactory.TYPE_WINDOWS);
ProxySurface ns = new ProxySurface(WindowsWGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(
capsChosen, capsRequested, chooser, screen) );