bool Rectangle2DClass::Initialize(ID3D11Device * device, ID3D11DeviceContext* context, int screenWidth, int screenHeight, int bitmapWidth, int bitmapHeight)
{
	HRESULT hr = S_OK;
	m_screenWidth = screenWidth;
	m_screenHeight = screenHeight;
	m_bitmapWidth = bitmapWidth;
	m_bitmapHeight = bitmapHeight;
	m_previousPosX = -1;
	m_previousPosY = -1;
	m_previousWidth = bitmapWidth;
	m_previousHeight = bitmapHeight;

	hr = InitializeBuffers(device);
	if (FAILED(hr))
		return hr;

	scaling[0] = 1.0f;
	scaling[1] = 1.0f;
	scaling[2] = 1.0f;

	D3D11_BUFFER_DESC bd;
	hr = InitializeBuffers(device);
	if (FAILED(hr))
		return hr;
	ZeroMemory(&bd, sizeof(bd));
	bd.ByteWidth = sizeof(Propertys);
	bd.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
	bd.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
	bd.Usage = D3D11_USAGE_DYNAMIC;
	hr = device->CreateBuffer(&bd, NULL, &m_BlockProperty);
	if (FAILED(hr))
	{
		MessageBox(NULL, L"ErrorCreate Translation Buffer", L"Error_BlockClass", MB_OK);
		return false;
	}
	ZeroMemory(&bd, sizeof(bd));
	bd.ByteWidth = sizeof(Factors);
	bd.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
	bd.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
	bd.Usage = D3D11_USAGE_DYNAMIC;
	hr = device->CreateBuffer(&bd, NULL, &m_RenderFactors);
	if (FAILED(hr))
	{
		MessageBox(NULL, L"ErrorCreate RenderFactors Buffer", L"Error_BlockClass", MB_OK);
		return false;
	}
	rotation[0] = 0.0f;
	rotation[1] = 0.0f;
	rotation[2] = 0.0f;
	D3DXMatrixIdentity(&propertys.RotationMatrix);
	return true;
}
Example #2
0
bool CloudClass::Initialize(ID3D11Device* device, int width, int height, float SCREEN_DEPTH, float SCREEN_NEAR){
	bool result;
	// Create the up sample render to texture object.
	front_texture_ = new RenderTextureClass;
	if(!front_texture_){
		return false;
	}
	// Initialize the up sample render to texture object.
	result = front_texture_->Initialize(device, width, height, SCREEN_DEPTH, SCREEN_NEAR);
	if(!result){
		return false;
	}
	back_texture_ = new RenderTextureClass;
	if(!back_texture_){
		return false;
	}
	// Initialize the up sample render to texture object.
	result = back_texture_->Initialize(device, width, height, SCREEN_DEPTH, SCREEN_NEAR);
	if(!result){
		return false;
	}
	// Initialize the vertex and index buffer that hold the geometry for the terrain.
	result = InitializeBuffers(device);
	if(!result){
		return false;
	}
	return true;
}
bool ModelClass::Initialize(ID3D10Device* device, char* modelFilename, WCHAR* textureFilename)
{
	bool result;


	// Load in the model data.
	result = LoadModel(modelFilename);
	if(!result)
	{
		return false;
	}

	// Initialize the vertex and index buffer that hold the geometry for the model.
	result = InitializeBuffers(device);
	if(!result)
	{
		return false;
	}

	// Load the texture for this model.
	result = LoadTexture(device, textureFilename);
	if(!result)
	{
		return false;
	}

	return true;
}
bool BumpModelClass::Initialize(ID3D10Device* device, char* modelFilename, WCHAR* textureFilename1, WCHAR* textureFilename2)
{
    bool result;


    // Load in the model data.
    result = LoadModel(modelFilename);
    if(!result)
    {
        return false;
    }

    // Calculate the normal, tangent, and binormal vectors for the model.
    CalculateModelVectors();

    // Initialize the vertex and index buffer that hold the geometry for the model.
    result = InitializeBuffers(device);
    if(!result)
    {
        return false;
    }

    // Load the textures for this model.
    result = LoadTextures(device, textureFilename1, textureFilename2);
    if(!result)
    {
        return false;
    }

    return true;
}
// |----------------------------------------------------------------------------|
// |						      Initialize									|
// |----------------------------------------------------------------------------|
bool ParticleSystemClass::Initialize(ID3D11Device* device, WCHAR* textureFilename)
{
	bool result;


	// Load the texture that is used for the particles.
	result = LoadTexture(device, textureFilename);
	if(!result)
	{
		return false;
	}

	// Initialize the particle system.
	result = InitializeParticleSystem();
	if(!result)
	{
		return false;
	}

	// Create the buffers that will be used to render the particles with.
	result = InitializeBuffers(device);
	if(!result)
	{
		return false;
	}

	return true;
}
Example #6
0
static BROTLI_BOOL DecompressFile(Context* context, BrotliDecoderState* s) {
  BrotliDecoderResult result = BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT;
  InitializeBuffers(context);
  for (;;) {
    if (result == BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT) {
      if (!HasMoreInput(context)) {
        fprintf(stderr, "corrupt input [%s]\n",
                PrintablePath(context->current_input_path));
        return BROTLI_FALSE;
      }
      if (!ProvideInput(context)) return BROTLI_FALSE;
    } else if (result == BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT) {
      if (!ProvideOutput(context)) return BROTLI_FALSE;
    } else if (result == BROTLI_DECODER_RESULT_SUCCESS) {
      if (!FlushOutput(context)) return BROTLI_FALSE;
      if (context->available_in != 0 || HasMoreInput(context)) {
        fprintf(stderr, "corrupt input [%s]\n",
                PrintablePath(context->current_input_path));
        return BROTLI_FALSE;
      }
      return BROTLI_TRUE;
    } else {
      fprintf(stderr, "corrupt input [%s]\n",
              PrintablePath(context->current_input_path));
      return BROTLI_FALSE;
    }

    result = BrotliDecoderDecompressStream(s, &context->available_in,
        &context->next_in, &context->available_out, &context->next_out, 0);
  }
}
bool SkyBox::Init(ID3D11Device* device)
{
	bool result;


	// Load in sky box model.
	result = LoadSkyBoxModel("../SkyBox.txt");
	if(!result)
	{
		return false;
	}

	// Load sky box into a vertex and index buffer for rendering.
	result = InitializeBuffers(device);
	if(!result)
	{
		return false;
	}

	// Set color at top of sky box.
	_apexColor = D3DXVECTOR4(0.0f, 0.15f, 0.66f, 1.0f);
	_apexColor = D3DXVECTOR4(0.0f, 0.145f, 0.667f, 1.0f);

	// Set color at center of sky box.
	_centerColor =  D3DXVECTOR4(0.81f, 0.38f, 0.66f, 1.0f);
	_centerColor =  D3DXVECTOR4(0.02f, 0.365f, 0.886f, 1.0f);

	return true;
}
Example #8
0
bool TerrainClass::Initialize(ID3D11Device* device, char* heightMapFilename)
{
	bool result;


	// Load in the height map for the terrain.
	result = LoadHeightMap(heightMapFilename);
	if(!result)
	{
		return false;
	}

	// Normalize the height of the height map.
	NormalizeHeightMap();

	// Calculate the normals for the terrain data.
	result = CalculateNormals();
	if(!result)
	{
		return false;
	}

	// Initialize the vertex and index buffer that hold the geometry for the terrain.
	result = InitializeBuffers(device);
	if(!result)
	{
		return false;
	}

	return true;
}
Example #9
0
bool ModelClass::Initialize(ID3D11Device* device, char* model_filename, WCHAR* texture_filename)
{
	bool result;

	result = LoadModel(model_filename);
	if(!result)
	{
		return false;
	}

	result = InitializeBuffers(device);
	if(!result)
	{
		return false;
	}

	

	//initialize texture
	result = LoadTexture(device, texture_filename);
	if(!result)
	{
		return false;
	}
	return true;
}
Example #10
0
bool BitmapFontClass::Initialize(ID3D11Device* device, ID3D11DeviceContext* deviceContext, char* textureFilename, const char* basisShaderFileName)
{
	bool initResult = InitializeShaders(device, basisShaderFileName);
	if (!initResult)
	{
		return false;
	}

	initResult = InitializeTextureView(device, deviceContext, textureFilename);
	if (!initResult)
	{
		return false;
	}

	initResult = InitializeBuffers(device);
	if (!initResult)
	{
		return false;
	}

	initResult = InitializeBlending(device, deviceContext);
	if (!initResult)
	{
		return false;
	}

	return true;
}
Example #11
0
bool CBitmap::Initialize(ID3D11Device* device, int width, int height, std::string filename, int bmpWidth, int bmpHeight)
{
	bool result;
	screenWidth = width;
	screenHeight = height;

	bitmapHeight = bmpHeight;
	bitmapWidth = bmpWidth;

	previousPosX = -1;
	previousPosY = -1;

	result = InitializeBuffers(device);
	if (!result)
	{
		CLog::Write("CBitmap::Initialize : Could not initialize the buffers");
		return false;
	}

	result = LoadTexture(device, filename);
	if (!result)
	{
		CLog::Write("CBitmap::Initialize : could not load the texture " + filename);
		return false;
	}

	return true;
}
Example #12
0
void PreviewObject::Initialize()
{
	bool result(true);

	//m_pInstancedObject = ContentManager::Load<ModelComponent>(_T("./Resources/Lemmings3D/models/LemmingsCube.ovm"));
	//m_pInstancedObject->Initialize();

	// Load the texture for this model.
	result = LoadTexture(GraphicsDevice::GetInstance()->GetDevice(), m_TextureFile);
	ASSERT(result, _T("Couldn't Load the Texture of the instancedObject!"));
	if(!result)
	{
		Release();
		return;
	}

	// Initialize the vertex and instance buffer that hold the geometry for the triangles.
	result = InitializeBuffers(GraphicsDevice::GetInstance()->GetDevice());
	ASSERT(result, _T("Couldn't initialize buffers of the instancedObject!"));
	if(!result)
	{
		ReleaseBuffers();
		return;
	}
}
bool BitmapClass::Initialize(ID3D11Device* device, ID3D11DeviceContext* deviceContext, HWND hwnd, int screenWidth, int screenHeight, char* textureFilename, int bitmapWidth, int bitmapHeight){
	bool result;

	m_screenWidth = screenWidth;
	m_screenHeight = screenHeight;

	m_previousPosX = -1;
	m_previousPosY = -1;
	m_previousAngle = -1000.0f;

	result = InitializeBuffers(device);
	if (!result){
		return false;
	}
	result = LoadTexture(device, deviceContext, textureFilename, hwnd);
	if (!result){
		return false;
	}

	if (bitmapHeight == 0){
		m_bitmapHeight = m_Texture->GetHeight();
	}
	else{
		m_bitmapHeight = bitmapHeight;
	}

	if (bitmapWidth == 0){
		m_bitmapWidth = m_Texture->GetWidth();
	}
	else{
		m_bitmapWidth = bitmapWidth;
	}

	return true;
}
Example #14
0
////////////////////////////////////////
//		PUBLIC UTILITY FUNCTIONS
////////////////////////////////////////
bool DiffuseContext::Initialize(HWND hWnd)
{
	bool result;

	result = InitializeBuffers();
	if(!result)
	{
		MessageBox(hWnd, L"Could not initialize a sprite context.", L"Error", MB_OK);
		return false;
	}

	// Create the color shader object.
	m_diffuseShade = new DiffuseShader("diffuse","diffuse");
	if(!m_diffuseShade)
	{
		return false;
	}

	// Initialize the color shader object.
	result = m_diffuseShade->Initialize(GraphicsGlobals::g_Device, hWnd);
	if(!result)
	{
		MessageBox(hWnd, L"Could not initialize the diffuse shader object.", L"Error", MB_OK);
		return false;
	}

	return true;
}
Example #15
0
////////////////////////////////////////
//		PUBLIC UTILITY FUNCTIONS
////////////////////////////////////////
bool ParticleContext::Initialize()
{
	bool result;

	result = InitializeBuffers();

	if(!result)
	{
		MessageBox(WindowGlobals::g_hWnd, L"Could not initialize the particle context.", L"Error", MB_OK);
		return false;
	}

	// Create the color shader object.
	m_particleShader = new ParticleShader(L"billboard",L"colors",L"billboard");
	if(!m_particleShader)
	{
		return false;
	}

	// Initialize the color shader object.
	result = m_particleShader->Initialize(ApplicationSettings::g_Device, WindowGlobals::g_hWnd);
	if(!result)
	{
		MessageBox(WindowGlobals::g_hWnd, L"Could not initialize the particle shader object.", L"Error", MB_OK);
		return false;
	}

	return true;
}
bool ModelClass::UpdateBuffers(ID3D11Device* pDevice, void* cBuf)
{
	bool result;




	//Shutdown();

	// Initialize the vertex and index buffers.
	result = InitializeBuffers(pDevice, cBuf);
	if (!result)
	{
		return false;
	}

	return true;

	// no longer loading textures from model
	//	//Load the texture for this model.
	//	result = LoadTexture(pDevice, textureFilename);
	//	if (!result)
	//	{
	//		return false;
	//	}

	return true;


}
bool DynamicBitmapClass::Initialize(ID3D10Device* device, int screenWidth, int screenHeight, int bitmapWidth, int bitmapHeight)
{
    bool result;


    // Store the screen size.
    m_screenWidth = screenWidth;
    m_screenHeight = screenHeight;

    // Store the size in pixels that this bitmap should be rendered at.
    m_bitmapWidth = bitmapWidth;
    m_bitmapHeight = bitmapHeight;

    // Initialize the previous rendering position to negative one.
    m_previousPosX = -1;
    m_previousPosY = -1;
    m_previousScale = 1.0f;

    // Initialize the vertex and index buffer that hold the geometry for the triangle.
    result = InitializeBuffers(device);
    if(!result)
    {
        return false;
    }

    //Create dynamic Textures to forward kinect image data for rendering
    D3D10_TEXTURE2D_DESC desc;
    desc.Width = bitmapWidth;
    desc.Height = bitmapHeight;
    desc.MipLevels = desc.ArraySize = 1;
    desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
    desc.SampleDesc.Count = 1;
    desc.Usage = D3D10_USAGE_DYNAMIC;
    desc.BindFlags = D3D10_BIND_SHADER_RESOURCE;
    desc.CPUAccessFlags = D3D10_CPU_ACCESS_WRITE;
    desc.MiscFlags = 0;


    result = device->CreateTexture2D( &desc, 0, &m_Texture );
    if(FAILED(result))
    {
        return false;
    }

    // Setup the description of the shader resource view.
    D3D10_SHADER_RESOURCE_VIEW_DESC shaderResourceViewDesc;
    shaderResourceViewDesc.Format = desc.Format;
    shaderResourceViewDesc.ViewDimension = D3D10_SRV_DIMENSION_TEXTURE2D;
    shaderResourceViewDesc.Texture2D.MostDetailedMip = 0;
    shaderResourceViewDesc.Texture2D.MipLevels = 1;

    // Create the shader resource view.
    result = device->CreateShaderResourceView(m_Texture, &shaderResourceViewDesc, &m_shaderResourceView);
    if(FAILED(result))
    {
        return false;
    }

    return true;
}
bool ModelClass::Initialize(ID3D11Device* device, char* modelFilename, WCHAR* colorTextureFilename, WCHAR* normalTextureFilename)
{
	bool result;


	// Load in the model data,
	result = LoadModel(modelFilename);
	if(!result)
	{
		return false;
	}

	// Initialize the vertex and index buffers.
	result = InitializeBuffers(device);
	if(!result)
	{
		return false;
	}

	// Load the textures for this model.
	result = LoadTextures(device, colorTextureFilename, normalTextureFilename);
	if(!result)
	{
		return false;
	}

	return true;
}
Example #19
0
static BROTLI_BOOL CompressFile(Context* context, BrotliEncoderState* s) {
  BROTLI_BOOL is_eof = BROTLI_FALSE;
  InitializeBuffers(context);
  for (;;) {
    if (context->available_in == 0 && !is_eof) {
      if (!ProvideInput(context)) return BROTLI_FALSE;
      is_eof = !HasMoreInput(context);
    }

    if (!BrotliEncoderCompressStream(s,
        is_eof ? BROTLI_OPERATION_FINISH : BROTLI_OPERATION_PROCESS,
        &context->available_in, &context->next_in,
        &context->available_out, &context->next_out, NULL)) {
      /* Should detect OOM? */
      fprintf(stderr, "failed to compress data [%s]\n",
              PrintablePath(context->current_input_path));
      return BROTLI_FALSE;
    }

    if (context->available_out == 0) {
      if (!ProvideOutput(context)) return BROTLI_FALSE;
    }

    if (BrotliEncoderIsFinished(s)) {
      return FlushOutput(context);
    }
  }
}
Example #20
0
bool Model::Initialize(ID3D10Device* device,char* modelFile,WCHAR* textureFile)
{
	bool result;



	result = LoadModel(modelFile);
	if(!result)
	{
		return false;
	}

	
	result = InitializeBuffers(device);
	if(!result)
	{
		
		return false;
	}

	// Load the texture for this model.
	result = LoadTexture(device, textureFile);
	if(!result)
	{
		return false;
	}

	return true;
}
Example #21
0
void DrawBloomPass::OnWindowResize()
{
	if (m_Quality == 0) {
		return;
	}
	InitializeBuffers();
}
Example #22
0
bool FoliageClass::Initialize(ID3D11Device* device, WCHAR* textureFilename, int fCount)
{
    bool result;


    // Set the foliage count.
    m_foliageCount = fCount;

    // Generate the positions of the foliage.
    result = GeneratePositions();
    if(!result)
    {
        return false;
    }

    // Initialize the vertex and instance buffer that hold the geometry for the foliage model.
    result = InitializeBuffers(device);
    if(!result)
    {
        return false;
    }

    // Load the texture for this model.
    result = LoadTexture(device, textureFilename);
    if(!result)
    {
        return false;
    }

    // Set the initial wind rotation and direction.
    m_windRotation = 0.0f;
    m_windDirection = 1;

    return true;
}
Example #23
0
bool BitmapClass::Initialize(ID3D11Device* device, int screenWidth, int screenHeight, WCHAR* textureFilename, int bitmapWidth, int bitmapHeight)
{
	bool result;

	// Store the screen size.
	m_screenWidth = screenWidth;
	m_screenHeight = screenHeight;

	// Store the size in pixels that this bitmap should be rendered at.
	m_bitmapWidth = bitmapWidth;
	m_bitmapHeight = bitmapHeight;

	// Initialize the previous rendering position to negative one.
	m_previousPosX = -1;
	m_previousPosY = -1;

	// Initialize the vertex and index buffers.
	result = InitializeBuffers(device);
	if (!result)
		return false;

	// Load the texture for this bitmap.
	result = LoadTexture(device, textureFilename);
	if (!result)
		return false;

	return true;
}
Example #24
0
bool SkyDomeClass::Initialize(ID3D11Device* device)
{
	bool result;


	// Load in the sky dome model.
	result = LoadSkyDomeModel("../TAEngine/data/Objects/skydome.txt");
	if(!result)
	{
		return false;
	}

	// Load the sky dome into a vertex and index buffer for rendering.
	result = InitializeBuffers(device);
	if(!result)
	{
		return false;
	}

	// Set the color at the top of the sky dome.
	m_apexColor = XMFLOAT4(0.04f, 0.05f, 0.06f, 1.0f);
	
	// Set the color at the center of the sky dome.
	m_centerColor = XMFLOAT4(0.2f, 0.05f, 0.06f, 1.0f);
	
	return true;
}
Example #25
0
	bool Bitmap::Initialize(ID3D11Device* device, int screenWidth, int screenHeight)
	{
		bool result;

		// Store the screen size.
		m_screenWidth = screenWidth;
		m_screenHeight = screenHeight;

		// Store the size in pixels that this bitmap should be rendered at.
		m_bitmapWidth = screenWidth;
		m_bitmapHeight = screenHeight;

		// Initialize the previous rendering position to negative one.
		m_previousPosX = -1;
		m_previousPosY = -1;

		// Initialize the vertex and index buffers.
		result = InitializeBuffers(device);
		if(!result)
		{
			return false;
		}

		return true;
	}
