How Can I.....(OpenGL)

This is a discussion on How Can I.....(OpenGL) within the Game Programming forums, part of the General Programming Boards category; In tetris, when you get a line, you need to delete that line and make everything on top of that ...

  1. #1
    Absent Minded Programmer
    Join Date
    May 2005
    Posts
    964

    How Can I.....(OpenGL)

    In tetris, when you get a line, you need to delete that line and make everything on top of that object fall down....

    My question is, how can you clear a certain area of your screen? Is there an eraser function with coordinates attached? How can I accomplish this?

  2. #2
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    you could just draw a rectangle

    something like glQuad or glPoly. I haven't done much openGL lately. Not sure I would even use openGl for something as trivial as a 2d game like tetris.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  3. #3
    Registered User
    Join Date
    Aug 2003
    Posts
    1,203
    That depends on how you set it up. The way I would do it would be to have a bunch of quads make up the different shapes in the game. Then when I row gets full I just delete the quads on that row.
    STL Util a small headers-only library with various utility functions. Mainly for fun but feedback is welcome.

  4. #4
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    You do this in your render function. You should be redrawing the screen each time based on the array in memory. So if you delete a row in memory...it won't show up on screen. To make the other blocks fall you simply need to add code that if a block is above a cell that is open...it falls. The rate at which it falls can be determined by a parameter to the function or some other method. Note that you can handle the blocks falling at a set rate, and the blocks falling down to fill gaps with the same function using this method.

  5. #5
    Absent Minded Programmer
    Join Date
    May 2005
    Posts
    964
    uhg, screen display arrays, scarryyyyyy....

    I like the idea of drawing a black rectangle over the objects i want to "remove"


    Right now, my shape functions are made of up multiple quads,

    in the square the quads are set up seperately to form a 4 block square, maybe I can clear any quads at a certain area depending on where the line was made
    Last edited by Shamino; 05-24-2005 at 11:21 AM.

  6. #6
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    Bubba's explanation is in fact the correct way to use opengl though.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  7. #7
    Absent Minded Programmer
    Join Date
    May 2005
    Posts
    964
    oh the cold truth

    I never worked with arrays that in depth yet, nor with pointers to memory or anything like that, I know how to use them, just not well

  8. #8
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    it's not so much an "array" concern. Just that you need a render() function of sorts that happens repeatedly. It should draw everything that is intended to be on the screen, every time. You may store that in an array or in the case of stuff that doesn't change you can just do certain instructions every time. It's just that opengl is an animation tool. Animation means frame after frame. And you have to draw those frames.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  9. #9
    Absent Minded Programmer
    Join Date
    May 2005
    Posts
    964
    well, i dunno what you mean by frame by frame, because you can move objects in 3d space without redrawing them....

    Regardless, I basically need to make a function that renders over all my other render functions, it is the god of all render functions...

    it renders what is inside my "game area" render function, and determines what is allowed in and what isnt


    I find it strange that I cant make a simple if statement

    if line = full
    clear anything less than the right end of the game but greater than the left end of the screen
    Last edited by Shamino; 05-24-2005 at 11:47 AM.

  10. #10
    Registered User
    Join Date
    Aug 2003
    Posts
    1,203
    Ummmmm...how can you move stuff without redrawing??? It is all memorybased....move something and you change something in memory (at least how I understand it). Everytime you change something in opengl you need to redraw it.
    STL Util a small headers-only library with various utility functions. Mainly for fun but feedback is welcome.

  11. #11
    Absent Minded Programmer
    Join Date
    May 2005
    Posts
    964
    eh, i guess, i didn't realize changing the translate f actually deleted/redrew the object...

    I thought that was what seperated turbo C++ graphics from OpenGL

  12. #12
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    the translate function moves the position of the coordinate system. It doesn't draw anything.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  13. #13
    Absent Minded Programmer
    Join Date
    May 2005
    Posts
    964
    right, so when u change the translatef of a cube for instance, you aren't redrawing the cube, but you are moving it in 3d space...

    Right?

  14. #14
    Registered User
    Join Date
    Aug 2003
    Posts
    1,203
    But you need to draw after you translate for it to show up.

    There is no way you can get something to move without redrawing!
    STL Util a small headers-only library with various utility functions. Mainly for fun but feedback is welcome.

  15. #15
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    Quote Originally Posted by Shamino
    right, so when u change the translatef of a cube for instance, you aren't redrawing the cube, but you are moving it in 3d space...
    no. you don't "translate a cube" you translate the coordinate system. There is no cube until you draw it.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

Page 1 of 3 123 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Linking OpenGL in Dev-C++
    By linkofazeroth in forum Game Programming
    Replies: 4
    Last Post: 09-13-2005, 10:17 AM
  2. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 12:34 PM
  3. OpenGL .dll vs video card dll
    By Silvercord in forum Game Programming
    Replies: 14
    Last Post: 02-12-2003, 06:57 PM
  4. OpenGL and Windows
    By sean345 in forum Game Programming
    Replies: 5
    Last Post: 06-24-2002, 10:14 PM
  5. opengl code not working
    By Unregistered in forum Windows Programming
    Replies: 4
    Last Post: 02-14-2002, 09:01 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21