Moved GL capabilities to GLCaps

This commit is contained in:
Elias Naur 2003-07-28 10:09:58 +00:00
parent 91e1e30652
commit 8b9931560f
14 changed files with 599 additions and 346 deletions

View File

@ -38,8 +38,8 @@ public abstract class Window {
/** Whether the window is currently minimized */
private boolean minimized;
/** Whether the window has focus */
private boolean focused = true;
/** Whether the window has focus */
private boolean focused = true;
/** Whether the window has been asked to close by the user or underlying OS */
private boolean closeRequested;
@ -134,16 +134,16 @@ public abstract class Window {
*/
private native void nSetTitle(String title);
/**
* @return true if the user or operating system has asked the window to close
*/
public final boolean isCloseRequested() {
assert isCreated();
boolean currentValue = closeRequested;
closeRequested = false;
return currentValue;
}
/**
* @return true if the user or operating system has asked the window to close
*/
public final boolean isCloseRequested() {
assert isCreated();
boolean currentValue = closeRequested;
closeRequested = false;
return currentValue;
}
/**
* @return true if the window is minimized or otherwise not visible
@ -153,13 +153,13 @@ public abstract class Window {
return minimized;
}
/**
* @return true if window is focused
*/
public final boolean isFocused() {
assert isCreated();
return focused;
}
/**
* @return true if window is focused
*/
public final boolean isFocused() {
assert isCreated();
return focused;
}
/**
* Minimize the game and allow the operating system's default display to become

View File

@ -0,0 +1,267 @@
/*
* Copyright (c) 2002 Lightweight Java Game Library Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of 'Light Weight Java Game Library' nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.lwjgl.opengl;
import org.lwjgl.Sys;
import org.lwjgl.Window;
import java.lang.reflect.*;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.StringTokenizer;
/**
* $Id$
*
* A static class describing all supported GL capabilities.
*
* @author elias_naur <elias_naur@users.sourceforge.net>
* @version $Revision$
*/
public class GLCaps {
/*
* Available extensions
*/
public static boolean GL_ARB_imaging;
public static boolean GL_ARB_depth_texture;
public static boolean GL_ARB_matrix_palette;
public static boolean GL_ARB_multisample;
public static boolean GL_ARB_multitexture;
public static boolean GL_ARB_point_parameters;
public static boolean GL_ARB_shadow;
public static boolean GL_ARB_shadow_ambient;
public static boolean GL_ARB_texture_compression;
public static boolean GL_ARB_texture_env_add;
public static boolean GL_ARB_texture_env_dot3;
public static boolean GL_ARB_texture_env_combine;
public static boolean GL_ARB_texture_env_crossbar;
public static boolean GL_ARB_texture_border_clamp;
public static boolean GL_ARB_texture_cube_map;
public static boolean GL_ARB_texture_mirrored_repeat;
public static boolean GL_ARB_transpose_matrix;
public static boolean GL_ARB_vertex_blend;
public static boolean GL_ARB_vertex_program;
public static boolean GL_ARB_vertex_buffer_object;
public static boolean GL_ARB_window_pos;
public static boolean GL_EXT_abgr;
public static boolean GL_EXT_bgra;
public static boolean GL_EXT_blend_color;
public static boolean GL_EXT_blend_function_separate;
public static boolean GL_EXT_blend_minmax;
public static boolean GL_EXT_blend_subtract;
public static boolean GL_EXT_compiled_vertex_array;
public static boolean GL_EXT_cull_vertex;
public static boolean GL_EXT_draw_range_elements;
public static boolean GL_EXT_fog_coord;
public static boolean GL_EXT_light_max_exponent;
public static boolean GL_EXT_multi_draw_arrays;
public static boolean GL_EXT_packed_pixels;
public static boolean GL_EXT_paletted_texture;
public static boolean GL_EXT_point_parameters;
public static boolean GL_EXT_rescale_normal;
public static boolean GL_EXT_secondary_color;
public static boolean GL_EXT_separate_specular_color;
public static boolean GL_EXT_shadow_funcs;
public static boolean GL_EXT_shared_texture_palette;
public static boolean GL_EXT_stencil_two_side;
public static boolean GL_EXT_stencil_wrap;
public static boolean GL_EXT_texture_compression_s3tc;
public static boolean GL_EXT_texture_env_combine;
public static boolean GL_EXT_texture_env_dot3;
public static boolean GL_EXT_texture_filter_anisotropic;
public static boolean GL_EXT_texture_lod_bias;
public static boolean GL_EXT_vertex_array;
public static boolean GL_EXT_vertex_shader;
public static boolean GL_EXT_vertex_weighting;
public static boolean GL_ATI_element_array;
public static boolean GL_ATI_envmap_bumpmap;
public static boolean GL_ATI_fragment_shader;
public static boolean GL_ATI_pn_triangles;
public static boolean GL_ATI_texture_mirror_once;
public static boolean GL_ATI_vertex_array_object;
public static boolean GL_ATI_vertex_streams;
public static boolean GL_ATIX_point_sprites;
public static boolean GL_ATIX_texture_env_route;
public static boolean GL_HP_occlusion_test;
public static boolean GL_NV_blend_square;
public static boolean GL_NV_copy_depth_to_color;
public static boolean GL_NV_depth_clamp;
public static boolean GL_NV_evaluators;
public static boolean GL_NV_fence;
public static boolean GL_NV_fog_distance;
public static boolean GL_NV_light_max_exponent;
public static boolean GL_NV_occlusion_query;
public static boolean GL_NV_packed_depth_stencil;
public static boolean GL_NV_point_sprite;
public static boolean GL_NV_register_combiners;
public static boolean GL_NV_register_combiners2;
public static boolean GL_NV_texgen_reflection;
public static boolean GL_NV_texture_env_combine4;
public static boolean GL_NV_texture_rectangle;
public static boolean GL_NV_texture_shader;
public static boolean GL_NV_texture_shader2;
public static boolean GL_NV_texture_shader3;
public static boolean GL_NV_vertex_array_range;
public static boolean GL_NV_vertex_array_range2;
public static boolean GL_NV_vertex_program;
public static boolean GL_NV_vertex_program1_1;
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;
public static boolean OpenGL14;
/*
* Available WGL extensions
*/
public static boolean WGL_ARB_buffer_region;
public static boolean WGL_ARB_extensions_string;
public static boolean WGL_ARB_pbuffer;
public static boolean WGL_ARB_pixel_format;
public static boolean WGL_ARB_render_texture;
public static boolean WGL_EXT_extensions_string;
public static boolean WGL_EXT_swap_control;
static {
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();
if(org.lwjgl.Sys.DEBUG) {
System.out.println(ext);
}
Field f = (Field)field_map.get(ext);
if (f != null) {
try {
f.setBoolean(GLCaps.class, true);
} catch (IllegalAccessException e) {
e.printStackTrace(System.err);
}
}
}
}
/**
* 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() {
// Grab all the public static booleans out of this class
Field[] fields = GLCaps.class.getDeclaredFields();
HashMap map = new HashMap(fields.length);
for (int i = 0; i < fields.length; i++) {
if (Modifier.isStatic(fields[i].getModifiers())
&& fields[i].getType() == boolean.class) {
map.put(fields[i].getName(), fields[i]);
// reset fields
try {
fields[i].setBoolean(GLCaps.class, false);
} catch (IllegalAccessException e) {
e.printStackTrace(System.err);
}
}
}
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 isWGLEXTExtensionsStringAvaiable();
private static native boolean isWGLARBExtensionsStringAvaiable();
/**
* 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 = isWGLARBExtensionsStringAvaiable();
WGL_EXT_extensions_string = isWGLEXTExtensionsStringAvaiable();
if (!WGL_EXT_extensions_string && !WGL_ARB_extensions_string)
return;
final String exts;
if (WGL_ARB_extensions_string)
exts = GL.wglGetExtensionsStringARB(Window.getCurrentWindow().getHandle());
// 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

@ -32,13 +32,9 @@
package org.lwjgl.opengl;
import org.lwjgl.*;
import org.lwjgl.Window;
import java.lang.reflect.*;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.StringTokenizer;
import org.lwjgl.Sys;
import org.lwjgl.Display;
/**
* $Id$
@ -76,231 +72,6 @@ public class GLWindow extends Window {
/** Fullscreen */
protected final boolean fullscreen;
/*
* Available extensions
*/
public boolean GL_ARB_imaging;
public boolean GL_ARB_depth_texture;
public boolean GL_ARB_matrix_palette;
public boolean GL_ARB_multisample;
public boolean GL_ARB_multitexture;
public boolean GL_ARB_point_parameters;
public boolean GL_ARB_shadow;
public boolean GL_ARB_shadow_ambient;
public boolean GL_ARB_texture_compression;
public boolean GL_ARB_texture_env_add;
public boolean GL_ARB_texture_env_dot3;
public boolean GL_ARB_texture_env_combine;
public boolean GL_ARB_texture_env_crossbar;
public boolean GL_ARB_texture_border_clamp;
public boolean GL_ARB_texture_cube_map;
public boolean GL_ARB_texture_mirrored_repeat;
public boolean GL_ARB_transpose_matrix;
public boolean GL_ARB_vertex_blend;
public boolean GL_ARB_vertex_program;
public boolean GL_ARB_vertex_buffer_object;
public boolean GL_ARB_window_pos;
public boolean GL_EXT_abgr;
public boolean GL_EXT_bgra;
public boolean GL_EXT_blend_color;
public boolean GL_EXT_blend_function_separate;
public boolean GL_EXT_blend_minmax;
public boolean GL_EXT_blend_subtract;
public boolean GL_EXT_compiled_vertex_array;
public boolean GL_EXT_cull_vertex;
public boolean GL_EXT_draw_range_elements;
public boolean GL_EXT_fog_coord;
public boolean GL_EXT_light_max_exponent;
public boolean GL_EXT_multi_draw_arrays;
public boolean GL_EXT_packed_pixels;
public boolean GL_EXT_paletted_texture;
public boolean GL_EXT_point_parameters;
public boolean GL_EXT_rescale_normal;
public boolean GL_EXT_secondary_color;
public boolean GL_EXT_separate_specular_color;
public boolean GL_EXT_shadow_funcs;
public boolean GL_EXT_shared_texture_palette;
public boolean GL_EXT_stencil_two_side;
public boolean GL_EXT_stencil_wrap;
public boolean GL_EXT_texture_compression_s3tc;
public boolean GL_EXT_texture_env_combine;
public boolean GL_EXT_texture_env_dot3;
public boolean GL_EXT_texture_filter_anisotropic;
public boolean GL_EXT_texture_lod_bias;
public boolean GL_EXT_vertex_array;
public boolean GL_EXT_vertex_shader;
public boolean GL_EXT_vertex_weighting;
public boolean GL_ATI_element_array;
public boolean GL_ATI_envmap_bumpmap;
public boolean GL_ATI_fragment_shader;
public boolean GL_ATI_pn_triangles;
public boolean GL_ATI_texture_mirror_once;
public boolean GL_ATI_vertex_array_object;
public boolean GL_ATI_vertex_streams;
public boolean GL_ATIX_point_sprites;
public boolean GL_ATIX_texture_env_route;
public boolean GL_HP_occlusion_test;
public boolean GL_NV_blend_square;
public boolean GL_NV_copy_depth_to_color;
public boolean GL_NV_depth_clamp;
public boolean GL_NV_evaluators;
public boolean GL_NV_fence;
public boolean GL_NV_fog_distance;
public boolean GL_NV_light_max_exponent;
public boolean GL_NV_occlusion_query;
public boolean GL_NV_packed_depth_stencil;
public boolean GL_NV_point_sprite;
public boolean GL_NV_register_combiners;
public boolean GL_NV_register_combiners2;
public boolean GL_NV_texgen_reflection;
public boolean GL_NV_texture_env_combine4;
public boolean GL_NV_texture_rectangle;
public boolean GL_NV_texture_shader;
public boolean GL_NV_texture_shader2;
public boolean GL_NV_texture_shader3;
public boolean GL_NV_vertex_array_range;
public boolean GL_NV_vertex_array_range2;
public boolean GL_NV_vertex_program;
public boolean GL_NV_vertex_program1_1;
public boolean GL_SGIS_generate_mipmap;
public boolean GL_SGIX_shadow;
public boolean GL_SGIX_depth_texture;
public boolean OpenGL10;
public boolean OpenGL11;
public boolean OpenGL12;
public boolean OpenGL13;
public boolean OpenGL14;
/*
* Available WGL extensions
*/
public boolean WGL_ARB_buffer_region;
public boolean WGL_ARB_extensions_string;
public boolean WGL_ARB_pbuffer;
public boolean WGL_ARB_pixel_format;
public boolean WGL_ARB_render_texture;
public boolean WGL_EXT_extensions_string;
public boolean WGL_EXT_swap_control;
/**
* Determine which extensions are available
*/
private void determineAvailableExtensions() {
if (Display.getPlatform() == Display.PLATFORM_WGL)
determineAvailableWGLExtensions();
// Grab all the public booleans out of this class
Field[] fields = GLWindow.class.getDeclaredFields();
HashMap map = new HashMap(fields.length);
for (int i = 0; i < fields.length; i++) {
if (!Modifier.isStatic(fields[i].getModifiers())
&& fields[i].getType() == boolean.class)
map.put(fields[i].getName(), fields[i]);
}
String exts = CoreGL11.glGetString(CoreGL11.GL_EXTENSIONS);
StringTokenizer st = new StringTokenizer(exts);
while (st.hasMoreTokens()) {
String ext = st.nextToken();
Field f = (Field) map.get(ext);
if (f != null) {
//System.out.println("Extension : "+ext+" : present");
try {
f.setBoolean(this, true);
} catch (IllegalAccessException e) {
e.printStackTrace(System.err);
}
// } else {
// System.out.println("Extension : "+ext+" : NOT AVAILABLE");
}
}
// 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
}
}
}
/**
* Checks and sets WGL_EXT_extensions_string and WGL_ARB_extensions_string
* if available.
*/
private native void checkWGLExtensionsString();
/**
* Determine which WGL extensions are available
*/
private void determineAvailableWGLExtensions() {
// First we must determine if WGL_EXT_extensions_string is available
checkWGLExtensionsString();
if (!WGL_EXT_extensions_string && !WGL_ARB_extensions_string)
return;
// Grab all the public booleans out of this class
Field[] fields = GLWindow.class.getDeclaredFields();
HashMap map = new HashMap(fields.length);
for (int i = 0; i < fields.length; i++) {
if (!Modifier.isStatic(fields[i].getModifiers())
&& fields[i].getType() == boolean.class)
map.put(fields[i].getName(), fields[i]);
}
final String exts;
if (WGL_ARB_extensions_string)
exts = GL.wglGetExtensionsStringARB(getHandle());
// 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:");
}
StringTokenizer st = new StringTokenizer(exts);
while (st.hasMoreTokens()) {
String ext = st.nextToken();
if(org.lwjgl.Sys.DEBUG) {
System.out.println(ext);
}
Field f = (Field) map.get(ext);
if (f != null) {
try {
f.setBoolean(this, true);
} catch (IllegalAccessException e) {
e.printStackTrace(System.err);
}
}
}
}
static {
System.loadLibrary(Sys.getLibraryName());
}
@ -359,7 +130,6 @@ public class GLWindow extends Window {
protected void doCreate() throws Exception {
nCreate(getTitle(), x, y, getWidth(), getHeight(), color, alpha, depth, stencil, fullscreen);
determineAvailableExtensions();
}
protected void doPaint() {

View File

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

View File

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

View File

@ -131,8 +131,9 @@ public class Grass {
public static void main(String[] args) {
ByteBuffer byte_buf = ByteBuffer.allocateDirect(4);
byte_buf.order(ByteOrder.nativeOrder());
System.out.println("Vertex program supported: " + gl.GL_NV_vertex_program);
GL.glGenProgramsNV(1, byte_buf.asIntBuffer());
GLCaps.determineAvailableExtensions();
System.out.println("Vertex program supported: " + GLCaps.GL_NV_vertex_program);
GL.glGenProgramsNV(1, byte_buf.asIntBuffer());
IntBuffer int_buf = byte_buf.asIntBuffer();
if (int_buf.get(0) == 0)
throw new RuntimeException("Could not allocate new vertex program id!");
@ -144,7 +145,7 @@ public class Grass {
program_buf.rewind();
program_buf.put(program);
program_buf.rewind();
GL.glLoadProgramNV(
GL.glLoadProgramNV(
GL.GL_VERTEX_PROGRAM_NV,
program_handle,
program_buf.remaining(),
@ -162,29 +163,24 @@ public class Grass {
light_buf_f.rewind();
light_buf_f.put(LightDiffuse);
GL.glLightfv(
GL.glLightfv(
GL.GL_LIGHT0,
GL.GL_DIFFUSE,
light_buf_f);
light_buf_f.rewind();
light_buf_f.put(LightPosition);
GL.glLightfv(
GL.glLightfv(
GL.GL_LIGHT0,
GL.GL_POSITION,
light_buf_f);
GL.glEnable(GL.GL_LIGHT0);
GL.glEnable(GL.GL_LIGHTING);
GL.glEnable(GL.GL_DEPTH_TEST);
GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
GL.glEnable(GL.GL_BLEND);
GL.glMatrixMode(GL.GL_PROJECTION);
GLU.gluPerspective(40.0, 1.0, 1.0, 50.0);
GL.glMatrixMode(GL.GL_MODELVIEW);
GL.glEnable(GL.GL_LIGHT0);
GL.glEnable(GL.GL_LIGHTING);
GL.glEnable(GL.GL_DEPTH_TEST);
GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
GL.glEnable(GL.GL_BLEND);
GL.glMatrixMode(GL.GL_PROJECTION);
GLU.gluPerspective(40.0, 1.0, 1.0, 50.0);
GL.glMatrixMode(GL.GL_MODELVIEW);
GLU.gluLookAt(14.0, 10.0, -16.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
@ -200,7 +196,7 @@ public class Grass {
degree *= (0.5 + myrand());
ptrAnimate(degree);
GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
//ptrDraw();
@ -246,16 +242,16 @@ public class Grass {
fRigid = ((fRigid = myrand()) < 0.2f) ? 0.2f : fRigid;
if (myrand() < 0.3)
GL.glBegin(GL.GL_LINE_STRIP);
GL.glBegin(GL.GL_LINE_STRIP);
else
GL.glBegin(GL.GL_QUAD_STRIP);
GL.glBegin(GL.GL_QUAD_STRIP);
for (cFaces = 0; cFaces < numFaces; cFaces++) {
for (cWidth = frndWidth;
cWidth >= -frndWidth;
cWidth -= (frndWidth * 2.0f)) {
GL.glColor4f(fX, fRigid, fZ, (float) cFaces / (float) numFaces);
GL.glVertex3f(
GL.glColor4f(fX, fRigid, fZ, (float) cFaces / (float) numFaces);
GL.glVertex3f(
(float) (((cFaces - 2) * 0.1f)
* java.lang.Math.cos(fRotate)
+ (cWidth) * java.lang.Math.sin(fRotate)),
@ -266,7 +262,7 @@ public class Grass {
}
frndWidth -= fDecWidth;
}
GL.glEnd();
GL.glEnd();
}
@ -275,110 +271,109 @@ public class Grass {
fArea = 20.0f;
mesh = GL.glGenLists(1);
GL.glNewList(mesh, GL.GL_COMPILE);
GL.glNewList(mesh, GL.GL_COMPILE);
for (cI = -fArea / 2; cI < fArea / 2; cI += 0.25f) {
for (cJ = -fArea / 2; cJ < fArea / 2; cJ += 0.25f) {
genGrass(0.5f, 0.1f, cI, cJ);
}
}
GL.glEndList();
GL.glEndList();
}
private static void grsDraw() {
GL.glEnable(GL.GL_VERTEX_PROGRAM_NV);
GL.glBindProgramNV(GL.GL_VERTEX_PROGRAM_NV, program_handle);
GL.glTrackMatrixNV(
GL.glEnable(GL.GL_VERTEX_PROGRAM_NV);
GL.glBindProgramNV(GL.GL_VERTEX_PROGRAM_NV, program_handle);
GL.glTrackMatrixNV(
GL.GL_VERTEX_PROGRAM_NV,
0,
GL.GL_MODELVIEW_PROJECTION_NV,
GL.GL_IDENTITY_NV);
GL.glProgramParameter4fNV(
GL.glProgramParameter4fNV(
GL.GL_VERTEX_PROGRAM_NV,
4,
0.0f,
0.0f,
0.0f,
0.0f);
GL.glProgramParameter4fNV(
GL.glProgramParameter4fNV(
GL.GL_VERTEX_PROGRAM_NV,
5,
0.0f,
0.0f,
0.0f,
0.0f);
GL.glProgramParameter4fNV(
GL.glProgramParameter4fNV(
GL.GL_VERTEX_PROGRAM_NV,
6,
1.763609f,
0.496495f,
0.0f,
0.0f);
GL.glProgramParameter4fNV(
GL.glProgramParameter4fNV(
GL.GL_VERTEX_PROGRAM_NV,
7,
-0.943599f,
3.203737f,
0.0f,
0.0f);
GL.glProgramParameter4fNV(
GL.glProgramParameter4fNV(
GL.GL_VERTEX_PROGRAM_NV,
8,
4.101107f,
0.943413f,
0.0f,
0.0f);
GL.glProgramParameter4fNV(
GL.glProgramParameter4fNV(
GL.GL_VERTEX_PROGRAM_NV,
9,
-1.218603f,
6.259399f,
0.0f,
0.0f);
GL.glProgramParameter4fNV(
GL.glProgramParameter4fNV(
GL.GL_VERTEX_PROGRAM_NV,
10,
7.214299f,
1.352961f,
0.0f,
0.0f);
GL.glProgramParameter4fNV(
GL.glProgramParameter4fNV(
GL.GL_VERTEX_PROGRAM_NV,
11,
-1.540748f,
10.080958f,
0.0f,
0.0f);
GL.glProgramParameter4fNV(
GL.glProgramParameter4fNV(
GL.GL_VERTEX_PROGRAM_NV,
12,
10.880035f,
1.759046f,
0.0f,
0.0f);
GL.glProgramParameter4fNV(
GL.glProgramParameter4fNV(
GL.GL_VERTEX_PROGRAM_NV,
13,
-1.852705f,
14.468674f,
0.0f,
0.0f);
GL.glProgramParameter4fNV(
GL.glProgramParameter4fNV(
GL.GL_VERTEX_PROGRAM_NV,
14,
14.292879f,
1.973329f,
0.0f,
0.0f);
GL.glProgramParameter4fNV(
GL.glProgramParameter4fNV(
GL.GL_VERTEX_PROGRAM_NV,
15,
-1.973387f,
18.506531f,
0.0f,
0.0f);
GL.glProgramParameter4fNV(
GL.glProgramParameter4fNV(
GL.GL_VERTEX_PROGRAM_NV,
16,
(float) (java.lang.Math.sin(aslod.angle)
@ -388,54 +383,54 @@ public class Grass {
* (aslod.value + aslod.ripple)),
0.0f);
GL.glProgramParameter4fNV(GL.GL_VERTEX_PROGRAM_NV, 17, 1.7f, 5f, 2f, 0f);
GL.glProgramParameter4fNV(
GL.glProgramParameter4fNV(GL.GL_VERTEX_PROGRAM_NV, 17, 1.7f, 5f, 2f, 0f);
GL.glProgramParameter4fNV(
GL.GL_VERTEX_PROGRAM_NV,
18,
-0.0187293f,
0.074261f,
0.2121144f,
1.570729f);
GL.glProgramParameter4fNV(GL.GL_VERTEX_PROGRAM_NV, 20, 0f, 0.5f, 1f, 0f);
GL.glProgramParameter4fNV(
GL.glProgramParameter4fNV(GL.GL_VERTEX_PROGRAM_NV, 20, 0f, 0.5f, 1f, 0f);
GL.glProgramParameter4fNV(
GL.GL_VERTEX_PROGRAM_NV,
21,
0.25f,
-9f,
0.75f,
0.1591549f);
GL.glProgramParameter4fNV(
GL.glProgramParameter4fNV(
GL.GL_VERTEX_PROGRAM_NV,
22,
24.9808f,
-24.9808f,
-60.14581f,
60.14581f);
GL.glProgramParameter4fNV(
GL.glProgramParameter4fNV(
GL.GL_VERTEX_PROGRAM_NV,
23,
85.45379f,
-85.45379f,
-64.93935f,
64.93935f);
GL.glProgramParameter4fNV(
GL.glProgramParameter4fNV(
GL.GL_VERTEX_PROGRAM_NV,
24,
19.73921f,
-19.73921f,
-1f,
1f);
GL.glProgramParameter4fNV(GL.GL_VERTEX_PROGRAM_NV, 25, 0f, 4f, 0f, 0f);
GL.glProgramParameter4fNV(
GL.glProgramParameter4fNV(GL.GL_VERTEX_PROGRAM_NV, 25, 0f, 4f, 0f, 0f);
GL.glProgramParameter4fNV(
GL.GL_VERTEX_PROGRAM_NV,
19,
1f,
3.141593f,
0.5f,
1f);
GL.glProgramParameter4fNV(GL.GL_VERTEX_PROGRAM_NV, 26, 0.7f, 0.4f, 0f, 0f);
GL.glCallList(mesh);
GL.glDisable(GL.GL_VERTEX_PROGRAM_NV);
GL.glProgramParameter4fNV(GL.GL_VERTEX_PROGRAM_NV, 26, 0.7f, 0.4f, 0f, 0f);
GL.glCallList(mesh);
GL.glDisable(GL.GL_VERTEX_PROGRAM_NV);
}

View File

@ -392,7 +392,8 @@ public class PbufferTest {
*/
private void glInit() {
//sync frame (only works on windows)
if (gl.WGL_EXT_swap_control) {
GLCaps.determineAvailableExtensions();
if (GLCaps.WGL_EXT_swap_control) {
GL.wglSwapIntervalEXT(1);
}
GL.glTexEnvf(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE, GL.GL_REPLACE);

View File

@ -0,0 +1,129 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class org_lwjgl_opengl_GLCaps */
#ifndef _Included_org_lwjgl_opengl_GLCaps
#define _Included_org_lwjgl_opengl_GLCaps
#ifdef __cplusplus
extern "C" {
#endif
/* Inaccessible static: _00024assertionsDisabled */
/* Inaccessible static: GL_ARB_imaging */
/* Inaccessible static: GL_ARB_depth_texture */
/* Inaccessible static: GL_ARB_matrix_palette */
/* Inaccessible static: GL_ARB_multisample */
/* Inaccessible static: GL_ARB_multitexture */
/* Inaccessible static: GL_ARB_point_parameters */
/* Inaccessible static: GL_ARB_shadow */
/* Inaccessible static: GL_ARB_shadow_ambient */
/* Inaccessible static: GL_ARB_texture_compression */
/* Inaccessible static: GL_ARB_texture_env_add */
/* Inaccessible static: GL_ARB_texture_env_dot3 */
/* Inaccessible static: GL_ARB_texture_env_combine */
/* Inaccessible static: GL_ARB_texture_env_crossbar */
/* Inaccessible static: GL_ARB_texture_border_clamp */
/* Inaccessible static: GL_ARB_texture_cube_map */
/* Inaccessible static: GL_ARB_texture_mirrored_repeat */
/* Inaccessible static: GL_ARB_transpose_matrix */
/* Inaccessible static: GL_ARB_vertex_blend */
/* Inaccessible static: GL_ARB_vertex_program */
/* Inaccessible static: GL_ARB_vertex_buffer_object */
/* Inaccessible static: GL_ARB_window_pos */
/* Inaccessible static: GL_EXT_abgr */
/* Inaccessible static: GL_EXT_bgra */
/* Inaccessible static: GL_EXT_blend_color */
/* Inaccessible static: GL_EXT_blend_function_separate */
/* Inaccessible static: GL_EXT_blend_minmax */
/* Inaccessible static: GL_EXT_blend_subtract */
/* Inaccessible static: GL_EXT_compiled_vertex_array */
/* Inaccessible static: GL_EXT_cull_vertex */
/* Inaccessible static: GL_EXT_draw_range_elements */
/* Inaccessible static: GL_EXT_fog_coord */
/* Inaccessible static: GL_EXT_light_max_exponent */
/* Inaccessible static: GL_EXT_multi_draw_arrays */
/* Inaccessible static: GL_EXT_packed_pixels */
/* Inaccessible static: GL_EXT_paletted_texture */
/* Inaccessible static: GL_EXT_point_parameters */
/* Inaccessible static: GL_EXT_rescale_normal */
/* Inaccessible static: GL_EXT_secondary_color */
/* Inaccessible static: GL_EXT_separate_specular_color */
/* Inaccessible static: GL_EXT_shadow_funcs */
/* Inaccessible static: GL_EXT_shared_texture_palette */
/* Inaccessible static: GL_EXT_stencil_two_side */
/* Inaccessible static: GL_EXT_stencil_wrap */
/* Inaccessible static: GL_EXT_texture_compression_s3tc */
/* Inaccessible static: GL_EXT_texture_env_combine */
/* Inaccessible static: GL_EXT_texture_env_dot3 */
/* Inaccessible static: GL_EXT_texture_filter_anisotropic */
/* Inaccessible static: GL_EXT_texture_lod_bias */
/* Inaccessible static: GL_EXT_vertex_array */
/* Inaccessible static: GL_EXT_vertex_shader */
/* Inaccessible static: GL_EXT_vertex_weighting */
/* Inaccessible static: GL_ATI_element_array */
/* Inaccessible static: GL_ATI_envmap_bumpmap */
/* Inaccessible static: GL_ATI_fragment_shader */
/* Inaccessible static: GL_ATI_pn_triangles */
/* Inaccessible static: GL_ATI_texture_mirror_once */
/* Inaccessible static: GL_ATI_vertex_array_object */
/* Inaccessible static: GL_ATI_vertex_streams */
/* Inaccessible static: GL_ATIX_point_sprites */
/* Inaccessible static: GL_ATIX_texture_env_route */
/* Inaccessible static: GL_HP_occlusion_test */
/* Inaccessible static: GL_NV_blend_square */
/* Inaccessible static: GL_NV_copy_depth_to_color */
/* Inaccessible static: GL_NV_depth_clamp */
/* Inaccessible static: GL_NV_evaluators */
/* Inaccessible static: GL_NV_fence */
/* Inaccessible static: GL_NV_fog_distance */
/* Inaccessible static: GL_NV_light_max_exponent */
/* Inaccessible static: GL_NV_occlusion_query */
/* Inaccessible static: GL_NV_packed_depth_stencil */
/* Inaccessible static: GL_NV_point_sprite */
/* Inaccessible static: GL_NV_register_combiners */
/* Inaccessible static: GL_NV_register_combiners2 */
/* Inaccessible static: GL_NV_texgen_reflection */
/* Inaccessible static: GL_NV_texture_env_combine4 */
/* Inaccessible static: GL_NV_texture_rectangle */
/* Inaccessible static: GL_NV_texture_shader */
/* Inaccessible static: GL_NV_texture_shader2 */
/* Inaccessible static: GL_NV_texture_shader3 */
/* Inaccessible static: GL_NV_vertex_array_range */
/* Inaccessible static: GL_NV_vertex_array_range2 */
/* Inaccessible static: GL_NV_vertex_program */
/* Inaccessible static: GL_NV_vertex_program1_1 */
/* Inaccessible static: GL_SGIS_generate_mipmap */
/* Inaccessible static: GL_SGIX_shadow */
/* Inaccessible static: GL_SGIX_depth_texture */
/* Inaccessible static: OpenGL10 */
/* Inaccessible static: OpenGL11 */
/* Inaccessible static: OpenGL12 */
/* Inaccessible static: OpenGL13 */
/* Inaccessible static: OpenGL14 */
/* Inaccessible static: WGL_ARB_buffer_region */
/* Inaccessible static: WGL_ARB_extensions_string */
/* Inaccessible static: WGL_ARB_pbuffer */
/* Inaccessible static: WGL_ARB_pixel_format */
/* Inaccessible static: WGL_ARB_render_texture */
/* Inaccessible static: WGL_EXT_extensions_string */
/* Inaccessible static: WGL_EXT_swap_control */
/* Inaccessible static: class_00024org_00024lwjgl_00024opengl_00024GLCaps */
/*
* Class: org_lwjgl_opengl_GLCaps
* Method: isWGLEXTExtensionsStringAvaiable
* Signature: ()Z
*/
JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_GLCaps_isWGLEXTExtensionsStringAvaiable
(JNIEnv *, jclass);
/*
* Class: org_lwjgl_opengl_GLCaps
* Method: isWGLARBExtensionsStringAvaiable
* Signature: ()Z
*/
JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_GLCaps_isWGLARBExtensionsStringAvaiable
(JNIEnv *, jclass);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -10,15 +10,6 @@ extern "C" {
/* Inaccessible static: _00024assertionsDisabled */
/* Inaccessible static: currentWindow */
/* Inaccessible static: class_00024org_00024lwjgl_00024Window */
/* Inaccessible static: class_00024org_00024lwjgl_00024opengl_00024GL */
/*
* Class: org_lwjgl_opengl_GLWindow
* Method: checkWGLExtensionsString
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GLWindow_checkWGLExtensionsString
(JNIEnv *, jobject);
/*
* Class: org_lwjgl_opengl_GLWindow
* Method: swapBuffers

View File

@ -11,6 +11,7 @@ NATIVE = \
org_lwjgl_input_Mouse.cpp \
org_lwjgl_input_Cursor.cpp \
org_lwjgl_opengl_GLWindow.cpp \
org_lwjgl_opengl_GLCaps.cpp \
org_lwjgl_opengl_Pbuffer.cpp \
org_lwjgl_Window.cpp \
extxcursor.cpp

View File

@ -0,0 +1,62 @@
/*
* Copyright (c) 2002 Light Weight Java Game Library Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of 'Light Weight Java Game Library' nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* $Id$
*
* @author elias_naur <elias_naur@users.sourceforge.net>
* @version $Revision$
*/
#include "org_lwjgl_opengl_GLCaps.h"
#include "extgl.h"
#include "jni.h"
/*
* Class: org_lwjgl_opengl_GLCaps
* Method: isWGLEXTExtensionsStringAvaiable
* Signature: ()Z
*/
JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_GLCaps_isWGLEXTExtensionsStringAvaiable
(JNIEnv *env, jclass clazz) {
return JNI_FALSE;
}
/*
* Class: org_lwjgl_opengl_GLCaps
* Method: isWGLARBExtensionsStringAvaiable
* Signature: ()Z
*/
JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_GLCaps_isWGLARBExtensionsStringAvaiable
(JNIEnv *env, jclass clazz) {
return JNI_FALSE;
}

View File

@ -255,19 +255,6 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GLWindow_nCreate
#endif
}
/*
* Class: org_lwjgl_opengl_GL
* Method: checkWGLExtensionsString
*/
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GLWindow_checkWGLExtensionsString(JNIEnv * env, jobject obj)
{
jclass clazz = env->GetObjectClass(obj);
jfieldID fid_WGL_ARB_extensions_string = env->GetFieldID(clazz, "WGL_ARB_extensions_string", "Z");
jfieldID fid_WGL_EXT_extensions_string = env->GetFieldID(clazz, "WGL_EXT_extensions_string", "Z");
env->SetBooleanField(obj, fid_WGL_ARB_extensions_string, JNI_FALSE);
env->SetBooleanField(obj, fid_WGL_EXT_extensions_string, JNI_FALSE);
}
/*
* Class: org_lwjgl_opengl_GLWindow
* Method: nDestroy

View File

@ -0,0 +1,63 @@
/*
* Copyright (c) 2002 Light Weight Java Game Library Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of 'Light Weight Java Game Library' nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* $Id$
*
* @author elias_naur <elias_naur@users.sourceforge.net>
* @version $Revision$
*/
#include <windows.h>
#include "org_lwjgl_opengl_GLCaps.h"
#include "extgl.h"
#include "jni.h"
/*
* Class: org_lwjgl_opengl_GLCaps
* Method: isWGLEXTExtensionsStringAvaiable
* Signature: ()Z
*/
JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_GLCaps_isWGLEXTExtensionsStringAvaiable
(JNIEnv *env, jclass clazz) {
return extgl_Extensions.wgl.EXT_extensions_string;
}
/*
* Class: org_lwjgl_opengl_GLCaps
* Method: isWGLARBExtensionsStringAvaiable
* Signature: ()Z
*/
JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_GLCaps_isWGLARBExtensionsStringAvaiable
(JNIEnv *env, jclass clazz) {
return extgl_Extensions.wgl.ARB_extensions_string;
}

View File

@ -206,21 +206,6 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GLWindow_nDestroyGL
extgl_Close();
}
/*
* Class: org_lwjgl_opengl_GL
* Method: checkWGLExtensionsString
*/
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GLWindow_checkWGLExtensionsString(JNIEnv * env, jobject obj)
{
jclass clazz = env->GetObjectClass(obj);
jfieldID fid_WGL_ARB_extensions_string = env->GetFieldID(clazz, "WGL_ARB_extensions_string", "Z");
jfieldID fid_WGL_EXT_extensions_string = env->GetFieldID(clazz, "WGL_EXT_extensions_string", "Z");
if (wglGetExtensionsStringARB)
env->SetBooleanField(obj, fid_WGL_ARB_extensions_string, JNI_TRUE);
if (wglGetExtensionsStringEXT)
env->SetBooleanField(obj, fid_WGL_EXT_extensions_string, JNI_TRUE);
}
/*
* Class: org_lwjgl_opengl_GLWindow
* Method: swapBuffers