MCPcopy Create free account
hub / github.com/REGoth-project/REGoth / screenSpaceQuad

Function screenSpaceQuad

src/render/RenderSystem.cpp:143–200  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

141}
142
143void screenSpaceQuad(float _textureWidth, float _textureHeight, float _width = 1.0f, float _height = 1.0f)
144{
145 if (bgfx::getAvailTransientVertexBuffer(3, Meshes::WorldStaticMeshVertex::ms_decl))
146 {
147 const bgfx::Caps* caps = bgfx::getCaps();
148 const bgfx::RendererType::Enum renderer = bgfx::getRendererType();
149 float _texelHalf = bgfx::RendererType::Direct3D9 == renderer ? 0.5f : 0.0f;
150
151 bgfx::TransientVertexBuffer vb;
152 bgfx::allocTransientVertexBuffer(&vb, 3, Meshes::WorldStaticMeshVertex::ms_decl);
153 Meshes::WorldStaticMeshVertex* vertex = (Meshes::WorldStaticMeshVertex*)vb.data;
154
155 const float minx = -_width;
156 const float maxx = _width;
157 const float miny = 0.0f;
158 const float maxy = _height * 2.0f;
159
160 const float texelHalfW = _texelHalf / _textureWidth;
161 const float texelHalfH = _texelHalf / _textureHeight;
162 const float minu = -1.0f + texelHalfW;
163 const float maxu = 1.0f + texelHalfH;
164
165 const float zz = 0.0f;
166
167 float minv = texelHalfH;
168 float maxv = 2.0f + texelHalfH;
169
170 if (caps->originBottomLeft)
171 {
172 float temp = minv;
173 minv = maxv;
174 maxv = temp;
175
176 minv -= 1.0f;
177 maxv -= 1.0f;
178 }
179
180 vertex[0].Position.x = minx;
181 vertex[0].Position.y = miny;
182 vertex[0].Position.z = zz;
183 vertex[0].TexCoord.x = minu;
184 vertex[0].TexCoord.y = minv;
185
186 vertex[1].Position.x = maxx;
187 vertex[1].Position.y = miny;
188 vertex[1].Position.z = zz;
189 vertex[1].TexCoord.x = maxu;
190 vertex[1].TexCoord.y = minv;
191
192 vertex[2].Position.x = maxx;
193 vertex[2].Position.y = maxy;
194 vertex[2].Position.z = zz;
195 vertex[2].TexCoord.x = maxu;
196 vertex[2].TexCoord.y = maxv;
197
198 bgfx::setVertexBuffer(0, &vb);
199 }
200}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected