Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: [Solved sorta] SFML 2.0"identifier not found" "undeclared identifier"  (Read 7069 times)

0 Members and 2 Guests are viewing this topic.

joshuar

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Hi, I'm new to SFML and OpenGL. I'm learning using the ArcSynthesis website, which uses modern OpenGL 3.3 in their tutorials and uses freeGlut instead of SFML for context.

Anyway, I'm having a problem trying to get SFML to work with the GLsdk. Specifically using the GLsdk's GLload class.

#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <SFML/Window/Joystick.hpp>
#include <SFML/Window/Event.hpp>
#include <SFML/Window.hpp>
#include <SFML/Window/ContextSettings.hpp>

#include <glload\gl_3_3.hpp>
#include <SFML/OpenGL.hpp>
#include <SFML/Graphics.hpp>

#include <gl/glut.h>
#include "framework.h"
#include <glm/glm.hpp>
#include <glm/gtc/quaternion.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>

The problem is when I use #include <glload\gl_3_3.hpp> after #include <SFML/OpenGL.hpp> (or #include <SFML/Graphics.hpp>)I get a "Error   1   error C1189: #error :  Attempt to include gle after including gl.h" error.

I googled a bit, and learned that order matters in the include statements, and it's usually safest to do #include <glload\gl_3_3.hpp> first before any other OpenGL includes. So, I switched the order and put it before  #include <SFML/OpenGL.hpp> . After doing that though, now it seems my program doesn't recognize any calls to OpenGL. It gives me ~94 errors all of the form: "error C3861: 'glClear': identifier not found" or "identifier not detected"

What's weird though is if I comment out#include <glload\gl_3_3.hpp>, the program works! And if I put it back in, the program forgets how to use OpenGL and gives me the "identifier not found" errors. I'd like to be able to use <glload\gl_3_3.hpp> and SFML.  I've been trying to figure it out for hours. :\

I'm working on a laptop (i7 processor) running Windows 7. The IDE's Visual Studio 2012. Radeon HD5730 1GB graphics card. Using SFML 2.0. .. Umm.. I'm not sure what other information you might need.  Feel free to ask!

Any help is appreciated. :)

« Last Edit: April 08, 2013, 09:41:06 pm by joshuar »

Halsys

  • Jr. Member
  • **
  • Posts: 66
  • Halsys like Hal.sys
    • View Profile
    • Email
Re: SFML and <glload\gl_3_3.hpp>; OpenGL won't work
« Reply #1 on: April 07, 2013, 05:45:59 am »
I would say #include <glload\gl_3_3.hpp> needs to be after #include <SFML/OpenGL.hpp> because OpenGL.hpp just includes more files for you that have nothing really anything to do with SFML but is there for pleasure and convenience.(They include <GL/gl.h> & <GL/glu.h>)
Also you might need to add -lopengl32 or OpenGL32.lib to your linker depending on your IDE if you want to keep #include <SFML/OpenGL.hpp>.

Also #include <SFML/Window.hpp> includes
#include <SFML/Window/Joystick.hpp>
#include <SFML/Window/Event.hpp>
#include <SFML/Window/ContextSettings.hpp>
So you don't have to add those 3.

Also you don't really need glut because SFML uses its own windowing/event systems.
If you are only using OpenGL, Use sf::window, Not Render window, because you have to jump through several hoops to make sure everything works and even still there is a slight performance loss if you do it that way. Because RenderWindow is for SFML related objects(Shapes/Sprites/Points) where Window is open for OpenGL.

I could be wrong for most of this stuff, Like the part about #include <glload\gl_3_3.hpp> needs to be after #include <SFML/OpenGL.hpp>. Other than that, good luck.
If you notice I put "....", in my sentences way too much... I'm sorry.

joshuar

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Re: SFML and <glload\gl_3_3.hpp>; OpenGL won't work
« Reply #2 on: April 07, 2013, 10:50:15 am »
Thanks for taking the time to reply. I've tried some of the things you suggested, but I'm still having trouble.

I switched the order of gl_3_3.hpp and OpenGL.hpp, and I got the same error I described in my original post: "Error   1   error C1189: #error :  Attempt to include gle after including gl.h" I don't even know what "gle" is. lol.

I also already had "OpenGL32.lib" included in my linker settings. Because I can get it to work if I comment out the include for gl_3_3.hpp, I'm thinking the problem is not linker settings, but I don't know that that is not the problem, so I'm open to any suggestions!

I did remove the 3 #includes you suggested. I also removed the #include for glut.h and all calls to glut(just to eliminate variables).

I know that I don't need glut for the windowing, I was actually just using it for the drawing of spheres, tori and cones, and such (e.g "glutSolidSphere(1,slices,stacks);"). lol. Before I decided to start the ArcSynthesis tutorials, I had a demo running with SFML and glut, so I know it can work. I was only using glut for making the spheres and tori, etc. though.

I also already made use of sf::Window as you suggested
       "sf::Window wind(sf::VideoMode(800, 600, 32), "Digital Canvas");"

Anymore suggestions?

Halsys

  • Jr. Member
  • **
  • Posts: 66
  • Halsys like Hal.sys
    • View Profile
    • Email
Re: SFML and GLsdk compatible?; OpenGL won't work
« Reply #3 on: April 08, 2013, 05:00:46 am »
Well I found Gle for you, http://code.google.com/p/oglpp/wiki/gle , which is "Open(GL) (E)xtension library" and I'm not really sure what else I can help you with. Just keep trying to decipher the Compiler errors I guess, I can still help you with that. :P
If you notice I put "....", in my sentences way too much... I'm sorry.

joshuar

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Re: SFML and GLsdk compatible?; OpenGL won't work
« Reply #4 on: April 08, 2013, 06:37:48 am »
Thanks for your help.

A bit more searching and I found a user who had a similar problem, but in French:
http://en.sfml-dev.org/forums/index.php?topic=4174.0
His solution was to add <gl/glut.h> I already have that though!

Laurent also thought it was a bad solution. :P lol, if I didn't already have it - I'd try it. Does anyone else have a suggestion?

Maybe I should download the newest nightly build and see if that helps... 



joshuar

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Couldn't figure it out, so I worked around it.
« Reply #5 on: April 08, 2013, 09:38:29 pm »
So, I didn't solve the problem, per se. I couldn't figure out how to use glload and SFML, so I'm going to use glew instead! It works! haha. I'm not sure what the difference is (if any), but since it's working, I'm just going to stick with it. Thanks for your help!

Um.. how do I say that this problem is resolved? (so that people won't have to look at this anymore).

may5

  • Newbie
  • *
  • Posts: 1
    • View Profile
GLLoad actually does some strange stuff to the OpenGL calls. If you use the .hpp file, all OpenGL calls are moved to the gl:: namespace, and their names slightly changed. So you'd have to do something like gl::Clear() instead of glClear(). If you use the glload.h instead of glload.hpp, it doesn't change any of the calls. Also GLLoad has to be included before other things that include OpenGL because it does some stuff behind the scenes.

All that being said, I don't even know if it'll work with SFML. I came to this forum to try to see if GLLoad would work with SFML because I'm considering moving from GLFW to SFML.

EDIT:
The reason I'd like to stick with GLLoad is because other stuff that I like to use such as GLUtil and GLImage require GLLoad.
« Last Edit: June 15, 2013, 02:16:30 am by may5 »

 

anything