Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (107)
games submitted by our members
Games in WIP (534)
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  
  Unit testing rendering?  (Read 1476 times)
0 Members and 1 Guest are viewing this topic.
Offline Jordgubben

Junior Newbie





« Posted 2007-02-08 14:40:11 »

I'm working on a small 2d-game engine and I've run in to some trouble. So far I've been very strict on coding test first programming and using JUnit to test everything.  But now I've come to the point where I'm rendering simple graphics, but I have no idea how to test this.  Huh

I'm guessing I should use some how BufferdImage.createGraphics(); to create a Graphics2D, render and then check the image for result. But beyond that I have no idea how to do things. Is there any one here that has had any experience with unit testing rendering that can give me a pointer or two in the right direction?  Undecided
Offline blahblahblahh

JGO Coder


Medals: 1


http://t-machine.org


« Reply #1 - Posted 2007-02-08 15:29:58 »

Just f'ing google it, for a start. But, beyond that, I would suggest you probably don't need to bother. Rendering unit testing takes a lot of effort and is worth the pain on large projects with many artists and toolchain and rendering and systems coders, but not so great on small projects.

malloc will be first against the wall when the revolution comes...
Offline quixote_arg

Junior Member


Projects: 1


Jengibre


« Reply #2 - Posted 2007-02-08 15:35:09 »

you can try something like this

http://oddlabs.com/blog/?p=20

It's not exactly unit test, but it will save you time and it's very easy to implement
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #3 - Posted 2007-02-08 15:49:46 »

I have yet to see a good method of unit testing graphics, other than the badly flawed "take a picture and compare it to a canned result" method.

I think you should be able to put the surrounding code under test (eg. image loaders, sprite priority management, etc.). But if you're using Java2D most of these are already written so you're only really writing the glue to put it together. I might have a MockRenderer which just checks that certain objects are actually calling into the renderer at the correct times/places, but even that might be overkill.

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline Jordgubben

Junior Newbie





« Reply #4 - Posted 2007-02-10 13:37:21 »

you can try something like this

http://oddlabs.com/blog/?p=20

It's not exactly unit test, but it will save you time and it's very easy to implement

Thanks! It wasn't really what I was looking for but it gave me some (hopefully good) ideas. If there was just some way to log Graphics2D. DebugGraphics has a functionality like this, but only for Graphics and I need the Graphics2D transformation stuff. Maybe I can implement a wrapper myself doing something like this on all Graphics2D methods:

1  
2  
3  
4  
public void drawString(String str, int x, int y) {
   someList.add("public void drawString("\" + str + "\", "+x+", "+y+") ");  
   realGraphics2D.drawString(str, x,  y);
}


Of course, doing this manually for all functions would be insane (in a bad way). Maybe it could be made with automated code generation. I'll Google it and see if I can figure something out. Thanks again  Cheesy
Offline quixote_arg

Junior Member


Projects: 1


Jengibre


« Reply #5 - Posted 2007-02-10 14:32:59 »

you're welcome Smiley

keep us posted on the solution
Online Abuse

JGO Coder


Medals: 11


falling into the abyss of reality


« Reply #6 - Posted 2007-02-16 21:13:13 »

I have yet to see a good method of unit testing graphics, other than the badly flawed "take a picture and compare it to a canned result" method.

Out of interest, why do you consider this mechanism to be badly flawed?
(barring the obvious task of ensuring the canned result itself is loaded in correctly)

In the world of J2ME I very much wish Sun HAD done this kind of unit testing of the reference implementations primitive & image drawing methods, as alot of them mis-behave in embarrassingly simple scenarios.

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! https://dl.dropbox.com/u/54785909/EliteIVsmaller.png
Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #7 - Posted 2007-02-22 10:48:58 »

Out of interest, why do you consider this mechanism to be badly flawed?
(barring the obvious task of ensuring the canned result itself is loaded in correctly)

In the world of J2ME I very much wish Sun HAD done this kind of unit testing of the reference implementations primitive & image drawing methods, as alot of them mis-behave in embarrassingly simple scenarios.
Well for a game I don't want all my graphics unit tests to break just because I tweeked the shader and traded some accuracy for performance. Practically all pc-style hardware rendering can give slightly different results based on drivers, hardware, colour depth, etc. etc. but will all still look 'correct'. Then you start getting into %age difference between the test result and the reference, and it all gets a little icky.

However now you mention in, for JME and other low-level pixel pushing APIs this method would probably work pretty well. You should be able to get much more reproducable results when you're just talking about basic sprite blitting.

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

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

The first screenshot will be displayed as a thumbnail.

pw (35 views)
2014-07-24 01:59:36

Riven (34 views)
2014-07-23 21:16:32

Riven (22 views)
2014-07-23 21:07:15

Riven (25 views)
2014-07-23 20:56:16

ctomni231 (56 views)
2014-07-18 06:55:21

Zero Volt (48 views)
2014-07-17 23:47:54

danieldean (39 views)
2014-07-17 23:41:23

MustardPeter (43 views)
2014-07-16 23:30:00

Cero (59 views)
2014-07-16 00:42:17

Riven (56 views)
2014-07-14 18:02:53
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
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!