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.

DarkBASIC Discussion / Display / MEMBLOCK Issues, help needed

Author
Message
DSoltyka
17
Years of Service
User Offline
Joined: 11th Aug 2007
Location:
Posted: 12th Aug 2007 00:27
Hey guys. I have a few questions. First of all, I'm trying to make a vertically scrolling paralax starfield. I'm running into a few problems.

I'm using the tutorial located here: http://developer.thegamecreators.com/?f=dbpro_tutorials

Specifically, I'm using the MEMBLOCK version.

The first problem I have run into is that when I copy data from a memblock to the display, the display is missing a good chunk of information. I've isolated the problem, but I do not undertstand it. Take for example, this code.



now, we enter the test



now that should work, but it doesn't. The bottom of the display is missing. The only workaround I have found is this:

mem_size = (sw * sh * bytes_per_pixel) * 1.12

That 1.12 is totally arbitrary, and I've only tested in a 800x600,32 environment, so I'm not sure yet if it changes. If anyone knows why this happens, please, let me know.

Also, as far as the starfield. When I used the turorial, it didnt work (same reasons posted above actually). What I want to do is move the stars vertaically, but when I adjust theit Y coordinate, the display....well freaks out. Really freaks out.

Any help is vastly appreciated.
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 12th Aug 2007 16:52
You are using some DBP commands that I don't understand

Explain what this is doing and I may be able to help.

Your signature has been erased by a mod because it was rubbish.
Kevin Picone
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 12th Aug 2007 18:41 Edited at: 12th Aug 2007 19:04
I haven't tried your test code, but I'm fairly sure the problem is a result of the screen surface being oversized. While you might ask DBpro to open a screen of 800*600 say, the device driver will often pad the width any surface (screen/image etc) so that each scan line falls upon even boundaries (address). So sadly you can't simply calculate the size of a surface by (width * bytesperpixel * height), Since width will often be incorrect. so you'll have to ask Dbpro for the PITCH of the surface (bytes per scan line). Which in Dbpro is probably Get Pixels Pitch()

So to calc the total size in bytes you'd

SizeInBytes = Get Pixels Pitch() * Height

DSoltyka
17
Years of Service
User Offline
Joined: 11th Aug 2007
Location:
Posted: 12th Aug 2007 23:15
Quote: "You are using some DBP commands that I don't understand
+ Code Snippet
lock pixels
copy memory get memblock ptr(1), get pixels pointer(), mem_size
unlock pixels

Explain what this is doing and I may be able to help."



Sorry. I'll break that command apart.

copy memory FromMemory, ToMemory, MemorySize

that command basically copies memory from one place in memory to another.


memblock ptr(1) returns a pointer to where in memory the memblock is stored
get pixels pointer() returns a pointer to where in memory our display is stored

So, the whole command essentially copies all of the information in our memblock directly to the display.


Quote: "I haven't tried your test code, but I'm fairly sure the problem is a result of the screen surface being oversized. While you might ask DBpro to open a screen of 800*600 say, the device driver will often pad the width any surface (screen/image etc) so that each scan line falls upon even boundaries (address). So sadly you can't simply calculate the size of a surface by (width * bytesperpixel * height), Since width will often be incorrect. so you'll have to ask Dbpro for the PITCH of the surface (bytes per scan line). Which in Dbpro is probably Get Pixels Pitch()

So to calc the total size in bytes you'd

SizeInBytes = Get Pixels Pitch() * Height"


And yes, thank you. It was actuaally a Backbuffer problem...I didn't really think about it, and found the answer searching these forums actually (should use it more often). The functional code was:



It fixed both problems at once, since the main problem was with the Y coordinate anyway. But thank you for answering.

Login to post a reply

Server time is: 2025-05-30 13:31:04
Your offset time is: 2025-05-30 13:31:04