Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

in c++ what will this show? void Graphics3DCubeInstance::DidChangeView(const pp:

ID: 3832646 • Letter: I

Question

in c++ what will this show?

void Graphics3DCubeInstance::DidChangeView(const pp::View& view) { device_scale_ = view.GetDeviceScale(); int32_t new_width = view.GetRect().width() * device_scale_; int32_t new_height = view.GetRect().height() * device_scale_; if (context_.is_null()) { if (!InitGL(new_width, new_height)) { Logger::Error("Couldn't initialize GLES library!"); return; } InitShaders(); InitBuffers(); InitTexture(); MainLoopIteration(0); } else { int32_t result = context_.ResizeBuffers(new_width, new_height); if (result < 0) { Logger::Error("Unable to resize buffers to %d x %d!", new_width, new_height); return; } } width_ = new_width; height_ = new_height; glViewport(0, 0, width_, height_); Logger::Log("Initialized module's view with resolution %dx%d", width_, height_); }

Explanation / Answer

The code snippet seems to be that of a Graphics3D application in C++ using GLES library.
Following is the explanation of the given snippet.

int32_t new_width = view.GetRect().width() * device_scale_;
int32_t new_height = view.GetRect().height() * device_scale_;
The above to lines are finiding the new width and height as per the resolution of the device.

if (context_.is_null()) {
if (!InitGL(new_width, new_height)) {
Logger::Error("Couldn't initialize GLES library!");
return;
}
InitShaders();
InitBuffers();
InitTexture();
MainLoopIteration(0);
}
The initialization of the graphics context is done inside the InitGL()function. The InitGL() function creates a Graphics3D context for rendering.
Once the context is ready the GPU program is compiled and linked inside the InitShaders() function and InitBuffers() is called, which creates necessary vertex buffer objects. InitTexture() method loads the texture into the GPU.
InitShaders() - OpenGL Shader Initialization
InitBuffers() - Buffer Initialisation
InitTexture() - Texture Initialisation
MainLoopIteration(0) - Main Rendering Loop

Logger::Error - Loggs a message to the log file as a error message
Logger::Log - Logs a message to the log file.

glViewport(0, 0, width_, height_) - Initialized module's view with resolution of width and height.