Sample code and demo using LWJGL

Started by napier, July 30, 2004, 18:59:22

Previous topic - Next topic

napier

I've put together a sample application and toolkit that wraps many commonly used GL features such as:

    allocate int and byte buffers
    get matrices, viewport, GL settings
    project/unproject
    load textures
    load and draw images
    load 3DS objects
    draw mesh

Zip file is here:  http://potatoland.com/code/lwjgl/lwjgl_demo_1.zip

I did this for my own use (got tired of allocateDirect().order(ByteOrder.nativeOrder()).asDoubleBuffer() .put() .flip() etc.), and I thought it could be useful to have these functions in a simple toolkit.  This is a smorgasbord of useful functions with minimal structure, aimed at beginners that want to get running with LGL.  

My questions: Is this useful, does it work, is there a need for this or something like it?  

If yes, I'm happy to incorporate suggestions, fixes, functions, etc. and put together some demos.  

Obvious immediate needs: this uses version .8, is only tested in Windows, has some known bugs (native cursor problems).
penGL/Java/LWJGL demos and code: http://potatoland.org/code/gl

Matzon

nice, here's some random comments:

The reason for your cursor woes, is because you're not loading a 1 bit transparent gif - the alpha channel must be either 0xff or 0x00, and if off - the rest of the data should also be 0x00
To confirm you can check the gif data. You may also fix it easily with a
for(int i=0; i<jpixels.length;i++) {
					if((jpixels[i] >> 24 & 0xff) != 0xff) {
						jpixels[i] = 0;
					}
				}
which basically says, if the alpha channel isn't 0xff, then all of the argb channels are 0'ed. Ordinarily you wouldn't have to think of rgb, if a was 0x00, however the win32 native cursor stuff is buggy - and I actually volunteered to fixed some months ago :roll: - for now the above solution works fine

All of the buffer utils has been implemented in a BufferUtils package

Other than that this is some good example code - would be nice to get it updated to latest CVS version ;)

napier

Thanks for the tip on the cursor code, I'll put that in.  I'm planning to move this code over to the latest version, just working up the energy to take the plunge.
penGL/Java/LWJGL demos and code: http://potatoland.org/code/gl

funsheep

Hi. I have tried to get this code working under Mac OS X and Linux.
under os x the app says:
Current display frequency is 0
--------> Can't find a compatible Display Mode!!! <---------
Setting display mode to null
Bus error


i am using lwjgl 0.9a.

under linux, it says that it can't find some key mapping things (don't know what it exactly was).

regards,
funsheep

elias

Can you be a little more specific on the linux error message? Also list your Linux OS name and version.

- elias

napier

funsheep,

This code was written using version .8 so that might be part of problem if you're using .9.

I'm planning to port it over to .9, also will test on OS X.

napier
penGL/Java/LWJGL demos and code: http://potatoland.org/code/gl