PDA

View Full Version : How to put a Texture on Disk



01-11-2003, 11:47 PM
Hello,
i have the following problem. I should put a texture on a Disk.
Here is the code i used can anybody tell me why it doesn't work?
Here is the code for the texture function:

void Texture(void){
AUX_RGBImageRec *myImage;
char *name;
name=(char*)malloc(10);
strcpy(name,"picture.bmp");
glEnable (GL_TEXTURE_2D);
glTexEnvi (GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE, GL_DECAL);
myImage = auxDIBImageLoadA ((const char*) name);
gluBuild2DMipmaps(GL_TEXTURE_2D, 3,meinBild->sizeX,
myImage->sizeY,GL_RGB, GL_UNSIGNED_BYTE,myImage->data );
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
}

Now the Code to show the disk without a texture:

void Disk(GLdouble innerRadius, GLdouble outerRadius){
GLUquadricObj* obj;
obj=gluNewQuadric();
gluQuadricDrawStyle(obj, GLU_FILL);
gluDisk (obj,innerRadius,outerRadius,25,25);
}

And now the code to put a texture on the Disk.

Texture();Disk(1,2);

Would be very nice if someone could help me.

Maverick

Bob
01-12-2003, 12:48 AM
First you need to bind the texture to a unique texture id. Look up glBindTexture. Then you need to tell GLU to generate texture coordinates. Look up glQuadricTexture.

01-12-2003, 04:10 AM
Thank you very much, this is exactly what i searched http://www.opengl.org/discussion_boards/ubb/smile.gif Now everything works fine.

I_NeedHelp
01-13-2003, 07:07 AM
void Texture(void){
AUX_RGBImageRec *myImage;
char *name;
name=(char*)malloc(10);
strcpy(name,"picture.bmp");
glEnable (GL_TEXTURE_2D);
glTexEnvi (GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE, GL_DECAL);
myImage = auxDIBImageLoadA ((const char*) name);
gluBuild2DMipmaps(GL_TEXTURE_2D, 3,meinBild->sizeX,
myImage->sizeY,GL_RGB, GL_UNSIGNED_BYTE,myImage->data );
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
}


This is from your topic, i was wondering if this code will will work using a borland c++ builder CONSOLE application. I got errors when i tried to do this. I tink it's because the function auxDIBImageLoadA don't work with console apps. Am i talkin poop or is it d case? Why did i get the following then:
[Linker Error] Unresolved external 'auxDIBImageLoadA' referenced from..... blah blah blah

Bob
01-13-2003, 07:26 AM
Am i talkin poop...

Yes http://www.opengl.org/discussion_boards/ubb/smile.gif

You need to link with the library that contains auxDIBImageLoadA. In MSVC, it's glaux.lib, but don't know if it's available on Borland compilers. Anyways, there are tons of code on the net to load images. Use a search engine and you will find some.

jebus
01-13-2003, 08:09 AM
you may want to consider different avenues than glaux. i don't think it's supported anymore as it is quite outdated.

jebus

I_NeedHelp
01-13-2003, 11:44 PM
Nope! I don't no. I'm still getting the error. I've included the glaux header file. Am i thick or is there something else i have to do to get the glaux.lib????
[Linker Error] Unresolved external 'auxDIBImageLoadA' referenced from blah blah blah.

Bob
01-14-2003, 01:27 AM
But you haven't included glaux.lib to the linker. If you look at the error it says it's a link error, not a compile error.

I_NeedHelp
01-14-2003, 05:36 AM
I have included it! Well i think so anyway, does this line do it:
#include "glaux.h"
if not how do i include the library???

The double qoutes indicate the header is in the present project directory with the source code and all the other files. I THINK, i'm not 100% on this.
I don't no, mayb i've been smokin something strange but i think this line means i've linked the program to the glaux library which is in the same directory.

To quote my user name, i need help!

[This message has been edited by I_NeedHelp (edited 01-14-2003).]

[This message has been edited by I_NeedHelp (edited 01-14-2003).]

Deiussum
01-14-2003, 06:24 AM
Including the header is not the same as linking to the library. A header is generally a bunch of pre-declarations so that your code knows about function prototypes, and such. A library is where the actual object code for those functions are stored.

How you include the library is dependent on the environment you are using. You say you are using Borland. Are you using the Borland IDE, or just the free command-line tools? If the IDE, there should be some menu setting for including libraries in the project. If the command-line tools, you will have to use a compiler setting to tell the compiler to include that library.

I don't remember for sure, but I think Borland also supported adding a line like so:

#pragma comment(lib, "glaux.lib")

I_NeedHelp
01-15-2003, 12:34 AM
Ok. Sorted it out. Added that line of code and didn't work BUT (and thats a big butt) when i got an up-to-date version of the glaux library (from nehe's tut 6 borland download) everyting snapped in2 place. Thanks for all the help