Drawn images using ImageBuffer do not show
Blitz3D Forums/Blitz3D Beginners Area/Drawn images using ImageBuffer do not show
| ||
Hello I am writing a program that Draws and Image in an Imagebuffer (using createImage and Plot) and then Tiles the image across the screen. However, the Tile does not work until after I have run the program, clicked another window, and clicked back on to the program. This seems to be an event error, but I don't know how to correct it. Following is the code. ;INITIALIZATION ;Set up the graphics Graphics 800,600,0,2 ;Seed the Random Generator SeedRnd MilliSecs() ;CONSTANTS ;The length of each block Const LENGTH = 100 ;The height of each block Const HEIGHT = 100 ;The amount of dots in each block Const DOTS = 100 ;END CONSTANTS ;IMAGES ;Create the dotfield image dotfieldimage = CreateImage(LENGTH,HEIGHT) ;END IMAGES ;For each dot, draw a random dot at a random location For loop = 0 To DOTS ;For every star ;draw only on created image SetBuffer ImageBuffer(dotfieldimage) ;Plot the dot Plot Rnd(LENGTH), Rnd(HEIGHT) Next ;Set buffer back to normal SetBuffer FrontBuffer() ;END INITIALIZATION ;MAIN LOOP ;Tile the image until the user quits (presses ESC) While Not KeyDown(1) TileImage dotfieldimage Wend ;END MAIN LOOP Thank you -Maneesh |
| ||
must be an error in your computer, works fine for me |
| ||
The error is more obvious (happens 100% of the time) if you change the Graphics code to Graphics 800,600 So the code becomes: ;INITIALIZATION ;Set up the graphics Graphics 800,600 ;Seed the Random Generator SeedRnd MilliSecs() ;CONSTANTS ;The length of each block Const LENGTH = 100 ;The height of each block Const HEIGHT = 100 ;The amount of dots in each block Const DOTS = 100 ;END CONSTANTS ;IMAGES ;Create the dotfield image dotfieldimage = CreateImage(LENGTH,HEIGHT) ;END IMAGES ;For each dot, draw a random dot at a random location For loop = 0 To DOTS ;For every star ;draw only on created image SetBuffer ImageBuffer(dotfieldimage) ;Plot the dot Plot Rnd(LENGTH), Rnd(HEIGHT) Next ;Set buffer back to normal SetBuffer FrontBuffer() ;END INITIALIZATION ;MAIN LOOP ;Tile the image until the user quits (presses ESC) While Not KeyDown(1) TileImage dotfieldimage Wend ;END MAIN LOOP Thanks -Maneesh |
| ||
The code above tiles the screen with an image. I think his may have something to do with drawing buffers. And i also assume your using blitzplus? If so, it uses the backbuffer for drawing by default. Put in: Flip After your Wend. |
| ||
Try to always use the backbuffer for drawing, then flip before the wend in the main loop. :o) |
| ||
When I put in Flip, it works when not in fullscreen mode. However, in full screen mode, it doesn't work. I get a blank beige screen. What is going on? Thanks -Maneesh |
| ||
YOu need to get rid of your setbuffer frontbuffer command. Forgot to mention that ^_^ |
| ||
When I set it to use the backbuffer, and use Flip, the screen alternates between blank beige and the star images. I still don't know what is happening. |
| ||
Ok, here's my code : I changed the SetBuffer FrontBuffer() command to SetBuffer BackBuffer(). And added flip. ;Set up the graphics Graphics 800,600 ;Seed the Random Generator SeedRnd MilliSecs() ;CONSTANTS ;The length of each block Const LENGTH = 100 ;The height of each block Const HEIGHT = 100 ;The amount of dots in each block Const DOTS = 100 ;END CONSTANTS ;IMAGES ;Create the dotfield image dotfieldimage = CreateImage(LENGTH,HEIGHT) ;END IMAGES ;For each dot, draw a random dot at a random location For loop = 0 To DOTS ;For every star ;draw only on created image SetBuffer ImageBuffer(dotfieldimage) ;Plot the dot Plot Rnd(LENGTH), Rnd(HEIGHT) Next ;Set buffer back to normal SetBuffer BackBuffer() ;END INITIALIZATION ;MAIN LOOP ;Tile the image until the user quits (presses ESC) While Not KeyDown(1) TileImage dotfieldimage Flip Wend ;END MAIN LOOP |
| ||
Awesome thanks! The only thing is, when I run your program, it flips very rapidly and you can very easily see a blank beige color being alternated at the same time as the star image. Do you know why? |
| ||
Are you using the exact same code as mine? |
| ||
yes, i copied and pasted it directly. Is it a problem with my computer? |
| ||
This is blitzplus, by the way |
| ||
I'm running this in blitzplus. Seems like an odd thing to happen. Have you set, or changed anything in your graphics card drivers? Try: (added in a cls at the top of the main loop) ;Set up the graphics Graphics 800,600 ;Seed the Random Generator SeedRnd MilliSecs() ;CONSTANTS ;The length of each block Const LENGTH = 100 ;The height of each block Const HEIGHT = 100 ;The amount of dots in each block Const DOTS = 100 ;END CONSTANTS ;IMAGES ;Create the dotfield image dotfieldimage = CreateImage(LENGTH,HEIGHT) ;END IMAGES ;For each dot, draw a random dot at a random location For loop = 0 To DOTS ;For every star ;draw only on created image SetBuffer ImageBuffer(dotfieldimage) ;Plot the dot Plot Rnd(LENGTH), Rnd(HEIGHT) Next ;Set buffer back to normal SetBuffer BackBuffer() ;END INITIALIZATION ;MAIN LOOP ;Tile the image until the user quits (presses ESC) While Not KeyDown(1) cls TileImage dotfieldimage Flip Wend ;END MAIN LOOP |
| ||
You say beige? That's an odd color to be changing too... |
| ||
Perfect, that fixes it completely! Any idea why the Cls command would have any effect here? Thanks -Maneesh |
| ||
Might be something to do with the tileimage command drawing over the previous contents of the buffer. I can't be sure :o) Usually put a cls in anyway, to wipe the buffer clean, before i draw. |