Added GLX_ARB_multisample support to Pbuffers
This commit is contained in:
parent
3122d0b1ba
commit
5c3e17c8a3
|
@ -81,9 +81,11 @@ public class Pbuffer {
|
||||||
* @param alpha Minimum bits per pixel in alpha buffer
|
* @param alpha Minimum bits per pixel in alpha buffer
|
||||||
* @param depth Minimum bits per pixel in depth buffer
|
* @param depth Minimum bits per pixel in depth buffer
|
||||||
* @param stencil Minimum bits per pixel in stencil 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 {
|
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);
|
handle = nCreate(width, height, bpp, alpha, depth, stencil, samples);
|
||||||
vbo_tracker = new VBOTracker();
|
vbo_tracker = new VBOTracker();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,7 +152,8 @@ public class Pbuffer {
|
||||||
int bpp,
|
int bpp,
|
||||||
int alpha,
|
int alpha,
|
||||||
int depth,
|
int depth,
|
||||||
int stencil) throws Exception;
|
int stencil,
|
||||||
|
int samples) throws Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destroys the Pbuffer. The buffer must not be current.
|
* Destroys the Pbuffer. The buffer must not be current.
|
||||||
|
|
|
@ -234,7 +234,7 @@ public class PbufferTest {
|
||||||
|
|
||||||
private void initPbuffer() {
|
private void initPbuffer() {
|
||||||
try {
|
try {
|
||||||
pbuffer = new Pbuffer(512, 512, mode.bpp, 0, 0, 0);
|
pbuffer = new Pbuffer(512, 512, mode.bpp, 0, 0, 0, 0);
|
||||||
pbuffer.makeCurrent();
|
pbuffer.makeCurrent();
|
||||||
initGLState(256, 256, 0.5f);
|
initGLState(256, 256, 0.5f);
|
||||||
GL11.glBindTexture(GL11.GL_TEXTURE_2D, tex_handle);
|
GL11.glBindTexture(GL11.GL_TEXTURE_2D, tex_handle);
|
||||||
|
|
|
@ -45,10 +45,10 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_Pbuffer_getPbufferCaps
|
||||||
/*
|
/*
|
||||||
* Class: org_lwjgl_opengl_Pbuffer
|
* Class: org_lwjgl_opengl_Pbuffer
|
||||||
* Method: nCreate
|
* Method: nCreate
|
||||||
* Signature: (IIIIII)I
|
* Signature: (IIIIIII)I
|
||||||
*/
|
*/
|
||||||
JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_Pbuffer_nCreate
|
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
|
* Class: org_lwjgl_opengl_Pbuffer
|
||||||
|
|
|
@ -80,10 +80,10 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_Pbuffer_getPbufferCaps
|
||||||
* Signature: (IIII)I
|
* Signature: (IIII)I
|
||||||
*/
|
*/
|
||||||
JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_Pbuffer_nCreate
|
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);
|
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_DOUBLEBUFFER, False,
|
||||||
GLX_RED_SIZE, bpe,
|
GLX_RED_SIZE, bpe,
|
||||||
GLX_GREEN_SIZE, bpe,
|
GLX_GREEN_SIZE, bpe,
|
||||||
|
@ -92,8 +92,16 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_Pbuffer_nCreate
|
||||||
GLX_DEPTH_SIZE, depth,
|
GLX_DEPTH_SIZE, depth,
|
||||||
GLX_STENCIL_SIZE, stencil,
|
GLX_STENCIL_SIZE, stencil,
|
||||||
GLX_DRAWABLE_TYPE, GLX_PBUFFER_BIT,
|
GLX_DRAWABLE_TYPE, GLX_PBUFFER_BIT,
|
||||||
|
None, None, /* for ARB_multisample */
|
||||||
|
None, None, /* */
|
||||||
None};
|
None};
|
||||||
int num_configs;
|
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);
|
GLXFBConfig *configs = glXChooseFBConfig(getCurrentDisplay(), getCurrentScreen(), attrib_list, &num_configs);
|
||||||
if (num_configs == 0) {
|
if (num_configs == 0) {
|
||||||
XFree(configs);
|
XFree(configs);
|
||||||
|
|
|
@ -65,7 +65,7 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_Pbuffer_getPbufferCaps(JNIEnv *env,
|
||||||
return 0;
|
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;
|
/* CGLPixelFormatObj pixel_format;
|
||||||
CGLContextObj context;
|
CGLContextObj context;
|
||||||
int dummy;
|
int dummy;
|
||||||
|
|
|
@ -68,7 +68,7 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_Pbuffer_getPbufferCaps
|
||||||
* Signature: (IIII)I
|
* Signature: (IIII)I
|
||||||
*/
|
*/
|
||||||
JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_Pbuffer_nCreate
|
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;
|
int iPixelFormat;
|
||||||
unsigned int num_formats_returned;
|
unsigned int num_formats_returned;
|
||||||
|
|
Loading…
Reference in New Issue