The JWS thread *LWJGL demos only*

LWJGL Work Frame:


http://www.realityflux.com/abba/Lwjgl/LWJGLFrame/LWJGLFrame.jpg

Keys: Escape to exit
H to display statistics
Source
Zip File Source

Author’s notes:
This Frame works makes developping demos and maybe games a hell lot easier since the programmer doesn’t have to worry about implementing the following things:
TextureGeneration.
Shaders handling including the new shading language OGLSL.
TextureLoading.
Milkshape3D and 3D Studio max files (with an option to generate Tangents and binormals vectors :wink: ).
Cursor rendering.
Text rendering with different fonts.
First person persepective camera.
Frustum class.
Cos and Sin look-up tables.
Quaternion class.

and so on…
It is largely inspired by Xith3D, and yet it is much more flexible (and less features complete).

Enjoy :slight_smile:

Cubic Environment bump mapping:


http://www.realityflux.com/abba/Lwjgl/CEBumpMap/CEBumpMap.jpg

Mouse: left drag for rotation, right drag for translation and middle button for zooming
Keys: Escape to exit, H to display statistics, S to switch OGLSL/Fragment-Vertex programs
Source
Zip File Source

Author’s notes:
Ok I updated this demo to use my latest framework and therefore I’m putting it up here again.
It now runs on top of my mini-scenegraph which is largely inspired by Xith3D, and although it’s not as complete as the latter, it is much much more flexible and Faster.
I also included the license terms on top of every class that I borrowed/modified from Xith3D.
Since OGLSL (Opengl Slang) shading language is now enabled on both Nvidia and ATi’s high end cards, I included an option to switch over it instead of the Vertex/Fragment Program combo.
However, OGLSL is noticeably slower than regular shader programs which is understandable since assembly is always faster than high-end language.
I for one prefer to write my shaders using the fragment/vertex program extension since they yield the fastest frame rate, and aren’t that hard to work with.
Keep in mind that fragment/vertex assembly-like syntax is a lot less complicated that x86 instructions.
This demo also introduces my MilkShape3D model loader even though I think it sucks the big sweaty-goat’s balls. Part of my negative impression regarding that file format is the fact that it writes the normal components into an independent array from the vertices, meaning that for a quad composed by 2 triangles and hence 4 vertices, we actually have a normal array of size 6!!!
Now if you still don’t see how that could cause any problem besides the few more bytes required for the extra normals’ components, remember that all the drawing functions in opengl (except the immediate which is not even an option considering how slow it is) take only one array of indices. Therefore we need to duplicate all the vertices till they match the size of our normal array ;Quite wasteful indeed, but mandatory.
The only reason that I use MS3D loader is because generating “good” noramls in 3DS is a true pain.
I haven’t done any animation yet with this loader, maybe MojoMonkey can throw me a hint on how I do them?

PROs: Awesome reflection effects
Cons: Requires a Radeon 9600+ or GeForce Fx 5200+.

Dynamic Cube Mapping:


http://www.realityflux.com/abba/Lwjgl/DynamicCubeMap/DynamicCubeMap.jpg

Mouse: Move to look around the scene.
Keys: A,Q,W,S,E,D, up, down, left and right to move around. H to display or hide the info.

Source
Zip File Source

