Where to start!? (Game Dev)
Where to start!? (Game Dev)
Where to start!? (Game Dev)
Where to start!? (Game Dev)
Where to start!? (Game Dev)
Where to start!? (Game Dev) Where to start!? (Game Dev) Where to start!? (Game Dev) Where to start!? (Game Dev) Where to start!? (Game Dev) Where to start!? (Game Dev) Where to start!? (Game Dev) Where to start!? (Game Dev)
Where to start!? (Game Dev) Where to start!? (Game Dev)
Where to start!? (Game Dev)
Go Back  Xtreme Visual Basic Talk > > > Where to start!? (Game Dev)


Reply
 
Thread Tools Display Modes
  #21  
Old 05-09-2006, 03:37 PM
Iceplug's Avatar
IceplugWhere to start!? (Game Dev) Iceplug is offline
MetaCenturion

Retired Moderator
* Guru *
 
Join Date: Aug 2001
Location: Iowa, USA
Posts: 16,583
Default


Again, I recommend this method:

GDI+ Backbuffers in VB.NET - Projectile Demo

Drawing to a bitmap, and then drawing the bitmap to the screen - the big advantage is that you only appear to be making one drawing with the drawing of the bitmap... so you save the time for requiring several drawings rendered to the display and having to clear it.

The problem is that it will not work very well if you are only trying to draw one thing and don't want a background.

You could do it several other ways to efficiently draw a single box... but typically you're going to draw something more complex than just a box.

Adding a background is as easy as using GFX.Clear() though.
__________________

Iceplug, USN
Quadrill 1 Quadrill 2 (full) Quadrill 3 JumpCross .NET Website is ALIVE! - DL Platform Tour for VB.NET! Posting Guidelines Hint: Specify your location in your user cp profile if you want compassion!
Reply With Quote
  #22  
Old 05-09-2006, 11:47 PM
Pooyae's Avatar
Pooyae Pooyae is offline
Junior Contributor
 
Join Date: Nov 2003
Location: Birmingham, AL
Posts: 206
Default

Quote:
Originally Posted by JNewt
You need to clear the Graphics object before you paint new stuff. Use
Code:
GFX.Clear
before you draw the rectangle.
I'm using VB .net 2005, and there is no
Code:
GFX.Clear()

there is only one that accepts an argument:
Code:
GFX.Clear (color as System.Drawing.Color)

so I used:
Code:
GFX.Clear(Me.BackColor)

STILL FLICKERS!!!
__________________
"Imagination is more important than knowledge." -Albert Einstein
Survived Hero! - Electrical & Computer Engineering Forum
Reply With Quote
  #23  
Old 05-10-2006, 12:14 AM
Pooyae's Avatar
Pooyae Pooyae is offline
Junior Contributor
 
Join Date: Nov 2003
Location: Birmingham, AL
Posts: 206
Default

Quote:
Originally Posted by Iceplug
Again, I recommend this method:

GDI+ Backbuffers in VB.NET - Projectile Demo

Drawing to a bitmap, and then drawing the bitmap to the screen - the big advantage is that you only appear to be making one drawing with the drawing of the bitmap... so you save the time for requiring several drawings rendered to the display and having to clear it.

The problem is that it will not work very well if you are only trying to draw one thing and don't want a background.

You could do it several other ways to efficiently draw a single box... but typically you're going to draw something more complex than just a box.

Adding a background is as easy as using GFX.Clear() though.
ok... I gave it a try and the bloody thing still flickers :-(
Code:
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Me.Show() Me.Focus() 'loads the picture into backbuffer Dim BackBuffer As Bitmap = New Bitmap("C:\....\1.bmp") GFX = Me.CreateGraphics Do Until isESCdown 'create graphics here ............................................................. GFX.Clear(Me.BackColor) GFX.DrawImage(BackBuffer, rectX1, rectY1) '.................................................................................. KeyStrokeActions() Application.DoEvents() Loop Me.Close() End Sub
__________________
"Imagination is more important than knowledge." -Albert Einstein
Survived Hero! - Electrical & Computer Engineering Forum
Reply With Quote
  #24  
Old 05-10-2006, 05:58 AM
elnerdo's Avatar
elnerdo elnerdo is offline
Contributor
 
Join Date: Jul 2004
Location: Northern New Jersey
Posts: 490
Default

Well.. There's a couple thing wrong with how you're using that bitmap. First, I'd recomment putting 'Dim buffer as bitmap' in the declarations section. Second, when you set it to a new bitmap, give it a width and a height rather than the location of a bitmap.

Code:
backbuffer = new bitmap(me.width,me.height) 'This line of code would go in the form_load sub

Doing this will give you an empty bitmap to work with. Now, declare a graphics object for the bitmap (I also recommend putting this declaration in the declarations section rather than in form_load). Now, put this special line of code after the line where you set backbuffer to be a new bitmap

Code:
gfx = graphics.fromimage(backbuffer) 'This sets gfx to draw TO the image backbuffer. This way it will draw to backbuffer rather than the form.

After this is done, declare ANOTHER graphics object ( Declare it in the declarations section with 'dim formgfx as graphics,' and set it to me.creategraphics in the form_load sub. ). THis new graphics object will be set to equal me.creategraphics. This will mean that this graphics object is drawing to the form, rather than the bitmap.

Now that you have it all set up, use gfx to draw everything, and then at the end of each loop have ONE line that draws backbuffer to the form using the formgfx.
__________________
nerds unite!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Where to start!? (Game Dev)
Where to start!? (Game Dev)
Where to start!? (Game Dev) Where to start!? (Game Dev)
Where to start!? (Game Dev)
Where to start!? (Game Dev)
Where to start!? (Game Dev) Where to start!? (Game Dev) Where to start!? (Game Dev) Where to start!? (Game Dev) Where to start!? (Game Dev) Where to start!? (Game Dev) Where to start!? (Game Dev)
Where to start!? (Game Dev)
Where to start!? (Game Dev)
 
Where to start!? (Game Dev)
Where to start!? (Game Dev)
 
-->