1. Post #1
    Gold Member
    compwhizii's Avatar
    February 2007
    8,442 Posts
    http://www.sfml-dev.org/tutorials/1.5/window-opengl.php Up to that part in the tutorial.

    Code:
    #include "stdafx.h"
    #include <SFML/Window.hpp>
    #include <iostream>
    
    int _tmain(int argc, _TCHAR* argv[])
    {
    	sf::Window App(sf::VideoMode(800, 600, 32), "SFML OpenGL");
    
    	sf::Clock Clock;
    
    	/*  How to pass settings to the window
    	sf::WindowSettings Settings;
    	Settings.DepthBits			= 24; // Request a 24 bits depth buffer
    	Settings.StencilBits		= 8;  // Request a 8 bits stencil buffer
    	Settings.AntialiasingLevel	= 2;  //Request 2 levels of AA
    	sf::Window App(sf::VideoMode(800, 600, 32), "SFML OpenGL", sf::Style::Close, Settings);
    	*/
    
    	// 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);
    
    	while (App.IsOpened())
    	{
    		sf::Event Event;
    		while (App.GetEvent(Event))
    		{
    			// Window Closed
    			if (Event.Type == sf::Event::Closed)
    				App.Close();
    
    			// Escape Key Pressed
    			if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
    				App.Close();
    			
    			// Window Resized
    			if (Event.Type == sf::Event::Resized)
    				glViewport(0, 0, Event.Size.Width, Event.Size.Height);
    		}
    
    		// Makes the current window active,
    		// Useless here
    		App.SetActive();
    
    		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    
    		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);
    
    		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();
    
    		App.Display();
    	}
    	
    	return EXIT_SUCCESS;
    }

    Error:
    Code:
    1>------ Build started: Project: SFML Test1, Configuration: Release Win32 ------
    1>Compiling...
    1>SFML Test1.cpp
    1>Linking...
    1>SFML Test1.obj : error LNK2001: unresolved external symbol _gluPerspective@32
    1>E:\__ALLDATA\SrcCon Project\SrcCon2\SFML\Release\SFML Test1.exe : fatal error LNK1120: 1 unresolved externals
    1>Build log was saved at "file://e:\__ALLDATA\SrcCon Project\SrcCon2\SFML\SFML Test1\Release\BuildLog.htm"
    1>SFML Test1 - 2 error(s), 0 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
    Help?

  2. Post #2
    Gold Member
    r4nk_'s Avatar
    April 2005
    2,021 Posts
    You need to link against glu.lib

  3. Post #3
    Gold Member
    HubmaN V2's Avatar
    November 2007
    885 Posts
    Fuck, beaten.

  4. Post #4
    Gold Member
    compwhizii's Avatar
    February 2007
    8,442 Posts


    Like that? It can't find it.

  5. Post #5
    Gold Member
    r4nk_'s Avatar
    April 2005
    2,021 Posts
    Oops sorry, try glu32.lib

  6. Post #6
    Gold Member
    compwhizii's Avatar
    February 2007
    8,442 Posts
    Yay. It built.

    Edited:

    Oh shit yes =D

  7. Post #7
    Gold Member
    Jallen's Avatar
    December 2007
    7,561 Posts
    -snip- didn't see /* */

    -snip- r4nk_ explained to to me on steam.

    Most useful post everrr