Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (120)
games submitted by our members
Games in WIP (577)
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] 2 3
1  Game Development / Networking & Multiplayer / What Happens when you try to read from a URL that doesn't exist? on: 2006-03-21 23:02:09
i'm trying to read several files from a server using a URL object, some of them exist and some don't. i've noticed that when i try to read a file that doesn't exist, an exception isn't thrown, but instead the program reads "junk". is this normal behaviour?
2  Java Game APIs & Engines / Java 2D / Re: transparent png image loaded as opaque on: 2005-12-16 01:03:01
really? strange, i see it alright...
3  Java Game APIs & Engines / Java 2D / Re: transparent png image loaded as opaque on: 2005-12-16 00:00:14
as i said, i know that PS solves the problem. what i want to understand is why it doesn't work using GraphicsGale. i mean, the image looks ok when you view it.
4  Java Game APIs & Engines / Java 2D / Re: transparent png image loaded as opaque on: 2005-12-15 21:19:01
I guess the difference is that you are using a program that doesnt make PNGs correctly.
as you can see, the image i've created looks fine (it's in the second post of this thread). it's only in java that it doesn't work.
5  Java Game APIs & Engines / Java 2D / Re: transparent png image loaded as opaque on: 2005-12-14 18:54:05
already tried it, but still, the image has a white background...
6  Java Game APIs & Engines / Java 2D / Re: transparent png image loaded as opaque on: 2005-12-14 18:15:14
yes, i know. but the question is what's the difference that makes the image load correctly after you save it in photoshop...
isn't gif a compression method that does lose data?
7  Java Game APIs & Engines / Java 2D / Re: transparent png image loaded as opaque on: 2005-12-13 22:35:27
p.s
i've attached the image i can't seem to load as transparent... maybe the problem is with it, as transparent png images i've downloaded from the internet work fine, while those i've created using GraphicsGale don't work (though, like i've said before, they do work on windows picture viewer).
8  Java Game APIs & Engines / Java 2D / transparent png image loaded as opaque on: 2005-12-13 22:26:27
i'm trying to load a transparent png image with the following code, which also converts it to a bufferedimage:
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  
28  
public createImage(Image img)
 {
        if(img instanceof BufferedImage)
        {
            theImage=(BufferedImage)img;    
        }
        else
        {
            MediaTracker mediaTracker=new MediaTracker(new Frame());
            mediaTracker.addImage(img,0);
            try
            {
                mediaTracker.waitForID(0);
            }
            catch(InterruptedException ie)
            {
                System.err.println(ie);
            }
           
            theImage=GraphicsEnvironment.getLocalGraphicsEnvironment().
                     getDefaultScreenDevice().getDefaultConfiguration().
                     createCompatibleImage(img.getWidth(null),
                                           img.getHeight(null),
                                           Transparency.BITMASK);
            theImage.getGraphics().drawImage(img,0,0,null);

        }
}

but when i draw the image i've loaded i see an opaque image, (the transparent pixels are white and opaque). if i open the image using windows picture viewer or acdc the image is displated correctly, with the transparent pixels transparet.
9  Game Development / Newbie & Debugging Questions / Re: Diagonal keyboard movement in java on: 2005-10-14 08:14:49
further more, you set your flags with the following methods:

private boolean[] keys=new boolean[256];
public void KeyPressed(KeyEvent e)
{
       keys[e.getKeyCode()]=true;
}
public void keyReleased(KeyEvent e)
{
       keys[e.getKeyCode()]=false;
}

// in your move method...
if(keys[KeyEvent.VK_UP])//Up is pressed
{
      charecter.moveUp();
}
if(keys[KeyEvent.VK_RIGHT])//Up is pressed
{
      charecter.moveRIGHT();
}

