Coder al azar:
Estoy creando un nuevo motor de juego 2D en lwjgl 3 usando OpenGL para probar lwjgl 3 ya que este es el primer proyecto que estoy usando lwjgl 3 en todos mis otros proyectos han tenido lwjgl 2. Pero cuando me hacen una imagen usando ese nuevo motor todos los colores cambian y algunos ni siquiera aparecen.
Código de texturas de carga
public Texture(String filename){
IntBuffer width = BufferUtils.createIntBuffer(1);
IntBuffer height = BufferUtils.createIntBuffer(1);
IntBuffer comp = BufferUtils.createIntBuffer(1);
ByteBuffer data = stbi_load(filename, width, height, comp, 4);
id = glGenTextures();
this.width = width.get();
this.height = height.get();
glBindTexture(GL_TEXTURE_2D, id);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, this.width, this.height, 0, GL_RGBA, GL_BYTE, data);
stbi_image_free(data);
}
Si usted sabe cómo podría evitar que suceda esto por favor hágamelo saber.
derhass:
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, this.width, this.height, 0, GL_RGBA, GL_BYTE, data); ^^^^^^^
GL_BYTE
es un firmado 8 Bit tipo entero, por lo que todos sus valores> 127 va a terminar siendo interpretado como valores negativos (asumiendo que su plataforma utiliza la representación de dos estándar complemento al menos) y sujetarse a 0.
Sólo uso GL_UNSIGNED_BYTE
.