Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "SceneOpenGl.h"
- SceneOpenGL::SceneOpenGL(SDL_Window* window) {
- if (window == NULL) {
- throw new SceneOpenGLException();
- }
- // Engine
- this->window = window;
- // Tools
- this->fps = new FPSCount();
- this->input = new Input();
- // Scene
- this->run = false;
- int w, h;
- SDL_GetWindowSize(window, &w, &h);
- this->projection = glm::perspective(70.0, (double)(w/h), 1.0, 100.0);
- this->modelview = glm::mat4(1.0);
- }
- SceneOpenGL::~SceneOpenGL()
- {
- delete fps;
- delete input;
- }
- void SceneOpenGL::start() {
- run = true;
- // Test en attendant ObjectGL.show() //
- float vertices[] = { -0.5, -0.5, 0.0, 0.5, 0.5, -0.5 };
- // /Test //
- while (run) {
- // FPS flag
- if (fps->flag()) {
- std::cout << "FPS : " << fps->getFps() << std::endl;
- }
- // Input check/actions
- input->updateEvents();
- if (input->isKeyPush(SDL_SCANCODE_ESCAPE)) {
- run = false;
- }
- // Cleaning last frame
- glClear(GL_COLOR_BUFFER_BIT);
- // Test en attendant ObjectGL.show() //
- glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, vertices);
- glEnableVertexAttribArray(0);
- glDrawArrays(GL_TRIANGLES, 0, 3);
- glDisableVertexAttribArray(0);
- // /Test //
- // FPS add frame
- fps->addFrame();
- // Rendering
- SDL_GL_SwapWindow(window);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement