Amrazek
Squire
40 Posts |
Posted - Mar 24 2003 : 6:21:47 PM
|
Don't go and explode on me! I'm perfectly aware that DirectDraw doesn't support lighting... Natively. I want to write my own functions to do it for me, using GetLockedArray() and modifying the memory.
However, before I continue with what I already have, I'd like to get assured on a few things:
1) The longs in the array returned from GetLockedArray() are NOT normal colors, and I have to somehow convert them.
2) The array from GetLockedArray() will have the same dimensions as the screen, right?
3) Some of the lighting code from www.Directx4vb.com will work, with slight modification.
4) I CANNOT make DLL calls while I have a surface locked, correct?
Thanks! -Amrazek |
|
Eric Coleman
Gladiator
USA
811 Posts |
Posted - Mar 24 2003 : 9:11:08 PM
|
I'm not really sure about most of that, but for question 4, once you have the array of data, you could pass a pointer to the array to a DLL call to do some fast color manipulation.
|
|
|
Amrazek
Squire
40 Posts |
Posted - Mar 24 2003 : 9:58:40 PM
|
quote: the debugger will not work whilst you are processing memory. Between the Surface.Lock and Surface.Unlock methods windows ceases execution, this is because directdraw takes the win16mutex which basically suspends windows. Because windows is effectively shut down you must do NOTHING complicated or invloved with other components. ie. No DLL calls, no file access and no running of other applications
That's straight from www.DirectX4VB.com... So I guess I must either settle for VB's pathetic speed or ... not heed this warning. I suppose there are other ways, as well, but I want to think the entire thing through. I guess I'm going to try my current code now and pray that Windows doesn't crash, but the only way not to be surprised is to prepare for the worst
I'll post anything I find. I'm going to start by attempting to answer my own questions... |
|
|
Eric Coleman
Gladiator
USA
811 Posts |
Posted - Mar 25 2003 : 01:17:12 AM
|
If you read the SDK, then you'll see that you're supposed to include the DDLOCK_NOSYSLOCK flag when locking a surface. This prevents the win16mutex problem, which only occurs on 95,98, and ME. And the only time the win16mutex causes a problem is if you lock a surface and then fail to unlock the surface, or if you lock a surface too often. If you lock your surface a few times per frame, then you shouldn't have any problems. If you lock the surface too many times per frame, then you'll end up slowing down windows, and your program will be effected, thus slowed down too. |
|
|
Amrazek
Squire
40 Posts |
Posted - Mar 25 2003 : 5:57:16 PM
|
Interesting. Is there any downside to using that flag? I want it to be as fast as possible, because I really can't afford to do all the game math, rendering, misc engine stuff, and THEN do lighting. Not to mention AI. I'm double-checking my code now before I run it, as it may lock up my computer if I screwed up even one little detail. |
|
|
Eric Coleman
Gladiator
USA
811 Posts |
Posted - Mar 25 2003 : 8:50:54 PM
|
Have you looked at the "fire" source in the SDK? I'm sure that will tell you all you need to know to access the memory directly.
For lighting, accessing the surface directly will be slow. To speed things up, you might want to consider precalculating the light. |
|
|
Amrazek
Squire
40 Posts |
Posted - Mar 26 2003 : 10:07:36 AM
|
That was the idea -- just hold all the calculated data in an array, and have the program that's accessing my engine tell it when it needs to recalculate. That way, if a light on, say, the floor tiles doesn't affect a character or things moving over it, it wouldn't ever have to be calculated again.
|
|
|
AT
Squire
18 Posts |
Posted - Mar 26 2003 : 10:47:59 AM
|
Looking at your last few posts ... making a diablo-style game ? |
|
|
Eric Coleman
Gladiator
USA
811 Posts |
Posted - Mar 26 2003 : 3:14:30 PM
|
I have a suggestion on how you can do lighting easily in a tiled direct draw game. The first requirement is that the game use tiles. Then, you create a light map, and then alpha blend the light map over tiles that need lighting. As long as the lights don't move, you can alpha blend the light map onto tiles once, and then use the lit tile for speed.
If you use 16 bit color, then you could use the vbdabl.dll to do the alpha blending. There is the .dll, source, and example programs at VoodooVB.
If you want to use 8 bit alpha blending, then you'll need to use lookup tables. There is a very good example of 8 bit palleted alpha blending at Unlimited Realities |
|
|
Amrazek
Squire
40 Posts |
Posted - Mar 26 2003 : 5:41:06 PM
|
Good suggestion -- I'll certainly give it a shot. And AT, I have been looking at starting a Diablo-style game... I've been getting into it a lot recently, for entertainment, as well as ideas. Some of the things done in Diablo are quite clever, and since I'm looking into being in the game industry, being 'up on it' sounded like a good idea. But before I begin, I've firmly decided to finish at least one game first. I'll need the experience, as well as the ideas, to work on such a ridiculously difficult genre. Not to mention artists... Which, somehow, has brought up another diablo-ish question: how do they do their terrain tiles? It seems almost as if they are all unique, but anybody that looks closely will notice the pattern. Realism is something that I believe many VB RPGs miss, and every little bit helps. I would guess that the designers draw up some sort of sketchy map, and the artists look at it and draw it themselves by hand -- or do they draw the entire thing out, and then break it up into smaller tiles? I know it's professionally done, but knowing the method may make my own come out better. |
|
|
AT
Squire
18 Posts |
Posted - Mar 26 2003 : 6:09:34 PM
|
By tiling things at an angle instead of simply horizontal/vertical types you can hide the effect to some extent. Again - if you can get at the tile graphics in diablo you could have a look. I do think the tiles are different sizes (so you might have a couple of 32x32 tiles alongside a 256x256 graphic) which helps to break things up. As long as you can't see obvious tiling in any one screen - you tend not to notice that the shrub a couple of screens down looks just like the one you passed a minute ago. As for maps - the diablo maps are partially random. But usually artists won't make tiles specifically for each bit of a map, but instead generic tiles (all the types required to go into the editor - ground, walls, trees, etc) - plus any specific objects needed. The designer should specify this - e.g. 'I want grass, mud, stone, some wooden huts, and one big wooden hut with purple light shining out of the windows'.
Getting into the games industry is a pain in the a*** ... |
|
|
Amrazek
Squire
40 Posts |
Posted - Mar 26 2003 : 9:12:38 PM
|
Different tile sizes? Interesting. I DO know that they have several larger objects, and populate the basic map with them. This seems to be mainly pillars, interactive objects, and torches, but it varies with the type of map.
quote: Getting into the games industry is a pain in the a*** ...
I've had that general feeling for a while now Why, in your opinion, is it difficult? |
|
|
AT
Squire
18 Posts |
Posted - Mar 26 2003 : 9:33:14 PM
|
As far as different tile sizes go - think multiples (essentially just a group of tiles which are put down together, because they don't 'tile' with other graphics otherwise). If you have starcraft - take a look at the tiles in the editor. There is a good chance that diablo (another blizzard game) has a similar system. http://www.hyperfictions.com/groundtile1.jpg - good artists are pretty damn important unless you want to make another rpg2000 lookalike.
As for the games industry - too many people for too few jobs. Junior positions are rare and experience is very important (not helpful if you are trying to start out). |
|
|
Amrazek
Squire
40 Posts |
Posted - Mar 27 2003 : 08:14:48 AM
|
I keep getting an automation error when attempting to unlock a surface. I think I'll have to take a closer look at that fire example.
On a side note, I've managed to get DirectDraw to do alphablending and rotation |
|
|
Amrazek
Squire
40 Posts |
Posted - Mar 27 2003 : 09:10:04 AM
|
I've got memory access working, at least, but I'm still trying to figure out how it all works. I'm about 50% done now. |
|
|
Eric Coleman
Gladiator
USA
811 Posts |
Posted - Mar 27 2003 : 7:21:51 PM
|
Are you using the rotation.dll? |
|
|
|
|