Jump to content
  • Advertisement
Sign in to follow this  
clunis

texture-lookup using ARB_fragment_program on ATI FireGL card

This topic is 4899 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am trying to implement a texture palette on my ATI FireGL card using ARB_fragment_program. I tried modifying one of the samples provided by ATI, but all I get is a blank display. My fragment program: !!ARBfp1.0 ATTRIB TexCoord = fragment.texcoord; TEMP Index; TEX Index, TexCoord, texture, 2D; TEX result.color, Index, texture[1], 1D; END In case there is something wrong with the setup, I've included the entire code. Any help would be immensely appreciated. code: #include <stdio.h> #include <glut.h> #include "ATIExtensions.h" int width = 400; int height = 400; float distance = 0.0f; float zoom = 60.0f; GLuint fShad; GLuint nTex, nPalette; void init() { // dependent texture glGenTextures(1, &nTex); glActiveTextureARB( GL_TEXTURE0_ARB); glBindTexture( GL_TEXTURE_2D, nTex); unsigned char pSlice[256*256], *ptr; ptr = pSlice; for(int i=0; i<256; ++i) { memset(ptr, i, 256); ptr += 256; } glTexImage2D( GL_TEXTURE_2D, 0, 1, 256, 256, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, (void*) pSlice); // texture palette glGenTextures(1, &nPalette); glActiveTextureARB( GL_TEXTURE1_ARB); glBindTexture( GL_TEXTURE_1D, nPalette ); float pfLUT[256*4], *pPtr; pPtr = pfLUT; for(int l=0; l<256; ++l) { pPtr[0] = l < 128 ? 0.0 : 1.0; pPtr[1] = pPtr[2] = pPtr[3] = 1.0; pPtr += 4; } glTexImage1D(GL_TEXTURE_1D, 0, 4, 256, 0, GL_RGBA, GL_FLOAT, (void*) pfLUT); fShad = loadFragmentProgram("lut.txt"); } ////////////////////////////////////////////////////////////////////// void drawModel() { glEnable(GL_TEXTURE_2D); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glColor3f(0,1,0); glActiveTextureARB( GL_TEXTURE0_ARB); glBindTexture( GL_TEXTURE_2D, nTex); glBegin(GL_QUADS); glTexCoord2f(0, 0); glVertex2f(-.5, -.5); glTexCoord2f(1, 0); glVertex2f(.5, -.5); glTexCoord2f(1, 1); glVertex2f(.5, .5); glTexCoord2f(0, 1); glVertex2f(-.5, .5); glEnd(); } ////////////////////////////////////////////////////////////////////// void draw() { glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode( GL_PROJECTION); glLoadIdentity(); gluPerspective( zoom, (float)width/(float)height, distance/10.0f, distance*2.0f); glMatrixMode( GL_MODELVIEW); glLoadIdentity(); glTranslatef( 0.0f, 0.0f, -distance); glBindProgramARB( GL_FRAGMENT_PROGRAM_ARB, fShad); glEnable( GL_FRAGMENT_PROGRAM_ARB); drawModel(); glDisable( GL_FRAGMENT_PROGRAM_ARB); glActiveTextureARB( GL_TEXTURE0_ARB); glutSwapBuffers(); } ////////////////////////////////////////////////////////////////////// int main( int argc, char **argv) { glutInit( &argc, argv); glutInitDisplayMode( GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH); glutInitWindowSize( width, height); glutCreateWindow("Simple Shader- ATI Fragment Program loader"); glutDisplayFunc( draw); glutIdleFunc( draw); SetupGL1_4(); SetupATIExtensions(); SetupARBExtensions(); init(); glutMainLoop(); return 0; }

Share this post


Link to post
Share on other sites
Advertisement
1- Have you tried to make a simple program first, like :
!!ARBfp1.0
MOV result.color, {1,0,0,1};
END

This should give you red polygons.

2- Are you sure your graphics card support fragment programs ?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!