void OGLText::PrintString(const Camera &camera, const Vector3f &position, float scale, const char* string) const { //apply texture _pTexture->ApplyTexture(0); //initalize matrices _positionTransform[12] = position.getX(); _positionTransform[13] = position.getY(); _positionTransform[14] = position.getZ(); _positionTransform[0] = scale; _positionTransform[5] = scale; _positionTransform[10] = scale; //initalize shader variables int shaderID = ShaderManager::GetManager()->GetActiveShaderID(); int texMatLoc = ShaderManager::GetManager()->GetVariableLocation(shaderID, "textureMat"); camera.ApplyCameraMatricesToActiveShader(_positionTransform); //bind array and index buffers glEnableVertexAttribArray(0); glEnableVertexAttribArray(4); glBindBuffer(GL_ARRAY_BUFFER, _vertexBufferID); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _indicesBufferID); glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, BUFFER_OFFSET(0)); glVertexAttribPointer(4, 2, GL_FLOAT, GL_FALSE, 0, BUFFER_OFFSET(48)); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); for (int i = 0; i < strlen(string); i++) { char character = string[i] - 32; float texX = (static_cast<float>(character % 16)) / 16.f; float texY = (static_cast<float>(character / 16)) / 16.f + 0.0625f; _textureTransform[6] = texX; _textureTransform[7] = texY; _positionTransform[12] += scale*2; camera.ApplyCameraMatricesToActiveShader(_positionTransform); ShaderManager::GetManager()->SetVariable(texMatLoc, _textureTransform); glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, BUFFER_OFFSET(0)); } glDisable(GL_BLEND); glDisableVertexAttribArray(0); glDisableVertexAttribArray(4); }