Jump to content
  • Advertisement
Sign in to follow this  
Nice Coder

Directdraw noobie needs some help.

This topic is 4371 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

ok, i'm having my first (major) experience with directdraw. I'm having a problem with directdraw (well, a couple, but two major ones). my tiles seem to be "popping" into existance on the edge of the screen. In other words, my tiles are 64x64 pixels, and as when theres a gap of between 0 and 63 pixels, it leaves it as black space, rather then blitting in part of the sprite. (which i'm telling it to do) Printscreen doesn't seem to be able to get an image (i start it up, hit printscreen, wait and close and i get a nice picture of my ide). I don't think its the rendering function, as it isn't doing any clipping. Either way, here it is.
Public Sub crender()
Dim spos As vector
Dim r As RECT
Dim bad As Boolean

For lay = 0 To UBound(layers)
For obj = 1 To UBound(layers(lay).objs)
spos = vsub(layers(lay).objs(obj).pos, screen)

With layers(lay).objs(obj)
    r.Left = 0
    r.Top = 0
    r.Right = .size.x
    r.Bottom = .size.y

If spos.x > 800 Then
r.Right = .size.x - (spos.x - 800)
End If
If spos.y > 600 Then
r.Bottom = .size.y - (spos.y - 600)
End If

bad = False
If r.Right + .size.x > 800 Then
    bad = True
End If
If r.Bottom + .size.y > 600 Then
    bad = True
End If

If Not bad Then DisplaySprite r, sprites(.sprite), r, True, spos.x, spos.y
End With

Next obj
Next lay
End Sub

I'm using a backbuffer, with fastblit. specifically backbuffer.fastblt. The reason i'm using fastblt is that for some reason when i try to blt normally it doesn't work. (i get a nice black screen, and nothing else). This is written in vb6, using directdraw7.

Share this post

Link to post
Share on other sites
It's been a while since I used DirectDraw, but I'm fairly confident that your calls to BltFast are failing because of clipping issues. The main source of the performance gain of BltFast (over Blt) is the absence of a need to clip the source against the viewport. Ipso facto, the call will fail unless the dest RECT entriely fits within the viewport.
You'll have to either perform the clipping yourself, or, more sensibly, use a straightforward Blt function. If you are having problems with Blt (as you say), then the fault is almost surely yours, and is probably indiciative of something more fundamental. Perhaps if you can describe your problems we can help diagnose the ailment.


Share this post

Link to post
Share on other sites

It blits properly for most of the tiles.
The problem is that tiles on the righthand edge that are partially out of the screen or those at the top that are partially out of the screen arn't displayed.

This then leads to a "popping" problem, where rather then smoothly scrolling the tiles simply pop into existance from a blank screen. (ie. there are four grey (my default backcolour) stripes running along all four edges of the screen, whose width is determined by how far you move mod the tilesize.

Share this post

Link to post
Share on other sites
ok, i've got it. :)

i thought that it would clip to the screen, but it doesn't.

:D i've got that working.

I've also gotten a sound system working, so i can play midi files for backround music. :)

A small problem tho:

Directinput works, i can grab the keyboard and it responds to keypresses, everythign is fine.

However when i'm using directinput for the mouse, i simply get a permission denied , on the line where i aquire the GUID_SysMouse. I'm using DISCL_FOREGROUND | DISCL_EXCLUSIVE as my cooperative level. (I think that might have something to do with it).

Both the mouse code and the keyboard code works perfectly when alone.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!