Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (762)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (846)
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 2075 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  

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

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

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

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

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

nelsongames (834 views)
2018-04-24 18:14:32

ivj94 (1282 views)
2018-03-24 14:47:39

ivj94 (399 views)
2018-03-24 14:46:31

ivj94 (1068 views)
2018-03-24 14:43:53

Solater (416 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 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!