Jump to content
  • Advertisement

Adrian Bibby Walther

  • Content Count

  • Joined

  • Last visited

Community Reputation

112 Neutral

About Adrian Bibby Walther

  • Rank
  1. I have been trying to solve this for some time, but after googling and googling, again ang again. I finally decided to post it here. I use the following code to load a texture into OpenGL, using DevIL: bool CImage::Load(const std::string &File){ Clear(); ILuint Image; ilGenImages(1,&Image); ilBindImage(Image); ilLoadImage(File.c_str()); if(ilGetInteger(IL_IMAGE_ORIGIN) == IL_ORIGIN_LOWER_LEFT) iluFlipImage(); Tex = ilutGLBindTexImage(); Width = ilGetInteger(IL_IMAGE_WIDTH); Height = ilGetInteger(IL_IMAGE_HEIGHT); int W,H; glGetTexLevelParameteriv(GL_TEXTURE_2D,0,GL_TEXTURE_WIDTH,&W); glGetTexLevelParameteriv(GL_TEXTURE_2D,0,GL_TEXTURE_HEIGHT,&H); ilDeleteImages(1,&Image); return Tex != 0; } My problem is that after the texture is loaded, it only has a size of 1*1 ie. one pixel, which it 512 times smaller than the actual image. The pixel is the same color as the top left pixel in the actual image, so I know that some of the data is loaded. If you want you can download the code here, and check it out: [attachment=10879:Engine.zip] PS: I don't know if this fits in this forum. It kind of has to do with OpenGL, and kind of doesn't.
  2. Adrian Bibby Walther

    glTexImage2D does nothing

    This time, errors did appear. I traced (due to the lack of a better word) it back to the SDL OpenGL configuration: I apparently didn't enable SDL_GL_MULTISAMPLEBUFFERS. ~Solved
  3. Adrian Bibby Walther

    glTexImage2D does nothing

    Turns out I only fixed the code for "power of 2"-textures. My graphics card does support GL_ARB_texture_non_power_of_two, and in my other project it worked absolutely fine.
  4. Adrian Bibby Walther

    glTexImage2D does nothing

    After fiddling around with the code for a bit, it appears that I've solved the problem. I don't know what caused it though.
  5. Adrian Bibby Walther

    glTexImage2D does nothing

    wglGetCurrentContext() doesn't return NULL. I don't know if there is more to check than that.
  6. Adrian Bibby Walther

    glTexImage2D does nothing

    Here you go: Clear(); SDL_Surface *Surf = IMG_Load(File.c_str()); if(!Surf) return false; GLenum Mode = GL_RGB; if(Surf->format->BytesPerPixel == 4){ Mode = GL_RGBA; } Width = Surf->w; Height = Surf->h; glGenTextures(1,&Tex); glBindTexture(GL_TEXTURE_2D,Tex); glTexImage2D(GL_TEXTURE_2D,0,Mode,Width,Height,0,Mode,GL_UNSIGNED_BYTE,Surf->pixels); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); int Min,Mag; glGetTexParameteriv(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,&Min); glGetTexParameteriv(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,&Mag); SDL_FreeSurface(Surf); glBindTexture(GL_TEXTURE_2D,0);
  7. Adrian Bibby Walther

    OpenGL glTexImage2D does nothing

    I'm using SDL_image to load textures for my game, I then try to load them into OpenGL using glTexImage2D. Using the following code I've found out, that the problem lies in glTexImage2D, as it simply does nothing. (at least the width and height of the texture remains unchanged) int ID,Width,Height; glGetIntegerv(GL_TEXTURE_BINDING_2D,&ID); glGetTexLevelParameteriv(GL_TEXTURE_2D,0,GL_TEXTURE_WIDTH,&Width); glGetTexLevelParameteriv(GL_TEXTURE_2D,0,GL_TEXTURE_HEIGHT,&Height); std::cout << ID << ": " << Width << "*" << Height << std::endl; The weird thing is that I have another program, and it uses the exact same code, but it works in that program. glGetError returns 0 ie no error. The code loading the texture and all is compiled and linked into a static library, and I have a test project that links with it, so I can see, if the code I've written works or not.
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!