Skip to main content
GameDev.net gamedev.net
🔒 Locked

2D on 3D

Started by Wayfarer May 7, 2000 at 9:48 PM 9 replies 800+ views
Original Post
Wayfarer
Wayfarer
I''m moving some of my 2D drawing routines to use D3D IM, so I can take advantage of things like 3D hardware alpha-blending and such, and I would like to know how to draw rect and line primitives in 3D given screen coordinates only? For example, if I want a horizontal line to appear exactly at screen coords 100,150 to 200,150, how would I draw this in 3D? Does it matter how I setup my transformation matrices, projection, view, etc.?
MadKeithV
MadKeithV
Hehehe bracket Must feel good to have so much response to your article!

#pragma DWIM // Do What I Mean!
~ Mad Keith ~
**I use Software Mode**
It's only funny 'till someone gets hurt.And then it's just hilarious.Unless it's you.
Wayfarer
Wayfarer
So if I use D3DTLVERTEX to put a rect or line primitive exactly on the
screen where I want, what are the members D3DVALUE rhw and D3DVALUE sz used for?
How do these two values affect the screen position of the primitive? Do I even
need to set these two when all I want is something that looks 2D?
Bracket
Bracket
sz isn''t used for 2D coordinates - how could it be? I tend to leave rhw at 1.0f to ensure that textures plot properly, since we can''t calculate "1/z" in a meaningful manner. The point of D3D''s flexible vertex format is that you choose the stage of the transformation pipeline you want to interact with, and enter relevant data only.

MadKeith: yes, it feels great to be in demand, although the BIG downside to writing an article like that is the sheer volume of email I get asking the same questions!
Wayfarer
Wayfarer
That was me. This default to anonymous poster is annoying as hell.

Wayfarer
SoGreen
SoGreen
Your last pixel isnt being drawn because the co-ordinates are inclusive-exclusive.

The first co-ord is included in the draw, but the last one is not, to get the last one to appear just increase your end co-ordinates by 1.
There's always something smaller and something bigger. Don't sweat the small stuff and don't piss off the big stuff :)
bogdanontanu
bogdanontanu
Take care all
Ihave tested Enhanced2D on a P150/64M video S3DX/GX with 4Mb VRAM and it does very poor: 1,5 fps at maximum...

On the other side my 2D asm routines (wo lights )
does better every time from 10 to 20 fps (full screen with a 240x320 alpha surface and scroll and may other things)

so 3D is NO Solution for low end PC...but maybe u dont want that market (at least not in USA)
still remember that not every guy is upgradeing his PC every year and USA standards are not (yet) standards for the world....

On the other hand it does better on my P2/400/128M/Voodo3
(150 up to 200 fps) but i think its my Vooodo that helps a loooot... i will try it on other boards ....


Regards
obysoft
Bracket
Bracket
bogdanontanu: I tend to agree with you about performance on low-end PCs. Anything much below a P120 struggles with D3D rendering, although the most important factor seems to be graphics card fill rate. If you are lucky enough to have a card with decent triangle-fill rate (and ideally at least 2 Mb texture memory), you get pretty good framerates. I tested a P150 with a Voodoo 1 and achieved a 20-30 fps for an average isometric scene. OTOH, using a Matrox Millenium or the old NV1 chipset (whose triangle fillrates were abysmal), was too slow to be worth measuring. Still, nothing I write really targets much below a PII-233 Mhz. If an audience that "small" is good enough for EA, its good enough for me!

I do think that with a combination of well-structured code and appropriate use of assembler (ASM is wonderful, but there is no point optimizing code thats called infrequently!) you could probably come up with a software gouraud triangle shader that would give decent framerates on low-end pentiums. I mean, if Unreal can run on a Pentium 200 in software mode, it is possible! About a year ago I experimented with Allegro''s (using DJGPP for DOS) shaded triangle rendering to achieve similar results. I was thinking of optimizing this beyond the 5 fps I achieved, but I picked up Visual C++ and started actually using my neat hardware! :-)
Wayfarer
Wayfarer
I was hoping including this line would fix my missing pixel problem:

d3d_device->SetRenderState( D3DRENDERSTATE_LASTPIXEL, FALSE );

But it didn''t do nothing.

Any ideas other than extending my line by 1 pixel? Is there something
else I have to enable/disable to get this thing to plot correctly?

Wayfarer

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.