1 /*
2 * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
116 return this;
117 }
118
119 @Override
120 public SurfaceData createManagedSurface(int w, int h, int transparency) {
121 return CGLSurfaceData.createData(this, w, h,
122 getColorModel(transparency),
123 null,
124 OGLSurfaceData.TEXTURE);
125 }
126
127 public static CGLGraphicsConfig getConfig(CGraphicsDevice device,
128 int pixfmt)
129 {
130 if (!cglAvailable) {
131 return null;
132 }
133
134 long cfginfo = 0;
135 int textureSize = 0;
136 final String ids[] = new String[1];
137 OGLRenderQueue rq = OGLRenderQueue.getInstance();
138 rq.lock();
139 try {
140 // getCGLConfigInfo() creates and destroys temporary
141 // surfaces/contexts, so we should first invalidate the current
142 // Java-level context and flush the queue...
143 OGLContext.invalidateCurrentContext();
144
145 cfginfo = getCGLConfigInfo(device.getCGDisplayID(), pixfmt,
146 kOpenGLSwapInterval);
147 if (cfginfo != 0L) {
148 textureSize = nativeGetMaxTextureSize();
149 // 7160609: GL still fails to create a square texture of this
150 // size. Half should be safe enough.
151 // Explicitly not support a texture more than 2^14, see 8010999.
152 textureSize = textureSize <= 16384 ? textureSize / 2 : 8192;
153 OGLContext.setScratchSurface(cfginfo);
154 rq.flushAndInvokeNow(() -> {
155 ids[0] = OGLContext.getOGLIdString();
156 });
|
1 /*
2 * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
116 return this;
117 }
118
119 @Override
120 public SurfaceData createManagedSurface(int w, int h, int transparency) {
121 return CGLSurfaceData.createData(this, w, h,
122 getColorModel(transparency),
123 null,
124 OGLSurfaceData.TEXTURE);
125 }
126
127 public static CGLGraphicsConfig getConfig(CGraphicsDevice device,
128 int pixfmt)
129 {
130 if (!cglAvailable) {
131 return null;
132 }
133
134 long cfginfo = 0;
135 int textureSize = 0;
136 final String[] ids = new String[1];
137 OGLRenderQueue rq = OGLRenderQueue.getInstance();
138 rq.lock();
139 try {
140 // getCGLConfigInfo() creates and destroys temporary
141 // surfaces/contexts, so we should first invalidate the current
142 // Java-level context and flush the queue...
143 OGLContext.invalidateCurrentContext();
144
145 cfginfo = getCGLConfigInfo(device.getCGDisplayID(), pixfmt,
146 kOpenGLSwapInterval);
147 if (cfginfo != 0L) {
148 textureSize = nativeGetMaxTextureSize();
149 // 7160609: GL still fails to create a square texture of this
150 // size. Half should be safe enough.
151 // Explicitly not support a texture more than 2^14, see 8010999.
152 textureSize = textureSize <= 16384 ? textureSize / 2 : 8192;
153 OGLContext.setScratchSurface(cfginfo);
154 rq.flushAndInvokeNow(() -> {
155 ids[0] = OGLContext.getOGLIdString();
156 });
|