Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > Game Programming > DirectX > [VB6] - Starting basic using Directx on VB6


Reply
 
Thread Tools Display Modes
  #1  
Old 01-13-2012, 12:53 PM
Cambalinho_83's Avatar
Cambalinho_83 Cambalinho_83 is offline
Senior Contributor
 
Join Date: Feb 2008
Location: somewhere in space
Posts: 1,279
Default [VB6] - Starting basic using Directx on VB6


i need a nice toturial for directx itself... every toturials that i found was for games, but i need a start thing for learn directx on basic. can anyone advice me?
Reply With Quote
  #2  
Old 01-13-2012, 04:16 PM
Flyguy's Avatar
Flyguy Flyguy is offline
Lost Soul

Super Moderator
* Guru *
 
Join Date: May 2001
Location: Vorlon
Posts: 19,057
Default

Why is it a problem that the tutorials are game oriented?
In almost all cases DirectX is used for games or 3D applications.

http://directx4vb.vbgamer.com/
Reply With Quote
  #3  
Old 01-13-2012, 04:50 PM
Cambalinho_83's Avatar
Cambalinho_83 Cambalinho_83 is offline
Senior Contributor
 
Join Date: Feb 2008
Location: somewhere in space
Posts: 1,279
Default

Quote:
Originally Posted by Flyguy View Post
Why is it a problem that the tutorials are game oriented?
In almost all cases DirectX is used for games or 3D applications.

http://directx4vb.vbgamer.com/
maybe because i learned on general. when we learn vb6, we don't learn for data, but how use the language and more
maybe is why.... sorry i still confuse on starting learn directx... so many things for initializate\load it
i need something for start learning, the basic.
i have 1 chm file from that page... thanks
Reply With Quote
  #4  
Old 01-13-2012, 05:52 PM
PlausiblyDamp's Avatar
PlausiblyDamp PlausiblyDamp is offline
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Nov 2003
Location: Newport, Wales
Posts: 1,931
Default

It looks as though http://directx4vb.vbgamer.com/DirectX4VB/TUT_DX8_DG.asp from that site should get you started as it seems a fairly straight forward walkthrough.
__________________
Intellectuals solve problems; geniuses prevent them.
-- Albert Einstein

Posting Guidelines Forum Rules Use the code tags
Reply With Quote
  #5  
Old 01-14-2012, 07:27 AM
Cambalinho_83's Avatar
Cambalinho_83 Cambalinho_83 is offline
Senior Contributor
 
Join Date: Feb 2008
Location: somewhere in space
Posts: 1,279
Default

Quote:
Originally Posted by PlausiblyDamp View Post
It looks as though http://directx4vb.vbgamer.com/DirectX4VB/TUT_DX8_DG.asp from that site should get you started as it seems a fairly straight forward walkthrough.
1 questiuon: i know these code is for clean the scren and give it a backcolor:
Code:
D3DDevice.Clear 0, ByVal 0, D3DCLEAR_TARGET, &HCCCCFF, 1#, 0
but '&HCCCCFF' can be expressesd in other way?(because i don't know what color is)
Reply With Quote
  #6  
Old 01-14-2012, 01:00 PM
Gruff's Avatar
Gruff Gruff is offline
Bald Mountain Survivor

Super Moderator
* Expert *
 
Join Date: Aug 2003
Location: Oregon, USA
Posts: 6,391
Default

I would imagine that any vb construct that resolves to a color value could be used instead. RGB(204, 204, 255), 13421823, vbBlue, Etc...
__________________
Burn the land and boil the sea
You can't take the sky from me


~T
Reply With Quote
  #7  
Old 01-14-2012, 01:14 PM
Cambalinho_83's Avatar
Cambalinho_83 Cambalinho_83 is offline
Senior Contributor
 
Join Date: Feb 2008
Location: somewhere in space
Posts: 1,279
Default

Quote:
Originally Posted by Gruff View Post
I would imagine that any vb construct that resolves to a color value could be used instead. RGB(204, 204, 255), 13421823, vbBlue, Etc...
but the directx works in same way(when recive these values the colors are real the same)?
Reply With Quote
  #8  
Old 01-15-2012, 12:55 PM
passel's Avatar
passel passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 7,914
Default

Yes, the color value is a long, and three of the bytes in the color represent the RGB (Red, Green, Blue) levels of the colors.
Gruff's first two examples are meant to be the same value as your example line of code, but Intel processors are little endian, and the red color comes first in memory, which is the lower byte of a long.
So, the same color that you have (which should be a very light red, (an off-white pink)), could be expressed in Hex, decimal, or RGB function
&HCCCCFF, 13421823, RGB(255,204,204).
Gruff just had the bytes reversed in the RGB function, following the big endian order that we print numbers in.
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.
Reply With Quote
  #9  
Old 01-15-2012, 01:27 PM
Cambalinho_83's Avatar
Cambalinho_83 Cambalinho_83 is offline
Senior Contributor
 
Join Date: Feb 2008
Location: somewhere in space
Posts: 1,279
Default

Quote:
Originally Posted by passel View Post
Yes, the color value is a long, and three of the bytes in the color represent the RGB (Red, Green, Blue) levels of the colors.
Gruff's first two examples are meant to be the same value as your example line of code, but Intel processors are little endian, and the red color comes first in memory, which is the lower byte of a long.
So, the same color that you have (which should be a very light red, (an off-white pink)), could be expressed in Hex, decimal, or RGB function
&HCCCCFF, 13421823, RGB(255,204,204).
Gruff just had the bytes reversed in the RGB function, following the big endian order that we print numbers in.
i need ask anotherthing: why, when we use the directx, after close the program, the IDE size is changed and otherthings?
Reply With Quote
  #10  
Old 01-16-2012, 01:28 PM
passel's Avatar
passel passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 7,914
Default

I don't do DirectX, but I assume it is because you're running the DirectX in full screen mode, and the screen resolution you choose is not the same as what you have Windows set to.
DirectX has to change the screen resolution to what you asked for, and if it is smaller than what Windows' resolution is, Windows will resize windows and possibly re-layout icons to fit in the new smaller resolution. If you revert back to a higher resolution when DirectX exits, the smaller windows and icon positions will still fit, and won't be resized back to an unknown previous size (although the icons may reposition if you have auto placement turned on).
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.
Reply With Quote
  #11  
Old 01-16-2012, 02:45 PM
Cambalinho_83's Avatar
Cambalinho_83 Cambalinho_83 is offline
Senior Contributor
 
Join Date: Feb 2008
Location: somewhere in space
Posts: 1,279
Default

Quote:
Originally Posted by passel View Post
I don't do DirectX, but I assume it is because you're running the DirectX in full screen mode, and the screen resolution you choose is not the same as what you have Windows set to.
DirectX has to change the screen resolution to what you asked for, and if it is smaller than what Windows' resolution is, Windows will resize windows and possibly re-layout icons to fit in the new smaller resolution. If you revert back to a higher resolution when DirectX exits, the smaller windows and icon positions will still fit, and won't be resized back to an unknown previous size (although the icons may reposition if you have auto placement turned on).
thanks for the help
note: my objective, using directx, is for speed up my graphics effects and image processing
Reply With Quote
  #12  
Old 01-28-2012, 05:05 PM
Cambalinho_83's Avatar
Cambalinho_83 Cambalinho_83 is offline
Senior Contributor
 
Join Date: Feb 2008
Location: somewhere in space
Posts: 1,279
Default

ok.. by testing, i can't use the vb colors constants. why?
Code:
D3DDevice.Clear 0, ByVal 0, D3DCLEAR_TARGET, vbYellow, 1#, 0
instead give me the yellow color, give me the cyan color. and the vbcyan give me the yellow color. theres more examples of these problem. can anyone tell me why?
the directx have 1 property\const for work with colors?
Reply With Quote
  #13  
Old 01-28-2012, 08:01 PM
passel's Avatar
passel passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 7,914
Default

Well, as I said I'm not a DX programmer, but obviously the format of the D3D color is not the same as the VB colors.
The VB color constants do not include alpha values, so I would think that would be an issue to start with. The order of Red,Green,Blue is probably reveresed in D3D, which probably aligns with the order used on the Web and .Net. The .Net constants can probably be used, but you may as well just create your own constants in your code.

There are a number of methods provided to set the D3DCOLOR type, i.e.
D3DCOLOR_ARGB
D3DCOLOR_AYUV
D3DCOLOR_COLORVALUE
D3DCOLOR_RGBA
D3DCOLOR_XRGB
D3DCOLOR_XYUV

Just use whichever of those you like, define what colors you want, and move on.

There are only a handful of VB constants anyway, so you can create your own set of constants in your code to replace them.
There is any number of ways to pull the Red, Green and Blue values from the VB constants, but I'll give another example.
Code:
Option Explicit

Private Type Colr32
  Colr As Long
End Type

Private Type RGBA
    R As Byte
    G As Byte
    B As Byte
    A As Byte
End Type

Private Sub Command1_Click()
  Dim colorStruct As RGBA
  Dim colorVal As Colr32
  
  With colorStruct
    colorVal.Colr = vbRed
    LSet colorStruct = colorVal
    Debug.Print .R, .G, .B
    
    colorVal.Colr = vbCyan
    LSet colorStruct = colorVal
    Debug.Print .R, .G, .B
    
    colorVal.Colr = vbWhite
    LSet colorStruct = colorVal
    Debug.Print .R, .G, .B
  End With
End Sub
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.
Reply With Quote
  #14  
Old 01-29-2012, 07:52 AM
Cambalinho_83's Avatar
Cambalinho_83 Cambalinho_83 is offline
Senior Contributor
 
Join Date: Feb 2008
Location: somewhere in space
Posts: 1,279
Default

thanks for the help.
heres the line updated:
Code:
D3DDevice.Clear 0, ByVal 0, D3DCLEAR_TARGET, D3DColorRGBA(0, 0, 255, 255), 1#, 0
the order of the color is RGBA. in these case the selected color is Blue. and we don't need the alpha value, that's why we put 255(the max value).
thanks

Last edited by passel; 01-30-2012 at 03:50 PM.
Reply With Quote
  #15  
Old 01-30-2012, 03:44 PM
passel's Avatar
passel passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 7,914
Default

If you didn't need the Alpha (default to 255), you could have done.
D3DDevice.Clear 0, ByVal 0, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 255), 1#, 0
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.
Reply With Quote
  #16  
Old 01-30-2012, 04:12 PM
Cambalinho_83's Avatar
Cambalinho_83 Cambalinho_83 is offline
Senior Contributor
 
Join Date: Feb 2008
Location: somewhere in space
Posts: 1,279
Default

Quote:
Originally Posted by passel View Post
If you didn't need the Alpha (default to 255), you could have done.
D3DDevice.Clear 0, ByVal 0, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 255), 1#, 0
thanks for that information
now i'm with 1 problem: when i close the program(using the fullscreen code), the VB6 IDE window size is changed. can i avoid these problem?
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
 
 
-->