Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/windows/native/sun/java2d/opengl/WGLGraphicsConfig.c
32288 views
/*1* Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425#include <stdlib.h>26#include <string.h>2728#include "sun_java2d_opengl_WGLGraphicsConfig.h"2930#include "jni.h"31#include "jni_util.h"32#include "jlong.h"33#include "WGLGraphicsConfig.h"34#include "WGLSurfaceData.h"3536/**37* This is a globally shared context used when creating textures. When any38* new contexts are created, they specify this context as the "share list"39* context, which means any texture objects created when this shared context40* is current will be available to any other context in any other thread.41*/42HGLRC sharedContext = 0;4344/**45* Attempts to initialize WGL and the core OpenGL library. For this method46* to return JNI_TRUE, the following must be true:47* - opengl32.dll must be loaded successfully (via LoadLibrary)48* - all core WGL/OGL function symbols from opengl32.dll must be49* available and loaded properly50* If any of these requirements are not met, this method will return51* JNI_FALSE, indicating there is no hope of using WGL/OpenGL for any52* GraphicsConfig in the environment.53*/54JNIEXPORT jboolean JNICALL55Java_sun_java2d_opengl_WGLGraphicsConfig_initWGL(JNIEnv *env, jclass wglgc)56{57J2dRlsTraceLn(J2D_TRACE_INFO, "WGLGraphicsConfig_initWGL");5859if (!OGLFuncs_OpenLibrary()) {60return JNI_FALSE;61}6263if (!OGLFuncs_InitPlatformFuncs() ||64!OGLFuncs_InitBaseFuncs())65{66OGLFuncs_CloseLibrary();67return JNI_FALSE;68}6970return JNI_TRUE;71}7273/**74* Disposes all memory and resources allocated for the given OGLContext.75*/76static void77WGLGC_DestroyOGLContext(OGLContext *oglc)78{79WGLCtxInfo *ctxinfo;8081J2dTraceLn(J2D_TRACE_INFO, "WGLGC_DestroyOGLContext");8283if (oglc == NULL) {84J2dRlsTraceLn(J2D_TRACE_ERROR,85"WGLGC_DestroyOGLContext: context is null");86return;87}8889// at this point, this context will be current to its scratch surface,90// so the following operations should be safe...9192OGLContext_DestroyContextResources(oglc);9394ctxinfo = (WGLCtxInfo *)oglc->ctxInfo;95if (ctxinfo != NULL) {96// release the current context before we continue97j2d_wglMakeCurrent(NULL, NULL);9899if (ctxinfo->context != 0) {100j2d_wglDeleteContext(ctxinfo->context);101}102if (ctxinfo->scratchSurface != 0) {103if (ctxinfo->scratchSurfaceDC != 0) {104j2d_wglReleasePbufferDCARB(ctxinfo->scratchSurface,105ctxinfo->scratchSurfaceDC);106}107j2d_wglDestroyPbufferARB(ctxinfo->scratchSurface);108}109110free(ctxinfo);111}112113free(oglc);114}115116/**117* Disposes all memory and resources associated with the given118* WGLGraphicsConfigInfo (including its native OGLContext data).119*/120void121OGLGC_DestroyOGLGraphicsConfig(jlong pConfigInfo)122{123WGLGraphicsConfigInfo *wglinfo =124(WGLGraphicsConfigInfo *)jlong_to_ptr(pConfigInfo);125126J2dTraceLn(J2D_TRACE_INFO, "OGLGC_DestroyOGLGraphicsConfig");127128if (wglinfo == NULL) {129J2dRlsTraceLn(J2D_TRACE_ERROR,130"OGLGC_DestroyOGLGraphicsConfig: info is null");131return;132}133134if (wglinfo->context != NULL) {135WGLGC_DestroyOGLContext(wglinfo->context);136}137138free(wglinfo);139}140141/**142* Creates a temporary (non-visible) window that can be used for querying143* the OpenGL capabilities of a given device.144*145* REMIND: should be able to create a window on a specific device...146*/147HWND148WGLGC_CreateScratchWindow(jint screennum)149{150static jboolean firsttime = JNI_TRUE;151152J2dTraceLn(J2D_TRACE_INFO, "WGLGC_CreateScratchWindow");153154if (firsttime) {155WNDCLASS wc;156157// setup window class information158ZeroMemory(&wc, sizeof(WNDCLASS));159wc.hInstance = GetModuleHandle(NULL);160wc.lpfnWndProc = DefWindowProc;161wc.lpszClassName = L"Tmp";162if (RegisterClass(&wc) == 0) {163J2dRlsTraceLn(J2D_TRACE_ERROR,164"WGLGC_CreateScratchWindow: error registering window class");165return 0;166}167168firsttime = JNI_FALSE;169}170171// create scratch window172return CreateWindow(L"Tmp", L"Tmp", 0,173CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,174CW_USEDEFAULT, NULL, NULL,175GetModuleHandle(NULL), NULL);176}177178/**179* Returns a pixel format identifier that is suitable for Java 2D's needs180* (must have a depth buffer, support for pbuffers, etc). This method will181* iterate through all pixel formats (if any) that match the requested182* attributes and will attempt to find a pixel format with a minimal combined183* depth+stencil buffer. Note that we currently only need depth capabilities184* (for shape clipping purposes), but wglChoosePixelFormatARB() will often185* return a list of pixel formats with the largest depth buffer (and stencil)186* sizes at the top of the list. Therefore, we scan through the whole list187* to find the most VRAM-efficient pixel format. If no appropriate pixel188* format can be found, this method returns 0.189*/190static int191WGLGC_GetPixelFormatForDC(HDC hdc)192{193int attrs[] = {194WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_ARB,195WGL_DRAW_TO_WINDOW_ARB, GL_TRUE,196WGL_DRAW_TO_PBUFFER_ARB, GL_TRUE,197WGL_DOUBLE_BUFFER_ARB, GL_TRUE,198WGL_DEPTH_BITS_ARB, 16, // anything >= 16 will work for us1990200};201int pixfmts[32];202int chosenPixFmt = 0;203int nfmts, i;204205// this is the initial minimum value for the combined depth+stencil size206// (we initialize it to some absurdly high value; realistic values will207// be much less than this number)208int minDepthPlusStencil = 512;209210J2dRlsTraceLn(J2D_TRACE_INFO, "WGLGC_GetPixelFormatForDC");211212// find all pixel formats (maximum of 32) with the provided attributes213if (!j2d_wglChoosePixelFormatARB(hdc, attrs, NULL, 32, pixfmts, &nfmts)) {214J2dRlsTraceLn(J2D_TRACE_ERROR,215"WGLGC_GetPixelFormatForDC: error choosing pixel format");216return 0;217}218219if (nfmts <= 0) {220J2dRlsTraceLn(J2D_TRACE_ERROR,221"WGLGC_GetPixelFormatForDC: no pixel formats found");222return 0;223}224225J2dRlsTraceLn(J2D_TRACE_VERBOSE, " candidate pixel formats:");226227// iterate through the list of pixel formats, looking for the one that228// meets our requirements while keeping the combined depth+stencil sizes229// to a minimum230for (i = 0; i < nfmts; i++) {231int attrKeys[] = {232WGL_DEPTH_BITS_ARB, WGL_STENCIL_BITS_ARB,233WGL_DOUBLE_BUFFER_ARB, WGL_ALPHA_BITS_ARB234};235int attrVals[4];236int pixfmt = pixfmts[i];237int depth, stencil, db, alpha;238239j2d_wglGetPixelFormatAttribivARB(hdc, pixfmt, 0, 4,240attrKeys, attrVals);241242depth = attrVals[0];243stencil = attrVals[1];244db = attrVals[2];245alpha = attrVals[3];246247J2dRlsTrace5(J2D_TRACE_VERBOSE,248"[V] pixfmt=%d db=%d alpha=%d depth=%d stencil=%d valid=",249pixfmt, db, alpha, depth, stencil);250251if ((depth + stencil) < minDepthPlusStencil) {252J2dRlsTrace(J2D_TRACE_VERBOSE, "true\n");253minDepthPlusStencil = depth + stencil;254chosenPixFmt = pixfmt;255} else {256J2dRlsTrace(J2D_TRACE_VERBOSE, "false (large depth)\n");257}258}259260if (chosenPixFmt == 0) {261J2dRlsTraceLn(J2D_TRACE_ERROR,262"WGLGC_GetPixelFormatForDC: could not find appropriate pixfmt");263return 0;264}265266J2dRlsTraceLn1(J2D_TRACE_INFO,267"WGLGC_GetPixelFormatForDC: chose %d as the best pixel format",268chosenPixFmt);269270return chosenPixFmt;271}272273/**274* Sets a "basic" pixel format for the given HDC. This method is used only275* for initializing a scratch window far enough such that we can load276* GL/WGL extension function pointers using wglGetProcAddress. (This method277* differs from the one above in that it does not use wglChoosePixelFormatARB,278* which is a WGL extension function, since we can't use that method without279* first loading the extension functions under a "basic" pixel format.)280*/281static jboolean282WGLGC_SetBasicPixelFormatForDC(HDC hdc)283{284PIXELFORMATDESCRIPTOR pfd;285int pixfmt;286287J2dTraceLn(J2D_TRACE_INFO, "WGLGC_SetBasicPixelFormatForDC");288289// find pixel format290ZeroMemory(&pfd, sizeof(PIXELFORMATDESCRIPTOR));291pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);292pfd.nVersion = 1;293pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;294pfd.iPixelType = PFD_TYPE_RGBA;295pixfmt = ChoosePixelFormat(hdc, &pfd);296297if (!SetPixelFormat(hdc, pixfmt, &pfd)) {298J2dRlsTraceLn(J2D_TRACE_ERROR,299"WGLGC_SetBasicPixelFormatForDC: error setting pixel format");300return JNI_FALSE;301}302303return JNI_TRUE;304}305306/**307* Creates a context that is compatible with the given pixel format308* identifier. Returns 0 if the context could not be created properly.309*/310static HGLRC311WGLGC_CreateContext(jint screennum, jint pixfmt)312{313PIXELFORMATDESCRIPTOR pfd;314HWND hwnd;315HDC hdc;316HGLRC hglrc;317318J2dTraceLn(J2D_TRACE_INFO, "WGLGC_CreateContext");319320hwnd = WGLGC_CreateScratchWindow(screennum);321if (hwnd == 0) {322J2dRlsTraceLn(J2D_TRACE_ERROR,323"WGLGC_CreateContext: could not create scratch window");324return 0;325}326327// get the HDC for the scratch window328hdc = GetDC(hwnd);329if (hdc == 0) {330J2dRlsTraceLn(J2D_TRACE_ERROR,331"WGLGC_CreateContext: could not get dc for scratch window");332DestroyWindow(hwnd);333return 0;334}335336// set the pixel format for the scratch window337if (!SetPixelFormat(hdc, pixfmt, &pfd)) {338J2dRlsTraceLn(J2D_TRACE_ERROR,339"WGLGC_CreateContext: error setting pixel format");340ReleaseDC(hwnd, hdc);341DestroyWindow(hwnd);342return 0;343}344345// create a context based on the scratch window346hglrc = j2d_wglCreateContext(hdc);347348// release the temporary resources349ReleaseDC(hwnd, hdc);350DestroyWindow(hwnd);351352return hglrc;353}354355/**356* Initializes the extension function pointers for the given device. Note357* that under WGL, extension functions have different entrypoints depending358* on the device, so we must first make a context current for the given359* device before attempting to load the function pointers via360* wglGetProcAddress.361*362* REMIND: ideally the extension function pointers would not be global, but363* rather would be stored in a structure associated with the364* WGLGraphicsConfig, so that we use the correct function entrypoint365* depending on the destination device...366*/367static jboolean368WGLGC_InitExtFuncs(jint screennum)369{370HWND hwnd;371HDC hdc;372HGLRC context;373374J2dTraceLn(J2D_TRACE_INFO, "WGLGC_InitExtFuncs");375376// create a scratch window377hwnd = WGLGC_CreateScratchWindow(screennum);378if (hwnd == 0) {379return JNI_FALSE;380}381382// get the HDC for the scratch window383hdc = GetDC(hwnd);384if (hdc == 0) {385DestroyWindow(hwnd);386return JNI_FALSE;387}388389// find and set a basic pixel format for the scratch window390if (!WGLGC_SetBasicPixelFormatForDC(hdc)) {391J2dRlsTraceLn(J2D_TRACE_ERROR,392"WGLGC_InitExtFuncs: could not find appropriate pixfmt");393ReleaseDC(hwnd, hdc);394DestroyWindow(hwnd);395return JNI_FALSE;396}397398// create a temporary context399context = j2d_wglCreateContext(hdc);400if (context == 0) {401J2dRlsTraceLn(J2D_TRACE_ERROR,402"WGLGC_InitExtFuncs: could not create temp WGL context");403ReleaseDC(hwnd, hdc);404DestroyWindow(hwnd);405return JNI_FALSE;406}407408// make the context current so that we can load the function pointers409// using wglGetProcAddress410if (!j2d_wglMakeCurrent(hdc, context)) {411J2dRlsTraceLn(J2D_TRACE_ERROR,412"WGLGC_InitExtFuncs: could not make temp context current");413j2d_wglDeleteContext(context);414ReleaseDC(hwnd, hdc);415DestroyWindow(hwnd);416return JNI_FALSE;417}418419if (!OGLFuncs_InitExtFuncs()) {420J2dRlsTraceLn(J2D_TRACE_ERROR,421"WGLGC_InitExtFuncs: could not initialize extension funcs");422j2d_wglMakeCurrent(NULL, NULL);423j2d_wglDeleteContext(context);424ReleaseDC(hwnd, hdc);425DestroyWindow(hwnd);426return JNI_FALSE;427}428429// destroy the temporary resources430j2d_wglMakeCurrent(NULL, NULL);431j2d_wglDeleteContext(context);432ReleaseDC(hwnd, hdc);433DestroyWindow(hwnd);434435return JNI_TRUE;436}437438/**439* Initializes a new OGLContext, which includes the native WGL context handle440* and some other important information such as the associated pixel format.441*/442static OGLContext *443WGLGC_InitOGLContext(jint pixfmt, HGLRC context,444HPBUFFERARB scratch, HDC scratchDC, jint caps)445{446OGLContext *oglc;447WGLCtxInfo *ctxinfo;448449J2dTraceLn(J2D_TRACE_INFO, "WGLGC_InitOGLContext");450451oglc = (OGLContext *)malloc(sizeof(OGLContext));452if (oglc == NULL) {453J2dRlsTraceLn(J2D_TRACE_ERROR,454"WGLGC_InitOGLContext: could not allocate memory for oglc");455return NULL;456}457458memset(oglc, 0, sizeof(OGLContext));459460ctxinfo = (WGLCtxInfo *)malloc(sizeof(WGLCtxInfo));461if (ctxinfo == NULL) {462J2dRlsTraceLn(J2D_TRACE_ERROR,463"WGLGC_InitOGLContext: could not allocate memory for ctxinfo");464free(oglc);465return NULL;466}467468ctxinfo->context = context;469ctxinfo->scratchSurface = scratch;470ctxinfo->scratchSurfaceDC = scratchDC;471oglc->ctxInfo = ctxinfo;472oglc->caps = caps;473474return oglc;475}476477/**478* Determines whether the WGL pipeline can be used for a given GraphicsConfig479* provided its screen number and visual ID. If the minimum requirements are480* met, the native WGLGraphicsConfigInfo structure is initialized for this481* GraphicsConfig with the necessary information (pixel format, etc.)482* and a pointer to this structure is returned as a jlong. If483* initialization fails at any point, zero is returned, indicating that WGL484* cannot be used for this GraphicsConfig (we should fallback on the existing485* DX pipeline).486*/487JNIEXPORT jlong JNICALL488Java_sun_java2d_opengl_WGLGraphicsConfig_getWGLConfigInfo(JNIEnv *env,489jclass wglgc,490jint screennum,491jint pixfmt)492{493OGLContext *oglc;494PIXELFORMATDESCRIPTOR pfd;495HWND hwnd;496HDC hdc;497HGLRC context;498HPBUFFERARB scratch;499HDC scratchDC;500WGLGraphicsConfigInfo *wglinfo;501const unsigned char *versionstr;502const char *extstr;503jint caps = CAPS_EMPTY;504int attrKeys[] = { WGL_DOUBLE_BUFFER_ARB, WGL_ALPHA_BITS_ARB };505int attrVals[2];506507J2dRlsTraceLn(J2D_TRACE_INFO, "WGLGraphicsConfig_getWGLConfigInfo");508509// initialize GL/WGL extension functions510if (!WGLGC_InitExtFuncs(screennum)) {511J2dRlsTraceLn(J2D_TRACE_ERROR,512"WGLGraphicsConfig_getWGLConfigInfo: could not init ext funcs");513return 0L;514}515516// create a scratch window517hwnd = WGLGC_CreateScratchWindow(screennum);518if (hwnd == 0) {519return 0L;520}521522// get the HDC for the scratch window523hdc = GetDC(hwnd);524if (hdc == 0) {525J2dRlsTraceLn(J2D_TRACE_ERROR,526"WGLGraphicsConfig_getWGLConfigInfo: could not get dc for scratch window");527DestroyWindow(hwnd);528return 0L;529}530531if (pixfmt == 0) {532// find an appropriate pixel format533pixfmt = WGLGC_GetPixelFormatForDC(hdc);534if (pixfmt == 0) {535J2dRlsTraceLn(J2D_TRACE_ERROR,536"WGLGraphicsConfig_getWGLConfigInfo: could not find appropriate pixfmt");537ReleaseDC(hwnd, hdc);538DestroyWindow(hwnd);539return 0L;540}541}542543if (sharedContext == 0) {544// create the one shared context545sharedContext = WGLGC_CreateContext(screennum, pixfmt);546if (sharedContext == 0) {547J2dRlsTraceLn(J2D_TRACE_ERROR,548"WGLGraphicsConfig_getWGLConfigInfo: could not create shared context");549ReleaseDC(hwnd, hdc);550DestroyWindow(hwnd);551return 0L;552}553}554555// set the pixel format for the scratch window556if (!SetPixelFormat(hdc, pixfmt, &pfd)) {557J2dRlsTraceLn(J2D_TRACE_ERROR,558"WGLGraphicsconfig_getWGLConfigInfo: error setting pixel format");559ReleaseDC(hwnd, hdc);560DestroyWindow(hwnd);561return 0L;562}563564// create the HGLRC (context) for this WGLGraphicsConfig565context = j2d_wglCreateContext(hdc);566if (context == 0) {567J2dRlsTraceLn(J2D_TRACE_ERROR,568"WGLGraphicsConfig_getWGLConfigInfo: could not create WGL context");569ReleaseDC(hwnd, hdc);570DestroyWindow(hwnd);571return 0L;572}573574// REMIND: when using wglShareLists, the two contexts must use an575// identical pixel format...576if (!j2d_wglShareLists(sharedContext, context)) {577J2dRlsTraceLn(J2D_TRACE_WARNING,578"WGLGraphicsConfig_getWGLConfigInfo: unable to share lists");579}580581// make the context current so that we can query the OpenGL version582// and extension strings583if (!j2d_wglMakeCurrent(hdc, context)) {584J2dRlsTraceLn(J2D_TRACE_ERROR,585"WGLGraphicsConfig_getWGLConfigInfo: could not make temp context current");586j2d_wglDeleteContext(context);587ReleaseDC(hwnd, hdc);588DestroyWindow(hwnd);589return 0L;590}591592// get version and extension strings593versionstr = j2d_glGetString(GL_VERSION);594extstr = j2d_wglGetExtensionsStringARB(hdc);595OGLContext_GetExtensionInfo(env, &caps);596597J2dRlsTraceLn1(J2D_TRACE_INFO,598"WGLGraphicsConfig_getWGLConfigInfo: OpenGL version=%s",599(versionstr == NULL) ? "null" : (char *)versionstr);600601if (!OGLContext_IsVersionSupported(versionstr)) {602J2dRlsTraceLn(J2D_TRACE_ERROR,603"WGLGraphicsConfig_getWGLConfigInfo: OpenGL 1.2 is required");604j2d_wglMakeCurrent(NULL, NULL);605j2d_wglDeleteContext(context);606ReleaseDC(hwnd, hdc);607DestroyWindow(hwnd);608return 0L;609}610611// check for required WGL extensions612if (!OGLContext_IsExtensionAvailable(extstr, "WGL_ARB_pbuffer") ||613!OGLContext_IsExtensionAvailable(extstr, "WGL_ARB_make_current_read")||614!OGLContext_IsExtensionAvailable(extstr, "WGL_ARB_pixel_format"))615{616J2dRlsTraceLn(J2D_TRACE_ERROR,617"WGLGraphicsConfig_getWGLConfigInfo: required ext(s) unavailable");618j2d_wglMakeCurrent(NULL, NULL);619j2d_wglDeleteContext(context);620ReleaseDC(hwnd, hdc);621DestroyWindow(hwnd);622return 0L;623}624625// get config-specific capabilities626j2d_wglGetPixelFormatAttribivARB(hdc, pixfmt, 0, 2, attrKeys, attrVals);627if (attrVals[0]) {628caps |= CAPS_DOUBLEBUFFERED;629}630if (attrVals[1] > 0) {631caps |= CAPS_STORED_ALPHA;632}633634// create the scratch pbuffer635scratch = j2d_wglCreatePbufferARB(hdc, pixfmt, 1, 1, NULL);636637// destroy the temporary resources638j2d_wglMakeCurrent(NULL, NULL);639ReleaseDC(hwnd, hdc);640DestroyWindow(hwnd);641642if (scratch == 0) {643J2dRlsTraceLn(J2D_TRACE_ERROR,644"WGLGraphicsConfig_getWGLConfigInfo: could not create scratch surface");645j2d_wglDeleteContext(context);646return 0L;647}648649// get the HDC for the scratch pbuffer650scratchDC = j2d_wglGetPbufferDCARB(scratch);651if (scratchDC == 0) {652J2dRlsTraceLn(J2D_TRACE_ERROR,653"WGLGraphicsConfig_getWGLConfigInfo: could not get hdc for scratch surface");654j2d_wglDeleteContext(context);655j2d_wglDestroyPbufferARB(scratch);656return 0L;657}658659// initialize the OGLContext, which wraps the pixfmt and HGLRC (context)660oglc = WGLGC_InitOGLContext(pixfmt, context, scratch, scratchDC, caps);661if (oglc == NULL) {662J2dRlsTraceLn(J2D_TRACE_ERROR,663"WGLGraphicsConfig_getWGLConfigInfo: could not create oglc");664j2d_wglDeleteContext(context);665j2d_wglReleasePbufferDCARB(scratch, scratchDC);666j2d_wglDestroyPbufferARB(scratch);667return 0L;668}669670J2dTraceLn(J2D_TRACE_VERBOSE,671"WGLGraphicsConfig_getWGLConfigInfo: finished checking dependencies");672673// create the WGLGraphicsConfigInfo record for this config674wglinfo = (WGLGraphicsConfigInfo *)malloc(sizeof(WGLGraphicsConfigInfo));675if (wglinfo == NULL) {676J2dRlsTraceLn(J2D_TRACE_ERROR,677"WGLGraphicsConfig_getWGLConfigInfo: could not allocate memory for wglinfo");678WGLGC_DestroyOGLContext(oglc);679return 0L;680}681682wglinfo->screen = screennum;683wglinfo->pixfmt = pixfmt;684wglinfo->context = oglc;685686return ptr_to_jlong(wglinfo);687}688689JNIEXPORT jint JNICALL690Java_sun_java2d_opengl_WGLGraphicsConfig_getDefaultPixFmt(JNIEnv *env,691jclass wglgc,692jint screennum)693{694J2dTraceLn(J2D_TRACE_INFO, "WGLGraphicsConfig_getDefaultPixFmt");695696// REMIND: eventually we should implement this method so that it finds697// the most appropriate default pixel format for the given698// device; for now, we'll just return 0, and then we'll find699// an appropriate pixel format in WGLGC_GetWGLConfigInfo()...700return 0;701}702703JNIEXPORT jint JNICALL704Java_sun_java2d_opengl_WGLGraphicsConfig_getOGLCapabilities(JNIEnv *env,705jclass wglgc,706jlong configInfo)707{708WGLGraphicsConfigInfo *wglinfo =709(WGLGraphicsConfigInfo *)jlong_to_ptr(configInfo);710711J2dTraceLn(J2D_TRACE_INFO, "WGLGraphicsConfig_getOGLCapabilities");712713if (wglinfo == NULL || wglinfo->context == NULL) {714return CAPS_EMPTY;715}716717return wglinfo->context->caps;718}719720721