本文整理汇总了C++中ProgramObject::setMatrix4fv方法的典型用法代码示例。如果您正苦于以下问题:C++ ProgramObject::setMatrix4fv方法的具体用法?C++ ProgramObject::setMatrix4fv怎么用?C++ ProgramObject::setMatrix4fv使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProgramObject
的用法示例。
在下文中一共展示了ProgramObject::setMatrix4fv方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int /*argc*/, char ** /*argv*/) {
BaseApp app;
ProgramObject program;
auto mainWindow = app.getMainWindow();
std::string prefix = app.getResourceDir() + "Shaders/Examples/e06_ModelLoader/";
PerspectiveCamera cam;
OrbitManipulator manipulator(&cam);
manipulator.setupCallbacks(app);
NodeShared root;
GLuint query[2];
app.addInitCallback([&]() {
auto vs = compileShader(GL_VERTEX_SHADER, Loader::text(prefix + "phong.vert"));
auto fs = compileShader(GL_FRAGMENT_SHADER, Loader::text(prefix + "phong.frag"));
program = createProgram(vs, fs);
root = Loader::scene(app.getResourceDir() + "Models/sponza/sponza.fbx");
glCreateQueries(GL_TIMESTAMP, 2, query);
SDL_GL_SetSwapInterval(0);
});
app.addResizeCallback([&](int w, int h) {
glViewport(0, 0, w, h);
cam.setAspect(float(w) / float(h));
});
app.addDrawCallback([&]() {
glQueryCounter(query[0], GL_TIMESTAMP);
glClearColor(0.2, 0.2, 0.2, 1);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);
//bunny
program.use();
program.setMatrix4fv("p", value_ptr(cam.getProjection()));
program.setMatrix4fv("v", value_ptr(cam.getView()));
drawNode(program, root);
glQueryCounter(query[1], GL_TIMESTAMP);
GLuint64 time1, time2;
glGetQueryObjectui64v(query[0], GL_QUERY_RESULT, &time1);
glGetQueryObjectui64v(query[1], GL_QUERY_RESULT, &time2);
std::string s = "fps: " + std::to_string(1e9 / (time2 - time1)) + " (" + std::to_string(ImGui::GetIO().Framerate) + ")";
label(s, 0, 0, 300, 100);
});
return app.run();
}