Author Topic: Blitting a UI onto the FrameBuffer  (Read 11992 times)

Offline cyberkilla

  • float
  • ****
  • Posts: 413
    • View Profile
    • http://futurerp.net
Blitting a UI onto the FrameBuffer
« on: February 02, 2007, 08:45:50 pm »
Hello again, yes, it is that time of the week:)
The time when I suddenly feel the urge to ask strange questions;).

Here we go......

I have a user interface. It is composed of several transparent images.



I looked through some of the Paradroidz source code, and found an interesting way of using textures and blitting.

Now, the blitting is fine for most of the stuff, but the bottom bar draws item thumbnails into the boxes.
This doesnt change much, so it would be a waste to keep drawing the images ontop.

Is there a way to save a copy of the blitted material, and reuse it.
Or, perhaps draw it on a BufferedImage, and create a texture from it?

Thanks again:)

EDIT:
Perhaps an ITextureEffect that uses a cached BufferedImage of the icons, and applies this to the dest[]?

Perhaps it would just be quicker to draw the item thumbnails like im doing everything else?:)
http://futurerp.net - Text Based MMORPG
http://beta.rpwar.com - 3D Isometric MMORPG

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Blitting a UI onto the FrameBuffer
« Reply #1 on: February 03, 2007, 12:03:06 pm »
Is this about the GUI of your game? If so, why would you want to blit into a jPCT FrameBuffer?

Offline cyberkilla

  • float
  • ****
  • Posts: 413
    • View Profile
    • http://futurerp.net
Blitting a UI onto the FrameBuffer
« Reply #2 on: February 03, 2007, 01:03:44 pm »
It is, yes.
I am experimenting with pure 3d, Egon.

Do not think I am jumping from one thing to the other;)

I merely wish to learn how to do it both ways.
http://futurerp.net - Text Based MMORPG
http://beta.rpwar.com - 3D Isometric MMORPG

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Blitting a UI onto the FrameBuffer
« Reply #3 on: February 03, 2007, 01:09:43 pm »
Well, then...i would start with blitting it each frame. That shouldn't be too heavy to handle. Everything else (blitting it into a BI, into another FrameBuffer or using an ITextureEffect) is fine for the software renderer but will slow down the hardware one.
I don't think that blitting a larger block is so much slower than blitting a few smaller ones which basically cover the same space on screen (or even less).

Offline cyberkilla

  • float
  • ****
  • Posts: 413
    • View Profile
    • http://futurerp.net
Blitting a UI onto the FrameBuffer
« Reply #4 on: February 03, 2007, 02:44:38 pm »
Okay, I will try it like that.

Thanks Egon:). I will post some screenshots of my progress.
The UI implementation is something that people seem very interested in.

Perhaps I could create a small UI Toolkit for the renderer.
I am also experimenting with controls, such as windows and buttons, and textfields, which are fully skinnable, and resizable.

I am just using a single texture, and blitting the parts into the right place.
I'm also using a keyboard focus interface to give keyboard data to only the control with focus. Its quite interesting. Ill definitely paste it here when im done:)
http://futurerp.net - Text Based MMORPG
http://beta.rpwar.com - 3D Isometric MMORPG

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Blitting a UI onto the FrameBuffer
« Reply #5 on: February 03, 2007, 03:20:18 pm »
For a GL based UI-toolkit that should work with jPCT, have a look here: http://www.fenggui.org/doku.php
I don't much about it, but raft used it in a test application and it seemed to work fine. It's GL-only of course, so the hardware renderer is a must when using it.

Offline cyberkilla

  • float
  • ****
  • Posts: 413
    • View Profile
    • http://futurerp.net
Blitting a UI onto the FrameBuffer
« Reply #6 on: February 03, 2007, 04:55:37 pm »
Wow, that is nice!

I cant help feeling it would be too heavyweight for a big game though.
Still, I must give it a try, but, as you said, it removes all possibility of using software mode.

EDIT:
Ive just noticed I cant blit with an alpha channel. I wonder what other ways this can be done. I distinctly remember some of raft's work using alpha.
I think I better do a quick search:).
http://futurerp.net - Text Based MMORPG
http://beta.rpwar.com - 3D Isometric MMORPG

