void D3D11RenderTarget::load(GraphicsDevice &g, const UINT width, const UINT height)
{
    m_graphics = &g.castD3D11();
    m_width = width;
    m_height = height;
    
    g.castD3D11().registerAsset(this);

    reset();
}
Ejemplo n.º 2
0
void AssetRenderer::init(GraphicsDevice &g)
{
    m_graphics = &g.castD3D11();

    m_shaders.init(g);
    m_shaders.registerShader("../../shaders/modelRendererColor.shader", "basicColor");
    m_shaders.registerShader("../../shaders/modelRendererTexture.shader", "basicTexture");
    m_constants.init(g);

    m_sphere.load(g, ml::shapes::sphere(1.0f, vec3f::origin));
    m_cylinder.load(g, ml::shapes::cylinder(0.01f, 1.0f, 2, 15, ml::vec4f(1.0f, 1.0f, 1.0f, 1.0f)));
    m_box.load(g, ml::shapes::box(1.0f));
}
Ejemplo n.º 3
0
void ml::D3D11TriMesh::initVB(GraphicsDevice &g)
{
    if (m_triMesh.getVertices().size() == 0) return;
	auto &device = g.castD3D11().getDevice();

	D3D11_BUFFER_DESC bufferDesc;
	ZeroMemory( &bufferDesc, sizeof(bufferDesc) );
	bufferDesc.Usage = D3D11_USAGE_DEFAULT;
    bufferDesc.ByteWidth = sizeof(TriMeshf::Vertex<float>) * (UINT)m_triMesh.getVertices().size();
	bufferDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
	bufferDesc.CPUAccessFlags = 0;

	D3D11_SUBRESOURCE_DATA data;
	ZeroMemory( &data, sizeof(data) );
    data.pSysMem = &m_triMesh.getVertices()[0];

	D3D_VALIDATE(device.CreateBuffer( &bufferDesc, &data, &m_vertexBuffer ));
}
Ejemplo n.º 4
0
void ml::D3D11TriMesh::initIB(GraphicsDevice &g)
{
    auto &indices = m_triMesh.getIndices();
    if (indices.size() == 0) return;
	auto &device = g.castD3D11().getDevice();

	D3D11_BUFFER_DESC bufferDesc;
	ZeroMemory( &bufferDesc, sizeof(bufferDesc) );
	bufferDesc.Usage = D3D11_USAGE_DEFAULT;
	bufferDesc.ByteWidth = sizeof( vec3ui ) * (UINT)indices.size();
	bufferDesc.BindFlags = D3D11_BIND_INDEX_BUFFER;
	bufferDesc.CPUAccessFlags = 0;

	D3D11_SUBRESOURCE_DATA data;
	ZeroMemory( &data, sizeof(data) );
    data.pSysMem = &indices[0];

	D3D_VALIDATE(device.CreateBuffer( &bufferDesc, &data, &m_indexBuffer ));
}
Ejemplo n.º 5
0
void ml::D3D11GeometryShader::init(
	GraphicsDevice& g, 
	const std::string& filename, 
	const std::string& entryPoint, 
	const std::string& shaderModel,
	const std::vector<std::pair<std::string, std::string>>& shaderMacros)
{
    m_graphics = &g.castD3D11();

	releaseGPU();
	SAFE_RELEASE(m_blob);

	m_filename = filename;
	//g.castD3D11().registerAsset(this);

	m_blob = D3D11Utility::CompileShader(m_filename, entryPoint, shaderModel, shaderMacros);
	MLIB_ASSERT_STR(m_blob != nullptr, "CompileShader failed");

	createGPU();
}
Ejemplo n.º 6
0
void ml::D3D11TriMesh::initVB(GraphicsDevice &g)
{
    if (m_triMesh.getVertices().size() == 0) return;
	auto &device = g.castD3D11().getDevice();

	size_t byteSize = sizeof(TriMeshf::Vertex) * m_triMesh.getVertices().size();
	if (byteSize > std::numeric_limits<UINT>::max()) {
		throw MLIB_EXCEPTION("buffer size too big " + std::to_string(byteSize) + ", while max is " + std::to_string(std::numeric_limits<UINT>::max()));
	}

	D3D11_BUFFER_DESC bufferDesc;
	ZeroMemory( &bufferDesc, sizeof(bufferDesc) );
	bufferDesc.Usage = D3D11_USAGE_DEFAULT;
	bufferDesc.ByteWidth = (UINT)byteSize;
	bufferDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
	bufferDesc.CPUAccessFlags = 0;

	D3D11_SUBRESOURCE_DATA data;
	ZeroMemory( &data, sizeof(data) );
    data.pSysMem = &m_triMesh.getVertices()[0];

	D3D_VALIDATE(device.CreateBuffer( &bufferDesc, &data, &m_vertexBuffer ));
}
Ejemplo n.º 7
0
void D3D11ShaderManager::init(GraphicsDevice &g)
{
    m_graphics = &g.castD3D11();
}
Ejemplo n.º 8
0
void D3D11Canvas2D::init(GraphicsDevice &g)
{
    m_graphics = &g.castD3D11();
	m_graphics->registerAsset(this);	//register to get resize, reset, and release events
}