Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (777)
Games in Android Showcase (231)
games submitted by our members
Games in WIP (856)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Loss of precision or just not VSynched?  (Read 2143 times)
0 Members and 1 Guest are viewing this topic.
Offline cghislai

Junior Newbie

« Posted 2008-12-23 16:37:16 »


My game handle his own backBuffer covering a whole gameArea, bigger than the screen. Differents cameras holds a Poition in the game's coordinates, a position on the screen and Dimension.

The gameArea is horizontally infinite, thats means when you reach right edge, you reappear on the left one. Its true for camera also, so when a camera cover an area that go farther than the right edge, its splitted in two. A method "Map<Rectangle2D, Rectangle2D> getGameAndScreenBounds()" returns mappings between rectangle2Ds representing the covered ingame area, entirely contained on the BackBuffer, and rectangle2Ds representing the screen's area on wich to draw the former one.

On the rendering loop, for each ingame rectanlges of each Camera, i clear the backBuffer with black and i draw sprites contained in the area.
Then, i draw the backBuffer on the screen by clipping the BufferStrategy's graphics2D to the camera's screen Rectangle2D and setting an AffineTransform to translate the buffer so the right game area is drawed.

This works well, but somthimes on the right edge of the camera's screen rectangle, ive got a 1-pixel wide vertical bar of white pixels (not covering the entire hieght of the rect). As i can switch to fullscreen (it seems it doesn't work for me, vm crash, bug  reported), and  i don't have vsync in windowed mode, i wonder if thats might be due to not vsyncing or more likely by a loss of precision?

All my Rectanlge2D use double value. I cast them to int using Math.floor and Math.ceil to be sure each pixel that might be visible is cleared. All my drawImage() calls use AffineTransforms. Clipping is set with setClip(Rectangle2D rect);

A screenshot showing the problem :
The screen is filled with red before copying the backBuffer for each camera.
Notice the white line in the lower right corner.


Pages: [1]
  ignore  |  Print  

hadezbladez (335 views)
2018-11-16 13:46:03

hadezbladez (180 views)
2018-11-16 13:41:33

hadezbladez (336 views)
2018-11-16 13:35:35

hadezbladez (82 views)
2018-11-16 13:32:03

EgonOlsen (2177 views)
2018-06-10 19:43:48

EgonOlsen (2205 views)
2018-06-10 19:43:44

EgonOlsen (1376 views)
2018-06-10 19:43:20

DesertCoockie (2008 views)
2018-05-13 18:23:11

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

nelsongames (2297 views)
2018-04-24 18:14:32
Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45

Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20

Deployment and Packaging
by philfrei
2018-08-19 23:54:46 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!