error C3861: 'gluBuild2DMipmaps': identifier not found



  • Hallo,

    ich habe den folgenden Quellcode geschrieben:

    #include "stdafx.h"
    #include <SFML/Graphics.hpp>
    #include <SFML/OpenGL.hpp>
    #pragma comment(lib, "glu32.lib")
    using namespace sf;
    
    int main()
    {
    	RenderWindow window(VideoMode(800, 600), "SFML OpenGL");
    
    	Texture t;
    	t.loadFromFile("resources/background.jpg");
    	Sprite background(t);
    
    	GLuint texture = 0;
    	{
    		Image image;
    		image.loadFromFile("resources/texture.jpg");
    
    		glGenTextures(1, &texture);
    		glBindTexture(GL_TEXTURE_2D, texture);
    		gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, image.getSize().x, image.getSize().y, GL_RGBA, GL_UNSIGNED_BYTE, image.getPixelsPtr());
    		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
    	}
    	glEnable(GL_DEPTH_TEST);
    	glDepthMask(GL_TRUE);
    	glClearDepth(1.f);
    	glMatrixMode(GL_PROJECTION);
    	glLoadIdentity();
    	gluPerspective(90.f, 1.f, 1.f, 500.f);
    	glEnable(GL_TEXTURE_2D);
    
    	Clock clock;
    
    	while (window.isOpen())
    	{
    		Event event;
    		while (window.pollEvent(event))
    		{
    			if (event.type == Event::Closed)
    				window.close();
    		}
    		float time = clock.getElapsedTime().asSeconds() * 100;
    		float size = 20.f;
    
    		//Draw the background
    		window.pushGLStates();
    		window.draw(background);
    		window.popGLStates();
    
    		//Clear the depth buffer
    		glClear(GL_DEPTH_BUFFER_BIT);
    
    		//Apply some transformations
    		glMatrixMode(GL_MODELVIEW);
    		glLoadIdentity();
    		glTranslatef(0, 0, -100);
    		glRotatef(time, 50, 50, 0);
    
    		//Draw a cube
    		glBindTexture(GL_TEXTURE_2D, texture);
    		glBegin(GL_QUADS);
    			// back
    		glTexCoord2f(0, 0); glVertex3f(-size, -size, -size);
    		glTexCoord2f(1, 0); glVertex3f( size, -size, -size);
    		glTexCoord2f(1, 1); glVertex3f( size,  size, -size);
    		glTexCoord2f(0, 1); glVertex3f(-size,  size, -size);
    			//front
    		glTexCoord2f(0, 0); glVertex3f( size, -size,  size);
    		glTexCoord2f(1, 0); glVertex3f(-size, -size,  size);
    		glTexCoord2f(1, 1); glVertex3f(-size,  size,  size);
    		glTexCoord2f(0, 1); glVertex3f( size,  size,  size);
    			//left
    		glTexCoord2f(0, 0); glVertex3f(-size, -size,  size);
    		glTexCoord2f(1, 0); glVertex3f(-size, -size, -size);
    		glTexCoord2f(1, 1); glVertex3f(-size,  size, -size);
    		glTexCoord2f(0, 1); glVertex3f(-size,  size,  size);
    			//right
    		glTexCoord2f(0, 0); glVertex3f( size, -size, -size);
    		glTexCoord2f(1, 0); glVertex3f( size, -size,  size);
    		glTexCoord2f(1, 1); glVertex3f( size,  size,  size);
    		glTexCoord2f(0, 1); glVertex3f( size,  size, -size);
    			//bottom
    		glTexCoord2f(0, 0); glVertex3f(-size, -size,  size);
    		glTexCoord2f(1, 0); glVertex3f( size,  size, -size);
    		glTexCoord2f(1, 1); glVertex3f( size,  size,  size);
    		glTexCoord2f(0, 1); glVertex3f(-size,  size,  size);
    			//top
    		glTexCoord2f(0, 0); glVertex3f(-size,  size, -size);
    		glTexCoord2f(1, 0); glVertex3f( size,  size, -size);
    		glTexCoord2f(1, 1); glVertex3f( size,  size,  size);
    		glTexCoord2f(0, 1); glVertex3f(-size,  size,  size);
    
    		glEnd();
    
    		//display all
    		window.display();
    	}
    
    	glDeleteTextures(1, &texture);
    
    	return 0;
    }
    

    Das Problem, das ich habe ist, dass die Funktion "gluBuild2DMipmaps" nicht erkannt wird. Es wird der Fehler "error C3861: 'gluBuild2DMipmaps': identifier not found" ausgegeben. Ich weiß nicht woran das liegt. Kann mir irgendwer weiterhelfen?



  • Keine Ahnung davon, aber eine Suche im Netz fördert https://www.opengl.org/wiki/Common_Mistakes#gluBuild2DMipmaps zu Tage und da steht zu dieser Funktion "Never use this.". Vielleicht ist's Absicht dass man sie nicht so direkt aufrufen kann?


  • Mod

    #include <Glu.h>
    

Anmelden zum Antworten