Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (768)
Games in Android Showcase (230)
games submitted by our members
Games in WIP (854)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  [solved][lwjgl] FBO stencil buffer not working on intel card  (Read 4212 times)
0 Members and 1 Guest are viewing this topic.
Offline roland
« Posted 2014-10-10 10:04:24 »

So now the shaders run fine, I just need to fix a problem with my FBOs - normal ones work fine however but I just can't get the stencil buffer to work with them (It works fine on my ATI card but not my intel HD 4000).

I've been looking over the internet for hours and trying different techniques to create the FBO that would work on both intel and ATI but I'm stumped. Can anyone help me?

My FBO creation code is below
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
frameBufferID = EXTFramebufferObject.glGenFramebuffersEXT();
EXTFramebufferObject.glBindFramebufferEXT( EXTFramebufferObject.GL_FRAMEBUFFER_EXT, frameBufferID );
EXTFramebufferObject.glFramebufferTexture2DEXT( EXTFramebufferObject.GL_FRAMEBUFFER_EXT, EXTFramebufferObject.GL_COLOR_ATTACHMENT0_EXT, GL11.GL_TEXTURE_2D, textureID, 0);

if (attachStencilBuffer)
{
   renderBufferID = EXTFramebufferObject.glGenRenderbuffersEXT();
   //System.out.println("Stencil buffer ID: " + stencilBufferID);
   EXTFramebufferObject.glBindRenderbufferEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT, renderBufferID);
   EXTFramebufferObject.glRenderbufferStorageEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT, EXTPackedDepthStencil.GL_DEPTH_STENCIL_EXT, width, height);

   //bind the same buffer twice: once as depth buffer, once as stencil
   EXTFramebufferObject.glFramebufferRenderbufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT,EXTFramebufferObject.GL_DEPTH_ATTACHMENT_EXT,EXTFramebufferObject.GL_RENDERBUFFER_EXT, renderBufferID);
   EXTFramebufferObject.glFramebufferRenderbufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT,EXTFramebufferObject.GL_STENCIL_ATTACHMENT_EXT,EXTFramebufferObject.GL_RENDERBUFFER_EXT, renderBufferID);
}

int status = EXTFramebufferObject.glCheckFramebufferStatusEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT);
switch (status)
{
case EXTFramebufferObject.GL_FRAMEBUFFER_COMPLETE_EXT:
   valid = true; //<--- gets to here
   break;
default:
   System.err.println(getFBOErrorStatus(status));
}

EXTFramebufferObject.glBindFramebufferEXT( EXTFramebufferObject.GL_FRAMEBUFFER_EXT, 0);
EXTFramebufferObject.glBindRenderbufferEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT, 0);



Pre-Rendering setup:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
EXTFramebufferObject.glBindFramebufferEXT( EXTFramebufferObject.GL_FRAMEBUFFER_EXT, frameBufferID);
if (attachStencilBuffer)
   EXTFramebufferObject.glBindRenderbufferEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT, renderBufferID);
GL11.glPushAttrib(GL11.GL_VIEWPORT_BIT);
GL11.glViewport( 0, 0, width, height );

GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glLoadIdentity();

GL11.glOrtho(0, width, 0, height, -1, 1);
GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glLoadIdentity();

if (clear)
   GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);


Post-Render:
1  
2  
3  
4  
5  
6  
7  
8  
9  
EXTFramebufferObject.glBindFramebufferEXT( EXTFramebufferObject.GL_FRAMEBUFFER_EXT, 0);
EXTFramebufferObject.glBindRenderbufferEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT, 0);
GL11.glPopAttrib();

GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glLoadIdentity();
GL11.glOrtho(0, Display.getWidth(), Display.getHeight(), 0, -1, 1);
GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glLoadIdentity();

Offline roland
« Reply #1 - Posted 2014-10-11 11:16:49 »

Actually the code above works fine. My problem was that I didn't set GL11.glStencilMask(1); before using the stencil buffer and GL11.glStencilMask(0); afterward. Not sure why It was only necessary in that exact situation but I'm glad it works Smiley

From the answer here:
http://stackoverflow.com/questions/8861736/opengl-stencil-buffer-not-quite-got-it-working
Pages: [1]
  ignore  |  Print  
 
 

 
EgonOlsen (1328 views)
2018-06-10 19:43:48

EgonOlsen (1205 views)
2018-06-10 19:43:44

EgonOlsen (930 views)
2018-06-10 19:43:20

DesertCoockie (1371 views)
2018-05-13 18:23:11

nelsongames (1111 views)
2018-04-24 18:15:36

nelsongames (1359 views)
2018-04-24 18:14:32

ivj94 (2094 views)
2018-03-24 14:47:39

ivj94 (1251 views)
2018-03-24 14:46:31

ivj94 (2250 views)
2018-03-24 14:43:53

Solater (803 views)
2018-03-17 05:04:08
Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45

Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20

Deployment and Packaging
by philfrei
2018-08-19 23:54:46
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!