iicm.ge3d
Class OGLCanvas

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Canvas
          extended by iicm.ge3d.OGLCanvas
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible

public class OGLCanvas
extends java.awt.Canvas

OGLCanvas - window context for GE3D. Copyright (c) 1996,97 IICM. All rights reserved.

Version:
1.0.3, changed: 6 Mar 97
Author:
Michael Pichler
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.awt.Canvas
java.awt.Canvas.AccessibleAWTCanvas
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  int cheight
           
protected  int cwidth
           
private  boolean hascontext
           
private  boolean loadedlib
           
protected  int mesa_backbuf
           
(package private) static int MESABACKBUF_AUTO
           
(package private) static int MESABACKBUF_PIXMAP
           
(package private) static int MESABACKBUF_XIMAGE
           
private  int nbuffer
           
private  long nbufferL
           
private  int ncanvas
           
private  int ncolormap
           
private  int ncontext
           
private  long ncontextL
           
private  int noglwindow
           
private  int nwindow
           
private  boolean nxactive
           
private  int nxbuffer
           
private  long nxbufferL
           
private  int nxcontext
           
private  long nxcontextL
           
(package private)  java.lang.String title
           
protected  boolean verbose
           
private  int version_1_0_8
           
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
OGLCanvas(java.lang.String t)
          constructor
 
Method Summary
private  void createContext(int flags)
           
 boolean hasContext()
          check whether native methods are callable
 java.awt.Dimension minimumSize()
          ... and minimum size
 boolean mouseEnter(java.awt.Event e, int x, int y)
          react on mouse enter/exit.
 boolean mouseExit(java.awt.Event e, int x, int y)
           
private  void mouseInside(int flag)
           
 void paint(java.awt.Graphics goofy)
          create an OpenGL canvas on first painting.
 java.awt.Dimension preferredSize()
          my preferred size ...
protected  boolean setContext(boolean shading)
          activate the context before issuing OpenGL commands in paint
protected  void swapBuffers()
          when finished with drawing, swap buffers or flush drawings (for double buffering resp. single buffering)
 void update(java.awt.Graphics gc)
          no need to clear background on graphics update (will be done by 3D drawing)
 
Methods inherited from class java.awt.Canvas
addNotify, createBufferStrategy, createBufferStrategy, getAccessibleContext, getBufferStrategy
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, mouseDown, mouseDrag, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

hascontext

private boolean hascontext

loadedlib

private boolean loadedlib

verbose

protected boolean verbose

cwidth

protected int cwidth

cheight

protected int cheight

title

java.lang.String title

nwindow

private int nwindow

ncanvas

private int ncanvas

noglwindow

private int noglwindow

ncontext

private int ncontext

ncontextL

private long ncontextL

nxcontext

private int nxcontext

nxcontextL

private long nxcontextL

ncolormap

private int ncolormap

nbuffer

private int nbuffer

nbufferL

private long nbufferL

nxbuffer

private int nxbuffer

nxbufferL

private long nxbufferL

nxactive

private boolean nxactive

MESABACKBUF_XIMAGE

static final int MESABACKBUF_XIMAGE
See Also:
Constant Field Values

MESABACKBUF_PIXMAP

static final int MESABACKBUF_PIXMAP
See Also:
Constant Field Values

MESABACKBUF_AUTO

static final int MESABACKBUF_AUTO
See Also:
Constant Field Values

mesa_backbuf

protected int mesa_backbuf

version_1_0_8

private int version_1_0_8
Constructor Detail

OGLCanvas

public OGLCanvas(java.lang.String t)
constructor

Parameters:
t - window title (needed to identify window)
Method Detail

preferredSize

public java.awt.Dimension preferredSize()
my preferred size ...

Overrides:
preferredSize in class java.awt.Component

minimumSize

public java.awt.Dimension minimumSize()
... and minimum size

Overrides:
minimumSize in class java.awt.Component

update

public void update(java.awt.Graphics gc)
no need to clear background on graphics update (will be done by 3D drawing)

Overrides:
update in class java.awt.Canvas

paint

public void paint(java.awt.Graphics goofy)
create an OpenGL canvas on first painting. derived class must also call setContext () before issuing OpenGL commands paint of a derived class will typically look like this: (see also SampleCanvas in ge3dsample package)
 super.paint (gc);  // create context on first draw

 if (!hasContext () || !setContext ())  // no context
   return;  // should clear background in this case

 // now ready to draw with OpenGL commands
 // on first draw you should call GE3D.initGE3D ()

 swapBuffers ();  // finish drawing
 

Overrides:
paint in class java.awt.Canvas

mouseEnter

public boolean mouseEnter(java.awt.Event e,
                          int x,
                          int y)
react on mouse enter/exit. (e.g. colormap installation) in native code. if derived class overrides this, remember calling super.mouseEnter/Exit.

Overrides:
mouseEnter in class java.awt.Component

mouseExit

public boolean mouseExit(java.awt.Event e,
                         int x,
                         int y)
Overrides:
mouseExit in class java.awt.Component
See Also:
mouseEnter(java.awt.Event, int, int)

createContext

private void createContext(int flags)

mouseInside

private void mouseInside(int flag)

hasContext

public boolean hasContext()
check whether native methods are callable


setContext

protected boolean setContext(boolean shading)
activate the context before issuing OpenGL commands in paint

Parameters:
shading - flag - should be set to true unless wireframe drawings
Returns:
flag, whether context could be established

swapBuffers

protected void swapBuffers()
when finished with drawing, swap buffers or flush drawings (for double buffering resp. single buffering)