本文整理汇总了C++中TextureLoader::loadBMP_custom方法的典型用法代码示例。如果您正苦于以下问题:C++ TextureLoader::loadBMP_custom方法的具体用法?C++ TextureLoader::loadBMP_custom怎么用?C++ TextureLoader::loadBMP_custom使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextureLoader
的用法示例。
在下文中一共展示了TextureLoader::loadBMP_custom方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: start
//The main function
int Main::start() {
//Init
if (init() == -1) {
fprintf(stderr, "Could not initialise the program\n");
return -1;
}
//Create the scene
Scene scene = Scene(window);
Camera* camera = scene.getCamera();
camera->setFOV(45);
//Create the loaders
ModelLoader loader = ModelLoader();
TextureLoader textureLoader = TextureLoader();
//Create the models
Model texturedModel = loader.loadToVao_OBJ_Textured("models/cube.obj", "textures/cube.bmp", glm::vec3(-3, 0, -5));
Model monkey = loader.loadToVao_OBJ("models/suzanne.obj", glm::vec3(0, 0, -5));
monkey.texture(textureLoader.loadBMP_custom("textures/suzanne texture.bmp"));
monkey.setReflectivity(0.0);
//Create an array of the same entities and add them to the scene
std::vector<Entity> cubes;
std::vector<glm::vec3> positions;
int numOfCubes = 1000;
Cube cubeTemp = Cube();
//Create the positions array
for (int i = 0; i < numOfCubes; i++) {
positions.insert(positions.end(), glm::vec3(rand() % 100, rand() % 100, rand() % 100));
}
//Generate cloned cubes and put them at different positions
cubes = cubeTemp.cloneEntity(positions);
//Add the cubes to the entity map
for (int i = 0; i < cubes.size(); i++) {
scene.addEntity(&cubes[i]);
}
//Add the models to the scene
scene.addModel(texturedModel);
scene.addModel(monkey);
//Create the onclick function
auto onClick = []() {
exit(0);
};
//Create the UIs
UIButton button = UIButton(0.06f, 0.05f, glm::vec2(1, -1), window, onClick);
button.setAlignment(UIButton::ALIGN_BOTTOM_RIGHT);
button.texture(textureLoader.loadBMP_custom("textures/Exit.bmp"));
UIElement* ui = &button;
//Add the UI
scene.addPauseUI(ui);
//Main loop
while (!window.shouldClose()) {
//Run the scene
scene.run();
//Run the UI
//Swap the buffers and poll events
glfwSwapBuffers(window.getWindow());
glfwPollEvents();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
//Terminate glfw
glfwTerminate();
return 0;
}