Results 1 to 3 of 3

Thread: Converting NVIDIA Code (PPL) for ATI Radeon Series (PPL)

  1. #1
    Senior Member Regular Contributor
    Join Date
    Jul 2000
    Location
    Arlon, Belgium
    Posts
    477

    Converting NVIDIA Code (PPL) for ATI Radeon Series (PPL)

    Hi,

    My Engine supports only Per Pixel Lightning for NIVIDIA Cards. I'd like to use PPL for ATI Radeon series too. But I don't have a ATI card so I need some help for converting my code for ATI users.

    Here's the first function for the NVIDIA Register Combiners.

    Code :
    // **********************************************
    bool Init_Register_Combiners()	// Register Combiners Initialisation
    {
    	// The name of the extension
    	char *Extension;
     
        Extension = (char *) glGetString(GL_EXTENSIONS);
     
        if (!(strstr(Extension, "GL_NV_register_combiners")) == 1)
    		{ 
    			// The "GL_NV_register_combiners" extension is not supported
    			MessageBox(NULL,"GL_NV_register_combiners","Extension not supported :",MB_ICONERROR);
     
    			return false;
    		} 
     
    	glCombinerParameterfvNV = (PFNGLCOMBINERPARAMETERFVNV) wglGetProcAddress("glCombinerParameterfvNV");
    	glCombinerParameterivNV = (PFNGLCOMBINERPARAMETERIVNV) wglGetProcAddress("glCombinerParameterivNV");
    	glCombinerParameterfNV  = (PFNGLCOMBINERPARAMETERFNV) wglGetProcAddress("glCombinerParameterfNV");
    	glCombinerParameteriNV  = (PFNGLCOMBINERPARAMETERINV) wglGetProcAddress("glCombinerParameteriNV");
    	glCombinerInputNV       = (PFNGLCOMBINERINPUTNV) wglGetProcAddress("glCombinerInputNV");
    	glCombinerOutputNV      = (PFNGLCOMBINEROUTPUTNV) wglGetProcAddress("glCombinerOutputNV");
    	glFinalCombinerInputNV  = (PFNGLFINALCOMBINERINPUTNV) wglGetProcAddress("glFinalCombinerInputNV");
     
    	glGetCombinerInputParameterfvNV      = (PFNGLGETCOMBINERINPUTPARAMETERFVNV) wglGetProcAddress("glGetCombinerInputParameterfvNV");
    	glGetCombinerInputParameterivNV      = (PFNGLGETCOMBINERINPUTPARAMETERIVNV) wglGetProcAddress("glGetCombinerInputParameterivNV");
    	glGetCombinerOutputParameterfvNV     = (PFNGLGETCOMBINEROUTPUTPARAMETERFVNV) wglGetProcAddress("glGetCombinerOutputParameterfvNV");
    	glGetCombinerOutputParameterivNV     = (PFNGLGETCOMBINEROUTPUTPARAMETERIVNV) wglGetProcAddress("glGetCombinerOutputParameterivNV");
    	glGetFinalCombinerInputParameterfvNV = (PFNGLGETFINALCOMBINERINPUTPARAMETERFVNV) wglGetProcAddress("glGetFinalCombinerInputParameterfvNV");
    	glGetFinalCombinerInputParameterivNV = (PFNGLGETFINALCOMBINERINPUTPARAMETERIVNV) wglGetProcAddress("glGetFinalCombinerInputParameterivNV");
     
    	return true;
    }
     
     
    // **********************************************
    void Setup_Register_Combiners()	// Setup the Register Combiners
    {
    	// Register Combiners Initialisation. We use 1 Register
    	glCombinerParameteriNV(GL_NUM_GENERAL_COMBINERS_NV, 1);
     
    	// Light Color
    	float Light_Color[] = { 1.0f, 1.0f, 1.0f, 1.0f };
     
    	// We give the Light Color params to the Register Combiners
    	glCombinerParameterfvNV(GL_CONSTANT_COLOR0_NV, (float *) &Light_Color);
     
    	// Register Combiners Calcul for the Light Attenuation
    	// ( 1 * Texture0 + 1 * Texture1)
    	glCombinerInputNV(GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_A_NV, GL_TEXTURE0_ARB, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
    	glCombinerInputNV(GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_B_NV, GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_RGB);
    	glCombinerInputNV(GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_C_NV, GL_TEXTURE1_ARB, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
    	glCombinerInputNV(GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_D_NV, GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_RGB);
    	glCombinerOutputNV(GL_COMBINER0_NV, GL_RGB, GL_DISCARD_NV, GL_DISCARD_NV, GL_SPARE0_NV, GL_NONE, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE);
     
    	// Final Register Combiners Initialisation with "(1 - Attenuation) * Color" calcul
    	glFinalCombinerInputNV(GL_VARIABLE_A_NV, GL_SPARE0_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
    	glFinalCombinerInputNV(GL_VARIABLE_B_NV, GL_ZERO, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
    	glFinalCombinerInputNV(GL_VARIABLE_C_NV, GL_CONSTANT_COLOR0_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
    	glFinalCombinerInputNV(GL_VARIABLE_D_NV, GL_ZERO, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
    	glFinalCombinerInputNV(GL_VARIABLE_G_NV, GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_ALPHA);
     
    	// We enable the Register Combiners
    	glEnable(GL_REGISTER_COMBINERS_NV);
     
    }

    Now, the Vertex Program function :

    Code :
    // **********************************************
    bool Init_Vertex_Program()
    {
     
    	// The name of the extension
    	char *Extension;
     
    	// We want to check a extension, so we do it
    	Extension = (char *) glGetString(GL_EXTENSIONS);
     
        if (!(strstr(Extension, "GL_NV_vertex_program")) == 1)
    		{ 
    			// The "GL_NV_vertex_program" extension is not supported
    			MessageBox(NULL,"GL_NV_vertex_program","Extension not supported :",MB_ICONERROR);
     
    			return false;
    		} 
     
    	glBindProgramNV				= (PFNGLBINDPROGRAMNV) wglGetProcAddress("glBindProgramNV");
    	glDeleteProgramsNV			= (PFNGLDELETEPROGRAMSNV) wglGetProcAddress("glDeleteProgramsNV");
    	glExecuteProgramNV			= (PFNGLEXECUTEPROGRAMNV) wglGetProcAddress("glExecuteProgramNV");
    	glGenProgramsNV				= (PFNGLGENPROGRAMSNV) wglGetProcAddress("glGenProgramsNV");
    	glAreProgramsResidentNV		= (PFNGLAREPROGRAMSRESIDENTNV) wglGetProcAddress("glAreProgramsResidentNV");
    	glRequestResidentProgramsNV = (PFNGLREQUESTRESIDENTPROGRAMSNV) wglGetProcAddress("glRequestResidentProgramsNV");
    	glGetProgramParameterfvNV	= (PFNGLGETPROGRAMPARAMETERFVNV) wglGetProcAddress("glGetProgramParameterfvNV");
    	glGetProgramParameterdvNV	= (PFNGLGETPROGRAMPARAMETERDVNV) wglGetProcAddress("glGetProgramParameterdvNV");
    	glGetProgramivNV			= (PFNGLGETPROGRAMIVNV) wglGetProcAddress("glGetProgramivNV");
    	glGetProgramStringNV		= (PFNGLGETPROGRAMSTRINGNV) wglGetProcAddress("glGetProgramStringNV");
    	glGetTrackMatrixivNV		= (PFNGLGETTRACKMATRIXIVNV) wglGetProcAddress("glGetTrackMatrixivNV");
    	glGetVertexAttribdvNV		= (PFNGLGETVERTEXATTRIBDVNV) wglGetProcAddress("glGetVerteexAttribdvNV");
    	glGetVertexAttribfvNV		= (PFNGLGETVERTEXATTRIBFVNV) wglGetProcAddress("glGetVertexAttribfvNV");
    	glGetVertexAttribivNV		= (PFNGLGETVERTEXATTRIBIVNV) wglGetProcAddress("glGetVertexAttribivNV");
    	glGetVertexAttribPointervNV = (PFNGLGETVERTEXATTRIBPOINTERVNV) wglGetProcAddress("glGetVertexAttribPointervNV");
    	glIsProgramNV				= (PFNGLISPROGRAMNV) wglGetProcAddress("glIsProgramNV");
    	glLoadProgramNV				= (PFNGLLOADPROGRAMNV) wglGetProcAddress("glLoadProgramNV");
    	glProgramParameter4fNV		= (PFNGLPROGRAMPARAMETER4FNV) wglGetProcAddress("glProgramParameter4fNV");
    	glProgramParameter4dNV		= (PFNGLPROGRAMPARAMETER4DNV) wglGetProcAddress("glProgramParameter4dNV");
    	glProgramParameter4dvNV		= (PFNGLPROGRAMPARAMETER4DVNV) wglGetProcAddress("glProgramParameter4dvNV");
    	glProgramParameter4fvNV		= (PFNGLPROGRAMPARAMETER4FVNV) wglGetProcAddress("glProgramParameter4fvNV");
    	glProgramParameters4dvNV	= (PFNGLPROGRAMPARAMETERS4DVNV) wglGetProcAddress("glProgramParameters4dvNV");
    	glProgramParameters4fvNV	= (PFNGLPROGRAMPARAMETERS4FVNV) wglGetProcAddress("glProgramParameters4fvNV");
    	glTrackMatrixNV				= (PFNGLTRACKMATRIXNV) wglGetProcAddress("glTrackMatrixNV");	
     
     
    	glVertexAttribPointerNV = (PFNGLVERTEXATTRIBPOINTERNV) wglGetProcAddress("glVertexAttribPointerNV");
    	glVertexAttrib1sNV		= (PFNGLVERTEXATTRIB1SNV) wglGetProcAddress("glVertexAttrib1sNV");
    	glVertexAttrib1fNV		= (PFNGLVERTEXATTRIB1FNV) wglGetProcAddress("glVertexAttrib1fNV");
    	glVertexAttrib1dNV		= (PFNGLVERTEXATTRIB1DNV) wglGetProcAddress("glVertexAttrib1dNV");
    	glVertexAttrib2sNV		= (PFNGLVERTEXATTRIB2SNV) wglGetProcAddress("glVertexAttrib2sNV");
    	glVertexAttrib2fNV		= (PFNGLVERTEXATTRIB2FNV) wglGetProcAddress("glVertexAttrib2fNV");
    	glVertexAttrib2dNV		= (PFNGLVERTEXATTRIB2DNV) wglGetProcAddress("glVertexAttrib2dNV");
    	glVertexAttrib3sNV		= (PFNGLVERTEXATTRIB3SNV) wglGetProcAddress("glVertexAttrib3sNV");
    	glVertexAttrib3fNV		= (PFNGLVERTEXATTRIB3FNV) wglGetProcAddress("glVertexAttrib3fNV");
    	glVertexAttrib3dNV		= (PFNGLVERTEXATTRIB3DNV) wglGetProcAddress("glVertexAttrib3dNV");
    	glVertexAttrib4sNV		= (PFNGLVERTEXATTRIB4SNV) wglGetProcAddress("glVertexAttrib4sNV");
    	glVertexAttrib4fNV		= (PFNGLVERTEXATTRIB4FNV) wglGetProcAddress("glVertexAttrib4fNV");
    	glVertexAttrib4dNV		= (PFNGLVERTEXATTRIB4DNV) wglGetProcAddress("glVertexAttrib4dNV");
    	glVertexAttrib4ubNV		= (PFNGLVERTEXATTRIB4UBNV) wglGetProcAddress("glVertexAttrib4ubNV");
    	glVertexAttrib1svNV		= (PFNGLVERTEXATTRIB1SVNV) wglGetProcAddress("glVertexAttrib1svNV");
    	glVertexAttrib1fvNV		= (PFNGLVERTEXATTRIB1FVNV) wglGetProcAddress("glVertexAttrib1fvNV");
    	glVertexAttrib1dvNV		= (PFNGLVERTEXATTRIB1DVNV) wglGetProcAddress("glVertexAttrib1dvNV");
    	glVertexAttrib2svNV		= (PFNGLVERTEXATTRIB2SVNV) wglGetProcAddress("glVertexAttrib2svNV");
    	glVertexAttrib2fvNV		= (PFNGLVERTEXATTRIB2FVNV) wglGetProcAddress("glVertexAttrib2fvNV");
    	glVertexAttrib2dvNV		= (PFNGLVERTEXATTRIB2DVNV) wglGetProcAddress("glVertexAttrib2dvNV");
    	glVertexAttrib3svNV		= (PFNGLVERTEXATTRIB3SVNV) wglGetProcAddress("glVertexAttrib3svNV");
    	glVertexAttrib3fvNV		= (PFNGLVERTEXATTRIB3FVNV) wglGetProcAddress("glVertexAttrib3fvNV");
    	glVertexAttrib3dvNV		= (PFNGLVERTEXATTRIB3DVNV) wglGetProcAddress("glVertexAttrib3dvNV");
    	glVertexAttrib4svNV		= (PFNGLVERTEXATTRIB4SVNV) wglGetProcAddress("glVertexAttrib4svNV");
    	glVertexAttrib4fvNV		= (PFNGLVERTEXATTRIB4FVNV) wglGetProcAddress("glVertexAttrib4fvNV");
    	glVertexAttrib4dvNV		= (PFNGLVERTEXATTRIB4DVNV) wglGetProcAddress("glVertexAttrib4dvNV");
    	glVertexAttrib4ubvNV	= (PFNGLVERTEXATTRIB4UBVNV) wglGetProcAddress("glVertexAttrib4ubvNV");
    	glVertexAttribs1svNV	= (PFNGLVERTEXATTRIBS1SVNV) wglGetProcAddress("glVertexAttribs1svNV");
    	glVertexAttribs1fvNV	= (PFNGLVERTEXATTRIBS1FVNV) wglGetProcAddress("glVertexAttribs1fvNV");
    	glVertexAttribs1dvNV	= (PFNGLVERTEXATTRIBS1DVNV) wglGetProcAddress("glVertexAttribs1dvNV");
    	glVertexAttribs2svNV	= (PFNGLVERTEXATTRIBS2SVNV) wglGetProcAddress("glVertexAttribs2svNV");
    	glVertexAttribs2fvNV	= (PFNGLVERTEXATTRIBS2FVNV) wglGetProcAddress("glVertexAttribs2fvNV");
    	glVertexAttribs2dvNV	= (PFNGLVERTEXATTRIBS2DVNV) wglGetProcAddress("glVertexAttribs2dvNV");
    	glVertexAttribs3svNV	= (PFNGLVERTEXATTRIBS3SVNV) wglGetProcAddress("glVertexAttribs3svNV");
    	glVertexAttribs3fvNV	= (PFNGLVERTEXATTRIBS3FVNV) wglGetProcAddress("glVertexAttribs3fvNV");
    	glVertexAttribs3dvNV	= (PFNGLVERTEXATTRIBS3DVNV) wglGetProcAddress("glVertexAttribs3dvNV");
    	glVertexAttribs4svNV	= (PFNGLVERTEXATTRIBS4SVNV) wglGetProcAddress("glVertexAttribs4svNV");
    	glVertexAttribs4fvNV	= (PFNGLVERTEXATTRIBS4FVNV) wglGetProcAddress("glVertexAttribs4fvNV");
    	glVertexAttribs4dvNV	= (PFNGLVERTEXATTRIBS4DVNV) wglGetProcAddress("glVertexAttribs4dvNV");
    	glVertexAttribs4ubvNV	= (PFNGLVERTEXATTRIBS4UBVNV) wglGetProcAddress("glVertexAttribs4ubvNV");
     
    	return true;
     
    }
    Thanks you very much.

  2. #2
    Senior Member Regular Contributor
    Join Date
    Apr 2001
    Location
    Fort Collins, Colorado
    Posts
    446

    Re: Converting NVIDIA Code (PPL) for ATI Radeon Series (PPL)

    Well, I've got a Radeon 8500 here at home, and several old SDR 32meg original Radeons in the test lab at work, so I'd be willing to test your code for you.

    As far as converting your code, that's gonna be tough without an Ati card to work with. Perhaps Humus or NitroGL could show you some of their code, or perhaps the Ati developer section sample code would help.

    Sorry I can't offer more help.

  3. #3
    Junior Member Newbie
    Join Date
    Oct 2002
    Location
    Kiev, Ukraine
    Posts
    6

    Re: Converting NVIDIA Code (PPL) for ATI Radeon Series (PPL)

    Cg compiled code will never work on Radeon, until some standartized extension will be supported by both ATI and NVidia drivers..

Similar Threads

  1. Replies: 0
    Last Post: 11-28-2013, 08:36 AM
  2. Anyone here have an Radeon 5k series card?
    By Mars_999 in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 12-30-2009, 08:22 AM
  3. Slow shaders on RADEON X300/X550 Series (128 MB)
    By devdept in forum OpenGL: GLSL
    Replies: 8
    Last Post: 06-02-2009, 10:16 AM
  4. Ati radeon 9000 series problems with ea games
    By alucard in forum OpenGL: User Software
    Replies: 0
    Last Post: 04-26-2003, 10:31 PM
  5. converting glut code to plain windows ogl code
    By TheLastMohican in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 03-10-2003, 09:50 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean