aboutsummaryrefslogtreecommitdiffstats
path: root/gl4java/drawable/SunJDK13GLDrawableFactory.java
blob: bc707d8a998fd39b067ed31f18798c097f4c1bbc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package gl4java.drawable;

import java.awt.*;
import gl4java.*;
import gl4java.awt.*;

/** A GLDrawableFactory which works with Sun's JDK 1.3 or greater. */

public abstract class SunJDK13GLDrawableFactory extends GLDrawableFactory {

    public GLAnimCanvas createGLAnimCanvas(GLCapabilities capabilities,
                                   int width,
                                   int height,
                                   String glName,
                                   String gluName)
    {
        GLCapabilities own = null;
        try {
        	own = (GLCapabilities) capabilities.clone();
	} catch (Exception ex) { System.out.println(ex); own=capabilities; } 

        GraphicsConfiguration config = getGraphicsConfiguration(own);
        if (config == null) {
            return null;
        }
        return new GLAnimCanvas(config, own,
	                        width, height, glName, gluName);
    }

    public GLCanvas createGLCanvas(GLCapabilities capabilities,
                                   int width,
                                   int height,
                                   String glName,
                                   String gluName)
    {
        GLCapabilities own = null;
        try {
        	own = (GLCapabilities) capabilities.clone();
	} catch (Exception ex) { System.out.println(ex); own=capabilities; } 

        GraphicsConfiguration config = getGraphicsConfiguration(own);
        if (config == null) {
            return null;
        }
        return new GLCanvas(config, own,
	                    width, height, glName, gluName);
    }

  /** Returns the GraphicsConfiguration most closely matching the
      specified set of GLCapabilities, or null if there was no
      matching visual. 

      @param capabilities  the requested set of OpenGL capabilities of
                           the canvas
      @return a GraphicsConfiguration supporting the set of specified capabilities,
      or null if there was no matching visual
    */
  public GraphicsConfiguration getGraphicsConfiguration
  					(GLCapabilities capabilities)
  {
    return getGraphicsConfiguration(capabilities,
                                    GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice());
  }

    //----------------------------------------------------------------------
    // Internals only below this point
    //

    /** The choice of the GraphicsDevice is not yet exported to
        clients. */
    abstract GraphicsConfiguration
        getGraphicsConfiguration(GLCapabilities capabilities,
                                 GraphicsDevice device);
}