www.jpct.net
jPCT - a 3d engine for Java => Support => Topic started by: paulscode on December 15, 2008, 01:15:02 am
-
Here's another question that's probably been asked a hundred times:
Is there a way to get a Graphics context to draw on when using hardware rendering mode? I can't use getGraphics() since, as the Javadoc states, "when using OpenGL support, this value is rather meaningless".
I suppose I could draw my layer onto an Image, and use that to create a Texture to use in the blit() method. I'd have to rethink how I handle images that change dynamically (since I wouldn't want to create a new texture every frame). Also, is a texture's alpha information taken into account by blit()? If not, is there another way to draw simi-transparent 2D stuff on top of the rendered scene?
--EDIT-- I see that one of the blit() methods has the ability to set an additional color. I'll play around with this to see if I can get the results I'm looking for.
-
Using a graphics context doesn't work, blitting is the way to go. Either that or use the Overlay from the util-package, which is similar to blitting but not exactly the same.
-
Thanks! I hadn't noticed the Overlay class ( I should really spend more time reading the Javadoc ;) ) That will definitely be useful for my 2D images that are more or less permanant, like borders or the outline for a life-meter, etc, and the blit() method looks best for dynamicaly changing foreground stuff like menus and highlighting.
Do both of these take a Texture's alpha information into account when drawing on top of the scene?
-
Yes, both support alpha when using the hardware renderer. When using the software renderer, only the overlay will.
-
Cool. I'll probably stick with the Overlay class then. I noticed it has a setVisibility() method, so as long as I break my dynamically changing images down into small enough components, this class should be able to handle everything, without having to constantly dispose() and create new Overlay instances. That way I won't have to write different code between software or hardware renderers.
Thanks for the info!