Ok I’m back as promised to comment on the dynamic cube mapping demo ;D
/me takes a long and deep breath
I spent a lot of time coding this application since I had to first learn and understand VBOs (Vertex Buffer Object) and then try to use them with LWJGL.
Few days ago I thought my demo was ready to be published, but then at the very last moment I decided it wasn’t since I wasn’t entirely satisfied with the performance on my Radeon 9700Pro backed by a 2.1 Ghz Athlon Xp CPU.
Now I understand that rendering the scene 7 times before displaying onto the screen takes a hell lot of computation and time, still the 140 FPS wasn’t something to be too proud of :
So like I said I decided to give VBOs a shot knowing that they mostly store the data on the Graphic Card memory and thus would reduce if not eliminate the time necessary for it to transit from the system’s memory to the graphic accelerator through the AGP bus.
At first, I generated 4 VBOs per shape; 1 for the vertices, 1 for the normals, 1 for the indices and finally 1 for the texture coordinates.
I noticed some performance boost over the conventional Vertex Arrays, and again I was attempted at uploading my work and move on to something else, yet I decided to hold on and attempt tweaking this demo even further.
I read on the Opengl forums that one can generate a unique VBO and use strides and offsets to differentiate texture coordinates, normals, vertices etc…;
Few hours later, I’m down to 1 VBO, but I haven’t noticed any performance boost over the version that used 4, so thinking there is nothing I can do about it anymore, I went ahead and posted it right here.
This morning when I was reading through my code again, an idea hit me; the indices buffer that I’m sending to the card every single frame is indeed slowing things down, so why not cache it too on the graphic card’s memory?
I proceeded to implement that idea and I was pleased by the 15% boost in the frame rate.
After that, I cleaned my code a bit, created a function to safely remove any OpenGL resource created and voila, I uploaded the improved demo to the server :).
Before I leave, just few things about the 3Ds max loader; there is a lot of features missing, but I’ll be working on implementing them in due time :slight_smile:

Texture Fonts:


http://www.realityflux.com/abba/Lwjgl/GLFonts/GLFonts.jpg

Keys: Escape to exit

Source
Zip File Source

Here’s the font factory that generates the textures:
FontFactory.
Notice that some fonts are screwed up until you increase their sizes in the FontFactory class, for example Batang needs at least a size of 27 to look sharp.

Blinn Lighting:


http://www.realityflux.com/abba/Lwjgl/BlinnLighting/BlinnLighting.png

Mouse: A,W,S,D up, down, left and right to move camera location, mouse to look around the seen.
Keys: Escape to exit, H to display statistics, P to enter camera tracking mode, + - decrease and increase the bumping, / * modify the light range

Source
Zip File Source

Lighting is computed via a vertex and pixel shader program and is using the Blinn Lighting illumination algorithm which is explained in this page.
Blinn lighting albeit less intensive than Phong Lighting is known to stress and push the most powerful machines to their limits.
Still a modern Graphic accelerator like the Radeon 9700 pro sitting on my machine can push about 250 FPS at 640*480.
Requires Vertex And Fragment shaders.

Parallax Mapping:


http://www.realityflux.com/abba/Lwjgl/ParallaxMapping/ParallaxMapping.png

Mouse: A,W,S,D up, down, left and right to move camera location, mouse to look around the seen.
Keys: Escape to exit, H to display statistics, P to enter camera tracking mode, + - decrease and increase the bumping, / * modify the light range

Source
Zip File Source

As seen in Unreal 3 technological demo, this demo produces an effect similar to bump mapping and yet a hell lot better.
Requires Vertex And Fragment shaders.
Enjoy

nice work, runs perfecly!
damn shaders, why oh why would anybody invent a new language using assembler like syntax ??? - oh well, some master it… ::slight_smile:
Thank god for GLSLang, though I have yet to try that out…

I really like the rugged bottom of the chalice!

Demo updated with the following things;
MouseRotations is now replaced with MouseInteraction with which you can translate, rotate and zoom at the same time.
Try holding your mouse’s three buttons at once and move the cursor; Crazy things ;D
Btw whoever came up with Mouse.getDX() and Mouse.getDY() gets a two thumbs up from meh :slight_smile:

Now lemmie put together my basic framework which I’m positive will help a lot of people get quicker into LWJGL

Check first post

I really like the bottom ;D

http://matzon.dk/brian/Random%20Junk/rugged_bottom.jpg

What ver. of LWJGL? I get a big fat nothing with webstart (no matter what screen mode), and I can’t compile the source. :frowning:

Linux, by the way… in case you hadn’t already guessed.

Damn, I really need a new graphics card, pics look very nice :slight_smile:

One question though, although I get a pretty dull model when I download the demo I still get the culling bug (as I did with your Buda demo), now if this bug isn’t related to lwjgl how come I don’t get the bug with your jogl Buda demo?

