Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 03 Jun 2000
Offline Last Active May 20 2015 02:55 PM

Topics I've Started

[.net] C++/CLI is and as equivalents

12 September 2007 - 09:16 PM

I know that C# has some 'is' and 'as' operators, what is the equivalent if I want to do the same in C++/CLI? Trying to use is and as doesn't work and as they are not highlighted I expect they are not part of C++/CLI syntax. I realise safe_cast is available but this can only be used in conjuction with catching errors. examples of what I want to do: if(this_var is System::Int32) { ... } System::Int32 qq = this_var as System::Int32; Any help appreciated. - stevenmarky

[.net] Determine file type

13 August 2007 - 09:42 PM

I am looking for way to determine if a certain file is a .NET IL file as opposed to a normal .dll or .exe. I'm not picky on the language used to achieve this (if there is no way to do it from the command-line). Any help appreciated.

HLSL incorrect compilation

05 August 2007 - 11:43 PM

I'm trying to write a HLSL pixel shader which simply outputs the texture set at stage 1 (set via IDirect3DDevice9::SetTexture(1, texture). The source is as follows:
texture texture0; // texture
texture texture1; // normal map

sampler2D texSampler0 : TEXUNIT0 = sampler_state
    Texture = <texture0>;

sampler2D texSampler1 : TEXUNIT1 = sampler_state
   Texture = <texture1>;

struct PS_INPUT
    float4 Position   : POSITION;
    float3 Texture : TEXCOORD0;  

struct PS_OUTPUT
    float4 color : COLOR0;  

PS_OUTPUT main( in PS_INPUT In )
    PS_OUTPUT Out;
    Out.color = tex2D(texSampler1, In.Texture);
    return Out;                    

The problem is, it outputs the texture at stage 0. I did some investigation and compiled the HLSL to assembly code, this is what it produces:
    dcl t0.xy
    dcl_2d s0
    texld r0, t0, s0
    mov oC0, r0

Whilst what I actually want is:
    dcl t0.xy 
    dcl_2d s1
    texld r0, t0, s1
    mov oC0, r0 

I fiddled around for a while and realised if I used both the textures in the pixel shader, I could access the texture on stage 1; for example if I do:
    Out.color = tex2D(texSampler1, In.Texture) + tex2D(texSampler0, In.Texture) * 0.1;
Then the output is pretty much the second texture. Obviously I don't want to have to do this to my HLSL each time I want to access a particular texture. Is something wrong with my HLSL? Why does it always output the first texture unless I use both textures? Any help appreciated.

[web] onmouseover woes

25 July 2007 - 11:37 PM

Internet Explorer 6.0 seems to have trouble responding to onmouseover events of table elements when they have an alpha value; the event is simply not fired a lot of the time. Here is my test case: Test Case. If you have any ideas on how I could get around this problem I would be grateful. I know that recent versions of Firefox and Opera have no trouble with this. edit: There is a small mistake on the test page - it says red instead of blue.

Problem understanding view transform

27 August 2006 - 06:47 AM

The translation values of view matrices is not the location of the camera, why is this? DirectX's D3DXMatrixLookAtLH Function is calculated as follows from three vectors, at, eye and up:

zaxis = normal(At - Eye)
xaxis = normal(cross(Up, zaxis))
yaxis = cross(zaxis, xaxis)

 xaxis.x           yaxis.x           zaxis.x          0
 xaxis.y           yaxis.y           zaxis.y          0
 xaxis.z           yaxis.z           zaxis.z          0
-dot(xaxis, eye)  -dot(yaxis, eye)  -dot(zaxis, eye)  1

But why isn't the last row simply (eye.x, eye.y, eye.z, 1)? After thinking about it for a minute it seems like the translation values have been transformed into the world coordinate system from the matrices coordinate system - is that correct? and if so..why?