after that it is pass to the rendering that are 2D sprite based on the bufferedImmageinternalRenderGame(dbg);

any sprite before to be render on the dbg ( that i s the Graphics2D) is passed to a chain of effect that execute specific effect implemented as BufferedImageOp brightness, and transparence or affine trasfomration for scale and rotation

1 2 3

//filtersToApplyare all the filter ot use: can be any, one of this or all -->brightness, transparence,scale and rotationBufferedImagefiltered = EffectManager.getInstance().chain(filtersToApply,image, position, size, color);dbg.drawImage(filtered, (int)(position.getPosX() - filtered.getWidth()/2), (int)(position.getPosY() - size.getHeigh()/2), null);

in the end finally draw the final immage with all the sprite and background painted over

but before is possible to pass the final image (that is the immage with the background and all the sprites) again to a chain of effect (that is implemented has before as BufferedImageOp brightness to make obscuration of all the immage)

ALL this story to explane that it is very easy nothing complex, and when i have activated the "OpenGL" VM flag -Dsun.java2d.opengl=True, my application is start to be very slow!!! it become a disaster, lost 30% of the frames!!!!i would like to understand why, or at list to understand how to analyze

Also, I have to say that, for some reason, the global performance of intelHD with java2D is quite bad, maybe is a driver issue. I have also a Nvidia GT520 in the laptop. In theory Nvidia GPU is not much better than the intel HD, but the performance in java2D is much better, maybe 5 times faster. Also, sometimes, the intel behaves weirdly. The performance suddently drops when I add some extra pictures.

-------------------------------------------

About the code you show. Several months ago a did many microbenchs in order to get the best performance with java2D, but I don't remember all the details.

You use a jPanel for drawing the stuff?. Did you tried to use a BufferStrategy over a canvas instead? As far I remember it gives better performance.

Ok, then you apply a set of affineTransforms, right?, so you create an intermediate BufferedImage called "filtered" with all the changes. Do you tried directly to draw the image to dbg without creating that "filtered" image?

something like this:dbg.scale(scaleX,scaleY);dbg.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,desired_alpha));dbg.drawImage(image,brightness_operation,posX,posY);

Oh, yes! davedes post remind me an important thing. Sometimes Java2D cannot recognize the hardware, so the direct3D pipeline cannot be activated. This happens for example in laptops with nvidia optimus.

You can solve this with the environment variable J2D_D3D_NO_HWCHECK=true, so you deactivate any hardware checking and pipeline can be enabled.

I would love to try java2D in more computers. But yes, it seems that if you go outside standard configurations, weird things can happen. That makes development more thrilling

Setting flags like that always screams to me "I can determine what Java2D pipeline will run faster on this machine better than Java2D itself can." Do you think the JVM is picking the wrong pipeline for some reason?

never tried to do it by canvas, is there a specific method to do it automatically? the old AWT expose something to do it? if exsist let me know i want to try it

Quote

Ok, then you apply a set of affineTransforms, right?, so you create an intermediate BufferedImage called "filtered" with all the changes. Do you tried directly to draw the image to dbg without creating that "filtered" image?

this part of the code is already optimized, the solution applied is this:every image transformed in the chain of effect is stored in a repository keeping with it information of the kind of transformation performed over it, so every time that on a image is required to execute same effect, first of all I look in the repository if that image with that kind of transformation already exists in this case this image is get and reused, other ways a new image with effect is created and saved in the repository. this make in my case a huge increasing of the performance and aloud to me to work on image modification on the flybut the back side of this solution is the memory used to store images in the repository

instead regarding this fact (davedes please don't take it personally, but i have to write this)

Quote

General consensus is: if you need reliable performance, Java2D is the wrong choice

the fact that exist technologies that are better of the Java2D is something that also the kids know,so if i use this specific section of the forum called Java2D, and not OpenGL Development may be ther is a reason what u think?http://www.java-gaming.org/boards/java-2d/15/view.html

if i can get 1 euro for all the guys that write in this forum,

Quote

General consensus is: if you need reliable performance, Java2D is the wrong choice

i will become one of the most reach person in the word (ok i will open a topic for this )

regarding the real discussion of this topic,

Quote

Setting flags like that always screams to me

me too!!!

i want to try to set the variable J2D_D3D_NO_HWCHECK=true and try to activate the direct3D. i will let to know how it works

alesky, I show you a skeleton of a canvas ready for drawing anything you want. I use a VolatileImage as a intermediate buffer. I set the same name you used. If you try it, it would be great some result comparison

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