Dynamic compass using OpenGL


Purpose
This sample demonstrates how to draw on a map in dynamic mode using an OpenGL application programming interface (API) through Java Bindings for OpenGL (JOGL). A command is implemented, which sets the map in dynamic mode. A compass object is added to the map, which rotates with the dynamic map.
 
The following areas are covered in this sample:
  1. Wiring dynamic map events to listen to the Before or After DynamicDraw, which allows you to plug-in your drawing to the map
  2. Creating OpenGL display lists
  3. Mapping a bitmap into an OpenGL texture and binding the texture to an OpenGL geometry
  4. Translating, scaling, and rotating OpenGL display lists

How to use

See How to use ArcGIS samples for help on running the sample. If the sample has associated data, you will find that the sample's zip file includes a "data" folder alongside the language folders. However, you will need to update the sample to point to the location of the data once you have extracted all the files.

  1. Run the sample.
  2. Click the Add OpenGL Compass command. A compass is added to the map.
  3. Use the Rotate tool to rotate the map. The compass rotates with the map.


Download the files for Java
display/CompassApplication.java Creates the graphical user interface (GUI) for the sample.
display/ShowCompassCommand.java Represents a command that sets the map in dynamic mode. The command attaches a map event listener, which draws the compass using JOGL in each AfterDynamicDraw event. It also attaches a display transformation event listener to rotate the compass as the map is rotated.
display/ImageTexturizer.java Reads the compass.gif image file and returns a byte representation that can be used with the JOGL API to draw the image on the map.




Additional Requirements
  • While running the sample using the Java command, you must provide the Djava.library.path=<path_to_jogl_lib_folder> VM argument. The value of this argument depends on your operating system (OS). For Windows, it will be similar to: %ARCGISHOME%/java/samples/engine/lib/jogl/jogl-1.1.0-windows-i586/lib.

Development licensing Deployment licensing
Engine Developer Kit Engine Runtime
ArcView