15bd8deadSopenharmony_ciName 25bd8deadSopenharmony_ci 35bd8deadSopenharmony_ci OES_draw_texture 45bd8deadSopenharmony_ci 55bd8deadSopenharmony_ciName Strings 65bd8deadSopenharmony_ci 75bd8deadSopenharmony_ci GL_OES_draw_texture 85bd8deadSopenharmony_ci 95bd8deadSopenharmony_ciContact 105bd8deadSopenharmony_ci 115bd8deadSopenharmony_ci Tom Olson (t-olson 'at' ti.com) 125bd8deadSopenharmony_ci 135bd8deadSopenharmony_ciNotice 145bd8deadSopenharmony_ci 155bd8deadSopenharmony_ci Copyright (c) 2004-2013 The Khronos Group Inc. Copyright terms at 165bd8deadSopenharmony_ci http://www.khronos.org/registry/speccopyright.html 175bd8deadSopenharmony_ci 185bd8deadSopenharmony_ciSpecification Update Policy 195bd8deadSopenharmony_ci 205bd8deadSopenharmony_ci Khronos-approved extension specifications are updated in response to 215bd8deadSopenharmony_ci issues and bugs prioritized by the Khronos OpenGL ES Working Group. For 225bd8deadSopenharmony_ci extensions which have been promoted to a core Specification, fixes will 235bd8deadSopenharmony_ci first appear in the latest version of that core Specification, and will 245bd8deadSopenharmony_ci eventually be backported to the extension document. This policy is 255bd8deadSopenharmony_ci described in more detail at 265bd8deadSopenharmony_ci https://www.khronos.org/registry/OpenGL/docs/update_policy.php 275bd8deadSopenharmony_ci 285bd8deadSopenharmony_ciStatus 295bd8deadSopenharmony_ci 305bd8deadSopenharmony_ci Ratified by the Khronos BOP, Aug 5, 2004. 315bd8deadSopenharmony_ci 325bd8deadSopenharmony_ciVersion 335bd8deadSopenharmony_ci 345bd8deadSopenharmony_ci Last Modified Date: 21 July 2004 355bd8deadSopenharmony_ci Author Revision 0.96 365bd8deadSopenharmony_ci 375bd8deadSopenharmony_ciNumber 385bd8deadSopenharmony_ci 395bd8deadSopenharmony_ci OpenGL ES Extension #7 405bd8deadSopenharmony_ci 415bd8deadSopenharmony_ciDependencies 425bd8deadSopenharmony_ci 435bd8deadSopenharmony_ci OES_fixed_point is required. 445bd8deadSopenharmony_ci EXT_fog_coord affects the definition of this extension. 455bd8deadSopenharmony_ci This extension is written against the OpenGL 1.3 and 465bd8deadSopenharmony_ci OpenGL ES 1.0 Specifications. 475bd8deadSopenharmony_ci 485bd8deadSopenharmony_ciOverview 495bd8deadSopenharmony_ci 505bd8deadSopenharmony_ci This extension defines a mechanism for writing pixel 515bd8deadSopenharmony_ci rectangles from one or more textures to a rectangular 525bd8deadSopenharmony_ci region of the screen. This capability is useful for 535bd8deadSopenharmony_ci fast rendering of background paintings, bitmapped font 545bd8deadSopenharmony_ci glyphs, and 2D framing elements in games. This 555bd8deadSopenharmony_ci extension is primarily intended for use with OpenGL ES. 565bd8deadSopenharmony_ci 575bd8deadSopenharmony_ci The extension relies on a new piece of texture state 585bd8deadSopenharmony_ci called the texture crop rectangle, which defines a 595bd8deadSopenharmony_ci rectangular subregion of a texture object. These 605bd8deadSopenharmony_ci subregions are used as sources of pixels for the texture 615bd8deadSopenharmony_ci drawing function. 625bd8deadSopenharmony_ci 635bd8deadSopenharmony_ci Applications use this extension by configuring the 645bd8deadSopenharmony_ci texture crop rectangle for one or more textures via 655bd8deadSopenharmony_ci ActiveTexture() and TexParameteriv() with pname equal to 665bd8deadSopenharmony_ci TEXTURE_CROP_RECT_OES. They then request a drawing 675bd8deadSopenharmony_ci operation using DrawTex{sifx}[v]OES(). The effect of 685bd8deadSopenharmony_ci the latter function is to generate a screen-aligned 695bd8deadSopenharmony_ci target rectangle, with texture coordinates chosen to map 705bd8deadSopenharmony_ci the texture crop rectangle(s) linearly to fragments in 715bd8deadSopenharmony_ci the target rectangle. The fragments are then processed 725bd8deadSopenharmony_ci in accordance with the fragment pipeline state. 735bd8deadSopenharmony_ci 745bd8deadSopenharmony_ciIP Status 755bd8deadSopenharmony_ci 765bd8deadSopenharmony_ci No known IP issues. 775bd8deadSopenharmony_ci 785bd8deadSopenharmony_ciIssues 795bd8deadSopenharmony_ci 805bd8deadSopenharmony_ci (1) Should we pass a texture name to the draw function, 815bd8deadSopenharmony_ci or use the currently bound texture? 825bd8deadSopenharmony_ci 835bd8deadSopenharmony_ci RESOLVED. Use the textures bound to currently 845bd8deadSopenharmony_ci enabled texture units. This makes it easy for 855bd8deadSopenharmony_ci drivers to implement DrawTex*() using existing 865bd8deadSopenharmony_ci texture hardware. If we didn't do this, they would 875bd8deadSopenharmony_ci have to save and restore the state of the texture 885bd8deadSopenharmony_ci unit(s). 895bd8deadSopenharmony_ci 905bd8deadSopenharmony_ci (2) Doesn't DrawPixels make this extension unnecessary? 915bd8deadSopenharmony_ci 925bd8deadSopenharmony_ci RESOLVED. No. DrawPixels is hard to support 935bd8deadSopenharmony_ci efficiently in hardware because the source pixels 945bd8deadSopenharmony_ci are in application memory. Also, the pixel setup 955bd8deadSopenharmony_ci pipeline (PixelTransfer, PixelMap etc.) is redundant 965bd8deadSopenharmony_ci for the intended applications. Also, PixelZoom 975bd8deadSopenharmony_ci looks ugly when the zoom factors are large, and there 985bd8deadSopenharmony_ci is no way to control filtering. Using textures and 995bd8deadSopenharmony_ci texture units solves all of these problems. 1005bd8deadSopenharmony_ci 1015bd8deadSopenharmony_ci (3) Doesn't ARB_point_sprite make this extension unnecessary? 1025bd8deadSopenharmony_ci 1035bd8deadSopenharmony_ci RESOLVED. No. Key differences include: 1045bd8deadSopenharmony_ci * ARB_point_sprite uses the entire source texture to 1055bd8deadSopenharmony_ci paint a point, i.e. its texture coordinates range 1065bd8deadSopenharmony_ci from 0.0 to 1.0. This extension allows a 1075bd8deadSopenharmony_ci subregion of a texture to be used as the source. 1085bd8deadSopenharmony_ci * ARB_point_sprite sprites are limited by the 1095bd8deadSopenharmony_ci maximum point size, which may be small. This 1105bd8deadSopenharmony_ci extension is limited only by the maximum supported 1115bd8deadSopenharmony_ci texture size and the screen size. 1125bd8deadSopenharmony_ci * ARB_point_sprite sprites are square. This 1135bd8deadSopenharmony_ci extension supports general rectangles as sprite 1145bd8deadSopenharmony_ci shapes. 1155bd8deadSopenharmony_ci * ARB_point_sprite sprites are clipped as points, so 1165bd8deadSopenharmony_ci if the center of a sprite falls outside the 1175bd8deadSopenharmony_ci frustrum, nothing is drawn. This extension draws 1185bd8deadSopenharmony_ci any portion of a sprite that lies within the 1195bd8deadSopenharmony_ci viewing frustrum. (There is a well-known 1205bd8deadSopenharmony_ci work-around for this, but it's ugly.) 1215bd8deadSopenharmony_ci 1225bd8deadSopenharmony_ci (4) How is the texture sampled? 1235bd8deadSopenharmony_ci 1245bd8deadSopenharmony_ci RESOLVED. It is sampled like a normal texture, and 1255bd8deadSopenharmony_ci not like an image sent to DrawPixels. This 1265bd8deadSopenharmony_ci facilitates implementing with texture hardware. 1275bd8deadSopenharmony_ci 1285bd8deadSopenharmony_ci (5) How does this work when multisampling is enabled? 1295bd8deadSopenharmony_ci 1305bd8deadSopenharmony_ci RESOLVED. Implementations should generate 1315bd8deadSopenharmony_ci multisample texture coordinates using the same 1325bd8deadSopenharmony_ci method they use in normal texture mapping. 1335bd8deadSopenharmony_ci Approximations are acceptable, e.g. they may use the 1345bd8deadSopenharmony_ci same texture value for all samples associated with a 1355bd8deadSopenharmony_ci fragment generated by DrawTex*(), even if they use 1365bd8deadSopenharmony_ci another policy for multisampled triangle rendering. 1375bd8deadSopenharmony_ci 1385bd8deadSopenharmony_ci (6) Do we really want the full fragment pipeline to be 1395bd8deadSopenharmony_ci active? 1405bd8deadSopenharmony_ci 1415bd8deadSopenharmony_ci RESOLVED. Yes, on grounds of orthogonality and 1425bd8deadSopenharmony_ci simplicity. Again, this makes it easy for existing 1435bd8deadSopenharmony_ci hardware to implement the extension. 1445bd8deadSopenharmony_ci 1455bd8deadSopenharmony_ci (7) How does this interact with user clip planes? 1465bd8deadSopenharmony_ci 1475bd8deadSopenharmony_ci RESOLVED. User clip planes are ignored. This is a 1485bd8deadSopenharmony_ci screen-level operation, so geometric entities like 1495bd8deadSopenharmony_ci clip planes are irrelevant. 1505bd8deadSopenharmony_ci 1515bd8deadSopenharmony_ci (8) How does this interact with mip-mapping? 1525bd8deadSopenharmony_ci 1535bd8deadSopenharmony_ci RESOLVED. It behaves exactly as in texturing. 1545bd8deadSopenharmony_ci This is really easy to do as LOD is a constant 1555bd8deadSopenharmony_ci across the target rectangle. 1565bd8deadSopenharmony_ci 1575bd8deadSopenharmony_ci (9) What happens when multiple texture units are 1585bd8deadSopenharmony_ci enabled? 1595bd8deadSopenharmony_ci 1605bd8deadSopenharmony_ci RESOLVED. All enabled texture units participate in 1615bd8deadSopenharmony_ci generating the final fragment color. Each unit 1625bd8deadSopenharmony_ci generates its own s,t based on its texture's crop 1635bd8deadSopenharmony_ci rectangle. 1645bd8deadSopenharmony_ci 1655bd8deadSopenharmony_ci (10) Should the target location be specified by the 1665bd8deadSopenharmony_ci current raster position (RasterPos or WindowPos), 1675bd8deadSopenharmony_ci or by arguments to DrawTex*OES()? 1685bd8deadSopenharmony_ci 1695bd8deadSopenharmony_ci RESOLVED. Use arguments passed to DrawTex*. In the 1705bd8deadSopenharmony_ci intended uses, the target will be set once per call, 1715bd8deadSopenharmony_ci so using arguments saves one inner loop function 1725bd8deadSopenharmony_ci call. 1735bd8deadSopenharmony_ci 1745bd8deadSopenharmony_ci (11) Do we want stretch-blt capability? 1755bd8deadSopenharmony_ci 1765bd8deadSopenharmony_ci RESOLVED. Yes. Supply a window size as well as 1775bd8deadSopenharmony_ci window position to DrawTex*() 1785bd8deadSopenharmony_ci 1795bd8deadSopenharmony_ci (12) OpenGL ES issue: WindowPos (if we use it) adds 16 1805bd8deadSopenharmony_ci entry points ({23}{sifd}[v]), which seems like a lot 1815bd8deadSopenharmony_ci even if they are trivial. Can we live with a 1825bd8deadSopenharmony_ci subset? (Note that the 'd' versions go away, but 1835bd8deadSopenharmony_ci they are replaced by 'x' versions.) 1845bd8deadSopenharmony_ci 1855bd8deadSopenharmony_ci RESOLVED. Moot, as we do not use WindowPos. But the 1865bd8deadSopenharmony_ci intent was to add only 3{si}[v] versions (four entry 1875bd8deadSopenharmony_ci points). This is not orthogonal and may be 1885bd8deadSopenharmony_ci surprising. But there is no intent to support 1895bd8deadSopenharmony_ci sub-pixel placement of rectangles, so the {fx} 1905bd8deadSopenharmony_ci versions are superfluous. {2} versions are easy to 1915bd8deadSopenharmony_ci express using {3} versions. Vector and individual 1925bd8deadSopenharmony_ci argument versions are kept to reduce the surprise 1935bd8deadSopenharmony_ci factor, and because constructing calls to a v-type 1945bd8deadSopenharmony_ci function is a huge pain if you don't already have 1955bd8deadSopenharmony_ci the data in vector format. 1965bd8deadSopenharmony_ci 1975bd8deadSopenharmony_ci (13) TexCropRect*OES adds eight entry points. Can we live 1985bd8deadSopenharmony_ci with a subset? For the intended use, integer values 1995bd8deadSopenharmony_ci suffice, so the {fx} versions are superfluous. But 2005bd8deadSopenharmony_ci orthogonality and 'least-astonishment' are virtues 2015bd8deadSopenharmony_ci too. 2025bd8deadSopenharmony_ci 2035bd8deadSopenharmony_ci RESOLVED. Moot. Replace with TexParameteriv(). 2045bd8deadSopenharmony_ci 2055bd8deadSopenharmony_ci (14) Would it be better to remove the texture crop 2065bd8deadSopenharmony_ci rectangle from the state, and instead pass 2075bd8deadSopenharmony_ci parameters to DrawTextureOES()? 2085bd8deadSopenharmony_ci 2095bd8deadSopenharmony_ci RESOLVED. No. Drawing the same pixel pattern multiple 2105bd8deadSopenharmony_ci times is a plausible usage scenario. 2115bd8deadSopenharmony_ci 2125bd8deadSopenharmony_ci (15) Should texture crop rect parameters be stored internally 2135bd8deadSopenharmony_ci as integers, or as float/fixed? I.e. should we allow 2145bd8deadSopenharmony_ci the crop rect to include fractional texels? This is 2155bd8deadSopenharmony_ci more flexible, but is not the intended use. Software 2165bd8deadSopenharmony_ci implementations would have to add a test for the (normal) 2175bd8deadSopenharmony_ci special case of integer bounds. 2185bd8deadSopenharmony_ci 2195bd8deadSopenharmony_ci RESOLVED. Integer only. Texture crop rect is 2205bd8deadSopenharmony_ci conceptually a subregion of an integer grid, so its 2215bd8deadSopenharmony_ci natural coordinates are integers. 2225bd8deadSopenharmony_ci 2235bd8deadSopenharmony_ci (16) Should we have a single global crop rect, or one per 2245bd8deadSopenharmony_ci texture unit? 2255bd8deadSopenharmony_ci 2265bd8deadSopenharmony_ci RESOLVED. Neither. We should have one per texture, 2275bd8deadSopenharmony_ci with TexParameter setting the rect for the currently 2285bd8deadSopenharmony_ci active texture. It isn't a lot of state, it 2295bd8deadSopenharmony_ci attaches the rect to a specific texture (which makes 2305bd8deadSopenharmony_ci sense) rather than a texture unit (which doesn't), 2315bd8deadSopenharmony_ci it is more orthogonal, and it allows tex coords to 2325bd8deadSopenharmony_ci be meaningful (if not actually useful) when multiple 2335bd8deadSopenharmony_ci texture units are enabled. 2345bd8deadSopenharmony_ci 2355bd8deadSopenharmony_ci (17) Should the destination rectangle specified by 2365bd8deadSopenharmony_ci DrawTex*() be defined as integer only like the crop 2375bd8deadSopenharmony_ci rectangle, or should its parameters be real-valued? 2385bd8deadSopenharmony_ci 2395bd8deadSopenharmony_ci RESOLVED. Real-valued. Since we now support 2405bd8deadSopenharmony_ci stretch-blit, we want the ability to animate the 2415bd8deadSopenharmony_ci scaling factor smoothly. If the destination rectangle 2425bd8deadSopenharmony_ci size is rounded to an integer, you won't get smooth 2435bd8deadSopenharmony_ci animation. 2445bd8deadSopenharmony_ci 2455bd8deadSopenharmony_ciNew Procedures and Functions 2465bd8deadSopenharmony_ci 2475bd8deadSopenharmony_ci Added to OpenGL 1.3 and OpenGL ES 1.0: 2485bd8deadSopenharmony_ci 2495bd8deadSopenharmony_ci void DrawTex{sifx}OES(T X, T Y, T Z, T W, T H); 2505bd8deadSopenharmony_ci void DrawTex{sifx}vOES(T* coords); 2515bd8deadSopenharmony_ci 2525bd8deadSopenharmony_ci Added to OpenGL ES 1.0: 2535bd8deadSopenharmony_ci 2545bd8deadSopenharmony_ci void TexParameter{ifx}v(enum target, enum pname, T param); 2555bd8deadSopenharmony_ci 2565bd8deadSopenharmony_ci 2575bd8deadSopenharmony_ciNew Types 2585bd8deadSopenharmony_ci 2595bd8deadSopenharmony_ci None 2605bd8deadSopenharmony_ci 2615bd8deadSopenharmony_ci 2625bd8deadSopenharmony_ciNew Tokens 2635bd8deadSopenharmony_ci 2645bd8deadSopenharmony_ci Accepted by the <pname> parameter of TexParameter() 2655bd8deadSopenharmony_ci and GetTexParameter(): 2665bd8deadSopenharmony_ci 2675bd8deadSopenharmony_ci TEXTURE_CROP_RECT_OES 0x8B9D 2685bd8deadSopenharmony_ci 2695bd8deadSopenharmony_ci 2705bd8deadSopenharmony_ciAdditions to Chapter 2 of the OpenGL 1.3 Specification 2715bd8deadSopenharmony_ci(OpenGL Operation): 2725bd8deadSopenharmony_ci 2735bd8deadSopenharmony_ci None 2745bd8deadSopenharmony_ci 2755bd8deadSopenharmony_ci 2765bd8deadSopenharmony_ciAdditions to Chapter 3 of the OpenGL 1.3 Specification 2775bd8deadSopenharmony_ci(Rasterization): 2785bd8deadSopenharmony_ci 2795bd8deadSopenharmony_ci In Table 3.19: Texture parameters and their values, p. 133, 2805bd8deadSopenharmony_ci add this line at the end of the table: 2815bd8deadSopenharmony_ci 2825bd8deadSopenharmony_ci Name Type Legal Values 2835bd8deadSopenharmony_ci -------------------------------------------------------- 2845bd8deadSopenharmony_ci TEXTURE_CROP_RECT_OES 4 integers any value 2855bd8deadSopenharmony_ci 2865bd8deadSopenharmony_ci 2875bd8deadSopenharmony_ci In section 3.8.4, Texture Parameters, after paragraph 3 2885bd8deadSopenharmony_ci (page 132) insert new paragraph: 2895bd8deadSopenharmony_ci 2905bd8deadSopenharmony_ci The texture parameter TEXTURE_CROP_RECT_OES controls the 2915bd8deadSopenharmony_ci operation of DrawTex{sifx}[v]OES(), as described in 2925bd8deadSopenharmony_ci section 5.7. It has no effect on the rasterization of 2935bd8deadSopenharmony_ci other primitives. 2945bd8deadSopenharmony_ci 2955bd8deadSopenharmony_ci 2965bd8deadSopenharmony_ciAdditions to Chapter 4 of the OpenGL 1.3 Specification 2975bd8deadSopenharmony_ci(Per-Fragment Operations and the Frame Buffer): 2985bd8deadSopenharmony_ci 2995bd8deadSopenharmony_ci None 3005bd8deadSopenharmony_ci 3015bd8deadSopenharmony_ci 3025bd8deadSopenharmony_ciAdditions to Chapter 5 of the OpenGL 1.3 Specification 3035bd8deadSopenharmony_ci(Special Functions): 3045bd8deadSopenharmony_ci 3055bd8deadSopenharmony_ci In Chapter 5, paragraph one, replace the last two words 3065bd8deadSopenharmony_ci ("and hints.") with the words "hints, and texture 3075bd8deadSopenharmony_ci rectangle drawing." 3085bd8deadSopenharmony_ci 3095bd8deadSopenharmony_ci After section 5.6, p. 196, insert: 3105bd8deadSopenharmony_ci 3115bd8deadSopenharmony_ci 5.7 Texture Rectangle Drawing 3125bd8deadSopenharmony_ci 3135bd8deadSopenharmony_ci OpenGL supports drawing sub-regions of a texture to 3145bd8deadSopenharmony_ci rectangular regions of the screen using the texturing 3155bd8deadSopenharmony_ci pipeline. Source region size and content are determined 3165bd8deadSopenharmony_ci by the texture crop rectangle(s) of the enabled 3175bd8deadSopenharmony_ci texture(s) (see section 3.8.14). 3185bd8deadSopenharmony_ci 3195bd8deadSopenharmony_ci The functions 3205bd8deadSopenharmony_ci 3215bd8deadSopenharmony_ci void DrawTex{sifx}OES(T Xs, T Ys, T Zs, T Ws, T Hs); 3225bd8deadSopenharmony_ci void DrawTex{sifx}vOES(T *coords); 3235bd8deadSopenharmony_ci 3245bd8deadSopenharmony_ci draw a texture rectangle to the screen. Xs, Ys, and Zs 3255bd8deadSopenharmony_ci specify the position of the affected screen rectangle. 3265bd8deadSopenharmony_ci Xs and Ys are given directly in window (viewport) 3275bd8deadSopenharmony_ci coordinates. Zs is mapped to window depth Zw as follows: 3285bd8deadSopenharmony_ci 3295bd8deadSopenharmony_ci { n, if z <= 0 3305bd8deadSopenharmony_ci Zw = { f, if z >= 1 3315bd8deadSopenharmony_ci { n + z * (f - n), otherwise 3325bd8deadSopenharmony_ci 3335bd8deadSopenharmony_ci where <n> and <f> are the near and far values of 3345bd8deadSopenharmony_ci DEPTH_RANGE. Ws and Hs specify the width and height of 3355bd8deadSopenharmony_ci the affected screen rectangle in pixels. These values 3365bd8deadSopenharmony_ci may be positive or negative; however, if either (Ws <= 3375bd8deadSopenharmony_ci 0) or (Hs <= 0), the INVALID_VALUE error is generated. 3385bd8deadSopenharmony_ci 3395bd8deadSopenharmony_ci Calling one of the DrawTex functions generates a 3405bd8deadSopenharmony_ci fragment for each pixel that overlaps the screen 3415bd8deadSopenharmony_ci rectangle bounded by (Xs, Ys) and (Xs + Ws), (Ys + Hs). 3425bd8deadSopenharmony_ci For each generated fragment, the depth is given by Zw 3435bd8deadSopenharmony_ci as defined above, and the color by the current color. 3445bd8deadSopenharmony_ci 3455bd8deadSopenharmony_ci If EXT_fog_coord is supported, and FOG_COORDINATE_SOURCE_EXT 3465bd8deadSopenharmony_ci is set to FOG_COORINATE_EXT, then the fragment distance for 3475bd8deadSopenharmony_ci fog purposes is set to CURRENT_FOG_COORDINATE. Otherwise, 3485bd8deadSopenharmony_ci the fragment distance for fog purposes is set to 0. 3495bd8deadSopenharmony_ci 3505bd8deadSopenharmony_ci Texture coordinates for each texture unit are computed 3515bd8deadSopenharmony_ci as follows: 3525bd8deadSopenharmony_ci 3535bd8deadSopenharmony_ci Let X and Y be the screen x and y coordinates of each 3545bd8deadSopenharmony_ci sample point associated with the fragment. Let Wt and 3555bd8deadSopenharmony_ci Ht be the width and height in texels of the texture 3565bd8deadSopenharmony_ci currently bound to the texture unit. (If the texture is 3575bd8deadSopenharmony_ci a mipmap, let Wt and Ht be the dimensions of the level 3585bd8deadSopenharmony_ci specified by TEXTURE_BASE_LEVEL.) Let Ucr, Vcr, Wcr and 3595bd8deadSopenharmony_ci Hcr be (respectively) the four integers that make up the 3605bd8deadSopenharmony_ci texture crop rectangle parameter for the currently bound 3615bd8deadSopenharmony_ci texture. The fragment texture coordinates (s, t, r, q) 3625bd8deadSopenharmony_ci are given by 3635bd8deadSopenharmony_ci 3645bd8deadSopenharmony_ci s = (Ucr + (X - Xs)*(Wcr/Ws)) / Wt 3655bd8deadSopenharmony_ci t = (Vcr + (Y - Ys)*(Hcr/Hs)) / Ht 3665bd8deadSopenharmony_ci r = 0 3675bd8deadSopenharmony_ci q = 1 3685bd8deadSopenharmony_ci 3695bd8deadSopenharmony_ci In the specific case where X, Y, Xs and Ys are all 3705bd8deadSopenharmony_ci integers, Wcr/Ws and Hcr/Hs are both equal to one, the 3715bd8deadSopenharmony_ci base level is used for the texture read, and fragments 3725bd8deadSopenharmony_ci are sampled at pixel centers, implementations are 3735bd8deadSopenharmony_ci required to ensure that the resulting u, v texture 3745bd8deadSopenharmony_ci indices are also integers. This results in a one-to-one 3755bd8deadSopenharmony_ci mapping of texels to fragments. 3765bd8deadSopenharmony_ci 3775bd8deadSopenharmony_ci Note that Wcr and/or Hcr can be negative. The formulas 3785bd8deadSopenharmony_ci given above for s and t still apply in this case. The 3795bd8deadSopenharmony_ci result is that if Wcr is negative, the source rectangle 3805bd8deadSopenharmony_ci for DrawTex operations lies to the left of the reference 3815bd8deadSopenharmony_ci point (Ucr, Vcr) rather than to the right of it, and 3825bd8deadSopenharmony_ci appears right-to-left reversed on the screen after a 3835bd8deadSopenharmony_ci call to DrawTex. Similarly, if Hcr is negative, the 3845bd8deadSopenharmony_ci source rectangle lies below the reference point (Ucr, 3855bd8deadSopenharmony_ci Vcr) rather than above it, and appears upside-down on 3865bd8deadSopenharmony_ci the screen. 3875bd8deadSopenharmony_ci 3885bd8deadSopenharmony_ci Note also that s, t, r, and q are computed for each 3895bd8deadSopenharmony_ci fragment as part of DrawTex rendering. This implies 3905bd8deadSopenharmony_ci that the texture matrix is ignored and has no effect on 3915bd8deadSopenharmony_ci the rendered result. 3925bd8deadSopenharmony_ci 3935bd8deadSopenharmony_ci 3945bd8deadSopenharmony_ciAdditions to Chapter 6 of the OpenGL 1.3 Specification 3955bd8deadSopenharmony_ci(State and State Requests): 3965bd8deadSopenharmony_ci 3975bd8deadSopenharmony_ci None 3985bd8deadSopenharmony_ci 3995bd8deadSopenharmony_ci 4005bd8deadSopenharmony_ciAdditions to Appendix A of the OpenGL 1.3 Specification 4015bd8deadSopenharmony_ci(Invariance): 4025bd8deadSopenharmony_ci 4035bd8deadSopenharmony_ci None 4045bd8deadSopenharmony_ci 4055bd8deadSopenharmony_ci 4065bd8deadSopenharmony_ciAdditions to the AGL/GLX/WGL Specifications: 4075bd8deadSopenharmony_ci 4085bd8deadSopenharmony_ci None 4095bd8deadSopenharmony_ci 4105bd8deadSopenharmony_ci 4115bd8deadSopenharmony_ciAdditions to Chapter 2 of the OpenGL ES 1.0 Specification 4125bd8deadSopenharmony_ci(OpenGL Operation): 4135bd8deadSopenharmony_ci 4145bd8deadSopenharmony_ci None 4155bd8deadSopenharmony_ci 4165bd8deadSopenharmony_ci 4175bd8deadSopenharmony_ciAdditions to Chapter 3 of the OpenGL ES 1.0 Specification 4185bd8deadSopenharmony_ci(Rasterization): 4195bd8deadSopenharmony_ci 4205bd8deadSopenharmony_ci After the fourth paragraph of section 3.8, Texturing, 4215bd8deadSopenharmony_ci p. 17, insert a new paragraph: 4225bd8deadSopenharmony_ci 4235bd8deadSopenharmony_ci DrawTexOES is supported. 4245bd8deadSopenharmony_ci 4255bd8deadSopenharmony_ci In the (unnamed) table of supported texture functions, 4265bd8deadSopenharmony_ci p. 19, delete the entry for TexParameter{i[v] fv}(), and 4275bd8deadSopenharmony_ci replace the entry for TexParameterf() with the following: 4285bd8deadSopenharmony_ci 4295bd8deadSopenharmony_ci OpenGL 1.3 Common Common-Lite 4305bd8deadSopenharmony_ci ------------------------------------------------ ------ ----------- 4315bd8deadSopenharmony_ci TexParameter{if}[v](enum target, enum param, T param) 4325bd8deadSopenharmony_ci target = TEXTURE_2D, pname = TEXTURE_CROP_RECT_OES (check) (check) 4335bd8deadSopenharmony_ci target = TEXTURE_1D, TEXTURE_3D, TEXTURE_CUBE_MAP - - 4345bd8deadSopenharmony_ci pname = TEXTURE_MIN_FILTER, TEXTURE_MAG_FILTER (check) (check) 4355bd8deadSopenharmony_ci pname = TEXTURE_WRAP_S, TEXTURE_WRAP_T (check) (check) 4365bd8deadSopenharmony_ci pname = TEXTURE_BORDER_COLOR - - 4375bd8deadSopenharmony_ci pname = TEXTURE_MIN_LOD, TEXTURE_MAX_LOD - - 4385bd8deadSopenharmony_ci pname = TEXTURE_BASE_LEVEL, TEXTURE_MAX_LEVEL - - 4395bd8deadSopenharmony_ci pname = TEXTURE_WRAP_R - - 4405bd8deadSopenharmony_ci pname = TEXTURE_PRIORITY - - 4415bd8deadSopenharmony_ci 4425bd8deadSopenharmony_ci In the same table, modify the entry for 4435bd8deadSopenharmony_ci GetTexParameter{if}v() to read as follows: 4445bd8deadSopenharmony_ci 4455bd8deadSopenharmony_ci OpenGL 1.3 Common Common-Lite 4465bd8deadSopenharmony_ci ------------------------------------------------------- ------ ----------- 4475bd8deadSopenharmony_ci GetTexParameter{if}v(enum target, enum param, T *params) (check) (dagger) 4485bd8deadSopenharmony_ci 4495bd8deadSopenharmony_ci 4505bd8deadSopenharmony_ciAdditions to Chapter 4 of the OpenGL ES 1.0 Specification 4515bd8deadSopenharmony_ci(Per-Fragment Operations and the Frame Buffer): 4525bd8deadSopenharmony_ci 4535bd8deadSopenharmony_ci None 4545bd8deadSopenharmony_ci 4555bd8deadSopenharmony_ci 4565bd8deadSopenharmony_ciAdditions to Chapter 5 of the OpenGL ES 1.0 Specification 4575bd8deadSopenharmony_ci(Special Functions): 4585bd8deadSopenharmony_ci 4595bd8deadSopenharmony_ci None 4605bd8deadSopenharmony_ci 4615bd8deadSopenharmony_ci 4625bd8deadSopenharmony_ciAdditions to Chapter 6 of the OpenGL ES 1.0 Specification 4635bd8deadSopenharmony_ci(State and State Requests): 4645bd8deadSopenharmony_ci 4655bd8deadSopenharmony_ci At the end of table 6.15, Texture Objects (cont.), p. 36, 4665bd8deadSopenharmony_ci insert a new entry: 4675bd8deadSopenharmony_ci 4685bd8deadSopenharmony_ci State Exposed Queriable 4695bd8deadSopenharmony_ci ------------------------------------------- ------- --------- 4705bd8deadSopenharmony_ci TEXTURE_CROP_RECT_OES (check) (check) 4715bd8deadSopenharmony_ci 4725bd8deadSopenharmony_ci 4735bd8deadSopenharmony_ci Replace the fourth paragraph of Chapter 7, Core Additions and 4745bd8deadSopenharmony_ci Extensions, p. 46, with the following: 4755bd8deadSopenharmony_ci 4765bd8deadSopenharmony_ci The Common and Common-Lite profiles add subsets of the 4775bd8deadSopenharmony_ci OES_byte_coordinates, OES_fixed_point, and 4785bd8deadSopenharmony_ci OES_single_precision ES-specific extensions as core 4795bd8deadSopenharmony_ci additions; OES_readFormat and 4805bd8deadSopenharmony_ci OES_compressed_paletted_texture as required profile 4815bd8deadSopenharmony_ci extensions; and OES_query_matrix and OES_draw_texture as 4825bd8deadSopenharmony_ci optional profile extensions. 4835bd8deadSopenharmony_ci 4845bd8deadSopenharmony_ci 4855bd8deadSopenharmony_ciAdditions to Chapter 7 of the OpenGL ES 1.0 Specification 4865bd8deadSopenharmony_ci(Core Additions and Extensions): 4875bd8deadSopenharmony_ci 4885bd8deadSopenharmony_ci At the end of Table 7.1: OES Extension Disposition, add a 4895bd8deadSopenharmony_ci new entry: 4905bd8deadSopenharmony_ci 4915bd8deadSopenharmony_ci Extension Name Common Common-Lite 4925bd8deadSopenharmony_ci ------------------------ ------------------ ------------------ 4935bd8deadSopenharmony_ci OES_draw_texture optional extension optional extension 4945bd8deadSopenharmony_ci 4955bd8deadSopenharmony_ci 4965bd8deadSopenharmony_ci After section 7.6, Query Matrix, insert 4975bd8deadSopenharmony_ci 4985bd8deadSopenharmony_ci 4995bd8deadSopenharmony_ci 7.7 Draw Texture 5005bd8deadSopenharmony_ci 5015bd8deadSopenharmony_ci The optional OES_draw_texture extension allows rectangular 5025bd8deadSopenharmony_ci subregions of a texture to be written to the screen using 5035bd8deadSopenharmony_ci the fragment pipeline. Texture coordinates are generated 5045bd8deadSopenharmony_ci for each fragment in the destination rectangle, such that 5055bd8deadSopenharmony_ci texels in the source texture are mapped linearly to pixels 5065bd8deadSopenharmony_ci on the screen. 5075bd8deadSopenharmony_ci 5085bd8deadSopenharmony_ci 5095bd8deadSopenharmony_ciGLX Protocol 5105bd8deadSopenharmony_ci 5115bd8deadSopenharmony_ci None 5125bd8deadSopenharmony_ci 5135bd8deadSopenharmony_ci 5145bd8deadSopenharmony_ciErrors 5155bd8deadSopenharmony_ci 5165bd8deadSopenharmony_ci None 5175bd8deadSopenharmony_ci 5185bd8deadSopenharmony_ci 5195bd8deadSopenharmony_ciDependencies on OES_fixed_point 5205bd8deadSopenharmony_ci 5215bd8deadSopenharmony_ci The DrawTex{sifx}[v]() function makes use of the 'x' 5225bd8deadSopenharmony_ci suffix and (in that form) accepts parameters of type fixed, 5235bd8deadSopenharmony_ci as defined in OES_fixed_point. 5245bd8deadSopenharmony_ci 5255bd8deadSopenharmony_ci 5265bd8deadSopenharmony_ciDependencies on EXT_fog_coord 5275bd8deadSopenharmony_ci 5285bd8deadSopenharmony_ci EXT_fog_coord affects the distance that is used in the fog 5295bd8deadSopenharmony_ci equations for fragments generated by DrawTex{sifx}[v](). 5305bd8deadSopenharmony_ci If EXT_fog_coord is not supported, the fog distance for 5315bd8deadSopenharmony_ci each fragment is set to zero. If EXT_fog_coord is 5325bd8deadSopenharmony_ci supported, the fog distance depends on the value of 5335bd8deadSopenharmony_ci FOG_COORDINATE_SOURCE_EXT. If the latter is set to 5345bd8deadSopenharmony_ci FRAGMENT_DEPTH_EXT, the fog distance is again set to zero. 5355bd8deadSopenharmony_ci If FOG_COORDINATE_SOURCE_EXT is set to FOG_COORDINATE_EXT, 5365bd8deadSopenharmony_ci the distance is set to CURRENT_FOG_COORDINATE. 5375bd8deadSopenharmony_ci 5385bd8deadSopenharmony_ci 5395bd8deadSopenharmony_ciNew State 5405bd8deadSopenharmony_ci 5415bd8deadSopenharmony_ci (table 6.16, Texture Objects (cont.), p. 224): 5425bd8deadSopenharmony_ci 5435bd8deadSopenharmony_ci Initial 5445bd8deadSopenharmony_ci Get Value Type Get Command Value Description Sec Attribute 5455bd8deadSopenharmony_ci --------- ---- ----------- --------- ----------- --- --------- 5465bd8deadSopenharmony_ci TEXTURE_CROP_RECT 4xZ GetTexParameteriv 0,0,0,0 texture crop 5.7 texture 5475bd8deadSopenharmony_ci rectangle 5485bd8deadSopenharmony_ci 5495bd8deadSopenharmony_ciNew Implementation Dependent State 5505bd8deadSopenharmony_ci 5515bd8deadSopenharmony_ci None. 5525bd8deadSopenharmony_ci 5535bd8deadSopenharmony_ci 5545bd8deadSopenharmony_ciRevision History 5555bd8deadSopenharmony_ci 5565bd8deadSopenharmony_ci July 21, 2004 (v0.96) 5575bd8deadSopenharmony_ci - Modified to say that if Ws or Hs < 0 then an 5585bd8deadSopenharmony_ci INVALID_VALUE error is generated 5595bd8deadSopenharmony_ci 5605bd8deadSopenharmony_ci July 16, 2004 (v0.95) 5615bd8deadSopenharmony_ci - Corrected a bug in the text description of DrawTex 5625bd8deadSopenharmony_ci with negative crop rectangle width or height. Thanks 5635bd8deadSopenharmony_ci to Petri Kero for the catch. 5645bd8deadSopenharmony_ci 5655bd8deadSopenharmony_ci July 14, 2004 (v0.9) 5665bd8deadSopenharmony_ci - added a Zs parameter to the destination rectangle 5675bd8deadSopenharmony_ci location specification. This allows applications 5685bd8deadSopenharmony_ci to control the depth coordinate of fragments generated 5695bd8deadSopenharmony_ci by DrawTex(). 5705bd8deadSopenharmony_ci - Removed DOS-mode carriage returns. 5715bd8deadSopenharmony_ci 5725bd8deadSopenharmony_ci June 29, 2004 (v0.8) 5735bd8deadSopenharmony_ci - Corrected dependencies to comply with ARB recommended 5745bd8deadSopenharmony_ci practice for extensions. 5755bd8deadSopenharmony_ci - Restructured the "Additions to the OpenGL ES 1.0 Spec" 5765bd8deadSopenharmony_ci sections to separate changes by chapter, following 5775bd8deadSopenharmony_ci ARB recommended practice for OpenGL and 5785bd8deadSopenharmony_ci GLX specifications. 5795bd8deadSopenharmony_ci - Modified TexParameter usage to be consistent with 5805bd8deadSopenharmony_ci OpenGL ES 1.1. 5815bd8deadSopenharmony_ci - Added a dependency on EXT_fog_coord. 5825bd8deadSopenharmony_ci - Inserted enumerant value. 5835bd8deadSopenharmony_ci 5845bd8deadSopenharmony_ci June 16, 2004 (v0.7) 5855bd8deadSopenharmony_ci - Modified to make texture crop rectangle part of 5865bd8deadSopenharmony_ci texture state (set by TexParameter) rather than by 5875bd8deadSopenharmony_ci an ad hoc function (TexCropRectOES). 5885bd8deadSopenharmony_ci - Modified to provide stretch-blit functionality. 5895bd8deadSopenharmony_ci 5905bd8deadSopenharmony_ci May 28, 2004 (v0.6) 5915bd8deadSopenharmony_ci - Formalized changes to 1.3 and ES 1.0 specs. 5925bd8deadSopenharmony_ci Modified to take screen coordinate arguments 5935bd8deadSopenharmony_ci rather than using the current raster position. 5945bd8deadSopenharmony_ci 5955bd8deadSopenharmony_ci May 19, 2004 (v0.5) 5965bd8deadSopenharmony_ci - Simplified to support only one-to-one source 5975bd8deadSopenharmony_ci blit. Sprite functionality was moved to a 5985bd8deadSopenharmony_ci separate proposal. 5995bd8deadSopenharmony_ci 6005bd8deadSopenharmony_ci May 4, 2004 (v0.4) 6015bd8deadSopenharmony_ci - Rewrote to use explicit source and destination 6025bd8deadSopenharmony_ci rectangles instead of overloading PixelZoom. 6035bd8deadSopenharmony_ci Made current raster rectangle explicit and 6045bd8deadSopenharmony_ci provided both screen space and object space 6055bd8deadSopenharmony_ci ways to define it. 6065bd8deadSopenharmony_ci 6075bd8deadSopenharmony_ci April 13, 2004 6085bd8deadSopenharmony_ci - Initial version (v0.3) 609