Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/thothbot/parallax/core/client/renderers/WebGLRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -2981,8 +2981,8 @@ public void setTexture( Texture texture, int slot )
getGL().pixelStorei( PixelStoreParameter.UNPACK_ALIGNMENT, texture.getUnpackAlignment() );

Element image = texture.getImage();
boolean isImagePowerOfTwo = Mathematics.isPowerOfTwo( image.getOffsetWidth() )
&& Mathematics.isPowerOfTwo( image.getOffsetHeight() );
boolean isImagePowerOfTwo = Mathematics.isPowerOfTwo( texture.getWidth() )
&& Mathematics.isPowerOfTwo( texture.getHeight() );

texture.setTextureParameters( getGL(), getMaxAnisotropy(), TextureTarget.TEXTURE_2D, isImagePowerOfTwo );

Expand Down Expand Up @@ -3029,6 +3029,10 @@ private CanvasElement createPowerOfTwoImage(Element image)
{
int width = image.getOffsetWidth();
int height = image.getOffsetHeight();
if (width == 0 && height == 0) {
width = image.getPropertyInt("width");
height = image.getPropertyInt("height");
}

CanvasElement canvas = Document.get().createElement("canvas").cast();

Expand All @@ -3055,6 +3059,10 @@ private Element clampToMaxSize ( Element image, int maxSize )
{
int imgWidth = image.getOffsetWidth();
int imgHeight = image.getOffsetHeight();
if (imgWidth == 0 && imgHeight == 0) {
imgWidth = image.getPropertyInt("width");
imgHeight = image.getPropertyInt("height");
}

if ( imgWidth <= maxSize && imgHeight <= maxSize )
return image;
Expand Down
26 changes: 26 additions & 0 deletions src/thothbot/parallax/core/client/textures/Texture.java
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,32 @@ public void setImage(Element image) {
this.image = image;
}

/**
* Gets texture width.
*
* @return the texture width.
*/
public int getWidth() {
int width = image.getOffsetWidth();
if (width == 0) {
width = image.getPropertyInt("width");
}
return width;
}

/**
* Gets texture height.
*
* @return the texture height.
*/
public int getHeight() {
int height = image.getOffsetHeight();
if (height == 0) {
height = image.getPropertyInt("height");
}
return height;
}

/**
* Gets texture offset.
*
Expand Down