also, it'll be good practice to implement a focus listener and set all the keys to false if you lose focus, as opposed to those games where if you minimize the window and then return to it, a key can get "stuck" and your charecter keeps on shooting though you're not pressing any key.
hope this helps,
noam
10  Game Development / Newbie & Debugging Questions / Re: help with level designer on: 2005-10-12 01:29:10
"rubberbanding" is that the term for what i'm trying to do?
are there any tutorials or other references i can look into?
11  Game Development / Newbie & Debugging Questions / help with level designer on: 2005-10-10 17:28:34
i'm starting to work on a level editor for my 2d platform game. the platforms are rectangles, so i'd like it to work like this:
the user selects the "platform" tool form the tool box. then, when he starts dragging the mouse, a new rectangle platform is created between the initial drag point and the location of the mouse. when the user releases the mouse the platform is set.
if the user clicks and drags inside a platfrom he can move it, and if he clicks and drags on it's bounds he can resize it. nothing non-standard.
the question is, is there somethin in the sun library that i can inherit from, or do i have to create my code from scratch?
i thought about using drag and drop, but that's useful when i want to move objects from one container to another, no?
thanks, noam
12  Java Game APIs & Engines / Java 2D / Re: Number of transparent pixels makes a difference? on: 2005-10-10 17:07:33
ok, that's a good reason... thank Smiley
13  Java Game APIs & Engines / Java 2D / Re: Number of transparent pixels makes a difference? on: 2005-10-10 14:03:43
But this would only help in a very few cases with only a few (i guess less than 10%) opaque pixels
sorry, but i really wnat to get to the bottom of this, why wouldn't it help in other cases? it gets rid of some alpha checking, and doesn't add new calculations, so i think it can only fasten the code, not slow it down. of course, it'll only work for software rendering of bitmask images, but that's still is alot, isn't it?
14  Java Game APIs & Engines / Java 2D / Re: Number of transparent pixels makes a difference? on: 2005-10-10 13:45:44
maybe i'm not understanding you, but this line:
only calculating alpha for non-opaque/transulescent pixel would be more expensive
makes me think that you don't understand me, because you talk about calculating alpha, though my method only checks the alpha at initialization, and after it just iterates through the opaque pixels (it's a bitmask image, so it doesn't have anything else than opaque and copletley transparent pixels).

15  Java Game APIs & Engines / Java 2D / Re: Number of transparent pixels makes a difference? on: 2005-10-10 11:25:38
I do not want to tell you again something which is not true but as far as I can imagine for buffered-image -> buffered-image blits
First variant:
- check if pixel is opaque (at least a compare/jump operation, maybe also masking)
- put into opaque array
- go through opque array and paint
- ....
For todays processors such opeations are a lot slower than just doing the same

