Answered step by step
Verified Expert Solution
Question
1 Approved Answer
With the below code I need help addig a complex 3 D object using at least two basic 3 D shapes. / / Main GLFW
With the below code I need help addig a complex D object using at least two basic D shapes.
Main GLFW window
GLFWwindow gWindow nullptr;
scene manager object for managing the D scene prepare and render
SceneManager gSceneManager nullptr;
shader manager object for dynamic interaction with the shader code
ShaderManager gShaderManager nullptr;
view manager object for managing the D view setup and projection to D
ViewManager gViewManager nullptr;
Function declarations all functions that are called manually
need to be predeclared at the beginning of the source code.
bool InitializeGLFW;
bool InitializeGLEW;
mainint char
This function gets called after the application has been
launched.
int mainint argc, char argv
if GLFW fails initialization, then terminate the application
if InitializeGLFW false
returnEXITFAILURE;
try to create a new shader manager object
gShaderManager new ShaderManager;
try to create a new view manager object
gViewManager new ViewManager
gShaderManager;
try to create the main display window
gWindow gViewManagerCreateDisplayWindowWINDOWTITLE;
if GLEW fails initialization, then terminate the application
if InitializeGLEW false
returnEXITFAILURE;
load the shader code from the external GLSL files
gShaderManagerLoadShaders
"shadersvertexShaderglsl
"shadersfragmentShaderglsl;
gShaderManageruse;
try to create a new scene manager object and prepare the D scene
gSceneManager new SceneManagergShaderManager;
gSceneManagerPrepareScene;
declare the variables for the transformations
glm::vec scaleXYZ;
float XrotationDegrees f;
float YrotationDegrees f;
float ZrotationDegrees f;
glm::vec positionXYZ;
loop will keep running until the application is closed
or until an error has occurred
while glfwWindowShouldClosegWindow
Enable zdepth
glEnableGLDEPTHTEST;
Clear the frame and z buffers
glClearColorffff;
glClearGLCOLORBUFFERBIT GLDEPTHBUFFERBIT;
convert from D object space to D view
gViewManagerPrepareSceneView;
refresh the D scene
gSceneManagerRenderScene;
Flips the the back buffer with the front buffer every frame.
glfwSwapBuffersgWindow;
query the latest GLFW events
glfwPollEvents;
clear the allocated manager objects from memory
if NULL gSceneManager
delete gSceneManager;
gSceneManager NULL;
if NULL gViewManager
delete gViewManager;
gViewManager NULL;
if NULL gShaderManager
delete gShaderManager;
gShaderManager NULL;
Terminates the program successfully
exitEXITSUCCESS;
InitializeGLFW
This function is used to initialize the GLFW library.
bool InitializeGLFW
GLFW: initialize and configure library
glfwInit;
#ifdef APPLE
set the version of OpenGL and profile to use
glfwWindowHintGLFWCONTEXTVERSIONMAJOR, ;
glfwWindowHintGLFWCONTEXTVERSIONMINOR, ;
glfwWindowHintGLFWOPENGLFORWARDCOMPAT, GLTRUE;
#else
set the version of OpenGL and profile to use
glfwWindowHintGLFWCONTEXTVERSIONMAJOR, ;
glfwWindowHintGLFWCONTEXTVERSIONMINOR, ;
glfwWindowHintGLFWOPENGLPROFILE, GLFWOPENGLCOREPROFILE;
#endif
GLFW: end
returntrue;
InitializeGLEW
This function is used to initialize the GLEW library.
bool InitializeGLEW
GLEW: initialize
GLenum GLEWInitResult GLEWOK;
try to initialize the GLEW library
GLEWInitResult glewInit;
if GLEWOK GLEWInitResult
std::cerr glewGetErrorStringGLEWInitResult std::endl;
return false;
GLEW: end
Displays a successful OpenGL initialization message
std::cout "INFO: OpenGL Successfully Initialized
;
std::cout "INFO: OpenGL Version: glGetStringGLVERSION
std::endl;
returntrue;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started