So you like Textures eh? Texturing Demo in JOGL.

hi there,

saw the “get2Fold” method in the TextureLoader. I am using the following elegant code snippet for this job


      /**
       * Generates the next power of two.
       * @param in An int.
       * @return The next power of two.
       */
      public static final int nextPowerOf2(int in)
      {
             in -= 1;

             in |= in >> 16;
             in |= in >> 8;
             in |= in >> 4;
             in |= in >> 2;
             in |= in >> 1;

             return in + 1;
      }

got this from a c library, actually, i currently don’t know, which one it was. if you guys want to know, i can search for it.

regarts,
funsheep

[quote]hi there,

saw the “get2Fold” method in the TextureLoader. I am using the following elegant code snippet for this job


      /**
       * Generates the next power of two.
       * @param in An int.
       * @return The next power of two.
       */
      public static final int nextPowerOf2(int in)
      {
             in -= 1;

             in |= in >> 16;
             in |= in >> 8;
             in |= in >> 4;
             in |= in >> 2;
             in |= in >> 1;

             return in + 1;
      }

got this from a c library, actually, i currently don’t know, which one it was. if you guys want to know, i can search for it.
[/quote]
That’s quite nice. I deduced a version of my own some time ago (next power of two, downwards):


    private static int getPowerOfTwo(int a)
    {
        return (int) Math.pow(2, (int) (Math.log(a) / Math.log(2)));
    }

i’m currently porting the postet files to my own application. we are using a sever <-> client concept, where the server loads the textures from a db and then transfer them to the client. so i will split both files into a version without OpenGL (for the server) and a conversion + binding loader/manager on the client side.

currently i’m wondering, if i save the byte array in the db or the real file…

i will post again, when its done :slight_smile:

regards,
funsheep

[quote]Yeah I can zip up what I have, but its not a good base to build from. 10.3 is releasing new builds very rapidly and I find myself reinstalling more than I do anything else at this point so I haven’t had a chance to pick it back up.
[/quote]
have you ever released this code? Or, has aNt optimized the QT loading? I need to do exactly the same thing and it would save a lot of time if the code that loads QT stuff (in its most updated form) was accessible.

Many many thanks…

arrr- i thought we had this in the bag now.

the movie loader was slow because we had to convert
using a QTImageProducer. Seems Apple my have drop
that little class with there newer QTJ version.

I will have another look at it to see if we can use
RawImageEncoders. At the end of the day QT still needs
to uncompress the media so we can then hand it to
GL. QTJ doesnt have the call to output the Data to a
given format (its in the ObjC/C headers- Apple just didnt
port it). So we have to find other tricks to do the same
thing- these seem to be slower then doing the ‘Apple
have done it us’ that to ObjC dudes get.

shame we miss out :frowning: If anyone at Apple wants to tell
us a trick to pull this off fell free.

i will have a look at a more low level way of doing anyways :slight_smile:

oh yes… please… that would be so so cool.

i just threw together a ‘proof-of-concept’ i was thinking about for some time now.

after having a lot of trouble with the, as of now, crappy QTJ API i finally figured out a way to use the native QT API through the JNI. as mentionened above the code is more of a ‘proof-of-concept’ and since i have not much experience with C/CPP i didn t manage to come up with a windows version ( maybe someone can help :wink: ). it s just osx.

the basic concept is to get rid off the, especially under osx, annoying copying of data from native to java to native to opengl and rather leave all the heavy data pushing in native world where it belongs.

i was really suprised to find out that when suppling a valid opengl context from jogl, you can call ‘native’ opengl functions via JNI from native code. i m not sure if this is valid, whatever that means, but i tested it under osx on several occasion and it seems to be robust.

with that knowledge i wrote ( and snipped of course ) a little wrapper around the native QT API that would simply allocate some memory, let quicktime write into this memory and copy it to opengl, all on the native side. the java/jogl part would just controll the whole process. which is creating, playing, looping movies etc.

it still seems a bit like blackmagic to me and maybe is. i would be happy to get some feedback and even better some improvement on this approach.

-> QTGLJNI

d3, this is really cool - but is there anyone who could adapt this to windows? i have no experience with C… and have no Macs to test it on…

If anyone could give it a try and convert it to a windows DLL, I would be very grateful.

Thanks a lot…

;D im new ::slight_smile:

I have a problem with the Texturing Demo described at the beginning of this Thread. When I load a bitmap as a texture, all of the blue colors in the bitmap(BLUE channel=255) are displayed in OpenGL as black and all of my black colors are displayed as blue. I send the picture as follows

textureManager.createManagedTexture("background", "bg.bmp", GL.GL_TEXTURE_2D, GL.GL_BGR, GL.GL_RGB, GL.GL_LINEAR, GL.GL_LINEAR, true, false );

The strange thing is that the problem only occurs when the blue channel is set to 255, so when I load a bitmap where all of of the pixels’ blue channels are set to 255 and the green and red channels set to 0 my texture is displayed as black. BUT when the blue channel is set to e.g. 254 and the green and red channels to 0 the texture is displayd as blue. So then the problem doesn’t occur. Does someone know what causes this?