Oh, talking about graphics cards, what would you guys recommend I go for, ATI or Nvidia?

Thanks all, and Cheers JCD, I’m sure that work frame will be very handy :wink:

I’ll update the code hopefully tonight and see if I can fix the culling bug :slight_smile:
Btw if you’re to buy a graphic card in the few next weeks, go for at least a Radeon 9700 Pro;
Not only it performs like a champ, over 18 months after it was introduced to the market, but it will last you at least for another 2 years.
The must would be a Radeon 9800 XT, but gotta have the bucks for that.
But again I’m an ATi fan, and their shaders performance got a lot to do with my addiction to their products…

[quote]Oh, talking about graphics cards, what would you guys recommend I go for, ATI or Nvidia
[/quote]
I’ve got the impression that Nvidia is better at opengl and ati is better at directx. I know people having problems running simple opengl aps on a Radeon 9600.

Take a look at toms hardware guide if your interested in benchmarks: http://www20.tomshardware.com/graphic/20031229/index.html

Always buy Nvidia.
Benchmarks schmenchmarks. Card’s no good if the bloody drivers don’t work. So buy Nvidia, because they know how to write drivers.

Cas :slight_smile:

[quote] So buy Nvidia, because they know how to write drivers
[/quote]
Bah! Some of us actually like that the games look top notch! nVidia keeps turning down image quality because their current generation graphics chips are inferior to ATI’s. Oh, and ATI is much better at supporting the open source community with driver specs.
and the “The way it’s meant to be played” shit I have to see each time I fire up a game, doesn’t make me feel any better with nVidia!
So, to sum it up, best performance (speed, image quality) = ATI, slightly more stable drivers (for wide spread OS’s) = nVidia.

I’d agree with Matzon here. In my very limited experiences, the Geforce FX cards have been pretty subpar. The latest gen of Radeons have been vastly superior. Faster framerate and sharper images. The geforce seemed a bit blurrier for me. This very scientific test is from me plugging in a Radeon 9700 Pro into my computer after trying a Geforce FX 5800.

Ok no more thread hijacking puh lease ::slight_smile:

Oh… very cool demo. ;D

[quote]What ver. of LWJGL? I get a big fat nothing with webstart (no matter what screen mode)

Linux, by the way… in case you hadn’t already guessed.
[/quote]
Ditto; although I only tried 640x480 non-fullscreen (the default, I think?)

PS: Thingie’s Q3 loader map with an LWJGL version and a software renderer version worked fine with Webstart, so…

PPS: Quite a few people make naive mistakes with selecting / accepting screen resolutions etc. AFAICS, if user selects w x h @ f, then for windowed mode you should accept “anything >=w, >=h, at any frequency”. For fullscreen mode, you should accept “w, h, at f if available, or the highest available if not”.

Why? Well, I’ve noticed that the screen mode querying consistently believes that I’m running at 0Hz. This may be something to do with using an LCD (hence frequency is meaningless; perhaps it returns 0 to signify N/A?), or may be something to do with linux.

[quote]However unless someone points out a free open source image loader to me
[/quote]
I haven’t tried any of them, but here’s a list of image codecs:

http://www.geocities.com/marcoschmidt.geo/java-image-coding.html

I’ll keep this quick, don’t want to upset JCD ;D

Cheers for the card recommendations guys, although now I’m probably more confused on the whole subject, I’ll probably opt for Nvidia…or maybe ATI :smiley:

Btw, I’m loving lwjgl, it’s a hoot.

Keep the demos coming JCD

Cheers all.

New demo up and greetings from Montreal ;D

very cool demo… runs 100-200fps in 1024(windowed mode)

When I ride the fireball its 300-450FPS

But it fucks up in fullscreen (screen out fo sync)… You cannot run it unless you have lwjgl installed…

An error occurred while launching/running the application.

Title: Phong Lighting & Particles
Vendor: Abdul Bezrati - Galactic Village
Category: Download Error

Unable to load resource: http://www.users.xith.org/JavaCoolDude/JWS/lib/lwjgl-macos.jar