openGL之API学习(二十六)glTexImage2D

学习提速专享!AI工具全家桶免费用 限时购周边加赠Coding Plan Lite,解锁20+主流AI工具,写代码、查资料快人一步! 阅读详情

给2维纹理分配显存空间,也可以从内存向显存拷贝数据。

void glTexImage2D(     GLenum target,
      GLint level,
      GLint internalformat,
      GLsizei width,
      GLsizei height,
      GLint border,
      GLenum format,
      GLenum type,
      const GLvoid * data);

target

    Specifies the target texture. Must be GL_TEXTURE_2D, GL_PROXY_TEXTURE_2D, GL_TEXTURE_1D_ARRAY, GL_PROXY_TEXTURE_1D_ARRAY, GL_TEXTURE_RECTANGLE, GL_PROXY_TEXTURE_RECTANGLE, GL_TEXTURE_CUBE_MAP_POSITIVE_X, GL_TEXTURE_CUBE_MAP_NEGATIVE_X, GL_TEXTURE_CUBE_MAP_POSITIVE_Y, GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, GL_TEXTURE_CUBE_MAP_POSITIVE_Z, GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, or GL_PROXY_TEXTURE_CUBE_MAP.

GL_TEXTURE_CUBE_MAP_POSITIVE_X, GL_TEXTURE_CUBE_MAP_NEGATIVE_X, GL_TEXTURE_CUBE_MAP_POSITIVE_Y, GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, GL_TEXTURE_CUBE_MAP_POSITIVE_Z, GL_TEXTURE_CUBE_MAP_NEGATIVE_Z分别对应立方体贴图Cubemap的六个面。
level

    Specifies the level-of-detail number. Level 0 is the base image level. Level n is the nth mipmap reduction image. If target is GL_TEXTURE_RECTANGLE or GL_PROXY_TEXTURE_RECTANGLE, level must be 0.
internalformat

    Specifies the number of color components in the texture. Must be one of base internal formats given in Table 1, one of the sized internal formats given in Table 2, or one of the compressed internal formats given in Table 3, below.
width

    Specifies the width of the texture image. All implementations support texture images that are at least 1024 texels wide.
height

    Specifies the height of the texture image, or the number of layers in a texture array, in the case of the GL_TEXTURE_1D_ARRAY and GL_PROXY_TEXTURE_1D_ARRAY targets. All implementations support 2D texture images that are at least 1024 texels high, and texture arrays that are at least 256 layers deep.
border

    This value must be 0.
format

    Specifies the format of the pixel data. The following symbolic values are accepted: GL_RED, GL_RG, GL_RGB, GL_BGR, GL_RGBA, GL_BGRA, GL_RED_INTEGER, GL_RG_INTEGER, GL_RGB_INTEGER, GL_BGR_INTEGER, GL_RGBA_INTEGER, GL_BGRA_INTEGER, GL_STENCIL_INDEX, GL_DEPTH_COMPONENT, GL_DEPTH_STENCIL.
type

    Specifies the data type of the pixel data. The following symbolic values are accepted: GL_UNSIGNED_BYTE, GL_BYTE, GL_UNSIGNED_SHORT, GL_SHORT, GL_UNSIGNED_INT, GL_INT, GL_HALF_FLOAT, GL_FLOAT, GL_UNSIGNED_BYTE_3_3_2, GL_UNSIGNED_BYTE_2_3_3_REV, GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_SHORT_5_6_5_REV, GL_UNSIGNED_SHORT_4_4_4_4, GL_UNSIGNED_SHORT_4_4_4_4_REV, GL_UNSIGNED_SHORT_5_5_5_1, GL_UNSIGNED_SHORT_1_5_5_5_REV, GL_UNSIGNED_INT_8_8_8_8, GL_UNSIGNED_INT_8_8_8_8_REV, GL_UNSIGNED_INT_10_10_10_2, and GL_UNSIGNED_INT_2_10_10_10_REV.
data

    Specifie

(十五)WebGL中gl.texImage2D函数使用详解 是WebGL中上传纹理的核心方法,它将图像数据或像素数据上传为纹理对象,允许在渲染时将纹理映射到几何体表面。理解如何使用并正确处理纹理数据,是开发WebGL应用的基础之一。 阅读详情

相关推荐

GLES3.0中文API-glTexImage2D

