If you have any topics you want covered please e-mail to: firstname.lastname@example.org
| DirectX |
| Dos32 (DJGPP) |
| C++Builder |
| Graphics |
| Game Development |
How do I access the pixels in a DIRECTDRAWSURFACE directly?
You must use the Lock() member function with the parameter DDLOCK_SURFACEMEMORYPTR and a
DDSURFACEDESC struct. The struct's "lpSurface" member will then be valid. You can now write
directly to the pixel array.
memcpy(ddsd.lpSurface + offset, data, size * sizeof(BYTE));
Make sure you call UnLock() afterwards, because, if the surface you are writing to is the
primary surface or any of it's relatives, Windows stops multitasking until Unlock() is
called. In other words, if you don't call Unlock() when you're done updating, you just crashed your
system! Also don't take too long updating the surface or your system will freeze
up while your program is updating the screen.
WARNING!!! Not only is this a good way to corrupt system memory, the scanlines aren't always
equal to the resolution width! Always check the "lPitch" member before blitting. Also, if
you are using a color depth other than 8 bit, make sure you've packed your pixels the same
way the DirectDrawSurface has.
There is example code in the DirectX help files. E-mail me
if you still can't figure it out.
Dos32 (DJGPP) Resources
How do I access the video memory directly?
Use the "far pointer" functions:
For an example of how this is used download my MGFX library and check out the "Dos-based" source
code. Specificaly the Vesa640.cpp file. Another good resource is the DJGPP FAQ and INFO files.
How do I get a timer that is millisecond accurate under Windows 95?
The Windows API has a function called "timeGetTime()". It doesn't take any arguments and
returns the number of milliseconds elapsed since windows was started. The actual accuracy of
the timer is system dependent, but is usually better than 10 ms. This is what I use to keep
my applications running at a certain FPS. The function is defined in the "mmsystem.h" header
file and the .lib file is automatically linked in by BCB.
Okay. I got the timer, but my code is event driven. How do I get my function
called faster than once every 55 milliseconds?
C++Builder has an "OnIdle" property as part of the TApplication class. You can declare
a function in your TForm derived class to handle idle processing. You then assign that function
to the "Idle" property in your application's TApplication class. One of the parameters passed to the idle function is the "Done" variable. If this is set to "false", the VCL will keep calling your idle function. Now all you have to do is call Application->ProcessMessage() every once in a while, so your program doesn't appear to freeze up, and you've just taken over all the left over CPU time. Now just combine this with the Timer from above and you can simply choose a frame rate to limit your program to.
Not conviced? Want to see the source code? Here it is:
EXE: idle.zip (128K)
How do I make the graphics for my game?
You need a good paint program and real live artists. You'll also need some 3D modelling and rendering software if you plan to go the 3D route.
We recomend Jasc Software's Paint Shop Pro software package. It comes bundled with an animation package and is a very robust program. We actually prefer it over Adobe's PhotoShop. It's compatable with most PhotoShop plugins too. ;-)
On the 3D side of things, we recomend Nendo, by Nichimen Graphics, for beginners. It's intuitive interface and high degree of flexibility make it a best first choice. It's $99 price tag helps too. For more power, we recomend stepping up to Nichimen's comercial level 3D application Mirai. Mirai is a fully featured 3D development suit and is very powerfull. Last we checked it retails for $6500, but can be had for $650 if you are a student. These guys have a really good support team and it is definately worth shelling out the big bucks.
**PLUG ALERT** Or you can contract MotBC to create your graphics for you. View our custom software and consulting page for more details =)
Alright I'm ready to do some kick but coding, but I'm not sure where to begin. Where do I go for more info?
Check out Viper's C++ Page. It has a lot of usefull information and sometimes us MotBC guys hang out in his forums.
If you are viewing this page outside of its frameset, click here
to return to the index page.