Xtreme Visual Basic Talk

Xtreme Visual Basic Talk (http://www.xtremevbtalk.com/)
-   .NET Game Programming (http://www.xtremevbtalk.com/-net-game-programming/)
-   -   How to change DirectDraw surface bitmap (http://www.xtremevbtalk.com/-net-game-programming/326287-change-directdraw-surface-bitmap.html)

ogi_dws 08-11-2013 06:51 AM

How to change DirectDraw surface bitmap
Hi I'm fairly new to DirectDraw and I currently writing a simple app where the main loop draws a surface using DrawFast method, it looks something like this:

frm.backbuffer.DrawFast(Control.MousePosition.X, Control.MousePosition.Y, frm.MySurface, DrawFastFlags.DoNotWait Or DrawFastFlags.SourceColorKey)

the image I'm drawing is a bitmap loaded into the memory, here's initialization of the surface:

MySurface = New Surface(bmpImage, New SurfaceDescription, GraphicsCard)

The problem here is that the 'bmpImage' is changing while the program runs and I don't know how to update this changes into the sprite surface. I want to note that I'm NOT trying to draw an animated sprite, so using a bitmap image with few frames on it is not a solution - I'm drawing a bitmap that is constantly changing.
What I'm doing now to update the surface is restoring the whole surface every time when it is drawn with this method:

Public Sub RestoreSurfaces()
MySurface = New Surface(_BB, New SurfaceDescription, GraphicsCard)
Dim ck As ColorKey = New ColorKey
MySurface.SetColorKey(ColorKeyFlags.SourceDraw, ck)
ck = Nothing
Catch ex As Exception
End Try

I'm wondering is it a good way to update the surface image like that, or this is very slow and bad solution, if there is better solution, please let me know about it, thank you.

All times are GMT -6. The time now is 02:47 AM.

Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2018, vBulletin Solutions, Inc.
Search Engine Optimisation provided by DragonByte SEO v2.0.15 (Lite) - vBulletin Mods & Addons Copyright © 2018 DragonByte Technologies Ltd.
All site content is protected by the Digital Millenium Act of 1998. Copyright©2001-2011 MAS Media Inc. and Extreme Visual Basic Forum. All rights reserved.
You may not copy or reproduce any portion of this site without written consent.