~ubuntu-branches/ubuntu/precise/mesa/precise-updates

« back to all changes in this revision

Viewing changes to src/gallium/state_trackers/wgl/stw_context.c

  • Committer: Package Import Robot
  • Author(s): Robert Hooker
  • Date: 2012-02-02 12:05:48 UTC
  • mfrom: (1.7.1) (3.3.27 sid)
  • Revision ID: package-import@ubuntu.com-20120202120548-nvkma85jq0h4coix
Tags: 8.0~rc2-0ubuntu4
Drop drisearchdir handling, it is no longer needed with multiarch
and dri-alternates being removed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
 
28
28
#include <windows.h>
29
29
 
 
30
#define WGL_WGLEXT_PROTOTYPES
 
31
 
 
32
#include <GL/gl.h>
 
33
#include <GL/wglext.h>
 
34
 
30
35
#include "pipe/p_compiler.h"
31
36
#include "pipe/p_context.h"
32
37
#include "pipe/p_state.h"
33
38
#include "util/u_memory.h"
 
39
#include "util/u_atomic.h"
34
40
#include "state_tracker/st_api.h"
35
41
 
36
42
#include "stw_icd.h"
120
126
   HDC hdc,
121
127
   INT iLayerPlane )
122
128
{
 
129
   return stw_create_context_attribs(hdc, iLayerPlane, 0, 1, 0, 0, WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB);
 
130
}
 
131
 
 
132
DHGLRC
 
133
stw_create_context_attribs(
 
134
   HDC hdc,
 
135
   INT iLayerPlane,
 
136
   DHGLRC hShareContext,
 
137
   int majorVersion, int minorVersion,
 
138
   int contextFlags, int profileMask)
 
139
{
123
140
   int iPixelFormat;
124
141
   const struct stw_pixelformat_info *pfi;
125
142
   struct st_context_attribs attribs;
126
143
   struct stw_context *ctx = NULL;
127
 
   
128
 
   if(!stw_dev)
 
144
   struct stw_context *shareCtx = NULL;
 
145
   enum st_context_error ctx_err = 0;
 
146
 
 
147
   if (!stw_dev)
129
148
      return 0;
130
 
   
 
149
 
131
150
   if (iLayerPlane != 0)
132
151
      return 0;
133
152
 
134
153
   iPixelFormat = GetPixelFormat(hdc);
135
154
   if(!iPixelFormat)
136
155
      return 0;
137
 
   
 
156
 
138
157
   pfi = stw_pixelformat_get_info( iPixelFormat - 1 );
139
 
   
 
158
 
 
159
   if (hShareContext != 0) {
 
160
      pipe_mutex_lock( stw_dev->ctx_mutex );
 
161
      shareCtx = stw_lookup_context_locked( hShareContext );
 
162
      pipe_mutex_unlock( stw_dev->ctx_mutex );
 
163
   }
 
164
 
140
165
   ctx = CALLOC_STRUCT( stw_context );
141
166
   if (ctx == NULL)
142
167
      goto no_ctx;
145
170
   ctx->iPixelFormat = iPixelFormat;
146
171
 
147
172
   memset(&attribs, 0, sizeof(attribs));
 
173
   attribs.visual = pfi->stvis;
 
174
   attribs.major = majorVersion;
 
175
   attribs.minor = minorVersion;
 
176
   if (contextFlags & WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB)
 
177
      attribs.flags |= ST_CONTEXT_FLAG_FORWARD_COMPATIBLE;
 
178
   if (contextFlags & WGL_CONTEXT_DEBUG_BIT_ARB)
 
179
      attribs.flags |= ST_CONTEXT_FLAG_DEBUG;
 
180
 
 
181
   /* There are no profiles before OpenGL 3.2.  The
 
182
    * WGL_ARB_create_context_profile spec says:
 
183
    *
 
184
    *     "If the requested OpenGL version is less than 3.2,
 
185
    *     WGL_CONTEXT_PROFILE_MASK_ARB is ignored and the functionality of the
 
186
    *     context is determined solely by the requested version."
 
187
    *
 
188
    * The spec also says:
 
189
    *
 
190
    *     "The default value for WGL_CONTEXT_PROFILE_MASK_ARB is
 
191
    *     WGL_CONTEXT_CORE_PROFILE_BIT_ARB."
 
192
    */
148
193
   attribs.profile = ST_PROFILE_DEFAULT;
149
 
   attribs.visual = pfi->stvis;
 
194
   if ((majorVersion > 3 || (majorVersion == 3 && minorVersion >= 2))
 
195
       && ((profileMask & WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB) == 0))
 
196
      attribs.profile = ST_PROFILE_OPENGL_CORE;
150
197
 
151
198
   ctx->st = stw_dev->stapi->create_context(stw_dev->stapi,
152
 
         stw_dev->smapi, &attribs, NULL);
153
 
   if (ctx->st == NULL) 
 
199
         stw_dev->smapi, &attribs, &ctx_err, shareCtx ? shareCtx->st : NULL);
 
200
   if (ctx->st == NULL)
154
201
      goto no_st_ctx;
155
202
 
156
203
   ctx->st->st_manager_private = (void *) ctx;
361
408
void
362
409
stw_notify_current_locked( struct stw_framebuffer *fb )
363
410
{
364
 
   struct stw_context *ctx = stw_current_context();
365
 
 
366
 
   if (ctx && ctx->current_framebuffer == fb)
367
 
      ctx->st->notify_invalid_framebuffer(ctx->st, fb->stfb);
 
411
   p_atomic_inc(&fb->stfb->stamp);
368
412
}
369
413
 
370
414
/**