Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define GLEW_STATIC
- #include <stdio.h>
- #include <stdlib.h>
- #include <GL/glew.h>
- #include <GLFW/glfw3.h>
- #include "SimpleParticleEngine.hpp"
- #include "Particle.hpp"
- #include "Util.hpp"
- #define PARTICLE_AMT 500
- int main() {
- trillek::util::Util::Seed();
- trillek::particle::SimpleParticleEngine engine;
- engine.Init(PARTICLE_AMT, 0, 0, -500);
- engine.lifeMin = 5;
- engine.lifeMax = 10;
- GLFWwindow* window;
- /* Initialize the library */
- // Ensure we can capture the escape key being pressed below
- glfwSetInputMode( window, GLFW_STICKY_KEYS, GL_TRUE);
- if (!glfwInit()) {
- fprintf(stderr, "Failed to initialize GLFW/n");
- return -1;
- }
- GLuint VertexArrayID;
- glGenVertexArrays(1, &VertexArrayID);
- glBindVertexArray(VertexArrayID);
- glewExperimental = true;
- if (glewInit() != GLEW_OK) {
- fprintf(stderr, "Failed to initialize GLEW\n");
- return -1;
- }
- glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); // We want OpenGL 3.3
- glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
- glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
- // Open a window and create its OpenGL context
- window = glfwCreateWindow(1024, 768, "Grant Particle test", NULL, NULL);
- if (window == NULL){
- fprintf(stderr, "Failed to open GLFW window. If you have an Intel GPU, they are not 3.3 compatible.");
- glfwTerminate();
- return -1;
- }
- glfwMakeContextCurrent(window);
- // Initialize GLEW
- do{
- // Draw nothing, see you in tutorial 2 !
- // Swap buffers
- glfwSwapBuffers(window);
- glfwPollEvents();
- } // Check if the ESC key was pressed or the window was closed
- while (glfwGetKey(window, GLFW_KEY_ESCAPE) != GLFW_PRESS &&
- glfwWindowShouldClose(window) == 0);
- /*
- glfwMakeContextCurrent(window);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- gluPerspective(60.f, (800.f/800.f), 0.0001f, 1000.f);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- glClearColor(0, 0, 0, 1);
- glBlendFunc(GL_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glEnable(GL_BLEND);
- while (!glfwWindowShouldClose(window)) {
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- engine.Update();
- for(int i = 0; i < PARTICLE_AMT; i++)
- {
- float r = trillek::util::Util::RandFloat(0.f, 1.f);
- float g = trillek::util::Util::RandFloat(0.f, 1.f);
- float b = trillek::util::Util::RandFloat(0.f, 1.f);
- glPushMatrix();
- glTranslatef(engine.particles[i].x, engine.particles[i].y, engine.particles[i].z);
- glColor3f(r, g, b);
- glBegin(GL_QUADS);
- glVertex3f(-1.5, 1.5, 0);
- glVertex3f(1.5, 1.5, 0);
- glVertex3f(1.5, -1.5, 0);
- glVertex3f(-1.5, -1.5, 0);
- glEnd();
- glPopMatrix();
- }
- glfwSwapBuffers(window);
- glfwPollEvents();
- }
- glfwTerminate();
- return 0;
- */
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement