Don't ignore lying drivers

This commit is contained in:
Elias Naur 2003-09-26 13:59:50 +00:00
parent 1f0a6136b7
commit 42ad1026af
22 changed files with 604 additions and 1667 deletions

View file

@ -36,7 +36,8 @@ import org.lwjgl.Sys;
import java.lang.reflect.*;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.StringTokenizer;
import java.util.HashSet;
import java.util.Iterator;
/**
* $Id$
@ -137,7 +138,6 @@ public abstract class GLCaps {
public static boolean GL_SGIS_generate_mipmap;
public static boolean GL_SGIX_shadow;
public static boolean GL_SGIX_depth_texture;
public static boolean OpenGL10;
public static boolean OpenGL11;
public static boolean OpenGL12;
public static boolean OpenGL13;
@ -158,10 +158,13 @@ public abstract class GLCaps {
System.loadLibrary(Sys.getLibraryName());
}
private static void setExtensionFields(String exts, HashMap field_map) {
StringTokenizer st = new StringTokenizer(exts);
while (st.hasMoreTokens()) {
String ext = st.nextToken();
private static void setExtensionFields(HashSet exts, HashMap field_map) {
if(org.lwjgl.Sys.DEBUG) {
System.out.println("Available extensions:");
}
Iterator it = exts.iterator();
while (it.hasNext()) {
String ext = (String)it.next();
if(org.lwjgl.Sys.DEBUG) {
System.out.println(ext);
}
@ -182,8 +185,7 @@ public abstract class GLCaps {
* Determine which extensions are available. Use this to initialize capability fields.
* Can only be called _after_ a GLWindow or Pbuffer has been created.
*/
public static void determineAvailableExtensions() {
public static void determineAvailableExtensions(HashSet exts) {
// Grab all the public static booleans out of this class
Field[] fields = GLCaps.class.getDeclaredFields();
HashMap map = new HashMap(fields.length);
@ -200,67 +202,6 @@ public abstract class GLCaps {
}
}
determineAvailableWGLExtensions(map);
String exts = CoreGL11.glGetString(CoreGL11.GL_EXTENSIONS);
if(org.lwjgl.Sys.DEBUG) {
System.out.println("Available GL extensions:");
}
setExtensionFields(exts, map);
// Let's see what openGL version we are too:
String version = CoreGL11.glGetString(CoreGL11.GL_VERSION);
int i = version.indexOf("1.");
if (i > -1) {
char c = version.charAt(i + 2);
// Each case intentionally falls through!
switch (c) {
case '4':
OpenGL14 = true;
case '3':
OpenGL13 = true;
case '2':
OpenGL12 = true;
case '1':
OpenGL11 = true;
case '0':
OpenGL10 = true;
break ;
default:
// Unexpected character - ignore
}
}
}
private static native boolean isWGLEXTExtensionsStringAvailable();
private static native boolean isWGLARBExtensionsStringAvailable();
/**
* Determine which WGL extensions are available
*/
private static void determineAvailableWGLExtensions(HashMap field_map) {
// First we must determine if WGL_EXT_extensions_string is available
WGL_ARB_extensions_string = isWGLARBExtensionsStringAvailable();
WGL_EXT_extensions_string = isWGLEXTExtensionsStringAvailable();
if (!WGL_EXT_extensions_string && !WGL_ARB_extensions_string)
return;
final String exts;
if (WGL_ARB_extensions_string)
exts = GL.wglGetExtensionsStringARB();
// Remember - this is an HWND not an HDC, which is what's required. The native
// code on the other side of wglGetExtensionsStringARB gets the HDC from the HWND
// behind the scenes.
else
exts = GL.wglGetExtensionsStringEXT();
if (exts == null)
return;
if(org.lwjgl.Sys.DEBUG) {
System.out.println("Available WGL extensions:");
}
setExtensionFields(exts, field_map);
}
}

View file

@ -24,6 +24,8 @@ package org.lwjgl.opengl;
import org.lwjgl.Display;
import org.lwjgl.Sys;
import java.util.HashSet;
public final class Window {
static {
@ -119,13 +121,13 @@ public final class Window {
return title;
}
/**
* @return whether this window is in fullscreen mode
*/
public static boolean isFullscreen() {
assert isCreated() : "Cannot determine state of uncreated window";
return fullscreen;
}
/**
* @return whether this window is in fullscreen mode
*/
public static boolean isFullscreen() {
assert isCreated() : "Cannot determine state of uncreated window";
return fullscreen;
}
/**
* Set the title of the window. This may be ignored by the underlying OS.
@ -298,11 +300,14 @@ public final class Window {
int bpp,
int alpha,
int depth,
int stencil)
int stencil,
HashSet extensions)
throws Exception;
private static void createWindow() throws Exception {
nCreate(title, x, y, width, height, fullscreen, color, alpha, depth, stencil);
HashSet extensions = new HashSet();
nCreate(title, x, y, width, height, fullscreen, color, alpha, depth, stencil, extensions);
GLCaps.determineAvailableExtensions(extensions);
created = true;
}

View file

@ -337,7 +337,6 @@ public class HWCursorTest {
GL.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
//sync frame (only works on windows)
GLCaps.determineAvailableExtensions();
if (GLCaps.WGL_EXT_swap_control) {
GL.wglSwapIntervalEXT(1);
}

View file

@ -315,7 +315,6 @@ public class FullScreenWindowedTest {
GL.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
//sync frame (only works on windows)
GLCaps.determineAvailableExtensions();
if (GLCaps.WGL_EXT_swap_control) {
GL.wglSwapIntervalEXT(1);
}

View file

@ -129,7 +129,6 @@ public class Grass {
public static void main(String[] args) {
ByteBuffer byte_buf = ByteBuffer.allocateDirect(4);
byte_buf.order(ByteOrder.nativeOrder());
GLCaps.determineAvailableExtensions();
System.out.println("Vertex program supported: " + GLCaps.GL_NV_vertex_program);
GL.glGenProgramsNV(byte_buf.asIntBuffer());
IntBuffer int_buf = byte_buf.asIntBuffer();

View file

@ -386,7 +386,6 @@ public class PbufferTest {
*/
private void glInit() {
//sync frame (only works on windows)
GLCaps.determineAvailableExtensions();
if (GLCaps.WGL_EXT_swap_control) {
GL.wglSwapIntervalEXT(1);
}

View file

@ -189,7 +189,6 @@ public final class VBOIndexTest {
Sys.setProcessPriority(Sys.HIGH_PRIORITY);
System.out.println("Timer resolution: " + Sys.getTimerResolution());
// Go into orthographic projection mode.
GLCaps.determineAvailableExtensions();
GL.glMatrixMode(GL.GL_PROJECTION);
GL.glLoadIdentity();
GLU.gluOrtho2D(0, Display.getWidth(), 0, Display.getHeight());

View file

@ -173,7 +173,6 @@ public final class VBOTest {
Sys.setProcessPriority(Sys.HIGH_PRIORITY);
System.out.println("Timer resolution: " + Sys.getTimerResolution());
// Go into orthographic projection mode.
GLCaps.determineAvailableExtensions();
GL.glMatrixMode(GL.GL_PROJECTION);
GL.glLoadIdentity();
GLU.gluOrtho2D(0, Display.getWidth(), 0, Display.getHeight());