0
votes

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);
}

...

1
Stretching depends on Texture Coordinate you use in the sampling of the Pixel Shader. Could you give the code of your pixel shader?Cédric Bignon
The texture address mode (repeating, mirroring, wrapping, clamping) depends on the D3D11_TEXTURE_ADDRESS_MODE you set for the Texture Sampler (created with the parameter D3D11_SAMPLER_DESC).Cédric Bignon
That looks horrible so I've posted it as an answer below. The texture is displayed fine until the Window is resized is what I have found. I know I am mapping the textures to a 2x2 block. (-1.0f to 1.0f) and so they are resized when the window is. Ideally I want the textures I am printing to always be the same size unless I want them to change. I just don't know how to do this or if it is possible.user2600628
Then you must resize swap chain when user resizing window. This has nothing with texture sampling. msdn.microsoft.com/en-us/library/windows/desktop/… And by rules of StackOverflow it is better to edit your post to add code than add new answer.Ivan Aksamentov - Drop
Done. Thankyou that will help but that doesn't change the original question. Textures are slightly squashed - even in the original window. I want to know if there is a way of displaying every pixel in a texture? (I am using a 2D environment with depth turned off.)user2600628

1 Answers

0
votes

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. :)