名称 glTexImage2D- 指定一个二维的纹理图片 C规范 void glTexImage2D(GLenum target, GLint level, GLint internalformat, ...

MSK1111的博客 763

OpenGL APIglTexImage2D

glTexImage2D详细说明.参数data在上文中说有两种解释: 1.当有缓冲区绑定到 GL_PIXEL_PACK/UNPACK_BUFFER 时,这时候使用了PBO(Pixel Buffer Object),此时的data是一个指向缓冲区对象数据的偏移量 2.当没有缓冲区绑定到GL_PIXEL_PACK/UNPACK_BUFFER 时,这是data是指向内存中的指针(上文中提到的pBytes)

whl0071的专栏 5616

OpenGL纹理拷贝的两种方法

然后,将源纹理绑定到帧缓冲区的颜色附着点,然后使用glCopyTexSubImage2D函数将源纹理的一部分数据拷贝到目标纹理中。最后,恢复OpenGL的状态。然后,将源纹理绑定到帧缓冲区的颜色附着点,然后使用glCopyTexImage2D函数将源纹理的数据拷贝到目标纹理中。在本文中,我将介绍两种常用的OpenGL纹理拷贝方法,并提供相应的源代码示例。glCopyTexSubImage2D函数也可以用于纹理拷贝,但与glCopyTexImage2D不同的是,它只拷贝纹理的一部分数据。

NckyPytorch的博客 1625

glTexImage2D()

函数定义: void glTexImage2D(GLenum target,           GLint level,           GLint internalFormat,           GLsizei width,           GLsizei height,           GLint border,           GLenum format,      ...

heibaigezi的博客 1万+

glTexSubImage2D的使用详解

Name glTexSubImage2D, glTextureSubImage2D — specify a two-dimensional texture subimage C Specification void glTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void * p

aoxuestudy的专栏 3183

Android OpenGL ES详解——glTexImage2D方法

glTexImage2D函数的主要功能是根据指定的参数生成一个2D纹理。这包括为纹理分配显存空间,并从内存向显存拷贝数据(如果提供了pixels参数)。这个函数是纹理贴图过程中的关键步骤之一,它定义了纹理的尺寸、格式和颜色数据。

闲暇部落 1833

OpenGL ES2.0/3.0 glTexImage2D 函数详解

glTexImage2D - 指定一个二维纹理图像 C规范 voidglTexImage2D( GLenumtarget, GLintlevel, GLintinternalformat, GLsizei宽度, GLsizei高度, GLint边框, GLenumformat, GLenumtype, const GLvoid *data); internalFormat:指定OpenGL是如何管理纹理单元中数据格式的,但是有很多解释说这个参数必须和...

juruiyuan111的专栏 2107

OpenGL:纹理

OpenGL:纹理

肖云鹤的博客 2931

从图像到纹理的GL函数

glTexImage2D这个GL函数可以实现把一幅图像转化为GL的纹理,从而可以在此基础上运用GPU做图像的显示和处理。此外,还有一个GL函数glTexSubImage2D可以实现对纹理中的图像进行局部更新。Android中有一个java工具类GLUtils也实现了同样的功能两个函数,只不过函数名称不一样,分别为texImage2D和texSubImage2D。当然在Android中也可以使用SDK封装的GL函数glTexImage2D和glTexSubImage2D

格物致知的专栏 [音视频编解码 网络协议 计算机视觉 计算机图形学 图像理解 语音识别 机器学习 模拟电路 传感器] 369

glTexImage2D函数

【代码】glTexImage2D函数。

格物致知的专栏 [音视频编解码 网络协议 计算机视觉 计算机图形学 图像理解 语音识别 机器学习 模拟电路 传感器] 290

OpenGL ES之glTexImage2D函数

名称: glTexImage2D—— 指定一个二维的纹理图片 函数原型: void glTexImage2D( GLenum target,  GLint level,  GLint internalformat,  GLsizei width,  GLsizei height,  GLint border,  G

飞鱼 3万+

glTexImage2D方法

 GlTexImage2D(Glenum target,Glint level,Glintinternalformat,Glsizei width,Glsizei height,Glint border,Glenum format,Glenumtype,const Glvoid *pixels) targe 必须是GL_TEXTURE_2D。level: 系统自动生成纹理

HopeAlwaysHere的专栏 7734

第十一课,纹理的使用入门

转自:http://www.programfan.com/club/post-244703.html我们在前一课中,学习了简单的像素操作,这意味着我们可以使用各种各样的BMP文件来丰富程序的显示效果,于是我们的OpenGL图形程序也不再像以前总是只显示几个多边形那样单调了。——但是这还不够。虽然我们可以将像素数据按照矩形进行缩小和放大,但是还不足以满足我们的要求。例如要将一幅世界地图绘制到一个

fengerfafa的专栏 3116

glTexImage2D的详细说明

Name glTexImage2D — specify a two-dimensional texture image C Specification void glTexImage2D( GLenum target,   GLint level,   GLint internalFormat,

huanyingtianhe的专栏 1万+

OpenGL中内存和显存之间的拷贝操作

1. 从内存至显存 1.1 对Buffer object的操作,比较简单: glGenBuffers(NumBuffers, Buffers); glBindBuffer(GL_ARRAY_BUFFER, Buffers[ArrayBuffer]); glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW...

To Be A Linux Graphics Coder 4774

OpenGL函数思考-glTexImage2D

OpenGL函数思考-glTexImage2D 函数原型: void glTexImage2D(GLenum target,GLint level,GLint components,GLsizei width, glsizei height,GLint border,GLenum format,GLenum type, const GLvoid *pixels); 函数说明: 定义一个二维纹理...

v5qqcom 521
上一篇: openGL之API学习(二十五)窗体默认FBO与手工创建的FBO的区别
下一篇: openGL之API学习(二十七)glEnable
hankern
博客等级 码龄19年 907粉丝 1016原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值