⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 svgamesa.c

📁 Mesa is an open-source implementation of the OpenGL specification - a system for rendering interacti
💻 C
📖 第 1 页 / 共 2 页
字号:
/**********************************************************************//*****                                                            *****//**********************************************************************/static void svgamesa_update_state( GLcontext *ctx, GLuint new_state ){   struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference( ctx );   /* Initialize all the pointers in the DD struct.  Do this whenever */   /* a new context is made current or we change buffers via set_buffer! */   ctx->Driver.UpdateState = svgamesa_update_state;   ctx->Driver.GetBufferSize = get_buffer_size;   ctx->Driver.Viewport = viewport;   /* Fill in the swrast driver interface:    */   swdd->SetBuffer = set_buffer;   switch (SVGABuffer.Depth) {    case  8: ctx->Driver.ClearIndex = __clear_index8;             ctx->Driver.Clear 	    = __clear8;             swdd->ReadCI32Span         = __read_ci32_span8;             swdd->ReadCI32Pixels       = __read_ci32_pixels8;             swdd->WriteCI8Span         = __write_ci8_span8;             swdd->WriteCI32Span        = __write_ci32_span8;             swdd->WriteCI32Pixels      = __write_ci32_pixels8;             swdd->WriteMonoCISpan      = __write_mono_ci_span8;             swdd->WriteMonoCIPixels    = __write_mono_ci_pixels8;#ifdef SVGA_DEBUG    SVGAlog("SVGAUpdateState: 8 bit mode.");#endif	     break;    case 15: ctx->Driver.ClearColor = __clear_color15;             ctx->Driver.Clear 	    = __clear15;             swdd->ReadRGBASpan         = __read_rgba_span15;             swdd->ReadRGBAPixels       = __read_rgba_pixels15;             swdd->WriteRGBASpan        = __write_rgba_span15;             swdd->WriteRGBAPixels      = __write_rgba_pixels15;             swdd->WriteMonoRGBASpan    = __write_mono_rgba_span15;             swdd->WriteMonoRGBAPixels  = __write_mono_rgba_pixels15;#ifdef SVGA_DEBUG    SVGAlog("SVGAUpdateState: 15 bit mode.");#endif	     break;    case 16: ctx->Driver.ClearColor = __clear_color16;             ctx->Driver.Clear 	    = __clear16;             swdd->ReadRGBASpan         = __read_rgba_span16;             swdd->ReadRGBAPixels       = __read_rgba_pixels16;             swdd->WriteRGBASpan        = __write_rgba_span16;             swdd->WriteRGBAPixels      = __write_rgba_pixels16;             swdd->WriteMonoRGBASpan    = __write_mono_rgba_span16;             swdd->WriteMonoRGBAPixels  = __write_mono_rgba_pixels16;	     break;#ifdef SVGA_DEBUG    SVGAlog("SVGAUpdateState: 16 bit mode.");#endif    case 24: ctx->Driver.ClearColor = __clear_color24;             ctx->Driver.Clear 	    = __clear24;             swdd->ReadRGBASpan         = __read_rgba_span24;             swdd->ReadRGBAPixels       = __read_rgba_pixels24;             swdd->WriteRGBASpan        = __write_rgba_span24;             swdd->WriteRGBAPixels      = __write_rgba_pixels24;             swdd->WriteMonoRGBASpan    = __write_mono_rgba_span24;             swdd->WriteMonoRGBAPixels  = __write_mono_rgba_pixels24;	     break;#ifdef SVGA_DEBUG    SVGAlog("SVGAUpdateState: 32 bit mode.");#endif    case 32: ctx->Driver.ClearColor = __clear_color32;             ctx->Driver.Clear 	    = __clear32;             swdd->ReadRGBASpan         = __read_rgba_span32;             swdd->ReadRGBAPixels       = __read_rgba_pixels32;             swdd->WriteRGBASpan        = __write_rgba_span32;             swdd->WriteRGBAPixels      = __write_rgba_pixels32;             swdd->WriteMonoRGBASpan    = __write_mono_rgba_span32;             swdd->WriteMonoRGBAPixels  = __write_mono_rgba_pixels32;   }	}/* * Create a new VGA/Mesa context and return a handle to it. */SVGAMesaContext SVGAMesaCreateContext( GLboolean doubleBuffer ){   SVGAMesaContext ctx;#ifndef DEV   GLboolean rgb_flag;   GLfloat redscale, greenscale, bluescale, alphascale;   GLint index_bits;   GLint redbits, greenbits, bluebits, alphabits;   /* determine if we're in RGB or color index mode */   if ((SVGABuffer.Depth==32) || (SVGABuffer.Depth==24)) {      rgb_flag = GL_TRUE;      redscale = greenscale = bluescale = alphascale = 255.0;      redbits = greenbits = bluebits = 8;      alphabits = 0;      index_bits = 0;   }   else if (SVGABuffer.Depth==8) {      rgb_flag = GL_FALSE;      redscale = greenscale = bluescale = alphascale = 0.0;      redbits = greenbits = bluebits = alphabits = 0;      index_bits = 8;   }   else if (SVGABuffer.Depth==15) {      rgb_flag = GL_TRUE;      redscale = greenscale = bluescale = alphascale = 31.0;      redbits = greenbits = bluebits = 5;      alphabits = 0;      index_bits = 0;   }   else if (SVGABuffer.Depth==16) {      rgb_flag = GL_TRUE;      redscale = bluescale = alphascale = 31.0;      greenscale = 63.0;      redbits = bluebits = 5;      greenbits = 6;      alphabits = 0;      index_bits = 0;   }   ctx = (SVGAMesaContext) calloc( 1, sizeof(struct svgamesa_context) );   if (!ctx) {      return NULL;   }   ctx->gl_vis = _mesa_create_visual( rgb_flag,                                      doubleBuffer,                                      GL_FALSE,  /* stereo */                                      redbits, greenbits,                                      bluebits, alphabits,                                      index_bits,                                      16,   /* depth_size */                                      8,    /* stencil_size */                                      16, 16, 16, 16,   /* accum_size */                                      1     /* samples */                                      );   ctx->gl_ctx = _mesa_create_context( ctx->gl_vis,                                       NULL,  /* share list context */                                       (void *) ctx, GL_FALSE );   _mesa_enable_sw_extensions(ctx->gl_ctx);   _mesa_enable_1_3_extensions(ctx->gl_ctx);   _mesa_init_driver_functions(&ctx->Driver);   ctx->gl_buffer = _mesa_create_framebuffer( ctx->gl_vis,                                              ctx->gl_vis->depthBits > 0,                                              ctx->gl_vis->stencilBits > 0,                                              ctx->gl_vis->accumRedBits > 0,                                              ctx->gl_vis->alphaBits > 0 );   ctx->width = ctx->height = 0;  /* temporary until first "make-current" */#endif   return ctx;}/* * Destroy the given VGA/Mesa context. */void SVGAMesaDestroyContext( SVGAMesaContext ctx ){#ifndef DEV   if (ctx) {      _mesa_destroy_visual( ctx->gl_vis );      _mesa_destroy_context( ctx->gl_ctx );      free( ctx );      if (ctx==SVGAMesa) {         SVGAMesa = NULL;      }   }#endif}/* * Make the specified VGA/Mesa context the current one. */void SVGAMesaMakeCurrent( SVGAMesaContext ctx ){#ifndef DEV   SVGAMesa = ctx;   svgamesa_update_state( ctx->gl_ctx, ~0 );   _mesa_make_current( ctx->gl_ctx, ctx->gl_buffer );   if (ctx->width==0 || ctx->height==0) {      ctx->width = vga_getxdim();      ctx->height = vga_getydim();   }#endif}/* * Return a handle to the current VGA/Mesa context. */SVGAMesaContext SVGAMesaGetCurrentContext( void ){   return SVGAMesa;}/* * Swap front/back buffers for current context if double buffered. */void SVGAMesaSwapBuffers( void ){#if 000   void * tmpptr;#endif   /* vga_waitretrace(); */   copy_buffer(SVGABuffer.BackBuffer);#ifndef DEV   _mesa_notifySwapBuffers( SVGAMesa->gl_ctx );   if (SVGAMesa->gl_vis->doubleBufferMode)#endif /* DEV */   {#ifdef SVGA_DEBUG      sprintf(cbuf,"SVGAMesaSwapBuffers : Swapping...");      SVGAlog(cbuf);#endif /* SVGA_DEBUG */#if 000      tmpptr=SVGABuffer.BackBuffer;      SVGABuffer.BackBuffer=SVGABuffer.FrontBuffer;      SVGABuffer.FrontBuffer=tmpptr;#endif#ifdef SVGA_DEBUG      sprintf(cbuf,"SVGAMesaSwapBuffers : WriteBuffer : %p\n"              "                      Readbuffer  : %p", \              SVGABuffer.BackBuffer, SVGABuffer.FrontBuffer );      SVGAlog(cbuf);#endif /* SVGA_DEBUG */   }}#else /*SVGA*//* * Need this to provide at least one external definition when SVGA is * not defined on the compiler command line. */extern int gl_svga_dummy_function(void);int gl_svga_dummy_function(void){   return 0;}#endif  /*SVGA*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -