@ -1385,7 +1385,7 @@ public class LwjglRenderer implements Renderer {
Texture tex = rb . getTexture ( ) ;
Texture tex = rb . getTexture ( ) ;
Image image = tex . getImage ( ) ;
Image image = tex . getImage ( ) ;
if ( image . isUpdateNeeded ( ) ) {
if ( image . isUpdateNeeded ( ) ) {
updateTexImageData ( image , tex . getType ( ) , tex . getMinFilter ( ) . usesMipMapLevels ( ) , 0 ) ;
updateTexImageData ( image , tex . getType ( ) , 0 ) ;
// NOTE: For depth textures, sets nearest/no-mips mode
// NOTE: For depth textures, sets nearest/no-mips mode
// Required to fix "framebuffer unsupported"
// Required to fix "framebuffer unsupported"
@ -1775,7 +1775,15 @@ public class LwjglRenderer implements Renderer {
}
}
}
}
public void updateTexImageData ( Image img , Texture . Type type , boolean mips , int unit ) {
/ * *
* Uploads the given image to the GL driver .
*
* @param img The image to upload
* @param type How the data in the image argument should be interpreted .
* @param updateMipsOnly If true , then texture data is already updated for this image , only
* @param unit The texture slot to be used to upload the image , not important
* /
public void updateTexImageData ( Image img , Texture . Type type , int unit ) {
int texId = img . getId ( ) ;
int texId = img . getId ( ) ;
if ( texId = = - 1 ) {
if ( texId = = - 1 ) {
// create texture
// create texture
@ -1800,13 +1808,15 @@ public class LwjglRenderer implements Renderer {
statistics . onTextureUse ( img , true ) ;
statistics . onTextureUse ( img , true ) ;
}
}
if ( ! img . hasMipmaps ( ) & & mips ) {
if ( ! img . hasMipmaps ( ) & & i mg . isGeneratedMipma psRequired ( ) ) {
// No pregenerated mips available,
// No pregenerated mips available,
// generate from base level if required
// generate from base level if required
if ( ! GLContext . getCapabilities ( ) . OpenGL30 ) {
if ( ! GLContext . getCapabilities ( ) . OpenGL30 ) {
glTexParameteri ( target , GL_GENERATE_MIPMAP , GL_TRUE ) ;
glTexParameteri ( target , GL_GENERATE_MIPMAP , GL_TRUE ) ;
img . setMipmapsGenerated ( true ) ;
}
}
} else {
} else {
// Image already has mipmaps or no mipmap generation desired.
// glTexParameteri(target, GL_TEXTURE_BASE_LEVEL, 0 );
// glTexParameteri(target, GL_TEXTURE_BASE_LEVEL, 0 );
if ( img . getMipMapSizes ( ) ! = null ) {
if ( img . getMipMapSizes ( ) ! = null ) {
glTexParameteri ( target , GL_TEXTURE_MAX_LEVEL , img . getMipMapSizes ( ) . length - 1 ) ;
glTexParameteri ( target , GL_TEXTURE_MAX_LEVEL , img . getMipMapSizes ( ) . length - 1 ) ;
@ -1871,11 +1881,12 @@ public class LwjglRenderer implements Renderer {
}
}
if ( GLContext . getCapabilities ( ) . OpenGL30 ) {
if ( GLContext . getCapabilities ( ) . OpenGL30 ) {
if ( ! img . hasMipmaps ( ) & & mips & & img . getData ( ) ! = null ) {
if ( ! img . hasMipmaps ( ) & & i mg . isGeneratedMipma psRequired ( ) & & img . getData ( ) ! = null ) {
// XXX: Required for ATI
// XXX: Required for ATI
glEnable ( target ) ;
glEnable ( target ) ;
glGenerateMipmapEXT ( target ) ;
glGenerateMipmapEXT ( target ) ;
glDisable ( target ) ;
glDisable ( target ) ;
img . setMipmapsGenerated ( true ) ;
}
}
}
}
@ -1884,8 +1895,8 @@ public class LwjglRenderer implements Renderer {
public void setTexture ( int unit , Texture tex ) {
public void setTexture ( int unit , Texture tex ) {
Image image = tex . getImage ( ) ;
Image image = tex . getImage ( ) ;
if ( image . isUpdateNeeded ( ) ) {
if ( image . isUpdateNeeded ( ) | | ( image . isGeneratedMipmapsRequired ( ) & & ! image . isMipmapsGenerated ( ) ) ) {
updateTexImageData ( image , tex . getType ( ) , tex . getMinFilter ( ) . usesMipMapLevels ( ) , unit ) ;
updateTexImageData ( image , tex . getType ( ) , unit ) ;
}
}
int texId = image . getId ( ) ;
int texId = image . getId ( ) ;