that's not the thing i had in mind.
you put the opaque pixels into the opaquearray on initialization, and then you just iterate through it every game loop. thus skipping the checking of the transparent pixels.
so, the order will be:
in initialization:
- check if pixel is opaque (at least a compare/jump operation, maybe also masking)
- put into opaque array
in the paint method:
- go through opque array and paint
here's some code to demonstarte my intentions:
class Pixel
{
     public Pixel(int X,int Y,Color color{
     ///some code here...
     }
     public Color color;
     public int x;
     public int y;
}
//(in Ctor)
{
        for(int i=0;i<width;i++)
        {
             for(int j=0;j<height;j++)
             {
                  if(pixel at (i,j) is opaque)
                  {
                        opaqueArray.add(new Pixel(i,j,color));
                  }
             }
        }
}
(in draw function)
{
        for(int i=0;i<opaqueArray.length;i++)
        {
           dst_image.setPixel(opaqueArray.x,opaqueArray.y,opaqueArray.color);//no checking for alpha, becuase
                                                                                                                                                 //opaquearray contains only opaque pixels
        }
}

of course i'm sure this has no resemblence to the real code, it's just to clarify the idea i thought of.
16  Java Game APIs & Engines / Java 2D / Re: Number of transparent pixels makes a difference? on: 2005-10-09 14:39:40
i still don't understand why, when it's a BufferedImage created with BITMASK,  you can't use the following ,method:
you create a two dimensional array of integers that stores the coordinates of only the opaque pixels, than the initialization code will look something like this:
for all pixels in src image do
  if pixel is opaque then add the pixel's coordinates to opaqueArray
  else go to next pixel
done
and the draw loop will look like this:

for all coordinates in opaqueArray do
  fetch a coordinate from opaqeuArray
  get the pixel in that coordinate from src image
  set the dst image's pixel at that coordinate to the src pixel color
done
that you you don't need to check if the pixels are transparent every draw loop.

to your question, the question came up when i wantd to add some drawing to an already large pic, but the drawing is very big on one dimesnsion adn very small on the other, so it adds alot of transparent pixels.
17  Java Game APIs & Engines / Java 2D / Re: Number of transparent pixels makes a difference? on: 2005-10-07 15:49:33
thanks for a great answer! i understand much more now, but i haven't gotten my answer- you answered what happenes with a translucent pixel (has alpha that is greater than zero but smaller than one), i.e that of an image created with Transparency.TRANSLUCENT, while i asked for transparent pixels, those who have zero alpha value, and are stored in an image created with Transparency.BITMASK.
to make it more clear, here's the original question, after a couple of changes:
if i have two pictures in different sizes, both created with Transparency.BITMASK, and have the same number of opaque pixels, will they draw at the same speed (more or less)?
thanks, noam
18  Java Game APIs & Engines / Java 2D / Re: Number of transparent pixels makes a difference? on: 2005-10-06 15:34:46
but it seems so logical that if the image is of type bitmask,  you can speed up the drawing by creating an array of coordinates, containing the coordinates of only the opaque pixels, and when you draw, you iterate through this array, thus skeeping the check of whatever the pixels are transparent or not. thus, the only thing that'll affect the rendering speed is the number of opaque pixels...
19  Java Game APIs & Engines / Java 2D / Re: Number of transparent pixels makes a difference? on: 2005-10-06 15:04:06
yes. the one with the more pixels has obviously larger dimensions...
20  Java Game APIs & Engines / Java 2D / Number of transparent pixels makes a difference? on: 2005-10-06 14:03:24
suppose i have a buffered image with some pixels transparent and some opaque. now, i've drawn this imag into a larger buffered image, that before the operation was completley transparent. so now i have two pictures with the same number of opaque pixels, but a different number of transparent ones. will this affect the speed of the rendering, and if it does, how much?
21  Java Game APIs & Engines / Java 2D / Re: opengl won't let me change resolution on: 2005-10-02 20:17:57
something i thought of- the images get replaced with a white rectangle only after they have been drawn a couple of times, so i guess it happenes the moment they are cached! what's happening and why?
22  Java Game APIs & Engines / Java 2D / Re: opengl won't let me change resolution on: 2005-10-02 19:33:45
Why do you create a new DisplayMode object?
It's *always* best to pick a DisplayMode that you got from "getDisplayModes()"
absolutely right...
that changed the problem, but didn't solve it-
now the resolution did change, but the screen remained black. so i added a short (two seconds!) waiting time in order to allow the new calibration to "settle in". so now in the first frame everything looks ok, but than every where on the screen where an image should be drawn, appears a white rectangle instead (?!). plus, the speed drops signficantly, as though opengl wasn't even enabled... very wierd...
23  Java Game APIs & Engines / Java 2D / Re: opengl won't let me change resolution on: 2005-10-02 16:54:59
Nope, i'm running on win xp
24  Java Game APIs & Engines / Java 2D / opengl won't let me change resolution on: 2005-10-02 14:33:52
when the my game initializes i set fullscreen mode and the resolution i want. this works fine when i don't enable opengl. but when i do, it won't permit any change of resolution (even if i try to set the resolution to the current resolution, it tells me that that display mode isn't available). i change resolution like so:
public void SetResolution(int PWidth,int PHeight,int PDepth)
   {
      if (!gd.isDisplayChangeSupported())
      {
          System.out.println("Display mode changing not supported");
          return;
      }
           boolean available=false;
                DisplayMode[] modes = gd.getDisplayModes(); // modes list
      for(int i = 0; i < modes.length; i++) {
          if ( width == modes.getWidth() &&
          height == modes.getHeight() &&
          bitDepth == modes.getBitDepth() )
                    {
                        available=true;
                    }
                }
          if (!available) {
          System.out.println("Display mode (" + PWidth + "," +
          PHeight + "," + PDepth + ") not available");
          return;
          }
          DisplayMode dm = new DisplayMode(PWidth, PHeight, PDepth,
          DisplayMode.REFRESH_RATE_UNKNOWN); // any refresh rate
          try {
          gd.setDisplayMode(dm);
          System.out.println("Display mode set to: (" +
                PWidth + "," +
                 PHeight + "," + PDepth + ")");
          }
          catch (IllegalArgumentException e)
          { System.out.println("Error setting Display mode (" +
                PWidth + "," +
                 PHeight + "," + PDepth + ")"+e.toString()); }

   }
25  Java Game APIs & Engines / Java 2D / Re: can a translucent image be quicker to draw than a bitmask one? on: 2005-10-02 13:53:52
After trying to add and remove all sort of things to my code, i finally realized what's my mistake- during the loading of the images from bitmap files, i've used a pixel grabber to make some pixel transparent. when i marked this line out the images were being accelerated. so i've solved my problem. my final question is, why does using a pixelgrabber on an image prevent it from being accelerated?
thanks, noam
26  Java Game APIs & Engines / Java 2D / Re: can a translucent image be quicker to draw than a bitmask one? on: 2005-09-30 22:31:00
 even if don't use texture paint but instead use drawimage (which gives a static, non scrolling background), the images are still not cached, and the painting takes even longer... maybe there's something else beside Antialiasing that can prevent caching?
27  Java Game APIs & Engines / Java 2D / Re: can a translucent image be quicker to draw than a bitmask one? on: 2005-09-30 10:10:03
Well each image  (this only applies to todays OpenGL implementations, there are already boards supporting "normal" sizes too) is cache in an OpenGL Texture which has to be x^2 size. so either 64, 128, 256, 512, 1024, 2048 ... and boom since this is the texture-size limit of ATI cards ;-)
So if you could resize your two background-images to 1024x256 and 64x1024 you would save for those two images 75% of texture memory.

Which card are you using? How much memory does it have?
lg Clemens
i'm using nvidia geforce mx400, with 60 mb of memory.
i've reduced the images sizes to 1024x256 and 64x1024, but they are still not cached... maybe they're just too big?
28  Java Game APIs & Engines / Java 2D / Re: can a translucent image be quicker to draw than a bitmask one? on: 2005-09-30 00:23:04
Finally, a breakthrough!
i don't know how i haven't noticed it before, but the drawing only takes long for only two pictures(though smaller ones are not cached either)- the extremely large ones, at the size of about 1066X266 (backgound)  and the other at 65X1100. is this too big for caching. i'm also not drawing the image by using drawImage but instead i create a texturepaint object in order to wrap the image all over the screen. could this be a problem too?
yup
are you refering to  the first question (about image sizes), or to the second one (about using texturepaint)?

That is some extremely bad sizes for images. It's possible that they have to be stored in pow2 textures in wich case you'll really be using a 2048x512 and 128x2048 backgrounds. Max 512x512 would be safe in opengl and 256x256 would be the optimal for the default pipeline. I think Undecided
so what do i do? chop down every large image into 10 small images?
29  Java Game APIs & Engines / Java 2D / Re: can a translucent image be quicker to draw than a bitmask one? on: 2005-09-29 17:27:59
Finally, a breakthrough!
i don't know how i haven't noticed it before, but the drawing only takes long for only two pictures(though smaller ones are not cached either)- the extremely large ones, at the size of about 1066X266 (backgound)  and the other at 65X1100. is this too big for caching. i'm also not drawing the image by using drawImage but instead i create a texturepaint object in order to wrap the image all over the screen. could this be a problem too?
30  Java Game APIs & Engines / Java 2D / Re: can a translucent image be quicker to draw than a bitmask one? on: 2005-09-29 14:06:53
Okay, that's a start. As Dmitri said above, -Dsun.java2d.trace=count is your friend. That will tell you what is being accelerated by the OGL pipeline, and what is not. So try again with both the opengl and trace flags, and post the output here.
here it is:

62 calls to OGLDrawGlyphs
468 calls to sun.java2d.opengl.OGLTextureToSurfaceTransform::TransformBlit("OpenGL Texture", AnyAlpha, "OpenGL Surface")
41 calls to OGLDrawRect
36 calls to sun.java2d.opengl.OGLRTTSurfaceToSurfaceBlit::Blit("OpenGL Surface (render-to-texture)", AnyAlpha, "OpenGL Surface")
6 calls to sun.java2d.opengl.OGLSwToTextureBlit::Blit(IntArgbPre, SrcNoEa, "OpenGL Texture")
38 calls to OGLDrawPoly
82 calls to OGLDrawLine
57 calls to sun.java2d.loops.DrawPolygons::DrawPolygons(OpaqueColor, SrcNoEa, AnyInt)
38291 calls to sun.java2d.loops.Blit$GeneralMaskBlit::Blit(IntArgbBm, SrcOverNoEa, "OpenGL Surface")
37 calls to sun.java2d.loops.Blit$GeneralMaskBlit::Blit(IntRgb, SrcNoEa, IntArgbBm)
37 calls to sun.java2d.loops.Blit::Blit(IntRgb, SrcNoEa, IntArgb)
37 calls to sun.java2d.loops.MaskBlit$General::MaskBlit(IntRgb, SrcNoEa, IntArgbBm)
2866 calls to OGLFillSpans
39351 calls to sun.java2d.loops.Blit::Blit(IntArgb, SrcNoEa, IntArgbPre)
39363 calls to sun.java2d.opengl.OGLMaskBlit::MaskBlit(IntArgb, SrcOver, "OpenGL Surface")
2 calls to sun.java2d.loops.Blit::Blit(IntRgb, SrcNoEa, IntRgb)
37 calls to sun.java2d.loops.MaskBlit::MaskBlit(IntArgb, AnyAlpha, IntArgbBm)
449 calls to sun.java2d.loops.MaskBlit::MaskBlit(IntRgb, AnyAlpha, IntArgbPre)
39602 calls to sun.java2d.opengl.OGLDelegateBlit::Blit(IntArgb, AnyAlpha, "OpenGL Surface")
40731 calls to sun.java2d.loops.Blit::Blit(IntRgb, SrcNoEa, IntArgbPre)
39614 calls to sun.java2d.loops.MaskBlit$General::MaskBlit(IntArgbBm, SrcOverNoEa, "OpenGL Surface")
630 calls to sun.java2d.loops.MaskFill::MaskFill(AnyColor, Src, IntArgbPre)
39623 calls to sun.java2d.loops.Blit::Blit(IntArgbBm, SrcNoEa, IntArgb)
188 calls to OGLFillRect
6 calls to sun.java2d.opengl.OGLSwToSurfaceTransform::TransformBlit(IntArgbPre, AnyAlpha, "OpenGL Surface")
282636 total calls to 25 different primitives

what's the conclusion?

Pages: [1] 2 3
 

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

The first screenshot will be displayed as a thumbnail.

Longarmx (52 views)
2014-10-17 03:59:02

Norakomi (42 views)
2014-10-16 15:22:06

Norakomi (32 views)
2014-10-16 15:20:20

lcass (37 views)
2014-10-15 16:18:58

TehJavaDev (68 views)
2014-10-14 00:39:48

TehJavaDev (66 views)
2014-10-14 00:35:47

TehJavaDev (59 views)
2014-10-14 00:32:37

BurntPizza (73 views)
2014-10-11 23:24:42

BurntPizza (45 views)
2014-10-11 23:10:45

BurntPizza (85 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

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
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!