Use texture mapping and position them in the screen
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 ...
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
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement