示例#1
0
/* %%Function:ResetMathPack %%Owner:bryanl */
ResetMathPack()
{
	extern BOOL	fError;

	Assert(fInitialized);
	fInRegister = fError = fFalse;
	inumTop = 0;
	DError(0);
}
示例#2
0
/* %%Function:InitMath %%Owner:bryanl */
InitMath()
{
	Assert(!fInitialized);
	fInitialized = fTrue;
	InitMathPack();
	/* Do NOT call ResetMathPack as it could screw up the stack! */
	DError(0);
	InitRnd();
}
示例#3
0
Script*		ScriptFactory::Create(const std::string& key) const
{
	Script* tmp = nullptr;

	std::map<std::string, Script*>::const_iterator it=m_map.find(key);
	if(it!=m_map.end())
		tmp=((*it).second)->Clone();
	else
		throw DError() << msg("ScriptFactory failed : requested class " + key + " is not registered or compiled.");
	return tmp;
}
示例#4
0
//=================================================================================================
void DAllocTracer::registerFree(void* pMemory, DBOOL array)
{
	if(!m_Available)
		return;
	m_Available = FALSE;
	
	std::map<void*, DS_Allocation>::iterator it = m_AllocMap.find(pMemory);
	if(it != m_AllocMap.end())
	{
		if(array != it->second.array)
		{
			if(array)
				DError("\"delete[]\" should be \"delete\" in file \"%s\" at line %i.", m_FreeInfoStack.top().pFile, m_FreeInfoStack.top().line);
			else
				DError("\"delete\" should be \"delete[]\" in file \"%s\" at line %i.", m_FreeInfoStack.top().pFile, m_FreeInfoStack.top().line);
		}
		
		m_AllocMap.erase(it);
		m_FreeInfoStack.pop();
	}
	
	m_Available = TRUE;
}
示例#5
0
//=================================================================================================
void DIndexBuffer::fill(u32 aIndices[], u32 count)
{
	DDebugAssert(!m_pIndexBuffer);

	// Création de l'index buffer
	D3D10_BUFFER_DESC indexBufferDesc;
	indexBufferDesc.Usage = D3D10_USAGE_DEFAULT;
	indexBufferDesc.ByteWidth = count * sizeof(u32);
	indexBufferDesc.BindFlags = D3D10_BIND_INDEX_BUFFER;
	indexBufferDesc.CPUAccessFlags = 0;
	indexBufferDesc.MiscFlags = 0;

	D3D10_SUBRESOURCE_DATA initData;
	initData.pSysMem = aIndices;

	if(FAILED(DRenderManager::getInstance()->m_pD3DDevice->CreateBuffer(&indexBufferDesc, &initData, &m_pIndexBuffer)))
		DError("Index buffer creation failed.");
	
	// Initialisation
	m_NbIndices = count;
}
示例#6
0
文件: Text.cpp 项目: kasspip/DOGLE
void			Text::LoadFont(GLfloat width, GLfloat height)
{
	shader = new Shader( (pathToShaders + "Text.vert").c_str(),
				  		 (pathToShaders + "Text.frag").c_str());
	shader->Use();
    glm::mat4 projection = glm::ortho(0.0f, width, 0.0f, height);
    glUniformMatrix4fv(glGetUniformLocation(shader->Program, "projection"), 1, GL_FALSE, glm::value_ptr(projection));

	if(FT_Init_FreeType(&freetype))
		throw DError() << msg("Could not init freetype library");
	if(FT_New_Face(freetype, (pathToFont + font).c_str(), 0, &face))
		throw DError() << msg("Could not open font: " + font);
	
	FT_Set_Pixel_Sizes(face, 0, size);
    glPixelStorei(GL_UNPACK_ALIGNMENT, 1); 

	for (GLubyte c = 0; c < 128; c++)
    {
        // Load character glyph 
        if (FT_Load_Char(face, c, FT_LOAD_RENDER))
        {
            std::cout << "ERROR::FREETYTPE: Failed to load Glyph" << std::endl;
            continue;
        }
        // Generate texture
        GLuint texture;
        glGenTextures(1, &texture);
        glBindTexture(GL_TEXTURE_2D, texture);
        glTexImage2D(
            GL_TEXTURE_2D,
            0,
            GL_RED,
            face->glyph->bitmap.width,
            face->glyph->bitmap.rows,
            0,
            GL_RED,
            GL_UNSIGNED_BYTE,
            face->glyph->bitmap.buffer
        );
        // Set texture options
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
        // Now store character for later use
        Character character = {
            texture,
            glm::ivec2(face->glyph->bitmap.width, face->glyph->bitmap.rows),
            glm::ivec2(face->glyph->bitmap_left, face->glyph->bitmap_top),
            (GLuint)face->glyph->advance.x
        };
        Characters.insert(std::pair<GLchar, Character>(c, character));
    }
    glBindTexture(GL_TEXTURE_2D, 0);
    // Destroy FreeType once we're finished
    FT_Done_Face(face);
    FT_Done_FreeType(freetype);

    
    // Configure VAO/VBO for texture quads
    glGenVertexArrays(1, &VAO);
    glGenBuffers(1, &VBO);
    glBindVertexArray(VAO);
    glBindBuffer(GL_ARRAY_BUFFER, VBO);
    glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * 6 * 4, NULL, GL_DYNAMIC_DRAW);
    glEnableVertexAttribArray(0);
    glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 4 * sizeof(GLfloat), 0);
    glBindBuffer(GL_ARRAY_BUFFER, 0);
    glBindVertexArray(0);
}