New context stuff - complete for win32, incomplete for linux / mac
This commit is contained in:
parent
c50ded0d22
commit
9592f68c8e
Binary file not shown.
|
@ -177,7 +177,7 @@
|
|||
RelativePath="..\..\src\native\common\org_lwjgl_opengl_GL14.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\native\common\org_lwjgl_opengl_GLU.cpp">
|
||||
RelativePath="..\..\src\native\common\org_lwjgl_opengl_GL15.cpp">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
|
@ -201,6 +201,9 @@
|
|||
<File
|
||||
RelativePath="..\..\src\native\win32\org_lwjgl_input_Mouse.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\native\common\org_lwjgl_opengl_GLContext.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\native\win32\org_lwjgl_opengl_Pbuffer.cpp">
|
||||
</File>
|
||||
|
@ -218,157 +221,160 @@
|
|||
Name="arb"
|
||||
Filter="">
|
||||
<File
|
||||
RelativePath="..\..\src\native\common\arb\org_lwjgl_opengl_arb_ARBMatrixPalette.cpp">
|
||||
RelativePath="..\..\src\native\common\arb\org_lwjgl_opengl_ARBImaging.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\native\common\arb\org_lwjgl_opengl_arb_ARBMultisample.cpp">
|
||||
RelativePath="..\..\src\native\common\arb\org_lwjgl_opengl_ARBMatrixPalette.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\native\common\arb\org_lwjgl_opengl_arb_ARBMultitexture.cpp">
|
||||
RelativePath="..\..\src\native\common\arb\org_lwjgl_opengl_ARBMultisample.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\native\common\arb\org_lwjgl_opengl_arb_ARBOcclusionQuery.cpp">
|
||||
RelativePath="..\..\src\native\common\arb\org_lwjgl_opengl_ARBMultitexture.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\native\common\arb\org_lwjgl_opengl_arb_ARBPointParameters.cpp">
|
||||
RelativePath="..\..\src\native\common\arb\org_lwjgl_opengl_ARBOcclusionQuery.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\native\common\arb\org_lwjgl_opengl_arb_ARBProgram.cpp">
|
||||
RelativePath="..\..\src\native\common\arb\org_lwjgl_opengl_ARBPointParameters.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\native\common\arb\org_lwjgl_opengl_arb_ARBShaderObjects.cpp">
|
||||
RelativePath="..\..\src\native\common\arb\org_lwjgl_opengl_ARBProgram.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\native\common\arb\org_lwjgl_opengl_arb_ARBTextureCompression.cpp">
|
||||
RelativePath="..\..\src\native\common\arb\org_lwjgl_opengl_ARBShaderObjects.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\native\common\arb\org_lwjgl_opengl_arb_ARBTransposeMatrix.cpp">
|
||||
RelativePath="..\..\src\native\common\arb\org_lwjgl_opengl_ARBTextureCompression.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\native\common\arb\org_lwjgl_opengl_arb_ARBVertexBlend.cpp">
|
||||
RelativePath="..\..\src\native\common\arb\org_lwjgl_opengl_ARBTransposeMatrix.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\native\common\arb\org_lwjgl_opengl_arb_ARBVertexBufferObject.cpp">
|
||||
RelativePath="..\..\src\native\common\arb\org_lwjgl_opengl_ARBVertexBlend.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\native\common\arb\org_lwjgl_opengl_arb_ARBVertexProgram.cpp">
|
||||
RelativePath="..\..\src\native\common\arb\org_lwjgl_opengl_ARBVertexBufferObject.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\native\common\arb\org_lwjgl_opengl_arb_ARBVertexShader.cpp">
|
||||
RelativePath="..\..\src\native\common\arb\org_lwjgl_opengl_ARBVertexProgram.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\native\common\arb\org_lwjgl_opengl_arb_ARBWindowPos.cpp">
|
||||
RelativePath="..\..\src\native\common\arb\org_lwjgl_opengl_ARBVertexShader.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\native\common\arb\org_lwjgl_opengl_ARBWindowPos.cpp">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="ati"
|
||||
Filter="">
|
||||
<File
|
||||
RelativePath="..\..\src\native\common\ati\org_lwjgl_opengl_ati_ATIDrawBuffers.cpp">
|
||||
RelativePath="..\..\src\native\common\ati\org_lwjgl_opengl_ATIDrawBuffers.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\native\common\ati\org_lwjgl_opengl_ati_ATIElementArray.cpp">
|
||||
RelativePath="..\..\src\native\common\ati\org_lwjgl_opengl_ATIElementArray.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\native\common\ati\org_lwjgl_opengl_ati_ATIEnvmapBumpmap.cpp">
|
||||
RelativePath="..\..\src\native\common\ati\org_lwjgl_opengl_ATIEnvmapBumpmap.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\native\common\ati\org_lwjgl_opengl_ati_ATIFragmentShader.cpp">
|
||||
RelativePath="..\..\src\native\common\ati\org_lwjgl_opengl_ATIFragmentShader.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\native\common\ati\org_lwjgl_opengl_ati_ATIMapObjectBuffer.cpp">
|
||||
RelativePath="..\..\src\native\common\ati\org_lwjgl_opengl_ATIMapObjectBuffer.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\native\common\ati\org_lwjgl_opengl_ati_ATIPnTriangles.cpp">
|
||||
RelativePath="..\..\src\native\common\ati\org_lwjgl_opengl_ATIPnTriangles.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\native\common\ati\org_lwjgl_opengl_ati_ATISeparateStencil.cpp">
|
||||
RelativePath="..\..\src\native\common\ati\org_lwjgl_opengl_ATISeparateStencil.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\native\common\ati\org_lwjgl_opengl_ati_ATIVertexArrayObject.cpp">
|
||||
RelativePath="..\..\src\native\common\ati\org_lwjgl_opengl_ATIVertexArrayObject.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\native\common\ati\org_lwjgl_opengl_ati_ATIVertexAttribArrayObject.cpp">
|
||||
RelativePath="..\..\src\native\common\ati\org_lwjgl_opengl_ATIVertexAttribArrayObject.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\native\common\ati\org_lwjgl_opengl_ati_ATIVertexStreams.cpp">
|
||||
RelativePath="..\..\src\native\common\ati\org_lwjgl_opengl_ATIVertexStreams.cpp">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="ext"
|
||||
Filter="">
|
||||
<File
|
||||
RelativePath="..\..\src\native\common\ext\org_lwjgl_opengl_ext_EXTBlendFuncSeparate.cpp">
|
||||
RelativePath="..\..\src\native\common\ext\org_lwjgl_opengl_EXTBlendFuncSeparate.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\native\common\ext\org_lwjgl_opengl_ext_EXTCompiledVertexArray.cpp">
|
||||
RelativePath="..\..\src\native\common\ext\org_lwjgl_opengl_EXTCompiledVertexArray.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\native\common\ext\org_lwjgl_opengl_ext_EXTDrawRangeElements.cpp">
|
||||
RelativePath="..\..\src\native\common\ext\org_lwjgl_opengl_EXTDrawRangeElements.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\native\common\ext\org_lwjgl_opengl_ext_EXTFogCoord.cpp">
|
||||
RelativePath="..\..\src\native\common\ext\org_lwjgl_opengl_EXTFogCoord.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\native\common\ext\org_lwjgl_opengl_ext_EXTMultiDrawArrays.cpp">
|
||||
RelativePath="..\..\src\native\common\ext\org_lwjgl_opengl_EXTMultiDrawArrays.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\native\common\ext\org_lwjgl_opengl_ext_EXTPointParameters.cpp">
|
||||
RelativePath="..\..\src\native\common\ext\org_lwjgl_opengl_EXTPointParameters.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\native\common\ext\org_lwjgl_opengl_ext_EXTSecondaryColor.cpp">
|
||||
RelativePath="..\..\src\native\common\ext\org_lwjgl_opengl_EXTSecondaryColor.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\native\common\ext\org_lwjgl_opengl_ext_EXTStencilTwoSide.cpp">
|
||||
RelativePath="..\..\src\native\common\ext\org_lwjgl_opengl_EXTStencilTwoSide.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\native\common\ext\org_lwjgl_opengl_ext_EXTVertexShader.cpp">
|
||||
RelativePath="..\..\src\native\common\ext\org_lwjgl_opengl_EXTVertexShader.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\native\common\ext\org_lwjgl_opengl_ext_EXTVertexWeighting.cpp">
|
||||
RelativePath="..\..\src\native\common\ext\org_lwjgl_opengl_EXTVertexWeighting.cpp">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="nv"
|
||||
Filter="">
|
||||
<File
|
||||
RelativePath="..\..\src\native\common\nv\org_lwjgl_opengl_nv_NVEvaluators.cpp">
|
||||
RelativePath="..\..\src\native\common\nv\org_lwjgl_opengl_NVEvaluators.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\native\common\nv\org_lwjgl_opengl_nv_NVFence.cpp">
|
||||
RelativePath="..\..\src\native\common\nv\org_lwjgl_opengl_NVFence.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\native\common\nv\org_lwjgl_opengl_nv_NVFragmentProgram.cpp">
|
||||
RelativePath="..\..\src\native\common\nv\org_lwjgl_opengl_NVFragmentProgram.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\native\common\nv\org_lwjgl_opengl_nv_NVHalfFloat.cpp">
|
||||
RelativePath="..\..\src\native\common\nv\org_lwjgl_opengl_NVHalfFloat.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\native\common\nv\org_lwjgl_opengl_nv_NVOcclusionQuery.cpp">
|
||||
RelativePath="..\..\src\native\common\nv\org_lwjgl_opengl_NVOcclusionQuery.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\native\common\nv\org_lwjgl_opengl_nv_NVPixelDataRange.cpp">
|
||||
RelativePath="..\..\src\native\common\nv\org_lwjgl_opengl_NVPixelDataRange.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\native\common\nv\org_lwjgl_opengl_nv_NVPointSprite.cpp">
|
||||
RelativePath="..\..\src\native\common\nv\org_lwjgl_opengl_NVPointSprite.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\native\common\nv\org_lwjgl_opengl_nv_NVPrimitiveRestart.cpp">
|
||||
RelativePath="..\..\src\native\common\nv\org_lwjgl_opengl_NVPrimitiveRestart.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\native\common\nv\org_lwjgl_opengl_nv_NVProgram.cpp">
|
||||
RelativePath="..\..\src\native\common\nv\org_lwjgl_opengl_NVProgram.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\native\common\nv\org_lwjgl_opengl_nv_NVRegisterCombiners.cpp">
|
||||
RelativePath="..\..\src\native\common\nv\org_lwjgl_opengl_NVRegisterCombiners.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\native\common\nv\org_lwjgl_opengl_nv_NVRegisterCombiners2.cpp">
|
||||
RelativePath="..\..\src\native\common\nv\org_lwjgl_opengl_NVRegisterCombiners2.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\native\common\nv\org_lwjgl_opengl_nv_NVVertexArrayRange.cpp">
|
||||
RelativePath="..\..\src\native\common\nv\org_lwjgl_opengl_NVVertexArrayRange.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\native\common\nv\org_lwjgl_opengl_nv_NVVertexProgram.cpp">
|
||||
RelativePath="..\..\src\native\common\nv\org_lwjgl_opengl_NVVertexProgram.cpp">
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
|
|
|
@ -204,7 +204,7 @@ public final class Sys {
|
|||
*/
|
||||
public static void alert(String title, String message) {
|
||||
String osName = System.getProperty("os.name");
|
||||
if (osName.startsWith("Windoxws")) {
|
||||
if (osName.startsWith("Windows")) {
|
||||
nAlert(title, message);
|
||||
} else {
|
||||
try {
|
||||
|
|
|
@ -35,9 +35,7 @@ package org.lwjgl.opengl;
|
|||
import java.lang.ref.WeakReference;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.lwjgl.Sys;
|
||||
|
@ -56,13 +54,7 @@ public final class GLContext {
|
|||
|
||||
/** The currently initialised context */
|
||||
private static WeakReference currentContext;
|
||||
|
||||
/** A map of WeakReferences to contexts to LWJGL pointers-to-extension-structs */
|
||||
private static final Map contextMap = new HashMap();
|
||||
|
||||
/** A map of WeakReferences to contents to Sets of extension names */
|
||||
private static final Map extensionsMap = new HashMap();
|
||||
|
||||
|
||||
/*
|
||||
* Available extensions
|
||||
*/
|
||||
|
@ -212,7 +204,10 @@ public final class GLContext {
|
|||
* in the future, freeing up a little RAM.
|
||||
* @param context The context object, which uniquely identifies a GL context
|
||||
*/
|
||||
public static synchronized void setContext(Object context) {
|
||||
public static synchronized void useContext(Object context) {
|
||||
if (context == null) {
|
||||
throw new NullPointerException("Can't use a null context");
|
||||
}
|
||||
// Is this the same as last time?
|
||||
Object current = currentContext == null ? null : currentContext.get();
|
||||
if (current == context) {
|
||||
|
@ -222,35 +217,16 @@ public final class GLContext {
|
|||
|
||||
// Ok, now it's the current context.
|
||||
currentContext = new WeakReference(context);
|
||||
|
||||
// Look in the context map to see if we've encountered this context before
|
||||
Integer encountered = (Integer) contextMap.get(currentContext);
|
||||
Set exts;
|
||||
if (encountered != null) {
|
||||
exts = (Set) extensionsMap.get(currentContext);
|
||||
reinit(encountered.intValue());
|
||||
} else {
|
||||
exts = new HashSet();
|
||||
contextMap.put(currentContext, new Integer(init(exts)));
|
||||
}
|
||||
|
||||
HashSet exts = new HashSet();
|
||||
init(exts);
|
||||
determineAvailableExtensions(exts);
|
||||
|
||||
VBOTracker.setCurrent(currentContext);
|
||||
}
|
||||
|
||||
/**
|
||||
* Native method to initialize a context from scratch or load its function pointers from a
|
||||
* cache.
|
||||
* Native method to initialize a context
|
||||
* @param exts An empty Set of Strings that will be filled with the names of enabled extensions
|
||||
* @return a LWJGL context-index-pointer
|
||||
*/
|
||||
private static native int init(Set exts);
|
||||
|
||||
/**
|
||||
* Native method to re-initialize a context.
|
||||
* @param context Hash code of the context object
|
||||
*/
|
||||
private static native void reinit(int context);
|
||||
private static native void init(Set exts);
|
||||
|
||||
}
|
||||
|
|
|
@ -225,7 +225,7 @@ public final class Window {
|
|||
public static synchronized void makeCurrent() {
|
||||
assert isCreated() : "No window has been created.";
|
||||
nMakeCurrent();
|
||||
GLContext.setContext(context);
|
||||
GLContext.useContext(context);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -185,7 +185,7 @@ public final class Game {
|
|||
GL11.glMatrixMode(GL11.GL_MODELVIEW);
|
||||
GL11.glLoadIdentity();
|
||||
GL11.glViewport(0, 0, Display.getWidth(), Display.getHeight());
|
||||
ByteBuffer num_tex_units_buf = ByteBuffer.allocateDirect(4);
|
||||
ByteBuffer num_tex_units_buf = ByteBuffer.allocateDirect(64);
|
||||
num_tex_units_buf.order(ByteOrder.nativeOrder());
|
||||
GL11.glGetInteger(GL13.GL_MAX_TEXTURE_UNITS, num_tex_units_buf.asIntBuffer());
|
||||
System.out.println("Number of texture units: " + num_tex_units_buf.getInt());
|
||||
|
|
|
@ -81,7 +81,7 @@ public class Grass {
|
|||
mode = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mode == -1) {
|
||||
System.out.println("did not find suitable mode");
|
||||
|
|
|
@ -37,25 +37,12 @@
|
|||
/*
|
||||
* Class: org_lwjgl_opengl_GLContext
|
||||
* Method: init
|
||||
* Signature: (Ljava/util/Set;)I
|
||||
* Signature: (Ljava/util/Set;)V
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_GLContext_init
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GLContext_init
|
||||
(JNIEnv * env, jclass clazz, jobject exts)
|
||||
{
|
||||
if (!extgl_Initialize(env, exts)) {
|
||||
throwException(env, "Failed to initialize GL extensions");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_lwjgl_opengl_GLContext
|
||||
* Method: reinit
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GLContext_reinit
|
||||
(JNIEnv * env, jclass clazz, jint context)
|
||||
{
|
||||
}
|
|
@ -119,19 +119,11 @@ extern "C" {
|
|||
/*
|
||||
* Class: org_lwjgl_opengl_GLContext
|
||||
* Method: init
|
||||
* Signature: (Ljava/util/Set;)I
|
||||
* Signature: (Ljava/util/Set;)V
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_GLContext_init
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GLContext_init
|
||||
(JNIEnv *, jclass, jobject);
|
||||
|
||||
/*
|
||||
* Class: org_lwjgl_opengl_GLContext
|
||||
* Method: reinit
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GLContext_reinit
|
||||
(JNIEnv *, jclass, jint);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue