Advertisement
Guest User

Untitled

a guest
Jan 21st, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.18 KB | None | 0 0
  1. // oglApplication.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "3rd\glew\include\GL\glew.h"
  6. #include "3rd\glm\glm.hpp"
  7. #include "3rd\GLFW\include\glfw3.h"
  8. #include "Game.h"
  9. #include "Content.h"
  10. #include "Effect.h"
  11. #include "Keyboard.h"
  12.  
  13.  
  14. int _tmain(int argc, _TCHAR* argv[]) {
  15.  
  16. // inicjlizacja GLFW
  17. if (!glfwInit()) {
  18. return -1;
  19. }
  20. glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);
  21. glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
  22. glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
  23. glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
  24. glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_FALSE);
  25. glfwWindowHint(GLFW_SAMPLES, 2);
  26. GLFWwindow* window;
  27. window = glfwCreateWindow( 800, 600, "GlGame4", NULL, NULL);
  28. if ( !window ) {
  29. glfwTerminate();
  30. return -1;
  31. }
  32. glfwMakeContextCurrent(window);
  33.  
  34. GLenum err = glGetError();
  35. if( err ) {
  36. fprintf( stderr, "ERROR: %s\n", glewGetErrorString( err ) );
  37. exit(EXIT_FAILURE);
  38. }
  39.  
  40. // inicjalizacja GLEW
  41. glewExperimental = GL_TRUE;
  42. GLenum GlewInitResult;
  43. GlewInitResult = glewInit();
  44. if (GLEW_OK != GlewInitResult) {
  45. fprintf( stderr, "ERROR: %s\n", glewGetErrorString(GlewInitResult));
  46. exit(EXIT_FAILURE);
  47. }
  48.  
  49. // glowna petla gry
  50. Game game;
  51. game.Init();
  52. Keyboard::KeyboardInit();
  53. glEnable(GL_DEPTH_TEST);
  54. while (!glfwWindowShouldClose(window))
  55. {
  56. // rendering
  57. game.Update();
  58. game.Redraw();
  59.  
  60. glfwSwapBuffers(window);
  61.  
  62. glfwPollEvents();
  63.  
  64. //mysz - obrot kamery dookola
  65.  
  66. int state_left = glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_LEFT);
  67. if (state_left == GLFW_PRESS)
  68. {
  69. Game::lewy = 1;
  70. }
  71. if (state_left == GLFW_RELEASE)
  72. {
  73. Game::lewy = 0;
  74. }
  75.  
  76. int state_right = glfwGetMouseButton(window, GLFW_MOUSE_BUTTON_RIGHT);
  77. if (state_right == GLFW_PRESS)
  78. {
  79. Game::prawy = 1;
  80. }
  81. if (state_right == GLFW_RELEASE)
  82. {
  83. Game::prawy = 0;
  84. }
  85.  
  86. //mysz - blokowanie
  87.  
  88. //glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
  89.  
  90. //mysz - chowanie kursora
  91. glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
  92. }
  93.  
  94. glfwTerminate();
  95.  
  96. return 0;
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement