Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (109)
games submitted by our members
Games in WIP (536)
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  
  Image (text) ticker implementation?  (Read 1443 times)
0 Members and 1 Guest are viewing this topic.
Offline whome

Junior Member




Carte Noir Java


« Posted 2009-02-17 14:34:50 »

How would you implement an image ticker scroller, I mean the proper way from the 3d resource point of view?

I have done an image ticker without 3d stuff. Moving images in a window bottom like a news ticker is not hard in a true 2D drawing. Each image takes an exact size and moves from right to left in a nice queue.

But using 3D stuff we must consider resource allocation, remember pow-2 texture size. If I had a long text string rendered to a png image 920x50px size, its quite nasty to create a texture from it. And I have two to twenty of them in a scroller data.

Screen size: 800x600
scroller height: 50px

scroll1 width 920px -> 1024x64 texture
scroll2 width 420px -> 512x64 texture
scroll3 width 1240px -> 2048x64 texture
and so on longer text strings start to grow out the roof.

I was thinking of few optimizations:
a) split longer data images to two or more textures, create sprite objects. Animate sprites to move across the window.

b) create one texture a size of the scroll area (1024x64) minimum, do not move texture but update pixel content at runtime to simulate data images scrolling across the window.

Any first-hand tips and experience any of you?
Online Riven
« League of Dukes »

JGO Overlord


Medals: 757
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #1 - Posted 2009-02-17 15:11:03 »

Fill 1 texture will the first 256 characters (16x16 tiles)

Then use java.awt.FontMetrics to position your quads.

Constant memory usage, no matter what the text length is.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline whome

Junior Member




Carte Noir Java


« Reply #2 - Posted 2009-02-17 15:51:47 »

Problem is I need to use a full unicode range, not just common known letters. And image may have one or two graphics images, bullets, effects and smileys so on... So I was thinking of creating plain 2d images using drawing api and scroller does not see texts as text but a ready to use image file.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Online Riven
« League of Dukes »

JGO Overlord


Medals: 757
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #3 - Posted 2009-02-17 16:18:43 »

Then you can use the texture as a cache of 256 characters. I doubt 1 ticker-item will use more than 256 unique characters.
Just in case, make the texture bigger, and use a cache of 512 or 1024 characters. You keep streaming new characters to the texture when required.


Then again, just drawing everything in Java2D, you'll not have any problems with large textures until you hit 4096px (or so), although you probably want to chop your textures into 256px anyway, to keep things managable.

If you have a group of ~6 textures of 256px (depending on the resolution width), and every texture that scrolls out of view is repositioned at the other side, you can just copy java.awt.Images from Java2D into those small textures. Then your drawing logic will be fully in Java2D (which is probably a good thing) and you only need to call g.translate(x,y) to draw the right part of the text in the Image (which is also 256px), which will be fully copied to the texture.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline whome

Junior Member




Carte Noir Java


« Reply #4 - Posted 2009-03-06 11:31:44 »

(follow-up post)
This is what I have done now, I made a test with Delphi+DX but similar technique should apply to JOGL/LWJGL 3d apps.

* create and render texts using a regular 2d drawing apis, no 3D is used here.
* split and save ARGB bitmaps to 256x64 image_XXX.png files
* create six 256x64 textures, just to fill entire scrolling width plus few extras
* bind first six bitmap memory buffers to texture objects and start scrolling

* when leading texture goes leftside offscreen, move it to the end of list and bind next pending memory buffer on it
* keep scrolling, move to the end, bind next memory buffer

Now I can run unlimited number of images, be it textTobitmap, bulleting icons anything  and use six fixed-size textures. Nice. Testscroller.exe takes 0-1 CPU% in a low-end laptop so am happy.

edit: testcroller.exe is using DX vertex buffers, I found out directx IDSprite interface did not give smooth enough animations.

I can vsync windowed DirectX9 application so scrolling is close to a ultra smooth. I believe this is going to be a major Java problem.

Working vsync is close to impossible in windowed Java application?
I am more than pleased to see examples if there are methods to make ultra smooth windowed animation.
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.

CogWheelz (18 views)
2014-07-30 21:08:39

Riven (25 views)
2014-07-29 18:09:19

Riven (15 views)
2014-07-29 18:08:52

Dwinin (13 views)
2014-07-29 10:59:34

E.R. Fleming (33 views)
2014-07-29 03:07:13

E.R. Fleming (12 views)
2014-07-29 03:06:25

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

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

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

Riven (31 views)
2014-07-23 20:56:16
List of Learning Resources
by SilverTiger
2014-07-31 18:29:50

List of Learning Resources
by SilverTiger
2014-07-31 18:26:06

List of Learning Resources
by SilverTiger
2014-07-31 13:54:12

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
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!