Question: i need help. i need two right triangles that can look like the one in the picture with the colors ty in advance #include /

i need help. i need two right triangles that can look like the one in the picture with the colors ty in advance
#include // cout, cerr
#include // EXIT_FAILURE
#include // GLEW library
#include // GLFW library
using namespace std; // Uses the standard namespace
// Unnamed namespace
namespace
{
const char* const WINDOW_TITLE = "Tutorial 2.7"; // Macro for window title
// Variables for window width and height
const int WINDOW_WIDTH =800;
const int WINDOW_HEIGHT =600;
// Stores the GL data relative to a given mesh
struct GLMesh
{
GLuint vao; // Handle for the vertex array object
GLuint vbo; // Handle for the vertex buffer object
GLuint nvertices; // Number of vertices of the mesh
};
// Main GLFW window
GLFWwindow* gWindow = nullptr;
// Triangle mesh data
GLMesh gMesh;
// Shader program
GLuint gProgramId;
}
/* User-defined Function prototypes to:
* initialize the program, set the window size,
* redraw graphics on the window when resized,
* and render graphics on the screen
*/
bool UInitialize(int, char*[], GLFWwindow** window);
void UResizeWindow(GLFWwindow* window, int width, int height);
void UProcessInput(GLFWwindow* window);
void UCreateMesh(GLMesh& mesh);
void UDestroyMesh(GLMesh& mesh);
void URender();
bool UCreateShaderProgram(const char* vtxShaderSource, const char* fragShaderSource, GLuint& programId);
void UDestroyShaderProgram(GLuint programId);
// Vertex Shader Program Source Code
const char* vertexShaderSource ="#version 440 core
"
"layout (location =0) in vec3 aPos;
"
"layout (location =1) in vec4 colorFromVBO;
"
"out vec4 colorFromVS;
"
"void main()
"
"{
"
" gl_Position = vec4(aPos.x, aPos.y, aPos.z,1.0);
"
" colorFromVS = colorFromVBO;
"
"}
\0";
// Fragment Shader Program Source Code
const char* fragmentShaderSource ="#version 440 core
"
"in vec4 colorFromVS;
"
"out vec4 FragColor;
"
"void main()
"
"{
"
" FragColor = colorFromVS;
"
"}
\0";
// main function. Entry point to the OpenGL program
int main(int argc, char* argv[])
{
if (!UInitialize(argc, argv, &gWindow))
return EXIT_FAILURE;
// Create the mesh
UCreateMesh(gMesh); // Calls the function to create the Vertex Buffer Object
// Create the shader program
if (!UCreateShaderProgram(vertexShaderSource, fragmentShaderSource, gProgramId))
return EXIT_FAILURE;
// Sets the background color of the window to black (it will be implicitely used by glClear)
glClearColor(0.0f,0.0f,0.0f,1.0f);
// render loop
//-----------
while (!glfwWindowShouldClose(gWindow))
{
// input
//-----
UProcessInput(gWindow);
// Render this frame
URender();
glfwPollEvents();
}
// Release mesh data
UDestroyMesh(gMesh);
// Release shader program
UDestroyShaderProgram(gProgramId);
exit(EXIT_SUCCESS); // Terminates the program successfully
}
// Initialize GLFW, GLEW, and create a window
bool UInitialize(int argc, char* argv[], GLFWwindow** window)
{
// GLFW: initialize and configure
//------------------------------
glfwInit();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 4);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
#ifdef __APPLE__
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
#endif
// GLFW: window creation
//---------------------
* window = glfwCreateWindow(WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_TITLE, NULL, NULL);
if (*window == NULL)
{
std::cout "Failed to create GLFW window" std::endl;
glfwTerminate();
return false;
}
glfwMakeContextCurrent(*window);
glfwSetFramebufferSizeCallback(*window, UResizeWindow);
// GLEW: initialize
//----------------
// Note: if using GLEW version 1.13 or earlier
glewExperimental = GL_TRUE;
GLenum GlewInitResult = glewInit();
if (GLEW_OK != GlewInitResult)
{
std::cerr glewGetErrorString(GlewInitResult) std::endl;
return false;
}
// Displays GPU OpenGL version
cout "INFO: OpenGL Version: " glGetString(GL_VERSION) endl;
return true;
}
// process all input: query GLFW whether relevant keys are pressed/released this frame and react accordingly
void UProcessInput(GLFWwindow* window)
{
if (glfwGetKey(window, GLFW_KEY_ESCAPE)== GLFW_PRESS)
glfwSetWindowShouldClose(window, true);
}
// glfw: whenever the window size changed (by OS or user resize) this callback function executes
void UResizeWindow(GLFWwindow* window, int width, int height)
{
glViewport(0,0, width, height);
}
// Functioned called to render a frame
void URender()
{
// Clear the background
glClearColor(0.0f,0.0f
 i need help. i need two right triangles that can look

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!