MCPcopy
hub / github.com/EngoEngine/engo / Draw

Method Draw

common/render_shaders_default.go:208–270  ·  view source on GitHub ↗
(ren *RenderComponent, space *SpaceComponent)

Source from the content-addressed store, hash-verified

206}
207
208func (s *basicShader) Draw(ren *RenderComponent, space *SpaceComponent) {
209 // If our texture (or any of its properties) has changed or we've reached the end of our buffer, flush before moving on.
210 if s.lastTexture != ren.Drawable.Texture() {
211 s.flush()
212 engo.Gl.BindTexture(engo.Gl.TEXTURE_2D, ren.Drawable.Texture())
213 s.setTexture(ren.Drawable.Texture())
214 } else if s.idx == len(s.vertices) {
215 s.flush()
216 }
217
218 if s.lastRepeating != ren.Repeat {
219 s.flush()
220 var val int
221 switch ren.Repeat {
222 case NoRepeat:
223 val = engo.Gl.CLAMP_TO_EDGE
224 case ClampToEdge:
225 val = engo.Gl.CLAMP_TO_EDGE
226 case ClampToBorder:
227 val = engo.Gl.CLAMP_TO_EDGE
228 case Repeat:
229 val = engo.Gl.REPEAT
230 case MirroredRepeat:
231 val = engo.Gl.MIRRORED_REPEAT
232 }
233 engo.Gl.TexParameteri(engo.Gl.TEXTURE_2D, engo.Gl.TEXTURE_WRAP_S, val)
234 engo.Gl.TexParameteri(engo.Gl.TEXTURE_2D, engo.Gl.TEXTURE_WRAP_T, val)
235
236 s.lastRepeating = ren.Repeat
237 }
238
239 if s.lastMagFilter != ren.magFilter {
240 s.flush()
241 var val int
242 switch ren.magFilter {
243 case FilterNearest:
244 val = engo.Gl.NEAREST
245 case FilterLinear:
246 val = engo.Gl.LINEAR
247 }
248 engo.Gl.TexParameteri(engo.Gl.TEXTURE_2D, engo.Gl.TEXTURE_MAG_FILTER, val)
249
250 s.lastMagFilter = ren.magFilter
251 }
252
253 if s.lastMinFilter != ren.minFilter {
254 s.flush()
255 var val int
256 switch ren.minFilter {
257 case FilterNearest:
258 val = engo.Gl.NEAREST
259 case FilterLinear:
260 val = engo.Gl.LINEAR
261 }
262 engo.Gl.TexParameteri(engo.Gl.TEXTURE_2D, engo.Gl.TEXTURE_MIN_FILTER, val)
263
264 s.lastMinFilter = ren.minFilter
265 }

Callers

nothing calls this directly

Calls 4

flushMethod · 0.95
setTextureMethod · 0.95
updateBufferMethod · 0.95
TextureMethod · 0.65

Tested by

no test coverage detected