This commit is contained in:
Caspian Rychlik-Prince 2002-08-17 14:13:12 +00:00
parent 12be603c2f
commit 11ce7e3b5b
13 changed files with 7779 additions and 54 deletions

View File

@ -79,7 +79,7 @@ public final class Sys {
}
/** The native library name */
public static final String LIBRARY_NAME = "lwjgl";
public static final String LIBRARY_NAME = "lwjgl_d";
/**
* No constructor for Sys.

View File

@ -32,6 +32,13 @@
package org.lwjgl.opengl;
import java.lang.reflect.*;
import java.lang.reflect.AccessibleObject;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.StringTokenizer;
import org.lwjgl.Display;
import org.lwjgl.Sys;
/**
@ -1302,7 +1309,7 @@ public class GL extends CoreGL implements GLConstants {
float writeFrequency,
float priority);
public native boolean wglBindTexImageARB(int hPbuffer, int iBuffer);
public static native boolean wglBindTexImageARB(int hPbuffer, int iBuffer);
public static native boolean wglChoosePixelFormatARB(
int hdc,
@ -1312,31 +1319,31 @@ public class GL extends CoreGL implements GLConstants {
int piFormats,
int piNumFormats);
public native int wglCreateBufferRegionARB(
public static native int wglCreateBufferRegionARB(
int hdc,
int iLayerPlane,
int uType);
public native int wglCreatePbufferARB(
public static native int wglCreatePbufferARB(
int hDC,
int iPixelFormat,
int iWidth,
int iHeight,
int piAttribList);
public native void wglDeleteBufferRegionARB(int hRegion);
public static native void wglDeleteBufferRegionARB(int hRegion);
public native boolean wglDestroyPbufferARB(int hPbuffer);
public static native boolean wglDestroyPbufferARB(int hPbuffer);
public static native void wglFreeMemoryNV(int pointer);
// #endif
public static native int wglGetCurrentReadDCARB();
public static native String wglGetExtensionsStringARB(int hdc);
// #endif
public static native String wglGetExtensionsStringEXT();
@ -1365,16 +1372,16 @@ public class GL extends CoreGL implements GLConstants {
int hReadDC,
int hglrc);
public native boolean wglQueryPbufferARB(
public static native boolean wglQueryPbufferARB(
int hPbuffer,
int iAttribute,
int piValue);
public native int wglReleasePbufferDCARB(int hPbuffer, int hDC);
public static native int wglReleasePbufferDCARB(int hPbuffer, int hDC);
public native boolean wglReleaseTexImageARB(int hPbuffer, int iBuffer);
public static native boolean wglReleaseTexImageARB(int hPbuffer, int iBuffer);
public native boolean wglRestoreBufferRegionARB(
public static native boolean wglRestoreBufferRegionARB(
int hRegion,
int x,
int y,
@ -1383,14 +1390,14 @@ public class GL extends CoreGL implements GLConstants {
int xSrc,
int ySrc);
public native boolean wglSaveBufferRegionARB(
public static native boolean wglSaveBufferRegionARB(
int hRegion,
int x,
int y,
int width,
int height);
public native boolean wglSetPbufferAttribARB(
public static native boolean wglSetPbufferAttribARB(
int hPbuffer,
int piAttribList);
@ -1529,6 +1536,90 @@ public class GL extends CoreGL implements GLConstants {
* Determine which extensions are available
*/
private void determineAvailableExtensions() {
determineAvailableWGLExtensions();
// Grab all the public booleans out of this class
Field[] fields = GL.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 = wglGetExtensionsStringEXT();
StringTokenizer st = new StringTokenizer(exts);
while (st.hasMoreTokens()) {
String ext = st.nextToken();
Field f = (Field) map.get(ext);
if (f != null) {
try {
f.setBoolean(this, true);
} catch (IllegalAccessException e) {
e.printStackTrace(System.err);
}
}
}
}
/*
* 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;
/**
* Checks and sets WGL_EXT_extensions_string and WGL_ARB_extensions_string
* if available.
*/
private static 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 = GL.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 = wglGetExtensionsStringARB(Display.getHandle()); // Remember - this is an HWND not an HDC, which is what's required
else
exts = wglGetExtensionsStringEXT();
StringTokenizer st = new StringTokenizer(exts);
while (st.hasMoreTokens()) {
String ext = st.nextToken();
Field f = (Field) map.get(ext);
if (f != null) {
try {
f.setBoolean(GL.class, true);
} catch (IllegalAccessException e) {
e.printStackTrace(System.err);
}
}
}
}
/* (non-Javadoc)

View File

@ -1,13 +0,0 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class org_lwjgl_Audio */
#ifndef _Included_org_lwjgl_Audio
#define _Included_org_lwjgl_Audio
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
#endif

