Archived

This topic is now archived and is closed to further replies.

GFX in VB question from a newbie

This topic is 6360 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

I am relatively new to VB and am only working in VB 4.0 My question is that I do not have any idea how to draw bitmaps to the screen in a way that I can use masking. I am looking for a way to put the images on screen without using picturebox or other controls, just straight drawing to the screen. The method must not use DirectX, and should (hopefully) be relatively easy to grasp. Failing this, how can I use VB to do a simple putpixel, I can build the rest from there. Thanks Red

Share this post


Link to post
Share on other sites
In VB 5 and 6 you can do it by using the API function BitBlt.
You can find some excellent tutorials on VbExplorer about BitBlt and many other things about drawing and manipulating bitmaps.

I don't know if these things apply in VB 4 which is much different from the other two so i would recommend you to move to VB 5 or 6.

However check the site's tutorials.They will help you.

Voodoo4


Edited by - Voodoo4 on July 18, 2000 12:31:16 PM

Share this post


Link to post
Share on other sites
I used the BltBit function in VB3, you just have to have the correct API reference copied to your VB app.

If I can find the code I used (it''s in a mag somewhere) I''ll post it here for you

Share this post


Link to post
Share on other sites
Ah... VB... my specialty.

You will have to use all the APIs to draw to the screen/desktop. GetDC(0) and ReleaseDC(0, hDesktopDC) are the functions you want to use to get the DC to the desktop. VB controls like PictureBoxes and Forms also have DCs.

If you don''t want to use any of them, then you will need to create a memory DC (hMemDC = CreateCompatibleDC(0)) and use LoadImage to load up a bitmap from the disk. Once that is done, you''ll need to use SelectObject (hOrigBMP = SelectObject(hMemDC, hMyBMP)) to put the bitmap in a DC. Whenever doing a SelectObject ALWAYS save what was there original because you need to restore it back before you DeleteDC(hMemDC).

Remember to always release all your GDI objects when you are done. Anything that you did a GetDC() with, you need to call a ReleaseDC. All non-system GDI object (except for DCs) need to be freed via the DeleteObject() function. All DCs you created need to be freed using DeleteDC().

Good Luck

PS: Keep you resource monitor open in your system tray so that you can see if you are creating/deleting your GDI objects properly

Dino M. Gambone

Good judgement is gained through experience. Experience, however, is gained through bad judgement.

Share this post


Link to post
Share on other sites
Hate to be the one to break up the party, but after 8 years experience in VB, I realised the following (and should have realised earlier)...

VB has crappy graphics support
VB has crappy API support - some things cannot be done or are difficult to perform due to...
VB has lack of pointers
VB is an interpreted language, not a compiled language (even after compiling, VB is just some code being interpreted by a virtual machine) making it slow at performing complex graphics operations - I made a brilliant iso engine in vb using bitblt, but i got about 4 fps even with drawing optimisations and all special effects turned off.

Therefore - VB is no good for high quality games.

Even using Microsoft''s new DX7 support for VB, I''ve found it was unnecessarily slow. DirectX can occasionally be slow in C++ as well, but it''s a lot better than in VB.

My suggestion...
If you want to make a career out of games development, take the time to learn C++ - you''ll thank yourself for it...
If you want to make a career out of writing business applications (not a bad career, but I''d prefer the first option) make sure you know VB real well, because VB is much better suited to databases and applications and is a great option for those situations.

Samah



"...the grave is no bar to my call..." - The Horn Of Valere

Share this post


Link to post
Share on other sites
1) VB does have pointers (StrPtr, ObjPtr, VarPtr functions) and all VB objects are really just pointers. It just doesn''t have a pointer data type (alla C/C++''s ''*'' and ''&'')

2) 95% of the APIs used to do game programming VB can use

3) VB''s performance is dramatically better in 6 since when compiled to native code it uses a C compiler.

4) VB is not a language used to make calculation intensive games, but a simple game like tetris or some less complicated game should not be a problem with VB.

----------HOWEVER----------
I agree with Samah. VB is not a language to do serious game programming with even with DX7. However, if you just want to play around with game programming using VB, go right ahead.

Good luck.

Dino M. Gambone

Good judgement is gained through experience. Experience, however, is gained through bad judgement.

Share this post


Link to post
Share on other sites