Java fillRect() with TexturePaint is slow

人走茶凉 提交于 2019-12-11 19:48:55

问题


TexturePaint Problems

I am currently making a 2D game using texturepaints. One significant problem I encountered was the fact that filling rectangles with the graphics2D setPaint method set to a texture paint is extremely slower than filling a rectangle with a base color. Is there possibly any other way to speed up painting by creating a custom class similar to Texturepaint that paints much faster? At this point I really don't know what to do because my fps is stuck at around 18-23fps.

EDIT :

        g2d.setPaint(new TexturePaint(current_paint.getImage(), new Rectangle(CamX, CamY, current_paint.getImage().getWidth(), current_paint.getImage().getHeight())));
        g2d.setClip(AffineTransform.getTranslateInstance(CamX, CamY).createTransformedShape(paint_regions.get(current_paint)));
        g2d.fillRect(0, 0, host_frame.getWidth(), host_frame.getHeight());

        System.setProperty("sun.java2d.opengl","true");//True or false makes almost no difference.

*Note : When commented out fillRectangle() is noticeably expensive.

来源:https://stackoverflow.com/questions/23118515/java-fillrect-with-texturepaint-is-slow

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!