HowToC:GetStarted

From S2PLOT

(Difference between revisions)
Jump to: navigation, search
Revision as of 05:01, 30 October 2007
S2plot admin (Talk | contribs)

← Previous diff
Revision as of 05:03, 30 October 2007
S2plot admin (Talk | contribs)

Next diff →
Line 10: Line 10:
To begin with, we will just consider steps 1 and 4. To begin with, we will just consider steps 1 and 4.
 +===First example===
Copy and paste the following code, and save the file as <tt>s2example.c</tt> Copy and paste the following code, and save the file as <tt>s2example.c</tt>
Line 38: Line 39:
A black screen should appear - not very exciting, but you have successfully started up the S2PLOT display and handed control to GLUT. A black screen should appear - not very exciting, but you have successfully started up the S2PLOT display and handed control to GLUT.
 +===Drawing a bounding box===
Next, we should start adding some static geometry. Next, we should start adding some static geometry.
Line 48: Line 50:
Save, compile with <tt>cbuild.csh</tt> and run again. This time, you should see a white box representing the coordinate system. Save, compile with <tt>cbuild.csh</tt> and run again. This time, you should see a white box representing the coordinate system.
 +===Testing S2PLOT interaction===
You can now begin to test the interactive aspects of S2PLOT: You can now begin to test the interactive aspects of S2PLOT:
* Press and hold the left mouse button and move the mouse to control rotation. * Press and hold the left mouse button and move the mouse to control rotation.
Line 54: Line 57:
* Press the <tt>a</tt> key to toggle autospin * Press the <tt>a</tt> key to toggle autospin
For full details on interaction, see [[S2Plot:Controls | here]]. For full details on interaction, see [[S2Plot:Controls | here]].
 +
 +===Labelling the coordinates===

Revision as of 05:03, 30 October 2007

Contents

Getting started

An S2PLOT program typically has four separate parts:

  1. Commands to open S2PLOT display and set-up the environment
  2. Commands to prepare static geometry, which is generated once and then drawn on all future screen refreshes
  3. Commands to prepare dynamic geometry (ie. callbacks), which are update on every screen refresh
  4. A command to hand over control to the OpenGL GLUT event loop, which controls interactivity such as mouse and keyboard controls

To begin with, we will just consider steps 1 and 4.

First example

Copy and paste the following code, and save the file as s2example.c

#include <stdio.h>
#include <stdlib.h>
#include "s2plot.h"

int main(int argc, char *argv[])
{
   float xmin = -1, xmax = +1;          /* X data range */
   float ymin = -1, ymax = +1;          /* Y data range */
   float zmin = -1, zmax = +1;          /* Z data range */

   s2opend("/?",argc,argv);             /* Which S2PLOT device to open? */
   s2swin(xmin, xmax, ymin, ymax, zmin, zmax);  /* Set the display coordinates */

   s2show(1);                           /* Hand over to the display */

   return 1;
}

Compile using: cbuild.csh s2example<tt> and then run by typing <tt>s2example at the command prompt.

You will be prompted for a device type - for the moment, just press return to choose the default for your system.

A black screen should appear - not very exciting, but you have successfully started up the S2PLOT display and handed control to GLUT.

Drawing a bounding box

Next, we should start adding some static geometry.

Add the following line below the s2swin command:

s2box("BCDE",0,0,"BCDE",0,0,"BCDE",0,0);     /* Draw a coordinate box */

Save, compile with cbuild.csh and run again. This time, you should see a white box representing the coordinate system.

Testing S2PLOT interaction

You can now begin to test the interactive aspects of S2PLOT:

  • Press and hold the left mouse button and move the mouse to control rotation.
  • Press and hole the middle or right mouse buttons to see what affect they have.
  • Press +/- to move the camera towards/away from the centre of the box.
  • Press the a key to toggle autospin

For full details on interaction, see here.

Labelling the coordinates

Personal tools