Hi everyone.
I'm having a little bit of trouble, while compiling the cube code from the official site:
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Window.hpp>
////////////////////////////////////////////////////////////
/// Entry point of application
///
/// \return Application exit code
///
////////////////////////////////////////////////////////////
int main()
{
// Create the main window
sf::Window App(sf::VideoMode(800, 600, 32), "SFML OpenGL");
// Create a clock for measuring time elapsed
sf::Clock Clock;
// Set color and depth clear value
glClearDepth(1.f);
glClearColor(0.f, 0.f, 0.f, 0.f);
// Enable Z-buffer read and write
glEnable(GL_DEPTH_TEST);
glDepthMask(GL_TRUE);
// Setup a perspective projection
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(90.f, 1.f, 1.f, 500.f);
// Start game loop
while (App.IsOpened())
{
// Process events
sf::Event Event;
while (App.GetEvent(Event))
{
// Close window : exit
if (Event.Type == sf::Event::Closed)
App.Close();
// Escape key : exit
if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
App.Close();
// Resize event : adjust viewport
if (Event.Type == sf::Event::Resized)
glViewport(0, 0, Event.Size.Width, Event.Size.Height);
}
// Set the active window before using OpenGL commands
// It's useless here because active window is always the same,
// but don't forget it if you use multiple windows or controls
App.SetActive();
// Clear color and depth buffer
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Apply some transformations
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.f, 0.f, -200.f);
glRotatef(Clock.GetElapsedTime() * 50, 1.f, 0.f, 0.f);
glRotatef(Clock.GetElapsedTime() * 30, 0.f, 1.f, 0.f);
glRotatef(Clock.GetElapsedTime() * 90, 0.f, 0.f, 1.f);
// Draw a cube
glBegin(GL_QUADS);
glVertex3f(-50.f, -50.f, -50.f);
glVertex3f(-50.f, 50.f, -50.f);
glVertex3f( 50.f, 50.f, -50.f);
glVertex3f( 50.f, -50.f, -50.f);
glVertex3f(-50.f, -50.f, 50.f);
glVertex3f(-50.f, 50.f, 50.f);
glVertex3f( 50.f, 50.f, 50.f);
glVertex3f( 50.f, -50.f, 50.f);
glVertex3f(-50.f, -50.f, -50.f);
glVertex3f(-50.f, 50.f, -50.f);
glVertex3f(-50.f, 50.f, 50.f);
glVertex3f(-50.f, -50.f, 50.f);
glVertex3f(50.f, -50.f, -50.f);
glVertex3f(50.f, 50.f, -50.f);
glVertex3f(50.f, 50.f, 50.f);
glVertex3f(50.f, -50.f, 50.f);
glVertex3f(-50.f, -50.f, 50.f);
glVertex3f(-50.f, -50.f, -50.f);
glVertex3f( 50.f, -50.f, -50.f);
glVertex3f( 50.f, -50.f, 50.f);
glVertex3f(-50.f, 50.f, 50.f);
glVertex3f(-50.f, 50.f, -50.f);
glVertex3f( 50.f, 50.f, -50.f);
glVertex3f( 50.f, 50.f, 50.f);
glEnd();
// Finally, display rendered frame on screen
App.Display();
}
return EXIT_SUCCESS;
}
I've linked with sfml-window-s.lib and sfml-system-s.lib files. However, i still get this error:
1>main.obj : error LNK2019: unresolved external symbol _gluPerspective@32 referenced in function _main
1>D:\Development\Tests\OpenGL usage\Debug\OpenGL usage.exe : fatal error LNK1120: 1 unresolved externals
So from the past problem, i understand, that this is linking problem. What do i need to link? Logically OpenGL libraries, but still - not sure about that.
P.S. sorry for noobish questions, shame on me, but well, i don't know such stuff yet.
P.S.S. i like SFML, i write the code pretty quick, it's easy to remember for me, i like it more than i did liked Allegro. Although, the OpenGL code was quite... Hard to type and remember.
SFML + OpenGL - Cube tutorial from the official site. sfml-window-s.lib is not enough
glu-prefixed functions are functions from the OpenGL utility library. Are you linking against it?
(http://en.wikipedia.org/wiki/OpenGL_Utility_Library)
(http://en.wikipedia.org/wiki/OpenGL_Utility_Library)
No, not really. I thought, that it's integrated in SFML, as they say "the OpenGL and GLU headers will be automatically included by it".
So basically what i need to do, is find and download OpenGL libraries, and install them to Visual Studio 2010 additionally, then compile?
So basically what i need to do, is find and download OpenGL libraries, and install them to Visual Studio 2010 additionally, then compile?
Have you tried asking this on the SFML forums? They are a helpful bunch, and I'm sure you aren't the first to have this kind of problem.
NHo, i haven't. I've got an idea, that they are not very active, so i asked here.
I will post this question on there now also.
I will post this question on there now also.
Quote:Original post by newn
No, not really. I thought, that it's integrated in SFML, as they say "the OpenGL and GLU headers will be automatically included by it".
So basically what i need to do, is find and download OpenGL libraries, and install them to Visual Studio 2010 additionally, then compile?
The headers are obviously there, otherwise the compiler would complain; not the linker ;)
If they included the headers, I'm sure the also included the libraries. Look for glu*.lib.
More info:
http://www.opengl.org/resources/faq/technical/gettingstarted.htm
Look at section:
2.060 What do I need to compile and run OpenGL programs?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement