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

Author Topic: use of undeclared identifier gluperspective  (Read 4682 times)

0 Members and 2 Guests are viewing this topic.

The Thinker

  • Newbie
  • *
  • Posts: 19
    • View Profile
use of undeclared identifier gluperspective
« on: May 17, 2015, 04:59:42 am »
Hi guys,

I have the following problem on SFML 2.3 with OpenGl under Xcode 6.3.1
In SFML 2.2 it was working fine.

"use of undeclared identifier gluperspective"

(- On Xcode's Project Target > Linked Frameworks and Libraries: I have added OpenGL.framework)

Please let me know how to fix it.

Thanks :)

CODE:
---------------------------
#include <SFML/System.hpp>
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
#include <SFML/OpenGL.hpp>

void cube()
{
    glBegin(GL_QUADS);      // Draw The Cube Using quads
   
    glColor3f(0.0f,1.0f,0.0f);  // Color Green
    glNormal3f(0.f, 1.f, 0.f);
    glVertex3f( 1.0f, 1.0f,-1.0f);  // Top Right Of The Quad (Top)
    glNormal3f(0.f, 1.f, 0.f);
    glVertex3f(-1.0f, 1.0f,-1.0f);  // Top Left Of The Quad (Top)
    glNormal3f(0.f, 1.f, 0.f);
    glVertex3f(-1.0f, 1.0f, 1.0f);  // Bottom Left Of The Quad (Top)
    glNormal3f(0.f, 1.f, 0.f);
    glVertex3f( 1.0f, 1.0f, 1.0f);  // Bottom Right Of The Quad (Top)
   
    glColor3f(1.0f,0.5f,0.0f);  // Color Orange
    glNormal3f(0.f, -1.f, 0.f);
    glVertex3f( 1.0f,-1.0f, 1.0f);  // Top Right Of The Quad (Bottom)
    glNormal3f(0.f, -1.f, 0.f);
    glVertex3f(-1.0f,-1.0f, 1.0f);  // Top Left Of The Quad (Bottom)
    glNormal3f(0.f, -1.f, 0.f);
    glVertex3f(-1.0f,-1.0f,-1.0f);  // Bottom Left Of The Quad (Bottom)
    glNormal3f(0.f, -1.f, 0.f);
    glVertex3f( 1.0f,-1.0f,-1.0f);  // Bottom Right Of The Quad (Bottom)
   
    glColor3f(1.0f, 0.0f, 0.0f);    // Color Red
    glNormal3f(0.f, 0.f, 1.f);
    glVertex3f( 1.0f, 1.0f, 1.0f);  // Top Right Of The Quad (Front)
    glNormal3f(0.f, 0.f, 1.f);
    glVertex3f(-1.0f, 1.0f, 1.0f);  // Top Left Of The Quad (Front)
    glNormal3f(0.f, 0.f, 1.f);
    glVertex3f(-1.0f,-1.0f, 1.0f);  // Bottom Left Of The Quad (Front)
    glNormal3f(0.f, 0.f, 1.f);
    glVertex3f( 1.0f,-1.0f, 1.0f);  // Bottom Right Of The Quad (Front)
   
    glColor3f(1.0f, 1.0f, 0.0f);    // Color Yellow
    glNormal3f(0.f, 0.f, -1.f);
    glVertex3f( 1.0f,-1.0f,-1.0f);  // Top Right Of The Quad (Back)
    glNormal3f(0.f, 0.f, -1.f);
    glVertex3f(-1.0f,-1.0f,-1.0f);  // Top Left Of The Quad (Back)
    glNormal3f(0.f, 0.f, -1.f);
    glVertex3f(-1.0f, 1.0f,-1.0f);  // Bottom Left Of The Quad (Back)
    glNormal3f(0.f, 0.f, -1.f);
    glVertex3f( 1.0f, 1.0f,-1.0f);  // Bottom Right Of The Quad (Back)
   
    glColor3f(0.0f, 0.0f, 1.0f);    // Color Blue
    glNormal3f(-1.f, 0.f, 0.f);
    glVertex3f(-1.0f, 1.0f, 1.0f);  // Top Right Of The Quad (Left)
    glNormal3f(-1.f, 0.f, 0.f);
    glVertex3f(-1.0f, 1.0f,-1.0f);  // Top Left Of The Quad (Left)
    glNormal3f(-1.f, 0.f, 0.f);
    glVertex3f(-1.0f,-1.0f,-1.0f);  // Bottom Left Of The Quad (Left)
    glNormal3f(-1.f, 0.f, 0.f);
    glVertex3f(-1.0f,-1.0f, 1.0f);  // Bottom Right Of The Quad (Left)
   
    glColor3f(1.0f, 0.0f, 1.0f);    // Color Violet
    glNormal3f(1.f, 0.f, 0.f);
    glVertex3f( 1.0f, 1.0f,-1.0f);  // Top Right Of The Quad (Right)
    glNormal3f(1.f, 0.f, 0.f);
    glVertex3f( 1.0f, 1.0f, 1.0f);  // Top Left Of The Quad (Right)
    glNormal3f(1.f, 0.f, 0.f);
    glVertex3f( 1.0f,-1.0f, 1.0f);  // Bottom Left Of The Quad (Right)
    glNormal3f(1.f, 0.f, 0.f);
    glVertex3f( 1.0f,-1.0f,-1.0f);  // Bottom Right Of The Quad (Right)
   
    glEnd();          // End Drawing The Cube
}

int main()
{
    sf::RenderWindow window(sf::VideoMode(800, 600), "Cube!", sf::Style::Default);
    window.setVerticalSyncEnabled(true);
    window.setActive(true);
    window.resetGLStates();
   
    bool running = true;
    while(running)
    {
        sf::Event event;
        while(window.pollEvent(event))
        {
            switch(event.type)
            {
                case sf::Event::KeyPressed:
                    if(event.key.code != sf::Keyboard::Escape) { break; }
                case sf::Event::Closed:
                    running = false;
                    break;
                default:
                    break;
            }
        }
       
        glClearColor(0.3f, 0.3f, 0.3f, 1.f);
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
       
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        sf::Vector2u wsize = window.getSize();
        glViewport(0, 0, wsize.x, wsize.y);
        gluPerspective(60, (float)wsize.x / (float)wsize.y, 0.1f, 512.f);
       

        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
       
        glPushMatrix();
        glTranslatef(0.f, 0.f, -5.f);
       
        cube();
       
        glPopMatrix();
       
        GLenum err = glGetError();
       
        window.display();
    }
   
    return 0;
}
« Last Edit: May 17, 2015, 05:03:59 am by The Thinker »

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: use of undeclared identifier gluperspective
« Reply #1 on: May 17, 2015, 05:27:52 am »
GLU was removed from the <SFML/OpenGL.hpp> header in 2.3 because it is old/slow and might not even be available on some systems. It is recommended to not use GLU any longer. You will always be able to construct a replacement for a GLU function that you might have used in the past just using standard OpenGL.

See this for a gluPerspective replacement.
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

 

anything