1 #include <stdlib.h>
2 #include <stdio.h>
3 #include <memory>
4 #include <glload/gl_all.h>
5 #include <glload/gll.hpp>
6 #include <glimg/glimg.h>
7 #include <GL/glfw.h>
8 #include <glimg/TextureGenerator.h>
9 using namespace glimg;
10
11 int main()
12 {
13 int width, height;
14 int frame = 0;
15 bool running = true;
16
17 glfwInit();
18
19 if( !glfwOpenWindow( 1600, 900, 0, 0, 0, 0, 0, 0, GLFW_FULLSCREEN ) )
20 {
21 glfwTerminate();
22 return 0;
23 }
24
25 glfwSetWindowTitle("GLFW Application");
26
27 //////////////////////////////////////////////////////////////////////////////////
28 if(glload::LoadFunctions() == glload::LS_LOAD_FAILED)
29 {
30 running = false;
31 return 0;
32 }
33
34 GLuint theTexture = 0;
35
36 try
37 {
38 std::auto_ptr<glimg::ImageSet> pImgSet(glimg::loaders::stb::LoadFromFile("TestImage.png"));
39 theTexture = glimg::CreateTexture(pImgSet.get(), 0);
40 }
41 catch(glimg::loaders::stb::StbLoaderException &e)
42 {
43 printf("Image file loading failed.");
44 }
45 catch(glimg::TextureGenerationException &e)
46 {
47 printf("Texture creation failed.");
48 }
49 /////////////////////////////////////////////////////////////////////////////////
50
51 while(running)
52 {
53 frame++;
54
55 glfwGetWindowSize( &width, &height );
56 height = height > 0 ? height : 1;
57
58 glViewport( 0, 0, width, height );
59
60 glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
61 glClear( GL_COLOR_BUFFER_BIT );
62 glMatrixMode(GL_PROJECTION);
63 glLoadIdentity();
64 glOrtho(0.0,width,height,0.0,-1.0,1.0);
65 glMatrixMode(GL_MODELVIEW);
66 glLoadIdentity();
67 glfwSwapBuffers();
68
69 // exit if ESC was pressed or window was closed
70 running = !glfwGetKey(GLFW_KEY_ESC) && glfwGetWindowParam( GLFW_OPENED);
71 }
72
73 glfwTerminate();
74
75 return 0;
76 }