diff options
Diffstat (limited to 'src/mesa/state_tracker')
40 files changed, 4661 insertions, 386 deletions
diff --git a/src/mesa/state_tracker/acc2.c b/src/mesa/state_tracker/acc2.c deleted file mode 100644 index fa5de2b764c..00000000000 --- a/src/mesa/state_tracker/acc2.c +++ /dev/null @@ -1,319 +0,0 @@ -/************************************************************************** - * - * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - - /* - * Authors: - * Brian Paul - */ - -#include "main/imports.h" -#include "main/image.h" -#include "main/macros.h" - -#include "st_context.h" -#include "st_cb_accum.h" -#include "st_cb_fbo.h" -#include "st_draw.h" -#include "st_format.h" -#include "pipe/p_context.h" -#include "pipe/p_defines.h" -#include "pipe/p_inlines.h" -#include "util/p_tile.h" - - -#define UNCLAMPED_FLOAT_TO_SHORT(us, f) \ - us = ( (short) ( CLAMP((f), -1.0, 1.0) * 32767.0F) ) - - -/** - * For hardware that supports deep color buffers, we could accelerate - * most/all the accum operations with blending/texturing. - * For now, just use the get/put_tile() functions and do things in software. - */ - - -static void -acc_get_tile_rgba(struct pipe_context *pipe, struct pipe_surface *acc_ps, - uint x, uint y, uint w, uint h, float *p) -{ - const enum pipe_format f = acc_ps->format; - const int cpp = acc_ps->cpp; - - acc_ps->format = PIPE_FORMAT_R16G16B16A16_SNORM; - acc_ps->cpp = 8; - - pipe_get_tile_rgba(pipe, acc_ps, x, y, w, h, p); - - acc_ps->format = f; - acc_ps->cpp = cpp; -} - - -static void -acc_put_tile_rgba(struct pipe_context *pipe, struct pipe_surface *acc_ps, - uint x, uint y, uint w, uint h, const float *p) -{ - enum pipe_format f = acc_ps->format; - const int cpp = acc_ps->cpp; - - acc_ps->format = PIPE_FORMAT_R16G16B16A16_SNORM; - acc_ps->cpp = 8; - - pipe_put_tile_rgba(pipe, acc_ps, x, y, w, h, p); - - acc_ps->format = f; - acc_ps->cpp = cpp; -} - - - -void -st_clear_accum_buffer(GLcontext *ctx, struct gl_renderbuffer *rb) -{ - struct pipe_context *pipe = ctx->st->pipe; - struct st_renderbuffer *acc_strb = st_renderbuffer(rb); - struct pipe_surface *acc_ps = acc_strb->surface; - const GLint xpos = ctx->DrawBuffer->_Xmin; - const GLint ypos = ctx->DrawBuffer->_Ymin; - const GLint width = ctx->DrawBuffer->_Xmax - xpos; - const GLint height = ctx->DrawBuffer->_Ymax - ypos; - const GLfloat r = ctx->Accum.ClearColor[0]; - const GLfloat g = ctx->Accum.ClearColor[1]; - const GLfloat b = ctx->Accum.ClearColor[2]; - const GLfloat a = ctx->Accum.ClearColor[3]; - GLfloat *accBuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); - int i; - -#if 1 - GLvoid *map; - - map = pipe_surface_map(acc_ps); - switch (acc_strb->format) { - case PIPE_FORMAT_R16G16B16A16_SNORM: - { - GLshort r = FLOAT_TO_SHORT(ctx->Accum.ClearColor[0]); - GLshort g = FLOAT_TO_SHORT(ctx->Accum.ClearColor[1]); - GLshort b = FLOAT_TO_SHORT(ctx->Accum.ClearColor[2]); - GLshort a = FLOAT_TO_SHORT(ctx->Accum.ClearColor[3]); - int i, j; - for (i = 0; i < height; i++) { - GLshort *dst = ((GLshort *) map - + ((ypos + i) * acc_ps->pitch + xpos) * 4); - for (j = 0; j < width; j++) { - dst[0] = r; - dst[1] = g; - dst[2] = b; - dst[3] = a; - dst += 4; - } - } - } - break; - default: - _mesa_problem(ctx, "unexpected format in st_clear_accum_buffer()"); - } - - pipe_surface_unmap(acc_ps); - -#else - for (i = 0; i < width * height; i++) { - accBuf[i*4+0] = r; - accBuf[i*4+1] = g; - accBuf[i*4+2] = b; - accBuf[i*4+3] = a; - } - - acc_put_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, accBuf); -#endif -} - - -/** For ADD/MULT */ -static void -accum_mad(struct pipe_context *pipe, GLfloat scale, GLfloat bias, - GLint xpos, GLint ypos, GLint width, GLint height, - struct pipe_surface *acc_ps) -{ - GLfloat *accBuf; - GLint i; - - accBuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); - - pipe_get_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, accBuf); - - for (i = 0; i < 4 * width * height; i++) { - accBuf[i] = accBuf[i] * scale + bias; - } - - pipe_put_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, accBuf); - - free(accBuf); -} - - -static void -accum_accum(struct pipe_context *pipe, GLfloat value, - GLint xpos, GLint ypos, GLint width, GLint height, - struct pipe_surface *acc_ps, - struct pipe_surface *color_ps) -{ - GLfloat *colorBuf, *accBuf; - GLint i; - - colorBuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); - accBuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); - - pipe_get_tile_rgba(pipe, color_ps, xpos, ypos, width, height, colorBuf); - acc_get_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, accBuf); - - for (i = 0; i < 4 * width * height; i++) { - accBuf[i] = accBuf[i] + colorBuf[i] * value; - } - - acc_put_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, accBuf); - - free(colorBuf); - free(accBuf); -} - - -static void -accum_load(struct pipe_context *pipe, GLfloat value, - GLint xpos, GLint ypos, GLint width, GLint height, - struct pipe_surface *acc_ps, - struct pipe_surface *color_ps) -{ - GLfloat *buf; - GLint i; - - buf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); - - pipe_get_tile_rgba(pipe, color_ps, xpos, ypos, width, height, buf); - - for (i = 0; i < 4 * width * height; i++) { - buf[i] = buf[i] * value; - } - - acc_put_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, buf); - - free(buf); -} - - -static void -accum_return(GLcontext *ctx, GLfloat value, - GLint xpos, GLint ypos, GLint width, GLint height, - struct pipe_surface *acc_ps, - struct pipe_surface *color_ps) -{ - struct pipe_context *pipe = ctx->st->pipe; - const GLubyte *colormask = ctx->Color.ColorMask; - GLfloat *abuf, *cbuf = NULL; - GLint i, ch; - - abuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); - - acc_get_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, abuf); - - if (!colormask[0] || !colormask[1] || !colormask[2] || !colormask[3]) { - cbuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); - pipe_get_tile_rgba(pipe, color_ps, xpos, ypos, width, height, cbuf); - } - - for (i = 0; i < width * height; i++) { - for (ch = 0; ch < 4; ch++) { - if (colormask[ch]) { - GLfloat val = abuf[i * 4 + ch] * value; - abuf[i * 4 + ch] = CLAMP(val, 0.0, 1.0); - } - else { - abuf[i * 4 + ch] = cbuf[i * 4 + ch]; - } - } - } - - pipe_put_tile_rgba(pipe, color_ps, xpos, ypos, width, height, abuf); - - free(abuf); - if (cbuf) - free(cbuf); -} - - -static void -st_Accum(GLcontext *ctx, GLenum op, GLfloat value) -{ - struct st_context *st = ctx->st; - struct pipe_context *pipe = st->pipe; - struct st_renderbuffer *acc_strb - = st_renderbuffer(ctx->DrawBuffer->Attachment[BUFFER_ACCUM].Renderbuffer); - struct st_renderbuffer *color_strb - = st_renderbuffer(ctx->ReadBuffer->_ColorReadBuffer); - struct pipe_surface *acc_ps = acc_strb->surface; - struct pipe_surface *color_ps = color_strb->surface; - - const GLint xpos = ctx->DrawBuffer->_Xmin; - const GLint ypos = ctx->DrawBuffer->_Ymin; - const GLint width = ctx->DrawBuffer->_Xmax - xpos; - const GLint height = ctx->DrawBuffer->_Ymax - ypos; - - /* make sure color bufs aren't cached */ - pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, NULL); - - switch (op) { - case GL_ADD: - if (value != 0.0F) { - accum_mad(pipe, 1.0, value, xpos, ypos, width, height, acc_ps); - } - break; - case GL_MULT: - if (value != 1.0F) { - accum_mad(pipe, value, 0.0, xpos, ypos, width, height, acc_ps); - } - break; - case GL_ACCUM: - if (value != 0.0F) { - accum_accum(pipe, value, xpos, ypos, width, height, acc_ps, color_ps); - } - break; - case GL_LOAD: - accum_load(pipe, value, xpos, ypos, width, height, acc_ps, color_ps); - break; - case GL_RETURN: - accum_return(ctx, value, xpos, ypos, width, height, acc_ps, color_ps); - break; - default: - assert(0); - } -} - - - -void st_init_accum_functions(struct dd_function_table *functions) -{ - functions->Accum = st_Accum; -} diff --git a/src/mesa/state_tracker/st_atom_framebuffer.c b/src/mesa/state_tracker/st_atom_framebuffer.c index 2916886610d..ca1a719a9ac 100644 --- a/src/mesa/state_tracker/st_atom_framebuffer.c +++ b/src/mesa/state_tracker/st_atom_framebuffer.c @@ -95,7 +95,7 @@ update_framebuffer_state( struct st_context *st ) struct pipe_framebuffer_state *framebuffer = &st->state.framebuffer; struct gl_framebuffer *fb = st->ctx->DrawBuffer; struct st_renderbuffer *strb; - GLuint i, j; + GLuint i; memset(framebuffer, 0, sizeof(*framebuffer)); @@ -108,20 +108,18 @@ update_framebuffer_state( struct st_context *st ) * to determine which surfaces to draw to */ framebuffer->num_cbufs = 0; - for (j = 0; j < MAX_DRAW_BUFFERS; j++) { - for (i = 0; i < fb->_NumColorDrawBuffers[j]; i++) { - strb = st_renderbuffer(fb->_ColorDrawBuffers[j][i]); - - /*printf("--------- framebuffer surface rtt %p\n", strb->rtt);*/ - if (strb->rtt) { - /* rendering to a GL texture, may have to update surface */ - update_renderbuffer_surface(st, strb); - } + for (i = 0; i < fb->_NumColorDrawBuffers; i++) { + strb = st_renderbuffer(fb->_ColorDrawBuffers[i]); - if (strb->surface) { - framebuffer->cbufs[framebuffer->num_cbufs] = strb->surface; - framebuffer->num_cbufs++; - } + /*printf("--------- framebuffer surface rtt %p\n", strb->rtt);*/ + if (strb->rtt) { + /* rendering to a GL texture, may have to update surface */ + update_renderbuffer_surface(st, strb); + } + + if (strb->surface) { + framebuffer->cbufs[framebuffer->num_cbufs] = strb->surface; + framebuffer->num_cbufs++; } } @@ -146,7 +144,7 @@ update_framebuffer_state( struct st_context *st ) cso_set_framebuffer(st->cso_context, framebuffer); - if (fb->_ColorDrawBufferMask[0] & BUFFER_BIT_FRONT_LEFT) { + if (fb->_ColorDrawBufferIndexes[0] == BUFFER_FRONT_LEFT) { if (st->frontbuffer_status == FRONT_STATUS_COPY_OF_BACK) { /* XXX copy back buf to front? */ } diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c index 73645201cc6..aa68aa9e3c1 100644 --- a/src/mesa/state_tracker/st_cb_bitmap.c +++ b/src/mesa/state_tracker/st_cb_bitmap.c @@ -791,7 +791,7 @@ st_destroy_bitmap(struct st_context *st) } if (st->bitmap.vbuf) { - pipe_buffer_destroy(pipe->screen, st->bitmap.vbuf); + pipe_buffer_reference(pipe->screen, &st->bitmap.vbuf, NULL); st->bitmap.vbuf = NULL; } diff --git a/src/mesa/state_tracker/st_cb_blit.c b/src/mesa/state_tracker/st_cb_blit.c index 327bafeb986..28526234720 100644 --- a/src/mesa/state_tracker/st_cb_blit.c +++ b/src/mesa/state_tracker/st_cb_blit.c @@ -79,7 +79,7 @@ st_BlitFramebuffer(GLcontext *ctx, struct st_renderbuffer *srcRb = st_renderbuffer(ctx->ReadBuffer->_ColorReadBuffer); struct st_renderbuffer *dstRb = - st_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0][0]); + st_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0]); struct pipe_surface *srcSurf = srcRb->surface; struct pipe_surface *dstSurf = dstRb->surface; diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index bc3055c3fdf..1412a3761f1 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -116,7 +116,7 @@ st_destroy_clear(struct st_context *st) st->clear.vs = NULL; } if (st->clear.vbuf) { - pipe_buffer_destroy(pipe->screen, st->clear.vbuf); + pipe_buffer_reference(pipe->screen, &st->clear.vbuf, NULL); st->clear.vbuf = NULL; } } diff --git a/src/mesa/state_tracker/st_cb_strings.c b/src/mesa/state_tracker/st_cb_strings.c index 066124f8f30..09545aa8fb8 100644 --- a/src/mesa/state_tracker/st_cb_strings.c +++ b/src/mesa/state_tracker/st_cb_strings.c @@ -40,7 +40,7 @@ #include "st_context.h" #include "st_cb_strings.h" -#define ST_VERSION_STRING "0.1" +#define ST_VERSION_STRING "0.2" static const GLubyte * st_get_string(GLcontext * ctx, GLenum name) diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index 0b2b639a5bd..d08229b57a3 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -749,8 +749,8 @@ st_GetTexImage(GLcontext * ctx, GLenum target, GLint level, static void st_GetCompressedTexImage(GLcontext *ctx, GLenum target, GLint level, GLvoid *pixels, - const struct gl_texture_object *texObj, - const struct gl_texture_image *texImage) + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) { st_get_tex_image(ctx, target, level, 0, 0, pixels, (struct gl_texture_object *) texObj, diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c index a8ae30a454f..a9387c05df8 100644 --- a/src/mesa/state_tracker/st_format.c +++ b/src/mesa/state_tracker/st_format.c @@ -512,6 +512,32 @@ st_choose_format(struct pipe_context *pipe, GLint internalFormat, return PIPE_FORMAT_Z24S8_UNORM; return PIPE_FORMAT_NONE; + case GL_SRGB_EXT: + case GL_SRGB8_EXT: + case GL_COMPRESSED_SRGB_EXT: + case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT: + case GL_SRGB_ALPHA_EXT: + case GL_SRGB8_ALPHA8_EXT: + case GL_COMPRESSED_SRGB_ALPHA_EXT: + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: + return default_rgba_format( screen, target, tex_usage, geom_flags ); + + case GL_SLUMINANCE_ALPHA_EXT: + case GL_SLUMINANCE8_ALPHA8_EXT: + case GL_COMPRESSED_SLUMINANCE_EXT: + case GL_COMPRESSED_SLUMINANCE_ALPHA_EXT: + if (screen->is_format_supported( screen, PIPE_FORMAT_A8L8_UNORM, target, tex_usage, geom_flags )) + return PIPE_FORMAT_A8L8_UNORM; + return default_rgba_format( screen, target, tex_usage, geom_flags ); + + case GL_SLUMINANCE_EXT: + case GL_SLUMINANCE8_EXT: + if (screen->is_format_supported( screen, PIPE_FORMAT_L8_UNORM, target, tex_usage, geom_flags )) + return PIPE_FORMAT_L8_UNORM; + return default_rgba_format( screen, target, tex_usage, geom_flags ); + default: return PIPE_FORMAT_NONE; } diff --git a/src/mesa/state_tracker/st_framebuffer.c b/src/mesa/state_tracker/st_framebuffer.c index 6ee1777fb7a..6fd731d209d 100644 --- a/src/mesa/state_tracker/st_framebuffer.c +++ b/src/mesa/state_tracker/st_framebuffer.c @@ -153,9 +153,9 @@ void st_resize_framebuffer( struct st_framebuffer *stfb, } -void st_unreference_framebuffer( struct st_framebuffer **stfb ) +void st_unreference_framebuffer( struct st_framebuffer *stfb ) { - _mesa_unreference_framebuffer((struct gl_framebuffer **) stfb); + _mesa_unreference_framebuffer((struct gl_framebuffer **) &stfb); } @@ -176,7 +176,9 @@ st_set_framebuffer_surface(struct st_framebuffer *stfb, assert(surfIndex < BUFFER_COUNT); strb = st_renderbuffer(stfb->Base.Attachment[surfIndex].Renderbuffer); - assert(strb); + + /* fail */ + if (!strb) return; /* replace the renderbuffer's surface/texture pointers */ pipe_surface_reference( &strb->surface, surf ); @@ -302,3 +304,10 @@ void *st_framebuffer_private( struct st_framebuffer *stfb ) return stfb->Private; } +void st_get_framebuffer_dimensions( struct st_framebuffer *stfb, + uint *width, + uint *height) +{ + *width = stfb->Base.Width; + *height = stfb->Base.Height; +} diff --git a/src/mesa/state_tracker/st_gen_mipmap.c b/src/mesa/state_tracker/st_gen_mipmap.c index b9d114b1c97..a15faf732ca 100644 --- a/src/mesa/state_tracker/st_gen_mipmap.c +++ b/src/mesa/state_tracker/st_gen_mipmap.c @@ -138,11 +138,11 @@ fallback_generate_mipmap(GLcontext *ctx, GLenum target, _mesa_generate_mipmap_level(target, datatype, comps, 0 /*border*/, pt->width[srcLevel], pt->height[srcLevel], pt->depth[srcLevel], - srcSurf->stride, /* stride in bytes */ srcData, + srcSurf->stride, /* stride in bytes */ pt->width[dstLevel], pt->height[dstLevel], pt->depth[dstLevel], - dstSurf->stride, /* stride in bytes */ - dstData); + dstData, + dstSurf->stride); /* stride in bytes */ pipe_buffer_unmap(pipe->screen, srcSurf->buffer); pipe_buffer_unmap(pipe->screen, dstSurf->buffer); diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.c b/src/mesa/state_tracker/st_mesa_to_tgsi.c index 50e638df46b..401f092cd06 100644 --- a/src/mesa/state_tracker/st_mesa_to_tgsi.c +++ b/src/mesa/state_tracker/st_mesa_to_tgsi.c @@ -346,6 +346,12 @@ compile_instruction( case OPCODE_DDY: fullinst->Instruction.Opcode = TGSI_OPCODE_DDY; break; + case OPCODE_DP2: + fullinst->Instruction.Opcode = TGSI_OPCODE_DP2; + break; + case OPCODE_DP2A: + fullinst->Instruction.Opcode = TGSI_OPCODE_DP2A; + break; case OPCODE_DP3: fullinst->Instruction.Opcode = TGSI_OPCODE_DP3; break; @@ -389,8 +395,8 @@ compile_instruction( fullinst->Instruction.Opcode = TGSI_OPCODE_IF; fullinst->InstructionExtLabel.Label = inst->BranchTarget + preamble_size; break; - case OPCODE_INT: - fullinst->Instruction.Opcode = TGSI_OPCODE_INT; + case OPCODE_TRUNC: + fullinst->Instruction.Opcode = TGSI_OPCODE_TRUNC; break; case OPCODE_KIL: /* conditional */ @@ -443,6 +449,12 @@ compile_instruction( case OPCODE_NOP: fullinst->Instruction.Opcode = TGSI_OPCODE_NOP; break; + case OPCODE_NRM3: + fullinst->Instruction.Opcode = TGSI_OPCODE_NRM; + break; + case OPCODE_NRM4: + fullinst->Instruction.Opcode = TGSI_OPCODE_NRM4; + break; case OPCODE_POW: fullinst->Instruction.Opcode = TGSI_OPCODE_POW; break; @@ -492,6 +504,9 @@ compile_instruction( case OPCODE_SNE: fullinst->Instruction.Opcode = TGSI_OPCODE_SNE; break; + case OPCODE_SSG: + fullinst->Instruction.Opcode = TGSI_OPCODE_SSG; + break; case OPCODE_SUB: fullinst->Instruction.Opcode = TGSI_OPCODE_SUB; break; @@ -563,7 +578,8 @@ make_input_decl( GLuint usage_mask, GLboolean semantic_info, GLuint semantic_name, - GLbitfield semantic_index ) + GLbitfield semantic_index, + GLbitfield input_flags) { struct tgsi_full_declaration decl; @@ -582,6 +598,10 @@ make_input_decl( if (interpolate_info) { decl.Declaration.Interpolate = interpolate; } + if (input_flags & PROG_PARAM_BIT_CENTROID) + decl.Declaration.Centroid = 1; + if (input_flags & PROG_PARAM_BIT_INVARIANT) + decl.Declaration.Invariant = 1; return decl; } @@ -594,7 +614,8 @@ make_output_decl( GLuint index, GLuint semantic_name, GLuint semantic_index, - GLbitfield usage_mask ) + GLuint usage_mask, + GLbitfield output_flags) { struct tgsi_full_declaration decl; @@ -608,6 +629,10 @@ make_output_decl( decl.DeclarationRange.Last = index; decl.Semantic.SemanticName = semantic_name; decl.Semantic.SemanticIndex = semantic_index; + if (output_flags & PROG_PARAM_BIT_CENTROID) + decl.Declaration.Centroid = 1; + if (output_flags & PROG_PARAM_BIT_INVARIANT) + decl.Declaration.Invariant = 1; return decl; } @@ -721,10 +746,12 @@ st_translate_mesa_program( const ubyte inputSemanticName[], const ubyte inputSemanticIndex[], const GLuint interpMode[], + const GLbitfield inputFlags[], GLuint numOutputs, const GLuint outputMapping[], const ubyte outputSemanticName[], const ubyte outputSemanticIndex[], + const GLbitfield outputFlags[], struct tgsi_token *tokens, GLuint maxTokens ) { @@ -762,7 +789,8 @@ st_translate_mesa_program( GL_TRUE, interpMode[i], TGSI_WRITEMASK_XYZW, GL_TRUE, inputSemanticName[i], - inputSemanticIndex[i]); + inputSemanticIndex[i], + inputFlags[i]); ti += tgsi_build_full_declaration(&fulldecl, &tokens[ti], header, @@ -779,7 +807,8 @@ st_translate_mesa_program( fulldecl = make_input_decl(i, GL_FALSE, 0, TGSI_WRITEMASK_XYZW, - GL_FALSE, 0, 0); + GL_FALSE, 0, 0, + inputFlags[i]); ti += tgsi_build_full_declaration(&fulldecl, &tokens[ti], header, @@ -798,13 +827,15 @@ st_translate_mesa_program( fulldecl = make_output_decl(i, TGSI_SEMANTIC_POSITION, /* Z / Depth */ outputSemanticIndex[i], - TGSI_WRITEMASK_Z ); + TGSI_WRITEMASK_Z, + outputFlags[i]); break; case TGSI_SEMANTIC_COLOR: fulldecl = make_output_decl(i, TGSI_SEMANTIC_COLOR, outputSemanticIndex[i], - TGSI_WRITEMASK_XYZW ); + TGSI_WRITEMASK_XYZW, + outputFlags[i]); break; default: assert(0); @@ -823,7 +854,8 @@ st_translate_mesa_program( fulldecl = make_output_decl(i, outputSemanticName[i], outputSemanticIndex[i], - TGSI_WRITEMASK_XYZW ); + TGSI_WRITEMASK_XYZW, + outputFlags[i]); ti += tgsi_build_full_declaration(&fulldecl, &tokens[ti], header, diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.h b/src/mesa/state_tracker/st_mesa_to_tgsi.h index 77c74644b8b..7b2bee1ab70 100644 --- a/src/mesa/state_tracker/st_mesa_to_tgsi.h +++ b/src/mesa/state_tracker/st_mesa_to_tgsi.h @@ -48,10 +48,12 @@ st_translate_mesa_program( const ubyte inputSemanticName[], const ubyte inputSemanticIndex[], const GLuint interpMode[], + const GLbitfield inputFlags[], GLuint numOutputs, const GLuint outputMapping[], const ubyte outputSemanticName[], const ubyte outputSemanticIndex[], + const GLbitfield outputFlags[], struct tgsi_token *tokens, GLuint maxTokens ); diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index af0df22dc59..cf4b39cee40 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -99,7 +99,12 @@ st_translate_vertex_program(struct st_context *st, ubyte vs_output_semantic_index[PIPE_MAX_SHADER_OUTPUTS]; uint vs_num_outputs = 0; + GLbitfield input_flags[MAX_PROGRAM_INPUTS]; + GLbitfield output_flags[MAX_PROGRAM_OUTPUTS]; + memset(&vs, 0, sizeof(vs)); + memset(input_flags, 0, sizeof(input_flags)); + memset(output_flags, 0, sizeof(output_flags)); if (stvp->Base.IsPositionInvariant) _mesa_insert_mvp_code(st->ctx, &stvp->Base); @@ -171,6 +176,8 @@ st_translate_vertex_program(struct st_context *st, default: assert(0); } + + input_flags[slot] = stvp->Base.Base.InputFlags[attr]; } } @@ -192,6 +199,7 @@ st_translate_vertex_program(struct st_context *st, for (i = 0; i < PIPE_MAX_SHADER_OUTPUTS; i++) { vs_output_semantic_name[i] = TGSI_SEMANTIC_GENERIC; vs_output_semantic_index[i] = 0; + output_flags[i] = 0x0; } num_generic = 0; @@ -276,6 +284,8 @@ st_translate_vertex_program(struct st_context *st, vs_output_semantic_index[slot] = num_generic++; } } + + output_flags[slot] = stvp->Base.Base.OutputFlags[attr]; } } @@ -307,21 +317,23 @@ st_translate_vertex_program(struct st_context *st, /* XXX: fix static allocation of tokens: */ - num_tokens = st_translate_mesa_program( TGSI_PROCESSOR_VERTEX, - &stvp->Base.Base, - /* inputs */ - vs_num_inputs, - stvp->input_to_index, - vs_input_semantic_name, - vs_input_semantic_index, - NULL, - /* outputs */ - vs_num_outputs, - outputMapping, - vs_output_semantic_name, - vs_output_semantic_index, - /* tokenized result */ - tokens, ST_MAX_SHADER_TOKENS); + num_tokens = st_translate_mesa_program(TGSI_PROCESSOR_VERTEX, + &stvp->Base.Base, + /* inputs */ + vs_num_inputs, + stvp->input_to_index, + vs_input_semantic_name, + vs_input_semantic_index, + NULL, + input_flags, + /* outputs */ + vs_num_outputs, + outputMapping, + vs_output_semantic_name, + vs_output_semantic_index, + output_flags, + /* tokenized result */ + tokens, ST_MAX_SHADER_TOKENS); assert(num_tokens < ST_MAX_SHADER_TOKENS); @@ -371,7 +383,12 @@ st_translate_fragment_program(struct st_context *st, ubyte fs_output_semantic_index[PIPE_MAX_SHADER_OUTPUTS]; uint fs_num_outputs = 0; + GLbitfield input_flags[MAX_PROGRAM_INPUTS]; + GLbitfield output_flags[MAX_PROGRAM_OUTPUTS]; + memset(&fs, 0, sizeof(fs)); + memset(input_flags, 0, sizeof(input_flags)); + memset(output_flags, 0, sizeof(output_flags)); /* which vertex output goes to the first fragment input: */ if (inputsRead & FRAG_BIT_WPOS) @@ -435,6 +452,8 @@ st_translate_fragment_program(struct st_context *st, stfp->input_semantic_index[slot] = num_generic++; interpMode[slot] = TGSI_INTERPOLATE_PERSPECTIVE; } + + input_flags[slot] = stfp->Base.Base.InputFlags[attr]; } } @@ -471,6 +490,9 @@ st_translate_fragment_program(struct st_context *st, default: assert(0); } + + output_flags[fs_num_outputs] = stfp->Base.Base.OutputFlags[attr]; + fs_num_outputs++; } } @@ -481,21 +503,23 @@ st_translate_fragment_program(struct st_context *st, /* XXX: fix static allocation of tokens: */ - num_tokens = st_translate_mesa_program( TGSI_PROCESSOR_FRAGMENT, - &stfp->Base.Base, - /* inputs */ - fs_num_inputs, - inputMapping, - stfp->input_semantic_name, - stfp->input_semantic_index, - interpMode, - /* outputs */ - fs_num_outputs, - outputMapping, - fs_output_semantic_name, - fs_output_semantic_index, - /* tokenized result */ - tokens, ST_MAX_SHADER_TOKENS); + num_tokens = st_translate_mesa_program(TGSI_PROCESSOR_FRAGMENT, + &stfp->Base.Base, + /* inputs */ + fs_num_inputs, + inputMapping, + stfp->input_semantic_name, + stfp->input_semantic_index, + interpMode, + input_flags, + /* outputs */ + fs_num_outputs, + outputMapping, + fs_output_semantic_name, + fs_output_semantic_index, + output_flags, + /* tokenized result */ + tokens, ST_MAX_SHADER_TOKENS); assert(num_tokens < ST_MAX_SHADER_TOKENS); diff --git a/src/mesa/state_tracker/st_public.h b/src/mesa/state_tracker/st_public.h index 5cfb2e41f24..88995aa8747 100644 --- a/src/mesa/state_tracker/st_public.h +++ b/src/mesa/state_tracker/st_public.h @@ -42,6 +42,8 @@ #define ST_SURFACE_DEPTH 8 #define ST_TEXTURE_2D 0x2 +#define ST_TEXTURE_RECT 0x4 + #define ST_TEXTURE_RGB 0x1 #define ST_TEXTURE_RGBA 0x2 @@ -75,6 +77,9 @@ void st_resize_framebuffer( struct st_framebuffer *stfb, void st_set_framebuffer_surface(struct st_framebuffer *stfb, uint surfIndex, struct pipe_surface *surf); +void st_get_framebuffer_dimensions( struct st_framebuffer *stfb, + uint *width, uint *height); + struct pipe_surface *st_get_framebuffer_surface(struct st_framebuffer *stfb, uint surfIndex); @@ -83,7 +88,7 @@ struct pipe_texture *st_get_framebuffer_texture(struct st_framebuffer *stfb, void *st_framebuffer_private( struct st_framebuffer *stfb ); -void st_unreference_framebuffer( struct st_framebuffer **stfb ); +void st_unreference_framebuffer( struct st_framebuffer *stfb ); void st_make_current(struct st_context *st, struct st_framebuffer *draw, @@ -96,6 +101,7 @@ void st_finish( struct st_context *st ); void st_notify_swapbuffers(struct st_framebuffer *stfb); void st_notify_swapbuffers_complete(struct st_framebuffer *stfb); +int st_set_teximage(struct pipe_texture *pt, int target); /** Redirect rendering into stfb's surface to a texture image */ int st_bind_teximage(struct st_framebuffer *stfb, uint surfIndex, diff --git a/src/mesa/state_tracker/st_texture.c b/src/mesa/state_tracker/st_texture.c index 29b16347625..63cfe5fc163 100644 --- a/src/mesa/state_tracker/st_texture.c +++ b/src/mesa/state_tracker/st_texture.c @@ -32,6 +32,7 @@ #include "st_cb_fbo.h" #include "main/enums.h" #include "main/teximage.h" +#include "main/texstore.h" #undef Elements /* fix re-defined macro warning */ @@ -352,6 +353,52 @@ st_texture_image_copy(struct pipe_context *pipe, } } +/** Bind a pipe surface for use as a texture image */ +int +st_set_teximage(struct pipe_texture *pt, int target) +{ + GET_CURRENT_CONTEXT(ctx); + const GLuint unit = ctx->Texture.CurrentUnit; + struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; + struct gl_texture_object *texObj; + struct gl_texture_image *texImage; + struct st_texture_image *stImage; + int internalFormat; + + switch (pt->format) { + case PIPE_FORMAT_A8R8G8B8_UNORM: + internalFormat = GL_RGBA8; + break; + default: + return 0; + }; + + switch (target) { + case ST_TEXTURE_2D: + target = GL_TEXTURE_2D; + break; + case ST_TEXTURE_RECT: + target = GL_TEXTURE_RECTANGLE_ARB; + break; + default: + return 0; + } + + texObj = _mesa_select_tex_object(ctx, texUnit, target); + texImage = _mesa_get_tex_image(ctx, texObj, target, 0); + stImage = st_texture_image(texImage); + + _mesa_init_teximage_fields(ctx, GL_TEXTURE_2D, texImage, pt->width[0], + pt->height[0], 1, 0, internalFormat); + + texImage->TexFormat = st_ChooseTextureFormat(ctx, internalFormat, GL_RGBA, + GL_UNSIGNED_BYTE); + _mesa_set_fetch_functions(texImage, 2); + + pipe_texture_reference(&stImage->pt, pt); + + return 1; +} /** Redirect rendering into stfb's surface to a texture image */ int diff --git a/src/mesa/state_tracker/wgl/SConscript b/src/mesa/state_tracker/wgl/SConscript new file mode 100644 index 00000000000..cceb8264ead --- /dev/null +++ b/src/mesa/state_tracker/wgl/SConscript @@ -0,0 +1,40 @@ +import os + +Import('*') + +if env['platform'] in ['windows']: + + env = env.Clone() + + env.Append(CPPPATH = [ + '#src/mesa', + ]) + + env.Append(CPPDEFINES = [ + '__GL_EXPORTS', + 'BUILD_GL32', + '_GNU_H_WINDOWS32_DEFINES', + ]) + + sources = [ + 'stw_device.c', + 'stw_framebuffer.c', + 'stw_icd.c', + 'stw_pixelformat.c', + 'stw_quirks.c', + 'stw_wgl_arbextensionsstring.c', + 'stw_wgl_arbmultisample.c', + 'stw_wgl_arbpixelformat.c', + #'stw_wgl.c', + 'stw_wgl_context.c', + 'stw_wgl_getprocaddress.c', + 'stw_wgl_pixelformat.c', + 'stw_wgl_swapbuffers.c', + ] + + wgl = env.ConvenienceLibrary( + target ='wgl', + source = sources, + ) + + Export('wgl') diff --git a/src/mesa/state_tracker/wgl/opengl32.def b/src/mesa/state_tracker/wgl/opengl32.def new file mode 100644 index 00000000000..238b728f1fe --- /dev/null +++ b/src/mesa/state_tracker/wgl/opengl32.def @@ -0,0 +1,879 @@ +; DO NOT EDIT - This file generated automatically by mesadef.py script +;DESCRIPTION 'Mesa (OpenGL work-alike) for Win32' +VERSION 6.5 +; +; Module definition file for Mesa (OPENGL32.DLL) +; +; Note: The OpenGL functions use the STDCALL +; function calling convention. Microsoft's +; OPENGL32 uses this convention and so must the +; Mesa OPENGL32 so that the Mesa DLL can be used +; as a drop-in replacement. +; +; The linker exports STDCALL entry points with +; 'decorated' names; e.g., _glBegin@0, where the +; trailing number is the number of bytes of +; parameter data pushed onto the stack. The +; callee is responsible for popping this data +; off the stack, usually via a RETF n instruction. +; +; However, the Microsoft OPENGL32.DLL does not export +; the decorated names, even though the calling convention +; is STDCALL. So, this module definition file is +; needed to force the Mesa OPENGL32.DLL to export the +; symbols in the same manner as the Microsoft DLL. +; Were it not for this problem, this file would not +; be needed (for the gl* functions) since the entry +; points are compiled with dllexport declspec. +; +; However, this file is still needed to export "internal" +; Mesa symbols for the benefit of the OSMESA32.DLL. +; +EXPORTS + glNewList + glEndList + glCallList + glCallLists + glDeleteLists + glGenLists + glListBase + glBegin + glBitmap + glColor3b + glColor3bv + glColor3d + glColor3dv + glColor3f + glColor3fv + glColor3i + glColor3iv + glColor3s + glColor3sv + glColor3ub + glColor3ubv + glColor3ui + glColor3uiv + glColor3us + glColor3usv + glColor4b + glColor4bv + glColor4d + glColor4dv + glColor4f + glColor4fv + glColor4i + glColor4iv + glColor4s + glColor4sv + glColor4ub + glColor4ubv + glColor4ui + glColor4uiv + glColor4us + glColor4usv + glEdgeFlag + glEdgeFlagv + glEnd + glIndexd + glIndexdv + glIndexf + glIndexfv + glIndexi + glIndexiv + glIndexs + glIndexsv + glNormal3b + glNormal3bv + glNormal3d + glNormal3dv + glNormal3f + glNormal3fv + glNormal3i + glNormal3iv + glNormal3s + glNormal3sv + glRasterPos2d + glRasterPos2dv + glRasterPos2f + glRasterPos2fv + glRasterPos2i + glRasterPos2iv + glRasterPos2s + glRasterPos2sv + glRasterPos3d + glRasterPos3dv + glRasterPos3f + glRasterPos3fv + glRasterPos3i + glRasterPos3iv + glRasterPos3s + glRasterPos3sv + glRasterPos4d + glRasterPos4dv + glRasterPos4f + glRasterPos4fv + glRasterPos4i + glRasterPos4iv + glRasterPos4s + glRasterPos4sv + glRectd + glRectdv + glRectf + glRectfv + glRecti + glRectiv + glRects + glRectsv + glTexCoord1d + glTexCoord1dv + glTexCoord1f + glTexCoord1fv + glTexCoord1i + glTexCoord1iv + glTexCoord1s + glTexCoord1sv + glTexCoord2d + glTexCoord2dv + glTexCoord2f + glTexCoord2fv + glTexCoord2i + glTexCoord2iv + glTexCoord2s + glTexCoord2sv + glTexCoord3d + glTexCoord3dv + glTexCoord3f + glTexCoord3fv + glTexCoord3i + glTexCoord3iv + glTexCoord3s + glTexCoord3sv + glTexCoord4d + glTexCoord4dv + glTexCoord4f + glTexCoord4fv + glTexCoord4i + glTexCoord4iv + glTexCoord4s + glTexCoord4sv + glVertex2d + glVertex2dv + glVertex2f + glVertex2fv + glVertex2i + glVertex2iv + glVertex2s + glVertex2sv + glVertex3d + glVertex3dv + glVertex3f + glVertex3fv + glVertex3i + glVertex3iv + glVertex3s + glVertex3sv + glVertex4d + glVertex4dv + glVertex4f + glVertex4fv + glVertex4i + glVertex4iv + glVertex4s + glVertex4sv + glClipPlane + glColorMaterial + glCullFace + glFogf + glFogfv + glFogi + glFogiv + glFrontFace + glHint + glLightf + glLightfv + glLighti + glLightiv + glLightModelf + glLightModelfv + glLightModeli + glLightModeliv + glLineStipple + glLineWidth + glMaterialf + glMaterialfv + glMateriali + glMaterialiv + glPointSize + glPolygonMode + glPolygonStipple + glScissor + glShadeModel + glTexParameterf + glTexParameterfv + glTexParameteri + glTexParameteriv + glTexImage1D + glTexImage2D + glTexEnvf + glTexEnvfv + glTexEnvi + glTexEnviv + glTexGend + glTexGendv + glTexGenf + glTexGenfv + glTexGeni + glTexGeniv + glFeedbackBuffer + glSelectBuffer + glRenderMode + glInitNames + glLoadName + glPassThrough + glPopName + glPushName + glDrawBuffer + glClear + glClearAccum + glClearIndex + glClearColor + glClearStencil + glClearDepth + glStencilMask + glColorMask + glDepthMask + glIndexMask + glAccum + glDisable + glEnable + glFinish + glFlush + glPopAttrib + glPushAttrib + glMap1d + glMap1f + glMap2d + glMap2f + glMapGrid1d + glMapGrid1f + glMapGrid2d + glMapGrid2f + glEvalCoord1d + glEvalCoord1dv + glEvalCoord1f + glEvalCoord1fv + glEvalCoord2d + glEvalCoord2dv + glEvalCoord2f + glEvalCoord2fv + glEvalMesh1 + glEvalPoint1 + glEvalMesh2 + glEvalPoint2 + glAlphaFunc + glBlendFunc + glLogicOp + glStencilFunc + glStencilOp + glDepthFunc + glPixelZoom + glPixelTransferf + glPixelTransferi + glPixelStoref + glPixelStorei + glPixelMapfv + glPixelMapuiv + glPixelMapusv + glReadBuffer + glCopyPixels + glReadPixels + glDrawPixels + glGetBooleanv + glGetClipPlane + glGetDoublev + glGetError + glGetFloatv + glGetIntegerv + glGetLightfv + glGetLightiv + glGetMapdv + glGetMapfv + glGetMapiv + glGetMaterialfv + glGetMaterialiv + glGetPixelMapfv + glGetPixelMapuiv + glGetPixelMapusv + glGetPolygonStipple + glGetString + glGetTexEnvfv + glGetTexEnviv + glGetTexGendv + glGetTexGenfv + glGetTexGeniv + glGetTexImage + glGetTexParameterfv + glGetTexParameteriv + glGetTexLevelParameterfv + glGetTexLevelParameteriv + glIsEnabled + glIsList + glDepthRange + glFrustum + glLoadIdentity + glLoadMatrixf + glLoadMatrixd + glMatrixMode + glMultMatrixf + glMultMatrixd + glOrtho + glPopMatrix + glPushMatrix + glRotated + glRotatef + glScaled + glScalef + glTranslated + glTranslatef + glViewport + glArrayElement + glColorPointer + glDisableClientState + glDrawArrays + glDrawElements + glEdgeFlagPointer + glEnableClientState + glGetPointerv + glIndexPointer + glInterleavedArrays + glNormalPointer + glTexCoordPointer + glVertexPointer + glPolygonOffset + glCopyTexImage1D + glCopyTexImage2D + glCopyTexSubImage1D + glCopyTexSubImage2D + glTexSubImage1D + glTexSubImage2D + glAreTexturesResident + glBindTexture + glDeleteTextures + glGenTextures + glIsTexture + glPrioritizeTextures + glIndexub + glIndexubv + glPopClientAttrib + glPushClientAttrib + glBlendColor + glBlendEquation + glDrawRangeElements + glColorTable + glColorTableParameterfv + glColorTableParameteriv + glCopyColorTable + glGetColorTable + glGetColorTableParameterfv + glGetColorTableParameteriv + glColorSubTable + glCopyColorSubTable + glConvolutionFilter1D + glConvolutionFilter2D + glConvolutionParameterf + glConvolutionParameterfv + glConvolutionParameteri + glConvolutionParameteriv + glCopyConvolutionFilter1D + glCopyConvolutionFilter2D + glGetConvolutionFilter + glGetConvolutionParameterfv + glGetConvolutionParameteriv + glGetSeparableFilter + glSeparableFilter2D + glGetHistogram + glGetHistogramParameterfv + glGetHistogramParameteriv + glGetMinmax + glGetMinmaxParameterfv + glGetMinmaxParameteriv + glHistogram + glMinmax + glResetHistogram + glResetMinmax + glTexImage3D + glTexSubImage3D + glCopyTexSubImage3D + glActiveTextureARB + glClientActiveTextureARB + glMultiTexCoord1dARB + glMultiTexCoord1dvARB + glMultiTexCoord1fARB + glMultiTexCoord1fvARB + glMultiTexCoord1iARB + glMultiTexCoord1ivARB + glMultiTexCoord1sARB + glMultiTexCoord1svARB + glMultiTexCoord2dARB + glMultiTexCoord2dvARB + glMultiTexCoord2fARB + glMultiTexCoord2fvARB + glMultiTexCoord2iARB + glMultiTexCoord2ivARB + glMultiTexCoord2sARB + glMultiTexCoord2svARB + glMultiTexCoord3dARB + glMultiTexCoord3dvARB + glMultiTexCoord3fARB + glMultiTexCoord3fvARB + glMultiTexCoord3iARB + glMultiTexCoord3ivARB + glMultiTexCoord3sARB + glMultiTexCoord3svARB + glMultiTexCoord4dARB + glMultiTexCoord4dvARB + glMultiTexCoord4fARB + glMultiTexCoord4fvARB + glMultiTexCoord4iARB + glMultiTexCoord4ivARB + glMultiTexCoord4sARB + glMultiTexCoord4svARB + glLoadTransposeMatrixfARB + glLoadTransposeMatrixdARB + glMultTransposeMatrixfARB + glMultTransposeMatrixdARB + glSampleCoverageARB + glCompressedTexImage3DARB + glCompressedTexImage2DARB + glCompressedTexImage1DARB + glCompressedTexSubImage3DARB + glCompressedTexSubImage2DARB + glCompressedTexSubImage1DARB + glGetCompressedTexImageARB + glActiveTexture + glClientActiveTexture + glMultiTexCoord1d + glMultiTexCoord1dv + glMultiTexCoord1f + glMultiTexCoord1fv + glMultiTexCoord1i + glMultiTexCoord1iv + glMultiTexCoord1s + glMultiTexCoord1sv + glMultiTexCoord2d + glMultiTexCoord2dv + glMultiTexCoord2f + glMultiTexCoord2fv + glMultiTexCoord2i + glMultiTexCoord2iv + glMultiTexCoord2s + glMultiTexCoord2sv + glMultiTexCoord3d + glMultiTexCoord3dv + glMultiTexCoord3f + glMultiTexCoord3fv + glMultiTexCoord3i + glMultiTexCoord3iv + glMultiTexCoord3s + glMultiTexCoord3sv + glMultiTexCoord4d + glMultiTexCoord4dv + glMultiTexCoord4f + glMultiTexCoord4fv + glMultiTexCoord4i + glMultiTexCoord4iv + glMultiTexCoord4s + glMultiTexCoord4sv + glLoadTransposeMatrixf + glLoadTransposeMatrixd + glMultTransposeMatrixf + glMultTransposeMatrixd + glSampleCoverage + glCompressedTexImage3D + glCompressedTexImage2D + glCompressedTexImage1D + glCompressedTexSubImage3D + glCompressedTexSubImage2D + glCompressedTexSubImage1D + glGetCompressedTexImage + glBlendColorEXT + glPolygonOffsetEXT + glTexImage3DEXT + glTexSubImage3DEXT + glTexSubImage1DEXT + glTexSubImage2DEXT + glCopyTexImage1DEXT + glCopyTexImage2DEXT + glCopyTexSubImage1DEXT + glCopyTexSubImage2DEXT + glCopyTexSubImage3DEXT + glAreTexturesResidentEXT + glBindTextureEXT + glDeleteTexturesEXT + glGenTexturesEXT + glIsTextureEXT + glPrioritizeTexturesEXT + glArrayElementEXT + glColorPointerEXT + glDrawArraysEXT + glEdgeFlagPointerEXT + glGetPointervEXT + glIndexPointerEXT + glNormalPointerEXT + glTexCoordPointerEXT + glVertexPointerEXT + glBlendEquationEXT + glPointParameterfEXT + glPointParameterfvEXT + glPointParameterfARB + glPointParameterfvARB + glColorTableEXT + glGetColorTableEXT + glGetColorTableParameterivEXT + glGetColorTableParameterfvEXT + glLockArraysEXT + glUnlockArraysEXT + glDrawRangeElementsEXT + glSecondaryColor3bEXT + glSecondaryColor3bvEXT + glSecondaryColor3dEXT + glSecondaryColor3dvEXT + glSecondaryColor3fEXT + glSecondaryColor3fvEXT + glSecondaryColor3iEXT + glSecondaryColor3ivEXT + glSecondaryColor3sEXT + glSecondaryColor3svEXT + glSecondaryColor3ubEXT + glSecondaryColor3ubvEXT + glSecondaryColor3uiEXT + glSecondaryColor3uivEXT + glSecondaryColor3usEXT + glSecondaryColor3usvEXT + glSecondaryColorPointerEXT + glMultiDrawArraysEXT + glMultiDrawElementsEXT + glFogCoordfEXT + glFogCoordfvEXT + glFogCoorddEXT + glFogCoorddvEXT + glFogCoordPointerEXT + glBlendFuncSeparateEXT + glFlushVertexArrayRangeNV + glVertexArrayRangeNV + glCombinerParameterfvNV + glCombinerParameterfNV + glCombinerParameterivNV + glCombinerParameteriNV + glCombinerInputNV + glCombinerOutputNV + glFinalCombinerInputNV + glGetCombinerInputParameterfvNV + glGetCombinerInputParameterivNV + glGetCombinerOutputParameterfvNV + glGetCombinerOutputParameterivNV + glGetFinalCombinerInputParameterfvNV + glGetFinalCombinerInputParameterivNV + glResizeBuffersMESA + glWindowPos2dMESA + glWindowPos2dvMESA + glWindowPos2fMESA + glWindowPos2fvMESA + glWindowPos2iMESA + glWindowPos2ivMESA + glWindowPos2sMESA + glWindowPos2svMESA + glWindowPos3dMESA + glWindowPos3dvMESA + glWindowPos3fMESA + glWindowPos3fvMESA + glWindowPos3iMESA + glWindowPos3ivMESA + glWindowPos3sMESA + glWindowPos3svMESA + glWindowPos4dMESA + glWindowPos4dvMESA + glWindowPos4fMESA + glWindowPos4fvMESA + glWindowPos4iMESA + glWindowPos4ivMESA + glWindowPos4sMESA + glWindowPos4svMESA + glWindowPos2dARB + glWindowPos2fARB + glWindowPos2iARB + glWindowPos2sARB + glWindowPos2dvARB + glWindowPos2fvARB + glWindowPos2ivARB + glWindowPos2svARB + glWindowPos3dARB + glWindowPos3fARB + glWindowPos3iARB + glWindowPos3sARB + glWindowPos3dvARB + glWindowPos3fvARB + glWindowPos3ivARB + glWindowPos3svARB + glAreProgramsResidentNV + glBindProgramNV + glDeleteProgramsNV + glExecuteProgramNV + glGenProgramsNV + glGetProgramParameterdvNV + glGetProgramParameterfvNV + glGetProgramivNV + glGetProgramStringNV + glGetTrackMatrixivNV + glGetVertexAttribdvNV + glGetVertexAttribfvNV + glGetVertexAttribivNV + glGetVertexAttribPointervNV + glIsProgramNV + glLoadProgramNV + glProgramParameter4dNV + glProgramParameter4dvNV + glProgramParameter4fNV + glProgramParameter4fvNV + glProgramParameters4dvNV + glProgramParameters4fvNV + glRequestResidentProgramsNV + glTrackMatrixNV + glVertexAttribPointerNV + glVertexAttrib1dNV + glVertexAttrib1dvNV + glVertexAttrib1fNV + glVertexAttrib1fvNV + glVertexAttrib1sNV + glVertexAttrib1svNV + glVertexAttrib2dNV + glVertexAttrib2dvNV + glVertexAttrib2fNV + glVertexAttrib2fvNV + glVertexAttrib2sNV + glVertexAttrib2svNV + glVertexAttrib3dNV + glVertexAttrib3dvNV + glVertexAttrib3fNV + glVertexAttrib3fvNV + glVertexAttrib3sNV + glVertexAttrib3svNV + glVertexAttrib4dNV + glVertexAttrib4dvNV + glVertexAttrib4fNV + glVertexAttrib4fvNV + glVertexAttrib4sNV + glVertexAttrib4svNV + glVertexAttrib4ubNV + glVertexAttrib4ubvNV + glVertexAttribs1dvNV + glVertexAttribs1fvNV + glVertexAttribs1svNV + glVertexAttribs2dvNV + glVertexAttribs2fvNV + glVertexAttribs2svNV + glVertexAttribs3dvNV + glVertexAttribs3fvNV + glVertexAttribs3svNV + glVertexAttribs4dvNV + glVertexAttribs4fvNV + glVertexAttribs4svNV + glVertexAttribs4ubvNV + glPointParameteriNV + glPointParameterivNV + glFogCoordf + glFogCoordfv + glFogCoordd + glFogCoorddv + glFogCoordPointer + glMultiDrawArrays + glMultiDrawElements + glPointParameterf + glPointParameterfv + glPointParameteri + glPointParameteriv + glSecondaryColor3b + glSecondaryColor3bv + glSecondaryColor3d + glSecondaryColor3dv + glSecondaryColor3f + glSecondaryColor3fv + glSecondaryColor3i + glSecondaryColor3iv + glSecondaryColor3s + glSecondaryColor3sv + glSecondaryColor3ub + glSecondaryColor3ubv + glSecondaryColor3ui + glSecondaryColor3uiv + glSecondaryColor3us + glSecondaryColor3usv + glSecondaryColorPointer + glWindowPos2d + glWindowPos2dv + glWindowPos2f + glWindowPos2fv + glWindowPos2i + glWindowPos2iv + glWindowPos2s + glWindowPos2sv + glWindowPos3d + glWindowPos3dv + glWindowPos3f + glWindowPos3fv + glWindowPos3i + glWindowPos3iv + glWindowPos3s + glWindowPos3sv + glVertexAttrib1sARB + glVertexAttrib1fARB + glVertexAttrib1dARB + glVertexAttrib2sARB + glVertexAttrib2fARB + glVertexAttrib2dARB + glVertexAttrib3sARB + glVertexAttrib3fARB + glVertexAttrib3dARB + glVertexAttrib4sARB + glVertexAttrib4fARB + glVertexAttrib4dARB + glVertexAttrib4NubARB + glVertexAttrib1svARB + glVertexAttrib1fvARB + glVertexAttrib1dvARB + glVertexAttrib2svARB + glVertexAttrib2fvARB + glVertexAttrib2dvARB + glVertexAttrib3svARB + glVertexAttrib3fvARB + glVertexAttrib3dvARB + glVertexAttrib4bvARB + glVertexAttrib4svARB + glVertexAttrib4ivARB + glVertexAttrib4ubvARB + glVertexAttrib4usvARB + glVertexAttrib4uivARB + glVertexAttrib4fvARB + glVertexAttrib4dvARB + glVertexAttrib4NbvARB + glVertexAttrib4NsvARB + glVertexAttrib4NivARB + glVertexAttrib4NubvARB + glVertexAttrib4NusvARB + glVertexAttrib4NuivARB + glVertexAttribPointerARB + glEnableVertexAttribArrayARB + glDisableVertexAttribArrayARB + glProgramStringARB + glBindProgramARB + glDeleteProgramsARB + glGenProgramsARB + glIsProgramARB + glProgramEnvParameter4dARB + glProgramEnvParameter4dvARB + glProgramEnvParameter4fARB + glProgramEnvParameter4fvARB + glProgramLocalParameter4dARB + glProgramLocalParameter4dvARB + glProgramLocalParameter4fARB + glProgramLocalParameter4fvARB + glGetProgramEnvParameterdvARB + glGetProgramEnvParameterfvARB + glGetProgramLocalParameterdvARB + glGetProgramLocalParameterfvARB + glGetProgramivARB + glGetProgramStringARB + glGetVertexAttribdvARB + glGetVertexAttribfvARB + glGetVertexAttribivARB + glGetVertexAttribPointervARB + glProgramNamedParameter4fNV + glProgramNamedParameter4dNV + glProgramNamedParameter4fvNV + glProgramNamedParameter4dvNV + glGetProgramNamedParameterfvNV + glGetProgramNamedParameterdvNV + glBindBufferARB + glBufferDataARB + glBufferSubDataARB + glDeleteBuffersARB + glGenBuffersARB + glGetBufferParameterivARB + glGetBufferPointervARB + glGetBufferSubDataARB + glIsBufferARB + glMapBufferARB + glUnmapBufferARB + glGenQueriesARB + glDeleteQueriesARB + glIsQueryARB + glBeginQueryARB + glEndQueryARB + glGetQueryivARB + glGetQueryObjectivARB + glGetQueryObjectuivARB + glBindBuffer + glBufferData + glBufferSubData + glDeleteBuffers + glGenBuffers + glGetBufferParameteriv + glGetBufferPointerv + glGetBufferSubData + glIsBuffer + glMapBuffer + glUnmapBuffer + glGenQueries + glDeleteQueries + glIsQuery + glBeginQuery + glEndQuery + glGetQueryiv + glGetQueryObjectiv + glGetQueryObjectuiv +; +; WGL API + wglChoosePixelFormat + wglCopyContext + wglCreateContext + wglCreateLayerContext + wglDeleteContext + wglDescribeLayerPlane + wglDescribePixelFormat + wglGetCurrentContext + wglGetCurrentDC + wglGetLayerPaletteEntries + wglGetPixelFormat + wglGetProcAddress + wglMakeCurrent + wglRealizeLayerPalette + wglSetLayerPaletteEntries + wglSetPixelFormat + wglShareLists + wglSwapBuffers + wglSwapLayerBuffers + wglUseFontBitmapsA + wglUseFontBitmapsW + wglUseFontOutlinesA + wglUseFontOutlinesW + wglGetExtensionsStringARB +; +; ICD API + DrvCopyContext + DrvCreateContext + DrvCreateLayerContext + DrvDeleteContext + DrvDescribeLayerPlane + DrvDescribePixelFormat + DrvGetLayerPaletteEntries + DrvGetProcAddress + DrvRealizeLayerPalette + DrvReleaseContext + DrvSetCallbackProcs + DrvSetContext + DrvSetLayerPaletteEntries + DrvSetPixelFormat + DrvShareLists + DrvSwapBuffers + DrvSwapLayerBuffers + DrvValidateVersion diff --git a/src/mesa/state_tracker/wgl/stw_device.c b/src/mesa/state_tracker/wgl/stw_device.c new file mode 100644 index 00000000000..52907f1a792 --- /dev/null +++ b/src/mesa/state_tracker/wgl/stw_device.c @@ -0,0 +1,93 @@ +/************************************************************************** + * + * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#include <windows.h> + +#include "pipe/p_debug.h" + +#include "stw_device.h" +#include "stw_winsys.h" +#include "stw_pixelformat.h" + + +struct stw_device *stw_dev = NULL; + + +static BOOL +st_init(void) +{ + static struct stw_device stw_dev_storage; + + assert(!stw_dev); + + stw_dev = &stw_dev_storage; + memset(stw_dev, 0, sizeof(*stw_dev)); + + stw_dev->screen = stw_winsys.create_screen(); + if(!stw_dev->screen) + goto error1; + + pixelformat_init(); + + return TRUE; + +error1: + stw_dev = NULL; + return FALSE; +} + + +static void +st_cleanup(void) +{ + DHGLRC dhglrc; + + if(!stw_dev) + return; + + /* Ensure all contexts are destroyed */ + for (dhglrc = 1; dhglrc <= DRV_CONTEXT_MAX; dhglrc++) + if (stw_dev->ctx_array[dhglrc - 1].hglrc) + DrvDeleteContext( dhglrc ); + + stw_dev = NULL; +} + + +BOOL WINAPI +DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) +{ + switch (fdwReason) { + case DLL_PROCESS_ATTACH: + return st_init(); + + case DLL_PROCESS_DETACH: + st_cleanup(); + break; + } + return TRUE; +} diff --git a/src/mesa/state_tracker/wgl/stw_device.h b/src/mesa/state_tracker/wgl/stw_device.h new file mode 100644 index 00000000000..49f79ac9c70 --- /dev/null +++ b/src/mesa/state_tracker/wgl/stw_device.h @@ -0,0 +1,58 @@ +/************************************************************************** + * + * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#ifndef ST_DEVICE_H_ +#define ST_DEVICE_H_ + + +#include "stw_icd.h" + +struct pipe_screen; + + +struct drv_context +{ + HGLRC hglrc; +}; + +#define DRV_CONTEXT_MAX 32 + + +struct stw_device +{ + struct pipe_screen *screen; + + struct drv_context ctx_array[DRV_CONTEXT_MAX]; + + DHGLRC ctx_current; +}; + + +extern struct stw_device *stw_dev; + + +#endif /* ST_DEVICE_H_ */ diff --git a/src/mesa/state_tracker/wgl/stw_framebuffer.c b/src/mesa/state_tracker/wgl/stw_framebuffer.c new file mode 100644 index 00000000000..57b89eee966 --- /dev/null +++ b/src/mesa/state_tracker/wgl/stw_framebuffer.c @@ -0,0 +1,182 @@ +/************************************************************************** + * + * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#define _GDI32_ + +#include <windows.h> +#include "main/context.h" +#include "pipe/p_format.h" +#include "state_tracker/st_context.h" +#include "state_tracker/st_public.h" +#include "stw_framebuffer.h" + +void +framebuffer_resize( + struct stw_framebuffer *fb, + GLuint width, + GLuint height ) +{ + if (fb->hbmDIB == NULL || fb->stfb->Base.Width != width || fb->stfb->Base.Height != height) { + if (fb->hbmDIB) + DeleteObject( fb->hbmDIB ); + + fb->hbmDIB = CreateCompatibleBitmap( + fb->hDC, + width, + height ); + } + + st_resize_framebuffer( fb->stfb, width, height ); +} + +static struct stw_framebuffer *fb_head = NULL; + +static LRESULT CALLBACK +window_proc( + HWND hWnd, + UINT uMsg, + WPARAM wParam, + LPARAM lParam ) +{ + struct stw_framebuffer *fb; + + for (fb = fb_head; fb != NULL; fb = fb->next) + if (fb->hWnd == hWnd) + break; + assert( fb != NULL ); + + if (uMsg == WM_SIZE && wParam != SIZE_MINIMIZED) + framebuffer_resize( fb, LOWORD( lParam ), HIWORD( lParam ) ); + + return CallWindowProc( fb->WndProc, hWnd, uMsg, wParam, lParam ); +} + +/* Create a new framebuffer object which will correspond to the given HDC. + */ +struct stw_framebuffer * +framebuffer_create( + HDC hdc, + GLvisual *visual, + GLuint width, + GLuint height ) +{ + struct stw_framebuffer *fb; + enum pipe_format colorFormat, depthFormat, stencilFormat; + + fb = CALLOC_STRUCT( stw_framebuffer ); + if (fb == NULL) + return NULL; + + /* Determine PIPE_FORMATs for buffers. + */ + colorFormat = PIPE_FORMAT_A8R8G8B8_UNORM; + + if (visual->depthBits == 0) + depthFormat = PIPE_FORMAT_NONE; + else if (visual->depthBits <= 16) + depthFormat = PIPE_FORMAT_Z16_UNORM; + else if (visual->depthBits <= 24) + depthFormat = PIPE_FORMAT_S8Z24_UNORM; + else + depthFormat = PIPE_FORMAT_Z32_UNORM; + + if (visual->stencilBits == 8) { + if (depthFormat == PIPE_FORMAT_S8Z24_UNORM) + stencilFormat = depthFormat; + else + stencilFormat = PIPE_FORMAT_S8_UNORM; + } + else { + stencilFormat = PIPE_FORMAT_NONE; + } + + fb->stfb = st_create_framebuffer( + visual, + colorFormat, + depthFormat, + stencilFormat, + width, + height, + (void *) fb ); + + fb->cColorBits = GetDeviceCaps( hdc, BITSPIXEL ); + fb->hDC = hdc; + + /* Subclass a window associated with the device context. + */ + fb->hWnd = WindowFromDC( hdc ); + if (fb->hWnd != NULL) { + fb->WndProc = (WNDPROC) SetWindowLong( + fb->hWnd, + GWL_WNDPROC, + (LONG) window_proc ); + } + + fb->next = fb_head; + fb_head = fb; + return fb; +} + +void +framebuffer_destroy( + struct stw_framebuffer *fb ) +{ + struct stw_framebuffer **link = &fb_head; + struct stw_framebuffer *pfb = fb_head; + + while (pfb != NULL) { + if (pfb == fb) { + if (fb->hWnd != NULL) { + SetWindowLong( + fb->hWnd, + GWL_WNDPROC, + (LONG) fb->WndProc ); + } + + *link = fb->next; + FREE( fb ); + return; + } + + link = &pfb->next; + pfb = pfb->next; + } +} + +/* Given an hdc, return the corresponding wgl_context. + */ +struct stw_framebuffer * +framebuffer_from_hdc( + HDC hdc ) +{ + struct stw_framebuffer *fb; + + for (fb = fb_head; fb != NULL; fb = fb->next) + if (fb->hDC == hdc) + return fb; + return NULL; +} diff --git a/src/mesa/state_tracker/wgl/stw_framebuffer.h b/src/mesa/state_tracker/wgl/stw_framebuffer.h new file mode 100644 index 00000000000..2e16e421f2c --- /dev/null +++ b/src/mesa/state_tracker/wgl/stw_framebuffer.h @@ -0,0 +1,71 @@ +/************************************************************************** + * + * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#ifndef STW_FRAMEBUFFER_H +#define STW_FRAMEBUFFER_H + +#include "main/mtypes.h" + +/* Windows framebuffer, derived from gl_framebuffer. + */ +struct stw_framebuffer +{ + struct st_framebuffer *stfb; + HDC hDC; + int pixelformat; + BYTE cColorBits; + HDC dib_hDC; + HBITMAP hbmDIB; + HBITMAP hOldBitmap; + PBYTE pbPixels; + HWND hWnd; + WNDPROC WndProc; + struct stw_framebuffer *next; +}; + +struct stw_framebuffer * +framebuffer_create( + HDC hdc, + GLvisual *visual, + GLuint width, + GLuint height ); + +void +framebuffer_destroy( + struct stw_framebuffer *fb ); + +void +framebuffer_resize( + struct stw_framebuffer *fb, + GLuint width, + GLuint height ); + +struct stw_framebuffer * +framebuffer_from_hdc( + HDC hdc ); + +#endif /* STW_FRAMEBUFFER_H */ diff --git a/src/mesa/state_tracker/wgl/stw_icd.c b/src/mesa/state_tracker/wgl/stw_icd.c new file mode 100644 index 00000000000..17bdbd15fac --- /dev/null +++ b/src/mesa/state_tracker/wgl/stw_icd.c @@ -0,0 +1,637 @@ +/************************************************************************** + * + * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#include <windows.h> +#include <stdio.h> + +#include "GL/gl.h" +#include "GL/mesa_wgl.h" + +#include "pipe/p_debug.h" + +#include "stw_device.h" +#include "stw_icd.h" + + +static HGLRC +_drv_lookup_hglrc( DHGLRC dhglrc ) +{ + if (dhglrc == 0 || dhglrc >= DRV_CONTEXT_MAX) + return NULL; + return stw_dev->ctx_array[dhglrc - 1].hglrc; +} + +BOOL APIENTRY +DrvCopyContext( + DHGLRC dhrcSource, + DHGLRC dhrcDest, + UINT fuMask ) +{ + debug_printf( "%s\n", __FUNCTION__ ); + + return FALSE; +} + +DHGLRC APIENTRY +DrvCreateLayerContext( + HDC hdc, + INT iLayerPlane ) +{ + DHGLRC dhglrc = 0; + + if (iLayerPlane == 0) { + DWORD i; + + for (i = 0; i < DRV_CONTEXT_MAX; i++) { + if (stw_dev->ctx_array[i].hglrc == NULL) + break; + } + + if (i < DRV_CONTEXT_MAX) { + stw_dev->ctx_array[i].hglrc = wglCreateContext( hdc ); + if (stw_dev->ctx_array[i].hglrc != NULL) + dhglrc = i + 1; + } + } + + debug_printf( "%s( 0x%p, %d ) = %u\n", __FUNCTION__, hdc, iLayerPlane, dhglrc ); + + return dhglrc; +} + +DHGLRC APIENTRY +DrvCreateContext( + HDC hdc ) +{ + return DrvCreateLayerContext( hdc, 0 ); +} + +BOOL APIENTRY +DrvDeleteContext( + DHGLRC dhglrc ) +{ + HGLRC hglrc = _drv_lookup_hglrc( dhglrc ); + BOOL success = FALSE; + + if (hglrc != NULL) { + success = wglDeleteContext( hglrc ); + if (success) + stw_dev->ctx_array[dhglrc - 1].hglrc = NULL; + } + + debug_printf( "%s( %u ) = %s\n", __FUNCTION__, dhglrc, success ? "TRUE" : "FALSE" ); + + return success; +} + +BOOL APIENTRY +DrvDescribeLayerPlane( + HDC hdc, + INT iPixelFormat, + INT iLayerPlane, + UINT nBytes, + LPLAYERPLANEDESCRIPTOR plpd ) +{ + debug_printf( "%s\n", __FUNCTION__ ); + + return FALSE; +} + +LONG APIENTRY +DrvDescribePixelFormat( + HDC hdc, + INT iPixelFormat, + ULONG cjpfd, + PIXELFORMATDESCRIPTOR *ppfd ) +{ + LONG r; + + r = wglDescribePixelFormat( hdc, iPixelFormat, cjpfd, ppfd ); + + debug_printf( "%s( 0x%p, %d, %u, 0x%p ) = %d\n", __FUNCTION__, hdc, iPixelFormat, cjpfd, ppfd, r ); + + return r; +} + +int APIENTRY +DrvGetLayerPaletteEntries( + HDC hdc, + INT iLayerPlane, + INT iStart, + INT cEntries, + COLORREF *pcr ) +{ + debug_printf( "%s\n", __FUNCTION__ ); + + return 0; +} + +PROC APIENTRY +DrvGetProcAddress( + LPCSTR lpszProc ) +{ + PROC r; + + r = wglGetProcAddress( lpszProc ); + + debug_printf( "%s( \", __FUNCTION__%s\" ) = 0x%p\n", lpszProc, r ); + + return r; +} + +BOOL APIENTRY +DrvRealizeLayerPalette( + HDC hdc, + INT iLayerPlane, + BOOL bRealize ) +{ + debug_printf( "%s\n", __FUNCTION__ ); + + return FALSE; +} + +BOOL APIENTRY +DrvReleaseContext( + DHGLRC dhglrc ) +{ + BOOL success = FALSE; + + if (dhglrc == stw_dev->ctx_current) { + HGLRC hglrc = _drv_lookup_hglrc( dhglrc ); + + if (hglrc != NULL) { + success = wglMakeCurrent( NULL, NULL ); + if (success) + stw_dev->ctx_current = 0; + } + } + + debug_printf( "%s( %u ) = %s\n", __FUNCTION__, dhglrc, success ? "TRUE" : "FALSE" ); + + return success; +} + +void APIENTRY +DrvSetCallbackProcs( + INT nProcs, + PROC *pProcs ) +{ + debug_printf( "%s( %d, 0x%p )\n", __FUNCTION__, nProcs, pProcs ); + + return; +} + +#define GPA_GL( NAME ) disp->NAME = gl##NAME + +static GLCLTPROCTABLE cpt; + +PGLCLTPROCTABLE APIENTRY +DrvSetContext( + HDC hdc, + DHGLRC dhglrc, + PFN_SETPROCTABLE pfnSetProcTable ) +{ + HGLRC hglrc = _drv_lookup_hglrc( dhglrc ); + GLDISPATCHTABLE *disp = &cpt.glDispatchTable; + + debug_printf( "%s( 0x%p, %u, 0x%p )\n", __FUNCTION__, hdc, dhglrc, pfnSetProcTable ); + + if (hglrc == NULL) + return NULL; + + if (!wglMakeCurrent( hdc, hglrc )) + return NULL; + + memset( &cpt, 0, sizeof( cpt ) ); + cpt.cEntries = OPENGL_VERSION_110_ENTRIES; + + GPA_GL( NewList ); + GPA_GL( EndList ); + GPA_GL( CallList ); + GPA_GL( CallLists ); + GPA_GL( DeleteLists ); + GPA_GL( GenLists ); + GPA_GL( ListBase ); + GPA_GL( Begin ); + GPA_GL( Bitmap ); + GPA_GL( Color3b ); + GPA_GL( Color3bv ); + GPA_GL( Color3d ); + GPA_GL( Color3dv ); + GPA_GL( Color3f ); + GPA_GL( Color3fv ); + GPA_GL( Color3i ); + GPA_GL( Color3iv ); + GPA_GL( Color3s ); + GPA_GL( Color3sv ); + GPA_GL( Color3ub ); + GPA_GL( Color3ubv ); + GPA_GL( Color3ui ); + GPA_GL( Color3uiv ); + GPA_GL( Color3us ); + GPA_GL( Color3usv ); + GPA_GL( Color4b ); + GPA_GL( Color4bv ); + GPA_GL( Color4d ); + GPA_GL( Color4dv ); + GPA_GL( Color4f ); + GPA_GL( Color4fv ); + GPA_GL( Color4i ); + GPA_GL( Color4iv ); + GPA_GL( Color4s ); + GPA_GL( Color4sv ); + GPA_GL( Color4ub ); + GPA_GL( Color4ubv ); + GPA_GL( Color4ui ); + GPA_GL( Color4uiv ); + GPA_GL( Color4us ); + GPA_GL( Color4usv ); + GPA_GL( EdgeFlag ); + GPA_GL( EdgeFlagv ); + GPA_GL( End ); + GPA_GL( Indexd ); + GPA_GL( Indexdv ); + GPA_GL( Indexf ); + GPA_GL( Indexfv ); + GPA_GL( Indexi ); + GPA_GL( Indexiv ); + GPA_GL( Indexs ); + GPA_GL( Indexsv ); + GPA_GL( Normal3b ); + GPA_GL( Normal3bv ); + GPA_GL( Normal3d ); + GPA_GL( Normal3dv ); + GPA_GL( Normal3f ); + GPA_GL( Normal3fv ); + GPA_GL( Normal3i ); + GPA_GL( Normal3iv ); + GPA_GL( Normal3s ); + GPA_GL( Normal3sv ); + GPA_GL( RasterPos2d ); + GPA_GL( RasterPos2dv ); + GPA_GL( RasterPos2f ); + GPA_GL( RasterPos2fv ); + GPA_GL( RasterPos2i ); + GPA_GL( RasterPos2iv ); + GPA_GL( RasterPos2s ); + GPA_GL( RasterPos2sv ); + GPA_GL( RasterPos3d ); + GPA_GL( RasterPos3dv ); + GPA_GL( RasterPos3f ); + GPA_GL( RasterPos3fv ); + GPA_GL( RasterPos3i ); + GPA_GL( RasterPos3iv ); + GPA_GL( RasterPos3s ); + GPA_GL( RasterPos3sv ); + GPA_GL( RasterPos4d ); + GPA_GL( RasterPos4dv ); + GPA_GL( RasterPos4f ); + GPA_GL( RasterPos4fv ); + GPA_GL( RasterPos4i ); + GPA_GL( RasterPos4iv ); + GPA_GL( RasterPos4s ); + GPA_GL( RasterPos4sv ); + GPA_GL( Rectd ); + GPA_GL( Rectdv ); + GPA_GL( Rectf ); + GPA_GL( Rectfv ); + GPA_GL( Recti ); + GPA_GL( Rectiv ); + GPA_GL( Rects ); + GPA_GL( Rectsv ); + GPA_GL( TexCoord1d ); + GPA_GL( TexCoord1dv ); + GPA_GL( TexCoord1f ); + GPA_GL( TexCoord1fv ); + GPA_GL( TexCoord1i ); + GPA_GL( TexCoord1iv ); + GPA_GL( TexCoord1s ); + GPA_GL( TexCoord1sv ); + GPA_GL( TexCoord2d ); + GPA_GL( TexCoord2dv ); + GPA_GL( TexCoord2f ); + GPA_GL( TexCoord2fv ); + GPA_GL( TexCoord2i ); + GPA_GL( TexCoord2iv ); + GPA_GL( TexCoord2s ); + GPA_GL( TexCoord2sv ); + GPA_GL( TexCoord3d ); + GPA_GL( TexCoord3dv ); + GPA_GL( TexCoord3f ); + GPA_GL( TexCoord3fv ); + GPA_GL( TexCoord3i ); + GPA_GL( TexCoord3iv ); + GPA_GL( TexCoord3s ); + GPA_GL( TexCoord3sv ); + GPA_GL( TexCoord4d ); + GPA_GL( TexCoord4dv ); + GPA_GL( TexCoord4f ); + GPA_GL( TexCoord4fv ); + GPA_GL( TexCoord4i ); + GPA_GL( TexCoord4iv ); + GPA_GL( TexCoord4s ); + GPA_GL( TexCoord4sv ); + GPA_GL( Vertex2d ); + GPA_GL( Vertex2dv ); + GPA_GL( Vertex2f ); + GPA_GL( Vertex2fv ); + GPA_GL( Vertex2i ); + GPA_GL( Vertex2iv ); + GPA_GL( Vertex2s ); + GPA_GL( Vertex2sv ); + GPA_GL( Vertex3d ); + GPA_GL( Vertex3dv ); + GPA_GL( Vertex3f ); + GPA_GL( Vertex3fv ); + GPA_GL( Vertex3i ); + GPA_GL( Vertex3iv ); + GPA_GL( Vertex3s ); + GPA_GL( Vertex3sv ); + GPA_GL( Vertex4d ); + GPA_GL( Vertex4dv ); + GPA_GL( Vertex4f ); + GPA_GL( Vertex4fv ); + GPA_GL( Vertex4i ); + GPA_GL( Vertex4iv ); + GPA_GL( Vertex4s ); + GPA_GL( Vertex4sv ); + GPA_GL( ClipPlane ); + GPA_GL( ColorMaterial ); + GPA_GL( CullFace ); + GPA_GL( Fogf ); + GPA_GL( Fogfv ); + GPA_GL( Fogi ); + GPA_GL( Fogiv ); + GPA_GL( FrontFace ); + GPA_GL( Hint ); + GPA_GL( Lightf ); + GPA_GL( Lightfv ); + GPA_GL( Lighti ); + GPA_GL( Lightiv ); + GPA_GL( LightModelf ); + GPA_GL( LightModelfv ); + GPA_GL( LightModeli ); + GPA_GL( LightModeliv ); + GPA_GL( LineStipple ); + GPA_GL( LineWidth ); + GPA_GL( Materialf ); + GPA_GL( Materialfv ); + GPA_GL( Materiali ); + GPA_GL( Materialiv ); + GPA_GL( PointSize ); + GPA_GL( PolygonMode ); + GPA_GL( PolygonStipple ); + GPA_GL( Scissor ); + GPA_GL( ShadeModel ); + GPA_GL( TexParameterf ); + GPA_GL( TexParameterfv ); + GPA_GL( TexParameteri ); + GPA_GL( TexParameteriv ); + GPA_GL( TexImage1D ); + GPA_GL( TexImage2D ); + GPA_GL( TexEnvf ); + GPA_GL( TexEnvfv ); + GPA_GL( TexEnvi ); + GPA_GL( TexEnviv ); + GPA_GL( TexGend ); + GPA_GL( TexGendv ); + GPA_GL( TexGenf ); + GPA_GL( TexGenfv ); + GPA_GL( TexGeni ); + GPA_GL( TexGeniv ); + GPA_GL( FeedbackBuffer ); + GPA_GL( SelectBuffer ); + GPA_GL( RenderMode ); + GPA_GL( InitNames ); + GPA_GL( LoadName ); + GPA_GL( PassThrough ); + GPA_GL( PopName ); + GPA_GL( PushName ); + GPA_GL( DrawBuffer ); + GPA_GL( Clear ); + GPA_GL( ClearAccum ); + GPA_GL( ClearIndex ); + GPA_GL( ClearColor ); + GPA_GL( ClearStencil ); + GPA_GL( ClearDepth ); + GPA_GL( StencilMask ); + GPA_GL( ColorMask ); + GPA_GL( DepthMask ); + GPA_GL( IndexMask ); + GPA_GL( Accum ); + GPA_GL( Disable ); + GPA_GL( Enable ); + GPA_GL( Finish ); + GPA_GL( Flush ); + GPA_GL( PopAttrib ); + GPA_GL( PushAttrib ); + GPA_GL( Map1d ); + GPA_GL( Map1f ); + GPA_GL( Map2d ); + GPA_GL( Map2f ); + GPA_GL( MapGrid1d ); + GPA_GL( MapGrid1f ); + GPA_GL( MapGrid2d ); + GPA_GL( MapGrid2f ); + GPA_GL( EvalCoord1d ); + GPA_GL( EvalCoord1dv ); + GPA_GL( EvalCoord1f ); + GPA_GL( EvalCoord1fv ); + GPA_GL( EvalCoord2d ); + GPA_GL( EvalCoord2dv ); + GPA_GL( EvalCoord2f ); + GPA_GL( EvalCoord2fv ); + GPA_GL( EvalMesh1 ); + GPA_GL( EvalPoint1 ); + GPA_GL( EvalMesh2 ); + GPA_GL( EvalPoint2 ); + GPA_GL( AlphaFunc ); + GPA_GL( BlendFunc ); + GPA_GL( LogicOp ); + GPA_GL( StencilFunc ); + GPA_GL( StencilOp ); + GPA_GL( DepthFunc ); + GPA_GL( PixelZoom ); + GPA_GL( PixelTransferf ); + GPA_GL( PixelTransferi ); + GPA_GL( PixelStoref ); + GPA_GL( PixelStorei ); + GPA_GL( PixelMapfv ); + GPA_GL( PixelMapuiv ); + GPA_GL( PixelMapusv ); + GPA_GL( ReadBuffer ); + GPA_GL( CopyPixels ); + GPA_GL( ReadPixels ); + GPA_GL( DrawPixels ); + GPA_GL( GetBooleanv ); + GPA_GL( GetClipPlane ); + GPA_GL( GetDoublev ); + GPA_GL( GetError ); + GPA_GL( GetFloatv ); + GPA_GL( GetIntegerv ); + GPA_GL( GetLightfv ); + GPA_GL( GetLightiv ); + GPA_GL( GetMapdv ); + GPA_GL( GetMapfv ); + GPA_GL( GetMapiv ); + GPA_GL( GetMaterialfv ); + GPA_GL( GetMaterialiv ); + GPA_GL( GetPixelMapfv ); + GPA_GL( GetPixelMapuiv ); + GPA_GL( GetPixelMapusv ); + GPA_GL( GetPolygonStipple ); + GPA_GL( GetString ); + GPA_GL( GetTexEnvfv ); + GPA_GL( GetTexEnviv ); + GPA_GL( GetTexGendv ); + GPA_GL( GetTexGenfv ); + GPA_GL( GetTexGeniv ); + GPA_GL( GetTexImage ); + GPA_GL( GetTexParameterfv ); + GPA_GL( GetTexParameteriv ); + GPA_GL( GetTexLevelParameterfv ); + GPA_GL( GetTexLevelParameteriv ); + GPA_GL( IsEnabled ); + GPA_GL( IsList ); + GPA_GL( DepthRange ); + GPA_GL( Frustum ); + GPA_GL( LoadIdentity ); + GPA_GL( LoadMatrixf ); + GPA_GL( LoadMatrixd ); + GPA_GL( MatrixMode ); + GPA_GL( MultMatrixf ); + GPA_GL( MultMatrixd ); + GPA_GL( Ortho ); + GPA_GL( PopMatrix ); + GPA_GL( PushMatrix ); + GPA_GL( Rotated ); + GPA_GL( Rotatef ); + GPA_GL( Scaled ); + GPA_GL( Scalef ); + GPA_GL( Translated ); + GPA_GL( Translatef ); + GPA_GL( Viewport ); + GPA_GL( ArrayElement ); + GPA_GL( BindTexture ); + GPA_GL( ColorPointer ); + GPA_GL( DisableClientState ); + GPA_GL( DrawArrays ); + GPA_GL( DrawElements ); + GPA_GL( EdgeFlagPointer ); + GPA_GL( EnableClientState ); + GPA_GL( IndexPointer ); + GPA_GL( Indexub ); + GPA_GL( Indexubv ); + GPA_GL( InterleavedArrays ); + GPA_GL( NormalPointer ); + GPA_GL( PolygonOffset ); + GPA_GL( TexCoordPointer ); + GPA_GL( VertexPointer ); + GPA_GL( AreTexturesResident ); + GPA_GL( CopyTexImage1D ); + GPA_GL( CopyTexImage2D ); + GPA_GL( CopyTexSubImage1D ); + GPA_GL( CopyTexSubImage2D ); + GPA_GL( DeleteTextures ); + GPA_GL( GenTextures ); + GPA_GL( GetPointerv ); + GPA_GL( IsTexture ); + GPA_GL( PrioritizeTextures ); + GPA_GL( TexSubImage1D ); + GPA_GL( TexSubImage2D ); + GPA_GL( PopClientAttrib ); + GPA_GL( PushClientAttrib ); + + return &cpt; +} + +int APIENTRY +DrvSetLayerPaletteEntries( + HDC hdc, + INT iLayerPlane, + INT iStart, + INT cEntries, + CONST COLORREF *pcr ) +{ + debug_printf( "%s\n", __FUNCTION__ ); + + return 0; +} + +BOOL APIENTRY +DrvSetPixelFormat( + HDC hdc, + LONG iPixelFormat ) +{ + PIXELFORMATDESCRIPTOR pfd; + BOOL r; + + wglDescribePixelFormat( hdc, iPixelFormat, sizeof( pfd ), &pfd ); + r = wglSetPixelFormat( hdc, iPixelFormat, &pfd ); + + debug_printf( "%s( 0x%p, %d ) = %s\n", __FUNCTION__, hdc, iPixelFormat, r ? "TRUE" : "FALSE" ); + + return r; +} + +BOOL APIENTRY +DrvShareLists( + DHGLRC dhglrc1, + DHGLRC dhglrc2 ) +{ + debug_printf( "%s\n", __FUNCTION__ ); + + return FALSE; +} + +BOOL APIENTRY +DrvSwapBuffers( + HDC hdc ) +{ + debug_printf( "%s( 0x%p )\n", __FUNCTION__, hdc ); + + return wglSwapBuffers( hdc ); +} + +BOOL APIENTRY +DrvSwapLayerBuffers( + HDC hdc, + UINT fuPlanes ) +{ + debug_printf( "%s\n", __FUNCTION__ ); + + return FALSE; +} + +BOOL APIENTRY +DrvValidateVersion( + ULONG ulVersion ) +{ + debug_printf( "%s( %u )\n", __FUNCTION__, ulVersion ); + + return ulVersion == 1; +} diff --git a/src/mesa/state_tracker/wgl/stw_icd.h b/src/mesa/state_tracker/wgl/stw_icd.h new file mode 100644 index 00000000000..7e2edca16ec --- /dev/null +++ b/src/mesa/state_tracker/wgl/stw_icd.h @@ -0,0 +1,491 @@ +/************************************************************************** + * + * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#ifndef DRV_H +#define DRV_H + + +#include <windows.h> + + +#include "GL/gl.h" +#include "GL/mesa_wgl.h" + + +typedef ULONG DHGLRC; + +#define OPENGL_VERSION_110_ENTRIES 336 + +struct __GLdispatchTableRec +{ + void (GLAPIENTRY * NewList)(GLuint, GLenum); + void (GLAPIENTRY * EndList)(void); + void (GLAPIENTRY * CallList)(GLuint); + void (GLAPIENTRY * CallLists)(GLsizei, GLenum, const GLvoid *); + void (GLAPIENTRY * DeleteLists)(GLuint, GLsizei); + GLuint (GLAPIENTRY * GenLists)(GLsizei); + void (GLAPIENTRY * ListBase)(GLuint); + void (GLAPIENTRY * Begin)(GLenum); + void (GLAPIENTRY * Bitmap)(GLsizei, GLsizei, GLfloat, GLfloat, GLfloat, GLfloat, const GLubyte *); + void (GLAPIENTRY * Color3b)(GLbyte, GLbyte, GLbyte); + void (GLAPIENTRY * Color3bv)(const GLbyte *); + void (GLAPIENTRY * Color3d)(GLdouble, GLdouble, GLdouble); + void (GLAPIENTRY * Color3dv)(const GLdouble *); + void (GLAPIENTRY * Color3f)(GLfloat, GLfloat, GLfloat); + void (GLAPIENTRY * Color3fv)(const GLfloat *); + void (GLAPIENTRY * Color3i)(GLint, GLint, GLint); + void (GLAPIENTRY * Color3iv)(const GLint *); + void (GLAPIENTRY * Color3s)(GLshort, GLshort, GLshort); + void (GLAPIENTRY * Color3sv)(const GLshort *); + void (GLAPIENTRY * Color3ub)(GLubyte, GLubyte, GLubyte); + void (GLAPIENTRY * Color3ubv)(const GLubyte *); + void (GLAPIENTRY * Color3ui)(GLuint, GLuint, GLuint); + void (GLAPIENTRY * Color3uiv)(const GLuint *); + void (GLAPIENTRY * Color3us)(GLushort, GLushort, GLushort); + void (GLAPIENTRY * Color3usv)(const GLushort *); + void (GLAPIENTRY * Color4b)(GLbyte, GLbyte, GLbyte, GLbyte); + void (GLAPIENTRY * Color4bv)(const GLbyte *); + void (GLAPIENTRY * Color4d)(GLdouble, GLdouble, GLdouble, GLdouble); + void (GLAPIENTRY * Color4dv)(const GLdouble *); + void (GLAPIENTRY * Color4f)(GLfloat, GLfloat, GLfloat, GLfloat); + void (GLAPIENTRY * Color4fv)(const GLfloat *); + void (GLAPIENTRY * Color4i)(GLint, GLint, GLint, GLint); + void (GLAPIENTRY * Color4iv)(const GLint *); + void (GLAPIENTRY * Color4s)(GLshort, GLshort, GLshort, GLshort); + void (GLAPIENTRY * Color4sv)(const GLshort *); + void (GLAPIENTRY * Color4ub)(GLubyte, GLubyte, GLubyte, GLubyte); + void (GLAPIENTRY * Color4ubv)(const GLubyte *); + void (GLAPIENTRY * Color4ui)(GLuint, GLuint, GLuint, GLuint); + void (GLAPIENTRY * Color4uiv)(const GLuint *); + void (GLAPIENTRY * Color4us)(GLushort, GLushort, GLushort, GLushort); + void (GLAPIENTRY * Color4usv)(const GLushort *); + void (GLAPIENTRY * EdgeFlag)(GLboolean); + void (GLAPIENTRY * EdgeFlagv)(const GLboolean *); + void (GLAPIENTRY * End)(void); + void (GLAPIENTRY * Indexd)(GLdouble); + void (GLAPIENTRY * Indexdv)(const GLdouble *); + void (GLAPIENTRY * Indexf)(GLfloat); + void (GLAPIENTRY * Indexfv)(const GLfloat *); + void (GLAPIENTRY * Indexi)(GLint); + void (GLAPIENTRY * Indexiv)(const GLint *); + void (GLAPIENTRY * Indexs)(GLshort); + void (GLAPIENTRY * Indexsv)(const GLshort *); + void (GLAPIENTRY * Normal3b)(GLbyte, GLbyte, GLbyte); + void (GLAPIENTRY * Normal3bv)(const GLbyte *); + void (GLAPIENTRY * Normal3d)(GLdouble, GLdouble, GLdouble); + void (GLAPIENTRY * Normal3dv)(const GLdouble *); + void (GLAPIENTRY * Normal3f)(GLfloat, GLfloat, GLfloat); + void (GLAPIENTRY * Normal3fv)(const GLfloat *); + void (GLAPIENTRY * Normal3i)(GLint, GLint, GLint); + void (GLAPIENTRY * Normal3iv)(const GLint *); + void (GLAPIENTRY * Normal3s)(GLshort, GLshort, GLshort); + void (GLAPIENTRY * Normal3sv)(const GLshort *); + void (GLAPIENTRY * RasterPos2d)(GLdouble, GLdouble); + void (GLAPIENTRY * RasterPos2dv)(const GLdouble *); + void (GLAPIENTRY * RasterPos2f)(GLfloat, GLfloat); + void (GLAPIENTRY * RasterPos2fv)(const GLfloat *); + void (GLAPIENTRY * RasterPos2i)(GLint, GLint); + void (GLAPIENTRY * RasterPos2iv)(const GLint *); + void (GLAPIENTRY * RasterPos2s)(GLshort, GLshort); + void (GLAPIENTRY * RasterPos2sv)(const GLshort *); + void (GLAPIENTRY * RasterPos3d)(GLdouble, GLdouble, GLdouble); + void (GLAPIENTRY * RasterPos3dv)(const GLdouble *); + void (GLAPIENTRY * RasterPos3f)(GLfloat, GLfloat, GLfloat); + void (GLAPIENTRY * RasterPos3fv)(const GLfloat *); + void (GLAPIENTRY * RasterPos3i)(GLint, GLint, GLint); + void (GLAPIENTRY * RasterPos3iv)(const GLint *); + void (GLAPIENTRY * RasterPos3s)(GLshort, GLshort, GLshort); + void (GLAPIENTRY * RasterPos3sv)(const GLshort *); + void (GLAPIENTRY * RasterPos4d)(GLdouble, GLdouble, GLdouble, GLdouble); + void (GLAPIENTRY * RasterPos4dv)(const GLdouble *); + void (GLAPIENTRY * RasterPos4f)(GLfloat, GLfloat, GLfloat, GLfloat); + void (GLAPIENTRY * RasterPos4fv)(const GLfloat *); + void (GLAPIENTRY * RasterPos4i)(GLint, GLint, GLint, GLint); + void (GLAPIENTRY * RasterPos4iv)(const GLint *); + void (GLAPIENTRY * RasterPos4s)(GLshort, GLshort, GLshort, GLshort); + void (GLAPIENTRY * RasterPos4sv)(const GLshort *); + void (GLAPIENTRY * Rectd)(GLdouble, GLdouble, GLdouble, GLdouble); + void (GLAPIENTRY * Rectdv)(const GLdouble *, const GLdouble *); + void (GLAPIENTRY * Rectf)(GLfloat, GLfloat, GLfloat, GLfloat); + void (GLAPIENTRY * Rectfv)(const GLfloat *, const GLfloat *); + void (GLAPIENTRY * Recti)(GLint, GLint, GLint, GLint); + void (GLAPIENTRY * Rectiv)(const GLint *, const GLint *); + void (GLAPIENTRY * Rects)(GLshort, GLshort, GLshort, GLshort); + void (GLAPIENTRY * Rectsv)(const GLshort *, const GLshort *); + void (GLAPIENTRY * TexCoord1d)(GLdouble); + void (GLAPIENTRY * TexCoord1dv)(const GLdouble *); + void (GLAPIENTRY * TexCoord1f)(GLfloat); + void (GLAPIENTRY * TexCoord1fv)(const GLfloat *); + void (GLAPIENTRY * TexCoord1i)(GLint); + void (GLAPIENTRY * TexCoord1iv)(const GLint *); + void (GLAPIENTRY * TexCoord1s)(GLshort); + void (GLAPIENTRY * TexCoord1sv)(const GLshort *); + void (GLAPIENTRY * TexCoord2d)(GLdouble, GLdouble); + void (GLAPIENTRY * TexCoord2dv)(const GLdouble *); + void (GLAPIENTRY * TexCoord2f)(GLfloat, GLfloat); + void (GLAPIENTRY * TexCoord2fv)(const GLfloat *); + void (GLAPIENTRY * TexCoord2i)(GLint, GLint); + void (GLAPIENTRY * TexCoord2iv)(const GLint *); + void (GLAPIENTRY * TexCoord2s)(GLshort, GLshort); + void (GLAPIENTRY * TexCoord2sv)(const GLshort *); + void (GLAPIENTRY * TexCoord3d)(GLdouble, GLdouble, GLdouble); + void (GLAPIENTRY * TexCoord3dv)(const GLdouble *); + void (GLAPIENTRY * TexCoord3f)(GLfloat, GLfloat, GLfloat); + void (GLAPIENTRY * TexCoord3fv)(const GLfloat *); + void (GLAPIENTRY * TexCoord3i)(GLint, GLint, GLint); + void (GLAPIENTRY * TexCoord3iv)(const GLint *); + void (GLAPIENTRY * TexCoord3s)(GLshort, GLshort, GLshort); + void (GLAPIENTRY * TexCoord3sv)(const GLshort *); + void (GLAPIENTRY * TexCoord4d)(GLdouble, GLdouble, GLdouble, GLdouble); + void (GLAPIENTRY * TexCoord4dv)(const GLdouble *); + void (GLAPIENTRY * TexCoord4f)(GLfloat, GLfloat, GLfloat, GLfloat); + void (GLAPIENTRY * TexCoord4fv)(const GLfloat *); + void (GLAPIENTRY * TexCoord4i)(GLint, GLint, GLint, GLint); + void (GLAPIENTRY * TexCoord4iv)(const GLint *); + void (GLAPIENTRY * TexCoord4s)(GLshort, GLshort, GLshort, GLshort); + void (GLAPIENTRY * TexCoord4sv)(const GLshort *); + void (GLAPIENTRY * Vertex2d)(GLdouble, GLdouble); + void (GLAPIENTRY * Vertex2dv)(const GLdouble *); + void (GLAPIENTRY * Vertex2f)(GLfloat, GLfloat); + void (GLAPIENTRY * Vertex2fv)(const GLfloat *); + void (GLAPIENTRY * Vertex2i)(GLint, GLint); + void (GLAPIENTRY * Vertex2iv)(const GLint *); + void (GLAPIENTRY * Vertex2s)(GLshort, GLshort); + void (GLAPIENTRY * Vertex2sv)(const GLshort *); + void (GLAPIENTRY * Vertex3d)(GLdouble, GLdouble, GLdouble); + void (GLAPIENTRY * Vertex3dv)(const GLdouble *); + void (GLAPIENTRY * Vertex3f)(GLfloat, GLfloat, GLfloat); + void (GLAPIENTRY * Vertex3fv)(const GLfloat *); + void (GLAPIENTRY * Vertex3i)(GLint, GLint, GLint); + void (GLAPIENTRY * Vertex3iv)(const GLint *); + void (GLAPIENTRY * Vertex3s)(GLshort, GLshort, GLshort); + void (GLAPIENTRY * Vertex3sv)(const GLshort *); + void (GLAPIENTRY * Vertex4d)(GLdouble, GLdouble, GLdouble, GLdouble); + void (GLAPIENTRY * Vertex4dv)(const GLdouble *); + void (GLAPIENTRY * Vertex4f)(GLfloat, GLfloat, GLfloat, GLfloat); + void (GLAPIENTRY * Vertex4fv)(const GLfloat *); + void (GLAPIENTRY * Vertex4i)(GLint, GLint, GLint, GLint); + void (GLAPIENTRY * Vertex4iv)(const GLint *); + void (GLAPIENTRY * Vertex4s)(GLshort, GLshort, GLshort, GLshort); + void (GLAPIENTRY * Vertex4sv)(const GLshort *); + void (GLAPIENTRY * ClipPlane)(GLenum, const GLdouble *); + void (GLAPIENTRY * ColorMaterial)(GLenum, GLenum); + void (GLAPIENTRY * CullFace)(GLenum); + void (GLAPIENTRY * Fogf)(GLenum, GLfloat); + void (GLAPIENTRY * Fogfv)(GLenum, const GLfloat *); + void (GLAPIENTRY * Fogi)(GLenum, GLint); + void (GLAPIENTRY * Fogiv)(GLenum, const GLint *); + void (GLAPIENTRY * FrontFace)(GLenum); + void (GLAPIENTRY * Hint)(GLenum, GLenum); + void (GLAPIENTRY * Lightf)(GLenum, GLenum, GLfloat); + void (GLAPIENTRY * Lightfv)(GLenum, GLenum, const GLfloat *); + void (GLAPIENTRY * Lighti)(GLenum, GLenum, GLint); + void (GLAPIENTRY * Lightiv)(GLenum, GLenum, const GLint *); + void (GLAPIENTRY * LightModelf)(GLenum, GLfloat); + void (GLAPIENTRY * LightModelfv)(GLenum, const GLfloat *); + void (GLAPIENTRY * LightModeli)(GLenum, GLint); + void (GLAPIENTRY * LightModeliv)(GLenum, const GLint *); + void (GLAPIENTRY * LineStipple)(GLint, GLushort); + void (GLAPIENTRY * LineWidth)(GLfloat); + void (GLAPIENTRY * Materialf)(GLenum, GLenum, GLfloat); + void (GLAPIENTRY * Materialfv)(GLenum, GLenum, const GLfloat *); + void (GLAPIENTRY * Materiali)(GLenum, GLenum, GLint); + void (GLAPIENTRY * Materialiv)(GLenum, GLenum, const GLint *); + void (GLAPIENTRY * PointSize)(GLfloat); + void (GLAPIENTRY * PolygonMode)(GLenum, GLenum); + void (GLAPIENTRY * PolygonStipple)(const GLubyte *); + void (GLAPIENTRY * Scissor)(GLint, GLint, GLsizei, GLsizei); + void (GLAPIENTRY * ShadeModel)(GLenum); + void (GLAPIENTRY * TexParameterf)(GLenum, GLenum, GLfloat); + void (GLAPIENTRY * TexParameterfv)(GLenum, GLenum, const GLfloat *); + void (GLAPIENTRY * TexParameteri)(GLenum, GLenum, GLint); + void (GLAPIENTRY * TexParameteriv)(GLenum, GLenum, const GLint *); + void (GLAPIENTRY * TexImage1D)(GLenum, GLint, GLint, GLsizei, GLint, GLenum, GLenum, const GLvoid *); + void (GLAPIENTRY * TexImage2D)(GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); + void (GLAPIENTRY * TexEnvf)(GLenum, GLenum, GLfloat); + void (GLAPIENTRY * TexEnvfv)(GLenum, GLenum, const GLfloat *); + void (GLAPIENTRY * TexEnvi)(GLenum, GLenum, GLint); + void (GLAPIENTRY * TexEnviv)(GLenum, GLenum, const GLint *); + void (GLAPIENTRY * TexGend)(GLenum, GLenum, GLdouble); + void (GLAPIENTRY * TexGendv)(GLenum, GLenum, const GLdouble *); + void (GLAPIENTRY * TexGenf)(GLenum, GLenum, GLfloat); + void (GLAPIENTRY * TexGenfv)(GLenum, GLenum, const GLfloat *); + void (GLAPIENTRY * TexGeni)(GLenum, GLenum, GLint); + void (GLAPIENTRY * TexGeniv)(GLenum, GLenum, const GLint *); + void (GLAPIENTRY * FeedbackBuffer)(GLsizei, GLenum, GLfloat *); + void (GLAPIENTRY * SelectBuffer)(GLsizei, GLuint *); + GLint (GLAPIENTRY * RenderMode)(GLenum); + void (GLAPIENTRY * InitNames)(void); + void (GLAPIENTRY * LoadName)(GLuint); + void (GLAPIENTRY * PassThrough)(GLfloat); + void (GLAPIENTRY * PopName)(void); + void (GLAPIENTRY * PushName)(GLuint); + void (GLAPIENTRY * DrawBuffer)(GLenum); + void (GLAPIENTRY * Clear)(GLbitfield); + void (GLAPIENTRY * ClearAccum)(GLfloat, GLfloat, GLfloat, GLfloat); + void (GLAPIENTRY * ClearIndex)(GLfloat); + void (GLAPIENTRY * ClearColor)(GLclampf, GLclampf, GLclampf, GLclampf); + void (GLAPIENTRY * ClearStencil)(GLint); + void (GLAPIENTRY * ClearDepth)(GLclampd); + void (GLAPIENTRY * StencilMask)(GLuint); + void (GLAPIENTRY * ColorMask)(GLboolean, GLboolean, GLboolean, GLboolean); + void (GLAPIENTRY * DepthMask)(GLboolean); + void (GLAPIENTRY * IndexMask)(GLuint); + void (GLAPIENTRY * Accum)(GLenum, GLfloat); + void (GLAPIENTRY * Disable)(GLenum); + void (GLAPIENTRY * Enable)(GLenum); + void (GLAPIENTRY * Finish)(void); + void (GLAPIENTRY * Flush)(void); + void (GLAPIENTRY * PopAttrib)(void); + void (GLAPIENTRY * PushAttrib)(GLbitfield); + void (GLAPIENTRY * Map1d)(GLenum, GLdouble, GLdouble, GLint, GLint, const GLdouble *); + void (GLAPIENTRY * Map1f)(GLenum, GLfloat, GLfloat, GLint, GLint, const GLfloat *); + void (GLAPIENTRY * Map2d)(GLenum, GLdouble, GLdouble, GLint, GLint, GLdouble, GLdouble, GLint, GLint, const GLdouble *); + void (GLAPIENTRY * Map2f)(GLenum, GLfloat, GLfloat, GLint, GLint, GLfloat, GLfloat, GLint, GLint, const GLfloat *); + void (GLAPIENTRY * MapGrid1d)(GLint, GLdouble, GLdouble); + void (GLAPIENTRY * MapGrid1f)(GLint, GLfloat, GLfloat); + void (GLAPIENTRY * MapGrid2d)(GLint, GLdouble, GLdouble, GLint, GLdouble, GLdouble); + void (GLAPIENTRY * MapGrid2f)(GLint, GLfloat, GLfloat, GLint, GLfloat, GLfloat); + void (GLAPIENTRY * EvalCoord1d)(GLdouble); + void (GLAPIENTRY * EvalCoord1dv)(const GLdouble *); + void (GLAPIENTRY * EvalCoord1f)(GLfloat); + void (GLAPIENTRY * EvalCoord1fv)(const GLfloat *); + void (GLAPIENTRY * EvalCoord2d)(GLdouble, GLdouble); + void (GLAPIENTRY * EvalCoord2dv)(const GLdouble *); + void (GLAPIENTRY * EvalCoord2f)(GLfloat, GLfloat); + void (GLAPIENTRY * EvalCoord2fv)(const GLfloat *); + void (GLAPIENTRY * EvalMesh1)(GLenum, GLint, GLint); + void (GLAPIENTRY * EvalPoint1)(GLint); + void (GLAPIENTRY * EvalMesh2)(GLenum, GLint, GLint, GLint, GLint); + void (GLAPIENTRY * EvalPoint2)(GLint, GLint); + void (GLAPIENTRY * AlphaFunc)(GLenum, GLclampf); + void (GLAPIENTRY * BlendFunc)(GLenum, GLenum); + void (GLAPIENTRY * LogicOp)(GLenum); + void (GLAPIENTRY * StencilFunc)(GLenum, GLint, GLuint); + void (GLAPIENTRY * StencilOp)(GLenum, GLenum, GLenum); + void (GLAPIENTRY * DepthFunc)(GLenum); + void (GLAPIENTRY * PixelZoom)(GLfloat, GLfloat); + void (GLAPIENTRY * PixelTransferf)(GLenum, GLfloat); + void (GLAPIENTRY * PixelTransferi)(GLenum, GLint); + void (GLAPIENTRY * PixelStoref)(GLenum, GLfloat); + void (GLAPIENTRY * PixelStorei)(GLenum, GLint); + void (GLAPIENTRY * PixelMapfv)(GLenum, GLint, const GLfloat *); + void (GLAPIENTRY * PixelMapuiv)(GLenum, GLint, const GLuint *); + void (GLAPIENTRY * PixelMapusv)(GLenum, GLint, const GLushort *); + void (GLAPIENTRY * ReadBuffer)(GLenum); + void (GLAPIENTRY * CopyPixels)(GLint, GLint, GLsizei, GLsizei, GLenum); + void (GLAPIENTRY * ReadPixels)(GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid *); + void (GLAPIENTRY * DrawPixels)(GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); + void (GLAPIENTRY * GetBooleanv)(GLenum, GLboolean *); + void (GLAPIENTRY * GetClipPlane)(GLenum, GLdouble *); + void (GLAPIENTRY * GetDoublev)(GLenum, GLdouble *); + GLenum (GLAPIENTRY * GetError)(void); + void (GLAPIENTRY * GetFloatv)(GLenum, GLfloat *); + void (GLAPIENTRY * GetIntegerv)(GLenum, GLint *); + void (GLAPIENTRY * GetLightfv)(GLenum, GLenum, GLfloat *); + void (GLAPIENTRY * GetLightiv)(GLenum, GLenum, GLint *); + void (GLAPIENTRY * GetMapdv)(GLenum, GLenum, GLdouble *); + void (GLAPIENTRY * GetMapfv)(GLenum, GLenum, GLfloat *); + void (GLAPIENTRY * GetMapiv)(GLenum, GLenum, GLint *); + void (GLAPIENTRY * GetMaterialfv)(GLenum, GLenum, GLfloat *); + void (GLAPIENTRY * GetMaterialiv)(GLenum, GLenum, GLint *); + void (GLAPIENTRY * GetPixelMapfv)(GLenum, GLfloat *); + void (GLAPIENTRY * GetPixelMapuiv)(GLenum, GLuint *); + void (GLAPIENTRY * GetPixelMapusv)(GLenum, GLushort *); + void (GLAPIENTRY * GetPolygonStipple)(GLubyte *); + const GLubyte * (GLAPIENTRY * GetString)(GLenum); + void (GLAPIENTRY * GetTexEnvfv)(GLenum, GLenum, GLfloat *); + void (GLAPIENTRY * GetTexEnviv)(GLenum, GLenum, GLint *); + void (GLAPIENTRY * GetTexGendv)(GLenum, GLenum, GLdouble *); + void (GLAPIENTRY * GetTexGenfv)(GLenum, GLenum, GLfloat *); + void (GLAPIENTRY * GetTexGeniv)(GLenum, GLenum, GLint *); + void (GLAPIENTRY * GetTexImage)(GLenum, GLint, GLenum, GLenum, GLvoid *); + void (GLAPIENTRY * GetTexParameterfv)(GLenum, GLenum, GLfloat *); + void (GLAPIENTRY * GetTexParameteriv)(GLenum, GLenum, GLint *); + void (GLAPIENTRY * GetTexLevelParameterfv)(GLenum, GLint, GLenum, GLfloat *); + void (GLAPIENTRY * GetTexLevelParameteriv)(GLenum, GLint, GLenum, GLint *); + GLboolean (GLAPIENTRY * IsEnabled)(GLenum); + GLboolean (GLAPIENTRY * IsList)(GLuint); + void (GLAPIENTRY * DepthRange)(GLclampd, GLclampd); + void (GLAPIENTRY * Frustum)(GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble); + void (GLAPIENTRY * LoadIdentity)(void); + void (GLAPIENTRY * LoadMatrixf)(const GLfloat *); + void (GLAPIENTRY * LoadMatrixd)(const GLdouble *); + void (GLAPIENTRY * MatrixMode)(GLenum); + void (GLAPIENTRY * MultMatrixf)(const GLfloat *); + void (GLAPIENTRY * MultMatrixd)(const GLdouble *); + void (GLAPIENTRY * Ortho)(GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble); + void (GLAPIENTRY * PopMatrix)(void); + void (GLAPIENTRY * PushMatrix)(void); + void (GLAPIENTRY * Rotated)(GLdouble, GLdouble, GLdouble, GLdouble); + void (GLAPIENTRY * Rotatef)(GLfloat, GLfloat, GLfloat, GLfloat); + void (GLAPIENTRY * Scaled)(GLdouble, GLdouble, GLdouble); + void (GLAPIENTRY * Scalef)(GLfloat, GLfloat, GLfloat); + void (GLAPIENTRY * Translated)(GLdouble, GLdouble, GLdouble); + void (GLAPIENTRY * Translatef)(GLfloat, GLfloat, GLfloat); + void (GLAPIENTRY * Viewport)(GLint, GLint, GLsizei, GLsizei); + void (GLAPIENTRY * ArrayElement)(GLint); + void (GLAPIENTRY * BindTexture)(GLenum, GLuint); + void (GLAPIENTRY * ColorPointer)(GLint, GLenum, GLsizei, const GLvoid *); + void (GLAPIENTRY * DisableClientState)(GLenum); + void (GLAPIENTRY * DrawArrays)(GLenum, GLint, GLsizei); + void (GLAPIENTRY * DrawElements)(GLenum, GLsizei, GLenum, const GLvoid *); + void (GLAPIENTRY * EdgeFlagPointer)(GLsizei, const GLvoid *); + void (GLAPIENTRY * EnableClientState)(GLenum); + void (GLAPIENTRY * IndexPointer)(GLenum, GLsizei, const GLvoid *); + void (GLAPIENTRY * Indexub)(GLubyte); + void (GLAPIENTRY * Indexubv)(const GLubyte *); + void (GLAPIENTRY * InterleavedArrays)(GLenum, GLsizei, const GLvoid *); + void (GLAPIENTRY * NormalPointer)(GLenum, GLsizei, const GLvoid *); + void (GLAPIENTRY * PolygonOffset)(GLfloat, GLfloat); + void (GLAPIENTRY * TexCoordPointer)(GLint, GLenum, GLsizei, const GLvoid *); + void (GLAPIENTRY * VertexPointer)(GLint, GLenum, GLsizei, const GLvoid *); + GLboolean (GLAPIENTRY * AreTexturesResident)(GLsizei, const GLuint *, GLboolean *); + void (GLAPIENTRY * CopyTexImage1D)(GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLint); + void (GLAPIENTRY * CopyTexImage2D)(GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint); + void (GLAPIENTRY * CopyTexSubImage1D)(GLenum, GLint, GLint, GLint, GLint, GLsizei); + void (GLAPIENTRY * CopyTexSubImage2D)(GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); + void (GLAPIENTRY * DeleteTextures)(GLsizei, const GLuint *); + void (GLAPIENTRY * GenTextures)(GLsizei, GLuint *); + void (GLAPIENTRY * GetPointerv)(GLenum, GLvoid **); + GLboolean (GLAPIENTRY * IsTexture)(GLuint); + void (GLAPIENTRY * PrioritizeTextures)(GLsizei, const GLuint *, const GLclampf *); + void (GLAPIENTRY * TexSubImage1D)(GLenum, GLint, GLint, GLsizei, GLenum, GLenum, const GLvoid *); + void (GLAPIENTRY * TexSubImage2D)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); + void (GLAPIENTRY * PopClientAttrib)(void); + void (GLAPIENTRY * PushClientAttrib)(GLbitfield); +}; + +typedef struct __GLdispatchTableRec GLDISPATCHTABLE; + +typedef struct _GLCLTPROCTABLE +{ + int cEntries; + GLDISPATCHTABLE glDispatchTable; +} GLCLTPROCTABLE, * PGLCLTPROCTABLE; + +typedef VOID (APIENTRY * PFN_SETPROCTABLE)(PGLCLTPROCTABLE); + +BOOL APIENTRY +DrvCopyContext( + DHGLRC dhrcSource, + DHGLRC dhrcDest, + UINT fuMask ); + +DHGLRC APIENTRY +DrvCreateLayerContext( + HDC hdc, + INT iLayerPlane ); + +DHGLRC APIENTRY +DrvCreateContext( + HDC hdc ); + +BOOL APIENTRY +DrvDeleteContext( + DHGLRC dhglrc ); + +BOOL APIENTRY +DrvDescribeLayerPlane( + HDC hdc, + INT iPixelFormat, + INT iLayerPlane, + UINT nBytes, + LPLAYERPLANEDESCRIPTOR plpd ); + +LONG APIENTRY +DrvDescribePixelFormat( + HDC hdc, + INT iPixelFormat, + ULONG cjpfd, + PIXELFORMATDESCRIPTOR *ppfd ); + +int APIENTRY +DrvGetLayerPaletteEntries( + HDC hdc, + INT iLayerPlane, + INT iStart, + INT cEntries, + COLORREF *pcr ); + +PROC APIENTRY +DrvGetProcAddress( + LPCSTR lpszProc ); + +BOOL APIENTRY +DrvRealizeLayerPalette( + HDC hdc, + INT iLayerPlane, + BOOL bRealize ); + +BOOL APIENTRY +DrvReleaseContext( + DHGLRC dhglrc ); + +void APIENTRY +DrvSetCallbackProcs( + INT nProcs, + PROC *pProcs ); + +PGLCLTPROCTABLE APIENTRY +DrvSetContext( + HDC hdc, + DHGLRC dhglrc, + PFN_SETPROCTABLE pfnSetProcTable ); + +int APIENTRY +DrvSetLayerPaletteEntries( + HDC hdc, + INT iLayerPlane, + INT iStart, + INT cEntries, + CONST COLORREF *pcr ); + +BOOL APIENTRY +DrvSetPixelFormat( + HDC hdc, + LONG iPixelFormat ); + +BOOL APIENTRY +DrvShareLists( + DHGLRC dhglrc1, + DHGLRC dhglrc2 ); + +BOOL APIENTRY +DrvSwapBuffers( + HDC hdc ); + +BOOL APIENTRY +DrvSwapLayerBuffers( + HDC hdc, + UINT fuPlanes ); + +BOOL APIENTRY +DrvValidateVersion( + ULONG ulVersion ); + +#endif /* DRV_H */ diff --git a/src/mesa/state_tracker/wgl/stw_pixelformat.c b/src/mesa/state_tracker/wgl/stw_pixelformat.c new file mode 100644 index 00000000000..7a054af3d3e --- /dev/null +++ b/src/mesa/state_tracker/wgl/stw_pixelformat.c @@ -0,0 +1,120 @@ +/************************************************************************** + * + * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#include "pipe/p_debug.h" +#include "stw_pixelformat.h" + +#define MAX_PIXELFORMATS 16 + +static struct pixelformat_info pixelformats[MAX_PIXELFORMATS]; +static uint pixelformat_count = 0; +static uint pixelformat_extended_count = 0; + +static void +add_standard_pixelformats( + struct pixelformat_info **ppf, + uint flags ) +{ + struct pixelformat_info *pf = *ppf; + struct pixelformat_color_info color24 = { 8, 0, 8, 8, 8, 16 }; + struct pixelformat_alpha_info alpha8 = { 8, 24 }; + struct pixelformat_alpha_info noalpha = { 0, 0 }; + struct pixelformat_depth_info depth24s8 = { 24, 8 }; + struct pixelformat_depth_info depth16 = { 16, 0 }; + + pf->flags = PF_FLAG_DOUBLEBUFFER | flags; + pf->color = color24; + pf->alpha = alpha8; + pf->depth = depth16; + pf++; + + pf->flags = PF_FLAG_DOUBLEBUFFER | flags; + pf->color = color24; + pf->alpha = alpha8; + pf->depth = depth24s8; + pf++; + + pf->flags = PF_FLAG_DOUBLEBUFFER | flags; + pf->color = color24; + pf->alpha = noalpha; + pf->depth = depth16; + pf++; + + pf->flags = PF_FLAG_DOUBLEBUFFER | flags; + pf->color = color24; + pf->alpha = noalpha; + pf->depth = depth24s8; + pf++; + + pf->flags = flags; + pf->color = color24; + pf->alpha = noalpha; + pf->depth = depth16; + pf++; + + pf->flags = flags; + pf->color = color24; + pf->alpha = noalpha; + pf->depth = depth24s8; + pf++; + + *ppf = pf; +} + +void +pixelformat_init( void ) +{ + struct pixelformat_info *pf = pixelformats; + + add_standard_pixelformats( &pf, 0 ); + pixelformat_count = pf - pixelformats; + + add_standard_pixelformats( &pf, PF_FLAG_MULTISAMPLED ); + pixelformat_extended_count = pf - pixelformats; + + assert( pixelformat_extended_count <= MAX_PIXELFORMATS ); +} + +uint +pixelformat_get_count( void ) +{ + return pixelformat_count; +} + +uint +pixelformat_get_extended_count( void ) +{ + return pixelformat_extended_count; +} + +const struct pixelformat_info * +pixelformat_get_info( uint index ) +{ + assert( index < pixelformat_extended_count ); + + return &pixelformats[index]; +} diff --git a/src/mesa/state_tracker/wgl/stw_pixelformat.h b/src/mesa/state_tracker/wgl/stw_pixelformat.h new file mode 100644 index 00000000000..0b67da8d25c --- /dev/null +++ b/src/mesa/state_tracker/wgl/stw_pixelformat.h @@ -0,0 +1,76 @@ +/************************************************************************** + * + * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#ifndef PIXELFORMAT_H +#define PIXELFORMAT_H + +#define PF_FLAG_DOUBLEBUFFER 0x00000001 +#define PF_FLAG_MULTISAMPLED 0x00000002 + +struct pixelformat_color_info +{ + uint redbits; + uint redshift; + uint greenbits; + uint greenshift; + uint bluebits; + uint blueshift; +}; + +struct pixelformat_alpha_info +{ + uint alphabits; + uint alphashift; +}; + +struct pixelformat_depth_info +{ + uint depthbits; + uint stencilbits; +}; + +struct pixelformat_info +{ + uint flags; + struct pixelformat_color_info color; + struct pixelformat_alpha_info alpha; + struct pixelformat_depth_info depth; +}; + +void +pixelformat_init( void ); + +uint +pixelformat_get_count( void ); + +uint +pixelformat_get_extended_count( void ); + +const struct pixelformat_info * +pixelformat_get_info( uint index ); + +#endif /* PIXELFORMAT_H */ diff --git a/src/mesa/state_tracker/wgl/stw_quirks.c b/src/mesa/state_tracker/wgl/stw_quirks.c new file mode 100644 index 00000000000..bf1ec3fee76 --- /dev/null +++ b/src/mesa/state_tracker/wgl/stw_quirks.c @@ -0,0 +1,108 @@ +/************************************************************************** + * + * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +/** + * @file + * + * This is hopefully a temporary hack to define some needed dispatch + * table entries. Hopefully, I'll find a better solution. The + * dispatch table generation scripts ought to be making these dummy + * stubs as well. + */ + +void gl_dispatch_stub_543(void){} +void gl_dispatch_stub_544(void){} +void gl_dispatch_stub_545(void){} +void gl_dispatch_stub_546(void){} +void gl_dispatch_stub_547(void){} +void gl_dispatch_stub_548(void){} +void gl_dispatch_stub_549(void){} +void gl_dispatch_stub_550(void){} +void gl_dispatch_stub_551(void){} +void gl_dispatch_stub_552(void){} +void gl_dispatch_stub_553(void){} +void gl_dispatch_stub_554(void){} +void gl_dispatch_stub_555(void){} +void gl_dispatch_stub_556(void){} +void gl_dispatch_stub_557(void){} +void gl_dispatch_stub_558(void){} +void gl_dispatch_stub_559(void){} +void gl_dispatch_stub_560(void){} +void gl_dispatch_stub_561(void){} +void gl_dispatch_stub_565(void){} +void gl_dispatch_stub_566(void){} +void gl_dispatch_stub_577(void){} +void gl_dispatch_stub_578(void){} +void gl_dispatch_stub_603(void){} +void gl_dispatch_stub_645(void){} +void gl_dispatch_stub_646(void){} +void gl_dispatch_stub_647(void){} +void gl_dispatch_stub_648(void){} +void gl_dispatch_stub_649(void){} +void gl_dispatch_stub_650(void){} +void gl_dispatch_stub_651(void){} +void gl_dispatch_stub_652(void){} +void gl_dispatch_stub_653(void){} +void gl_dispatch_stub_733(void){} +void gl_dispatch_stub_734(void){} +void gl_dispatch_stub_735(void){} +void gl_dispatch_stub_736(void){} +void gl_dispatch_stub_737(void){} +void gl_dispatch_stub_738(void){} +void gl_dispatch_stub_744(void){} +void gl_dispatch_stub_745(void){} +void gl_dispatch_stub_746(void){} +void gl_dispatch_stub_760(void){} +void gl_dispatch_stub_761(void){} +void gl_dispatch_stub_763(void){} +void gl_dispatch_stub_765(void){} +void gl_dispatch_stub_766(void){} +void gl_dispatch_stub_767(void){} +void gl_dispatch_stub_768(void){} + +void gl_dispatch_stub_562(void){} +void gl_dispatch_stub_563(void){} +void gl_dispatch_stub_564(void){} +void gl_dispatch_stub_567(void){} +void gl_dispatch_stub_568(void){} +void gl_dispatch_stub_569(void){} +void gl_dispatch_stub_580(void){} +void gl_dispatch_stub_581(void){} +void gl_dispatch_stub_606(void){} +void gl_dispatch_stub_654(void){} +void gl_dispatch_stub_655(void){} +void gl_dispatch_stub_656(void){} +void gl_dispatch_stub_739(void){} +void gl_dispatch_stub_740(void){} +void gl_dispatch_stub_741(void){} +void gl_dispatch_stub_748(void){} +void gl_dispatch_stub_749(void){} +void gl_dispatch_stub_769(void){} +void gl_dispatch_stub_770(void){} +void gl_dispatch_stub_771(void){} +void gl_dispatch_stub_772(void){} +void gl_dispatch_stub_773(void){} diff --git a/src/mesa/state_tracker/wgl/stw_wgl.c b/src/mesa/state_tracker/wgl/stw_wgl.c new file mode 100644 index 00000000000..6cace957458 --- /dev/null +++ b/src/mesa/state_tracker/wgl/stw_wgl.c @@ -0,0 +1,201 @@ +/************************************************************************** + * + * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#define _GDI32_ + +#include <windows.h> + +#include "pipe/p_debug.h" + +WINGDIAPI BOOL APIENTRY +wglUseFontBitmapsA( + HDC hdc, + DWORD first, + DWORD count, + DWORD listBase ) +{ + (void) hdc; + (void) first; + (void) count; + (void) listBase; + + assert( 0 ); + + return FALSE; +} + +WINGDIAPI BOOL APIENTRY +wglShareLists( + HGLRC hglrc1, + HGLRC hglrc2 ) +{ + (void) hglrc1; + (void) hglrc2; + + assert( 0 ); + + return FALSE; +} + +WINGDIAPI BOOL APIENTRY +wglUseFontBitmapsW( + HDC hdc, + DWORD first, + DWORD count, + DWORD listBase ) +{ + (void) hdc; + (void) first; + (void) count; + (void) listBase; + + assert( 0 ); + + return FALSE; +} + +WINGDIAPI BOOL APIENTRY +wglUseFontOutlinesA( + HDC hdc, + DWORD first, + DWORD count, + DWORD listBase, + FLOAT deviation, + FLOAT extrusion, + int format, + LPGLYPHMETRICSFLOAT lpgmf ) +{ + (void) hdc; + (void) first; + (void) count; + (void) listBase; + (void) deviation; + (void) extrusion; + (void) format; + (void) lpgmf; + + assert( 0 ); + + return FALSE; +} + +WINGDIAPI BOOL APIENTRY +wglUseFontOutlinesW( + HDC hdc, + DWORD first, + DWORD count, + DWORD listBase, + FLOAT deviation, + FLOAT extrusion, + int format, + LPGLYPHMETRICSFLOAT lpgmf ) +{ + (void) hdc; + (void) first; + (void) count; + (void) listBase; + (void) deviation; + (void) extrusion; + (void) format; + (void) lpgmf; + + assert( 0 ); + + return FALSE; +} + +WINGDIAPI BOOL APIENTRY +wglDescribeLayerPlane( + HDC hdc, + int iPixelFormat, + int iLayerPlane, + UINT nBytes, + LPLAYERPLANEDESCRIPTOR plpd ) +{ + (void) hdc; + (void) iPixelFormat; + (void) iLayerPlane; + (void) nBytes; + (void) plpd; + + assert( 0 ); + + return FALSE; +} + +WINGDIAPI int APIENTRY +wglSetLayerPaletteEntries( + HDC hdc, + int iLayerPlane, + int iStart, + int cEntries, + CONST COLORREF *pcr ) +{ + (void) hdc; + (void) iLayerPlane; + (void) iStart; + (void) cEntries; + (void) pcr; + + assert( 0 ); + + return 0; +} + +WINGDIAPI int APIENTRY +wglGetLayerPaletteEntries( + HDC hdc, + int iLayerPlane, + int iStart, + int cEntries, + COLORREF *pcr ) +{ + (void) hdc; + (void) iLayerPlane; + (void) iStart; + (void) cEntries; + (void) pcr; + + assert( 0 ); + + return 0; +} + +WINGDIAPI BOOL APIENTRY +wglRealizeLayerPalette( + HDC hdc, + int iLayerPlane, + BOOL bRealize ) +{ + (void) hdc; + (void) iLayerPlane; + (void) bRealize; + + assert( 0 ); + + return FALSE; +} diff --git a/src/mesa/state_tracker/wgl/stw_wgl_arbextensionsstring.c b/src/mesa/state_tracker/wgl/stw_wgl_arbextensionsstring.c new file mode 100644 index 00000000000..fe3a3c1daa9 --- /dev/null +++ b/src/mesa/state_tracker/wgl/stw_wgl_arbextensionsstring.c @@ -0,0 +1,43 @@ +/************************************************************************** + * + * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#define _GDI32_ + +#include <windows.h> +#include "stw_wgl_arbextensionsstring.h" + +WINGDIAPI const char * APIENTRY +wglGetExtensionsStringARB( + HDC hdc ) +{ + (void) hdc; + + return + "WGL_ARB_extensions_string " + "WGL_ARB_multisample " + "WGL_ARB_pixel_format"; +} diff --git a/src/mesa/state_tracker/wgl/stw_wgl_arbextensionsstring.h b/src/mesa/state_tracker/wgl/stw_wgl_arbextensionsstring.h new file mode 100644 index 00000000000..a0e4c5d98e8 --- /dev/null +++ b/src/mesa/state_tracker/wgl/stw_wgl_arbextensionsstring.h @@ -0,0 +1,35 @@ +/************************************************************************** + * + * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#ifndef WGL_ARBEXTENSIONSSTRING_H +#define WGL_ARBEXTENSIONSSTRING_H + +WINGDIAPI const char * APIENTRY +wglGetExtensionsStringARB( + HDC hdc ); + +#endif /* WGL_ARBEXTENSIONSSTRING_H */ diff --git a/src/mesa/state_tracker/wgl/stw_wgl_arbmultisample.c b/src/mesa/state_tracker/wgl/stw_wgl_arbmultisample.c new file mode 100644 index 00000000000..aad04e3e8a2 --- /dev/null +++ b/src/mesa/state_tracker/wgl/stw_wgl_arbmultisample.c @@ -0,0 +1,41 @@ +/************************************************************************** + * + * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#include <windows.h> +#include "stw_wgl_arbmultisample.h" + +int +wgl_query_sample_buffers( void ) +{ + return 1; +} + +int +wgl_query_samples( void ) +{ + return 4; +} diff --git a/src/mesa/state_tracker/wgl/stw_wgl_arbmultisample.h b/src/mesa/state_tracker/wgl/stw_wgl_arbmultisample.h new file mode 100644 index 00000000000..de3e2cc6a33 --- /dev/null +++ b/src/mesa/state_tracker/wgl/stw_wgl_arbmultisample.h @@ -0,0 +1,40 @@ +/************************************************************************** + * + * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#ifndef WGL_ARBMULTISAMPLE_H +#define WGL_ARBMULTISAMPLE_H + +#define WGL_SAMPLE_BUFFERS_ARB 0x2041 +#define WGL_SAMPLES_ARB 0x2042 + +int +wgl_query_sample_buffers( void ); + +int +wgl_query_samples( void ); + +#endif /* WGL_ARBMULTISAMPLE_H */ diff --git a/src/mesa/state_tracker/wgl/stw_wgl_arbpixelformat.c b/src/mesa/state_tracker/wgl/stw_wgl_arbpixelformat.c new file mode 100644 index 00000000000..14a7c5e1e06 --- /dev/null +++ b/src/mesa/state_tracker/wgl/stw_wgl_arbpixelformat.c @@ -0,0 +1,515 @@ +/************************************************************************** + * + * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#define _GDI32_ + +#include <windows.h> + +#include "pipe/p_compiler.h" +#include "util/u_memory.h" +#include "stw_pixelformat.h" +#include "stw_wgl_arbmultisample.h" +#include "stw_wgl_arbpixelformat.h" + +#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000 +#define WGL_DRAW_TO_WINDOW_ARB 0x2001 +#define WGL_DRAW_TO_BITMAP_ARB 0x2002 +#define WGL_ACCELERATION_ARB 0x2003 +#define WGL_NEED_PALETTE_ARB 0x2004 +#define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005 +#define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006 +#define WGL_SWAP_METHOD_ARB 0x2007 +#define WGL_NUMBER_OVERLAYS_ARB 0x2008 +#define WGL_NUMBER_UNDERLAYS_ARB 0x2009 +#define WGL_TRANSPARENT_ARB 0x200A +#define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037 +#define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038 +#define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039 +#define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A +#define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B +#define WGL_SHARE_DEPTH_ARB 0x200C +#define WGL_SHARE_STENCIL_ARB 0x200D +#define WGL_SHARE_ACCUM_ARB 0x200E +#define WGL_SUPPORT_GDI_ARB 0x200F +#define WGL_SUPPORT_OPENGL_ARB 0x2010 +#define WGL_DOUBLE_BUFFER_ARB 0x2011 +#define WGL_STEREO_ARB 0x2012 +#define WGL_PIXEL_TYPE_ARB 0x2013 +#define WGL_COLOR_BITS_ARB 0x2014 +#define WGL_RED_BITS_ARB 0x2015 +#define WGL_RED_SHIFT_ARB 0x2016 +#define WGL_GREEN_BITS_ARB 0x2017 +#define WGL_GREEN_SHIFT_ARB 0x2018 +#define WGL_BLUE_BITS_ARB 0x2019 +#define WGL_BLUE_SHIFT_ARB 0x201A +#define WGL_ALPHA_BITS_ARB 0x201B +#define WGL_ALPHA_SHIFT_ARB 0x201C +#define WGL_ACCUM_BITS_ARB 0x201D +#define WGL_ACCUM_RED_BITS_ARB 0x201E +#define WGL_ACCUM_GREEN_BITS_ARB 0x201F +#define WGL_ACCUM_BLUE_BITS_ARB 0x2020 +#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021 +#define WGL_DEPTH_BITS_ARB 0x2022 +#define WGL_STENCIL_BITS_ARB 0x2023 +#define WGL_AUX_BUFFERS_ARB 0x2024 + +#define WGL_NO_ACCELERATION_ARB 0x2025 +#define WGL_GENERIC_ACCELERATION_ARB 0x2026 +#define WGL_FULL_ACCELERATION_ARB 0x2027 + +#define WGL_SWAP_EXCHANGE_ARB 0x2028 +#define WGL_SWAP_COPY_ARB 0x2029 +#define WGL_SWAP_UNDEFINED_ARB 0x202A + +#define WGL_TYPE_RGBA_ARB 0x202B +#define WGL_TYPE_COLORINDEX_ARB 0x202C + +static boolean +query_attrib( + int iPixelFormat, + int iLayerPlane, + int attrib, + int *pvalue ) +{ + uint count; + uint index; + const struct pixelformat_info *pf; + + count = pixelformat_get_extended_count(); + + if (attrib == WGL_NUMBER_PIXEL_FORMATS_ARB) { + *pvalue = (int) count; + return TRUE; + } + + index = (uint) iPixelFormat - 1; + if (index >= count) + return FALSE; + + pf = pixelformat_get_info( index ); + + switch (attrib) { + case WGL_DRAW_TO_WINDOW_ARB: + *pvalue = TRUE; + return TRUE; + + case WGL_DRAW_TO_BITMAP_ARB: + *pvalue = FALSE; + return TRUE; + + case WGL_NEED_PALETTE_ARB: + *pvalue = FALSE; + return TRUE; + + case WGL_NEED_SYSTEM_PALETTE_ARB: + *pvalue = FALSE; + return TRUE; + + case WGL_SWAP_METHOD_ARB: + if (pf->flags & PF_FLAG_DOUBLEBUFFER) + *pvalue = WGL_SWAP_COPY_ARB; + else + *pvalue = WGL_SWAP_UNDEFINED_ARB; + return TRUE; + + case WGL_SWAP_LAYER_BUFFERS_ARB: + *pvalue = FALSE; + return TRUE; + + case WGL_NUMBER_OVERLAYS_ARB: + *pvalue = 0; + return TRUE; + + case WGL_NUMBER_UNDERLAYS_ARB: + *pvalue = 0; + return TRUE; + } + + if (iLayerPlane != 0) + return FALSE; + + switch (attrib) { + case WGL_ACCELERATION_ARB: + *pvalue = WGL_FULL_ACCELERATION_ARB; + break; + + case WGL_TRANSPARENT_ARB: + *pvalue = FALSE; + break; + + case WGL_TRANSPARENT_RED_VALUE_ARB: + case WGL_TRANSPARENT_GREEN_VALUE_ARB: + case WGL_TRANSPARENT_BLUE_VALUE_ARB: + case WGL_TRANSPARENT_ALPHA_VALUE_ARB: + case WGL_TRANSPARENT_INDEX_VALUE_ARB: + break; + + case WGL_SHARE_DEPTH_ARB: + case WGL_SHARE_STENCIL_ARB: + case WGL_SHARE_ACCUM_ARB: + *pvalue = TRUE; + break; + + case WGL_SUPPORT_GDI_ARB: + *pvalue = FALSE; + break; + + case WGL_SUPPORT_OPENGL_ARB: + *pvalue = TRUE; + break; + + case WGL_DOUBLE_BUFFER_ARB: + if (pf->flags & PF_FLAG_DOUBLEBUFFER) + *pvalue = TRUE; + else + *pvalue = FALSE; + break; + + case WGL_STEREO_ARB: + *pvalue = FALSE; + break; + + case WGL_PIXEL_TYPE_ARB: + *pvalue = WGL_TYPE_RGBA_ARB; + break; + + case WGL_COLOR_BITS_ARB: + *pvalue = (int) (pf->color.redbits + pf->color.greenbits + pf->color.bluebits); + break; + + case WGL_RED_BITS_ARB: + *pvalue = (int) pf->color.redbits; + break; + + case WGL_RED_SHIFT_ARB: + *pvalue = (int) pf->color.redshift; + break; + + case WGL_GREEN_BITS_ARB: + *pvalue = (int) pf->color.greenbits; + break; + + case WGL_GREEN_SHIFT_ARB: + *pvalue = (int) pf->color.greenshift; + break; + + case WGL_BLUE_BITS_ARB: + *pvalue = (int) pf->color.bluebits; + break; + + case WGL_BLUE_SHIFT_ARB: + *pvalue = (int) pf->color.blueshift; + break; + + case WGL_ALPHA_BITS_ARB: + *pvalue = (int) pf->alpha.alphabits; + break; + + case WGL_ALPHA_SHIFT_ARB: + *pvalue = (int) pf->alpha.alphashift; + break; + + case WGL_ACCUM_BITS_ARB: + case WGL_ACCUM_RED_BITS_ARB: + case WGL_ACCUM_GREEN_BITS_ARB: + case WGL_ACCUM_BLUE_BITS_ARB: + case WGL_ACCUM_ALPHA_BITS_ARB: + *pvalue = 0; + break; + + case WGL_DEPTH_BITS_ARB: + *pvalue = (int) pf->depth.depthbits; + break; + + case WGL_STENCIL_BITS_ARB: + *pvalue = (int) pf->depth.stencilbits; + break; + + case WGL_AUX_BUFFERS_ARB: + *pvalue = 0; + break; + + case WGL_SAMPLE_BUFFERS_ARB: + if (pf->flags & PF_FLAG_MULTISAMPLED) + *pvalue = wgl_query_sample_buffers(); + else + *pvalue = 0; + break; + + case WGL_SAMPLES_ARB: + if (pf->flags & PF_FLAG_MULTISAMPLED) + *pvalue = wgl_query_samples(); + else + *pvalue = 0; + break; + + default: + return FALSE; + } + + return TRUE; +} + +struct attrib_match_info +{ + int attribute; + int weight; + BOOL exact; +}; + +static struct attrib_match_info attrib_match[] = { + + /* WGL_ARB_pixel_format */ + { WGL_DRAW_TO_WINDOW_ARB, 0, TRUE }, + { WGL_DRAW_TO_BITMAP_ARB, 0, TRUE }, + { WGL_ACCELERATION_ARB, 0, TRUE }, + { WGL_NEED_PALETTE_ARB, 0, TRUE }, + { WGL_NEED_SYSTEM_PALETTE_ARB, 0, TRUE }, + { WGL_SWAP_LAYER_BUFFERS_ARB, 0, TRUE }, + { WGL_SWAP_METHOD_ARB, 0, TRUE }, + { WGL_NUMBER_OVERLAYS_ARB, 4, FALSE }, + { WGL_NUMBER_UNDERLAYS_ARB, 4, FALSE }, + /*{ WGL_SHARE_DEPTH_ARB, 0, TRUE },*/ /* no overlays -- ignore */ + /*{ WGL_SHARE_STENCIL_ARB, 0, TRUE },*/ /* no overlays -- ignore */ + /*{ WGL_SHARE_ACCUM_ARB, 0, TRUE },*/ /* no overlays -- ignore */ + { WGL_SUPPORT_GDI_ARB, 0, TRUE }, + { WGL_SUPPORT_OPENGL_ARB, 0, TRUE }, + { WGL_DOUBLE_BUFFER_ARB, 0, TRUE }, + { WGL_STEREO_ARB, 0, TRUE }, + { WGL_PIXEL_TYPE_ARB, 0, TRUE }, + { WGL_COLOR_BITS_ARB, 1, FALSE }, + { WGL_RED_BITS_ARB, 1, FALSE }, + { WGL_GREEN_BITS_ARB, 1, FALSE }, + { WGL_BLUE_BITS_ARB, 1, FALSE }, + { WGL_ALPHA_BITS_ARB, 1, FALSE }, + { WGL_ACCUM_BITS_ARB, 1, FALSE }, + { WGL_ACCUM_RED_BITS_ARB, 1, FALSE }, + { WGL_ACCUM_GREEN_BITS_ARB, 1, FALSE }, + { WGL_ACCUM_BLUE_BITS_ARB, 1, FALSE }, + { WGL_ACCUM_ALPHA_BITS_ARB, 1, FALSE }, + { WGL_DEPTH_BITS_ARB, 1, FALSE }, + { WGL_STENCIL_BITS_ARB, 1, FALSE }, + { WGL_AUX_BUFFERS_ARB, 2, FALSE }, + + /* WGL_ARB_multisample */ + { WGL_SAMPLE_BUFFERS_ARB, 2, FALSE }, + { WGL_SAMPLES_ARB, 2, FALSE } +}; + +struct pixelformat_score +{ + int points; + uint index; +}; + +static BOOL +score_pixelformats( + struct pixelformat_score *scores, + uint count, + int attribute, + int expected_value ) +{ + uint i; + struct attrib_match_info *ami = NULL; + uint index; + + /* Find out if a given attribute should be considered for score calculation. + */ + for (i = 0; i < sizeof( attrib_match ) / sizeof( attrib_match[0] ); i++) { + if (attrib_match[i].attribute == attribute) { + ami = &attrib_match[i]; + break; + } + } + if (ami == NULL) + return TRUE; + + /* Iterate all pixelformats, query the requested attribute and calculate + * score points. + */ + for (index = 0; index < count; index++) { + int actual_value; + + if (!query_attrib( index + 1, 0, attribute, &actual_value )) + return FALSE; + + if (ami->exact) { + /* For an exact match criteria, if the actual and expected values differ, + * the score is set to 0 points, effectively removing the pixelformat + * from a list of matching pixelformats. + */ + if (actual_value != expected_value) + scores[index].points = 0; + } + else { + /* For a minimum match criteria, if the actual value is smaller than the expected + * value, the pixelformat is rejected (score set to 0). However, if the actual + * value is bigger, the pixelformat is given a penalty to favour pixelformats that + * more closely match the expected values. + */ + if (actual_value < expected_value) + scores[index].points = 0; + else if (actual_value > expected_value) + scores[index].points -= (actual_value - expected_value) * ami->weight; + } + } + + return TRUE; +} + +WINGDIAPI BOOL APIENTRY +wglChoosePixelFormatARB( + HDC hdc, + const int *piAttribIList, + const FLOAT *pfAttribFList, + UINT nMaxFormats, + int *piFormats, + UINT *nNumFormats ) +{ + uint count; + struct pixelformat_score *scores; + uint i; + + *nNumFormats = 0; + + /* Allocate and initialize pixelformat score table -- better matches + * have higher scores. Start with a high score and take out penalty + * points for a mismatch when the match does not have to be exact. + * Set a score to 0 if there is a mismatch for an exact match criteria. + */ + count = pixelformat_get_extended_count(); + scores = (struct pixelformat_score *) MALLOC( count * sizeof( struct pixelformat_score ) ); + if (scores == NULL) + return FALSE; + for (i = 0; i < count; i++) { + scores[i].points = 0x7fffffff; + scores[i].index = i; + } + + /* Given the attribute list calculate a score for each pixelformat. + */ + if (piAttribIList != NULL) { + while (*piAttribIList != 0) { + if (!score_pixelformats( scores, count, piAttribIList[0], piAttribIList[1] )) { + FREE( scores ); + return FALSE; + } + piAttribIList += 2; + } + } + if (pfAttribFList != NULL) { + while (*pfAttribFList != 0) { + if (!score_pixelformats( scores, count, (int) pfAttribFList[0], (int) pfAttribFList[1] )) { + FREE( scores ); + return FALSE; + } + pfAttribFList += 2; + } + } + + /* Bubble-sort the resulting scores. Pixelformats with higher scores go first. + * TODO: Find out if there are any patent issues with it. + */ + if (count > 1) { + uint n = count; + boolean swapped; + + do { + swapped = FALSE; + for (i = 1; i < n; i++) { + if (scores[i - 1].points < scores[i].points) { + struct pixelformat_score score = scores[i - 1]; + + scores[i - 1] = scores[i]; + scores[i] = score; + swapped = TRUE; + } + } + n--; + } + while (swapped); + } + + /* Return a list of pixelformats that are the best match. + * Reject pixelformats with non-positive scores. + */ + for (i = 0; i < count; i++) { + if (scores[i].points > 0) { + if (*nNumFormats < nMaxFormats) + piFormats[*nNumFormats] = scores[i].index + 1; + (*nNumFormats)++; + } + } + + FREE( scores ); + return TRUE; +} + +WINGDIAPI BOOL APIENTRY +wglGetPixelFormatAttribfvARB( + HDC hdc, + int iPixelFormat, + int iLayerPlane, + UINT nAttributes, + const int *piAttributes, + FLOAT *pfValues ) +{ + UINT i; + + (void) hdc; + + for (i = 0; i < nAttributes; i++) { + int value; + + if (!query_attrib( iPixelFormat, iLayerPlane, piAttributes[i], &value )) + return FALSE; + pfValues[i] = (FLOAT) value; + } + + return TRUE; +} + +WINGDIAPI BOOL APIENTRY +wglGetPixelFormatAttribivARB( + HDC hdc, + int iPixelFormat, + int iLayerPlane, + UINT nAttributes, + const int *piAttributes, + int *piValues ) +{ + UINT i; + + (void) hdc; + + for (i = 0; i < nAttributes; i++) { + if (!query_attrib( iPixelFormat, iLayerPlane, piAttributes[i], &piValues[i] )) + return FALSE; + } + + return TRUE; +} diff --git a/src/mesa/state_tracker/wgl/stw_wgl_arbpixelformat.h b/src/mesa/state_tracker/wgl/stw_wgl_arbpixelformat.h new file mode 100644 index 00000000000..5e480b822b3 --- /dev/null +++ b/src/mesa/state_tracker/wgl/stw_wgl_arbpixelformat.h @@ -0,0 +1,58 @@ +/************************************************************************** + * + * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#ifndef WGL_ARBPIXELFORMAT_H +#define WGL_ARBPIXELFORMAT_H + +WINGDIAPI BOOL APIENTRY +wglChoosePixelFormatARB( + HDC hdc, + const int *piAttribIList, + const FLOAT *pfAttribFList, + UINT nMaxFormats, + int *piFormats, + UINT *nNumFormats ); + +WINGDIAPI BOOL APIENTRY +wglGetPixelFormatAttribfvARB( + HDC hdc, + int iPixelFormat, + int iLayerPlane, + UINT nAttributes, + const int *piAttributes, + FLOAT *pfValues ); + +WINGDIAPI BOOL APIENTRY +wglGetPixelFormatAttribivARB( + HDC hdc, + int iPixelFormat, + int iLayerPlane, + UINT nAttributes, + const int *piAttributes, + int *piValues ); + +#endif /* WGL_ARBPIXELFORMAT_H */ diff --git a/src/mesa/state_tracker/wgl/stw_wgl_context.c b/src/mesa/state_tracker/wgl/stw_wgl_context.c new file mode 100644 index 00000000000..59b47200be4 --- /dev/null +++ b/src/mesa/state_tracker/wgl/stw_wgl_context.c @@ -0,0 +1,293 @@ +/************************************************************************** + * + * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#define _GDI32_ + +#include <windows.h> + +#include "main/mtypes.h" +#include "main/context.h" +#include "pipe/p_compiler.h" +#include "pipe/p_context.h" +#include "state_tracker/st_context.h" +#include "state_tracker/st_public.h" +#include "stw_device.h" +#include "stw_winsys.h" +#include "stw_framebuffer.h" +#include "stw_pixelformat.h" +#include "stw_wgl_arbmultisample.h" +#include "stw_wgl_context.h" +#include "stw_wgl_pixelformat.h" + +static struct wgl_context *ctx_head = NULL; + +static HDC current_hdc = NULL; +static HGLRC current_hrc = NULL; + +WINGDIAPI BOOL APIENTRY +wglCopyContext( + HGLRC hglrcSrc, + HGLRC hglrcDst, + UINT mask ) +{ + (void) hglrcSrc; + (void) hglrcDst; + (void) mask; + + return FALSE; +} + +WINGDIAPI HGLRC APIENTRY +wglCreateContext( + HDC hdc ) +{ + uint pfi; + const struct pixelformat_info *pf; + struct wgl_context *ctx; + GLvisual *visual; + struct pipe_context *pipe; + + pfi = wglGetPixelFormat( hdc ); + if (pfi == 0) + return NULL; + + pf = pixelformat_get_info( pfi - 1 ); + + ctx = CALLOC_STRUCT( wgl_context ); + if (ctx == NULL) + return NULL; + + ctx->hdc = hdc; + ctx->color_bits = GetDeviceCaps( ctx->hdc, BITSPIXEL ); + + /* Create visual based on flags + */ + visual = _mesa_create_visual( + GL_TRUE, + (pf->flags & PF_FLAG_DOUBLEBUFFER) ? GL_TRUE : GL_FALSE, + GL_FALSE, + pf->color.redbits, + pf->color.greenbits, + pf->color.bluebits, + pf->alpha.alphabits, + 0, + pf->depth.depthbits, + pf->depth.stencilbits, + 0, + 0, + 0, + 0, + (pf->flags & PF_FLAG_MULTISAMPLED) ? wgl_query_samples() : 0 ); + if (visual == NULL) { + FREE( ctx ); + return NULL; + } + + pipe = stw_winsys.create_context( stw_dev->screen ); + if (!pipe) { + _mesa_destroy_visual( visual ); + FREE( ctx ); + return NULL; + } + + ctx->st = st_create_context( pipe, visual, NULL ); + if (ctx->st == NULL) { + pipe->destroy( pipe ); + _mesa_destroy_visual( visual ); + FREE( ctx ); + return NULL; + } + ctx->st->ctx->DriverCtx = ctx; + + ctx->next = ctx_head; + ctx_head = ctx; + + return (HGLRC) ctx; +} + +WINGDIAPI HGLRC APIENTRY +wglCreateLayerContext( + HDC hdc, + int iLayerPlane ) +{ + (void) hdc; + (void) iLayerPlane; + + return NULL; +} + +WINGDIAPI BOOL APIENTRY +wglDeleteContext( + HGLRC hglrc ) +{ + struct wgl_context **link = &ctx_head; + struct wgl_context *ctx = ctx_head; + + while (ctx != NULL) { + if (ctx == (struct wgl_context *) hglrc) { + GLcontext *glctx = ctx->st->ctx; + GET_CURRENT_CONTEXT( glcurctx ); + struct stw_framebuffer *fb; + + /* Unbind current if deleting current context. + */ + if (glcurctx == glctx) + st_make_current( NULL, NULL, NULL ); + + fb = framebuffer_from_hdc( ctx->hdc ); + if (fb) + framebuffer_destroy( fb ); + + if (WindowFromDC( ctx->hdc ) != NULL) + ReleaseDC( WindowFromDC( ctx->hdc ), ctx->hdc ); + + st_destroy_context( ctx->st ); + + *link = ctx->next; + FREE( ctx ); + return TRUE; + } + + link = &ctx->next; + ctx = ctx->next; + } + + return FALSE; +} + +/* Find the width and height of the window named by hdc. + */ +static void +get_window_size( HDC hdc, GLuint *width, GLuint *height ) +{ + if (WindowFromDC( hdc )) { + RECT rect; + + GetClientRect( WindowFromDC( hdc ), &rect ); + *width = rect.right - rect.left; + *height = rect.bottom - rect.top; + } + else { + *width = GetDeviceCaps( hdc, HORZRES ); + *height = GetDeviceCaps( hdc, VERTRES ); + } +} + +WINGDIAPI HGLRC APIENTRY +wglGetCurrentContext( VOID ) +{ + return current_hrc; +} + +WINGDIAPI HDC APIENTRY +wglGetCurrentDC( VOID ) +{ + return current_hdc; +} + +WINGDIAPI BOOL APIENTRY +wglMakeCurrent( + HDC hdc, + HGLRC hglrc ) +{ + struct wgl_context *ctx = ctx_head; + GET_CURRENT_CONTEXT( glcurctx ); + struct stw_framebuffer *fb; + GLuint width = 0; + GLuint height = 0; + + current_hdc = hdc; + current_hrc = hglrc; + + if (hdc == NULL || hglrc == NULL) { + st_make_current( NULL, NULL, NULL ); + return TRUE; + } + + while (ctx != NULL) { + if (ctx == (struct wgl_context *) hglrc) + break; + ctx = ctx->next; + } + if (ctx == NULL) + return FALSE; + + /* Return if already current. + */ + if (glcurctx != NULL) { + struct wgl_context *curctx = (struct wgl_context *) glcurctx->DriverCtx; + + if (curctx != NULL && curctx == ctx && ctx->hdc == hdc) + return TRUE; + } + + fb = framebuffer_from_hdc( hdc ); + + if (hdc != NULL) + get_window_size( hdc, &width, &height ); + + /* Lazy creation of framebuffers. + */ + if (fb == NULL && ctx != NULL && hdc != NULL) { + GLvisual *visual = &ctx->st->ctx->Visual; + + fb = framebuffer_create( hdc, visual, width, height ); + if (fb == NULL) + return FALSE; + + fb->dib_hDC = CreateCompatibleDC( hdc ); + fb->hbmDIB = NULL; + fb->pbPixels = NULL; + } + + if (ctx && fb) { + st_make_current( ctx->st, fb->stfb, fb->stfb ); + framebuffer_resize( fb, width, height ); + } + else { + /* Detach */ + st_make_current( NULL, NULL, NULL ); + } + + return TRUE; +} + +struct wgl_context * +wgl_context_from_hdc( + HDC hdc ) +{ + struct wgl_context *ctx = ctx_head; + + while (ctx != NULL) { + if (ctx->hdc == hdc) + return ctx; + ctx = ctx->next; + } + return NULL; +} + +#include "stw_wgl.c" diff --git a/src/mesa/state_tracker/wgl/stw_wgl_context.h b/src/mesa/state_tracker/wgl/stw_wgl_context.h new file mode 100644 index 00000000000..d87b3bdce23 --- /dev/null +++ b/src/mesa/state_tracker/wgl/stw_wgl_context.h @@ -0,0 +1,46 @@ +/************************************************************************** + * + * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#ifndef WGL_CONTEXT_H +#define WGL_CONTEXT_H + +#include <windows.h> + +struct st_context; + +struct wgl_context +{ + struct st_context *st; + HDC hdc; + DWORD color_bits; + struct wgl_context *next; +}; + +struct wgl_context * +wgl_context_from_hdc(HDC hdc ); + +#endif /* WGL_CONTEXT_H */ diff --git a/src/mesa/state_tracker/wgl/stw_wgl_getprocaddress.c b/src/mesa/state_tracker/wgl/stw_wgl_getprocaddress.c new file mode 100644 index 00000000000..ec4f1513cb8 --- /dev/null +++ b/src/mesa/state_tracker/wgl/stw_wgl_getprocaddress.c @@ -0,0 +1,71 @@ +/************************************************************************** + * + * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#define _GDI32_ + +#include <windows.h> +#include "glapi/glapi.h" +#include "stw_wgl_arbextensionsstring.h" +#include "stw_wgl_arbpixelformat.h" + +struct extension_entry +{ + const char *name; + PROC proc; +}; + +#define EXTENTRY(P) { #P, (PROC) P } + +static struct extension_entry extension_entries[] = { + + /* WGL_ARB_extensions_string */ + EXTENTRY( wglGetExtensionsStringARB ), + + /* WGL_ARB_pixel_format */ + EXTENTRY( wglChoosePixelFormatARB ), + EXTENTRY( wglGetPixelFormatAttribfvARB ), + EXTENTRY( wglGetPixelFormatAttribivARB ), + + { NULL, NULL } +}; + +WINGDIAPI PROC APIENTRY +wglGetProcAddress( + LPCSTR lpszProc ) +{ + struct extension_entry *entry; + + PROC p = (PROC) _glapi_get_proc_address( (const char *) lpszProc ); + if (p) + return p; + + for (entry = extension_entries; entry->name; entry++) + if (strcmp( lpszProc, entry->name ) == 0) + return entry->proc; + + return NULL; +} diff --git a/src/mesa/state_tracker/wgl/stw_wgl_pixelformat.c b/src/mesa/state_tracker/wgl/stw_wgl_pixelformat.c new file mode 100644 index 00000000000..bfc085093a8 --- /dev/null +++ b/src/mesa/state_tracker/wgl/stw_wgl_pixelformat.c @@ -0,0 +1,189 @@ +/************************************************************************** + * + * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#define _GDI32_ + +#include <windows.h> + +#include "pipe/p_compiler.h" +#include "pipe/p_debug.h" +#include "stw_pixelformat.h" +#include "stw_wgl_pixelformat.h" + +static uint currentpixelformat = 0; + +WINGDIAPI int APIENTRY +wglChoosePixelFormat( + HDC hdc, + CONST PIXELFORMATDESCRIPTOR *ppfd ) +{ + uint count; + uint index; + uint bestindex; + uint bestdelta; + + (void) hdc; + + count = pixelformat_get_count(); + bestindex = count; + bestdelta = 0xffffffff; + + if (ppfd->nSize != sizeof( PIXELFORMATDESCRIPTOR ) || ppfd->nVersion != 1) + return 0; + if (ppfd->iPixelType != PFD_TYPE_RGBA) + return 0; + if (!(ppfd->dwFlags & PFD_DRAW_TO_WINDOW)) + return 0; + if (!(ppfd->dwFlags & PFD_SUPPORT_OPENGL)) + return 0; + if (ppfd->dwFlags & PFD_DRAW_TO_BITMAP) + return 0; + if (ppfd->dwFlags & PFD_SUPPORT_GDI) + return 0; + if (!(ppfd->dwFlags & PFD_STEREO_DONTCARE) && (ppfd->dwFlags & PFD_STEREO)) + return 0; + + for (index = 0; index < count; index++) { + uint delta = 0; + const struct pixelformat_info *pf = pixelformat_get_info( index ); + + if (!(ppfd->dwFlags & PFD_DOUBLEBUFFER_DONTCARE)) { + if ((ppfd->dwFlags & PFD_DOUBLEBUFFER) && !(pf->flags & PF_FLAG_DOUBLEBUFFER)) + continue; + if (!(ppfd->dwFlags & PFD_DOUBLEBUFFER) && (pf->flags & PF_FLAG_DOUBLEBUFFER)) + continue; + } + + if (ppfd->cColorBits != pf->color.redbits + pf->color.greenbits + pf->color.bluebits) + delta += 8; + + if (ppfd->cDepthBits != pf->depth.depthbits) + delta += 4; + + if (ppfd->cStencilBits != pf->depth.stencilbits) + delta += 2; + + if (ppfd->cAlphaBits != pf->alpha.alphabits) + delta++; + + if (delta < bestdelta) { + bestindex = index; + bestdelta = delta; + if (bestdelta == 0) + break; + } + } + + if (bestindex == count) + return 0; + return bestindex + 1; +} + +WINGDIAPI int APIENTRY +wglDescribePixelFormat( + HDC hdc, + int iPixelFormat, + UINT nBytes, + LPPIXELFORMATDESCRIPTOR ppfd ) +{ + uint count; + uint index; + const struct pixelformat_info *pf; + + (void) hdc; + + count = pixelformat_get_extended_count(); + index = (uint) iPixelFormat - 1; + + if (ppfd == NULL) + return count; + if (index >= count || nBytes != sizeof( PIXELFORMATDESCRIPTOR )) + return 0; + + pf = pixelformat_get_info( index ); + + ppfd->nSize = sizeof( PIXELFORMATDESCRIPTOR ); + ppfd->nVersion = 1; + ppfd->dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL; + if (pf->flags & PF_FLAG_DOUBLEBUFFER) + ppfd->dwFlags |= PFD_DOUBLEBUFFER | PFD_SWAP_COPY; + ppfd->iPixelType = PFD_TYPE_RGBA; + ppfd->cColorBits = pf->color.redbits + pf->color.greenbits + pf->color.bluebits; + ppfd->cRedBits = pf->color.redbits; + ppfd->cRedShift = pf->color.redshift; + ppfd->cGreenBits = pf->color.greenbits; + ppfd->cGreenShift = pf->color.greenshift; + ppfd->cBlueBits = pf->color.bluebits; + ppfd->cBlueShift = pf->color.blueshift; + ppfd->cAlphaBits = pf->alpha.alphabits; + ppfd->cAlphaShift = pf->alpha.alphashift; + ppfd->cAccumBits = 0; + ppfd->cAccumRedBits = 0; + ppfd->cAccumGreenBits = 0; + ppfd->cAccumBlueBits = 0; + ppfd->cAccumAlphaBits = 0; + ppfd->cDepthBits = pf->depth.depthbits; + ppfd->cStencilBits = pf->depth.stencilbits; + ppfd->cAuxBuffers = 0; + ppfd->iLayerType = 0; + ppfd->bReserved = 0; + ppfd->dwLayerMask = 0; + ppfd->dwVisibleMask = 0; + ppfd->dwDamageMask = 0; + + return count; +} + +WINGDIAPI int APIENTRY +wglGetPixelFormat( + HDC hdc ) +{ + (void) hdc; + + return currentpixelformat; +} + +WINGDIAPI BOOL APIENTRY +wglSetPixelFormat( + HDC hdc, + int iPixelFormat, + const PIXELFORMATDESCRIPTOR *ppfd ) +{ + uint count; + uint index; + + (void) hdc; + + count = pixelformat_get_extended_count(); + index = (uint) iPixelFormat - 1; + + if (index >= count || ppfd->nSize != sizeof( PIXELFORMATDESCRIPTOR )) + return FALSE; + + currentpixelformat = index + 1; + return TRUE; +} diff --git a/src/mesa/state_tracker/wgl/stw_wgl_pixelformat.h b/src/mesa/state_tracker/wgl/stw_wgl_pixelformat.h new file mode 100644 index 00000000000..ee875c7a1d2 --- /dev/null +++ b/src/mesa/state_tracker/wgl/stw_wgl_pixelformat.h @@ -0,0 +1,35 @@ +/************************************************************************** + * + * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#ifndef WGL_PIXELFORMAT_H +#define WGL_PIXELFORMAT_H + +WINGDIAPI int APIENTRY +wglGetPixelFormat( + HDC hdc ); + +#endif /* WGL_PIXELFORMAT_H */ diff --git a/src/mesa/state_tracker/wgl/stw_wgl_swapbuffers.c b/src/mesa/state_tracker/wgl/stw_wgl_swapbuffers.c new file mode 100644 index 00000000000..a4dffc5fa0e --- /dev/null +++ b/src/mesa/state_tracker/wgl/stw_wgl_swapbuffers.c @@ -0,0 +1,75 @@ +/************************************************************************** + * + * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#define _GDI32_ + +#include <windows.h> +#include "pipe/p_winsys.h" +#include "pipe/p_screen.h" +#include "pipe/p_context.h" +#include "state_tracker/st_context.h" +#include "state_tracker/st_public.h" +#include "stw_winsys.h" +#include "stw_device.h" +#include "stw_framebuffer.h" +#include "stw_wgl_context.h" + +WINGDIAPI BOOL APIENTRY +wglSwapBuffers( + HDC hdc ) +{ + struct stw_framebuffer *fb; + struct pipe_surface *surf; + + fb = framebuffer_from_hdc( hdc ); + if (fb == NULL) + return FALSE; + + /* If we're swapping the buffer associated with the current context + * we have to flush any pending rendering commands first. + */ + st_notify_swapbuffers( fb->stfb ); + + surf = st_get_framebuffer_surface( fb->stfb, ST_SURFACE_BACK_LEFT ); + + stw_winsys.flush_frontbuffer(stw_dev->screen->winsys, + surf, + hdc ); + + return TRUE; +} + +WINGDIAPI BOOL APIENTRY +wglSwapLayerBuffers( + HDC hdc, + UINT fuPlanes ) +{ + (void) hdc; + (void) fuPlanes; + + return FALSE; +} diff --git a/src/mesa/state_tracker/wgl/stw_winsys.h b/src/mesa/state_tracker/wgl/stw_winsys.h new file mode 100644 index 00000000000..68f1c7b16b7 --- /dev/null +++ b/src/mesa/state_tracker/wgl/stw_winsys.h @@ -0,0 +1,53 @@ +/************************************************************************** + * + * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#ifndef STW_WINSYS_H +#define STW_WINSYS_H + +#include <windows.h> /* for HDC */ + +struct pipe_screen; +struct pipe_context; +struct pipe_winsys; + +struct stw_winsys +{ + struct pipe_screen * + (*create_screen)( void ); + + struct pipe_context * + (*create_context)( struct pipe_screen *screen ); + + void + (*flush_frontbuffer)( struct pipe_winsys *winsys, + struct pipe_surface *surf, + HDC hDC ); +}; + +extern const struct stw_winsys stw_winsys; + +#endif /* STW_WINSYS_H */ |