Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Recreate this photograph in a basic 2D OpenGL scene to include the bed, fridge, window and walls/floors. While this OpenGL scene does not have to

image text in transcribed

Recreate this photograph in a basic 2D OpenGL scene to include the bed, fridge, window and walls/floors. While this OpenGL scene does not have to be perfect in any way, it still needs to be recognizable. Please post source code, any shaders used and command for running the program! I will be sure to like quick if response is good! Here is what I have so far, feel free to use it at a starting point. Thanks!

#include #include

int main(void) { GLFWwindow* window;

if (!glfwInit()) return -1;

window = glfwCreateWindow(640, 480, "OpenGL Test", NULL, NULL); if (!window) { glfwTerminate(); return -1; }

glfwMakeContextCurrent(window);

while (!glfwWindowShouldClose(window)) { int width, height; glfwGetFramebufferSize(window, &width, &height); glViewport(0, 0, width, height);

// Clear the screen to white glClearColor(1.0, 1.0, 1.0, 1.0); glClear(GL_COLOR_BUFFER_BIT);

// Draw the bed glBegin(GL_QUADS); glColor3f(0.8, 0.8, 0.8); glVertex2f(-0.7, -0.7); glVertex2f(0.7, -0.7); glVertex2f(0.7, -0.5); glVertex2f(-0.7, -0.5); glEnd();

// Draw the floor glBegin(GL_QUADS); glColor3f(0.9, 0.9, 0.9); glVertex2f(-1.0, -1.0); glVertex2f(1.0, -1.0); glVertex2f(1.0, -0.7); glVertex2f(-1.0, -0.7); glEnd();

// Draw the window glBegin(GL_QUADS); glColor3f(0.7, 0.7, 1.0); glVertex2f(0.6, 0.6); glVertex2f(0.8, 0.6); glVertex2f(0.8, 0.8); glVertex2f(0.6, 0.8); glEnd();

// Draw the fridge glBegin(GL_QUADS); glColor3f(0.5, 0.5, 0.5); glVertex2f(-0.9, -0.7); glVertex2f(-0.7, -0.7); glVertex2f(-0.7, 0.7); glVertex2f(-0.9, 0.7); glEnd();

glfwSwapBuffers(window);

glfwPollEvents(); }

glfwTerminate(); return 0; }

COMMAND FOR RUNNING THIS:

g++ -o test test.cpp -lglfw -lGL -lX11

./test

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Secrets Of Analytical Leaders Insights From Information Insiders

Authors: Wayne Eckerson

1st Edition

1935504347, 9781935504344

More Books

Students also viewed these Databases questions

Question

4 What are the main practices associated with SHRM?

Answered: 1 week ago