Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
C-/C++-Quelltext |
|
1 2 3 |
Device->CreateTexture2D(&TextureDesc, 0, &MyD3DTexture2D); // Funktioniert Device->CreateTexture2D(&TextureDesc, &ResourceData, &MyD3DTexture2D); // Funktioniert nicht |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
/* unsigned char* ImageBuffer = ... */ /* Initialize resource data description */ D3D11_SUBRESOURCE_DATA ResourceData; ResourceData.pSysMem = (const void*)ImageBuffer; ResourceData.SysMemPitch = Width * 4; ResourceData.SysMemSlicePitch = Height * ResourceData.SysMemPitch; /* Initialize texture description */ D3D11_TEXTURE2D_DESC TextureDesc; TextureDesc.Width = Width; TextureDesc.Height = Height; TextureDesc.MipLevels = 0; // Generate MipMaps automatically TextureDesc.ArraySize = 1; TextureDesc.Usage = D3D11_USAGE_DEFAULT; TextureDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; TextureDesc.CPUAccessFlags = 0; TextureDesc.MiscFlags = 0; TextureDesc.SampleDesc.Count = 1; TextureDesc.SampleDesc.Quality = 0; TextureDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE; /* Create the 2D texture */ Device->CreateTexture2D(&TextureDesc, &ResourceData, &Texture2D); // Error: Invalid Arguments (E_INVALIDARG) |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
Texture2D Tex; SamplerState SamplerLinear; cbuffer ConstantBuffer { float4x4 World; float4x4 View; float4x4 Projection; } /* === Vertex Shader === */ struct VertexOutput { float4 Pos : SV_POSITION; float4 Color : COLOR0; float3 TexCoord : TEXCOORD0; }; VertexOutput VertexMain(float4 Pos : POSITION, float4 Color : COLOR, float3 TexCoord : TEXCOORD0) { VertexOutput Output; Output.Pos = mul(Pos, World); Output.Pos = mul(Output.Pos, View); Output.Pos = mul(Output.Pos, Projection); Output.Color = Color; Output.TexCoord = TexCoord; return Output; } /* === Pixel Shader === */ float4 PixelMain(VertexOutput Input) : SV_Target { return Tex.Sample(SamplerLinear, Input.TexCoord.xy) * Input.Color; } |
Werbeanzeige