mirror of
https://github.com/JoeyDeVries/LearnOpenGL.git
synced 2026-01-30 20:13:22 +08:00
Merge pull request #173 from rbarkmore/fix_text_rend
Fix 'use' and 'ID' in two places each, delete second main()
This commit is contained in:
@@ -76,8 +76,8 @@ int main()
|
|||||||
// ----------------------------
|
// ----------------------------
|
||||||
Shader shader("text.vs", "text.fs");
|
Shader shader("text.vs", "text.fs");
|
||||||
glm::mat4 projection = glm::ortho(0.0f, static_cast<float>(SCR_WIDTH), 0.0f, static_cast<float>(SCR_HEIGHT));
|
glm::mat4 projection = glm::ortho(0.0f, static_cast<float>(SCR_WIDTH), 0.0f, static_cast<float>(SCR_HEIGHT));
|
||||||
shader.Use();
|
shader.use();
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shader.Program, "projection"), 1, GL_FALSE, glm::value_ptr(projection));
|
glUniformMatrix4fv(glGetUniformLocation(shader.ID, "projection"), 1, GL_FALSE, glm::value_ptr(projection));
|
||||||
|
|
||||||
// FreeType
|
// FreeType
|
||||||
// --------
|
// --------
|
||||||
@@ -179,34 +179,6 @@ int main()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The MAIN function, from here we start our application and run the Game loop
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
// Init GLFW
|
|
||||||
glfwInit();
|
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
|
|
||||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
|
||||||
glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);
|
|
||||||
|
|
||||||
GLFWwindow* window = glfwCreateWindow(WIDTH, HEIGHT, "LearnOpenGL", nullptr, nullptr); // Windowed
|
|
||||||
glfwMakeContextCurrent(window);
|
|
||||||
|
|
||||||
// Initialize GLEW to setup the OpenGL Function pointers
|
|
||||||
glewExperimental = GL_TRUE;
|
|
||||||
glewInit();
|
|
||||||
|
|
||||||
// Define the viewport dimensions
|
|
||||||
glViewport(0, 0, WIDTH, HEIGHT);
|
|
||||||
|
|
||||||
// Set OpenGL options
|
|
||||||
glEnable(GL_CULL_FACE);
|
|
||||||
glEnable(GL_BLEND);
|
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// process all input: query GLFW whether relevant keys are pressed/released this frame and react accordingly
|
// process all input: query GLFW whether relevant keys are pressed/released this frame and react accordingly
|
||||||
// ---------------------------------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------------------------------
|
||||||
void processInput(GLFWwindow *window)
|
void processInput(GLFWwindow *window)
|
||||||
@@ -230,8 +202,8 @@ void framebuffer_size_callback(GLFWwindow* window, int width, int height)
|
|||||||
void RenderText(Shader &shader, std::string text, float x, float y, float scale, glm::vec3 color)
|
void RenderText(Shader &shader, std::string text, float x, float y, float scale, glm::vec3 color)
|
||||||
{
|
{
|
||||||
// activate corresponding render state
|
// activate corresponding render state
|
||||||
shader.Use();
|
shader.use();
|
||||||
glUniform3f(glGetUniformLocation(shader.Program, "textColor"), color.x, color.y, color.z);
|
glUniform3f(glGetUniformLocation(shader.ID, "textColor"), color.x, color.y, color.z);
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
glBindVertexArray(VAO);
|
glBindVertexArray(VAO);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user