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

Method Draw

common/render_shaders_blendmap.go:295–371  ·  view source on GitHub ↗
(ren *RenderComponent, space *SpaceComponent)

Source from the content-addressed store, hash-verified

293}
294
295func (s *blendmapShader) Draw(ren *RenderComponent, space *SpaceComponent) {
296 bm, ok := ren.Drawable.(Blendmap)
297 if !ok {
298 panic("only blendmap drawables are supported by blendmap shader.")
299 }
300 if bm.TexturePack == nil || bm.TexturePack.Fallback == nil {
301 panic("No Textures.")
302 }
303
304 if s.lastTexturePack != bm.TexturePack {
305 s.flush()
306 s.bindTexturePack(bm.TexturePack)
307 if s.lastTexture == bm.Texture() {
308 // if its a different texture we will update the scale with the texture.
309 s.updateScale(bm)
310 }
311 s.lastTexturePack = bm.TexturePack
312 }
313
314 if s.lastTexture != ren.Drawable.Texture() {
315 s.flush()
316
317 engo.Gl.BindTexture(engo.Gl.TEXTURE_2D, ren.Drawable.Texture())
318 s.updateScale(bm)
319
320 s.lastTexture = ren.Drawable.Texture()
321 } else if s.idx == len(s.vertices) {
322 s.flush()
323 }
324
325 if s.lastRepeating != ren.Repeat {
326 s.flush()
327 var val int
328 switch ren.Repeat {
329 case NoRepeat:
330 val = engo.Gl.CLAMP_TO_EDGE
331 case ClampToEdge:
332 val = engo.Gl.CLAMP_TO_EDGE
333 case ClampToBorder:
334 val = engo.Gl.CLAMP_TO_EDGE
335 case Repeat:
336 val = engo.Gl.REPEAT
337 case MirroredRepeat:
338 val = engo.Gl.MIRRORED_REPEAT
339 }
340 engo.Gl.TexParameteri(engo.Gl.TEXTURE_2D, engo.Gl.TEXTURE_WRAP_S, val)
341 engo.Gl.TexParameteri(engo.Gl.TEXTURE_2D, engo.Gl.TEXTURE_WRAP_T, val)
342 }
343
344 if s.lastMagFilter != ren.magFilter {
345 s.flush()
346 var val int
347 switch ren.magFilter {
348 case FilterNearest:
349 val = engo.Gl.NEAREST
350 case FilterLinear:
351 val = engo.Gl.LINEAR
352 }

Callers

nothing calls this directly

Calls 5

flushMethod · 0.95
bindTexturePackMethod · 0.95
updateScaleMethod · 0.95
updateBufferMethod · 0.95
TextureMethod · 0.65

Tested by

no test coverage detected