Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

DmGoober

Is 2D completely dead in DirectX?

This topic is 5949 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok, so microsoft, at the behest of graphics card makers everywhere, has removed direct access to surface memory. (to understand why they removed direct draw see one of my long winded posts or read: http://www.reactorcritical.com/preview-directx8/preview-directx8_5.shtml) But is 2d really dead? Arguments for 2d still being alive: 1) We still have CopyRect! Using CopyRect, we can put 2d images to the screen. Of course, these 2d images must be pre-made bmp, jpegs, etc. 2) Well that doesnt matter, cause almost everything these days is a premade graphic anyway! That''s true -- look at Starcraft. There is no need to draw single pixels in starcraft. Everything is a premade bitmap -- from the cursor, to the indvidual units. 3) We can technically still draw lines -- by setting the device to wireframe and rendering two connected vertices. True. Arguments for the death of 2d: 1) How in the hell can we make tron style games anymore? True -- without direct access to surface memory, writing tron or worms games will take twice as much memory! We''ve got to allocate a second array to represent each pixel. . . 2) How can we write missile command style games anymore? Hmm. We can use two vertices and wireframe mode to draw missiles. . . but that''s such a pain in the butt! 3) How can we write artillery style games with deformable landscapes? Hmmm. That''s pretty tough. 4) How can we write starfield simulators? Uhhh. . . individual vertices using point style rendering. . . 5) How can I write maze games where my player controllable sprite is only one pixel large? Ok this is getting ridiculous. . . try playing a game where a single pixel matters in 1024 resolution. You''ll go nuts! Ok. So to me it seems that the removal of direct access to vid memory has just stopped us from easily programming a lot of old school games. . . but beyond that, i don''t think the removal of direct draw has hurt programmers too much (speed issues aside). but i think it has helped video card makers immensly. Post your thoughts. I''d like to hear of other ways that the removal of directdraw has truly hurt programmers. . . i can''t think of many.

Share this post


Link to post
Share on other sites
Advertisement
Hmmm

you guys dont understand that the lack of freedom is bad

Well we cant make anymore games like:
Starcraft
Red Alert
Age of Empires
Cossacks
Battlecry
Diablo I and II
(one of the best games ever)

we also cant make DEMOS like in the DEMOSCENE, we cant invent strange funny filters (other then FSAA) we just cant make in software anything that the hardware dosent have yet (2D i mean)

Not to speack that basically all 3D is based on fast 2D in the card so u loose a level under your feet ....you now are on thin air ...

Its a sad day for computers and software...

After all thats all about software... it has to be able to do all the things that hardware cant do for now...

maybe a happy day for profit making big company that convinced you to give away somenthing for they can make more big bucks..

Anyway i will continue to make 2D and hopefully omething diffrent from a Doom clone....someday

Bogdan

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I hear you Bogdan... I love 2d games, especially for RTS''s and RPG''s. Not a single 3d RTS has had that wonderful feeling of a static environment and total control, it''s either a 5 hour tutorial on how to control the camare (ahum... no names or just too much of unnecessary features like rotation and such. I''m planning on making a strategy game and I''ll use 2d, that''s for sure.

cheers,
--- pelle

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
"..... at the behest of graphics card makers everywhere, has removed direct access to surface memory."
How did you get this idea? I refer to the DirectX sdk help.

Accessing Surface Memory Directly
You can directly access the surface memory by using the IDirect3DSurface8::LockRect method. When you call this method, the pRect parameter is a pointer to a RECT structure that describes the rectangle on the surface to access directly. To request that the entire surface be locked, set pRect to NULL. Also, you can specify a RECT that covers only a portion of the surface. Providing that no two rectangles overlap, two threads or processes can simultaneously lock multiple rectangles in a surface. Note that a multisample back buffer cannot be locked.

The LockRect method fills a D3DLOCKED_RECT structure with all the information to properly access the surface memory. The structure includes information about the pitch and has a pointer to the locked bits. When you finish accessing the surface memory, call the IDirect3DSurface8::UnlockRect method to unlock it.

While you have a surface locked, you can directly manipulate the contents. The following list describes some tips for avoiding common problems with directly rendering surface memory.

Never assume a constant display pitch. Always examine the pitch information returned by the LockRect method. This pitch can vary for a number of reasons, including the location of the surface memory, the display card type, or even the version of the Microsoft® Direct3D® driver. For more information, see Width vs. Pitch.
Make certain you copy to unlocked surfaces. Direct3D copy methods will fail if called on a locked surface.
Limit your application''s activity while a surface is locked.
Always copy data aligned to display memory. Microsoft® Windows® 95 and Windows 98 use a page fault handler, Vflatd.386, to implement a virtual flat-frame buffer for display cards with bank-switched memory. The handler allows these display devices to present a linear frame buffer to Direct3D. Copying data unaligned to display memory can cause the system to suspend operations if the copy spans memory banks.
A surface may not be locked if it belongs to a resource assigned to the D3DPOOL_DEFAULT memory pool. Back buffer surfaces, which may be accessed using the IDirect3DDevice8::GetBackBuffer and IDirect3DSwapChain8::GetBackBuffer methods, may be locked only if the swap chain was created with the Flags member of the D3DPRESENT_PARAMETERS structure set to include D3DPRESENTFLAG_LOCKABLE_BACKBUFFER.


Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:
Original post by Anonymous Poster

"..... at the behest of graphics card makers everywhere, has removed direct access to surface memory."
How did you get this idea? I refer to the DirectX sdk help.

Accessing Surface Memory Directly
You can directly access the surface memory by using the IDirect3DSurface8::LockRect method.


This is true, I think it''s access to the front buffer that they took away, but that''s not a problem, we always have the back buffer.

- Anthony Graham

Share this post


Link to post
Share on other sites
quote:
Original post by Anonymous Poster

[quote]Original post by Anonymous Poster

This is true, I think it''s access to the front buffer that they took away, but that''s not a problem, we always have the back buffer.

- Anthony Graham


YOU CANNOT ACCESS SURFACES DIRECTLY!

Yes, you can lockrects. But after you lock them, the only action that you can perform is to copy from another surface, which is technically not accessing the memory directly.

Take a look at IDirect3dsurface interface. There are the following functions:
GetDevice
GetContainer
GetDesc
LockRect
UnlockRect
FreePrivateData
GetPrivateData
SetPrivateData

None of these allows access to memory. Getprivatedata is the only thing that returns a pointer to something -- and that pointer is simply a void * which represents "private data." private data is, according to SDK help:
"Associates data with the surface that is intended for use by the application, not by Microsoft® Direct3D®."

There is no direct access, no matter how badly the sdk help file describes it. This was a conscious design decision at behest of hardware makers.

Again i refer you to:
http://www.reactorcritical.com/preview-directx8/preview-directx8_5.shtml

Share this post


Link to post
Share on other sites
quote:
Original post by bogdanontanu
you guys dont understand that the lack of freedom is bad



Yes, lack of freedom is bad. But what you have to understand is that forcing hardware makers to conform to directdraw standards is also a lack of freedom. Hardware makers weren''t allowed to make arbitrary optimizations if they violated the directdraw standard. So it was a choice between freedom for progammers and freedom for hardware. Hardware won out. (don''t forget, if hardware doesn''t support directx directx dies. MS prolly figured programmers would find a way around it.)

quote:
Original post by bogdanontanu
Well we cant make anymore games like:
Starcraft
Red Alert
Age of Empires
Cossacks
Battlecry
Diablo I and II
(one of the best games ever)



Umm, why not? Just because you can''t blit each individual pixel of a Reaver, doesn''t mean that you can''t CopyRect a sprite of a reaver onto terrain. The only 2D games that are more difficult to program are games where individual pixels make a difference.

quote:
Original post by bogdanontanu
we also cant make DEMOS like in the DEMOSCENE, we cant invent strange funny filters (other then FSAA) we just cant make in software anything that the hardware dosent have yet (2D i mean)



Ok i concede the point to you on this one. but honestly, how many people make demos? Not only that, but the point of directx is it allows programmers to write a decent looking game with great game logic and gameplay without having to think too much about graphics. Using asm and direct access to memory allows you to write amazing look demos, with absolutely no input whatsoever. Yes demos are amazing, but i''ve spent hundreds of hours playing a game with good gameplay and medicore graphics, and maybe a sum total of 5 minutes staring at a demo. directx is not designed for everyone, but it serves it purpose: make graphics/networking/sound easy, so programmers can focus on gameplay.

quote:
Original post by bogdanontanu
Not to speack that basically all 3D is based on fast 2D in the card so u loose a level under your feet ....you now are on thin air ...



Obviously this is forum of software designers, not hardware designers. It really shows on our view of the world.
The reason that MS removed directdraw is so that hardware makers could make their own optimizations in 2d rendering, without having to worry about conforming to directdraw. In doing so, hardware makers have taken the responsbility of creating fast blits using hardware. So the questions becomes: Can a software person optimize his or her code so that it runs faster than a hardware optimization? Well, maybe. I guess really good software designer could probably write optimizations specific to a certain graphics card that would be faster. But who wants to write optimizations for every graphics card out there? Besides, software is built on hardware. The hardware limits the optimizations that software designers can make. . . so directx takes the approach: Hardware will do optimizations however hardware wants. Programmers don''t want to know about every optimization of every graphics card (that''s the point of directx -- otherwise just go back to DOS and write a graphics driver for every graphics card that you think is availible). So, we''ll let the graphics card handle the graphics, and let the programmer request that the graphics card do something. Hopefully, the graphics card will do it quickly and well.

quote:
Original post by bogdanontanu
After all thats all about software... it has to be able to do all the things that hardware cant do for now...


But what if hardware can do it? Do we program to the lowest common denominator? I''m not asking that question rhetorically. It''s a good and scary point -- we are now tied to hardware! Hardware becomes part of the game (look at the asus see thru walls cheat for halflife.) It is kind of scary.

quote:
Original post by bogdanontanu
maybe a happy day for profit making big company that convinced you to give away somenthing for they can make more big bucks..



Uh you speak as if directx and directdraw are our god given rights. . . =) You can always use directx 7 (that is until hardware makers decide that their optimizations out pace the old directdraw standard, and decide to stop supporting directx 7 and directdraw.)

But you are right, there are certain things that are scary about the whole thing. . . but in truth, directx is a standard that is created mainly by hardware gurus. . .

DmGoober

Bogdan

Share this post


Link to post
Share on other sites
IDirect3DSurface8::LockRect return a D3DLOCKED_RECT-struct and it looks like pBits is a pointer to the surface:

D3DLOCKED_RECT
Describes a locked rectangular region.

typedef struct _D3DLOCKED_RECT {
INT Pitch;
void* pBits;
} D3DLOCKED_RECT;

Members
Pitch
Pitch of surface, in bytes.
pBits
Pointer to the locked bits. If a RECT was provided to the LockRect call, pBits will be appropriately offset from the start of the surface.
Remarks
The pitch for DXTn formats is different from what was returned in DirectX 7.0. It now refers to a row of blocks. For example, if you have a width of 16, then you will have a pitch of 4 blocks (4*8 for DXT1, 4*16 for DXT2-5.)

Requirements
Header: Declared in D3d8types.h.



Edited by - gyzmo on November 25, 2000 1:59:35 PM

Share this post


Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!