Advertisement

problems with undisplaying images

Started by April 04, 2003 11:59 AM
4 comments, last by havoc_2003 21 years, 10 months ago
hi, im pretty new to opengl and im having a problem. im making a blackjack game, and i cant seem to undisplay cards after a game finishes so i can start a new game. i tried using (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT), but all that seems to do is clear the background image and not the cards i display. is there a function to undisplay the cards (im using a texture array to store the cards images). or to clear the whole screen. thanks
as far as I know glClear clears entire screen not just some parts. What about screenshot or something so we can understand better...Maybe some code too...
Advertisement
i dont know how to post images, but here is some code:

//clearing the screen to start a new game
if (clear)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
//drawing the cards on the screen
Game.validatePlayerDeck();

for (int i = 0; i < 2; i++) {
pcard = Game.getCardPlayer();
dcard = Game.getCardDealer();<br> }<br> <br> DrawCardPlayer(CardObjects[pcard[0]]);<br> DrawCardPlayer(CardObjects[pcard[1]]);<br> DrawCardDealer(CardObjects[dcard[0]]);<br> DrawCardDealer(CardObjects[dcard[1]]);<br><br>//heres the actual function where i draw the card<br>GLvoid DrawCardDealer(UINT mTexture)<br>{<br> glPushMatrix();<br> glBindTexture(GL_TEXTURE_2D, mTexture);<br> glBegin(GL_QUADS) ;<br><br> glTexCoord2f(0, 0);glVertex3f(x_corr1, 0.3, 0) ;<br> glTexCoord2f(1, 0);glVertex3f(x_corr2, 0.3, 0) ; <br> glTexCoord2f(1, 1);glVertex3f(x_corr2, 0.8, 0) ; <br> glTexCoord2f(0, 1);glVertex3f(x_corr1, 0.8, 0) ; <br><br> glEnd() ;<br> glPopMatrix();<br><br> x_corr1 += 0.07;<br> x_corr2 += 0.07;<br>}<br><br>//heres the main<br><br>void main(int argc, char** argv)<br>{ <br> //set up GLUT''s OpenGL <br> srand(time(0));<br><br> int hit = 0;<br> glutInit(&argc, argv);<br> glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);<br> glutInitWindowSize(800, 600);<br> glutInitWindowPosition(0, 0);<br> glutCreateWindow("Black Jack");<br> glClearColor(0.0f, 0.0f, 0.0f, 0.5f);<br> glEnable(GL_TEXTURE_2D);<br> glShadeModel(GL_SMOOTH);<br> glClearDepth(1.0f); <br> loadTextures();<br><br> glutDisplayFunc(myDisplay);<br> glutMouseFunc(processMouse);<br> <br> glutMainLoop();<br>}<br>//where i call clear<br>else if ((x > 25) && (x < 225) && (y > 351) && (y < 400) ) { if (Status == Off) {<br> clear = true;<br> }<br><br>basically, when i do this, the backgound image is cleared, but the cards remain </i> <br><br>
I''m taking a stab here, but it looks like after you clear the screen, you are redrawing the cards. Do you want the cards off, or are you redrawing them to their default state.

Sorry if I have mis-interpreted you.
Can you upload code somewhere and put a link or email it to me on plejast@icqmail.com. I''ll try to find your bug.
i e-mailed u the code, although i dont know if it got to u since its a bit over 2MB.

i moved the clear to the end, and it did clear it properly, but for some reason, it doesnt let me continue to play the game.

im gonna plaqy around, hopefully somethign will work

thanks for the help

This topic is closed to new replies.

Advertisement