Search code examples
graphicsdirectxgame-enginedirectx-11directx-9

Directx 11 Texture mapping


I've looked for this and I am so sure it can be done.

Does anyone know how I can stop a texture being stretched over an oversized facet?

I remember in some game designs you would have the option of either stretching the image over the object or running a repeat.

EDIT: Okay, so I have used pixel coordinates and the issue still remains. The vertices are fine. What I am trying to do is load a bitmap and keep the size the same regardless of what the resolution is, or the size of the image. I want the image to only use 20x20 physical pixels.

I hope that makes sense because I don't think my previous explaination did.

Texture2D Texture;

SamplerState SampleType
{
    Filter = TEXT_1BIT;
//    AddressU = Clamp;
//    AddressV = Clamp;
};

struct Vertex
{
    float4 position : POSITION;
    float2 tex : TEXCOORD0;
};

struct Pixel
{
    float4 position : SV_POSITION;
    float2 tex : TEXCOORD0;
};

Pixel FontVertexShader(Vertex input)
{
    return input;
}

float4 FPS(Pixel input) : SV_Target
{
    return Texture.Sample(SampleType, input.tex);
}

...


Solution

  • The answer is in hwnd = CreateWindow(...);

    Using WS_POPUP meant I removed the borders and my texture was able to map itself correctly.

    You need to use GetClientRect();

    Thankyou to everyone for your help. :)