Discussion:
managed directx - initial experience
(too old to reply)
Daniel Biesiada
2007-07-10 13:46:13 UTC
Permalink
Hello,

I must say I'm not good in DX but in my spare time I wanted to play a little
bit with its managed incarnation.

Maybe I'm not smart enough but I find real difficulty not with the
technology itself but lack of good documentation which would step by step
introduce some advanced tricks and framework's behaviour.

Currently I see below two difficulties:
1) 2d Stuff (3d I think also can matter later in this issue)

I don't know how to make such an effect that I have a texture with inregular
shape and and a single shape I could use as colorkey for transparency.
I'd like to render such a texture as a 2d sprite with that key color being
transparent and the rest with % transparency to the back surface prior to
rendering.
Can you help?

Is there any indicator why no 3d object is rendered Sprite.Draw2D() renders
nothing? I just found such a ridiculous behaviour and cannot get a clue why
it'd happen. :)

2) 3D stuff

I'm looking for a nice Pixel/Vertex shader HLSL tutorial which could explain
me logically step by step about the elements inside the code.
I've managed some basics of Pixel Shader from SDK examples but still I'm not
sure about certain things.
If you can recommend me some good online resources I'd be glad (I searched
some but I'm not satisfied).
If not can anybody tell me if ShaderX series of books are good as a
complementary resource?

best regards,
db
Daniel Biesiada
2007-07-11 10:15:11 UTC
Permalink
Post by Daniel Biesiada
1) 2d Stuff (3d I think also can matter later in this issue)
I don't know how to make such an effect that I have a texture with
inregular shape and and a single shape I could use as colorkey for
transparency.
I'd like to render such a texture as a 2d sprite with that key color being
transparent and the rest with % transparency to the back surface prior to
rendering.
Can you help?
Okay, I figured out how to make it. Color key is obvious because it's set up
in TextureLoaded.FromFile method.
As for %value transparency Alpha value in Draw2D() method's Color param
solves the issue.

But I've got another issue with sprites.
I wanted to rescale them using Sprite.Transform and Sprite.Draw.
So I created proper matrix to rescale it and then drawn and I see only black
shape in proper rescaled size.
Any clues?

Code looks like:

Matrix trans = Matrix.Identity;
trans = Matrix.Transformation2D(new
Vector2(Config.DisplayMode.Width / 2, Config.DisplayMode.Height / 2), 0,
new Vector2(0.5f, 0.5f), Vector2.Empty, 0,
Vector2.Empty);
sprite.Transform = trans;
sprite.Draw(renderTarget, new
Rectangle(0,0,Config.DisplayMode.Width, Config.DisplayMode.Height),
Vector3.Empty, Vector3.Empty, Color.White.ToArgb());

-
greetings,
db.
OpenSebJ
2007-07-14 06:17:03 UTC
Permalink
Hi Daniel,

This post may be a bit of a "best of" if you read the history of the
newsgroup but hopefully useful none the less.

The MDX libraries are nice, if they were more fully documented with
better examples they would be great. However one thing to note is that
MDX is
not being actively worked on by Microsoft; so you should consider
alternatives before you embark on any new development work with these
libraries.

As for examples on shaders, check out this one, a good example of
whats commonly known as bump mapping (or normal mapping) in MDX is
here: http://www.mdxinfo.com/tutorials/normalmapping.php

As for alternatives on the platform you could check out XNA
http://msdn2.microsoft.com/en-us/xna/default.aspx - which has
effectively superseded MDX - with a focus on game development; but it
doesn't contain access to the same, lower level functions. Or a more
open alternative is SDL.Net - http://cs-sdl.sourceforge.net/index.php/Main_Page
- I've only used the audio API in it so far but it has been by all
accounts fantastic from what I have seen.

Cheers,
Sebastian

On Jul 10, 11:46 pm, "Daniel Biesiada"
Post by Daniel Biesiada
Hello,
I must say I'm not good in DX but in my spare time I wanted to play a little
bit with its managed incarnation.
Maybe I'm not smart enough but I find real difficulty not with the
technology itself but lack of good documentation which would step by step
introduce some advanced tricks and framework's behaviour.
1) 2d Stuff (3d I think also can matter later in this issue)
I don't know how to make such an effect that I have a texture with inregular
shape and and a single shape I could use as colorkey for transparency.
I'd like to render such a texture as a 2d sprite with that key color being
transparent and the rest with % transparency to the back surface prior to
rendering.
Can you help?
Is there any indicator why no 3d object is rendered Sprite.Draw2D() renders
nothing? I just found such a ridiculous behaviour and cannot get a clue why
it'd happen. :)
2) 3D stuff
I'm looking for a nice Pixel/Vertex shader HLSL tutorial which could explain
me logically step by step about the elements inside the code.
I've managed some basics of Pixel Shader from SDK examples but still I'm not
sure about certain things.
If you can recommend me some good online resources I'd be glad (I searched
some but I'm not satisfied).
If not can anybody tell me if ShaderX series of books are good as a
complementary resource?
best regards,
db
Loading...