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

📄 s_texstore.c

📁 Mesa is an open-source implementation of the OpenGL specification - a system for rendering interacti
💻 C
📖 第 1 页 / 共 2 页
字号:
   }   /* GL_SGIS_generate_mipmap */   if (level == texObj->BaseLevel && texObj->GenerateMipmap) {      ctx->Driver.GenerateMipmap(ctx, target, texObj);   }}/** * Fallback for Driver.CopyTexImage2D(). * * We implement CopyTexImage by reading the image from the framebuffer * then passing it to the ctx->Driver.TexImage2D() function. * * Device drivers should try to implement direct framebuffer->texture copies. */void_swrast_copy_teximage2d( GLcontext *ctx, GLenum target, GLint level,                         GLenum internalFormat,                         GLint x, GLint y, GLsizei width, GLsizei height,                         GLint border ){   struct gl_texture_unit *texUnit;   struct gl_texture_object *texObj;   struct gl_texture_image *texImage;   texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];   texObj = _mesa_select_tex_object(ctx, texUnit, target);   ASSERT(texObj);   texImage = _mesa_select_tex_image(ctx, texObj, target, level);   ASSERT(texImage);   ASSERT(ctx->Driver.TexImage2D);   if (is_depth_format(internalFormat)) {      /* read depth image from framebuffer */      GLuint *image = read_depth_image(ctx, x, y, width, height);      if (!image) {         _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexImage2D");         return;      }      /* call glTexImage2D to redefine the texture */      ctx->Driver.TexImage2D(ctx, target, level, internalFormat,                             width, height, border,                             GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, image,                             &ctx->DefaultPacking, texObj, texImage);      _mesa_free(image);   }   else if (is_depth_stencil_format(internalFormat)) {      GLuint *image = read_depth_stencil_image(ctx, x, y, width, height);      if (!image) {         _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexImage2D");         return;      }      /* call glTexImage2D to redefine the texture */      ctx->Driver.TexImage2D(ctx, target, level, internalFormat,                             width, height, border,                             GL_DEPTH_STENCIL_EXT, GL_UNSIGNED_INT_24_8_EXT,                             image, &ctx->DefaultPacking, texObj, texImage);      _mesa_free(image);   }   else {      /* read RGBA image from framebuffer */      const GLenum format = GL_RGBA;      const GLenum type = ctx->ReadBuffer->_ColorReadBuffer->DataType;      GLvoid *image = read_color_image(ctx, x, y, type, width, height);      if (!image) {         _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexImage2D");         return;      }      /* call glTexImage2D to redefine the texture */      ctx->Driver.TexImage2D(ctx, target, level, internalFormat,                             width, height, border, format, type, image,                             &ctx->DefaultPacking, texObj, texImage);      _mesa_free(image);   }   /* GL_SGIS_generate_mipmap */   if (level == texObj->BaseLevel && texObj->GenerateMipmap) {      ctx->Driver.GenerateMipmap(ctx, target, texObj);   }}/* * Fallback for Driver.CopyTexSubImage1D(). */void_swrast_copy_texsubimage1d( GLcontext *ctx, GLenum target, GLint level,                            GLint xoffset, GLint x, GLint y, GLsizei width ){   struct gl_texture_unit *texUnit;   struct gl_texture_object *texObj;   struct gl_texture_image *texImage;   texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];   texObj = _mesa_select_tex_object(ctx, texUnit, target);   ASSERT(texObj);   texImage = _mesa_select_tex_image(ctx, texObj, target, level);   ASSERT(texImage);   ASSERT(ctx->Driver.TexImage1D);   if (texImage->_BaseFormat == GL_DEPTH_COMPONENT) {      /* read depth image from framebuffer */      GLuint *image = read_depth_image(ctx, x, y, width, 1);      if (!image) {         _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage1D");         return;      }      /* call glTexSubImage1D to redefine the texture */      ctx->Driver.TexSubImage1D(ctx, target, level, xoffset, width,                                GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, image,                                &ctx->DefaultPacking, texObj, texImage);      _mesa_free(image);   }   else if (texImage->_BaseFormat == GL_DEPTH_STENCIL_EXT) {      /* read depth/stencil image from framebuffer */      GLuint *image = read_depth_stencil_image(ctx, x, y, width, 1);      if (!image) {         _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage1D");         return;      }      /* call glTexImage1D to redefine the texture */      ctx->Driver.TexSubImage1D(ctx, target, level, xoffset, width,                                GL_DEPTH_STENCIL_EXT, GL_UNSIGNED_INT_24_8_EXT,                                image, &ctx->DefaultPacking, texObj, texImage);      _mesa_free(image);   }   else {      /* read RGBA image from framebuffer */      const GLenum format = GL_RGBA;      const GLenum type = ctx->ReadBuffer->_ColorReadBuffer->DataType;      GLvoid *image = read_color_image(ctx, x, y, type, width, 1);      if (!image) {         _mesa_error( ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage1D" );         return;      }      /* now call glTexSubImage1D to do the real work */      ctx->Driver.TexSubImage1D(ctx, target, level, xoffset, width,                                format, type, image,                                &ctx->DefaultPacking, texObj, texImage);      _mesa_free(image);   }   /* GL_SGIS_generate_mipmap */   if (level == texObj->BaseLevel && texObj->GenerateMipmap) {      ctx->Driver.GenerateMipmap(ctx, target, texObj);   }}/** * Fallback for Driver.CopyTexSubImage2D(). * * Read the image from the framebuffer then hand it * off to ctx->Driver.TexSubImage2D(). */void_swrast_copy_texsubimage2d( GLcontext *ctx,                            GLenum target, GLint level,                            GLint xoffset, GLint yoffset,                            GLint x, GLint y, GLsizei width, GLsizei height ){   struct gl_texture_unit *texUnit;   struct gl_texture_object *texObj;   struct gl_texture_image *texImage;   texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];   texObj = _mesa_select_tex_object(ctx, texUnit, target);   ASSERT(texObj);   texImage = _mesa_select_tex_image(ctx, texObj, target, level);   ASSERT(texImage);   ASSERT(ctx->Driver.TexImage2D);   if (texImage->_BaseFormat == GL_DEPTH_COMPONENT) {      /* read depth image from framebuffer */      GLuint *image = read_depth_image(ctx, x, y, width, height);      if (!image) {         _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage2D");         return;      }      /* call glTexImage2D to redefine the texture */      ctx->Driver.TexSubImage2D(ctx, target, level,                                xoffset, yoffset, width, height,                                GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, image,                                &ctx->DefaultPacking, texObj, texImage);      _mesa_free(image);   }   else if (texImage->_BaseFormat == GL_DEPTH_STENCIL_EXT) {      /* read depth/stencil image from framebuffer */      GLuint *image = read_depth_stencil_image(ctx, x, y, width, height);      if (!image) {         _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage2D");         return;      }      /* call glTexImage2D to redefine the texture */      ctx->Driver.TexSubImage2D(ctx, target, level,                                xoffset, yoffset, width, height,                                GL_DEPTH_STENCIL_EXT, GL_UNSIGNED_INT_24_8_EXT,                                image, &ctx->DefaultPacking, texObj, texImage);      _mesa_free(image);   }   else {      /* read RGBA image from framebuffer */      const GLenum format = GL_RGBA;      const GLenum type = ctx->ReadBuffer->_ColorReadBuffer->DataType;      GLvoid *image = read_color_image(ctx, x, y, type, width, height);      if (!image) {         _mesa_error( ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage2D" );         return;      }      /* now call glTexSubImage2D to do the real work */      ctx->Driver.TexSubImage2D(ctx, target, level,                                xoffset, yoffset, width, height,                                format, type, image,                                &ctx->DefaultPacking, texObj, texImage);      _mesa_free(image);   }   /* GL_SGIS_generate_mipmap */   if (level == texObj->BaseLevel && texObj->GenerateMipmap) {      ctx->Driver.GenerateMipmap(ctx, target, texObj);   }}/* * Fallback for Driver.CopyTexSubImage3D(). */void_swrast_copy_texsubimage3d( GLcontext *ctx,                            GLenum target, GLint level,                            GLint xoffset, GLint yoffset, GLint zoffset,                            GLint x, GLint y, GLsizei width, GLsizei height ){   struct gl_texture_unit *texUnit;   struct gl_texture_object *texObj;   struct gl_texture_image *texImage;   texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];   texObj = _mesa_select_tex_object(ctx, texUnit, target);   ASSERT(texObj);   texImage = _mesa_select_tex_image(ctx, texObj, target, level);   ASSERT(texImage);   ASSERT(ctx->Driver.TexImage3D);   if (texImage->_BaseFormat == GL_DEPTH_COMPONENT) {      /* read depth image from framebuffer */      GLuint *image = read_depth_image(ctx, x, y, width, height);      if (!image) {         _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage3D");         return;      }      /* call glTexImage3D to redefine the texture */      ctx->Driver.TexSubImage3D(ctx, target, level,                                xoffset, yoffset, zoffset, width, height, 1,                                GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, image,                                &ctx->DefaultPacking, texObj, texImage);      _mesa_free(image);   }   else if (texImage->_BaseFormat == GL_DEPTH_STENCIL_EXT) {      /* read depth/stencil image from framebuffer */      GLuint *image = read_depth_stencil_image(ctx, x, y, width, height);      if (!image) {         _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage3D");         return;      }      /* call glTexImage3D to redefine the texture */      ctx->Driver.TexSubImage3D(ctx, target, level,                                xoffset, yoffset, zoffset, width, height, 1,                                GL_DEPTH_STENCIL_EXT, GL_UNSIGNED_INT_24_8_EXT,                                image, &ctx->DefaultPacking, texObj, texImage);      _mesa_free(image);   }   else {      /* read RGBA image from framebuffer */      const GLenum format = GL_RGBA;      const GLenum type = ctx->ReadBuffer->_ColorReadBuffer->DataType;      GLvoid *image = read_color_image(ctx, x, y, type, width, height);      if (!image) {         _mesa_error( ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage3D" );         return;      }      /* now call glTexSubImage3D to do the real work */      ctx->Driver.TexSubImage3D(ctx, target, level,                                xoffset, yoffset, zoffset, width, height, 1,                                format, type, image,                                &ctx->DefaultPacking, texObj, texImage);      _mesa_free(image);   }   /* GL_SGIS_generate_mipmap */   if (level == texObj->BaseLevel && texObj->GenerateMipmap) {      ctx->Driver.GenerateMipmap(ctx, target, texObj);   }}

⌨️ 快捷键说明

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