Use texture mapping and position them in the screen

Started by
1 comment, last by ahmed30 15 years, 3 months ago
Hello guys... I am new to this Forum ... I am AHmed ... I am creating a game using OpenGl "glut.h" ... the game is about shooting target... and i wished to load pics in to my project. so the targets appear will be from a pic file loaded from my hard disk and can change it's position ... can some one tell me a simple code to do this.. bec. all the codes i found are hard to understand... This is my sample code that i am using in my project. not any thing else " void main (int argc, char** argv) { srand(time(0)); glutInit(&argc,argv); glutInitWindowSize(W,H); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB); glutCreateWindow("Shooting Targets"); init(); glutDisplayFunc(display); glutMainLoop(); } //************************************************************************* // Functions Definition //************************************************************************* void init (void) { glClearColor(1.0, 1.0 , 1.0, 1.0); glColor3f(1.0, 0.0, 0.0); glPointSize(5.0); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D (0, W, 0, H); } //////////////////////////////////////////////////////////////////////////// void display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Want to load and draw a picture in this function :)) .. glFlush(); glutSwapBuffers(); } " Thanks you all for ur time ...
Advertisement
Hi

You'll want to load the picture outside of your drawing code, that way it won't load the picture every frame, which will get slow.

You want to look into texture mapping. There are tons of tutorials about it. Just load the texture, bind it, and use it to draw a polygon.

-G

[size="1"]And a Unix user said rm -rf *.* and all was null and void...|There's no place like 127.0.0.1|The Application "Programmer" has unexpectedly quit. An error of type A.M. has occurred.
[size="2"]

Thanks but where i can find tutorials about texture mapping ???

This topic is closed to new replies.

Advertisement