Fixed AWTGLCanvas destroy crash. Fixed nv vertex array range glitch
This commit is contained in:
parent
e3f5cc7691
commit
5e962e54e2
|
@ -24,7 +24,7 @@ public final class NVVertexArrayRange {
|
||||||
}
|
}
|
||||||
private static native void nglFreeMemoryNV(Buffer pointer, int pointer_position);
|
private static native void nglFreeMemoryNV(Buffer pointer, int pointer_position);
|
||||||
|
|
||||||
public static native java.nio.ByteBuffer glAllocateMemoryNV(int size, float readFrequency, float writeFrequency, float priority, int result_size);
|
public static native java.nio.ByteBuffer glAllocateMemoryNV(int size, float readFrequency, float writeFrequency, float priority);
|
||||||
|
|
||||||
public static native void glFlushVertexArrayRangeNV();
|
public static native void glFlushVertexArrayRangeNV();
|
||||||
|
|
||||||
|
|
|
@ -18,9 +18,9 @@ static void JNICALL Java_org_lwjgl_opengl_NVVertexArrayRange_nglFreeMemoryNV(JNI
|
||||||
glFreeMemoryNV(pointer_address);
|
glFreeMemoryNV(pointer_address);
|
||||||
}
|
}
|
||||||
|
|
||||||
static jobject JNICALL Java_org_lwjgl_opengl_NVVertexArrayRange_glAllocateMemoryNV(JNIEnv *env, jclass clazz, jint size, jfloat readFrequency, jfloat writeFrequency, jfloat priority, jint result_size) {
|
static jobject JNICALL Java_org_lwjgl_opengl_NVVertexArrayRange_glAllocateMemoryNV(JNIEnv *env, jclass clazz, jint size, jfloat readFrequency, jfloat writeFrequency, jfloat priority) {
|
||||||
GLvoid * __result = glAllocateMemoryNV(size, readFrequency, writeFrequency, priority);
|
GLvoid * __result = glAllocateMemoryNV(size, readFrequency, writeFrequency, priority);
|
||||||
return safeNewBuffer(env, __result, result_size);
|
return safeNewBuffer(env, __result, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void JNICALL Java_org_lwjgl_opengl_NVVertexArrayRange_glFlushVertexArrayRangeNV(JNIEnv *env, jclass clazz) {
|
static void JNICALL Java_org_lwjgl_opengl_NVVertexArrayRange_glFlushVertexArrayRangeNV(JNIEnv *env, jclass clazz) {
|
||||||
|
|
|
@ -194,45 +194,51 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_AWTGLCanvas_nMakeCurrent
|
||||||
* Signature: ()V
|
* Signature: ()V
|
||||||
*/
|
*/
|
||||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_AWTGLCanvas_nDestroyContext
|
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_AWTGLCanvas_nDestroyContext
|
||||||
(JNIEnv *env, jobject awtglcanvas)
|
(JNIEnv *env, jobject canvas)
|
||||||
{
|
{
|
||||||
// 1. Get the context
|
JAWT awt;
|
||||||
HGLRC hglrc = getContext(env, awtglcanvas);
|
JAWT_DrawingSurface* ds;
|
||||||
HWND hwnd = getHWND(env, awtglcanvas);
|
JAWT_DrawingSurfaceInfo* dsi;
|
||||||
HDC hdc;
|
JAWT_Win32DrawingSurfaceInfo* dsi_win;
|
||||||
|
jboolean result;
|
||||||
|
HGLRC hglrc;
|
||||||
|
BOOL mcResult;
|
||||||
|
LPVOID lpMsgBuf;
|
||||||
|
jclass cls_AWTGLCanvas;
|
||||||
|
jmethodID mid_doPaint;
|
||||||
|
|
||||||
// Check to ensure it's the current context for this thread
|
// Get the AWT
|
||||||
// (it should be!)
|
awt.version = JAWT_VERSION_1_4;
|
||||||
if (hglrc = wglGetCurrentContext()) {
|
result = JAWT_GetAWT(env, &awt);
|
||||||
|
if (result == JNI_FALSE) {
|
||||||
|
throwGeneralException(env, "java/lang/RuntimeException", "Failed get AWT.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// obtain its associated device context
|
// Get the drawing surface
|
||||||
HDC hdc = wglGetCurrentDC() ;
|
ds = awt.GetDrawingSurface(env, canvas);
|
||||||
|
if (ds == NULL) {
|
||||||
|
throwGeneralException(env, "java/lang/RuntimeException", "Failed get drawing surface.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the drawing surface info
|
||||||
|
dsi = ds->GetDrawingSurfaceInfo(ds);
|
||||||
|
|
||||||
|
// Get the platform-specific drawing info
|
||||||
|
dsi_win = (JAWT_Win32DrawingSurfaceInfo*)dsi->platformInfo;
|
||||||
|
|
||||||
|
hglrc = getContext(env, canvas);
|
||||||
// make the rendering context not current
|
// make the rendering context not current
|
||||||
wglMakeCurrent(NULL, NULL) ;
|
wglMakeCurrent(NULL, NULL) ;
|
||||||
|
|
||||||
// release the device context
|
|
||||||
ReleaseDC (hwnd, hdc) ;
|
|
||||||
|
|
||||||
// delete the rendering context
|
// delete the rendering context
|
||||||
wglDeleteContext(hglrc);
|
wglDeleteContext(hglrc);
|
||||||
|
|
||||||
} else {
|
// Free the drawing surface info
|
||||||
throwException(env, "Could not destroy context: not current");
|
ds->FreeDrawingSurfaceInfo(dsi);
|
||||||
}
|
|
||||||
}
|
// Free the drawing surface
|
||||||
/*
|
awt.FreeDrawingSurface(ds);
|
||||||
* Class: org_lwjgl_opengl_AWTGLCanvas
|
|
||||||
* Method: nSwapBuffers
|
|
||||||
* Signature: ()V
|
|
||||||
*/
|
|
||||||
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_AWTGLCanvas_nSwapBuffers
|
|
||||||
(JNIEnv *env, jobject awtglcanvas)
|
|
||||||
{
|
|
||||||
HWND hwnd = getHWND(env, awtglcanvas);
|
|
||||||
HDC hdc = GetDC(hwnd);
|
|
||||||
SwapBuffers(hdc);
|
|
||||||
ReleaseDC(hwnd, hdc);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue