예제 #1
0
파일: text.cpp 프로젝트: steve7987/Stick
int Text::RegisterSentence(ID3D11Device* device, int maxLength){
	//find first open spot for sentence
	int index;
	for (index = 0; index < MAXSENTENCE; index++){
		if (m_sentenceArray[index] == 0){
			break;
		}
	}
	if (index == MAXSENTENCE){
		textDump("sentence array full");
		return -1;
	}
	//check if highestsentence should be updated
	if (index >= highestSentence){
		highestSentence = index + 1;
	}
	//found open index, register sentence
	//can make new sentence here and then not pass sentencetype ** (i think)
	m_sentenceArray[index] = new SentenceType;
	if (InitializeSentence(m_sentenceArray[index], maxLength, device)){
		m_sentenceArray[index]->visible = true;
		return index;
	}
	textDump("error initializing sentence");
	return -1;
}
예제 #2
0
bool TextClass::Initialize(ID3D11Device* device, FontClass* Font, int screenWidth, int screenHeight, int maxLength, char* text, int positionX, int positionY, float red, float green, float blue, bool shadow,
                           ID3D11DeviceContext* deviceContext)
{
    bool result;


    // Store if this sentence is shadowed or not.
    m_shadow = shadow;

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

    // Store the maximum length of the sentence.
    m_maxLength = maxLength;

    // Initalize the sentence.
    result = InitializeSentence(device, Font, text, positionX, positionY, red, green, blue, deviceContext);
    if(!result)
    {
        return false;
    }

    return true;
}
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;
}
예제 #4
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;
	}
예제 #5
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;
}
예제 #6
0
파일: textclass.cpp 프로젝트: xdiv/dev
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;
}
예제 #7
0
bool TextClass::Initialize(ID3D11Device* device, ID3D11DeviceContext* deviceContext, HWND hwnd, int screenWidth, int screenHeight, 
						   D3DXMATRIX baseViewMatrix)
{
	bool result;


	// Store the screen width and height for calculating pixel location during the sentence updates.
	m_screenWidth = screenWidth;
	m_screenHeight = screenHeight;

	// Store the base view matrix for 2D text rendering.
	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, "../StarLight/data/fontdata.txt", L"../StarLight/data/font.dds");
	if(!result)
	{
		MessageBox(hwnd, L"Could not initialize the font object.", L"Error", MB_OK);
		return false;
	}

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

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

	// Initialize the third sentence.
	result = InitializeSentence(&m_sentence3, 16, device);
	if(!result)
	{
		return false;
	}

	// Initialize the fourth sentence.
	result = InitializeSentence(&m_sentence4, 16, device);
	if(!result)
	{
		return false;
	}

	// Initialize the fifth sentence.
	result = InitializeSentence(&m_sentence5, 16, device);
	if(!result)
	{
		return false;
	}

	// Initialize the sixth sentence.
	result = InitializeSentence(&m_sentence6, 16, device);
	if(!result)
	{
		return false;
	}

	// Initialize the seventh sentence.
	result = InitializeSentence(&m_sentence7, 16, device);
	if(!result)
	{
		return false;
	}

	// Initialize the eighth sentence.
	result = InitializeSentence(&m_sentence8, 16, device);
	if(!result)
	{
		return false;
	}

	// Initialize the ninth sentence.
	result = InitializeSentence(&m_sentence9, 16, device);
	if(!result)
	{
		return false;
	}

	// Initialize the tenth sentence.
	result = InitializeSentence(&m_sentence10, 16, device);
	if(!result)
	{
		return false;
	}

	return true;
}
예제 #8
0
파일: textclass.cpp 프로젝트: xdiv/dev
bool TextClass::Initialize(ID3D10Device* device, HWND hwnd, int screenWidth, int screenHeight, D3DXMATRIX baseViewMatrix)
{
	bool result;
	//Store the screen size and the base view matrix, these will be used for rendering 2D text.
	m_d3d = device;
	// Store the screen width and height.
	m_screenWidth = screenWidth;
	m_screenHeight = screenHeight;

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

	//Create and initialize the font object.
	// 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 and initialize the font shader object.
	// 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;
	}

	// Create and initialize the two strings that will be used for this tutorial. One string says Hello in white at 100, 100 and the other
	// says Goodbye in yellow at 100, 200. The UpdateSentence function can be called to change the contents, location, and color of the strings at any time.
	// Initialize the first sentence.
	result = InitializeSentence(&m_sentence1, 16, device);
	if(!result)
	{
		return false;
	}

	// Now update the sentence vertex buffer with the new string information.
	/*result = UpdateSentence(m_sentence1, "Hello", 100, 100, 1.0f, 1.0f, 1.0f);
	if(!result)
	{
		return false;
	}*/

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

	// Now update the sentence vertex buffer with the new string information.
	/*result = UpdateSentence(m_sentence2, "Goodbye", 100, 200, 1.0f, 1.0f, 0.0f);
	if(!result)
	{
		return false;
	}*/

	return true;
}
예제 #9
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;
}
예제 #10
0
bool TextClass::Initialize(ID3D10Device* device, 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, "assets/font/fontdata.txt", L"assets/font/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 FontShader;
	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, 150, device);
	if(!result)
	{
		return false;
	}

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

	// Initialize the third sentence.
	result = InitializeSentence(&m_sentence3, 16, device);
	if(!result)
	{
		return false;
	}

	// Initialize the fourth sentence.
	result = InitializeSentence(&m_sentence4, 16, device);
	if(!result)
	{
		return false;
	}

	// Initialize the fifth sentence.
	result = InitializeSentence(&m_sentence5, 16, device);
	if(!result)
	{
		return false;
	}

	// Initialize the sixth sentence.
	result = InitializeSentence(&m_sentence6, 16, device);
	if(!result)
	{
		return false;
	}

	// Initialize the seventh sentence.
	result = InitializeSentence(&m_sentence7, 16, device);
	if(!result)
	{
		return false;
	}

	// Initialize the eighth sentence.
	result = InitializeSentence(&m_sentence8, 16, device);
	if(!result)
	{
		return false;
	}

	// Initialize the ninth sentence.
	result = InitializeSentence(&m_sentence9, 16, device);
	if(!result)
	{
		return false;
	}

	// Initialize the tenth sentence.
	result = InitializeSentence(&m_sentence10, 16, device);
	if(!result)
	{
		return false;
	}

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

	return true;
}