How can I zoom in and zoom out in Allegro 4.4 game programming library? - zooming

void al_scale_transform(ALLEGRO_TRANSFORM *trans, float sx, float sy);
I guess this function zoom in and zoom out in allegro 5.But I use allegro 4.4.
How can I zoom in and zoom out in Allegro 4.4 game programming library? Which function?

I have bad news for you...
In allegro 4 the TRANSFORM object doesn't exist, so you have to handle the matrices yourself to do any kind of transformation on the render surface.
I don't use allegro 4, however, it does have a full chapter on the API about 3D-math routines that might assist you in scaling a bitmap. Keep in mind this is not hardware accelerated as-is because that library was not designed for that, so expect a hit on performance using this functions.
As a side note, here is the definition of a built-in MATRIXtype on allegro 4's library.
If you are not supporting some legacy code from Allegro 4, I would honestly recommend to use the newer Allegro 5 library for a new project as it is the one where the new features are worked on and I personally find it easier to use and better designed.

Related

how to make a camera in tk?

I have a grid based coordinate system where the distance between each grid center is a set number of pixels. Doing this in OpenGL I made a camera using view/projection matrices. Changing view center and scale for the whole scene could be made by setting matrix elements.
This is from a prototype using OpenGL that I made before going full Tcl/Tk. The node positions are {[1..5], [1..3]} (text at fractional y-offset):
How would I accomplish this in Tcl/Tk? I'm reading about canvas zooming however was hoping for a smaller example; create line between 1..2, 3..4, pan, zoom, pan again, zoom again.
The Tk canvas widget supports panning (it's following the Tk scrollable window protocol) but doesn't allow zooming of the viewport. (It has a scale method, but that just changes the coordinates of the objects, which is not the same thing; in particular, it doesn't change things like font sizes, embedded window/image sizes, line thicknesses, etc.) You can control the panning via the xview and yview methods, as with any scrollable Tk widget.
However, there's an alternative that might be more suitable for you.
Paul Obermeier's Tcl3D, which allows you to use OpenGL together with Tcl/Tk, would let you keep a lot of what you've done so far with writing OpenGL code, and yet it still provides the benefits of being able to use Tcl/Tk. Basically, the core of it is that it includes Togl, a package for presenting an OpenGL drawing surface as a Tk widget, together with bindings to the OpenGL API. I know of quite a few people who use Tcl3D to power their (both commercial and open-source) applications, and you'd end up with a hybrid that should provide the best of both worlds. (Also, it's considered entirely reasonable to include some custom C code in a Tcl application that needs a bit more performance in a critical spot; it's outright good style to do this. Complex GUIs sometimes need that sort of thing.)

Refactoring for starling

I'm making a flash app for AIR. The app is mostly made, but I'm not happy with rendering speed on mobile (render mode - gpu).
I know there is a framework that allows user-friendly way to work with Stage3d called Starling, but I've never used it.
After looking into it and following through some tutorials I've noticed that I need to rename all package flash default classes, e.g flash.display.DisplayObject -> starling.display.DisplayObject.
But such action might be destructive to my code base, plus, I have other frameworks attached that work with some flash package classes.
Is there a way to attach Starling to a complete project without re-naming all the package names, changing assets and re-factoring all frameworks that work with default AIR API?
If you're thinking of switching to Starling, you'll have to redesign your whole rendering code. Starling is no drop-in solution. Just renaming classes in your existing code will not do because it completely replaces flash display list for Direct3D, which does all it's rendering with GPU, with all the differences it brings: bitmapped graphics, texture atlases, careful draw ordering. Learning curve can be a bit steep in the beginning but once you get familiar with basic concepts it's a breeze to work with.
IMHO, it's well worth the effort, especially on mobile. Code that ran in low 10s of FPS in classic display list can easily be made to run at solid 60fps with Starling. Basically, for flash on mobile, Stage3D is the only game in town. And Starling is the best supported and widely accepted framework for 2D stuff on Stage3D, with lots of supporting libraries and a very helpful community of developers.
Go on, take the plunge, you won't regret it.
You can run Starling and a native flash application layer at the same time but it wouldn't give you an optimum experience.
If you want to take full advantage of the gpu acceleration of Stage3d and Starling though it would be preferable to refactor your existing code to use Starling display objects rather than Flash display objects.
You might want to post this question on the Starling forum, they are very helpful guys and it's a thriving developer community! - http://forum.starling-framework.org

What does Chrome use for accelerated 2D vector graphics in its HTML5 canvas draw functions?

So i would like to do things like what is possible with a HW accelerated HTML5 canvas for animated 2D vector graphics drawing, but on top of my OpenGL (4.x) rendered 3D scene (for complex HUD and GUI displays). I need this to be able to work on Win7+, MacOs, and Linux, mobile platform support is not needed.
BTW I am working with C++.
I was wondering if anyone knew what for example Chrome uses for accelerated 2D vector graphics in its HTML5 canvas draw functions? I was under the impression it was accelerated using ANGLE (which wraps OpenGL or DX9). Or am I wrong and its only SVG rendering that is accelerated, not the javascript canvas draw functions.
Doing HTML5 canvas style animated 2D vector graphics with OpenGL is highly non-trivial, is Google using an available library for that or is it just in-house code?
I have been looking into OpenVG and have had a hard time finding the right implementation to use for that, so far the only thing i can actually get examples compiled for is ShivaVG (but there seems to be shimmering artifacts for the tiger demo and other issues for the latest release 7 years ago). Also i think ShivaVG is using fixed function and my team decide to lock down our OpenGL usage to 4.x core profile, so that won't work. I would love to use NV_Path_Rendering but its not portable (to anything other than a nvidia accelerated device).
I also thought using OpenVG would be useful since I might be able to hide NV_Path underneath, or a new OpenVG library that might come out in the future. But I am wondering if OpenVG's future might be in peril.
They apparently use the Skia library for all 2D rendering.

3d objects in actionscript 3 without plugins

I am fairly new to actionscript and was wondering is it possible to create 3d shapes (cones, spheres, cubes) using actionscript.
I would like not to have to use a plugin.
The shapes must be 3d as I need to rotate them.
Here you will find Adobes documentation for what you are looking for:
http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS7D38179D-58B9-409c-9E5C-257DDECB1A02.html
Is there any specific reason that you don't want to use 3D libraries like away3D?
I think Matej's answer does not fully cover the topic as the link he gave only describes a classic display list approach to drawing 3D objects. Depending on your needs, drawing things using classic display list can be slow, as it is not GPU accelerated. If you want to utilize your GPU you can use Stage3D APIs - that does not require any external frameworks. Here's an excellent article for starters.
And even though you can render 3D content using 'raw' Context3D, I`d recommend using a framework like Away3D or Alternativa3D. Both are open source, by the way.

Is it possible to accelerate even more Google maps for Flash with Stage 3D hardrware acceleration?

I am using Google Flash API for Flash and so far it is working more than great.
Anyway I wish to increase it's drawing performance using Stage 3D hardware acceleration.
Is it possible to force hardware acceleration using Stage 3D with Google Maps API for Flash ?
It's not possible to force Stage3D acceleration on any existing content.
Apps need to be built specifically for the GPU using the Stage3D API's directly or working on top of a framework. Geometry is composed of triangles defined by a series of vertices, these vertices are essentially colored and assembled by shaders written in AS3's shader assembly language AGAL. Vector content cannot be rendered on the GPU, everything is bitmap based.
This is a great post on how Stage3D is implemented: http://www.adobe.com/devnet/flashplayer/articles/how-stage3d-works.html
Also as RIAstar mentioned, the Google maps Flash API is deprecated. Mapquest has a Flash API that might be worth checking out. I'm not sure how the performance compares since it is not a Stage3D app either.
http://developer.mapquest.com/web/products/featured/as3-flex-flash
YCanvas is an open source 2D tile renderer library written in ActionScript 3. It provides high performance solution for rendering world maps. The library also contains Stage3D (GPU) accelerated implementation based on Starling.
ApplicationMap - YCanvasMap implementation with Feathers UI available on (available tiles: ArcGIS Imagery, ArcGIS National Geographic, MapQuest, OpenStreetMap, MapBox, CloudMade, Bing Maps Imagery)