#include <stdlib.h>
#include <stdio.h>
#include <memory>
// #include <glload/gl_all.h>
// #include <glload/gll.hpp>
// #include <glimg/glimg.h>
#include <GL/glfw.h>
// #include <glimg/TextureGenerator.h>
// using namespace glimg;
bool running = false;
void GLFWCALL My_Key_Callback(int key, int action)
{
if ( action == GLFW_PRESS )
{
printf("Key %c (%d) pressed \n", key, key);
if( key == GLFW_KEY_ESC )
running = false;
}
}
int main()
{
int width, height;
int frame = 0;
glfwInit();
if( glfwOpenWindow( 800, 600, 0, 0, 0, 0, 0, 0, GLFW_WINDOW ) != GL_TRUE )
{
printf("glfwOpenWindow() fails :( \n");
glfwTerminate();
return 0;
}
else
running = true;
glfwSetWindowTitle("GLFW Application");
glfwSetKeyCallback(My_Key_Callback);
//////////////////////////////////////////////////////////////////////////////////
/*
if(glload::LoadFunctions() == glload::LS_LOAD_FAILED)
{
running = false;
return 0;
}
GLuint theTexture = 0;
try
{
std::auto_ptr<glimg::ImageSet> pImgSet(glimg::loaders::stb::LoadFromFile("TestImage.png"));
theTexture = glimg::CreateTexture(pImgSet.get(), 0);
}
catch(glimg::loaders::stb::StbLoaderException &e)
{
printf("Image file loading failed.");
}
catch(glimg::TextureGenerationException &e)
{
printf("Texture creation failed.");
}
*/
/////////////////////////////////////////////////////////////////////////////////
while(running == true)
{
frame++;
glfwGetWindowSize( &width, &height );
// printf("window size = %d x %d \n", width, height);
// height = height > 0 ? height : 1;
glViewport( 0, 0, width, height );
glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
glClear( GL_COLOR_BUFFER_BIT );
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0,width,height,0.0,-1.0,1.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glfwSwapBuffers();
glfwPollEvents();
}
printf("Quit \n");
glfwTerminate();
return 0;
}