Main Menu

GL constants

Started by Qudus, July 14, 2008, 09:48:21

Previous topic - Next topic

Qudus

hi

I just wanted to ask, I I can assume, that all the static GL_NEAREST, GL_LUMINANCE, etc. constants from the GL11, GL12, etc. classes will have the same values in JOGL or other OpenGL layers. I guess, the values are actually defined in the OpenGL specification and must therefore be the same in a Java layer. But I wanted to make sure :).

Marvin

Qudus

I have written a small testcase, that tests most of the constants. They are all equal. So, everything is fine.

Here is the testcase'es code, if anyone cares:
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;

import javax.media.opengl.GL;

import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import org.lwjgl.opengl.GL13;
import org.lwjgl.opengl.GL14;
import org.lwjgl.opengl.GL15;
import org.lwjgl.opengl.GL20;
import org.lwjgl.opengl.GL21;

public class GLConstantsTest
{
    public GLConstantsTest() throws Throwable
    {
        int equalFields = 0;
        int notEqualFields = 0;
        
        for ( Field field1 : GL.class.getFields() )
        {
            if ( ( ( field1.getModifiers() & Modifier.PUBLIC ) != 0 ) && field1.getName().startsWith( "GL_" ) && ( field1.getType() == int.class ) )
            {
                try
                {
                    Field field2 = GL11.class.getField( field1.getName() );
                    //Field field2 = GL12.class.getField( field1.getName() );
                    //Field field2 = GL13.class.getField( field1.getName() );
                    //Field field2 = GL14.class.getField( field1.getName() );
                    //Field field2 = GL15.class.getField( field1.getName() );
                    //Field field2 = GL20.class.getField( field1.getName() );
                    //Field field2 = GL21.class.getField( field1.getName() );
                    
                    int v1 = field1.getInt( null );
                    int v2 = field2.getInt( null );
                    
                    if ( v1 == v2 )
                    {
                        equalFields++;
                    }
                    else
                    {
                        System.out.println( field1.getName() + ": " + v1 + ", " + v2 );
                        
                        notEqualFields++;
                    }
                }
                catch ( NoSuchFieldException e )
                {
                    
                }
            }
        }
        
        System.out.println( "equal fields: " + equalFields );
        System.out.println( "not equal fields: " + notEqualFields );
    }
}


Marvin