Created
June 26, 2012 20:33
-
-
Save KAYLukas/2998740 to your computer and use it in GitHub Desktop.
glfw testje
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// main.cpp | |
// GLFWtest | |
// | |
// Created by Kay Lukas on 26-06-12. | |
// Copyright (c) 2012 TU/e. All rights reserved. | |
// | |
#include <iostream> | |
#include <GL/glfw.h> | |
#include <GLUT/glut.h> | |
#include <stdlib.h> | |
int main(){ | |
printf("Hello World\n"); | |
glfwInit();//Initialize | |
glfwOpenWindow(640, 480, 8,8,8,8,8,8, GLFW_WINDOW);//Open a window | |
glfwSetWindowTitle("Code snappit"); | |
int running = true; | |
glClearColor(0,0,0,0); | |
glViewport(0, 0, 640, 480 ); | |
glMatrixMode(GL_PROJECTION ); | |
glLoadIdentity(); | |
gluPerspective (90, 640.0/480.0, 1.0, 5000.0 ); | |
glTranslated(0.0f, 0.0f, -1.0f); | |
glColor4f(1.0f, 1.0f, 1.0f, 1.0f); | |
int counter = 0; | |
while(running){//Execute main loop, just as many fps as you can achieve | |
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);//clear buffer bits | |
glRasterPos2i(0, 0); | |
glColor3f(1.0f,1.0f,1.0f); | |
//Draw a white triangle | |
glBegin(GL_TRIANGLES); | |
glVertex3f( 0.0f, 1.0f, 0.0f); | |
glVertex3f(-1.0f,-1.0f, 0.0f); | |
glVertex3f( 1.0f,-1.0f,0.0f); | |
glEnd(); | |
//Draw abc using glut | |
glColor3f(0.0f, 0.0f, 0.0f); | |
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, 'a'); | |
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, 'b'); | |
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_18, 'c'); | |
glfwSwapBuffers(); | |
running = !glfwGetKey(GLFW_KEY_ESC) && glfwGetWindowParam(GLFW_OPENED); | |
if(counter++ == 100){ | |
counter = 0; | |
printf("100 frames achieved!\n"); | |
} | |
} | |
glfwCloseWindow(); | |
glfwTerminate(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Het toevoegen van: glfwSwapInterval(0); voor while(running) zet vsync uit, zodat je maximale fps kan bekijken. Let er wel op dat je vsync wel aan wilt hebben, geeft over het algemeen mooier beeld.