Advertisement
Guest User

Untitled

a guest
Apr 18th, 2014
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.72 KB | None | 0 0
  1. #define GLEW_STATIC
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <GL/glew.h>
  5. #include <GLFW/glfw3.h>
  6. #include "SimpleParticleEngine.hpp"
  7. #include "Particle.hpp"
  8. #include "Util.hpp"
  9.  
  10.  
  11. #define PARTICLE_AMT 500
  12.  
  13. int main() {
  14. trillek::util::Util::Seed();
  15. trillek::particle::SimpleParticleEngine engine;
  16. engine.Init(PARTICLE_AMT, 0, 0, -500);
  17.  
  18. engine.lifeMin = 5;
  19. engine.lifeMax = 10;
  20.  
  21. GLFWwindow* window;
  22.  
  23. /* Initialize the library */
  24. // Ensure we can capture the escape key being pressed below
  25. glfwSetInputMode( window, GLFW_STICKY_KEYS, GL_TRUE);
  26.  
  27. if (!glfwInit()) {
  28. fprintf(stderr, "Failed to initialize GLFW/n");
  29. return -1;
  30. }
  31.  
  32. GLuint VertexArrayID;
  33. glGenVertexArrays(1, &VertexArrayID);
  34. glBindVertexArray(VertexArrayID);
  35. glewExperimental = true;
  36. if (glewInit() != GLEW_OK) {
  37. fprintf(stderr, "Failed to initialize GLEW\n");
  38. return -1;
  39. }
  40. glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); // We want OpenGL 3.3
  41. glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
  42. glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
  43.  
  44. // Open a window and create its OpenGL context
  45. window = glfwCreateWindow(1024, 768, "Grant Particle test", NULL, NULL);
  46. if (window == NULL){
  47. fprintf(stderr, "Failed to open GLFW window. If you have an Intel GPU, they are not 3.3 compatible.");
  48. glfwTerminate();
  49. return -1;
  50. }
  51. glfwMakeContextCurrent(window);
  52. // Initialize GLEW
  53.  
  54.  
  55.  
  56. do{
  57. // Draw nothing, see you in tutorial 2 !
  58.  
  59. // Swap buffers
  60. glfwSwapBuffers(window);
  61. glfwPollEvents();
  62.  
  63. } // Check if the ESC key was pressed or the window was closed
  64. while (glfwGetKey(window, GLFW_KEY_ESCAPE) != GLFW_PRESS &&
  65. glfwWindowShouldClose(window) == 0);
  66.  
  67.  
  68. /*
  69.  
  70.  
  71. glfwMakeContextCurrent(window);
  72. glMatrixMode(GL_PROJECTION);
  73. glLoadIdentity();
  74. gluPerspective(60.f, (800.f/800.f), 0.0001f, 1000.f);
  75. glMatrixMode(GL_MODELVIEW);
  76. glLoadIdentity();
  77. glClearColor(0, 0, 0, 1);
  78. glBlendFunc(GL_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  79. glEnable(GL_BLEND);
  80. while (!glfwWindowShouldClose(window)) {
  81. glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  82.  
  83. engine.Update();
  84.  
  85. for(int i = 0; i < PARTICLE_AMT; i++)
  86. {
  87. float r = trillek::util::Util::RandFloat(0.f, 1.f);
  88. float g = trillek::util::Util::RandFloat(0.f, 1.f);
  89. float b = trillek::util::Util::RandFloat(0.f, 1.f);
  90.  
  91. glPushMatrix();
  92.  
  93. glTranslatef(engine.particles[i].x, engine.particles[i].y, engine.particles[i].z);
  94. glColor3f(r, g, b);
  95. glBegin(GL_QUADS);
  96. glVertex3f(-1.5, 1.5, 0);
  97. glVertex3f(1.5, 1.5, 0);
  98. glVertex3f(1.5, -1.5, 0);
  99. glVertex3f(-1.5, -1.5, 0);
  100. glEnd();
  101.  
  102. glPopMatrix();
  103. }
  104.  
  105. glfwSwapBuffers(window);
  106.  
  107. glfwPollEvents();
  108. }
  109.  
  110. glfwTerminate();
  111. return 0;
  112. */
  113. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement