#### Archived

This topic is now archived and is closed to further replies.

# What are the most common ways for objects to disappear

This topic is 5866 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I know this question sounds...mundane...but I can''t figure out why one of my triangles is disappearing. I need to know the most common ways for objects to disappear. So far I only know of objects passing outside of the ''viewing volume'' (when this happens they stop being rendered). I have thought that maybe swapping the buffers could have something to do with it (how often are you supposed to swap the buffers? After every other call to glEnd()?) Are there any other ways that an object can just disappear? My problem is the fact that I have a triangle and it moves perfectly when I press ''up'' and ''left'' but when i press ''right'' and/or ''down'' it simply disappears. Weird man. Also, do you think it is better to take your base code from someone''s online tutorials, or do you think one should at least write their own base code (what i mean is window creation code and what not. I can''t ever seem to get my own window creation code working so I use NeHe''s). Okay thanks if you can help me shed some light on this frickin'' problem

##### Share on other sites
Swaping bufferes: you swap buffers whenever you need to update the screen. For example lets say you''re doing a loading screne and you have a bar. You''ll update the expansion of the bar by swaping buffers and you''ll only need to do this after you''ve loaded something (make sence?). Think of it like this:
There are two screens, the one that is currently on the screen and the one you are currently drawing. You''ve already drawn the one on the screen and the OGL code you write now is modifying the next screen. When you swap buffers you replace the one currently on the screen with the one you just drew and then start drawing a new screen.

Disapearing triangles:
Here are ways a triangle disapears
-Off the viewing volume (You are translating too much)
-Backface removal (if you''re verticies are in the wrong order and GL_CULL_FACE is enabled your triangle might not be drawn. Try glDisable(GL_CULL_FACE) )
-Depth test (if something is infront of you''re triangle then its not going to be drawn. glDisable(GL_DEPTH_TEST) )

It seems however that you''re problem is with the modelview matrix as you can draw the triangle when you translate up and left. Check you''re code for translation (posting it would also be great).

Base Code:
I have never written my own base code. It depends on the circumstances. One think you have to realize though is that this is on a by project basis. If you just want base code so that you can fool around (no offence) with OGL then there is no point. A good rule is if no one isnt going to use or grade it then there is no point in writing youre own - use whats out there. If however you need base code for a project then you decide to either make you''re own or download. If the project needs speed/effeciency and is professional then you should do you''re own code. That way you can control which functions are executed (so that you dont waste youre time on other stuff), which classes are used, and you dont run into legal stuff. If you''re pressed for time or the project is for school (ie high school) then download.

##### Share on other sites
I think the error is the "else" before the DrawGlScene: remove it

  else // Not Time To Quit, Update Screen{  DrawGLScene(XPosition, YPosition); // Draw The Scene  SwapBuffers(hDC); // Swap Buffers (Double Buffering)}

Check also the (keys[VK_?]) tests...

##### Share on other sites
Thank you both very much for posting. Removing the else clause made the program work as I want it to. It still seems funny that that was the cause of the problem. It is even more funny that I could move it up and to the left but not down and to the right, but, oh well, it is fine now.

1. 1
2. 2
3. 3
Rutin
18
4. 4
JoeJ
14
5. 5

• 14
• 10
• 23
• 9
• 32
• ### Forum Statistics

• Total Topics
632630
• Total Posts
3007521
• ### Who's Online (See full list)

There are no registered users currently online

×