开发者

Problem with OpenGL texturing when using core profile

开发者 https://www.devze.com 2023-02-06 21:52 出处:网络
my problem is that, when using glutInitContextProfile(GLUT_CORE_PROFILE) instead of glutInitContextProfile(GLUT_COMPATIBILITY_PROFILE) the textured areas just stay black.

my problem is that, when using glutInitContextProfile(GLUT_CORE_PROFILE) instead of glutInitContextProfile(GLUT_COMPATIBILITY_PROFILE) the textured areas just stay black. (just to emphasize that: with compatibility profile, everything works the way i expect it to)

I'm loading my textures with DevIL, usually with ilutGLLoadImage(filename), because i wasn't sure if the tex parameters are set correctly by DevIL, i also load some textures with that code:

    ILuint img;
 ilGenImages(1, &img);
 ilBindImage(img);
 ILboolean ret = false;
 if((ret = ilLoadImage("...jpg"))){
  ret = ilConvertImage(IL_RGBA, IL_UNSIGNED_BYTE);
  if(!ret){
   std::cout << "image conversion failed" << std::endl;
  }

  glGenTextures(1, &texture[20]);
  glBindTexture(GL_TEXTURE_2D, texture[20]);
  glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
  glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
  glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT);
  glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);
  /*char imageData[27] = {
   127, 127, 127,
   127, 127, 127,
   127, 127, 127,
   127, 127, 127, 
   127, 127, 127,
   127, 127, 127,
   127, 127, 127,
   127, 127, 127,
   127, 127, 127,
  };*/
  //glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 3, 3, 0, GL_RGB, GL_UNSIGNED_BYTE, imageData);

  glTexImage2D(GL_TEXTURE_2D, 0, ilGetInteger(IL_IMAGE_BPP), ilGetInteger(IL_IMAGE_WIDTH),
       ilGetInteger(IL_IMAGE_HEIGHT), 0, ilGetInteger(IL_IMAGE_FORMAT), GL_UNSIGNED_BYTE,
       ilGetData());
 }
 else{
  std::cout << "image file not found" << std::endl;
 }
 ilDeleteImages(1, &img);

I tested different tex-parameters without success, with those used, there should at least be no mipmapping related problems involved. When i use the commented part with the imagedata-array, everything works fine, so i guess there is no problem with the binding, drawing and shading. If you think there could arise problems with that signature, i will post more code.

I know that, with core profile, textures can开发者_如何学C be considered "incomplete" for some reasons but i just can't find why that should happen. I'm not getting any errors, neither from DevIL nor from OpenGL.

Thanks for helping.


You should check for GL errors, ilGetInteger(IL_IMAGE_BPP) returns the number of bytes per pixel, which is NOT a internal format enum value. Use a enumeration such as GL_RGB or GL_RGBA instead. That was valid in the compatibility profile, but is not in the core profile.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号