Advertisement

3D Exploration

Started by May 13, 2000 10:40 AM
33 comments, last by Kelvin Big 24 years, 6 months ago
Hi Pentode,

Thanks much for your reply. I did neglect to place the 3dExploration generated *bmp files in the project folder when I created the app with the second 3dExploration download, but when I did include them, I was back to square one with the Illegal Operation error.

As long as those *.bmp files are not in the directory, my app runs fine but the object is rendered without any texture.

I have a feeling it has to do with my trying to use the "Sample App" code generated by 3dExploration instead of the "Display List" or "Data" export options.

Can you tell me which option you are using and any other info you might add associated with the Kevin Big which seemed to solve his problems based on your suggestions.

Thanks again for all your help.

Karl

karl@hsnp.com

KarlFisher
KarlFisher
I''ve used SAMPLE APP option with the code he provided as well as some of my own!

KB

quote: Original post by karl

Hi Pentode,

Thanks much for your reply. I did neglect to place the 3dExploration generated *bmp files in the project folder when I created the app with the second 3dExploration download, but when I did include them, I was back to square one with the Illegal Operation error.

As long as those *.bmp files are not in the directory, my app runs fine but the object is rendered without any texture.

I have a feeling it has to do with my trying to use the "Sample App" code generated by 3dExploration instead of the "Display List" or "Data" export options.

Can you tell me which option you are using and any other info you might add associated with the Kevin Big which seemed to solve his problems based on your suggestions.

Thanks again for all your help.

Karl

karl@hsnp.com

KarlFisher


DKC
Advertisement
Hi Kelvin,

Thanks for your help, but I still get the same result. If I
put the 3DExploration generated *.bmp file in the project directory and/or the debug directory, I receive the Illegal Operation error when my app runs. If I delete the 3dExploration generated *.bmp file the app runs fine but no texture on the object.

Is it possible that you have a different version than either the versions I have.

The first one I got is Version 1.25 and the one that was recommended when I e-mailed support is Version 1.3.00 Beta May 4 2000.

They both do the same thing.

Would it be possible for you to send me the 3dExploration app that you are using?

Thanks much

Karl

karl@hsnp.com

KarlFisher
KarlFisher
Hmmm. I attempted to use a sample app with a texture as well, and I get an assertion failure in debug mode.. Which translates to an illegal operation in normal modes. I think this is generally just a problem with the code that 3D Exploration exports. The same thing happens when I attempt to load the GL data file with my own source.. Loop + Meterial stuff, etc. I''m going to look into it further, and see if I can figure it out.. I''ll keep you posted.
I whipped up some code, and I got the texture coords down, and textures applied perfectly from the exported cpp files from 3D Exploration.. If either of you guys are interested, I''d be more then happy to share the code with you. Just let me know here. Don''t e-mail me, btw. That address no longer works.
Nevermind, I know you guys want it anyway. So here it is:


Stick these functions somewhere first, they''re going to load your textures, and set up the filtering, etc.

AUX_RGBImageRec *LoadBMP(char *filename) {

FILE *File=NULL;

if(!filename) {
return NULL;
}

File = fopen(filename,"r");
if(File) {
fclose(File);
return auxDIBImageLoad(filename);
}

return NULL;
}

int LoadTextures() {

int status = FALSE;

AUX_RGBImageRec *TextureImage[1];
memset(TextureImage,0,sizeof(void *)*1);
/*put whatever file name you need, here.*/
if(TextureImage[0]=LoadBMP("3dexMod_0.bmp")) {
status = TRUE;
glGenTextures(3,&texture[0]);


glBindTexture(GL_TEXTURE_2D,texture[2]);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);
gluBuild2DMipmaps(GL_TEXTURE_2D,3,TextureImage[0]->sizeX,
TextureImage[0]->sizeY,GL_RGB,GL_UNSIGNED_BYTE,
TextureImage[0]->data);
}

if(TextureImage[0]) {
if(TextureImage[0]->data) {
free(TextureImage[0]->data);
}
free(TextureImage[0]);
}
return status;
}

Ok, don''t forget to add: glEnable(GL_TEXTURE_2D); in your InitGL function.

And also, add:

if(!LoadTextures()) {
return FALSE;
}
To the very top of your InitGL function.

Ok, now in your main GL rendering function, after all your pre-drawing functions are called, put this as thow you were normally rendering some sort of object in there:

glBindTexture(GL_TEXTURE_2D, texture[2]);

glBegin(GL_TRIANGLES);

for(int i = 0; i
mcount--;
for(int j = 0; j < 3; j++) {
int vi=face_indicies[j];
int ni=face_indicies[j+3];<br> int ti=face_indicies[j+6];<br> glNormal3f(normals[ni][0],normals[ni][1],normals[ni][2]);<br> glTexCoord2f(textures[ti][0],textures[ti][1]);<br> glVertex3f(verticies[vi][0],verticies[vi][1],verticies[vi][2]);<br> }<br> }<br><br> glEnd();<br><br><br>Also, define "GLuint texture[3];" somewhere at the top of your source file.. if you export data only in 3D Exploration, and rename the file to a header file, then include it to your main source file, this should work good. <br><br>Good luck.<br> </i>
Advertisement
That first loop line got cut off, heres the entire thing..
Sorry about that.


for(int i = 0; i <sizeof(face_indicies)/sizeof(face_indicies[0]);i++) {
for(int i = 0; i < sizeof(face_indicies)/sizeof(face_indicies[0]);i++) {
Hi Pentode,

I would like to express many thanks to you for the kind help and sample code, without which I would not have been able to get my app to work with texturing using the 3dExplorer model export.

Thanks also to Kelvin Big for the moral support provided by his saying he had got it to work. I was about to give up until I read his post.

I have been using DirectX since version 2, but I noticed so much interest in OpenGL, I felt I had to give it a try.

You and the great tutorials from NEHE have given me the confidence to continue to learn more about OGL.

Thanks again

Karl

Karl Fisher
Hot Springs Village, Arkansas

karl@hsnp.com



KarlFisher
KarlFisher
I did not asked the help from Pentode to use textures in
my SAMPLE APP only the how to load it to use it in my own application! The tutorials on from NEHE has done the texture part as well as some books on OPENGL programming I''ve bought form Amazon for me!

I''m just not a PRO in coding but a starter as most of us
here, I''m glad that Pentode could help you out. Note that
some of the things he explained can be found at the tutorial section on OPENGL.ORG as well!

Kelvin Big
Netherlands

This topic is closed to new replies.

Advertisement