ATI Fragment Program Problem

I have the following code, but nothing appears when I run the program, just a blank screen.

PFNGLGENPROGRAMSARBPROC glGenProgramsARB = NULL;
PFNGLDELETEPROGRAMSARBPROC glDeleteProgramsARB = NULL;
PFNGLBINDPROGRAMARBPROC glBindProgramARB = NULL;
PFNGLPROGRAMSTRINGARBPROC glProgramStringARB = NULL;
PFNGLPROGRAMENVPARAMETER4FARBPROC glProgramEnvParameter4fARB = NULL;
glGenProgramsARB           = (PFNGLGENPROGRAMSARBPROC)wglGetProcAddress("glGenProgramsARB");
glDeleteProgramsARB        = (PFNGLDELETEPROGRAMSARBPROC)wglGetProcAddress("glDeleteProgramsARB");
glProgramStringARB         = (PFNGLPROGRAMSTRINGARBPROC)wglGetProcAddress("glProgramStringARB");
glBindProgramARB           = (PFNGLBINDPROGRAMARBPROC)wglGetProcAddress("glBindProgramARB");
glProgramEnvParameter4fARB = (PFNGLPROGRAMENVPARAMETER4FARBPROC)wglGetProcAddress("glProgramEnvParameter4fARB");

unsigned char *MyString = GetFile(“sample.psh”);

if(!MyString)
	exit(1);

glGenProgramsARB(1, &progID);
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, progID);
glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, strlen((char*)MyString), MyString);
glEnable(GL_FRAGMENT_PROGRAM_ARB);

void Draw (void)
{
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
glLoadIdentity (); // Reset The Modelview Matrix

glTranslatef(-0.5,-0.5,-4);

glBegin(GL_QUADS);
glColor3f(1,0,0);
glVertex3f(0,0,0);

glColor3f(0,1,0);
glVertex3f(0,1,0);

glColor3f(0,0,1);
glVertex3f(1,1,0);

glColor3f(1,1,1);
glVertex3f(1,0,0);
glEnd();

glFlush ();													// Flush The GL Rendering Pipeline

}

####sample.psh#####
!!ARBfp1.0

MOV result.color, fragment.color;

END

Shouldn’t this work? All I’m doing in the fragment program is transfering the color from the incoming fragment to the result. I’m running this on a Radeon 9000 Mobility, and I know that ATI_fragment_shader is supported, so why isn’t this working?

First, we have


tags on this board for a reason; they should be used.

Second, A Radeon 9000 does not support ARB_fragment_program. Only 9500+ cards do.

ATI_fragment_shader is a different language from ARB_fragment_program. You even specify programs differently (though the text fragment shader extension allows you to specify them as text).

Oh jeese, I had thought the fragment shader and fragment program were the same thing. So the fragment shader let’s you put code like the above? Any links to info on this? I really hate Ati’s site, they seem to support DirectX a lot more than OpenGL.

You might want to look up the two extensions in the extension registry.

So the fragment shader let’s you put code like the above?

No, as I pointed out, ATI_fragment_shader (mention specific extensions; it makes it more difficult to confuse the two) doesn’t accept text. ATI_text_fragment_shader does allow the specifying of ATI-fragment shaders as text files. However, ATI_fragment_shader is a different language from ARB_fragment_program; a program written for one won’t work on the other.

Sorry for asking you a stupid question… But are you setting your projection matrix? is GL_COLOR_MATERIAL enabled?

Zengar

Yes I am, but as I found out before fragment program isn’t supported on my card. But then again, I got some fragment shader code from ATI’s site and put it into my program and that didn’t work either, just a blank screen. I’ll have to mess around with that for a while. It’s the code from the Radeon 8500 demo of the logo spinning around.

If ARB_fragment_program isn’t supported on your card then wglGetProcAddress will return 0-pointer. So you should get an access violation error on calling ARB functions. If you don’t get it, pointers are not 0 - so, the extension IS supported(maybe in software) - well, at least I think so. Thje error will be in your setup code.

Originally posted by Zengar:
If ARB_fragment_program isn’t supported on your card then wglGetProcAddress will return 0-pointer. So you should get an access violation error on calling ARB functions. If you don’t get it, pointers are not 0 - so, the extension IS supported(maybe in software)<…>
Well, it’s not official in any case. It may be an experimental hack, even cause random crashes. It also may be a driver bug of sorts, in that you get the entry points for R300 and these obviously shouldn’t work.

You should never trust upon an extension that’s not properly exposed.