Results 1 to 3 of 3

Thread: glubuild2dmipmaps segfaults

  1. #1
    Junior Member Newbie
    Join Date
    Feb 2004
    Posts
    9

    glubuild2dmipmaps segfaults

    Hello, i have been porting a small graphics app which i drew in windows to linux and have come across problems when loading textures, the following code causes a segfault when it gets to the mipmaps call (im using a 4 channel image)

    I have used GDB to step through the code but cant see anything wrong with the parameters, what have i done wrong here?

    The width and height parameters are correct and the memory is allocated and read correctly.

    Code :
    void CTexData::LoadFile()
    {
     
    	SDDBData TextureImage;
    	// Load The Bitmap
    	TextureImage=LoadImage(strFileName.c_str());
     
    	cerr << "Loaded image\n";
    	//Create Texture
    	glGenTextures(1, &amp;uiTexture);
     
    	// Create Nearest mipmapped Texture
    	glBindTexture(GL_TEXTURE_2D, uiTexture);
     
    	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
    	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR);
     
    	glPushAttrib(GL_CURRENT_BIT);
     
    	if(!TextureImage.cpData)
    	{
    		cerr << strFileName.c_str() << "\n";
    	}
     
     
     
    	//These functions are segfaulting!! Pointer is not null!
    	if(TextureImage.cChannels ==3) //RGB
    	{
    		gluBuild2DMipmaps(GL_TEXTURE_2D, 3, TextureImage.uiWidth, 
    					TextureImage.uiHeight, GL_RGB, 
    					GL_UNSIGNED_BYTE, TextureImage.cpData);
    	}
     
    	if(TextureImage.cChannels ==4) //RGBA
    	{
    		gluBuild2DMipmaps(GL_TEXTURE_2D, 4, TextureImage.uiWidth, 
    					TextureImage.uiHeight, GL_RGBA, 
    					GL_UNSIGNED_BYTE, TextureImage.cpData);
    	}
     
    	glPopAttrib();
     
    	// Free The Texture Image Memory
    	delete[] TextureImage.cpData;	
    	cerr << "openGL image Funcs called\n";
     
    }
    the backtrace from GDB is this:
    Code :
    #0  0x40370121 in __strtod_internal () from /lib/tls/libc.so.6
    #1  0x402357c6 in __gluTessErrorString ()
       from /usr/X11R6/lib/libGLU.so.1
    if it is important i am using the ATI drivers not Mesa or NVidia

  2. #2
    Junior Member Newbie
    Join Date
    Feb 2004
    Posts
    9

    Re: glubuild2dmipmaps segfaults

    Never mind, solved it. For those who may have a similar problem make sure that you have finished intialising your openGL stuff first

    i moved my load textures routine from before the following code to the end and that solved the problem

    Code :
    //Activate window
    	glXMakeCurrent(dpy, glwin, cx); 
     
    	XMapWindow(dpy, glwin); 
    	XIfEvent(dpy,  &amp;event,  WaitForMapNotify,  (char *)glwin); 
     
    	InitGL(); 
    	Resize(WINDOW_WIDTH, WINDOW_HEIGHT);

  3. #3
    Guest

    Re: glubuild2dmipmaps segfaults

    You can usually call your texture loading function "after" you make the DC cuurent with the RC...which is aftrer you create your pixelformatdescriptor.. Even before your Init function.

    But, maybe Lynux a little different.

Similar Threads

  1. Replies: 2
    Last Post: 06-10-2015, 11:08 AM
  2. OpenCL ICD loader - segfaults on test
    By steve-slicify in forum OpenCL
    Replies: 1
    Last Post: 04-15-2014, 08:52 PM
  3. gluBuild2DMipmaps()
    By devdept in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 08-24-2008, 08:23 AM
  4. gluBuild2DMipmaps?
    By roswell in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 08-10-2008, 12:25 PM
  5. gluBuild2DMipmaps()...
    By Sephiroth in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 01-25-2002, 02:58 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