Click here to Skip to main content
15,880,972 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi :)

There is function that generates a texture: void Render(char* Img);
At the init of openGL:

glutInit(&argc, argv);
glutInitWindowSize(w, h);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
glutCreateWindow("triunghi");
glutDisplayFunc(afis);
glutIdleFunc(idle);

glClearColor(0, 0, 0, 0);
glEnable( GL_TEXTURE_2D );
texture=LoadTexture();


where LoadTexture is

glGenTextures( 1, &texture );
glBindTexture( GL_TEXTURE_2D, texture );
glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, false ? GL_REPEAT : GL_CLAMP );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, false ? GL_REPEAT : GL_CLAMP


and in the drawing function
glClear(GL_COLOR_BUFFER_BIT);
glLoadIdentity();

glEnable( GL_TEXTURE_2D );
glBindTexture( GL_TEXTURE_2D, texture );
gluBuild2DMipmaps(  GL_TEXTURE_2D, 3, w, h, GL_RGB, GL_UNSIGNED_BYTE, Img);

glBegin(GL_QUADS);
        glTexCoord2d(0.0,0.0); glVertex2d(-1.0,-1.0);
        glTexCoord2d(1.0,0.0); glVertex2d(1.0,-1.0);
        glTexCoord2d(1.0,1.0); glVertex2d(1.0,1.0);
        glTexCoord2d(0.0,1.0); glVertex2d(-1.0,1.0);
glEnd();
glutSwapBuffers();


in idle, the data in Img is updated, and glutPostRedisplay is called.
The trouble is that only the first texture is displayed, at the next frame only 10% at the top of the image updated and after that the texture is static. The object can be moved, but the texture is the same.
The same thing happens even if a new texture number is assigned and the old one freed.
The Img is updated correctly, because it is also written to a file which is ok.

What am I doing wrong?

Thank you :)
Posted
Comments
GPUToaster™ 3-Sep-10 7:30am    
What are you trying to achieve? Can you explain it more!!
Santhosh G_ 3-Sep-10 11:52am    
Could you please post the code written in Idle function.

1 solution

Sorry, the problem was in the buffer, it didn't update correctly...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900