problem with loading HDR image using pbrt

This is a discussion on problem with loading HDR image using pbrt within the C++ Programming forums, part of the General Programming Boards category; Hi everyone I'm trying to load an HDR image into my program using pbrt libaray( 3rdparty), I include the associated ...

  1. #1
    Registered User
    Join Date
    Feb 2012
    Posts
    5

    problem with loading HDR image using pbrt

    Hi everyone
    I'm trying to load an HDR image into my program using pbrt libaray( 3rdparty), I include the associated libraries in "Additional include directories" of my solution. I'm using visual studio 2010. here is my code to load the image:

    [B]
    Code:
    bool loadTexture(const char *path)
    {
    Imf::Rgba * pixelBuffer;
    GLuint width;
    GLuint height;
    try
    {
    Imf::RgbaInputFile in(path);
    
    Imath::Box2i win = in.dataWindow();
    width = win.max.x - win.min.x+1;
    height = win.max.y - win.min.y+1;
    Imath::V2i dim(win.max.x - win.min.x + 1,
    win.max.y - win.min.y + 1);
    
    pixelBuffer = new Imf::Rgba[dim.x * dim.y];
    
    
    int dx = win.min.x;
    int dy = win.min.y;
    
    int order = in.lineOrder();
    
    in.setFrameBuffer(pixelBuffer - dx - (dy * dim.x), 1, dim.x);
    in.readPixels(win.min.y, win.max.y);
    }
    catch(Iex::BaseExc & e)
    {
    std::cerr << e.what() << std::endl;
    
    delete[]pixelBuffer;
    return false;
    }
    //GLuint texture;
    glGenTextures(1, &texture);
    glBindTexture(GL_TEXTURE_2D /*GL_TEXTURE_RECTANGLE*/, texture);
    
    glTexParameteri(GL_TEXTURE_2D , GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D , GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D , GL_TEXTURE_WRAP_S, GL_CLAMP);
    glTexParameteri(GL_TEXTURE_2D , GL_TEXTURE_WRAP_T, GL_CLAMP);
    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
    
    glTexImage2D(GL_TEXTURE_2D , 0, GL_RGBA16F, width, height, 0, GL_RGBA, GL_HALF_FLOAT, pixelBuffer);
    
    delete[]pixelBuffer;
    return true;
    
    
    }
    I got this linking errors:
    error LNK1120:7 unresoved externals
    error LNK2019:unresoved external symbol "int_cdecl Imf::globalTreadCount(void)(?globalTreadCount@Imf@ @yahXZ)refrenced in function "bool_cdeclloadTexture(char const*)"(?loadTexture@@YA_NPBD@Z)
    And 4 more linker errors like this.

    Thanks in advance!
    Last edited by Salem; 02-17-2012 at 10:30 AM. Reason: Removed a crap-load of useless tags

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,494
    > I include the associated libraries in "Additional include directories" of my solution.
    That only tells the compiler where to find include files.

    There is an equivalent "Additional library directories" as well for the linker.
    Here, you specify where to look, and the name(s) of the libraries you want to link with.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    May 2010
    Posts
    2,708
    I'm trying to load an HDR image into my program using pbrt libaray( 3rdparty), I include the associated libraries in "Additional include directories" of my solution.
    The Additional include directories is only providing the compiler with the location of the include files. You still need to tell the linker to link with your library.

    Jim

  4. #4
    Registered User
    Join Date
    Feb 2012
    Posts
    5
    I did that too but I still have the same linker errors!!

  5. #5
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,300
    Look at the Command Line for the linker options to confirm that it is pointing at the right directory.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  6. #6
    Registered User
    Join Date
    May 2010
    Posts
    2,708
    How did you compile the external library? You also need the OpenEXR library.

    Edit: Also, it looks it requires Cygwin.

    Jim
    Last edited by jimblumberg; 02-17-2012 at 11:23 AM.

  7. #7
    Registered User
    Join Date
    Feb 2012
    Posts
    5
    pbrt contains the OpenEXR library! I uploaded my source code . here is the link: http://www.4shared.com/rar/VWHYOCl5/testloadmesh1.html

  8. #8
    Registered User
    Join Date
    May 2010
    Posts
    2,708
    Okay, the latest version does not require OpenEXR, nor Cygwin. Did you compile and install the pbrt library using the VC-2010 solution file included with the source?

    Jim

  9. #9
    Registered User
    Join Date
    Feb 2012
    Posts
    5
    I didn't compile the library, It was compiled before, you can find the compiled libraries in 3rdparty folder!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Loading image from Resource
    By parad0x13 in forum C++ Programming
    Replies: 1
    Last Post: 03-15-2009, 10:36 PM
  2. Loading & displaying an image
    By csonx_p in forum Windows Programming
    Replies: 1
    Last Post: 06-19-2008, 06:40 AM
  3. Loading an image into memory using OpenGL
    By Kaelin in forum C++ Programming
    Replies: 3
    Last Post: 02-08-2005, 11:03 AM
  4. Image class - loading image file
    By GaPe in forum Windows Programming
    Replies: 2
    Last Post: 07-11-2004, 01:35 PM
  5. Image Loading Troubles
    By frenchfry164 in forum C++ Programming
    Replies: 3
    Last Post: 11-02-2003, 12:07 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21