Jump to content
  • Advertisement
Sign in to follow this  
ahmed30

OpenGL Use texture mapping and position them in the screen

This topic is 3614 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

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 ...

Share this post


Link to post
Share on other sites
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

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!