Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

214
Vistas
LWJGL Assimp: Cargando Texturas

Estoy usando la versión LWJGL 3 de assimp, y me tropecé al cargar un modelo. El problema con el que me encuentro es cargar datos de píxeles reales para texturas. ¿Cuál es el proceso de carga de estas texturas mediante el uso de un objeto AIMaterial?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Cuando hice esto para una prueba de demostración rápida, simplemente usé el Image IO normal de Java. No es tan elegante, pero funciona y podría ponerte en marcha:

 public static ByteBuffer decodePng( BufferedImage image ) throws IOException { int width = image.getWidth(); int height = image.getHeight(); // Load texture contents into a byte buffer ByteBuffer buf = ByteBuffer.allocateDirect( 4 * width * height ); // decode image // ARGB format to -> RGBA for( int h = 0; h < height; h++ ) for( int w = 0; w < width; w++ ) { int argb = image.getRGB( w, h ); buf.put( (byte) ( 0xFF & ( argb >> 16 ) ) ); buf.put( (byte) ( 0xFF & ( argb >> 8 ) ) ); buf.put( (byte) ( 0xFF & ( argb ) ) ); buf.put( (byte) ( 0xFF & ( argb >> 24 ) ) ); } buf.flip(); return buf; }

Donde la imagen fue cargada como parte de otra rutina:

 public Texture(InputStream is) throws Exception { try { // Load Texture file BufferedImage image = ImageIO.read(is); this.width = image.getWidth(); this.height = image.getHeight(); // Load texture contents into a byte buffer ByteBuffer buf = xogl.utils.TextureUtils.decodePng(image); // Create a new OpenGL texture this.id = glGenTextures(); // Bind the texture glBindTexture(GL_TEXTURE_2D, this.id); // Tell OpenGL how to unpack the RGBA bytes. Each component is 1 byte size glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); // Upload the texture data glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, this.width, this.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, buf);
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda