@@ -831,18 +831,18 @@ function loadTexture(gl, n, texture, u_Sampler, image) {
831831 ` gl.pixelStorei(pname, param) `
832832
833833 | 参数 | 描述 |
834- |-----------------------------------|------------------------------|
834+ | -----------------------------------| ------------------------------|
835835 | pname | 可以是以下二者之一 |
836836 | gl.UNPACK_FLIP_Y_WEBGL | 对图像进行Y轴反转。默认值为false |
837837 | gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL | 将图像RGB颜色值的每一个分量乘以A。默认值为false |
838838 | param | 指定非0(true)或0(false)。必须为整数 |
839839
840840 | 返回值 | 描述 |
841- |-----|----|
841+ | -----| ----|
842842 | 无 | |
843843
844844 | 错误 | 描述 |
845- |--------------|-------------|
845+ | --------------| -------------|
846846 | INVALID_ENUM | pname不是合法的值 |
847847
8488482 . ** 激活纹理单位(gl.activeTexture())**
@@ -855,15 +855,15 @@ function loadTexture(gl, n, texture, u_Sampler, image) {
855855 ` gl.activeTexture(texUnit) ` 开启0号纹理单元
856856
857857 | 参数 | 描述 |
858- |---------|------------------------------------------------------------------|
858+ | ---------| ------------------------------------------------------------------|
859859 | texUnit | 指定准备激活的纹理单元:gl.TEXTURE0、gl.TEXTURE1...gl.TEXTURE7。最后的数字表示纹理单元的编号 |
860860
861861 | 返回值 | 描述 |
862- |-----|----|
862+ | -----| ----|
863863 | 无 | |
864864
865865 | 错误 | 描述 |
866- |--------------|--------------|
866+ | --------------| --------------|
867867 | INVALID_ENUM | texUnit的值不合法 |
868868
869869 ![ 原理图] ( ./images/activeTexture.png )
@@ -873,23 +873,23 @@ function loadTexture(gl, n, texture, u_Sampler, image) {
873873 接下来,还需要告诉WebGL系统纹理对象使用的是哪种类型的纹理。在对纹理对象进行操作之前,我们需要绑定纹理对象,这一点与缓冲区很像:在对缓冲区对象进行操作之前,也需要绑定缓冲区对象。WebGL支持两种类型的纹理
874874
875875 | 纹理类型 | 描述 |
876- |---------------------|-------|
876+ | ---------------------| -------|
877877 | gl.TEXTURE_2D | 二维纹理 |
878878 | gl.TEXTURE_CUBE_MAP | 立方体纹理 |
879879
880880 ` gl.bindTexture(target, texture) `
881881
882882 | 参数 | 描述 |
883- |---------|-------------------------------------|
883+ | ---------| -------------------------------------|
884884 | target | gl.TEXTURE_2D 或 gl.TEXTURE_CUBE_MAP |
885885 | texture | 表示绑定的纹理单元 |
886886
887887 | 返回值 | 描述 |
888- |-----|----|
888+ | -----| ----|
889889 | 无 | |
890890
891891 | 错误 | 描述 |
892- |--------------|--------------|
892+ | --------------| --------------|
893893 | INVALID_ENUM | target不是合法的值 |
894894
895895 此方法完成了两个任务:开启纹理对象,以及纹理对象绑定到纹理单元上。
@@ -902,17 +902,17 @@ function loadTexture(gl, n, texture, u_Sampler, image) {
902902 ` gl.texParameteri(target, pname, param) `
903903
904904 | 参数 | 描述 |
905- | ---------| -----------------------------------|
905+ | ---------| -----------------------------------|
906906 | target | gl.TEXTURE_2D或gl.TEXTURE_CUBE_MAP |
907907 | pname | 纹理参数 |
908908 | param | 纹理参数值 |
909909
910910 | 返回值 | 描述 |
911- |-----|----|
911+ | -----| ----|
912912 | 无 | |
913913
914914 | 错误 | 描述 |
915- |-------------------|---------------|
915+ | -------------------| ---------------|
916916 | INVALID_ENUM | target不是合法的值 |
917917 | INVALID_OPERATION | 当前目标上没有绑定纹理对象 |
918918
@@ -926,7 +926,7 @@ function loadTexture(gl, n, texture, u_Sampler, image) {
926926 ** 纹理参数及它们的默认值**
927927
928928 | 纹理参数 | 描述 | 默认值 |
929- | -----------------------| --------| --------------------------|
929+ | -----------------------| --------| --------------------------|
930930 | gl.TEXTURE_MAG_FILTER | 纹理方大 | gl.LINEAR |
931931 | gl.TEXTURE_MIN_FILTER | 纹理缩小 | gl.NEAREST_MIPMAP_LINEAR |
932932 | gl.TEXTURE_WRAP_S | 纹理水平填充 | gl.REPEAT |
@@ -935,14 +935,14 @@ function loadTexture(gl, n, texture, u_Sampler, image) {
935935 ** 可以赋值给` gl.TEXTURE_MAG_FILTER ` 和 ` gl.TEXTURE_MIN_FILTER ` 的非金字塔纹理类型常量**
936936
937937 | 值 | 描述 |
938- |------------|---------------------------------------------------------------------|
938+ | ------------| ---------------------------------------------------------------------|
939939 | gl.NEAREST | 使用原纹理上距离映射后像素(新像素)中心最近的那个像素的颜色值,作为新像素的值(使用曼哈顿距离) |
940940 | gl.LINEAR | 使用距离新像素中心最近的四个像素的颜色值的加权平均,作为新像素的值(与gl.NEAREST相比,该方法的图像质量更好,当会有较大的开销 |
941941
942942 ** 可以赋值给` gl.TEXTURE_WRAP_S ` 和 ` gl.TEXTURE_WRAP_T ` 的常量**
943943
944944 | 值 | 描述 |
945- |--------------------|------------|
945+ | --------------------| ------------|
946946 | gl.REPEAT | 平铺式的重复纹理 |
947947 | gl.MIRRORED_REPEAT | 镜像对称式的重复纹理 |
948948 | gl.CLAMP_TO_EDGE | 使用纹理图像边缘值 |
@@ -954,7 +954,7 @@ function loadTexture(gl, n, texture, u_Sampler, image) {
954954 ` gl.texImage(target, level, internalformat, format, type, image) `
955955
956956 | 参数 | 描述 |
957- |----------------|-----------------------------------|
957+ | ----------------| -----------------------------------|
958958 | target | gl.TEXTURE_2D或gl.TEXTURE_CUBE_MAP |
959959 | level | 传入0(实际上,该参数是为金字塔纹理准备的) |
960960 | internalformat | 图像的内部格式 |
@@ -963,11 +963,11 @@ function loadTexture(gl, n, texture, u_Sampler, image) {
963963 | image | 包含纹理图像的Image对象 |
964964
965965 | 返回值 | 描述 |
966- |-----|----|
966+ | -----| ----|
967967 | 无 | |
968968
969969 | 错误 | 描述 |
970- |-------------------|----------------|
970+ | -------------------| ----------------|
971971 | INVALID_ENUM | target不是合法的值 |
972972 | INVALID_OPERATION | 当前目标上没有绑定的纹理对象 |
973973
@@ -976,7 +976,7 @@ function loadTexture(gl, n, texture, u_Sampler, image) {
976976 ** 图像内部格式**
977977
978978 | 格式 | 描述 |
979- |--------------------|----------------------|
979+ | --------------------| ----------------------|
980980 | gl.RGB | 红、绿、蓝 |
981981 | gl.RGBA | 红、绿、蓝、透明度 |
982982 | gl.ALPHA | (0.0, 0.0, 0.0, 透明度) |
@@ -988,7 +988,7 @@ function loadTexture(gl, n, texture, u_Sampler, image) {
988988 type参数指定了纹理数据类型。通常我们使用` gl.UNSIGNED_BYTE ` 数据类型。当然也可以使用其他数据类型。
989989
990990 | 格式 | 描述 |
991- |---------------------------|-------------------------------|
991+ | ---------------------------| -------------------------------|
992992 | gl.UNSIGNED_BYTE | 无符号整型,每个颜色分量占据1字节 |
993993 | gl.UNSIGNED_SHORT_5_6_5 | RGB: 每个分量分别占据5、6、5比特 |
994994 | gl.UNSIGNED_SHORT_4_4_4_4 | RGBA: 每个分量分别占据4,4,4,4比特 |
@@ -1012,7 +1012,7 @@ function loadTexture(gl, n, texture, u_Sampler, image) {
10121012 ** 专用于纹理的数据类型**
10131013
10141014 | 类型 | 描述 |
1015- | ------------ - | -------------------------------- |
1015+ | ------------ - | -------------------------------- |
10161016 | sampler2D | 绑定到gl .TEXTURE_2D 上的纹理数据类型 |
10171017 | samplerCube | 绑定到gl .TEXTURE_CUBE_MAP 上的纹理数据类型 |
10181018
@@ -1038,7 +1038,7 @@ function loadTexture(gl, n, texture, u_Sampler, image) {
10381038 ` vec4 texture2D(sampler2d smapler, vec2 coord)`
10391039
10401040 | 参数 | 描述 |
1041- | -------- - | ---------- |
1041+ | -------- - | ---------- |
10421042 | sampler | 指定纹理单元编号 |
10431043 | coord | 指定纹理坐标 |
10441044
0 commit comments