Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Memblock tutorial Help

Author
Message
Dia
19
Years of Service
User Offline
Joined: 16th Jan 2005
Location:
Posted: 15th Jan 2010 14:21
I have never really messed around with memblocks much, so I tired to have a go at the starfield tutorial.

As far as it went, it was fine, however I was wondering if anyone can explain why there are the blank spots (see the attached image)

I *think* that it has something to do with the size of the memblock used, but I can't figure out why the stars are drawn in 'blocks' and why there should be a blank "strip and a half" at the bottom

I messed around with the code and tried different memblock sizes and screen sizes, but every different one I tried had a similar effect

Anyone got any ideas?

This is not the Sig you are looking for....

Attachments

Login to view attachments
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 15th Jan 2010 14:44
Maybe if you posted the code you are using.
I don't quite get what you mean either; if it's the blackness around the "Dark Basic PRO"-text, I suppose that sprite doesn't have any alpha channel set / doesn't treat black as transparent.

Dia
19
Years of Service
User Offline
Joined: 16th Jan 2005
Location:
Posted: 15th Jan 2010 15:05
ok, this is a cut and paste of the tutorial source code



The blackness I am referring to is not around the Dark Basic Pro Sprite, but the black strip and a half at the bottom of the screen (where I have added the "See what I Mean?" text and the hand drawn arrows

This is not the Sig you are looking for....
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 15th Jan 2010 18:29
I think that's got to do with how the pixel buffer is laid out.
If I recall correctly, something similar was mentioned not too long ago. I think that it was something along the lines that the pixel buffer has a larger size than the visible rendering surface (whether it was of the full window, including borders, or the entire display mode, I don't remember), so when you draw to pixel (320, 5), assuming the screen width is 800, the calculation you perform would be p = ((5 * 800) + 320) * 4 = 17280.
However, if the pixel buffer has a width of, say, 810 instead, that position would instead point to the pixel (270, 5), and in that way you would eventually not write anything at all to the lowest pixels (which correspond to the highest numbers).

I'm just rambling here, but I believe that the pixel buffer can only be set the size of any available resolution your graphics card can handle. So, when creating a 800x600 window, you will probably get a pixel buffer of that size. If you then set your window to be of that size, that likely includes the window borders and thus you will be drawing to some pixels that aren't visible as described above.
Also worth noting is that if your application is running in 16-bit colour depth, the pixel buffer will (most likely) also be 16-bit. In that code it is assumed to be 32-bit. That would not seem likely to cause the effect you are describing though, but worth watching out for if you're going to write directly to the pixel buffer.
I would probably reccommend making sprites from memblocks instead.

Dia
19
Years of Service
User Offline
Joined: 16th Jan 2005
Location:
Posted: 16th Jan 2010 05:03 Edited at: 16th Jan 2010 05:06
so would I, however I have never really used memblocks before, so was just doing the tutorial so that I could at least learn how to use memblocks a little bit.

when I didn't get the output I was hoping for (even with the source code supplied in the tutorial) I was hoping to find out how I could modify it so that it would give me pretty stars over the entire screen

The other interesting point I picked up while trying to mess around with it a little is that the stars appear semi-randomly, and dissappear semi-randomly as well, rather than being 'born' at one side of the screen and 'dying' at the other. I guess this ties in to the potentital issue of the buffer being a diff size to the actual displayed screen

Don't get me wrong, I am not overly concerned that the tutorial doesn't work properly, hell you learn more from stuff that doesn't work than from stuff that does. It would just appear that what the tutorial is telling me in http://developer.thegamecreators.com/?f=dbpro_tutorials is not entirely accurate, so just pointing it out to whoever owns it. A tutorial that is incorrect is not all that effective at helping me learn!

This is not the Sig you are looking for....

Login to post a reply

Server time is: 2024-09-28 14:27:16
Your offset time is: 2024-09-28 14:27:16