JOGL + Nvidia Cg - Can't set other Fragment Profiles except for ARBFP1

Hello folks

I’m trying to use Cg fragment programs with my code but
I can’t set any profile beside ARBFP1. I have a Radeon 9800 Pro
Card which should support ps20 and it works perfectly with the
C++ implementation of Cg. What am I doing wrong?

Are you sure you’re setting up and using your Cg context while an OpenGL context is current (i.e., in your GLEventListener’s init() or display() method)?

Could you post a small test case?

Here is a minimum example:



package video.filter.cg;


import com.sun.opengl.*;
import com.sun.opengl.cg.*;
import com.sun.opengl.util.*;
import javax.swing.*;
import javax.media.opengl.*;
import javax.media.opengl.glu.*;

import java.awt.*;
import java.awt.image.*;
import java.awt.event.*;
import java.io.*;

import javax.imageio.*;

import util.*;

/**
 * cgGL_vertex_example: simple demo of Nvidia CgGL API. Based upon C version
 * distributed with the NVidia Cg Toolkit. Ported to the Java language by
 * Christopher Kline 5/29/2003.
 */
public class cgext implements GLEventListener 
{
  
  /******************************************************************************/
  /*** Static Data                                                            ***/
  /******************************************************************************/

  private final int TextureRes = 512;
  
  private static CGcontext Context = null;
  private static CGprogram vertexProgram = null;
  private static CGprogram fragmentProgram = null;
  private static CGparameter KdParam = null;
  private static CGparameter ModelViewProjParam = null;
  private static CGparameter TestColorParam = null;
  private static CGparameter colorParam = null;
  private static /*CGprofile*/ int vertexprofile;
  private static /*CGprofile*/ int fragmentprofile;
  
  
  public ImageDisplayFrame imdisplay = new ImageDisplayFrame();

 
  public void display(GLAutoDrawable drawable) 
  {  
  }

  public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged)
  {
  }

  public void init(GLAutoDrawable drawable) 
  {  
	GL gl = drawable.getGL();
	GLU glu = new GLU();
	vGLSubsystem.init(gl,352,288);

    Context = CgGL.cgCreateContext();
    
    vertexprofile = CgGL.cgGLGetLatestProfile(CgGL.CG_GL_VERTEX);
    fragmentprofile = CgGL.cgGLGetLatestProfile(CgGL.CG_GL_FRAGMENT);
    
    System.out.println("The latest fragment profile is: " +fragmentprofile); 
  }

  public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height)
  {
	  
  }

  public static void main(String[] argv)
  {    
    Frame frame = new Frame("NVidia Cg Toolkit \"cgGL_vertex_example\" demo");
   
    GLCanvas canvas = new GLCanvas(new GLCapabilities());
    
    
    canvas.addGLEventListener(new cgext());

    frame.add(canvas);
    frame.setSize(800, 400);
    
    final Animator animator = new Animator(canvas);
    frame.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
          // Run this on another thread than the AWT event queue to
          // make sure the call to Animator.stop() completes before
          // exiting
          new Thread(new Runnable() {
              public void run() {
                animator.stop();
                System.exit(0);
              }
            }).start();
        }
      });
    frame.setVisible(true);
    
    
    animator.start();
  }

}   



This is what vGLSubsystem.init(gl,352,288) does:


public static void init(GL globj,int iWidth,int iHeight)
	{
		gl = globj;
		gl.glClearColor (0.0f, 0.0f, 0.0f, 0.0f);
		gl.glShadeModel(GL.GL_FLAT);
		gl.glEnable(GL.GL_DEPTH_TEST);
		
		imageWidth = iWidth;
		imageHeight = iHeight;
		
		if( imageWidth < 1 || imageHeight < 1)
		{
		    System.out.println("Fehler: Bildhöhe und Bildbreite <= 0");
		    System.exit(1);
		}
		
		initExtension(gl, "GL_ARB_multitexture");
		
		textureIndices = new int[MAX_FILTERS];
	    gl.glGenTextures(10, textureIndices,0);
	    
	    hasInited = true;
	}

The output of the proc should be:

The latest fragment profile is: 7000

Whick corresponds to CG_PROFILE_ARBFP1

Thinking about this more, isn’t ps20 a Direct3D profile? That would explain why it isn’t accessible from the OpenGL Cg implementation.

Is it possible that the Radeon 9800 Pro doesn’t support better profiles than arbfp1?

I think it is possible in particular for the OpenGL Cg implementation.

What graphics board are you using? Whats your best fragment profile with jogl-cg?

I have an NVidia Quadro FX Go700, which is a notebook chip from a few years back. Your test program reports CG_PROFILE_FP30 as the latest profile on my card. As I recall this is an NVidia-specific profile which is why it wouldn’t be showing up on your ATI card. CG_PROFILE_ARBFP1 and ARBVP1 should be pretty feature complete and support techniques like HDR (see the demo on the jogl-demos page, which uses GL_ARB_fragment_program) so unless you’re doing something esoteric I would suggest you try them.

Do you have a list with the capabilities of the different profiles?

I need to know the maximum number of commands and texture reads with arbfp1
which seems to be ~20 from the tests I made.

I don’t. I’d recommend you try posting on the forums on opengl.org or becoming a registered developer on NVidia’s web site and posting on their forums there.

Seems like it. Thanks anyways.