File diff suppressed because it is too large Load Diff

View File

@ -7,6 +7,94 @@
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: org_lwjgl_opengl_GLU
* Method: errorString
* Signature: (I)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_lwjgl_opengl_GLU_errorString
(JNIEnv *, jobject, jint);
/*
* Class: org_lwjgl_opengl_GLU
* Method: getString
* Signature: (I)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_lwjgl_opengl_GLU_getString
(JNIEnv *, jobject, jint);
/*
* Class: org_lwjgl_opengl_GLU
* Method: ortho2D
* Signature: (DDDD)V
*/
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GLU_ortho2D
(JNIEnv *, jobject, jdouble, jdouble, jdouble, jdouble);
/*
* Class: org_lwjgl_opengl_GLU
* Method: perspective
* Signature: (DDDD)V
*/
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GLU_perspective
(JNIEnv *, jobject, jdouble, jdouble, jdouble, jdouble);
/*
* Class: org_lwjgl_opengl_GLU
* Method: pickMatrix
* Signature: (DDDDI)V
*/
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GLU_pickMatrix
(JNIEnv *, jobject, jdouble, jdouble, jdouble, jdouble, jint);
/*
* Class: org_lwjgl_opengl_GLU
* Method: lookAt
* Signature: (DDDDDDDDD)V
*/
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GLU_lookAt
(JNIEnv *, jobject, jdouble, jdouble, jdouble, jdouble, jdouble, jdouble, jdouble, jdouble, jdouble);
/*
* Class: org_lwjgl_opengl_GLU
* Method: project
* Signature: (DDDIIIIII)I
*/
JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_GLU_project
(JNIEnv *, jobject, jdouble, jdouble, jdouble, jint, jint, jint, jint, jint, jint);
/*
* Class: org_lwjgl_opengl_GLU
* Method: unProject
* Signature: (DDDIIIIII)I
*/
JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_GLU_unProject
(JNIEnv *, jobject, jdouble, jdouble, jdouble, jint, jint, jint, jint, jint, jint);
/*
* Class: org_lwjgl_opengl_GLU
* Method: scaleImage
* Signature: (IIIIIIIII)I
*/
JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_GLU_scaleImage
(JNIEnv *, jobject, jint, jint, jint, jint, jint, jint, jint, jint, jint);
/*
* Class: org_lwjgl_opengl_GLU
* Method: build1DMipmaps
* Signature: (IIIIII)I
*/
JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_GLU_build1DMipmaps
(JNIEnv *, jobject, jint, jint, jint, jint, jint, jint);
/*
* Class: org_lwjgl_opengl_GLU
* Method: build2DMipmaps
* Signature: (IIIIIII)I
*/
JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_GLU_build2DMipmaps
(JNIEnv *, jobject, jint, jint, jint, jint, jint, jint, jint);
#ifdef __cplusplus
}
#endif

View File

@ -1,13 +0,0 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class org_lwjgl_opengl_GLUT */
#ifndef _Included_org_lwjgl_opengl_GLUT
#define _Included_org_lwjgl_opengl_GLUT
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
#endif

View File

