• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Mixing Android GUI controls with game graphics

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is it possible to use Android GUI controls (buttons, labels, text fields, etc) on top of game graphics? For example; let's say I have an OpenGL drawn scene and want to popup a quit confirmation dialog? (the graphics a really on the box in that case)

What about rendering controls in the actual OpenGL or 2D graphics scene, for example a free floating button or text field in the middle of the screen.

The reason I'm asking is that in the desktop world, gaming engines usually have their own Game UI control libraries. Now, in Java2D/Swing it was possible to do some of this because the Swing controls are lightweight. I'm not sure if the Android controls are lightweight or not, so wondering if you guys know a bit about this (I realize the book is not about gaming, but hopefully you get what I mean).

Thanks!
 
author
Posts: 51
Android Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Satya is the OpenGL guy on our team, so I'm afraid I can't help on this one.

- dave
 
Augusto Sellhorn
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Let me ask it another way, do you know if there's a way to draw a UI control in a view's onDraw method? Say in my 2D game scene I want to draw and animate buttons in the middle of the scene? Or is this done with some type of overlay mechanism?

Thanks
 
author
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Augusto,

I see the dilemma. I don't know the answer.

All I know is OpenGL drawing occurs on a special view called GLSurfaceView which itself is derived from a View. Here is what the doc says about this view

Manages a surface, which is a special piece of memory that can be composited into the Android view system
Provides a dedicated drawing surface embedded inside of a view hierarchy. You can control the format of this surface and, if you like, its size; the SurfaceView takes care of placing the surface at the correct location on the screen

The surface is Z ordered so that it is behind the window holding its SurfaceView; the SurfaceView punches a hole in its window to allow its surface to be displayed. The view hierarchy will take care of correctly compositing with the Surface any siblings of the SurfaceView that would normally appear on top of it. This can be used to place overlays such as buttons on top of the Surface, though note however that it can have an impact on performance since a full alpha-blended composite will be performed each time the Surface changes.



It may be obliquely pointing to what you are refering to.

 
Augusto Sellhorn
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually that's good info. It sounds like for GL views they have something similar to Swing's layered panes. Will have to try it out.

For a 2D view, what I'm thinking is maybe I can pass the Canvas object to the onDraw method of a GUI control. I'm just getting started on Android so sorry, haven't tried out a bunch of these things, just trying to move from the Swing world :-)
 
Satya Komatineni
author
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you will find Android a good company then.

I am quite jealous of the EXTENSIVE graphics API in Android. Probably the most extensive of the Android APIs. You can see this from the sample programs that come with the android sdk.

However having spoiled by the web for so many years I haven't had a chance to cover the graphics API much as I will need to refresh the basic drawing principles on a canvas and using the drawable views etc. Not sure at all when I will get a chance to do that at this moment.

This is one area that needs a good short book

Satya
 
This will take every ounce of my mental strength! All for a tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic