What went wrong?
Blitz3D Forums/Blitz3D Beginners Area/What went wrong?
| ||
I'm trying to just get a sphere to roll around... here is the code so far (you can find the sphere texture in the Mak samples, under 3Dfirepaint). See what I did wrong.Graphics3D 800, 600 SeedRnd MilliSecs() Const leftkey = 203, rightkey = 205, upkey = 200, downkey = 208 Const spacebar = 57, enter = 28 light = CreateLight() PositionEntity light, 0, 0, 0 camera = CreateCamera() PositionEntity camera, 0, 20, 0 sphere = CreateSphere() PositionEntity sphere, 0, 1, 20 spheretex = LoadTexture("blitzlogo.bmp") ScaleTexture spheretex,.125,.25 EntityTexture sphere, spheretex PointEntity camera, sphere ground = CreatePlane() PositionEntity ground, 0, -1, 0 Print "Hi" While Not KeyDown(1) Cls If KeyDown(upkey) TurnEntity sphere, 10, 0, 0 MoveEntity sphere, 0, 0, 2 EndIf If KeyDown(leftkey) TurnEntity sphere, 0, 5, 0 EndIf UpdateWorld RenderWorld Wend Notice the Print "Hi" before the game loop? If I don't have this, the entire screen is just black, and nothing happens. Also, the turning doesn't work. This happens both with and without the command Setbuffer Backbuffer() ... but do I need that command anyway? I haven't ever updated Blitz... is this a bug or a noob error? Someone please help. |
| ||
yes, get the update. you forgot the flip. The philosophy is doublebuffering. Thus you need setbuffer backbuffer() Graphics3D 800,600,32,2 setbuffer backbuffer() .... renderworld() flip ppl see the frontbuffer while you are preparing the backbuffer to become the next frontbuffer, by drawing to it and then flip front and backbuffer. |
| ||
You do not need the CLS here either. Rendering is always to the backbuffer. So you do not need the setbuffer backbuffer() in this context because that is set by the Graphics3d command. We are at version 1.95 now and bugs are very few and far between. They were not that common even in version 1.64. As to the ball rolling stuff here is something posted a year or two back which may help. http://www.blitzbasic.com/Community/posts.php?topic=20523 Well in particular the bit that rolls the ball with inputs transformed from the camera yaw and which gives the appearance of rotation. |
| ||
I can't believe I forgot Flip! Well, thanks. |
| ||
So you do not need the setbuffer backbuffer() in this context because that is set by the Graphics3d command. Not sure if this is really the way it is, no offense. I remember clearly I had serious probems when I didn't set a buffer explicitly. DirectX used to draw to a random buffer, sometimes back, sometimes frontbuffer, resulting in a flickering bugous output. Tho, not sure if this happened only in 2D. However, with setting the backbuffer you're on the save side. |
| ||
I have found the same with WritePixel/Fast and ReadPixel/Fast command. You sometimes have to put in the optional buffer parameter, even if it's the backbuffer. |