@ -42,6 +42,7 @@
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <stdio.h>
#include "LWJGL.h"
/*
* DLL entry point for Windows. Called when Java loads the .dll

View File

@ -748,6 +748,7 @@ void *lglGetProcAddress(char *name)
/* char err[1000];*/
if (t == NULL)
{
printf("Failed to get function: %s\n", name);
/*sprintf(err, "wglGetProcAddress on %s failed", name);*/
error = 1; /* MessageBox(0, err, "Error", MB_OK | MB_ICONHAND);*/
}
@ -1779,6 +1780,8 @@ int glInitialize()
{
error = 0;
InitSupportedExtensions();
if (error != 0)
printf("Failed to init supported extensions\n");
/* first load the etensions */
InitARBImaging();

View File

@ -42,11 +42,11 @@
#include <windows.h>
#include "org_lwjgl_Display.h"
#define DIRECTINPUT_VERSION 0x0700
//#define DIRECTINPUT_VERSION 0x0700
#include <dinput.h>
#define WINDOWCLASSNAME "JGLIBWINDOW"
#define WINDOWCLASSNAME "LWJGLWINDOW"
// Initialise static variables
bool oneShotInitialised = false;
@ -75,6 +75,8 @@ LRESULT CALLBACK WindowProc(HWND hWnd,
break;
}
}
case WM_PAINT:
return 0;
}
// default action
@ -180,7 +182,7 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_Display_nCreate
width, height,
NULL,
NULL,
(HINSTANCE) GetCurrentProcess(),
GetModuleHandle(NULL),
NULL);
// And we never look at windowClass again...
@ -199,12 +201,31 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_Display_nCreate
ShowCursor(FALSE);
// Create input
HRESULT ret = DirectInputCreate((HINSTANCE)GetCurrentProcess(), DIRECTINPUT_VERSION, &lpdi, NULL);
HRESULT ret = DirectInputCreate(GetModuleHandle(NULL), DIRECTINPUT_VERSION, &lpdi, NULL);
if (ret != DI_OK && ret != DIERR_BETADIRECTINPUTVERSION ) {
printf("Failed to create directinput\n");
printf("Failed to create directinput");
switch (ret) {
case DIERR_BETADIRECTINPUTVERSION :
printf(" - Beta versio0n\n");
break;
case DIERR_INVALIDPARAM :
printf(" - Invalid parameter\n");
break;
case DIERR_OLDDIRECTINPUTVERSION :
printf(" - Old Version\n");
break;
case DIERR_OUTOFMEMORY :
printf(" - Out Of Memory\n");
break;
default:
printf("\n");
}
return JNI_FALSE;
}
jfieldID fid_handle = env->GetStaticFieldID(clazz, "handle", "I");
env->SetStaticIntField(clazz, fid_handle, (jint) hwnd);
return JNI_TRUE;
}

View File

