Question: Question # 1 ( 2 5 points ) : Cube Texture Here are the requirements for the program: Find a suitable cube texture file set
Question # points: Cube Texture
Here are the requirements for the program:
Find a suitable cube texture file set and copy it to the media folder. Add code to load the cube texture. Use whatever texture unit you wish, but be sure to use it with the artifacts you will create.
The first artifact should be a skybox.
Use a block shape.
Suitably scale and position the artifact.
Set the texture unit appropriately.
Set the surface effect to use the skybox case in the fragment shader.
The second artifact should be a reflection box.
Use a block shape.
Scale the artifact by and
Center the artifact at
Set the texture unit appropriately.
Configure rotation animation
The rotation axis should be
The rotation center should be the center of the artifact.
The rotation rate should be rpm rotations per minute
Set the surface effect to use the reflection case in the fragment shader.
Code:
#include
#include
#include
#include "learnopenglshaderh
#include csviewh
#include csartifacth
#include cstextureutilities.h
#include cswindowh
#include csbufferutilities.h
#include callbacksh
static cs::View theview;
static Shader shader;
static std::vector artifactlist;
void init
theview new cs::View;
theviewenableLogging false;
theviewsetFLUPglm::vec
glm::vec
glm::vec
glm::vec;
shader new Shadervertexshaderglsl"fragmentshaderglsl;
shaderuse;
glEnableGLDEPTHTEST;
load in a cube texture hee
two artifacts go here
cs::initBuffersshaderID artifactlist, bposition",
btexturecoord", bnormal";
void render
auto viewtransform glm::lookAttheviewcameraPosition,
theviewcameraPosition theviewcameraForward,
theviewcameraUp;
auto projectiontransform glm::infinitePerspectivetheviewperspectiveFOVY,
theviewperspectiveAspect, theviewperspectiveNear;
auto vptransform projectiontransform viewtransform;
shadersetMatuvptransform", vptransform;
shadersetVecucameraposition", theviewcameraPosition;
static auto lasttime ;
auto time glfwGetTime;
auto deltatime time lasttime;
lasttime time;
for auto artf : artifactlist
artfworldTransformationanimationStep;
glm::mat modeltransform artfworldTransformationgetMatrix;
glm::mat ntransform glm::inverseTransposemodeltransform;
shadersetMatumtransform", modeltransform;
shadersetMatuntransform", ntransform;
shadersetIntusampler artftextureUnit;
shadersetIntusamplerC", artftextureUnit;
shadersetIntusurfaceeffect", artfsurfaceEffect;
glDrawArraysGLTRIANGLES, artftheShapebufferStart, artftheShapebufferSize;
int
mainint argc, char argv
glfwInit;
cs::setOpenglVersion;
GLFWwindow window cs::setupWindowReflecting Object", ;
gladLoadGLglfwGetProcAddress;
init;
theviewperspectiveAspect cs::getAspectRatiowindow;
glfwSetWindowUserPointerwindow theview;
printfview logging d
theviewenableLogging;
glfwSetKeyCallbackwindow generalkeycallback;
glfwSetCursorPosCallbackwindow movecallback;
glfwSetWindowSizeCallbackwindow windowsizecallback;
while glfwWindowShouldClosewindow
glClearBufferfvGLCOLOR, cs::X::grayasFloatArray;
glClearGLDEPTHBUFFERBIT;
render;
glfwSwapBufferswindow;
glfwPollEvents;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
