Java-Gaming.org Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (761)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (845)
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 4163 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 (347 views)
2018-06-10 19:43:48

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

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

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

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

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

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

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

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

Solater (400 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05
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!