I've been trying to use the Unofficial OpenGL SDK, but when I attempt to use the image loading library, I keep getting errors. Here is my code:


Code:

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
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
63         glMatrixMode(GL_PROJECTION);
64         glLoadIdentity();
65         glOrtho(0.0,width,height,0.0,-1.0,1.0);
66
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 }


Here are the errors that I cant seem to fix:


Code:

C:\Users\Colin\Documents\CompDev\C++\TextureTest\main.cpp||In function 'int main()':|
C:\Users\Colin\Documents\CompDev\C++\TextureTest\main.cpp|45|error: expected type-specifier|
C:\Users\Colin\Documents\CompDev\C++\TextureTest\main.cpp|45|error: expected unqualified-id before '&' token|
C:\Users\Colin\Documents\CompDev\C++\TextureTest\main.cpp|45|error: expected ')' before '&' token|
C:\Users\Colin\Documents\CompDev\C++\TextureTest\main.cpp|45|error: expected '{' before '&' token|
C:\Users\Colin\Documents\CompDev\C++\TextureTest\main.cpp|45|error: 'e' was not declared in this scope|
C:\Users\Colin\Documents\CompDev\C++\TextureTest\main.cpp|45|error: expected ';' before ')' token|
||=== Build finished: 6 errors, 0 warnings (0 minutes, 1 seconds) ===|



I've tried commenting out the offending catch(), but the program always crashes before it can get to the main loop, and never due to failed image file loading.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement