本文整理汇总了C++中Keyboard::HandleEvent方法的典型用法代码示例。如果您正苦于以下问题:C++ Keyboard::HandleEvent方法的具体用法?C++ Keyboard::HandleEvent怎么用?C++ Keyboard::HandleEvent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Keyboard
的用法示例。
在下文中一共展示了Keyboard::HandleEvent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char ** argv[])
{
Display display(800, 600, "TSBK07 Level of Detail on Terrain");
Basic_Shader base_shader("./shaders/space");
Phong_Shader phong("./shaders/phong");
Texture texture("./textures/dirt.tga");
Camera camera(glm::vec3(0, 1, 0), 70.0f, display.GetAspectRation(), 0.01f, 1000.0f);
Terrain terr("./textures/terrain2.jpg", "./textures/terrain2.jpg");
Skybox sky;
sky.SkyboxInit("./textures/skybox/", "back.jpg", "front.jpg", "left.jpg", "right.jpg", "top.jpg", "bottom.jpg");
Transform transform;
Keyboard keyboard;
Mouse mouse;
float counter = 0.0f;
Mesh monkey("./models/monkey3.obj");
Mesh box("./models/box.obj");
std::cout << "init complete" << std::endl;
bool wireframe = true;
bool lock = false;
while (!display.IsClosed())
{
display.Clear(1, 0, 1, 1);
SDL_Event e;
while (SDL_PollEvent(&e))
{
if (e.type == SDL_QUIT)
{
display.HandleEvent(e);
}
if (e.type == SDL_MOUSEMOTION || e.type == SDL_MOUSEBUTTONDOWN || e.type == SDL_MOUSEBUTTONUP)
{
mouse.HandleEvent(e, camera);
}
}
const Uint8* currentKeyStates = SDL_GetKeyboardState(NULL);
keyboard.HandleEvent(currentKeyStates, camera);
sky.Draw(transform, camera);
if (currentKeyStates[SDL_SCANCODE_B])
{
lock = !lock;
}
if (currentKeyStates[SDL_SCANCODE_F])
{
wireframe = !wireframe;
}
terr.Draw(transform, camera, lock, wireframe);
display.Update();
counter += 0.001f;
}
return 0;
}