Advertisement
Guest User

Untitled

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