Click to See Complete Forum and Search --> : DIRECTX8 - Modularity
danday1974
Aug 30th, 2002, 01:24 AM
Hi I am using VB 6.0. I want my DX8 project to run fast (50 fps at a resolution of 800 x 600) and I want to make it modular. I know of 2 approaches at the moment.
1) Use classes - is this too slow?
2) Use ActiveX DLLs - is this too slow?
I know how to work with both approaches but I was wondering if they are efficient. Are there any other approaches on offer that work better or do these work well?
I would appreciate any tips. Thanks in advance.
DAN
Zaei
Aug 30th, 2002, 08:43 AM
Both are COM based, and are therfore going to be the source of a slowdown. VB does not lend itself very well to combining modularity and speed. When it comes to business applications that require modularity, it offers a LOT of freedom with COM, but at the expense of speed. To this end, you are not going to have a very modular game, or you are not going to ahve a very fast game. If you REALLY need the modularity, you are going to have to learn some C++ (or some other Object Oriented language).
The other problem that you are going to run into is the speed of VB itself. It is quite easy to get a fast running application running with DirectX, but that is ONLY because DirectX is HIGHLY optimized. What is going to start slowing you down is the VB inbetween the DirectX calls, the logic, and such. While this is not a real problem, as long as you keep your logic to a moderate level, it can become one if you tried, for instance, some complex AI.
In the end, your best bet is to use various UDTs, with functions that act on those UDTs.
Z.
Machaira
Aug 30th, 2002, 10:26 AM
Exactly what do you mean by modular? You can put all of your graphics code in a regular module, all of your sound code in another module, etc. Using classes will not necessarily slow down the game below the specs you've given. It depends on the type of game you're creating. I'm using about a dozen and a half classes in my RPG.
Also, why do you think you need it to run at 50 fps, instead of say 40 or 30? Frame rate is not necessarily the be all and end all of a game. What type of game are you working on?
danday1974
Aug 30th, 2002, 01:36 PM
Thanks for the advice guys.
UDT = User Defined Type?
So basically Z u r saying if speed is more important than modularity then keep it all in one file?
Thankfully I wont be needing any AI since I am just having to make a walkthrough of my college, walls, sinks and stuff. Nothing that runs around trying to shoot u :).
In reply to the other guy. Well I guess 30 or 40 FPS is acceptable but 50 is my ideal target. Quite tough since with the bare minimum I only start at 180 FPS. Also I want to allow changes to higher resolutions. If it runs at 30 FPS in 800x600 u can guarantee bumping the res up to 1024x768 will mean an unacceptable frame rate at that res.
Also by modular I just mean in different files be that a .cls file or a .dll file.
Cheers again lads
Dan
danday1974
Aug 30th, 2002, 01:42 PM
Z
By the way do u know any sites as good as www.directx4vb.com but for C++ instead?
If not I guess Ill stick to VB since my time is limited to learn this stuff. The project has to be in in 9 months and I will soon have lots of other college work to do.
Thanks
Dan
PS When u learn DirectX8 in VB is it easy to apply the knowledge you have learnt to C++?
PPS Considering my time scale Z and that I have only ever programmed C++ for small 'crappy' college projects (although I do have a good BASIC grasp) do u think it would be too much for me to move over to C++ now?
Zaei
Aug 30th, 2002, 04:50 PM
Machaira: That is code modularity, not Binary Modularity.
UDT means User Defined Type, yep. If speed is the most important, just one exe is best, for VB.
When increasing resolution, the thing that is important is fill rate. For instance, at 300x300 resolution, with, say, 900 triangles transformed, 2700 vertices are being transformed, and 90000 pixels are being drawn to the screen. At 1000x1000 resolution (I am making up these resolutions so they are easy to square, by the way =), with 900 triangles, you are STILL transforming 2700 vertices, but you DRAW 1,000,000 pixels. Obviously, the speed at which your video card (HW accelerated rendering, even on older cards, all drawing is done in hardware, while on newer cards, the vertices are also transformed in hardware) can draw pixels.
I first learned DX8 with VB, and http://www.directx4vb.com . Once I got a little experience with C++, I decided to give it a go. To tell the truth, the difference between using DX8 in C++ and VB is VERY small. There are a few differences, but the majority is the same. As time went on, I STILL used the DirectX4VB site, even while implementing the things in C++.
On the other hand, given your timescale, I wouldnt go C++ since there is a lot of getting used to, and you want to spend most of your time getting your project right.
Z.
danday1974
Aug 30th, 2002, 05:21 PM
Z
Thanks sounds like sound advice :).
My lecturers wont be pleased not to see modularity but I can just explain wot u told me using really long words to confuse em ;).
Maybe Ill go over to C++ if I decide to go into this for a career (Im toying wiv the idea since I enjoy it) but Im thinking is there enough cash in it. Maybe Ill stick to embedded systems as far as careers go. There seems to be loadsa money in that.
Cheers again Z.
Dan
PS Am working on billboards now. Off to find out what Sin and Cos mean ;) scary stuff!
PPS Z do u do this for a living? Working wiv DX I mean
Zaei
Aug 30th, 2002, 05:30 PM
If they want modularity, they shouldnt be teaching VB =).
Actually, if you want, you could throw some code into an ActiveX DLL, and stick your Initialization code in it =). No slowdown, etc.
If you wanted to do this for a career, you would HAVE to go C++. Its the industry standard, so, not only is it a trendy thing to do, its also a much cleaner way to program games.
If I had my way, I would definately do this for a living, but not at the moment =).
Billboarding is actually a Matrix Trick. Let me post a snippet of code for you =).
Z.
danday1974
Aug 30th, 2002, 05:37 PM
lol at not teaching VB ;)
Cheers for the making Init modular, thats a good idea :). If they see a dll they will think I am the man.
Code -- cool, Ill check back in a min to see if it is here.
Hey Z mate u r so good at this stuff u should try and get a job in it. I rekon u'd breeze through an interview.
Cheers
Dan
Zaei
Aug 30th, 2002, 05:39 PM
Public Sub MatrixMatrixBillboardTranspose(result As D3DMATRIX8, a As D3DMATRIX8 , x As Single, y As Single, z As Single)
result._11 = a._11
result._12 = a._21
result._13 = a._31
result._14 = 0.0
result._21 = a._12
result._22 = a._22
result._23 = a._32
result._24 = 0.0
result._31 = a._13
result._32 = a._23
result._33 = a._33
result._34 = 0.0
result._41 = x
result._42 = y
result._43 = z
result._44 = a._44
End Sub
That SHOULD work (dont remember the exact name for a Matrix in VB =). That comes out of my matrix library. Simply pass in a matrix that will hold the result of the operation. The second matrix is the current View matrix, and the last parameters should be the center of the billboard that you want to face the camera. Then, Multiply each vertex in your billboard by that matrix, and save it into your vertex buffer, or array (if you use DrawPrimitive, or DrawPrimitiveUP, respectivly). Then just render them =).
Z.
[edit]
Please forgive my wierd function name =).
danday1974
Aug 30th, 2002, 05:59 PM
Z
That code looks a lot easier than the direct4vb code.
OOO I hate maths.
Im gonna play wiv both methods and see which 1 i find more comfy.
Yours does look more efficient tho
Cheers
Dan
Machaira
Aug 31st, 2002, 01:33 AM
Originally posted by danday1974
Z
Maybe Ill go over to C++ if I decide to go into this for a career (Im toying wiv the idea since I enjoy it) but Im thinking is there enough cash in it. Maybe Ill stick to embedded systems as far as careers go. There seems to be loadsa money in that.
Have to confirm what Z said. C++ (specifically Visual C++) is pretty much the standard. There are some companies that use other compilers but the language is what you'll have to learn. How much money you make in the industry depends on where you live and what company you hook up with. I made pretty good money while I was in it. Also, sometimes it's not just about the money. You should enjoy what you're doing. I sometimes hated business programming, but I loved pretty much everything about game programming. And you usually can't beat the perks. Going to work in shorts and a t-shirt is my idea of the perfect dress code. :)
Zaei
Aug 31st, 2002, 11:34 AM
Money is not all that important, I must agree. As long as you can live on it, and pay for the cable connection, and the electricity to run your computer, its enough, in my book =). And of course, if you hate what you are doing, the money will NEVER be enough =).
Z.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.