Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (487)
Games in Android Showcase (112)
games submitted by our members
Games in WIP (553)
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 / Java 2D / Consecutive JFrames, 2nd isnt accelerated on: 2006-11-14 19:11:30
Hi

Im using Java2D for my game, bufferstrategy on a JFrame which works fine, fps is 100+. Now what I've done is create a config window which pops up first allowing various resolutions etc to be selected, and when this window is closed, the settings are saved and only then is the main game window created. However, now the game runs at about 40 fps, as if not accelerated. If i comment out the creation of the config window, the fps is fine. Any pointers as to what I can do so that after the creation and removal of the first window, the second created window is accelerated?

Update: Ok shortly after posting this I realised its because the opengl flag was being set after the creation of the config window, if I move this to before the config window, the 2nd JFrame is accelerated. However, I'd like the config window to be able to select between opengl, direct3d and software. Is there a way I can apply these flags after the creation of the config window and have them behave correctly?

Thanks
2  Java Game APIs & Engines / Tools Discussion / Re: Java collections good for gaming? on: 2006-10-03 01:39:53
The problem with ArrayLists *is* removing of Objects, as all objects right of it, must be shifted to the left.

If you're doing that (adding/inserting/removing) very often per frame it can very well become a bottleneck.

So surely you can copy the last element of your arraylist to the position of the element to be removed, and simply remove the last element of the arraylist? Wouldn't that just be a reference copy and then a removal with no shifting?
3  Java Game APIs & Engines / OpenGL Development / Re: Using GCJ with LWJGL? on: 2005-12-03 03:55:09
This might be a bit off-topic but are there any windows binaries of GCJ? Does MingW provide it?

*thinks the layout of the gcc site is confusing.. links to links to links...*

Nm.. http://www.thisiscool.com/gcc_mingw.htm
4  Games Center / Archived Projects / Re: SpaceWorms on: 2005-11-20 02:49:15
Yeah nice game. Simple and addictive. 51k .. I can't get past the initial rush!  Wink
5  Java Game APIs & Engines / OpenGL Development / Re: Keeping transparency on: 2005-02-26 16:05:55
Well Weston, turns out you were closest  Wink I was disabling blending in my particle rendering code  :-/

Ok so they do have transparency now, but what I'm seeing now is that when two sprites overlap, the transparent area of the sprite on top is drawn over the sprite beneath it, so basically, the terrain under both sprites gets drawn over part of the lower sprite.

I've tried setting blending mode to both of

GL.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);

but I see the same effect in both. Any ideas?



6  Java Game APIs & Engines / OpenGL Development / Re: Keeping transparency on: 2005-02-26 09:51:29

Heh, ye, towards the bottom of my post, the 2nd code segment I pasted. Wink So does anyone know what I'm missing?
7  Java Game APIs & Engines / OpenGL Development / Keeping transparency on: 2005-02-25 22:06:11
Hi, I've recently converted a small game from Java 2D to LWJGL. My sprites were drawn in photoshop... ask for a transparent background.. start drawing etc... which works fine for java 2D. I'm struggling to load the images correctly using DevIL. They display correctly but the parts that should be transparent are pure white. The code I use to load a texture from a file is:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
public int loadTexture(String path) 
      {
       IntBuffer image = ByteBuffer.allocateDirect(4).order(ByteOrder.nativeOrder()).asIntBuffer();
       IL.ilGenImages(1, image);
       IL.ilBindImage(image.get(0));
       IL.ilLoadImage(path);
       IL.ilConvertImage(IL.IL_RGBA, IL.IL_BYTE);
       ByteBuffer scratch = ByteBuffer.allocateDirect(IL.ilGetInteger(IL.IL_IMAGE_WIDTH) * IL.ilGetInteger(IL.IL_IMAGE_HEIGHT) * 4);
       IL.ilCopyPixels(0, 0, 0, IL.ilGetInteger(IL.IL_IMAGE_WIDTH), IL.ilGetInteger(IL.IL_IMAGE_HEIGHT), 1, IL.IL_RGBA, IL.IL_BYTE, scratch);
       
       // Create A IntBuffer? For Image Address In Memory
      IntBuffer buf = ByteBuffer.allocateDirect(4).order(ByteOrder.nativeOrder()).asIntBuffer();
       GL.glGenTextures(buf); // Create Texture In OpenGL

       GL.glBindTexture(GL11.GL_TEXTURE_2D, buf.get(0));
       // Typical Texture Generation Using Data From The Image

       // Linear Filtering
      GL.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
       // Linear Filtering
      GL.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
       // Generate The Texture
      GL.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, IL.ilGetInteger(IL.IL_IMAGE_WIDTH),
               IL.ilGetInteger(IL.IL_IMAGE_HEIGHT), 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, scratch);

       return buf.get(0); // Return Image Address In Memory
  }


Then in the initGL method I have:

1  
2  
GL.glEnable(GL11.GL_BLEND);
            GL.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);


