jdk/src/solaris/native/sun/java2d/opengl/GLXSurfaceData.c
author duke
Sat, 01 Dec 2007 00:00:00 +0000
changeset 2 90ce3da70b43
child 887 0aab8d3fa11a
permissions -rw-r--r--
Initial load
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * Copyright 2003-2007 Sun Microsystems, Inc.  All Rights Reserved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
#include <jlong.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
#include "sun_java2d_opengl_GLXSurfaceData.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
#include "OGLRenderQueue.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
#include "GLXGraphicsConfig.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
#include "GLXSurfaceData.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
#include "awt_Component.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
#include "awt_GraphicsEnv.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * The methods in this file implement the native windowing system specific
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * layer (GLX) for the OpenGL-based Java 2D pipeline.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
extern LockFunc       OGLSD_Lock;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
extern GetRasInfoFunc OGLSD_GetRasInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
extern UnlockFunc     OGLSD_Unlock;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
extern DisposeFunc    OGLSD_Dispose;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
extern struct MComponentPeerIDs mComponentPeerIDs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
jboolean surfaceCreationFailed = JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
Java_sun_java2d_opengl_GLXSurfaceData_initOps(JNIEnv *env, jobject glxsd,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
                                              jobject peer, jlong aData)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    OGLSDOps *oglsdo = (OGLSDOps *)SurfaceData_InitOps(env, glxsd,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
                                                       sizeof(OGLSDOps));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    GLXSDOps *glxsdo = (GLXSDOps *)malloc(sizeof(GLXSDOps));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    J2dTraceLn(J2D_TRACE_INFO, "GLXSurfaceData_initOps");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    if (glxsdo == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
        JNU_ThrowOutOfMemoryError(env, "creating native GLX ops");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    oglsdo->privOps = glxsdo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    oglsdo->sdOps.Lock       = OGLSD_Lock;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    oglsdo->sdOps.GetRasInfo = OGLSD_GetRasInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    oglsdo->sdOps.Unlock     = OGLSD_Unlock;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    oglsdo->sdOps.Dispose    = OGLSD_Dispose;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    oglsdo->drawableType = OGLSD_UNDEFINED;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    oglsdo->activeBuffer = GL_FRONT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    oglsdo->needsInit = JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
#ifdef XAWT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    if (peer != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        glxsdo->window = JNU_CallMethodByName(env, NULL, peer,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
                                              "getContentWindow", "()J").j;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        glxsdo->window = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    if (peer != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        struct ComponentData *cdata;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        cdata = (struct ComponentData *)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
            JNU_GetLongFieldAsPtr(env, peer, mComponentPeerIDs.pData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        if (cdata == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
            free(glxsdo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
            JNU_ThrowNullPointerException(env, "Component data missing");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        if (cdata->widget == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
            free(glxsdo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
            JNU_ThrowInternalError(env, "Widget is NULL in initOps");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        glxsdo->widget = cdata->widget;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        glxsdo->widget = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    glxsdo->configData = (AwtGraphicsConfigDataPtr)jlong_to_ptr(aData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    if (glxsdo->configData == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        free(glxsdo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        JNU_ThrowNullPointerException(env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
                                 "Native GraphicsConfig data block missing");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    if (glxsdo->configData->glxInfo == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        free(glxsdo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        JNU_ThrowNullPointerException(env, "GLXGraphicsConfigInfo missing");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
#endif /* HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
 * This function disposes of any native windowing system resources associated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
 * with this surface.  For instance, if the given OGLSDOps is of type
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
 * OGLSD_PBUFFER, this method implementation will destroy the actual pbuffer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
 * surface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
OGLSD_DestroyOGLSurface(JNIEnv *env, OGLSDOps *oglsdo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    GLXSDOps *glxsdo = (GLXSDOps *)oglsdo->privOps;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    J2dTraceLn(J2D_TRACE_INFO, "OGLSD_DestroyOGLSurface");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    if (oglsdo->drawableType == OGLSD_PBUFFER) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        if (glxsdo->drawable != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
            j2d_glXDestroyPbuffer(awt_display, glxsdo->drawable);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
            glxsdo->drawable = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    } else if (oglsdo->drawableType == OGLSD_WINDOW) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        // X Window is free'd later by AWT code...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
 * Makes the given context current to its associated "scratch" surface.  If
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
 * the operation is successful, this method will return JNI_TRUE; otherwise,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
 * returns JNI_FALSE.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
static jboolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
GLXSD_MakeCurrentToScratch(JNIEnv *env, OGLContext *oglc)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    GLXCtxInfo *ctxInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    J2dTraceLn(J2D_TRACE_INFO, "GLXSD_MakeCurrentToScratch");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    if (oglc == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
                      "GLXSD_MakeCurrentToScratch: context is null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    ctxInfo = (GLXCtxInfo *)oglc->ctxInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    if (!j2d_glXMakeContextCurrent(awt_display,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
                                   ctxInfo->scratchSurface,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
                                   ctxInfo->scratchSurface,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
                                   ctxInfo->context))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
                      "GLXSD_MakeCurrentToScratch: could not make current");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
 * Returns a pointer (as a jlong) to the native GLXGraphicsConfigInfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
 * associated with the given OGLSDOps.  This method can be called from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
 * shared code to retrieve the native GraphicsConfig data in a platform-
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
 * independent manner.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
jlong
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
OGLSD_GetNativeConfigInfo(OGLSDOps *oglsdo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    GLXSDOps *glxsdo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    if (oglsdo == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
                      "OGLSD_GetNativeConfigInfo: ops are null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        return 0L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    glxsdo = (GLXSDOps *)oglsdo->privOps;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    if (glxsdo == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
                      "OGLSD_GetNativeConfigInfo: glx ops are null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        return 0L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    if (glxsdo->configData == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
                      "OGLSD_GetNativeConfigInfo: config data is null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
        return 0L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
    return ptr_to_jlong(glxsdo->configData->glxInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
 * Makes the given GraphicsConfig's context current to its associated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
 * "scratch" surface.  If there is a problem making the context current,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
 * this method will return NULL; otherwise, returns a pointer to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
 * OGLContext that is associated with the given GraphicsConfig.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
OGLContext *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
OGLSD_SetScratchSurface(JNIEnv *env, jlong pConfigInfo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    GLXGraphicsConfigInfo *glxInfo =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        (GLXGraphicsConfigInfo *)jlong_to_ptr(pConfigInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    OGLContext *oglc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
    J2dTraceLn(J2D_TRACE_INFO, "OGLSD_SetScratchContext");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    if (glxInfo == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
                      "OGLSD_SetScratchContext: glx config info is null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    oglc = glxInfo->context;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    if (!GLXSD_MakeCurrentToScratch(env, oglc)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    if (OGLC_IS_CAP_PRESENT(oglc, CAPS_EXT_FBOBJECT)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
        // the GL_EXT_framebuffer_object extension is present, so this call
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        // will ensure that we are bound to the scratch pbuffer (and not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        // some other framebuffer object)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        j2d_glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    return oglc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
 * Makes a context current to the given source and destination
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
 * surfaces.  If there is a problem making the context current, this method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
 * will return NULL; otherwise, returns a pointer to the OGLContext that is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
 * associated with the destination surface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
OGLContext *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
OGLSD_MakeOGLContextCurrent(JNIEnv *env, OGLSDOps *srcOps, OGLSDOps *dstOps)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
    GLXSDOps *dstGLXOps = (GLXSDOps *)dstOps->privOps;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
    OGLContext *oglc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
    J2dTraceLn(J2D_TRACE_INFO, "OGLSD_MakeOGLContextCurrent");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
    oglc = dstGLXOps->configData->glxInfo->context;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
    if (oglc == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
                      "OGLSD_MakeOGLContextCurrent: context is null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
    if (dstOps->drawableType == OGLSD_FBOBJECT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
        OGLContext *currentContext = OGLRenderQueue_GetCurrentContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
        // first make sure we have a current context (if the context isn't
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
        // already current to some drawable, we will make it current to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
        // its scratch surface)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
        if (oglc != currentContext) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
            if (!GLXSD_MakeCurrentToScratch(env, oglc)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
                return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
        // now bind to the fbobject associated with the destination surface;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
        // this means that all rendering will go into the fbobject destination
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
        // (note that we unbind the currently bound texture first; this is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
        // recommended procedure when binding an fbobject)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
        j2d_glBindTexture(dstOps->textureTarget, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
        j2d_glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, dstOps->fbobjectID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
        GLXSDOps *srcGLXOps = (GLXSDOps *)srcOps->privOps;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
        GLXCtxInfo *ctxinfo = (GLXCtxInfo *)oglc->ctxInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
        // make the context current
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
        if (!j2d_glXMakeContextCurrent(awt_display,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
                                       dstGLXOps->drawable,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
                                       srcGLXOps->drawable,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
                                       ctxinfo->context))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
            J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
                "OGLSD_MakeOGLContextCurrent: could not make current");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
            return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
        if (OGLC_IS_CAP_PRESENT(oglc, CAPS_EXT_FBOBJECT)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
            // the GL_EXT_framebuffer_object extension is present, so we
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
            // must bind to the default (windowing system provided)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
            // framebuffer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
            j2d_glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
    return oglc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
 * This function initializes a native window surface and caches the window
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
 * bounds in the given OGLSDOps.  Returns JNI_TRUE if the operation was
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
 * successful; JNI_FALSE otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
jboolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
OGLSD_InitOGLWindow(JNIEnv *env, OGLSDOps *oglsdo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
    GLXSDOps *glxsdo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
    Window window;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
#ifdef XAWT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
    XWindowAttributes attr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
    Widget widget;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
    J2dTraceLn(J2D_TRACE_INFO, "OGLSD_InitOGLWindow");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
    if (oglsdo == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
                      "OGLSD_InitOGLWindow: ops are null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
    glxsdo = (GLXSDOps *)oglsdo->privOps;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
    if (glxsdo == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
                      "OGLSD_InitOGLWindow: glx ops are null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
#ifdef XAWT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
    window = glxsdo->window;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
    if (window == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
                      "OGLSD_InitOGLWindow: window is invalid");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
    XGetWindowAttributes(awt_display, window, &attr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
    oglsdo->width = attr.width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
    oglsdo->height = attr.height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
    widget = glxsdo->widget;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
    if (widget == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
        J2dTraceLn(J2D_TRACE_WARNING, "OGLSD_InitOGLWindow: widget is null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
    if (!XtIsRealized(widget)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
                      "OGLSD_InitOGLWindow: widget is unrealized");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
    window = XtWindow(widget);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
    oglsdo->width = widget->core.width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
    oglsdo->height = widget->core.height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
    oglsdo->drawableType = OGLSD_WINDOW;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
    oglsdo->isOpaque = JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
    oglsdo->xOffset = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
    oglsdo->yOffset = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
    glxsdo->drawable = window;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
    glxsdo->xdrawable = window;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
    J2dTraceLn2(J2D_TRACE_VERBOSE, "  created window: w=%d h=%d",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
                oglsdo->width, oglsdo->height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
    return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
GLXSD_BadAllocXErrHandler(Display *display, XErrorEvent *xerr)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
    int ret = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
    if (xerr->error_code == BadAlloc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
        surfaceCreationFailed = JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
        ret = (*xerror_saved_handler)(display, xerr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
    return ret;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
JNIEXPORT jboolean JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
Java_sun_java2d_opengl_GLXSurfaceData_initPbuffer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
    (JNIEnv *env, jobject glxsd,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
     jlong pData, jlong pConfigInfo,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
     jboolean isOpaque,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
     jint width, jint height)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
    OGLSDOps *oglsdo = (OGLSDOps *)jlong_to_ptr(pData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
    GLXGraphicsConfigInfo *glxinfo =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
        (GLXGraphicsConfigInfo *)jlong_to_ptr(pConfigInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
    GLXSDOps *glxsdo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
    GLXPbuffer pbuffer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
    int attrlist[] = {GLX_PBUFFER_WIDTH, 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
                      GLX_PBUFFER_HEIGHT, 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
                      GLX_PRESERVED_CONTENTS, GL_FALSE, 0};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
    J2dTraceLn3(J2D_TRACE_INFO,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
                "GLXSurfaceData_initPbuffer: w=%d h=%d opq=%d",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
                width, height, isOpaque);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
    if (oglsdo == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
                      "GLXSurfaceData_initPbuffer: ops are null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
    glxsdo = (GLXSDOps *)oglsdo->privOps;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
    if (glxsdo == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
                      "GLXSurfaceData_initPbuffer: glx ops are null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
    if (glxinfo == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
                      "GLXSurfaceData_initPbuffer: glx config info is null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
    attrlist[1] = width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
    attrlist[3] = height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
    surfaceCreationFailed = JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
    EXEC_WITH_XERROR_HANDLER(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
        GLXSD_BadAllocXErrHandler,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
        pbuffer = j2d_glXCreatePbuffer(awt_display,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
                                       glxinfo->fbconfig, attrlist));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
    if ((pbuffer == 0) || surfaceCreationFailed) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
            "GLXSurfaceData_initPbuffer: could not create glx pbuffer");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
    oglsdo->drawableType = OGLSD_PBUFFER;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
    oglsdo->isOpaque = isOpaque;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
    oglsdo->width = width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
    oglsdo->height = height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
    oglsdo->xOffset = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
    oglsdo->yOffset = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
    glxsdo->drawable = pbuffer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
    glxsdo->xdrawable = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
    return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
OGLSD_SwapBuffers(JNIEnv *env, jlong window)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
    J2dTraceLn(J2D_TRACE_INFO, "OGLSD_SwapBuffers");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
    if (window == 0L) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
                      "OGLSD_SwapBuffers: window is null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
    j2d_glXSwapBuffers(awt_display, (Window)window);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
#endif /* !HEADLESS */