Example #26
0
bool HexMapClass::Initialize(ID3D11Device* device, int screenWidth, int screenHeight, CHAR* textureFilename, int mapWidth, int mapHeight){
	bool result;

	// Store the screen size.
	m_screenWidth = screenWidth;
	m_screenHeight = screenHeight;

	// Store the dimensions of the map.
	m_mapWidth = mapWidth;
	m_mapHeight = mapHeight;
	m_mapTiles = m_mapWidth*m_mapHeight;

	// Initialize the previous rendering position to negative one.
	m_previousPosX = -1;
	m_previousPosY = -1;

	// Initialize the vertex and index buffers.
	result = InitializeBuffers(device);
	if (!result){
		return false;
	}

	// Load the texture for this model.
	result = LoadTexture(device, textureFilename);
	if (!result){
		return false;
	}

	return true;
}
bool ModelClass::Initialize(ID3D11Device* device, char* modelFilename, WCHAR* textureFilename, HWND m_hwnd)
{
	bool result;

	Vesseltree::Root *tree = Vesseltree::Parser::parseDocument("Resources/vesselTree2.xml", m_hwnd);
	Sampling* sampling = new Sampling;
	sampling->downsample(tree, 1, 1); 
	
	mesh = new Mesh;
	mesh->calculateMesh(tree);
	AdaptiveSubdivision* subdiv = new AdaptiveSubdivision;

	mesh->triangles = subdiv->Subdivide(mesh->triangles, 0.05, 2);
	
	// Initialize the vertex and index buffers.
	result = InitializeBuffers(device);
	if(!result)
	{
		return false;
	}

	// Load the texture for this model.
	result = LoadTexture(device, textureFilename);
	if(!result)
	{
		return false;
	}
	

	return true;
}
Example #28
0
Model::Model(ID3D11Device* device, std::shared_ptr<ModelData> modelData, WCHAR* textureFilename, std::string name) : RenderObject(name)
{
	this->m_vertexBuffer = 0;
	this->m_indexBuffer = 0;
	this->m_texture = 0;
	this->m_model = 0;

	bool result;

	result = LoadModel(modelData);
	if (!result)
	{
		throw std::exception("Could not load modelData");
	}

	result = InitializeBuffers(device);
	if (!result)
	{
		throw std::exception("Could not initialize Model Buffers");
	}

	result = LoadTexture(device, textureFilename);
	if (!result)
	{
		std::stringstream ss;
		ss << "Could not load Model Texture: " << textureFilename;
		throw std::exception(ss.str().c_str());
	}
}
Example #29
0
bool ModelClass::Initialize(ID3D11Device *device, char *modelFilename, WCHAR *textureFilename1, WCHAR * textureFilename2, WCHAR *textureFilename3)
{
	bool result;

	//load model data
	result = LoadModel(modelFilename);
	if (!result)
	{
		return false;
	}

	//intialize the vertex and index buffer that hold the geometry for the triangle
	result = InitializeBuffers(device);
	if (!result)
	{
		return false;
	}

	//load the texture for this model
	result = LoadTextures(device, textureFilename1, textureFilename2, textureFilename3);
	if (!result)
	{
		return false;
	}

	return true;
}
bool ModelClass::Initialize(ID3D11Device* device, int xCount, int yCount, float uTexScale, float vTexScale,
	WCHAR* heightmap, WCHAR* primary, WCHAR* secondary, WCHAR* tertiary)
{
	bool result;


	// Load in the model data,
	result = LoadQuadMesh(xCount, yCount, uTexScale, vTexScale);
	if(!result)
	{
		return false;
	}


	// Initialize the vertex and index buffers.
	result = InitializeBuffers(device);
	if(!result)
	{
		return false;
	}

	//CalculateBNT(device);

	// Load the texture for this model.
	result = LoadTexture(device, heightmap, primary, secondary, tertiary);
	if(!result)
	{
		return false;
	}

	return true;
}