@ -67,8 +67,8 @@ JNIEXPORT void JNICALL Java_org_lwjgl_input_Keyboard_initIDs
globalClassLock = env->NewGlobalRef(clazz);
}
fid_readBuffer = env->GetFieldID(clazz, "readBuffer", "Ljava/nio/ByteBuffer;");
fid_readBufferAddress = env->GetFieldID(clazz, "readBufferAddress", "I");
fid_readBuffer = env->GetStaticFieldID(clazz, "readBuffer", "Ljava/nio/ByteBuffer;");
fid_readBufferAddress = env->GetStaticFieldID(clazz, "readBufferAddress", "I");
}
/*

View File

@ -109,12 +109,6 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_BaseGL_nCreate
return JNI_FALSE;
}
_wglSetDC(hdc);
if (!glInitialize()) {
printf("Failed to initialize GL\n");
return JNI_FALSE;
}
// Create a rendering context
hglrc = wglCreateContext(hdc);
if (hglrc == NULL) {
@ -123,7 +117,20 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_opengl_BaseGL_nCreate
}
// Automatically make it the current context
Java_org_lwjgl_opengl_BaseGL_nMakeCurrent(env, obj);
wglMakeCurrent(hdc, hglrc);
char * p = (char *) glGetString(GL_EXTENSIONS);
if (NULL == p) {
printf("NO extensions available\n");
} else {
printf("Available extensions:\n%s\n", p);
}
_wglSetDC(hdc);
if (glInitialize() != 0) {
printf("Failed to initialize GL\n");
return JNI_FALSE;
}
return JNI_TRUE;
}

File diff suppressed because it is too large Load Diff

View File

@ -41,3 +41,124 @@
#include <windows.h>
#include "org_lwjgl_opengl_GLU.h"
#include "extgl.h"
#include "checkGLerror.h"
#include "gl/glu.h"
/*
* Class: org_lwjgl_opengl_GLU
* Method: getString
*/
JNIEXPORT jstring JNICALL Java_org_lwjgl_opengl_GLU_getString(JNIEnv * env, jobject obj, jint p0)
{
const char * msg = (const char *) gluGetString((GLint) p0);
jstring ret = env->NewStringUTF(msg);
return ret;
}
/*
* Class: org_lwjgl_opengl_GLU
* Method: errorString
*/
JNIEXPORT jstring JNICALL Java_org_lwjgl_opengl_GLU_errorString(JNIEnv * env, jobject obj, jint p0)
{
const GLubyte * msg = gluErrorString((GLint) p0);
jstring ret = env->NewStringUTF((const char *) msg);
return ret;
}
/*
* Class: org_lwjgl_opengl_GLU
* Method: ortho2D
*/
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GLU_ortho2D(JNIEnv * env, jobject obj, jdouble p0, jdouble p1, jdouble p2, jdouble p3)
{
gluOrtho2D((GLdouble) p0, (GLdouble) p1, (GLdouble) p2, (GLdouble) p3);
CHECK_GL_ERROR
}
/*
* Class: org_lwjgl_opengl_GLU
* Method: perspective
*/
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GLU_perspective(JNIEnv * env, jobject obj, jdouble p0, jdouble p1, jdouble p2, jdouble p3)
{
gluPerspective((GLdouble) p0, (GLdouble) p1, (GLdouble) p2, (GLdouble) p3);
CHECK_GL_ERROR
}
/*
* Class: org_lwjgl_opengl_GLU
* Method: pickMatrix
*/
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GLU_pickMatrix(JNIEnv * env, jobject obj, jdouble p0, jdouble p1, jdouble p2, jdouble p3, jint p4)
{
gluPickMatrix((GLdouble) p0, (GLdouble) p1, (GLdouble) p2, (GLdouble) p3, (GLint *) p4);
CHECK_GL_ERROR
}
/*
* Class: org_lwjgl_opengl_GLU
* Method: lookAt
*/
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_GLU_lookAt(JNIEnv * env, jobject obj, jdouble p0, jdouble p1, jdouble p2, jdouble p3, jdouble p4, jdouble p5, jdouble p6, jdouble p7, jdouble p8)
{
gluLookAt((GLdouble) p0, (GLdouble) p1, (GLdouble) p2, (GLdouble) p3, (GLdouble) p4, (GLdouble) p5, (GLdouble) p6, (GLdouble) p7, (GLdouble) p8);
CHECK_GL_ERROR
}
/*
* Class: org_lwjgl_opengl_GLU
* Method: project
*/
JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_GLU_project(JNIEnv * env, jobject obj, jdouble p0, jdouble p1, jdouble p2, jint p3, jint p4, jint p5, jint p6, jint p7, jint p8)
{
jint ret = (jint) gluProject((GLdouble) p0, (GLdouble) p1, (GLdouble) p2, (const GLdouble *) p3, (const GLdouble *) p4, (const GLint *) p5, (GLdouble *) p6, (GLdouble *) p7, (GLdouble *) p8);
CHECK_GL_ERROR
return ret;
}
/*
* Class: org_lwjgl_opengl_GLU
* Method: unProject
*/
JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_GLU_unProject(JNIEnv * env, jobject obj, jdouble p0, jdouble p1, jdouble p2, jint p3, jint p4, jint p5, jint p6, jint p7, jint p8)
{
jint ret = (jint) gluUnProject((GLdouble) p0, (GLdouble) p1, (GLdouble) p2, (const GLdouble *) p3, (const GLdouble *) p4, (const GLint *) p5, (GLdouble *) p6, (GLdouble *) p7, (GLdouble *) p8);
CHECK_GL_ERROR
return ret;
}
/*
* Class: org_lwjgl_opengl_GLU
* Method: scaleImage
*/
JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_GLU_scaleImage(JNIEnv * env, jobject obj, jint p0, jint p1, jint p2, jint p3, jint p4, jint p5, jint p6, jint p7, jint p8)
{
jint ret = (jint) gluScaleImage((GLint) p0, (GLint) p1, (GLint) p2, (GLint) p3, (const void *) p4, (GLint) p5, (GLint) p6, (GLint) p7, (void *) p8);
CHECK_GL_ERROR
return ret;
}
/*
* Class: org_lwjgl_opengl_GLU
* Method: build1DMipmaps
*/
JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_GLU_build1DMipmaps(JNIEnv * env, jobject obj, jint p0, jint p1, jint p2, jint p3, jint p4, jint p5)
{
jint ret = (jint) gluBuild1DMipmaps((GLint) p0, (GLint) p1, (GLint) p2, (GLint) p3, (GLint) p4, (const void *) p5);
CHECK_GL_ERROR
return ret;
}
/*
* Class: org_lwjgl_opengl_GLU
* Method: build2DMipmaps
*/
JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_GLU_build2DMipmaps(JNIEnv * env, jobject obj, jint p0, jint p1, jint p2, jint p3, jint p4, jint p5, jint p6)
{
jint ret = (jint) gluBuild2DMipmaps((GLint) p0, (GLint) p1, (GLint) p2, (GLint) p3, (GLint) p4, (GLint) p5, (const void *) p6);
CHECK_GL_ERROR
return ret;
}