OpenGL 4 Tessellation Doesn't Work

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

OpenGL 4 Tessellation Doesn't Work

Remco47
Hi, I have a problem with OpenGL 4 tessellation. I draw 4 vertices in GL_PATCHES mode, with GL_PATCH_VERTICES set to 4 and all the default levels set to 64. I expect OpenGL to recognize the vertices as a quad, and subdivide it into 64 by 64 quads. For some reason, all that appears on screen is 4 points. Below is a small test case:

import java.awt.*;
import java.awt.event.*;
import javax.media.opengl.*;
import javax.media.opengl.awt.*;

public class TessellatorTest implements GLEventListener {
    public TessellatorTest()
    {
        GLProfile profile = GLProfile.get(GLProfile.GL4bc);
        GLCapabilities caps = new GLCapabilities(profile);
        GLCanvas canvas = new GLCanvas(caps);
        canvas.addGLEventListener(this);
       
        Frame frame = new Frame("Hello world!");
        frame.add(canvas);
        frame.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) { System.exit(0); }
        });
        frame.setSize(500, 500);
        frame.setResizable(false);
        frame.setVisible(true);
    }

    public static void main(String[] args) {
        new TessellatorTest();
    }

    public void display(GLAutoDrawable drawable) {
        GL4bc gl = drawable.getGL().getGL4bc();

        gl.glPolygonMode(GL4bc.GL_FRONT, GL4bc.GL_LINE);
        gl.glPatchParameteri(GL4bc.GL_PATCH_VERTICES, 4);
        gl.glPatchParameterfv(GL4bc.GL_PATCH_DEFAULT_OUTER_LEVEL, new float[]{ 64, 64, 64, 64 }, 0);
        gl.glPatchParameterfv(GL4bc.GL_PATCH_DEFAULT_INNER_LEVEL, new float[]{ 64, 64 }, 0);
        gl.glBegin(GL4bc.GL_PATCHES);
        gl.glVertex3f(-0.8f, -0.8f, 0);
        gl.glVertex3f( 0.8f, -0.8f, 0);
        gl.glVertex3f( 0.8f,  0.8f, 0);
        gl.glVertex3f(-0.8f,  0.8f, 0);
        gl.glEnd();
    }

    public void init(GLAutoDrawable a){}
    public void reshape(GLAutoDrawable a, int b, int c, int d, int e){}
    public void dispose(GLAutoDrawable a){}
}
Reply | Threaded
Open this post in threaded view
|

Re: OpenGL 4 Tessellation Doesn't Work

Job Zwiers
Hi,

I think patch parameters etcetera apply to tesselation shaders. But your program does use no (programmable)  shaders at all, so it will use the fixed function pipeline from OpenGL 2.1.  An that does not include tesselation as far as I know.
Reply | Threaded
Open this post in threaded view
|

Re: OpenGL 4 Tessellation Doesn't Work

Remco47
Thanks for your reply. It seems my simple example was a tad too simple. I solved the actual problem in my original code. It was a linking error. To everyone who doesn't seem to get things working: do not only check for GLSL compilation errors; you must also check for linking errors.