diff --git a/src/java/org/lwjgl/opengl/Pbuffer.java b/src/java/org/lwjgl/opengl/Pbuffer.java index 8ddd47b0..02eb4e33 100644 --- a/src/java/org/lwjgl/opengl/Pbuffer.java +++ b/src/java/org/lwjgl/opengl/Pbuffer.java @@ -81,9 +81,11 @@ public class Pbuffer { * @param alpha Minimum bits per pixel in alpha buffer * @param depth Minimum bits per pixel in depth buffer * @param stencil Minimum bits per pixel in stencil buffer + * @param samples Minimum samples in multisample buffer (corresponds to GL_SAMPLES_ARB in GL_ARB_multisample spec). + Pass 0 to disable multisampling. This parameter is ignored if GL_ARB_multisample is not supported. */ - public Pbuffer(int width, int height, int bpp, int alpha, int depth, int stencil) throws Exception { - handle = nCreate(width, height, bpp, alpha, depth, stencil); + public Pbuffer(int width, int height, int bpp, int alpha, int depth, int stencil, int samples) throws Exception { + handle = nCreate(width, height, bpp, alpha, depth, stencil, samples); vbo_tracker = new VBOTracker(); } @@ -150,7 +152,8 @@ public class Pbuffer { int bpp, int alpha, int depth, - int stencil) throws Exception; + int stencil, + int samples) throws Exception; /** * Destroys the Pbuffer. The buffer must not be current. diff --git a/src/java/org/lwjgl/test/opengl/PbufferTest.java b/src/java/org/lwjgl/test/opengl/PbufferTest.java index b43be0ad..641b801c 100644 --- a/src/java/org/lwjgl/test/opengl/PbufferTest.java +++ b/src/java/org/lwjgl/test/opengl/PbufferTest.java @@ -234,7 +234,7 @@ public class PbufferTest { private void initPbuffer() { try { - pbuffer = new Pbuffer(512, 512, mode.bpp, 0, 0, 0); + pbuffer = new Pbuffer(512, 512, mode.bpp, 0, 0, 0, 0); pbuffer.makeCurrent(); initGLState(256, 256, 0.5f); GL11.glBindTexture(GL11.GL_TEXTURE_2D, tex_handle); diff --git a/src/native/common/org_lwjgl_opengl_Pbuffer.h b/src/native/common/org_lwjgl_opengl_Pbuffer.h index 9a82ac90..59238a52 100644 --- a/src/native/common/org_lwjgl_opengl_Pbuffer.h +++ b/src/native/common/org_lwjgl_opengl_Pbuffer.h @@ -45,10 +45,10 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_Pbuffer_getPbufferCaps /* * Class: org_lwjgl_opengl_Pbuffer * Method: nCreate - * Signature: (IIIIII)I + * Signature: (IIIIIII)I */ JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_Pbuffer_nCreate - (JNIEnv *, jclass, jint, jint, jint, jint, jint, jint); + (JNIEnv *, jclass, jint, jint, jint, jint, jint, jint, jint); /* * Class: org_lwjgl_opengl_Pbuffer diff --git a/src/native/linux/org_lwjgl_opengl_Pbuffer.cpp b/src/native/linux/org_lwjgl_opengl_Pbuffer.cpp index 8edd3f82..92844bec 100644 --- a/src/native/linux/org_lwjgl_opengl_Pbuffer.cpp +++ b/src/native/linux/org_lwjgl_opengl_Pbuffer.cpp @@ -80,10 +80,10 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_Pbuffer_getPbufferCaps * Signature: (IIII)I */ JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_Pbuffer_nCreate - (JNIEnv *env, jclass clazz, jint width, jint height, jint bpp, jint alpha, jint depth, jint stencil) + (JNIEnv *env, jclass clazz, jint width, jint height, jint bpp, jint alpha, jint depth, jint stencil, jint samples) { int bpe = convertToBPE(bpp); - const int attrib_list[] = {GLX_RENDER_TYPE, GLX_RGBA_BIT, + int attrib_list[] = {GLX_RENDER_TYPE, GLX_RGBA_BIT, GLX_DOUBLEBUFFER, False, GLX_RED_SIZE, bpe, GLX_GREEN_SIZE, bpe, @@ -92,8 +92,16 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_Pbuffer_nCreate GLX_DEPTH_SIZE, depth, GLX_STENCIL_SIZE, stencil, GLX_DRAWABLE_TYPE, GLX_PBUFFER_BIT, + None, None, /* for ARB_multisample */ + None, None, /* */ None}; int num_configs; + if (samples > 0 && extgl_Extensions.GLX_ARB_multisample) { + attrib_list[18] = GLX_SAMPLE_BUFFERS_ARB; + attrib_list[19] = 1; + attrib_list[20] = GLX_SAMPLES_ARB; + attrib_list[21] = samples; + } GLXFBConfig *configs = glXChooseFBConfig(getCurrentDisplay(), getCurrentScreen(), attrib_list, &num_configs); if (num_configs == 0) { XFree(configs); diff --git a/src/native/macosx/org_lwjgl_opengl_Pbuffer.cpp b/src/native/macosx/org_lwjgl_opengl_Pbuffer.cpp index 98d2510b..fbab57dc 100644 --- a/src/native/macosx/org_lwjgl_opengl_Pbuffer.cpp +++ b/src/native/macosx/org_lwjgl_opengl_Pbuffer.cpp @@ -65,7 +65,7 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_Pbuffer_getPbufferCaps(JNIEnv *env, return 0; } -JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_Pbuffer_nCreate(JNIEnv *env, jclass clazz, jint width, jint height, jint bpp, jint alpha, jint depth, jint stencil) { +JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_Pbuffer_nCreate(JNIEnv *env, jclass clazz, jint width, jint height, jint bpp, jint alpha, jint depth, jint stencil, jint samples) { /* CGLPixelFormatObj pixel_format; CGLContextObj context; int dummy; diff --git a/src/native/win32/org_lwjgl_opengl_Pbuffer.cpp b/src/native/win32/org_lwjgl_opengl_Pbuffer.cpp index 1b21503b..90d8c9d7 100755 --- a/src/native/win32/org_lwjgl_opengl_Pbuffer.cpp +++ b/src/native/win32/org_lwjgl_opengl_Pbuffer.cpp @@ -68,7 +68,7 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_Pbuffer_getPbufferCaps * Signature: (IIII)I */ JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_Pbuffer_nCreate - (JNIEnv *env, jclass clazz, jint width, jint height, jint bpp, jint alpha, jint depth, jint stencil) + (JNIEnv *env, jclass clazz, jint width, jint height, jint bpp, jint alpha, jint depth, jint stencil, jint samples) { int iPixelFormat; unsigned int num_formats_returned;