Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Topics - AeroShark333

Pages: [1] 2
Support / Increase number of texture units
« on: July 29, 2020, 06:55:13 pm »
I received a crash from an user with the following stacktrace:
Code: [Select]
  at com.threed.jpct.Logger.log (
  at com.threed.jpct.GL20.checkError (
  at com.threed.jpct.GL20.glGenBuffers (
  at com.threed.jpct.CompiledInstance.compileToVBO (
  at com.threed.jpct.CompiledInstance.render (
  at com.threed.jpct.GLRenderer.drawWireframe (
  at com.threed.jpct.World.draw (
  at com.threed.jpct.World.drawWireframe (
  at com.aeroshark333.artofearthify.lw.ArtOfEarthify$ (
  at com.aeroshark333.artofearthify.utils.WorkerThread$ (
  at com.aeroshark333.artofearthify.lw.ArtOfEarthify.onDrawFrame (
  at com.aeroshark333.artofearthify.lw.LiveWallpaperRenderer.onDrawFrame (
  at android.opengl.GLSurfaceView$GLThread.guardedRun (
  at android.opengl.GLSurfaceView$ (
Any idea what this could be? I've only received this once so maybe it could be ignored...

PS: The question is unrelated to the original thread but I thought the topic title suited... so...

PPS: Although jPCT has Config.maxTextureLayers, the hard limit seems to be 4. Would it be possible to increase this value to 8 (or arbitrary)? Or assign these extra textures using a hack or something? I'd like to be able to access 8 textures in my fragment shader in a single pass

Support / Minor blitshader bug
« on: April 23, 2020, 12:20:58 am »

I believe I've found a minor blitshader bug, it's mostly about the blits that follow (whether these use another blitshader or no blitshader) after you are done using the blitshader in a single draw call.
I do follow the instructions I've read elsewhere on this forums:
It should work. At least I see no reason, why it shouldn't. Just make sure not to do this:

Code: [Select]

That doesn't work, because blits are buffered but the shader isn't. If you need to reset the shader in the process, make sure to execute the blits before. You can force this by blitting a dummy blit from some other texture. Like:

Code: [Select]
fb.blit(...); // <- Dummy-blit (1x1 transparent pixel with some other texture or something)

Now in my case, I use:
Code: [Select]
fb.blit(...); // <- Dummy-blit (1x1 transparent pixel with some other texture or something)
fb.blit(...); // <- Dummy-blit (1x1 transparent pixel with some other texture or something)
fb.blit(...); // <- Dummy-blit (1x1 transparent pixel with some other texture or something)

Every blit using the first shader seems to go fine but once another shader or no shader is used, blitting is kinda broken (not on all devices but most).
- When you blit (after having used the first shader) with no shader, something that doesn't match the original texture you're trying to blit is shown.
- When you blit (after having used the first shader) with another shader, either nothing is shown or the correct result is shown. (50/50 depending on device)
- When you blit (after having used the first shader) with no/another shader AND you used fb.display() before these blits, then the correct result will be shown in all cases.

So it seems that now fb.display() is required if
- you want to keep blitting normally after the first blits with shader
- you want to use another blitshader to blit with
Though, I'm not sure if fb.display() is intended to be used like that


Support / [Tips] Huge texture uploading (memory tricks)
« on: April 03, 2020, 08:52:58 pm »

I have been digging around a little for the memory issues I have concerning texture uploading since I do use pretty huge textures.
It seems that jPCT-AE requires twice the size of a texture (in peak memory usage) in JVM RAM: the original pixeldata of the texture + the buffer used for uploading.
But I believe that on modern day devices you can actually use tricks to consume near nothing in the JVM RAM when loading such huge textures.
I believe jPCT-AE doesn't support these features out of the box because it's been directly ported from the PC version and to provide backwards compatibility with the very old devices.

Here's the class I use to upload textures now (feel free to use it or make your own modifications to it):
Code: [Select]
package com.aeroshark333.artofearthify.utils;

import android.opengl.GLES20;
import android.opengl.GLUtils;

import com.threed.jpct.RGBColor;
import com.threed.jpct.Texture;

// Created by Abiram/AeroShark333
public class CustomTexture extends Texture {
    final Bitmap bmp;

    public CustomTexture(Bitmap image) {
        super(2, 2, RGBColor.BLACK);
        this.bmp = image;

    public int loadTexture(final boolean forceNearest, final boolean keepInMemory){
        final int[] textureHandle = new int[1];

        GLES20.glGenTextures(1, textureHandle, 0);

        if (textureHandle[0] != 0)
            // Bind to the texture in OpenGL
            GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureHandle[0]);

            // Set filtering
            if (!forceNearest) {
                GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);
                GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
            }else {
                GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_NEAREST);
                GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_NEAREST);

            // Load the bitmap into the bound texture.
            GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bmp, 0);

            // Recycle the bitmap, since its data has been loaded into OpenGL.
            if (!keepInMemory) {

        if (textureHandle[0] == 0)
            throw new RuntimeException("Error loading texture.");

        return textureHandle[0];

One could use the CustomTexture constructor from any Thread but the CustomTexture#loadTexture(boolean,boolean) method needs to be called from the GLThread.
This implementation is kinda very simple and it doesn't cover all of jPCT-AE's texture features (and it probably isn't really (easily) possible to have texture manipulation/effects like jPCT-AE supports them out of the box). However, the uploading process seems much faster using this method too. Also, this could potentially solve memory issues if you have them.

Now, I did say you could use near nothing in JVM RAM, so what about the Bitmap that is passed to this CustomTexture?
Well, as since Android 8.0, you can load Bitmap's immediately into the hardware-level (probably GPU..?), meaning that the Bitmap is not stored in the JVM RAM.
That is if you use Bitmap.Config.HARDWARE when you decode your image file (from resources, online of file):
Unfortunately, jPCT-AE does not seem to support Bitmap's that have been created using this Config, because of the immutability and inaccessibility of the Bitmap pixels.
However, but the CustomTexture class would work with Bitmap's that are using this Config.

I hope this could be useful for someone someday.
Feel free to give your thoughts and ideas :)


Support / Object3D generating issue
« on: July 23, 2018, 06:05:48 pm »

I've been trying to create some code to generate a geosphere/icosphere, I got somewhere but the results aren't exactly perfect.
Issue 1: UV mapping still does not seem perfect (especially around the top and bottom, where texCoord.y is around 0.0 or 1.0) but around the middle (0.5) all seems fine
Issue 2: I seem to get black polygons on some devices (but I don't get these black polygons on an emulator..?)

The code till now (it's not really optimized yet since I ported most of the code from some C# code:
Code: [Select]
private class TriangleIndices {
public int v1;
public int v2;
public int v3;

public TriangleIndices(int v1, int v2, int v3) {
this.v1 = v1;
this.v2 = v2;
this.v3 = v3;

private ArrayList<SimpleVector> vertexData;
private ArrayList<Integer> vertexDataIndices;
private int index;
private Map<Long, Integer> middlePointIndexCache;

// add vertex to mesh, fix position to be on unit sphere, return index
private int addVertex(SimpleVector p) {
// 0.5 is a scale factor here...
double length = Math.sqrt(p.x * p.x + p.y * p.y + p.z * p.z) / 0.5;
vertexData.add(new SimpleVector(p.x / length, p.y / length, p.z
/ length));
return index++;

// return index of point in the middle of p1 and p2
private int getMiddlePoint(int p1, int p2) {
// first check if we have it already
boolean firstIsSmaller = p1 < p2;
long smallerIndex = firstIsSmaller ? p1 : p2;
long greaterIndex = firstIsSmaller ? p2 : p1;
long key = (smallerIndex << 32) + greaterIndex;

if (middlePointIndexCache.containsKey(key)) {
int ret = this.middlePointIndexCache.get(key);
return ret;

// not in cache, calculate it
SimpleVector point1 = this.vertexData.get(p1);
SimpleVector point2 = this.vertexData.get(p2);
SimpleVector middle = new SimpleVector((point1.x + point2.x) / 2.0,
(point1.y + point2.y) / 2.0, (point1.z + point2.z) / 2.0);

// add vertex makes sure point is on unit sphere
int i = addVertex(middle);

// store it, return index
this.middlePointIndexCache.put(key, i);
return i;

public Object3D create(int recursionLevel) {
this.vertexData = new ArrayList<SimpleVector>();
this.vertexDataIndices = new ArrayList<Integer>();
this.middlePointIndexCache = new HashMap<Long, Integer>();
this.index = 0;

// create 12 vertices of a icosahedron
float t = (float) ((1.0f + Math.sqrt(5.0f)) / 2.0f);

addVertex(new SimpleVector(-1, t, 0));
addVertex(new SimpleVector(1, t, 0));
addVertex(new SimpleVector(-1, -t, 0));
addVertex(new SimpleVector(1, -t, 0));

addVertex(new SimpleVector(0, -1, t));
addVertex(new SimpleVector(0, 1, t));
addVertex(new SimpleVector(0, -1, -t));
addVertex(new SimpleVector(0, 1, -t));

addVertex(new SimpleVector(t, 0, -1));
addVertex(new SimpleVector(t, 0, 1));
addVertex(new SimpleVector(-t, 0, -1));
addVertex(new SimpleVector(-t, 0, 1));

// create 20 triangles of the icosahedron
List<TriangleIndices> faces = new ArrayList<TriangleIndices>();

// 5 faces around point 0
faces.add(new TriangleIndices(0, 11, 5));
faces.add(new TriangleIndices(0, 5, 1));
faces.add(new TriangleIndices(0, 1, 7));
faces.add(new TriangleIndices(0, 7, 10));
faces.add(new TriangleIndices(0, 10, 11));

// 5 adjacent faces
faces.add(new TriangleIndices(1, 5, 9));
faces.add(new TriangleIndices(5, 11, 4));
faces.add(new TriangleIndices(11, 10, 2));
faces.add(new TriangleIndices(10, 7, 6));
faces.add(new TriangleIndices(7, 1, 8));

// 5 faces around point 3
faces.add(new TriangleIndices(3, 9, 4));
faces.add(new TriangleIndices(3, 4, 2));
faces.add(new TriangleIndices(3, 2, 6));
faces.add(new TriangleIndices(3, 6, 8));
faces.add(new TriangleIndices(3, 8, 9));

// 5 adjacent faces
faces.add(new TriangleIndices(4, 9, 5));
faces.add(new TriangleIndices(2, 4, 11));
faces.add(new TriangleIndices(6, 2, 10));
faces.add(new TriangleIndices(8, 6, 7));
faces.add(new TriangleIndices(9, 8, 1));

// refine triangles
for (int i = 0; i < recursionLevel; i++) {
List<TriangleIndices> faces2 = new ArrayList<TriangleIndices>();
for (TriangleIndices tri : faces) {
// replace triangle by 4 triangles
int a = getMiddlePoint(tri.v1, tri.v2);
int b = getMiddlePoint(tri.v2, tri.v3);
int c = getMiddlePoint(tri.v3, tri.v1);

faces2.add(new TriangleIndices(tri.v1, a, c));
faces2.add(new TriangleIndices(tri.v2, b, a));
faces2.add(new TriangleIndices(tri.v3, c, b));
faces2.add(new TriangleIndices(a, b, c));
faces = faces2;

// done, now add triangles to mesh
for (TriangleIndices tri : faces) {

Object3D obj = new Object3D(vertexDataIndices.size() / 3);

for (int c = 0; c < (vertexDataIndices.size() / 3); c++) {

final SimpleVector aa = vertexData
.get(vertexDataIndices.get(c * 3));
final SimpleVector aaP = cartesianToPolar(aa, true);
final SimpleVector bb = vertexData.get(vertexDataIndices
.get(c * 3 + 1));
final SimpleVector bbP = cartesianToPolar(bb, true);
final SimpleVector cc = vertexData.get(vertexDataIndices
.get(c * 3 + 2));
final SimpleVector ccP = cartesianToPolar(cc, true);

// texture corrections...
if (Math.abs(aaP.z - bbP.z) > 0.5f) {
if (Math.abs(aaP.z - ccP.z) > 0.5f) {
if (Math.abs(bbP.z - ccP.z) > 0.5f) {

obj.addTriangle(aa, aaP.z, aaP.y, bb, bbP.z, bbP.y, cc, ccP.z,

return obj;

public static SimpleVector cartesianToPolar(SimpleVector cartesian,
boolean normalize) {
if (normalize) {
return new SimpleVector(
1.0 - (Math.acos(cartesian.y / cartesian.length()) / Math.PI),
1.0 - (Math.atan2(cartesian.x, cartesian.z) + Math.PI / 2.0)
/ (Math.PI * 2.0) );
return new SimpleVector(cartesian.length(), Math.acos(cartesian.z
/ cartesian.length()), Math.atan2(cartesian.y, cartesian.x));


Any idea what I'm doing wrong here?

Support / Camera rotation issue
« on: July 14, 2018, 01:34:13 pm »

I got a small issue with camera rotations.
My camera automatically rotates around a spherical object like this:
1. Set camera position to center of sphere.
2. Apply rotations
3. Camera.MOVE_OUT
This all works fine but after a long while (let's say 8+ hours) the rotation around the sphere don't seem spherical any more (or the rotation pivot center has some offset).
But the spherical object that the camera is facing isn't in the center any more but slightly offset. The longer you wait the worse this offset gets.
I suppose it'd have to do something with floating point precision but I'm not sure.
Any solutions?


Support / Calculate visibility of an Object3D
« on: December 20, 2017, 08:00:22 pm »

My problem is the following.
Let's say I have 2 Object3D's and one camera.
Object1 is drawn first using FOV setting 1.
Object2 is drawn after using FOV setting 2.
Both objects are sphere's (if that's helpful information)
A part of Object1 is 'blocked' by Object2 (which is fine since Object2 is closer to the camera anyway).

How can I calculate if Object1 is blocked or if it is visible?
And if Object1 is a complex Object3D how can I calculate what percentage of the total of Object1 is visible?

In the past I was able to calculate if Object1 was visible or not using sine, but in that case FOV1 = FOV2. (see sketch)
Now that the FOV's are different, it doesn't work.


Support / OpenGLES 3.0+
« on: November 14, 2017, 05:30:46 pm »

I have some questions regarding the OpenGLES version that jPCT supports or can support.
-> Will OpenGLES 3.0 be supported any time soon by jPCT-AE?
-> Will OpenGLES 3.1 be supported any time soon by jPCT-AE?
-> Will OpenGLES 3.2 be supported any time soon by jPCT-AE?
-> Since OpenGLES 3.0 is backwards compatible, wouldn't it be possible to render applications that now use OpenGLES2.0 using OpenGLES3.0 with some performance increase without changing too much to the jPCT-AE libary?


Support / Crash (native)
« on: July 10, 2017, 07:29:06 pm »

There are some issues with my app on some devices and I don't really know what's causing it...
Code: [Select]
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: 'motorola/surnia_retbr_dstv/surnia_udstv:6.0/MPI24.65-39-4/3:user/release-keys'
Revision: 'p30d'
ABI: 'arm'
pid: 4182, tid: 4448, name: GLThread 17896  >>> com.aeroshark333.artofearthify <<<
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0xa336f000
    r0 a336dab0  r1 a336dd10  r2 00000190  r3 a336efec
    r4 00000654  r5 9daa3d00  r6 a336e9b8  r7 a336e364
    r8 00000208  r9 00000000  sl 00000004  fp 00000000
    ip 00000020  sp a1c05528  lr a336edac  pc ac7a5396  cpsr 200f0030

    #00 pc 000bc396  /system/vendor/lib/egl/ (oxili_tile_texture+637)
    #01 pc 000917a3  /system/vendor/lib/egl/
    #02 pc 000935c9  /system/vendor/lib/egl/ (rb_texture_update_hw_subimage+4204)
    #03 pc 000949d7  /system/vendor/lib/egl/ (rb_texture_loadimage+224)
    #04 pc 0006e6b9  /system/vendor/lib/egl/ (TexImageLoad+216)
    #05 pc 0006e933  /system/vendor/lib/egl/ (core_glTexImage2D+234)
    #06 pc 0004cd3b  /system/vendor/lib/egl/ (glTexImage2D+50)
    #07 pc 0006b5cf  /system/lib/
    #08 pc 02d6f84d  /system/framework/arm/boot.oat (offset 0x1feb000)
Code: [Select]
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: 'motorola/surnia_retbr_dstv/surnia_udstv:6.0/MPI24.65-39-4/3:user/release-keys'
Revision: 'p30d'
ABI: 'arm'
pid: 3892, tid: 4136, name: GLThread 17925  >>> com.aeroshark333.artofearthify <<<
signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0x9fa331a8
    r0 9fa32500  r1 9fa32520  r2 00000190  r3 9fa337fc
    r4 00000654  r5 9f386e00  r6 9fa331a8  r7 9fa32b74
    r8 0000014c  r9 00000000  sl 00000004  fp 00000000
    ip 00000032  sp a02ff528  lr 9fa337fc  pc ac7a538e  cpsr 800f0030

    #00 pc 000bc38e  /system/vendor/lib/egl/ (oxili_tile_texture+629)
    #01 pc 000917a3  /system/vendor/lib/egl/
    #02 pc 000935c9  /system/vendor/lib/egl/ (rb_texture_update_hw_subimage+4204)
    #03 pc 000949d7  /system/vendor/lib/egl/ (rb_texture_loadimage+224)
    #04 pc 0006e6b9  /system/vendor/lib/egl/ (TexImageLoad+216)
    #05 pc 0006e933  /system/vendor/lib/egl/ (core_glTexImage2D+234)
    #06 pc 0004cd3b  /system/vendor/lib/egl/ (glTexImage2D+50)
    #07 pc 0006b5cf  /system/lib/
    #08 pc 02d6f84d  /system/framework/arm/boot.oat (offset 0x1feb000)

The device is a Motorola Moto E with 4G (2nd Gen) running Android 6.0.
I can't reproduce this crash myself on any of my devices.

Projects / Art of Earthify (3D live wallpaper)
« on: May 28, 2017, 02:34:19 am »
Hey everyone,

I wanted to share my newest live wallpaper I made using this library! :)
The live wallpaper is actually based on a previous live wallpaper I made but I was not really satisfied with the result there.
I didn't work on this project too much due to studies but when I had some free time I'd be working on this.
Anyhow, I am really satisfied with the outcome of how it is now. :D

Original project:,4784.0.html (I just noticed all these dead links but I blame DropBox for that... ::) )

Screenshot 1:
Screenshot 2:
Screenshot 3:
Screenshot 4:
Screenshot 5:
Screenshot 6:

Download link:

I'd like to thank 'Egon Olsen' as always for the amazing library :)

Feel free to comment :)


Support / Could not link shader program error
« on: April 30, 2017, 02:35:00 pm »

I have a weird crash that I can't really explain since the logs don't give me enough information nor does the error stacktrace...
Code: [Select]
java.lang.RuntimeException: [ 1493390702610 ] - ERROR: Could not link shader program:
at com.threed.jpct.Logger.log(
at com.threed.jpct.GLSLShader.createProgram(
at com.threed.jpct.GLSLShader.loadProgram(
at com.threed.jpct.GLSLShader.preInit(
at com.threed.jpct.GL20.setShader(
at com.threed.jpct.GLRenderer.setShader(
at com.threed.jpct.CompiledInstance.render(
at com.threed.jpct.GLRenderer.drawVertexArray(
at com.threed.jpct.World.draw(
at com.threed.jpct.World.draw(
at com.aeroshark333.artofearthify.lw.LiveWallpaperRenderer.onDrawFrame(
at android.opengl.GLSurfaceView$GLThread.guardedRun(
at android.opengl.
I am using custom shaders and they do seem to work fine on most devices...
The only device that gave me this error happens to be my brother's phone (Samsung Galaxy S3 mini).
It works fine on my phone and enough other phones, however...

Thanks in advance :)

Support / Why does jPCT-AE need to keep the texture in the VM memory?
« on: December 01, 2016, 04:59:09 am »

Well I guess the title explains all...
I wondered because when textures get uploaded to the GPU (even when pixeldata is kept so it should be safe for any context change) why does it still need the texture data in the VM memory?

Is it possible to not have the textures in VM memory but uploaded to the GPU only?


Projects / Earthify 3D
« on: October 20, 2016, 12:16:45 am »
Hello everyone,

I would like to share my live wallpaper app here which I made using some amazing 3D engine called jPCT-AE! :D

This app has been out for a while now actually but I never really published it here because it's actually still not finished...
I decided to publish it already so people can already use/enjoy the live wallpaper.
I'm really proud of my work although it's probably not nearly the best live wallpaper out there.
That's not my aim either but I guess I'm a little of a perfectionist so I will try to keep improving it.

I'm not really a programmer, it's just an hobby for me. (I have a busy life as an Applied Physics student so I don't spend that much time on programming)
This is not my first app using this library, my most popular app is Skin Viewer 3D (in my forum signature) which is more than a year old now already.
The GLSL Shader language was rather new to me when I began this project but I managed to learn it a little from examples mainly! :)
The custom shaders are based on the default shaders but they have mainly be written by myself (and with a lot of help from the internet/Google).
My biggest problem is probably to support a large range of devices since I'm not really able to test on a lot of devices myself.

What I like most about my own live wallpaper is that it is very customizable.
And it's quite funny to see how the live wallpaper changed over the passed few months.
I tried my best to optimize the wallpaper as much as possible to reduce battery usage...
(usually people say Live Wallpapers are battery consuming but in my opinion it just depends HOW you use your live wallpaper... if you're playing with it constantly on your homescreen then it sort of makes sense to me I guess)
Not all features of the app work properly yet but I'm still working on that.


Google Play Store link:

Special thanks:
EgonOlsen - For making this amazing 3D library and for providing quick support on the forums! :)

Feel free to comment! :)


Support / Strange Fatal Error
« on: October 08, 2016, 08:10:11 pm »

So I've been trying to develop a new app, though I have just one major issue with it...

Code: [Select]
10-08 17:52:19.684: W/google-breakpad(18652): ### ### ### ### ### ### ### ### ### ### ### ### ###
10-08 17:52:19.684: W/google-breakpad(18652): Chrome build fingerprint:
10-08 17:52:19.684: W/google-breakpad(18652): 3.8
10-08 17:52:19.684: W/google-breakpad(18652): 16
10-08 17:52:19.684: W/google-breakpad(18652): ### ### ### ### ### ### ### ### ### ### ### ### ###
10-08 17:52:19.684: A/libc(18652): Fatal signal 11 (SIGSEGV), code 2, fault addr 0x749c3000 in tid 21230 (GLThread 3696)

So the app starts fine and the camera basically starts facing in the direction of the sunlight.
However, whenever I turn the camera (using touch or autorotation) towards the sun, the app simply just crashes However, it will not always crash...
So I tried using less objects and lower resolution textures.
Both seemed to have a small impact on the chance of this crash to happen.
However, disabling jPCT's LensFlare in my app seemed to fix the whole problem.
But, disabling most objects (and prevent their textures from being loaded) seemed to fix the problem as well.
Having both enabled just does not always work. (Maybe it will work 1 in 10 times, and once it does work, it won't crash when you look away from the sun and back)

EDIT: Nevermind, the crash can also happen with the LensFlare disabled...

Support / Texture resizing
« on: May 27, 2016, 08:20:19 am »

So I have a small question...
Let's say I have an Android bitmap with the following resolution 1024x2048 (height x width) and I want to make it a 2048x2048 squared texture (to provide support for devices that don't support non-squared textures).
How can I scale the height in the most efficient way?
Bitmap.createScaledBitmap isn't that memory efficient I suppose... (There will be a moment when the original bitmap and the scaled bitmap are loaded in the memory, right? I would like to avoid this,because it could rise an OutOfMemoryError for some devices I guess)

So then, is it possible to do it with a Texture instance instead?
Basically pass the original 1024x2048 bitmap instance to a new texture instance and do Texture.scaleHeight(2);
(Texture.scaleWidth(0.5f); would be possible too of course...)
And when the texture is uploaded to the TextureManager, then the texture will be uploaded as a 2048x2048 texture to the GPU.
I don't know if this can be done... but I guess it would be quite memory efficient if this was possible.


Support / TextureInfo multi-texture question
« on: April 04, 2016, 03:45:41 am »

So I have a little problem...

Let's say I have an Object3D and I need to apply one texture with transparent parts on it.
Object3D.setTexture("textureName"); would apply the texture correctly.
The Object3D is a sphere.

But now I want to apply the same texture on a new texturelayer using TextureInfo.
Well okay, that works fine using TextureInfo.add(textureId, MODE);

But I would like to have the texture on stage 1 and I would like the same texture to have a rotation  (of let's say 90, 180 or 270 degrees) compared to the texture of stage 1 on stage 2.
The textures are squared (width=height) so a 90, 180, 270 degrees rotation should still give a squared texture...
If these rotations are possible, then I wonder if rotations like 30 degrees would work too...
And is it possible to 'translate' the texture for the new/second stage. So when you translate the texture with a certain amount of x, the texture will be shifted to the right (and what was on the right side will replace the 'empty' space  (caused by the translation) on the left)...
Sorry for the bad explanation, I can draw pictures to clarify it if needed...

Current solutions I have:
- I could also upload the rotated/translated texture and use that for the second stage... but the texture I use is rather big... I don't really want to waste memory if it is not needed... And I don't want OutOfMemoryError's obviously...
- (currently using this solution) I create another Object3D (and re-use the mesh of the original) and apply these 'texture rotations' I want by rotating the new Object3D in both the x-axis and the y-axis. And I can get these so called 'texture translations' by rotating the Object3D around the z-axis. Because both Object3D's are basically overlapping each other, it looks like one sphere. So okay, this solution seems fine but I noticed that using multiple texturelayers is much faster than having multiple Object3D's. The World.draw(FrameBuffer); method seems to execute faster when having one multitextured object instead of having multiple single-textured Object3D's.


Pages: [1] 2