Jump to content
  • Advertisement

Joakim1234

Member
  • Content Count

    8
  • Joined

  • Last visited

Everything posted by Joakim1234

  1. Ok it seems I found the problem - for some reason XMMATRIX can't be used as extern XMMATRIX * testmatrix and it causes it to crash I had the habit of making a lot of things extern,guess I'll change them to normal now Edit: I am the original poster,but here I wasn't allowed to use Facebook when I wrote this thread.Does that violate some terms?If so,I apologize to the moderators for not remembering the rights and terms.
  2. I'm using a little helper function to create vertex buffers: void AssetManager::CreateVertexBuffer(ID3D11Buffer** buffer, unsigned int bufferSize, void* vertices, D3D11_USAGE bufferUsage, D3D11_CPU_ACCESS_FLAG processorAccess) { D3D11_BUFFER_DESC bufferDesc; D3D11_SUBRESOURCE_DATA subResData; bufferDesc.Usage = bufferUsage; bufferDesc.ByteWidth = bufferSize; bufferDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER; bufferDesc.CPUAccessFlags = processorAccess; bufferDesc.MiscFlags = 0; bufferDesc.StructureByteStride = 0; subResData.pSysMem = vertices; subResData.SysMemPitch = 0; subResData.SysMemSlicePitch = 0; HR(gD3DDevice->CreateBuffer(&bufferDesc, &subResData, buffer)); } And it causes a E_INVALIDARG error,but doesn't give a clue about which argument is the invalid one.Here is how the function is called in the program: vertexBuffer = 0; VertexType* vertices = new VertexType[vertexCount];; vertices[0].position = XMFLOAT3(-1.0f, -1.0f, 0.0f); //just random values to see if it debugs at all vertices[0].texture = XMFLOAT2(0.0f, 1.0f); vertices[1].position = XMFLOAT3(0.0f, 1.0f, 0.0f); vertices[1].texture = XMFLOAT2(0.5f, 0.0f); vertices[2].position = XMFLOAT3(1.0f, -1.0f, 0.0f); vertices[2].texture = XMFLOAT2(1.0f, 1.0f); AssetManager->CreateVertexBuffer(&vertexBuffer,sizeof(VertexType)*vertexCount, &vertices); Could the problem be in "bufferDesc.StructureByteStride = 0;"?Am I supposed to leave it at 0?Cause all the tutorial project files leave it at 0 and they compile just fine.But the problem can't be in the project itself,I linked all the needed libraries and the paths to the SDK.
  3. Joakim1234

    Is gaming going downhill?

    It's because of profit expectation.In the old times not everyone had a computer and it wasn't all profit-oriented,so people did it more for the sake of fun,innovation and discovery and it was more of an art than an industry I guess.I mean when I ran Crysis 2 on max on my brother's computer it looked photorealistic and everything,but it got boring after 30 minutes of playing.Serious Sam The Second Encounter however always felt extremely fun and refreshing to play and the monsters looked very..uhm defined.In Crysis 2 the enemies are so packed with details,spikes,tentacles,lights,eyes,arms that I sometimes can't tell the different types apart.I hate to admit with what Blizzard said about Diablo 2,but they were right,it was something along the lines of "We don't focus so much on high definition graphics,but on a fresh and memorable art style,so we can create a graphics that will be acceptable even in 5 years from now.".
  4. Thanks for showing me this,I guess it's not such a good idea to have a buffer creator function anyway
  5. lol it actually worked,but what kind of access does 0 mean?READWRITE?
  6. They are void CreateVertexBuffer(ID3D11Buffer** buffer, unsigned int bufferSize, void * vertices, D3D11_USAGE bufferUsage = D3D11_USAGE_DEFAULT, D3D11_CPU_ACCESS_FLAG processorAccess = D3D11_CPU_ACCESS_READ); It should result in the same buffer creation that I saw in a tutorial which used to work with no problems.
  7. When I call D3DX11CompileFromFile(pixelShaderPath, NULL, NULL, "SpritePixelShader", "vs_5_0", D3D10_SHADER_ENABLE_STRICTNESS, 0, NULL, &pixelShaderBuffer, NULL, NULL); I get the error message: Unexpected error encountered Error Code: E_FAIL(0x80004005) Calling: D3DX11CompileFromFile(pixelShaderPath, NULL, NULL, "SpritePixelShader", "vs_5_0", D3D10_SHADER_ENABLE_STRICTNESS, 0, NULL, &pixelShaderBuffer, NULL, NULL) [/quote] The D3DX11CompileFromFile(vertexShaderPath, NULL, NULL, "SpriteVertexShader", "vs_5_0", D3D10_SHADER_ENABLE_STRICTNESS, 0, NULL, &vertexShaderBuffer, NULL, NULL) function doesn't cause an error,but on the next 2 lines where I call CreateVertexShader and CreatePixelShader, CreateVertexShader does cause an error: Unexpected error encountered Error Code: E_INVALIDARG(0x80070057) Calling: CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &vertexShader)) [/quote] Which brings me to believe,that D3DX11CompileFromFile(vertexShaderPath, NULL, NULL, "SpriteVertexShader", "vs_5_0", D3D10_SHADER_ENABLE_STRICTNESS, 0, NULL, &vertexShaderBuffer, NULL, NULL) also didn't work out very well.All the pointers are initialized properly before calling these functions,so that can't be it: vertexShader = 0; pixelShader = 0; vertexShaderBuffer = 0; pixelShaderBuffer = 0; And it can't be from not finding the SpriteEffect.vs and SpriteEffect.ps files,they're right next to the source files,I also copied them in the debug folder to be next to the .exe just in case.Could the problem be invalid code in the shader files themselves?They're just a simple instanced geometry/bump map effect: cbuffer MatrixBuffer { matrix worldMatrix; matrix viewMatrix; matrix projectionMatrix; }; struct VertexInputType { float4 position : POSITION; float2 tex : TEXCOORD0; float3 normal : NORMAL; float3 tangent : TANGENT; float3 binormal : BINORMAL; float3 instancePosition : TEXCOORD1; }; struct PixelInputType { float4 position : SV_POSITION; float2 tex : TEXCOORD0; float3 normal : NORMAL; float3 tangent : TANGENT; float3 binormal : BINORMAL; }; PixelInputType SpriteVertexShader(VertexInputType input) { PixelInputType output; input.position.w = 1.0f; input.position.x += input.instancePosition.x; input.position.y += input.instancePosition.y; input.position.z += input.instancePosition.z; output.position = mul(input.position, worldMatrix); output.position = mul(output.position, viewMatrix); output.position = mul(output.position, projectionMatrix); output.tex = input.tex; output.normal = mul(input.normal, (float3x3)worldMatrix); output.normal = normalize(output.normal); output.tangent = mul(input.tangent, (float3x3)worldMatrix); output.tangent = normalize(output.tangent); output.binormal = mul(input.binormal, (float3x3)worldMatrix); output.binormal = normalize(output.binormal); return output; } Texture2D shaderTexture; SamplerState SampleType; struct PixelInputType { float4 position : SV_POSITION; float2 tex : TEXCOORD0; float3 normal : NORMAL; float3 tangent : TANGENT; float3 binormal : BINORMAL; }; float4 SpritePixelShader(PixelInputType input) : SV_TARGET { float4 textureColor; float4 bumpMap; float3 bumpNormal; float3 lightDir; float lightIntensity; float4 color; textureColor = shaderTextures[0].Sample(SampleType, input.tex); bumpMap = shaderTextures[1].Sample(SampleType, input.tex); bumpMap = (bumpMap * 2.0f) - 1.0f; bumpNormal = input.normal + bumpMap.x * input.tangent + bumpMap.y * input.binormal; bumpNormal = normalize(bumpNormal); lightDir = -lightDirection; lightIntensity = saturate(dot(bumpNormal, lightDir)); color = saturate(diffuseColor * lightIntensity); color = color * textureColor; return color; } I don't have syntax highlighting for HLSL,so it's possible that I missed something stupid.Any help would be appreciated.
  8. Ah,thank you,it seems there were a lot of missing variables from the SpriteEffect.ps file.Is there a program in existence that checks and highlights HLSL code like Visual Studio with Intellisense highlights C++?
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!