Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Texture Question using DevIL

  1. #1
    Junior Member Newbie
    Join Date
    Mar 2002
    Location
    washington, dc
    Posts
    7

    Texture Question using DevIL

    Hello,
    I am trying to wrap a texture around a sphere. I was able to follow the tutorial on http://home.clara.net/paulyg/ogl.htm to load the texture of the earth in .raw form. However, the image I want to use is a jpg, so I downloaded DevIL. I think that I am loading the texture correctly because I am not getting any errors. But my sphere is turning out black. Here is my code:

    Code :
       GLuint  texture[1]; 
     
       ilInit();
       iluInit();
       ilutInit();
     
       ilutRenderer(ILUT_OPENGL);
       ilLoadImage(file_name);
       texture[0] = ilutGLBindTexImage();
     
       glPushMatrix();
       glColor4f(1.0, 1.0, 1.0, 1.0 );
       glBindTexture(GL_TEXTURE_2D, texture[0]);   // Select Our Texture
       glEnable(GL_TEXTURE_2D);
       GLUquadricObj* qobj = gluNewQuadric();
       gluQuadricDrawStyle(qobj, GLU_FILL  );
       gluQuadricNormals  (qobj, GLU_SMOOTH);
       gluQuadricTexture  (qobj, GL_TRUE   );
       gluSphere(qobj, Radius, 50, 50);
       gluDeleteQuadric(qobj);
     
       glPopMatrix();
       glDisable(GL_TEXTURE_2D);
    Thanks for your help,
    Allison

  2. #2

    Re: Texture Question using DevIL

    Generally a good sign that your not setting up textures correctly is when everything goes white. Everything going black is usually a sign that you've set up the lighting wrong. Can't see any lighting stuff in the code you sent. Are you using lights anywhere else?

  3. #3
    Senior Member Regular Contributor
    Join Date
    Sep 2001
    Location
    macedon, ny
    Posts
    288

    Re: Texture Question using DevIL

    Try this, the proper way to set up a devIL image is like this. They way you have it setup might cause some issues.

    ilGenImages(1, &Image);
    ilBindImage(Image);
    ilLoadImage("Image.tga");
    ilutGLBindTexImage();
    ilDeleteImages(1, &Image);

    glBindTexture (GL_TEXTURE_2D, Image);

    also your main loop should resemble this.

    //ilut initialization
    ilInit();

    //glut setup
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
    glutGameModeString(VideoMode);
    glutEnterGameMode();

    //ilut setup for opengl
    ilutRenderer(ILUT_OPENGL);

    //input setup
    //Scene setup
    //continue glut setup
    glutDisplayFunc(RenderScene);
    glutReshapeFunc(ChangeSize);

    //LET IT RIP
    glutMainLoop();

    return 0;

  4. #4
    Junior Member Newbie
    Join Date
    Mar 2002
    Location
    washington, dc
    Posts
    7

    Re: Texture Question using DevIL

    henryj -
    I don't think its the lighting, because I didn't use any.

    dabeav -
    Using the setup for devIL you suggested, my sphere turned white. Any ideas????

    Thanks again,
    Allison

  5. #5
    Senior Member Frequent Contributor
    Join Date
    Oct 2001
    Posts
    595

    Re: Texture Question using DevIL

    is the jpg image in n^2 size?

  6. #6
    Senior Member Regular Contributor
    Join Date
    Sep 2001
    Location
    macedon, ny
    Posts
    288

    Re: Texture Question using DevIL

    Hmm??

    Lets start from square one here. First, what Compiler you using? I know that devIL has to have the Code Generation set to multithreaded dll to work correctly, did you change that setting in the compiler?

    Second, did you add glut to your project.

    Third, how did you set up your devIL image variable, I use ILuint, which maps to a C++ unsinged int. But I stick with the ILuint to keep things portable. ie: ILuint Image;

    Forth, did you set up your main "exactly" like shown?
    ilInit(); HAS to come before glutInit();
    and ilutRenderer(ILUT_OPENGL); has to come after glutInit(); or it wont work at all.

    If this dosnt work, please either post more code, we will get this yet.

    Edit: Oh by the way, i dont think you need these
    iluInit(); ilutInit();

    [This message has been edited by dabeav (edited 06-26-2002).]

  7. #7
    Junior Member Newbie
    Join Date
    Mar 2002
    Location
    washington, dc
    Posts
    7

    Re: Texture Question using DevIL

    Mazy-
    I believe that the image is n^2.

    dabeav-
    I'm using BCB 5. I'm not quite sure how to check the multithreaded dll setting.

    I'm currently in the process of adding glut to my project, its taking me a bit, because I've never used the library before.

    I used ILuint as my image variable.

    So I'll get back to you with more code once I finish adding the glut.

    Allison

  8. #8
    Member Contributor
    Join Date
    Jun 2002
    Location
    Alamogordo, NM USA
    Posts
    67

    Re: Texture Question using DevIL

    Also check the size of image and the memory it will occupy on board. We have images turning black when we exceed the maximum texture size of 4kx4k on our boards (2kx2k on older boards). This also occurs when the total texture memory on the board is exceeded (for instance, loading 2 4K textures).... Remember some boards store 4 bytes per pixel reguardless of image, so 4kx4k (16mb * color components RGBA) would be 64Mb, no room even for rasterization on a 64Mb board. Mipmapping increases texture memory by 4/3. When you exceed a limit, a board/driver has two choices, ignore it, or swap with real memory. Both choices are bad.... Ignoring it often results in black-out textures (especially on Nvidia hardware), swapping generally results in an instant drop to 1/10 frame rate or less. Image size for mip-mapping, I think, is limited to 512x512 max on some boards, so you can only go higher in texture size if you don't use mipmaps (however, that problem, in my experience, is generally characterized by a crash of the program during Mip-map creation and storage). When diagnosing texture problems, I often drop the texture size down to 512x512 or 256x256 for debugging and then step up from there. There are also serious performance problems with textures greater than 1kx1k on pre lightning memory architecture boards (DDR double pumped throughput).

    [This message has been edited by Jeffry J Brickley (edited 06-26-2002).]
    Japanese Proverb: "Talk about things of tomorrow and the mice in the ceiling laugh."

  9. #9
    Senior Member Regular Contributor
    Join Date
    Sep 2001
    Location
    macedon, ny
    Posts
    288

    Re: Texture Question using DevIL

    Ok, I believe Ilut, operates ontop of glut, so you need that atleast initialized in the program. Im not positive, but I think so. Never tried it without. But you do have to figure out how to set the multithreaded DLL setting to your project, thats a biggie, may not be causing your problem currently, but will eventualy. Let me know how things work out for ya.

  10. #10
    Junior Member Newbie
    Join Date
    Mar 2002
    Location
    washington, dc
    Posts
    7

    Re: Texture Question using DevIL

    Thank you to everybody for you help. With a little bit of work and a lot of frustration I was finally able to correct my code and get an error message.

    The line:
    ilLoadImage(file_name)

    always returns false, so I'm checking into that. But, thanks again.
    Allison

Page 1 of 2 12 LastLast

Similar Threads

  1. How make an animated texture? (OpenGL, DevIL, C++)
    By PocketTNT in forum OpenGL: Basic Coding
    Replies: 9
    Last Post: 05-21-2016, 12:53 AM
  2. Memory leak in texture loading with loadImage using Devil
    By opty2001 in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 08-04-2013, 09:39 PM
  3. texture mapping, loading up an image, DevIL
    By annette in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 03-03-2012, 03:12 PM
  4. OpenGL Texture loading using Devil
    By Pan007 in forum OpenGL: Basic Coding
    Replies: 12
    Last Post: 10-06-2011, 01:58 AM
  5. DevIL question
    By kehziah in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 10-01-2001, 08:30 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean