Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (754)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (842)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Java Game APIs & Engines / OpenGL Development / Re: Reusing depth values from FBO on: 2014-02-25 02:57:02
Yeah, you're right. It's not part of webgl...

Wonder if there is another way of doing this
2  Java Game APIs & Engines / OpenGL Development / Re: Reusing depth values from FBO on: 2014-02-25 01:35:38
I managed to do what I wanted, more or less. I post it here, so maybe someone will find it useful.

Since GLES/WebGL do not support depth textures out of box (extensions exist, but I don't use them), I did it in fragment shader by storing depth value in alpha channel.

while rendering to FBO
color.a = gl_FragCoord.z;

and while rendering that FBO to the screen

gl_FragDepth = color.a;
color.a = 1.0;

Also, to avoid doing that with completely transparent pixels, in both shaders add
if(color.a == 0) discard;

before doing anything.

That wouldn't work well with semi transparent tiles, as devades mentioned.

For older devices that don't support depth textures, another idea is to use a "multi texture" batch like so:
I also though of that, but as I also mentioned earlier, I want to be able to zoom out ver far, so I have to prerender some chunks of terrain into texture anyway. (one could argue that with such zoom out I shouldn't also be displaying any objects, so depth stops being relevant, but whatever Tongue )
3  Java Game APIs & Engines / OpenGL Development / Re: Reusing depth values from FBO on: 2014-02-24 05:48:41
If your sprites are semi transparent it probably isn't worth it.
They are not semi transparent.

Introducing FBO binds means less batching and more state switches
When zoomed out, it's better to have a few prerendered chunks, than half milion of tiles. (yet they need their depth values preserved)
I even packed tile mesh to VBO. New machines don't have a problem with million tris, but it really is a bottleneck on older ones.

I appreciate your advices, but I already know that stuff Wink (sprite batching and texture atlases)

but you can't always fit all your sprites into one atlas. Terrain has it's separate atlas and I don't want to switch between objects and terrain atlases, depth buffer solved that so far. (and terrain is not flat, some objects can be behind some parts of terrain)

It's more of a testing ground, and I have a few ideas on my mind.
I'm going off to sleep now and I hoped that meanwhile someone would share what they know about FBO usage.
How to render FBO's content preserving it's depth values is all I'm asking for.
4  Java Game APIs & Engines / OpenGL Development / Reusing depth values from FBO on: 2014-02-24 04:14:44
Suppose I have a 2D scene to render (orthographic projection), which I render with depth testing enabled. This scene is composed of lots and lots of small tiles, so I render it in bigger chunks to FBOs, to avoid re-rendering lots of triangles every frame.

Now, when I render contents of those FBOs, I also would like to preserve the depth value of every of its pixels/texels.
How should I go about that?

GL ES 2.0 / WebGL compatible solution would be appreciated.
5  Games Center / WIP games, tools & toy projects / Re: SF Citybuilder- Buildings/Concept Art on: 2013-08-22 21:59:13
Those arts look very well. You've got the skill.

Are you by any chance looking for cooperation in this?
6  Game Development / Performance Tuning / Re: repaint vs custom draw method performance in ms on: 2013-06-14 09:56:36
What are you trying to accomplish here? This looks kinda stupid.

Strategy is used with active rendring, paint (and repaint) is used with passive rendering.

In paint() method you should NOT use buffer strategy - it already gives you Graphics object.

And you should not use passive rendering for game, use active rendering. Draw on canvas, don't even touch the window/frame.

         for(Tile t : tiles)
            g.drawImage(t.img.getImage(), t.x+trackX, t.y+trackY, null);
This is going to be slow if you render every tile with separate render call. Also, you shouldn't have an instance of class per every tile, that's memory inefficinent. You should hold tile types in array.
7  Games Center / Archived Projects / Re: Space Simulation (with gravity n stuff) on: 2013-06-11 01:29:18
That's weird, but it seems like your card doesn't support OpenGL 2.1+ or at least LibGDX failed at detecting it. I added some debug, would you copy the output when it shows?

It should work now, try again.
8  Games Center / Archived Projects / Space Simulation (with gravity n stuff) on: 2013-06-10 20:37:23

Applet link:
(hopefully should work on all systems)

What is this?

I've been playing with simulating solar system with box2d. So far I've got earth and moon working more or less. There are more planets, but they are out of precision range now. (at least rendering wise, I use double for physics)

This is totally work in progress. Finally world should be chunked a little maybe... it's intended for multiplayer.

How to play?
Hit Space (or X) to start rocket... when detatched, steer left and hold W to escape the gravity pull. Try to land on the moon. Don't hit the moon too hard though, or you will crash. Then try to get back on Earth - this is a hard task.

I don't really want to work on a game by myself. Some of you guys here also make space related games and I think maybe someone would like to join forces?
9  Game Development / Performance Tuning / Re: Java System System.currentTimeMillis(); error on: 2013-06-04 22:42:12
That's probably a Windos bug - as it is the only OS that doesnt return accurate milisecond timer. It rounds it to 16 miliseconds.

Your best bet is to use System.nanoTime(); which doesnt use that retarder windows pipeline underneath.

long time = System.nanoTime();

// do stuff

time = (System.nanoTime() - time) / 1000000; // here you go, accurate miliseconds
10  Discussions / General Discussions / Re: XBox One on: 2013-05-23 23:27:25
As far as I remember, long time ago Steve Ballmer said he likes idea of world, where people have no privacy... or something like that, anyway he was into surveillance.

Now looking at Xbox One, the device that is 24/7 on in your living room, with camera and microphone always on, always watching you... That guy wasn't joking, I bet Microsoft has some secret agreement with the government, so they can monitor all xbox users without their knowledge.
11  Game Development / Performance Tuning / Re: How to do object pooling right? on: 2013-05-21 13:14:38
A few more fine jvm options, that you should at least try
-XX:MaxPermSize=20M // this or 30m, typically my apps never needed more for perm size

back to OpenJDK

For Linux: OpenJDK already contains server VM. Should be pre-installed. If not, user can install it with one command line, no need to bundle it.

For MacOSX: Probably contains server VM already, no need to bundle.

For Window: 32 bit constains only client vm, you should bundle openjdk.
If user somehow has 64 bit jvm, then it has server vm only, no need to bundle - but users don't usually have 64 bit vm... - 8mb
- rt.jar is not compressed - 24mb - so 7zip can compress it more efficiently. (resulting in 8mb package)
12  Java Game APIs & Engines / Engines, Libraries and Tools / Re: [LibGDX] Linking a Sprite (Or another image) to a Box2D Body on: 2013-05-20 11:57:01
I think the proper way should be this:

You have an Entity class, which holds reference to a Body and a reference to Sprite

your game loop should go in this order


for(Entity ent :entities) {
   ent.update(); // entity logic like AI, inputs, etc. At the end it updates Sprite position to match a Body position

//render sprites

Sprites should be held in different structure, optimal for rendering.

Body's UserData should hold reference to its Entity - not to loop through bodies. It's useful for collision detection. Box2D lets you add listeners and filters to your world... so you can detect when your bullet collides with a player, etc. your listeners would receive to Bodies. you can identify them by their UserData
13  Game Development / Performance Tuning / Re: How to do object pooling right? on: 2013-05-20 10:12:59
Server VM (and therefore EscapeAnalysis) is not present in client VM - which is the only one in 32-bit JRE on Windows.

This also does not apply to Dalvik. They did testing on escape analysis but I don't know why didn't they include it. It gives soo much performance gain, ugh.

Thankfully, on Linux machines (and probably Mac too) server VM is present (with -server switch) and on 64-bit JRE on Windows server VM is also default. (Sadly almost no-one has 64 bit JVM on Windows)

Good thing is (if you are not targeting Android or iOS) you can ship JRE with server VM on Windows with your app legally. Bad thing is it weights much... You can remove some things from it, but rt.jar still weights a f**kton...

Again, good thing is, There are unofficial OpenJDK builds for Windows - and you can strip them off of everything that is unnecessary. Including contents of rt.jar - but you should be careful not to remove something important.

edit: see posts below
14  Game Development / Performance Tuning / Re: Speeding up Minecraft? on: 2013-05-19 19:01:00
because the linux drivers arent nearly as good as the windows ones. -_-
I installed proprietry drivers from NVIDIA on many Linux machines and never had any problem with it.
I once had a radeon card, but I also don't remember having any driver issues with it.

If you have NVIDIA or ATI, just install proprietry drivers - card manufacturers know best how their cards work.
15  Game Development / Performance Tuning / Re: FPS problems in LWJGL on: 2013-05-19 18:52:41
I played it for a few minutes and no problem so far.. FPS is stable and it looks smooth.
Problem is specific to your hardware, it seems.
16  Java Game APIs & Engines / OpenGL Development / Texturing a sphere, creating a cube map - the proper way? on: 2013-05-18 14:08:38
So I've been looking into spheres and this seems to be a wild subject... couldn't find at least one place that would agree on any proper way to do this.

People say spheres sould be textured with cube maps, and not Mercator streched textures. (like ones NASA gives)

I found this blog post
The guy reprojected Mercator texture onto Gnomonic cube map.

I was able to texture a sphere with that cube map he gave. I'm not sure if I created that mesh correctly, but it looks quite good.
example: (press
  • on numpad to add more vertices, press V to see wireframe)

1. But I don't know how he did that. How did he reproject from Mercator to Gnomonic. He gave a link to wolfram page on Gnomonic projection, but I am not sure how use that.

2. What if I want to create my own cube map? (ie. procedurally, out of perlin noise, or even manually)

I hope some of you guys been through this and can give me some advices, maybe even some code.
I would really like to know what are good ways to mesh a sphere and texture it procedurally correctly.
17  Game Development / Newbie & Debugging Questions / Re: Where next? on: 2013-05-11 10:26:57
Why are you guys sending him to JMonkey? Maybe he wants to know how these things are made? Good programmer should know how things work underneath. Additionaly engines usually assume that you are familiar with these things, so they dont necessarily explain everythig in documentations.

I think good approach would be to take any engine, like maybe Ardor3D, JMonkey. Look at what features they have and what they are showing in their demos and tests. Make research on these features one by one. Google "<feature> opengl how to" etc. Any OpenGL tutorials and guides should suffice. If you can't find anything useful... Ardor3D and JMonkey are open source - you can check the sources. (Warning, if you have no idea on the subjects, watching the sources might be confusing, because even comments and javadoc usually assume you are familiar with these things)

That's what I do, at least.
18  Games Center / Showcase / Re: [RELEASED] Janken Game - Multi Platform JankenPo! on: 2013-05-07 05:32:28
Web version(Only for Chrome)
Only for Chrome? Are you f**king serious?
19  Game Development / Newbie & Debugging Questions / Re: My game project freezing when I run it? on: 2013-04-29 11:58:48
Can you pack your whole project into zip? I will then run it and try debug your problem.
20  Discussions / General Discussions / Re: AWESOME particle system on: 2013-04-29 11:49:33
for graphics effects in java: search opengl + <insert name of effect>
i didn't start learning openGl yet  Roll Eyes
i need to finish my first Java2D game  Cool
ps :
i dunno why it scares me  Tongue
"openGL"  xD
it's hard to learn isn't it ?
This OpenGL introduction applies to LWJGL - caution, as it has 7 parts, and not really much is yet explained here but it will get you into OpenGL enough so you can use other tutorials and stuff.

And for Matrix and Camera use LibGDX classes (PerspectiveCamera and Matrix4/Matrix3)
While learning, please use LWJGL directly, don't use LibGDX GL wrappers, they don't support VAO
21  Game Development / Newbie & Debugging Questions / Re: BufferStrategy - CPU Usage on: 2013-04-28 21:48:03
Do you limit FPS in any way? If you don't, then you'll always eat cpu...

also, the code you have commented uses reflection in a way that will be rather cpu intensive
22  Game Development / Newbie & Debugging Questions / Re: what is the correct method to loads images on: 2013-04-28 21:39:57
BufferedImage img ="/some/resource.png"));

This will load image from classpath (from inside the jar the application is run)

If you use eclipse, you should select "graphics" folder and add it as source file. (you then can refer to them with path as "/image.png")
later, if you change something in graphics folder, don't forget to refresh workspace in eclipse.
23  Java Game APIs & Engines / OpenGL Development / Re: [solved] Horrible performance with GL_UNSIGNED_BYTE on: 2013-04-28 21:12:47
No, the case I tested it with now is the same speed with floats.
Sorry for additional confusion.
24  Java Game APIs & Engines / OpenGL Development / Re: Horrible performance with GL_UNSIGNED_BYTE on: 2013-04-28 20:19:38
@pitbuller: That's probably it!

I used 3 unsigned bytes for coords + 2 unsigned bytes for texture coords.

I just changed vec3 to vec4 and added one dummy value + changed UV to unsigned shorts. So they are all now 4-byte aligned and it went to 300 fps on ATI card.


How could I have missed that best-practices page. Cheesy
25  Java Game APIs & Engines / OpenGL Development / [solved] Horrible performance with GL_UNSIGNED_BYTE on: 2013-04-28 16:38:04
I'm learning OpenGL and decided to make some voxel rendering.

I use VBO to hold mesh for one chunk and I store only visible faces into the VBO
One VAO and one VBO per chunk.

Each chunk is only 32x32 so I decided to use unsigned byte as vertex data instead of floats.
Each vertex is stored with its local position in chunk.
I store chunk offset as uniform and add it to vertex data to render it at correct position.

Performance decreased... mostly visible on ATI cards (its horrible there)

I noticed it is very dependant on number of vertices. As all data is uploaded to VBO, it is clear that it's fail on GPU side.
I removed the lightning calculations to see if they were the cause, but it seems they weren't.

Maybe it's something with shaders having problem converting data types?
It works good with floats, but not with bytes.

Here are my shaders:
#version 130

uniform mat4 camera;
uniform vec3 chunk; // chunk offset

in vec3 vert; // vertex
in vec2 vtex; // texture coordinate

out vec2 ftex;

void main() {
   // as I store UV in bytes, i need to divide them by amount of tiles I have in texture (currently 2x2)
    ftex = vtex/2;
   // I add vertex position and chunk offset to get corrent world position of vertex
    gl_Position = camera * vec4(vert+chunk, 1);

#version 130

uniform sampler2D tex;

in vec2 ftex;

out vec4 final;

void main() {
    final = texture2D(tex, ftex);

They do almost nothing, but they perform hirribly.
Might it be the problem with input data definition?

in vec3 vert; // vertex
in vec2 vtex; // texture coordinate

vec3 and vec2 are float vectors - but VBO contains bytes.. is it really so hard for gpu to convert those types? I don't believe.
Maybe I should have use ivec3 and ivec2 (or uvec3 and uvec2) but if I use them I get veery werid input. deffinitely not what vbo contains.

What my scene looks like you can see in this demo: (light and all the stuff is removed to concentrate on the problem - simple vertex data rendering is horribly slow) - it should work with about 900fps .. but it works with 100 on NVIDIA and 15(!) on ATI.
26  Game Development / Newbie & Debugging Questions / Re: rotating a single object without rotating the entire screen with Graphics2D on: 2013-04-23 16:45:58
I don't think matrix stack is neccessary for simple things...
He can do it like this.
AffineTransform t = g2.getTransform();

for(Something object : yourObjects) {
    g2.translate(object.x, object.y);
27  Java Game APIs & Engines / Java 2D / Re: Awesome Speeds With VolatileImage on: 2012-10-06 10:14:43
Sorry I dig out an old thread, but it is not "ended" with proper information.

Java2D can be accelerated (mostly defaultly it is) by Direct3D or OpenGL. - here you can set some flags to force acceleration (usefult to force direct3d on windows and opengl everywhere else)

BufferedImage when loaded from resources may be INCOMPATIBLE ... there are several types of BufferedImage (depending on layout of pixeldata inside)
For maximum performance, you can create compatible BufferedImage with GraphicsConfiguration,%20int,%20int%29

Java2D tries to cache BufferedImage as texture whenever possible, so drawing it anywhere is as fast as drawing texture.

problem is.. drawing ON BufferedImage is performed in software, while drawing ON VolatileImage is (if possible) on GPU.

so its only faster to use VolatileImage if you want to draw ON IT, otherwise its better to use compatible BufferedImage.

Here is some more info on OpenGL acceleration in Java2D:

Direct3D pipeline is very similiar.
28  Game Development / Newbie & Debugging Questions / Re: Ticks & Random Movement on: 2012-03-12 03:17:06
@GabrielBailey74: If you "code how you code" then keep it for yourself and dont post bad code on the forums.
Otherwise stop whining if you get corrected.
Pages: [1]
DesertCoockie (20 views)
2018-05-13 18:23:11

nelsongames (68 views)
2018-04-24 18:15:36

nelsongames (65 views)
2018-04-24 18:14:32

ivj94 (748 views)
2018-03-24 14:47:39

ivj94 (79 views)
2018-03-24 14:46:31

ivj94 (555 views)
2018-03-24 14:43:53

Solater (94 views)
2018-03-17 05:04:08

nelsongames (168 views)
2018-03-05 17:56:34

Gornova (338 views)
2018-03-02 22:15:33

buddyBro (998 views)
2018-02-28 16:59:18
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!