DDraw basic drawing commands?
in VB DDraw, the LPDIRECTDRAWSURFACE7 class has a few basic drawing commands - DrawCircle, DrawBox, DrawEllipse, you get the idea.
How do you to this in C++?
Thanks again,
BeanDog
Simple Versioning System: Source code control for the common man.
[Edited by - BeanDog on January 15, 2006 12:49:29 PM]
I looked over the SDK help file description of it, and it goes into too much technicality.
Could you describe how the Lock/Unlock functions work in real life? VERY SHORT example maybe?
Hopefully,
Ben "Bean Dog" Dilts
Could you describe how the Lock/Unlock functions work in real life? VERY SHORT example maybe?
Hopefully,
Ben "Bean Dog" Dilts
HEY!
Wouldn''t it just be easier to use standard windows API or GDI or whatever calls on the surface? Can you do that? Would that be really slow compared to doing it myself using Lock/Unlock, what? What''s the verdict?
-Ben Dilts
Wouldn''t it just be easier to use standard windows API or GDI or whatever calls on the surface? Can you do that? Would that be really slow compared to doing it myself using Lock/Unlock, what? What''s the verdict?
-Ben Dilts
You can call GetDC to get a device context connected to the surface. With that you call your usual GDI functions. Just remember to call ReleaseDC when you''re done.
Lock() basically gives you a pointer to the surface data. Unlock() tells DirectX that your done using the data and it''s free to do as it pleases with it.
If you wan''t to use Lock() to do your drawing you have to implement each drawing routine yourself. So unless you''re really good at assembler you probably won''t see any speed enhancement over GDI.
Verdict: Use GDI.
Be warned though, GetDC/Lock slows down D3D, so if you''re using D3D you should implement the drawing routines with 3D calls.
Lock() basically gives you a pointer to the surface data. Unlock() tells DirectX that your done using the data and it''s free to do as it pleases with it.
If you wan''t to use Lock() to do your drawing you have to implement each drawing routine yourself. So unless you''re really good at assembler you probably won''t see any speed enhancement over GDI.
Verdict: Use GDI.
Be warned though, GetDC/Lock slows down D3D, so if you''re using D3D you should implement the drawing routines with 3D calls.
DDSURFACEDESC ddsd; // Structure to be filled with surface information
ZeroMemory(&ddsd, sizeof(DDSURFACEDESC));
ddsd.dwSize = sizeof(DDSURFACEDESC);
lpdds->Lock(0, &ddsd, DDLOCK_WAIT, 0);
unsigned short int* lpdest = (unsigned short int*)ddsd.lpSurface;
lpdest[x + y * ddsd.lPitch] = color;
lpdds->Unlock(0);
That would lock a surface (the entire surface), get the surface memory pointer (ddsd.lpSurface) and then draw a single pixel to it. Beware of the pitch, since you cannot always expect a surface to be linear.
You need to pay attention to what vid. mode you are in though. The way Staffan did it would really be messed up in a eight bit mode. For 8 bit color, use a unsigned char*.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement