Fixed compile warnings and crash on non existing models

This commit is contained in:
lanariel 2014-01-16 09:30:01 +01:00
parent 0a3d68a407
commit 483236801f
16 changed files with 57 additions and 51 deletions

View File

@ -215,3 +215,8 @@ UINT32 Core::Buffer::GetVertexSize()
{
return this->mElementSize;
}
ID3D11Buffer* Core::Buffer::GetBufferPointer()
{
return this->mBuffer;
}

View File

@ -7,7 +7,7 @@
#include "Dx11Includes.h"
#include <sstream>
#include "OysterMath.h"
#include <vld.h>
//#include <vld.h>
namespace Oyster
{

View File

@ -356,8 +356,8 @@ namespace Oyster
{
ID3D11Texture2D* tex;
D3D11_TEXTURE2D_DESC texDesc;
texDesc.Width = Core::resolution.x;
texDesc.Height = Core::resolution.y;
texDesc.Width = (UINT)Core::resolution.x;
texDesc.Height = (UINT)Core::resolution.y;
texDesc.MipLevels = 1;
texDesc.ArraySize = 1;
texDesc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT;

View File

@ -58,7 +58,7 @@ namespace Oyster
}
else
{
VSMap[name] = VS.size();
VSMap[name] = (int)VS.size();
VS.push_back((ID3D11VertexShader*)data);
}
}
@ -76,7 +76,7 @@ namespace Oyster
}
else
{
HSMap[name] = HS.size();
HSMap[name] = (int)HS.size();
HS.push_back((ID3D11HullShader*)data);
}
@ -95,7 +95,7 @@ namespace Oyster
}
else
{
DSMap[name] = DS.size();
DSMap[name] = (int)DS.size();
DS.push_back((ID3D11DomainShader*)data);
}
}
@ -113,7 +113,7 @@ namespace Oyster
}
else
{
GSMap[name] = GS.size();
GSMap[name] = (int)GS.size();
GS.push_back((ID3D11GeometryShader*)data);
}
}
@ -131,7 +131,7 @@ namespace Oyster
}
else
{
PSMap[name] = PS.size();
PSMap[name] = (int)PS.size();
PS.push_back((ID3D11PixelShader*)data);
}
}
@ -149,7 +149,7 @@ namespace Oyster
}
else
{
CSMap[name] = CS.size();
CSMap[name] = (int)CS.size();
CS.push_back((ID3D11ComputeShader*)data);
}
@ -347,19 +347,19 @@ namespace Oyster
Core::deviceContext->IASetPrimitiveTopology(se.IAStage.Topology);
if(se.CBuffers.Vertex.size())
{
deviceContext->VSSetConstantBuffers(0,se.CBuffers.Vertex.size(),&se.CBuffers.Vertex[0]);
deviceContext->VSSetConstantBuffers(0,(int)se.CBuffers.Vertex.size(),&se.CBuffers.Vertex[0]);
}
if(se.CBuffers.Pixel.size())
{
deviceContext->PSSetConstantBuffers(0,se.CBuffers.Pixel.size(),&se.CBuffers.Pixel[0]);
deviceContext->PSSetConstantBuffers(0,(int)se.CBuffers.Pixel.size(),&se.CBuffers.Pixel[0]);
}
if(se.CBuffers.Geometry.size())
{
deviceContext->GSSetConstantBuffers(0,se.CBuffers.Geometry.size(),&se.CBuffers.Geometry[0]);
deviceContext->GSSetConstantBuffers(0,(int)se.CBuffers.Geometry.size(),&se.CBuffers.Geometry[0]);
}
if(se.CBuffers.Compute.size())
{
deviceContext->CSSetConstantBuffers(0,se.CBuffers.Compute.size(),&se.CBuffers.Compute[0]);
deviceContext->CSSetConstantBuffers(0,(int)se.CBuffers.Compute.size(),&se.CBuffers.Compute[0]);
}
Core::deviceContext->RSSetState(se.RenderStates.Rasterizer);
Core::deviceContext->PSSetSamplers(0,se.RenderStates.SampleCount,se.RenderStates.SampleState);
@ -369,43 +369,43 @@ namespace Oyster
if(se.SRV.Vertex.size())
{
Core::deviceContext->VSSetShaderResources(0,se.SRV.Vertex.size(),&se.SRV.Vertex[0]);
Core::deviceContext->VSSetShaderResources(0,(int)se.SRV.Vertex.size(),&se.SRV.Vertex[0]);
}
if(se.SRV.Geometry.size())
{
Core::deviceContext->GSSetShaderResources(0,se.SRV.Geometry.size(),&se.SRV.Geometry[0]);
Core::deviceContext->GSSetShaderResources(0,(int)se.SRV.Geometry.size(),&se.SRV.Geometry[0]);
}
if(se.SRV.Pixel.size())
{
Core::deviceContext->PSSetShaderResources(0,se.SRV.Pixel.size(),&se.SRV.Pixel[0]);
Core::deviceContext->PSSetShaderResources(0,(int)se.SRV.Pixel.size(),&se.SRV.Pixel[0]);
}
if(se.SRV.Compute.size())
{
Core::deviceContext->CSSetShaderResources(0,se.SRV.Compute.size(),&se.SRV.Compute[0]);
Core::deviceContext->CSSetShaderResources(0,(int)se.SRV.Compute.size(),&se.SRV.Compute[0]);
}
if(se.RTV.size())
{
if(se.UAV.Pixel.size())
{
deviceContext->OMSetRenderTargetsAndUnorderedAccessViews(se.RTV.size(),&se.RTV[0],se.depth,se.RTV.size(),se.UAV.Pixel.size(),&se.UAV.Pixel[0],0);
deviceContext->OMSetRenderTargetsAndUnorderedAccessViews((int)se.RTV.size(),&se.RTV[0],se.depth,(int)se.RTV.size(),(int)se.UAV.Pixel.size(),&se.UAV.Pixel[0],0);
}
else
{
deviceContext->OMSetRenderTargets(se.RTV.size(),&se.RTV[0],se.depth);
deviceContext->OMSetRenderTargets((int)se.RTV.size(),&se.RTV[0],se.depth);
}
}
else
{
if(se.UAV.Pixel.size())
{
deviceContext->OMSetRenderTargetsAndUnorderedAccessViews(0,NULL,se.depth,0,se.UAV.Pixel.size(),&se.UAV.Pixel[0],0);
deviceContext->OMSetRenderTargetsAndUnorderedAccessViews(0,NULL,se.depth,0,(int)se.UAV.Pixel.size(),&se.UAV.Pixel[0],0);
}
}
if(se.UAV.Compute.size())
{
deviceContext->CSSetUnorderedAccessViews(0,se.UAV.Compute.size(),&se.UAV.Compute[0],0);
deviceContext->CSSetUnorderedAccessViews(0,(int)se.UAV.Compute.size(),&se.UAV.Compute[0],0);
}
}

View File

@ -6,6 +6,7 @@
#include "../FileLoader/ObjReader.h"
#include "../../Misc/Resource/OysterResource.h"
#include "../FileLoader/GeneralLoader.h"
#include "../Model/ModelInfo.h"
#include <vld.h>
namespace Oyster
@ -47,7 +48,7 @@ namespace Oyster
{
if(Lights.size())
{
Render::Rendering::Basic::NewFrame(View, Projection, &Lights[0], Lights.size());
Render::Rendering::Basic::NewFrame(View, Projection, &Lights[0], (int)Lights.size());
}
else
{
@ -75,6 +76,7 @@ namespace Oyster
return API::Sucsess;
}
//returns null for invalid filenames
Model::Model* API::CreateModel(std::wstring filename)
{
Model::Model* m = new Model::Model();
@ -83,11 +85,19 @@ namespace Oyster
m->info = Oyster::Resource::OysterResource::LoadResource(filename.c_str(),Oyster::Graphics::Loading::LoadOBJ);
Model::ModelInfo* mi = (Model::ModelInfo*)m->info;
if(mi->Vertices->GetBufferPointer() == NULL)
{
return NULL;
}
return m;
}
void API::DeleteModel(Model::Model* model)
{
if(model==NULL)
return;
Model::ModelInfo* info = (Model::ModelInfo*)model->info;
delete model;
Oyster::Resource::OysterResource::ReleaseResource((Oyster::Resource::OHRESOURCE)info);

View File

@ -4,7 +4,7 @@
#include "..\Model\Model.h"
#include "OysterMath.h"
#include <Windows.h>
#include <vld.h>
//#include <vld.h>
#ifdef GFX_DLL_EXPORT
#define GFX_DLL_USAGE __declspec(dllexport)

View File

@ -230,7 +230,6 @@ std::map<std::string, ID3D11ShaderResourceView *> ObjReader::GetMaterials(std::w
input.open(fileName.c_str());
std::map<std::string, ID3D11ShaderResourceView *> materials;
ID3D11ShaderResourceView *srv;
string texture;
string s;
string path;

View File

@ -50,6 +50,8 @@ namespace Oyster
{
for(int i = 0; i < count; ++i)
{
if(&models[i] == NULL)
continue;
if(models[i].Visible)
{
Definitions::PerModel pm;
@ -65,7 +67,7 @@ namespace Oyster
if(info->Material.size())
{
Core::deviceContext->PSSetShaderResources(0,info->Material.size(),&(info->Material[0]));
Core::deviceContext->PSSetShaderResources(0,(UINT)info->Material.size(),&(info->Material[0]));
}
@ -86,11 +88,11 @@ namespace Oyster
{
Core::PipelineManager::SetRenderPass(Resources::Deffered::LightPass);
Core::deviceContext->Dispatch((Core::resolution.x + 15U) / 16U,(Core::resolution.y + 15U) / 16U,1);
Core::deviceContext->Dispatch((UINT)((Core::resolution.x + 15U) / 16U), (UINT)((Core::resolution.y + 15U) / 16U), 1);
Core::PipelineManager::SetRenderPass(Resources::Deffered::PostPass);
Core::deviceContext->Dispatch((Core::resolution.x + 15U) / 16U,(Core::resolution.y + 15U) / 16U,1);
Core::deviceContext->Dispatch((UINT)((Core::resolution.x + 15U) / 16U), (UINT)((Core::resolution.y + 15U) / 16U), 1);
Core::swapChain->Present(0,0);
}

View File

@ -155,7 +155,7 @@ namespace Oyster
Buffer* b = &PointLightsData;
Core::Init::CreateLinkedShaderResourceFromStructuredBuffer(&b,&PointLightView,NULL);
srand(time(0));
srand((unsigned int)time(0));
//SSAO
Math::Vector3 kernel[KernelSize];
Math::Vector3 random[SampleSpread];

View File

@ -12,7 +12,6 @@ struct VertexIn
struct VertexOut
{
float4 pos : SV_POSITION;
float4 ViewPos : POSITION;
float2 UV : TEXCOORD;
float3 normal : NORMAL;
//float3 tangent : TANGENT;

View File

@ -21,8 +21,8 @@ DiffSpec LightCalc(PointLight pl, float3 pos, int2 texCoord)
output.Specular * 0;
if(d > pl.Radius)
{
output.Diffuse = float4(0,0,0,1);
output.Specular = float4(0,0,0,1);
output.Diffuse = float3(0,0,0);
output.Specular = float3(0,0,0);
}
return output;
}

View File

@ -12,13 +12,13 @@
[numthreads(16, 16, 1)]
void main( uint3 DTid : SV_DispatchThreadID, uint3 GTid : SV_GroupThreadID )
{
float2 UV = DTid / Pixels;
float2 UV = DTid.xy / Pixels;
UV.x = UV.x * 2 - 1;
UV.y = 1 - 2 * UV.y;
float3 ViewPos = ToVpos(DTid.xy, UV);
DiffSpec Shaded;
Shaded.Diffuse = float4(0,0,0,0);
Shaded.Specular = float4(0,0,0,0);
Shaded.Diffuse = float3(0,0,0);
Shaded.Specular = float3(0,0,0);
for(int i = 0; i < Lights; ++i)
{

View File

@ -24,7 +24,7 @@ float GetSSAO(float3 pos, float2 uv, int2 texCoord2, uint2 rndID)
float4 ProjOffset = sampled;
ProjOffset = mul(Proj, ProjOffset);
float4 offset = ProjOffset;
float2 UV = offset;
float2 UV = offset.xy;
offset /= offset.w;
offset.xyz = offset.xyz * 0.5f + 0.5f;
//extra invert y axis, DX11

View File

@ -4,7 +4,7 @@ VertexOut main( VertexIn input )
{
VertexOut output;
output.pos = mul(WVP, float4(input.pos,1));
output.normal = mul(WV, float4(input.normal,0));
output.normal = mul(WV, float4(input.normal,0)).xyz;
output.UV = input.UV;
return output;
}

View File

@ -44,18 +44,6 @@ int WINAPI wWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdL
{
BOOL b = SetDllDirectoryW(L"..\\DLL");
typedef struct tagLOADPARMS32
{
LPSTR lpEnvAddress; // address of environment strings
LPSTR lpCmdLine; // address of command line
LPSTR lpCmdShow; // how to show new program
DWORD dwReserved; // must be zero
} LOADPARMS32;
LOADPARMS32 params;
params.dwReserved=NULL;
params.lpCmdLine="";
params.lpCmdShow="";
params.lpEnvAddress="";
if( FAILED( InitWindow( hInstance, nCmdShow ) ) )
return 0;
@ -171,10 +159,12 @@ HRESULT InitDirect3D()
return E_FAIL;
}
m = Oyster::Graphics::API::CreateModel(L"orca_dummy");
m2 = Oyster::Graphics::API::CreateModel(L"worldDummy");
m = Oyster::Graphics::API::CreateModel(L"crate2");
if(m==NULL)
m = Oyster::Graphics::API::CreateModel(L"crate");
m2 = Oyster::Graphics::API::CreateModel(L"crate");
m2->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3::null,Oyster::Math::Float3(0,5,0),Oyster::Math::Float3::null);
m3 = Oyster::Graphics::API::CreateModel(L"worldDummy");
m3 = Oyster::Graphics::API::CreateModel(L"crate");
m3->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3::null,Oyster::Math::Float3(0,5,0),Oyster::Math::Float3::null);

View File

@ -136,6 +136,7 @@
<AdditionalDependencies>OysterGraphics_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(SolutionDir)..\Bin\DLL;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<PreventDllBinding>true</PreventDllBinding>
<DelayLoadDLLs>OysterGraphics_$(PlatformShortName)D.dll;</DelayLoadDLLs>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">