aboutsummaryrefslogtreecommitdiffstats
path: root/make/gl-impl-CustomJavaCode-common.java
blob: fb8a3ba0b398714eedcbd6a664a4e1c58008f7ab (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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
  public final boolean isGL2() {
    return GLProfile.implementationOfGL2(this);
  }

  public final boolean isGLES1() {
    return GLProfile.implementationOfGLES1(this);
  }

  public final boolean isGLES2() {
    return GLProfile.implementationOfGLES2(this);
  }

  public final boolean isGLES() {
    return GLProfile.implementationOfGLES(this);
  }

  public final boolean isGL2ES1() {
    return GLProfile.implementationOfGL2ES1(this);
  }

  public final boolean isGL2ES2() {
    return GLProfile.implementationOfGL2ES2(this);
  }

  public final GL2 getGL2() throws GLException {
    if(!isGL2()) {
        throw new GLException("Not a GL2 implementation");
    }
    return (GL2)this;
  }

  public final GLES1 getGLES1() throws GLException {
    if(!isGLES1()) {
        throw new GLException("Not a GLES1 implementation");
    }
    return (GLES1)this;
  }

  public final GLES2 getGLES2() throws GLException {
    if(!isGLES2()) {
        throw new GLException("Not a GLES2 implementation");
    }
    return (GLES2)this;
  }

  public final GL2ES1 getGL2ES1() throws GLException {
    if(!isGL2ES1()) {
        throw new GLException("Not a GL2ES1 implementation");
    }
    return (GL2ES1)this;
  }

  public final GL2ES2 getGL2ES2() throws GLException {
    if(!isGL2ES2()) {
        throw new GLException("Not a GL2ES2 implementation");
    }
    return (GL2ES2)this;
  }

  public final boolean matchesProfile() {
    return matchesProfile(GLProfile.getProfile());
  }

  public final boolean matchesProfile(String test_profile) {
    if(null==test_profile) {
        return false;
    }
    if(test_profile.equals(GLProfile.GL2)) {
        return isGL2();
    }
    if(test_profile.equals(GLProfile.GLES1)) {
        return isGLES1();
    }
    if(test_profile.equals(GLProfile.GLES2)) {
        return isGLES2();
    }
    return false;
  }

  public final String toString() {
      StringBuffer buf = new StringBuffer();
      buf.append("GL: ");
      buf.append(getClass().getName());
      buf.append(" (GLContext: ");
      GLContext context = getContext();
      buf.append(context.getClass().getName());
      buf.append(", GLDrawable: ");
      GLDrawable drawable = context.getGLDrawable();
      buf.append(drawable.getClass().getName());
      buf.append(", Factory: ");
      GLDrawableFactory factory = drawable.getFactory();
      buf.append(factory.getClass().getName());
      buf.append(")");
      return buf.toString();
  }