Offline cyberkilla

  • float
  • ****
  • Posts: 413
    • View Profile
    • http://futurerp.net
Blitting a UI onto the FrameBuffer
« Reply #7 on: February 03, 2007, 06:12:36 pm »
I know that there is no bug here. Im just wondering what other ways there is to achieve this effect...



EDIT:
I am not concerned if the software renderer only supports opaque in this case,
but when the mode is set for openGL, it would be nice to use a translucent interface.

It looks like raft is using Swing/AWT to achieve it, but with a native window, which is surely impossible.


Argh, google found this on your changes page:)
Quote

"Removed some alpha related code from the 2d blitting routines...no clue, if it was of any need...i couldn't find any."


You know, Egon, I am seriously considering this as an alternative to what I was doing before.
I find myself able to make 3d models a lot faster than I can make 2d images that have the look of 3d.

There is also a lot more that be done in terms of weaponry, and special effects.

The more I experiment with this engine, the more I am hooked on it:).
You really have done an excellent job with it.

Your change to permit alpha framebuffer has enabled me to pre-render thumbnails of the items in the inventory.

There must be a way to blit in alpha. Perhaps it is staring me in the face.
http://futurerp.net - Text Based MMORPG
http://beta.rpwar.com - 3D Isometric MMORPG

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Blitting a UI onto the FrameBuffer
« Reply #8 on: February 04, 2007, 01:49:15 am »
Alpha for hardware is possible. Just supply a proper alpha channel to the texture like PNG offers it. There are constructors for creating a texture with alpha. Use these and do a transparent blit and alpha will be there.

Edit: Here's an example: http://www.jpct.net/forum/viewtopic.php?t=724

Offline cyberkilla

  • float
  • ****
  • Posts: 413
    • View Profile
    • http://futurerp.net
Blitting a UI onto the FrameBuffer
« Reply #9 on: February 04, 2007, 01:51:04 am »
Really? Wow! Im both embarrassed, and excited! I must test this!

Btw, i use quite dark textures - will the darker colours be invisible by mistake?
I have an idea. I will test it to find out:)

EDIT:
Actually, im more embarrassed than excited. I should have noticed that :roll: .
http://futurerp.net - Text Based MMORPG
http://beta.rpwar.com - 3D Isometric MMORPG

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Blitting a UI onto the FrameBuffer
« Reply #10 on: February 04, 2007, 01:52:39 am »
Quote from: "cyberkilla"

Btw, i use quite dark textures - will the darker colours be invisible by mistake?
If a texture comes with no alpha channel, the texture loader creates one and sets all dark (everything below 0f0f0f i think) areas to be translucent.

Offline cyberkilla

  • float
  • ****
  • Posts: 413
    • View Profile
    • http://futurerp.net
Blitting a UI onto the FrameBuffer
« Reply #11 on: February 04, 2007, 01:57:50 am »
Yup, works perfectly!

Many thanks Egon:)

Evidently, I do not know why I continue to call you Egon, when I know it is not your real name: P
http://futurerp.net - Text Based MMORPG
http://beta.rpwar.com - 3D Isometric MMORPG

Offline cyberkilla

  • float
  • ****
  • Posts: 413
    • View Profile
    • http://futurerp.net
Blitting a UI onto the FrameBuffer
« Reply #12 on: February 04, 2007, 03:20:28 am »
Login screen starting to take shape now.

I have succeeded in creating a window manager/control manager.
I have make the windows, and the actual controls(textfield shown below) as separate entities, because I will never nest them, and the source looks cleaner/faster:)

http://futurerp.net - Text Based MMORPG
http://beta.rpwar.com - 3D Isometric MMORPG

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Blitting a UI onto the FrameBuffer
« Reply #13 on: February 04, 2007, 01:49:58 pm »
Looks fine! And calling me Egon is fine too, btw... :wink:

Offline ToddMcF2002

  • long
  • ***
  • Posts: 103
    • View Profile
Re: Blitting a UI onto the FrameBuffer
« Reply #14 on: April 03, 2007, 06:03:59 am »
So I got this working myself with the alpha channel - very slick!  But honestly... what are you folks using to create your PNGs?  I'm using GIMP right now and I'm pulling my hair out trying to figure out how to do basic drawing.

Is there anything easier?