How does TileImage work?
BlitzMax Forums/BlitzMax Beginners Area/How does TileImage work?
| ||
Like the topic title says, how does TileImage work? I've written a little demo but it doesn't tile the image that is created, why? Graphics 640, 480, 0 '-- CONSTANTS --------------------------------------------------- Const WIDTH = 100 Const HEIGHT = 100 Const DOTS = 100 '-- END CONSTANTS ----------------------------------------------- '-- IMAGES ------------------------------------------------------- dotImage = CreateImage(WIDTH, HEIGHT) '-- END IMAGES --------------------------------------------------- SeedRnd MilliSecs() LockImage dotImage For counter = 0 To DOTS Plot Rnd(WIDTH), Rnd(HEIGHT) Next UnlockImage dotImage '-- MAIN LOOP ---------------------------------------------------- While Not KeyHit(KEY_ESCAPE) TileImage dotImage FlushMem Flip Wend '-- END MAIN LOOP ------------------------------------------------ End Thanks, Nicolas. |
| ||
your plotting dits to an imagebuffer, But hav not specified a colour to be used. Perhaps the fore and background colour are the same. Making the image completely black and making it look like nothing is tiled. thats just a shot in the dark though. |
| ||
No, that doesn't solve the problem. Sins I don't specify colour the dot's are drawn in white and the background is black so... I should be able to see them and I do see them but it's not tiled. Here I've uploaded a screenshot of it: http://www.n-software.info/public/Game%20Development/BlitzMax/TileImage.tiff Thanks anyway, Nicolas. |
| ||
I don't have my Mac in front of me at the moment, but doesn't TileImage require arguments to be sent to it? I thought you had to specify a rectangle to tile within... |
| ||
TileImage parameters are image:TImage, x# = 0#, y# = 0#, frame = 0 but I don't now what x and y exactly are. I've tried TileImage dotImage, 640, 480 (the resolution of the screen) and TileImage dotImage, 100, 100 (the width and height of the image) but whit no luck. Thanks anyway, Nicolas. |
| ||
I think you're meant to use tile image to draw an image to the backbuffer, tiled many times over? |
| ||
Yes, I want to creat an image, tile the image all over te screen in the backbuffer and then flip buffers. Nicolas. |
| ||
Hi, In your example you are drawing directly to the back buffer using Plot. This is why you see the untiled dots. Unlike Blitz2D there's no SetBuffer() command, so things have to be done a little bit differently. Basically, how I understand it is the image itself is stored in video ram, so to access it you need to get it into CPU addressable ram using the LockImage function. LockImage returns a pixmap onto which you can then draw whatever you want using WritePixel. Example: |
| ||
Seams to work fine, thank you very much. Nicolas. |