Пример #1
0
bool TextClass::SetMousePosition(int mouseX, int mouseY, ID3D11DeviceContext* deviceContext)
{
	char tempString[16];
	char mouseString[16];
	bool result;

	_itoa_s(mouseX, tempString, 10);

	strcpy_s(mouseString, "Mouse X: ");
	strcat_s(mouseString, tempString);

	result = UpdateSentence(_sentence1, mouseString, 20, 20, 1.0f, 1.0f, 1.0f, deviceContext);
	if (!result)
	{
		return false;
	}

	_itoa_s(mouseY, tempString, 10);

	strcpy_s(mouseString, "Mouse Y: ");
	strcat_s(mouseString, tempString);

	result = UpdateSentence(_sentence2, mouseString, 20, 40, 1.0f, 1.0f, 1.0f, deviceContext);
	if (!result)
	{
		return false;
	}
	
	return true;
}
Пример #2
0
bool CTextClass::Initialize(ID3D11Device* device, ID3D11DeviceContext* deviceContext, HWND hwnd, int screenWidth, int screenHeight, XMMATRIX& baseViewMatrix)
{
	bool result;

	//Guardamos el alto y ancho de la pantalla, junto con la matriz base de vista
	m_screenWidth = screenWidth;
	m_screenHeight = screenHeight;
	m_baseViewMatrix = baseViewMatrix;

	//Inicializamos la clase Font
	m_Font = new CFontClass();
	if (!m_Font)
	{
		return false;
	}
	result = m_Font->Initialize(device, "../Resources/Fonts/DaFontTextureCoord.txt", L"../Resources/Fonts/DaFont.dds");
	if (!result)
	{
		MessageBox(hwnd, L"No se pudo inicializar la Font", L"Error", MB_OK);
		return false;
	}
	//Ahorael shader de la clase Font
	m_FontShader = new CFontShaderClass();
	if (!m_FontShader)
	{
		return false;
	}
	result = m_FontShader->Initialize(device, hwnd);
	if (!result)
	{
		MessageBox(hwnd, L"No se pudo inicializar la Font Shader", L"Error", MB_OK);
		return false;
	}

	//Ahora las sentencias, primero la primera
	//
	result = initializeSentence(&m_Sentence1, 16, device);
	if (!result)
	{
		return false;
	}
	result = UpdateSentence(m_Sentence1, "Hello", 100, 100, 1.0f, 1.0f, 1.0f, deviceContext);
	if (!result)
	{
		return false;
	}
	//Ahora la segunda
	result = initializeSentence(&m_Sentence2, 16, device);
	if (!result)
	{
		return false;
	}
	result = UpdateSentence(m_Sentence2, "Goodbye", 100, 200, 1.0f, 1.0f, 0.0f, deviceContext);
	if (!result)
	{
		return false;
	}
	return true;
}
Пример #3
0
bool TextClass::SetCameraPosition(float posX, float posY, float posZ, ID3D11DeviceContext* deviceContext)
{
	int positionX, positionY, positionZ;
	char tempString[16];
	char dataString[16];
	bool result;


	// Convert the position from floating point to integer.
	positionX = (int)posX;
	positionY = (int)posY;
	positionZ = (int)posZ;

	// Truncate the position if it exceeds either 9999 or -9999.
	if(positionX > 9999) { positionX = 9999; }
	if(positionY > 9999) { positionY = 9999; }
	if(positionZ > 9999) { positionZ = 9999; }

	if(positionX < -9999) { positionX = -9999; }
	if(positionY < -9999) { positionY = -9999; }
	if(positionZ < -9999) { positionZ = -9999; }

	// Setup the X position string.
	_itoa_s(positionX, tempString, 10);
	strcpy_s(dataString, "X: ");
	strcat_s(dataString, tempString);

	result = UpdateSentence(m_sentence5, dataString, 10, 130, 0.0f, 1.0f, 0.0f, deviceContext);
	if(!result)
	{
		return false;
	}
	
	// Setup the Y position string.
	_itoa_s(positionY, tempString, 10);
	strcpy_s(dataString, "Y: ");
	strcat_s(dataString, tempString);

	result = UpdateSentence(m_sentence6, dataString, 10, 150, 0.0f, 1.0f, 0.0f, deviceContext);
	if(!result)
	{
		return false;
	}

	// Setup the Z position string.
	_itoa_s(positionZ, tempString, 10);
	strcpy_s(dataString, "Z: ");
	strcat_s(dataString, tempString);

	result = UpdateSentence(m_sentence7, dataString, 10, 170, 0.0f, 1.0f, 0.0f, deviceContext);
	if(!result)
	{
		return false;
	}

	return true;
}
Пример #4
0
bool TextClass::SetCameraRotation(float rotX, float rotY, float rotZ, ID3D11DeviceContext* deviceContext)
{
	int rotationX, rotationY, rotationZ;
	char tempString[16];
	char dataString[16];
	bool result;


	// Convert the rotation from floating point to integer.
	rotationX = (int)rotX;
	rotationY = (int)rotY;
	rotationZ = (int)rotZ;

	// Setup the X rotation string.
	_itoa_s(rotationX, tempString, 10);
	strcpy_s(dataString, "rX: ");
	strcat_s(dataString, tempString);

	result = UpdateSentence(m_sentence8, dataString, 10, 210, 0.0f, 1.0f, 0.0f, deviceContext);
	if(!result)
	{
		return false;
	}

	// Setup the Y rotation string.
	_itoa_s(rotationY, tempString, 10);
	strcpy_s(dataString, "rY: ");
	strcat_s(dataString, tempString);

	result = UpdateSentence(m_sentence9, dataString, 10, 230, 0.0f, 1.0f, 0.0f, deviceContext);
	if(!result)
	{
		return false;
	}

	// Setup the Z rotation string.
	_itoa_s(rotationZ, tempString, 10);
	strcpy_s(dataString, "rZ: ");
	strcat_s(dataString, tempString);

	result = UpdateSentence(m_sentence10, dataString, 10, 250, 0.0f, 1.0f, 0.0f, deviceContext);
	if(!result)
	{
		return false;
	}

	return true;
}
Пример #5
0
bool TextClass::SetFps(int fps, ID3D11DeviceContext* deviceContext)
{
	char tempString[16];
	char fpsString[16];
	bool result;


	// Truncate the fps to prevent a buffer over flow.
	if(fps > 9999)
	{
		fps = 9999;
	}

	// Convert the fps integer to string format.
	_itoa_s(fps, tempString, 10);

	// Setup the fps string.
	strcpy_s(fpsString, "Fps: ");
	strcat_s(fpsString, tempString);

	// Update the sentence vertex buffer with the new string information.
	result = UpdateSentence(m_sentence3, fpsString, 10, 70, 0.0f, 1.0f, 0.0f, deviceContext);
	if(!result)
	{
		return false;
	}

	return true;
}
Пример #6
0
bool TextHandle::SetRenderCount(int count, ID3D11DeviceContext* deviceContext)
{
	char tempString[16];
	char renderString[32];
	bool result;


	// Truncate the render count if it gets to large to prevent a buffer overflow.
	if(count > 999999999)
	{
		count = 999999999;
	}

	// Convert the cpu integer to string format.
	_itoa_s(count, tempString, 10);

	// Setup the cpu string.
	strcpy_s(renderString, "Render Count: ");
	strcat_s(renderString, tempString);

	// Update the sentence vertex buffer with the new string information.
	result = UpdateSentence(m_sentence11, renderString, 10, 290, 0.0f, 1.0f, 0.0f, deviceContext);
	if(!result)
	{
		return false;
	}

	return true;
}
Пример #7
0
bool TextClass::SetRenderCount(int renderCount){
	char tempString[20];
	char renderString[20];
	bool result;


	// Truncate the fps to prevent a buffer over flow.
	if(renderCount > 99999)
	{
		renderCount = 99999;
	}

	// Convert the fps integer to string format.
	_itoa_s(renderCount, tempString, 10);

	// Setup the fps string.
	strcpy_s(renderString, "Rendering: ");
	strcat_s(renderString, tempString);

	// Update the sentence vertex buffer with the new string information.
	result = UpdateSentence(m_sentence1, renderString, 10, 10, 0.0f, 1.0f, 0.0f);
	if(!result)
	{
		return false;
	}

	return true;
}
Пример #8
0
	void TextClass::UpdateText2(const char * text,ID3D11DeviceContext * devCon)
	{
		char * newText = new char[strlen(text)+2];
		strcpy(newText,text);
		UpdateSentence(mSentence2, newText, 10, 10 , 0.0f, 1.0f, 0.0f, devCon);
		delete[] newText;
	}
bool TextClass::Initialize(ID3D11Device* device, ID3D11DeviceContext* deviceContext, HWND hwnd, int screenWidth, int screenHeight, 
						   D3DXMATRIX baseViewMatrix)
{
	bool result;


	// Store the screen width and height.
	m_screenWidth = screenWidth;
	m_screenHeight = screenHeight;

	// Store the base view matrix.
	m_baseViewMatrix = baseViewMatrix;

	// Create the font object.
	m_Font = new FontClass;
	if(!m_Font)
	{
		return false;
	}

	// Initialize the font object.
	result = m_Font->Initialize(device, "../Engine/data/fontdata.txt", L"../Engine/data/font.dds");
	if(!result)
	{
		MessageBox(hwnd, L"Could not initialize the font object.", L"Error", MB_OK);
		return false;
	}

	// Create the font shader object.
	m_FontShader = new FontShaderClass;
	if(!m_FontShader)
	{
		return false;
	}

	// Initialize the font shader object.
	result = m_FontShader->Initialize(device, hwnd);
	if(!result)
	{
		MessageBox(hwnd, L"Could not initialize the font shader object.", L"Error", MB_OK);
		return false;
	}

	// Initialize the first sentence.
	result = InitializeSentence(&m_sentence1, 32, device);
	if(!result)
	{
		return false;
	}

	// Now update the sentence vertex buffer with the new string information.
	result = UpdateSentence(m_sentence1, "Intersection: No", 20, 20, 1.0f, 0.0f, 0.0f, deviceContext);
	if(!result)
	{
		return false;
	}

	return true;
}
Пример #10
0
bool Text::ChangeSentence(ID3D11DeviceContext* deviceContext, int id, std::string text, int positionX, int positionY, 
						  float red, float green, float blue){
	if (m_sentenceArray[id] == 0){
		textDump("invalid access of sentence");
		return false;
	}
	return UpdateSentence(m_sentenceArray[id], text, positionX, positionY, red, green, blue, deviceContext);
}
bool TextClass::SetIntersection(bool intersection, ID3D11DeviceContext* deviceContext)
{
	char intersectionString[32];
	bool result;


	if(intersection)
	{
		strcpy_s(intersectionString, "Intersection: Yes");
		result = UpdateSentence(m_sentence1, intersectionString, 20, 20, 0.0f, 1.0f, 0.0f, deviceContext);
	}
	else
	{
		strcpy_s(intersectionString, "Intersection: No");
		result = UpdateSentence(m_sentence1, intersectionString, 20, 20, 1.0f, 0.0f, 0.0f, deviceContext);
	}

	return result;
}
Пример #12
0
	bool TextClass::Initialize(ID3D11Device* dev, ID3D11DeviceContext * devCon, HWND hwnd, int screenWidth, int screenHeight)
	{
		bool result;
		mScreenWidth = screenWidth;
		mScreenHeight = screenHeight;

		mFont = new FontClass();
		if(!mFont)
		{
			return false;
		}
		result = mFont->Init(dev,"data/fontIndex.txt", "data/font.gif");
		if(!result)
		{
			LOG_MSGERR("Problem with init font");	
			return false;
		}
		mFontShader = new FontShaderClass();
		mFontShader->Init(dev,hwnd);
		result = InitializeSentence(&mSentence1,40, dev);
		if(!result)
		{
			LOG_MSGERR("Problem with init sentence");	
			return false;
		}
		result = UpdateSentence(mSentence1,"Hello World!", 100,100 , 1.0f, 1.0f, 1.0f, devCon);
		if(!result)
		{
			return false;
		}
		result = InitializeSentence(&mSentence2,16, dev);
		if(!result)
		{
			LOG_MSGERR("Problem with init sentence");	
			return false;
		}
		result = UpdateSentence(mSentence2,"Goodbye", 100,200 , 1.0f, 1.0f, 0.0f, devCon);
		if(!result)
		{
			return false;
		}
		return true;
	}
Пример #13
0
bool OldText::Init(ID3D11Device* device, ID3D11DeviceContext* deviceContext, HWND hwnd, int screenWidth, int screenHeight, D3DXMATRIX baseViewMatrix, 
	char* words, int startX, int startY, float r, float g, float b)
{
	bool result;

	result = CoCreateGuid(&_guid);
	if (FAILED(result))
		return false;

	//Store the screen width and heigh
	_screenWidth = screenWidth;
	_screenHeight = screenHeight;

	_baseViewMatrix = baseViewMatrix;

	_words = words;

	_drawX = 0;
	_drawY = 0;

	//Create the font and font shader objects
	_font = new Font();
	if (!_font)
		return false;

	result = _font->Init(device, "Data/Fonts/fontdata.txt", "Data/Fonts/font.dds");
	if (!result)
	{
		MessageBox(hwnd, L"Could not init the font object", L"Error", MB_OK);
		return false;
	}

	_fontShader = new OldFontShader();
	if (!_fontShader)
		return false;

	result = _fontShader->Init(device, hwnd);
	if (!result)
	{
		MessageBox(hwnd, L"Could not init the font shader object", L"Error", MB_OK);
		return false;
	}

	//Init the first sentence
	result = InitSentence(&_sentence, 32, device);
	if (!result)
		return false;

	//Update the sentence vertex buffer with the new string info
	result = UpdateSentence(_words, startX, startY, 1.0f, 1.0f, 1.0f, deviceContext);
	if (!result)
		return false;

	return true;
}
Пример #14
0
bool TextClass::SetVideoCardInfo(char* videoCardName, int videoCardMemory, ID3D11DeviceContext* deviceContext)
{
	char dataString[150];
	bool result;
	char tempString[16];
	char memoryString[32];


	// Setup the video card name string.
	strcpy_s(dataString, "Video Card: ");
	strcat_s(dataString, videoCardName);

	// Update the sentence vertex buffer with the new string information.
	result = UpdateSentence(m_sentence1, dataString, 10, 10, 1.0f, 1.0f, 1.0f, deviceContext);
	if(!result)
	{
		return false;
	}

	// Truncate the memory value to prevent buffer over flow.
	if(videoCardMemory > 9999999)
	{
		videoCardMemory = 9999999;
	}

	// Convert the video memory integer value to a string format.
	_itoa_s(videoCardMemory, tempString, 10);

	// Setup the video memory string.
	strcpy_s(memoryString, "Video Memory: ");
	strcat_s(memoryString, tempString);
	strcat_s(memoryString, " MB");

	// Update the sentence vertex buffer with the new string information.
	result = UpdateSentence(m_sentence2, memoryString, 10, 30, 1.0f, 1.0f, 1.0f, deviceContext);
	if(!result)
	{
		return false;
	}

	return true;
}
Пример #15
0
bool TextClass::SetFps(int fps, ID3D11DeviceContext* deviceContext)
{
    char tempString[16];
    char fpsString[16];
    float red, green, blue;
    bool result;


    // Truncate the fps to below 10,000.
    if(fps > 9999)
    {
        fps = 9999;
    }

    // Convert the fps integer to string format.
    _itoa_s(fps, tempString, 10);

    // Setup the fps string.
    strcpy_s(fpsString, "Fps: ");
    strcat_s(fpsString, tempString);

    // If fps is 60 or above set the fps color to green.
    if(fps >= 60)
    {
        red = 0.0f;
        green = 1.0f;
        blue = 0.0f;
    }

    // If fps is below 60 set the fps color to yellow.
    if(fps < 60)
    {
        red = 1.0f;
        green = 1.0f;
        blue = 0.0f;
    }

    // If fps is below 30 set the fps color to red.
    if(fps < 30)
    {
        red = 1.0f;
        green = 0.0f;
        blue = 0.0f;
    }

    // Update the sentence vertex buffer with the new string information.
    result = UpdateSentence(m_sentence1, fpsString, 20, 20, red, green, blue, deviceContext);
    if(!result)
    {
        return false;
    }

    return true;
}
bool TextClass::GetDirectories(string names[], int game, ID3D11DeviceContext* deviceContext)
{
	bool result;

	char sen1[256];
	strcpy(sen1, names[game].c_str());

	result = UpdateSentence(m_sentence1, sen1, 900 - (names[game].length() * 5)/2, 105, 0.0f, 0.0f, 0.0f, deviceContext);
	if (!result)
	{
		return false;
	}

	result = UpdateSentence(m_sentence2, sen1, 900 - (names[game].length() * 5) / 2, 100, 1.0f, 1.0f, 1.0f, deviceContext);
	if (!result)
	{
		return false;
	}

}
Пример #17
0
bool Text::Initialize(ID3D11Device* device, ID3D11DeviceContext* deviceContext,
	HWND hwnd, int screenWidth, int screenHeight, D3DXMATRIX baseViewMatrix)
{
	bool result;
	m_screenWidth = screenWidth;
	m_screenHeight = screenHeight;
	m_baseViewMatrix = baseViewMatrix;


	m_Font = new Font();
	result = m_Font->Initialize(device, fontCfgPath, fontImgPath.c_str());
	if (!result)
	{
		MessageBox(hwnd, "Could not initialize the font object", "Error", MB_OK);
		return false;
	}

	m_FontShader = new FontShader();
	result = m_FontShader->Initialize(device, hwnd);
	if (!result)
	{
		MessageBox(hwnd, "Could not initialize the font shader object", "Error", MB_OK);
		return false;
	}


	result = InitializeSentence(&sen01, 16, device);
	if (!result) return false;

	result = InitializeSentence(&sen02, 16, device);
	if (!result) return false;

	result = UpdateSentence(sen01, "chuj, dupa", 0, 0, 1.0f, 1.0f, 1.0f, deviceContext);
	if (!result) return false;

	result = UpdateSentence(sen02, "i kamieni kupa", 0, 0, 1.0f, 1.0f, 1.0f, deviceContext);
	if (!result) return false;

	return true;
}
bool TextClass::SetMousePosition(int mouseX, int mouseY, ID3D11DeviceContext* deviceContext)
{
	char tempString[16];
	char mouseString[16];
	bool result;


	// Convert the mouseX integer to string format.
	_itoa_s(mouseX, tempString, 10);

	// Setup the mouseX string.
	strcpy_s(mouseString, "Mouse X: ");
	strcat_s(mouseString, tempString);

	// Update the sentence vertex buffer with the new string information.
	result = UpdateSentence(m_sentence1, mouseString, 20, 20, 1.0f, 1.0f, 1.0f, deviceContext);
	if (!result)
	{
		return false;
	}

	// Convert the mouseY integer to string format.
	_itoa_s(mouseY, tempString, 10);

	// Setup the mouseY string.
	strcpy_s(mouseString, "Mouse Y: ");
	strcat_s(mouseString, tempString);

	// Update the sentence vertex buffer with the new string information.
	result = UpdateSentence(m_sentence2, mouseString, 20, 60, 1.0f, 1.0f, 1.0f, deviceContext);
	if (!result)
	{
		return false;
	}

	return true;
}
bool TextClass::SetJoystickRot(int joyX, int joyY, ID3D11DeviceContext* deviceContext)
{
	char tempString[16];
	char joyString[16];
	bool result;


	// Convert the mouseX integer to string format.
	_itoa_s(joyX, tempString, 32);

	// Setup the mouseX string.
	strcpy_s(joyString, "Joystick X: ");
	strcat_s(joyString, tempString);

	// Update the sentence vertex buffer with the new string information.
	result = UpdateSentence(m_sentence1, joyString, 20, 20, 1.0f, 1.0f, 1.0f, deviceContext);
	if (!result)
	{
		return false;
	}

	// Convert the mouseY integer to string format.
	_itoa_s(joyY, tempString, 32);

	// Setup the mouseY string.
	strcpy_s(joyString, "Joystick Y: ");
	strcat_s(joyString, tempString);

	// Update the sentence vertex buffer with the new string information.
	result = UpdateSentence(m_sentence2, joyString, 20, 60, 1.0f, 1.0f, 1.0f, deviceContext);
	if (!result)
	{
		return false;
	}

	return true;
}
Пример #20
0
bool TextClass::SetFps(int fps, ID3D11DeviceContext* context)
{
	char tempString[16];
	char fpsString[16];
	float r, g, b;
	bool result;

	if (fps > 9999)
	{
		fps = 9999;
	}

	_itoa_s(fps, tempString, 10);

	strcpy_s(fpsString, "Fps : ");
	strcat_s(fpsString, tempString);

	if (fps >= 60)
	{
		r = 0.0f;
		g = 1.0f;
		b = 0.0f;
	}

	if (fps < 60)
	{
		r = 1.0f;
		g = 1.0f;
		b = 0.0f;
	}

	if (fps < 60)
	{
		r = 1.0f;
		g = 0.0f;
		b = 0.0f;
	}

	result = UpdateSentence(_fpsentence, fpsString, 100, 20, r, g, b, context);
	if (!result)
	{
		return false;
	}

	return true;
}
Пример #21
0
bool TextClass::AddWord(char * text, int x, int y, float r, float g, float b )
{
	bool result;
	// Initialize the first sentence.
	result = InitializeSentence(&m_sentence2, 18, m_d3d);
	if(!result)
	{
		return false;
	}

	// Now update the sentence vertex buffer with the new string information.
	result = UpdateSentence(m_sentence2, text, x, y, r, g, b);
	if(!result)
	{
		return false;
	}
	return result;
}
Пример #22
0
bool TextClass::SetCpu(int cpu, ID3D11DeviceContext* context)
{
	char tempString[16];
	char cpustring[16];
	bool result;

	_itoa_s(cpu, tempString, 10);

	strcpy_s(cpustring, "Cpu : ");
	strcat_s(cpustring, tempString);
	strcat_s(cpustring, "%");

	result = UpdateSentence(_cpusentence, cpustring, 100, 40, 0.0f, 1.f, 0.f, context);
	if (!result)
	{
		return false;
	}

	return true;
}
Пример #23
0
bool TextClass::SetRenderCount(int cpu)
{
	char tempString[16];
	char cpuString[16];
	bool result;


	// Convert the cpu integer to string format.
	_itoa_s(cpu, tempString, 10);

	// Setup the cpu string.
	strcpy_s(cpuString, "Objects: ");
	strcat_s(cpuString, tempString);

	// Update the sentence vertex buffer with the new string information.
	result = UpdateSentence(m_sentence2, cpuString, 200, 40, 0.0f, 1.0f, 0.0f);
	if(!result)
	{
		return false;
	}

	return true;
}
Пример #24
0
bool TextClass::SetCpu(int cpu, ID3D11DeviceContext* deviceContext)
{
	char tempString[16];
	char cpuString[16];
	bool result;


	// Convert the cpu integer to string format.
	_itoa_s(cpu, tempString, 10);

	// Setup the cpu string.
	strcpy_s(cpuString, "Cpu: ");
	strcat_s(cpuString, tempString);
	strcat_s(cpuString, "%");

	// Update the sentence vertex buffer with the new string information.
	result = UpdateSentence(m_sentence4, cpuString, 10, 90, 0.0f, 1.0f, 0.0f, deviceContext);
	if(!result)
	{
		return false;
	}

	return true;
}
Пример #25
0
bool TextClass::SetTime(float cpu)
{
	char tempString[20];
	char cpuString[20];
	bool result;


	// Convert the cpu integer to string format.
	sprintf(tempString,"%f", sprintf);

	// Setup the cpu string.
	strcpy_s(cpuString, "time: ");
	strcat_s(cpuString, tempString);
	strcat_s(cpuString, "ms");

	// Update the sentence vertex buffer with the new string information.
	result = UpdateSentence(m_sentence2, cpuString, 90, 40, 0.0f, 1.0f, 0.0f);
	if(!result)
	{
		return false;
	}

	return true;
}
Пример #26
0
bool TextClass::Initialize(ID3D11Device* device, ID3D11DeviceContext* context, HWND hwnd, int screenWidth, int screenHeight, D3DXMATRIX baseViewMatrix)
{
	bool result;

	_screenWidth = screenWidth;
	_screenHeight = screenHeight;

	_baseViewMatrix = baseViewMatrix;

	_font = new FontClass;
	if (!_font)
	{
		return false;
	}

	result = _font->Initialize(device, "fontIndex.txt", L"./Texture/font.gif");
	if (!result)
	{
		MessageBox(hwnd, L"Coud not Init th font obj", L"E", MB_OK);
		return false;
	}


	_fontShader = new FontShaderClass;
	if (!_fontShader)
	{
		return false;
	}

	result = _fontShader->Initialize(device, hwnd);
	if (!result)
	{
		MessageBox(hwnd, L"Coud not init font shader obj", L"E", MB_OK);
		return false;
	}

	result = InitializeSentence(&_sentence1, 16, device);
	if (!result)
	{
		return false;
	}

	result = UpdateSentence(_sentence1, "Hello", 100, 200, 1.0f, 1.0f, 1.0f, context);
	if (!result)
	{
		return false;
	}

	result = InitializeSentence(&_sentence2, 16, device);
	if (!result)
	{
		return false;
	}

	result = UpdateSentence(_sentence2, "GOODBYE", 100, 20, 1.0f, 1.0f, 0.0f, context);
	if (!result)
	{
		return false;
	}

	result = InitializeSentence(&_fpsentence, 16, device);
	if (!result)
	{
		return false;
	}

	result = InitializeSentence(&_cpusentence, 16, device);
	if (!result)
	{
		return false;
	}

	return true;
}
Пример #27
0
bool TextClass::InitializeSentence(ID3D11Device* device, FontClass* Font, char* text, int positionX, int positionY, float red, float green, float blue, ID3D11DeviceContext* deviceContext)
{
    VertexType* vertices;
    unsigned long* indices;
    D3D11_BUFFER_DESC vertexBufferDesc, indexBufferDesc;
    D3D11_SUBRESOURCE_DATA vertexData, indexData;
    HRESULT result;
    int i;


    // Set the vertex and index count.
    m_vertexCount = 6 * m_maxLength;
    m_indexCount = 6 * m_maxLength;

    // Create the vertex array.
    vertices = new VertexType[m_vertexCount];
    if(!vertices)
    {
        return false;
    }

    // Create the index array.
    indices = new unsigned long[m_indexCount];
    if(!indices)
    {
        return false;
    }

    // Initialize vertex array to zeros at first.
    memset(vertices, 0, (sizeof(VertexType) * m_vertexCount));

    // Initialize the index array.
    for(i=0; i<m_indexCount; i++)
    {
        indices[i] = i;
    }

    // Set up the description of the dynamic vertex buffer.
    vertexBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
    vertexBufferDesc.ByteWidth = sizeof(VertexType) * m_vertexCount;
    vertexBufferDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
    vertexBufferDesc.CPUAccessFlags = D3D10_CPU_ACCESS_WRITE;
    vertexBufferDesc.MiscFlags = 0;
    vertexBufferDesc.StructureByteStride = 0;

    // Give the subresource structure a pointer to the vertex data.
    vertexData.pSysMem = vertices;
    vertexData.SysMemPitch = 0;
    vertexData.SysMemSlicePitch = 0;

    // Create the vertex buffer.
    result = device->CreateBuffer(&vertexBufferDesc, &vertexData, &m_vertexBuffer);
    if(FAILED(result))
    {
        return false;
    }

    // Set up the description of the static index buffer.
    indexBufferDesc.Usage = D3D11_USAGE_DEFAULT;
    indexBufferDesc.ByteWidth = sizeof(unsigned long) * m_indexCount;
    indexBufferDesc.BindFlags = D3D11_BIND_INDEX_BUFFER;
    indexBufferDesc.CPUAccessFlags = 0;
    indexBufferDesc.MiscFlags = 0;
    indexBufferDesc.StructureByteStride = 0;

    // Give the subresource structure a pointer to the index data.
    indexData.pSysMem = indices;
    indexData.SysMemPitch = 0;
    indexData.SysMemSlicePitch = 0;

    // Create the index buffer.
    result = device->CreateBuffer(&indexBufferDesc, &indexData, &m_indexBuffer);
    if(FAILED(result))
    {
        return false;
    }

    // If shadowed create the second vertex and index buffer.
    if(m_shadow)
    {
        result = device->CreateBuffer(&vertexBufferDesc, &vertexData, &m_vertexBuffer2);
        if(FAILED(result))
        {
            return false;
        }

        result = device->CreateBuffer(&indexBufferDesc, &indexData, &m_indexBuffer2);
        if(FAILED(result))
        {
            return false;
        }
    }

    // Release the vertex array as it is no longer needed.
    delete [] vertices;
    vertices = 0;

    // Release the index array as it is no longer needed.
    delete [] indices;
    indices = 0;

    // Now add the text data to the sentence buffers.
    result = UpdateSentence(Font, text, positionX, positionY, red, green, blue, deviceContext);
    if(!result)
    {
        return false;
    }

    return true;
}