What am I forgetting/not doing right? Oh.. and the images are saved in .gif format.  Smiley
8  Java Game APIs & Engines / Java 2D / Re: Rotating large images on: 2005-02-05 18:19:56
Ok, its working nicely and all that.. using tile sizes of 512, it draws at about 450 fps, but with a tile size of 64, it drops to about 75 fps at 1024 * 768 res. It that normal? Didn't realise calls to drawImage would be THAT expensive...

Secondly, rotating the whole screen very slightly by say, 5 to 10 degrees causes these ripples to appear as the avatar runs to the sides.. is there a way to avoid this?

Ah! Nevermind. Adding hints for render quality made any visual artifacts virtually disappear Smiley
9  Java Game APIs & Engines / Java 2D / Rotating large images on: 2005-01-11 00:56:04
Hi

I'm thinking about a top down 2d game in the style of Nox (if I remember correctly), where turning the avatar left or right causes the landscape around him to be rotated. How feasible is it to expect a frame rate of 60+ using Java 2D, with the opengl pipeline enabled?

I am using a bufferstrategy and a window size of 1024*768. I  added the line gr2D.rotate(0.1) in the beginning  of my rendering method just to test, which drops the frame rate from about 150 to 3, and causes alot of the colours to appear wrong.

Is there a better way to do this?
10  Game Development / Networking & Multiplayer / Re: java 1.1 compatiable 3d engine? on: 2005-01-06 21:22:14

Sorry if these questions are dumb but...

Do browsers come with a java runtime? And if so, why don't newer releases of browsers contain the latest java runtime? Surely there must be some general push towards newer technology?
11  Game Development / Newbie & Debugging Questions / Escape analysis on: 2004-12-01 22:52:12

Hi

Just a simple question, because I am hearing about it alot, but don't seem to see it in any books.. what is escape analysis?
12  Java Game APIs & Engines / Java 2D / Best frame setup for drawing on: 2004-12-01 21:47:52

Hi.. I'm trying to write a basic tile engine game, and I'm wondering what the best way is to set up a frame for drawing. What I was doing was: create a JFrame and then add another JFrame to that one, and set the first's content pane to be the 2nd one. JPanels use double buffering as default, so I did not specify any specific buffer strategy. Then I just overwrote the paint function of the 2nd one to do the drawing, but while it was pretty smooth, it didn't seem smooth enough. I have played some games that just felt 'super-smooth'. I don't know if this is because it was updating passively at times? I had set both frames to ignore repaint.

So what I tried now is to create only one main JFrame, creating a bufferstrategy(2), and then have a draw function like:

1  
2  
3  
4  
5  
6  
7  
8  
9  
public void draw()
{
        Graphics2D gr2D = (Graphics2D) bufferStrategy.getDrawGraphics();

        // do drawing stuff

        bufferStrategy.show();            
        gr2D.dispose();
}


It nows feels a whole lot smoother, no frame skipping at all, and is also about 30 fps faster .. but sometimes when I close the application, it leaves a black background on the screen where the window was. I did some googling but only found one site with a brief comment "It's considered bad practice to draw directly to the main JFrame's content..", or something to that effect.

So my question is, why is this black background left behind occassionally? And is it considered bad practice to do the drawing straight to the content pane of the main JFrame? If so, what's the best practice?

Ok maybe a few more.. why does using a buffer strategy give a slightly higher frame rate, when a JFrame uses a default buffer strategy already?

And finally.. I've tested my game on Linux (I'm using Java 1.5) and the frame rate compared to running in windows is pretty awful. In windows, currently its about 200 fps, tiling an 800x600 window with a tile size of 64... under linux, the fps is about 30 or 40. That's quite horrid. Why is performance so bad? This is with opengl enabled, but disabling it produces similar results (aside from huge slowdowns when anything translucent appears on screen).

Oh! Final final question.. is there a way I can enable vsync in the app? Because the results are just wow when I set wait for vsync to true in my ati drivers, but the program being able to specify it wants to wait for vsync would be nicer. Using default java/java2d though.. no opengl bindings.

Thanks for any help. I browse this forum quite regularly and it definately seems to be the best source of info for Java on the web.
13  Java Game APIs & Engines / Java 2D / Re: Hiding the cursor on: 2004-09-22 23:23:55
Thanks, that's what I needed Smiley
14  Java Game APIs & Engines / Java 2D / Hiding the cursor on: 2004-09-22 20:31:04
Hi

How do I hide the mouse cursor in awt/swing? I would like to draw my own graphic.

Would it be better to hide the cursor and draw an image based on the cursor, or to create a custom mouse cursor and set it to that?

Thanks
Pages: [1]
 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

TehJavaDev (16 views)
2014-08-28 18:26:30

CopyableCougar4 (25 views)
2014-08-22 19:31:30

atombrot (38 views)
2014-08-19 09:29:53

Tekkerue (34 views)
2014-08-16 06:45:27

Tekkerue (32 views)
2014-08-16 06:22:17

Tekkerue (20 views)
2014-08-16 06:20:21

Tekkerue (30 views)
2014-08-16 06:12:11

Rayexar (66 views)
2014-08-11 02:49:23

BurntPizza (43 views)
2014-08-09 21:09:32

BurntPizza (34 views)
2014-08-08 02:01:56
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org 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‑gaming.org
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!