| 161 | // *********************************************************************** |
| 162 | |
| 163 | void CreateFullScreenQuad(f32 _textureWidth, f32 _textureHeight, f32 _texelHalf, bool _originBottomLeft, f32 _depth, f32 _width = 1.0f, f32 _height = 1.0f) { |
| 164 | |
| 165 | // allocate space for 3 vertices, stack might be fine |
| 166 | VertexData vertices[3]; |
| 167 | |
| 168 | const f32 minx = -_width; |
| 169 | const f32 maxx = _width; |
| 170 | const f32 miny = 0.0f; |
| 171 | const f32 maxy = _height * 2.0f; |
| 172 | |
| 173 | const f32 texelHalfW = _texelHalf / _textureWidth; |
| 174 | const f32 texelHalfH = _texelHalf / _textureHeight; |
| 175 | const f32 minu = -1.0f + texelHalfW; |
| 176 | const f32 maxu = 1.0f + texelHalfH; |
| 177 | |
| 178 | const f32 zz = _depth; |
| 179 | |
| 180 | f32 minv = texelHalfH; |
| 181 | f32 maxv = 2.0f + texelHalfH; |
| 182 | |
| 183 | if (_originBottomLeft) { |
| 184 | f32 temp = minv; |
| 185 | minv = maxv; |
| 186 | maxv = temp; |
| 187 | |
| 188 | minv -= 1.0f; |
| 189 | maxv -= 1.0f; |
| 190 | } |
| 191 | |
| 192 | vertices[0].pos.x = minx; |
| 193 | vertices[0].pos.y = miny; |
| 194 | vertices[0].pos.z = zz; |
| 195 | vertices[0].tex.x = minu; |
| 196 | vertices[0].tex.y = minv; |
| 197 | |
| 198 | vertices[1].pos.x = maxx; |
| 199 | vertices[1].pos.y = maxy; |
| 200 | vertices[1].pos.z = zz; |
| 201 | vertices[1].tex.x = maxu; |
| 202 | vertices[1].tex.y = maxv; |
| 203 | |
| 204 | vertices[2].pos.x = maxx; |
| 205 | vertices[2].pos.y = miny; |
| 206 | vertices[2].pos.z = zz; |
| 207 | vertices[2].tex.x = maxu; |
| 208 | vertices[2].tex.y = minv; |
| 209 | |
| 210 | sg_buffer_desc vbufferDesc = { |
| 211 | .data = SG_RANGE(vertices) |
| 212 | }; |
| 213 | pRenderState->fullscreenTriangle = sg_make_buffer(&vbufferDesc); |
| 214 | } |
| 215 | |
| 216 | |
| 217 | // *********************************************************************** |