LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: Antiveganer on March 11, 2005, 09:19:58

Title: Newbie: How to create a Pixel Unpack Buffer?
Post by: Antiveganer on March 11, 2005, 09:19:58
I am working with my opengl book and im trying to code the examples. I tried to create a stippled Polygon with this code:

public void render(){
               glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);  
               glLoadIdentity();
               glTranslatef(0,0,-5);
               
               glEnable(GL_POLYGON_SMOOTH);
               glEnable(GL_POLYGON_STIPPLE);
             
               
               glPolygonStipple(0xAAAA);
               glBegin(GL_POLYGON);
               {
                   glVertex3f(0f,1f,0f);
                   glVertex3f(-1f,-1f,0f);
                   glVertex3f(1f,-1f,0f);
                   glVertex3f(1f,0f,0f);
               }
               glEnd();
}

But when trying to run it i get the following error in line glPolygonStipple(0xAAAA);

Exception in thread "main" org.lwjgl.opengl.OpenGLException: Cannot use offsets when Pixel Unpack Buffer Object is disabled
at org.lwjgl.opengl.GLBufferChecks.ensureUnpackPBOenabled(GLBufferChecks.java:98)
at org.lwjgl.opengl.GL11.glPolygonStipple(GL11.java:1276)
at Test.<init>(Test.java:47)
at Test.main(Test.java:98)

Thanks for your help!
freddy[/code]
Title: Newbie: How to create a Pixel Unpack Buffer?
Post by: spasi on March 11, 2005, 10:12:43
PolygonStipple requires a byte buffer, with 32x32 values. With PBO, you can also specify a pixel buffer offset, which is why a method with an int argument also exists.
Title: Newbie: How to create a Pixel Unpack Buffer?
Post by: Antiveganer on March 11, 2005, 10:14:15
Well that makes sense.. im gonna try it with a bytebuffer then... thanks a lot
edit: it works perfectly