RenderSetup is called by the material render setup
(gs *gls.GLS, slotIdx, uniIdx int)
| 340 | |
| 341 | // RenderSetup is called by the material render setup |
| 342 | func (t *Texture2D) RenderSetup(gs *gls.GLS, slotIdx, uniIdx int) { // Could have as input - TEXTURE0 (slot) and uni location |
| 343 | |
| 344 | // One time initialization |
| 345 | if t.gs == nil { |
| 346 | t.texname = gs.GenTexture() |
| 347 | t.gs = gs |
| 348 | } |
| 349 | |
| 350 | // Sets the texture unit for this texture |
| 351 | gs.ActiveTexture(uint32(gls.TEXTURE0 + slotIdx)) |
| 352 | gs.BindTexture(gls.TEXTURE_2D, t.texname) |
| 353 | |
| 354 | // Transfer texture data to OpenGL if necessary |
| 355 | if t.updateData { |
| 356 | if t.compressed { |
| 357 | gs.CompressedTexImage2D( |
| 358 | gls.TEXTURE_2D, |
| 359 | 0, |
| 360 | uint32(t.iformat), |
| 361 | t.width, |
| 362 | t.height, |
| 363 | t.size, |
| 364 | t.data, |
| 365 | ) |
| 366 | } else { |
| 367 | gs.TexImage2D( |
| 368 | gls.TEXTURE_2D, // texture type |
| 369 | 0, // level of detail |
| 370 | t.iformat, // internal format |
| 371 | t.width, // width in texels |
| 372 | t.height, // height in texels |
| 373 | t.format, // format of supplied texture data |
| 374 | t.formatType, // type of external format color component |
| 375 | t.data, // image data |
| 376 | ) |
| 377 | } |
| 378 | // Generates mipmaps if requested |
| 379 | if t.genMipmap { |
| 380 | gs.GenerateMipmap(gls.TEXTURE_2D) |
| 381 | } |
| 382 | // No data to send |
| 383 | t.updateData = false |
| 384 | } |
| 385 | |
| 386 | // Sets texture parameters if needed |
| 387 | if t.updateParams { |
| 388 | gs.TexParameteri(gls.TEXTURE_2D, gls.TEXTURE_MAG_FILTER, int32(t.magFilter)) |
| 389 | gs.TexParameteri(gls.TEXTURE_2D, gls.TEXTURE_MIN_FILTER, int32(t.minFilter)) |
| 390 | gs.TexParameteri(gls.TEXTURE_2D, gls.TEXTURE_WRAP_S, int32(t.wrapS)) |
| 391 | gs.TexParameteri(gls.TEXTURE_2D, gls.TEXTURE_WRAP_T, int32(t.wrapT)) |
| 392 | t.updateParams = false |
| 393 | } |
| 394 | |
| 395 | // Transfer texture unit uniform |
| 396 | var location int32 |
| 397 | if uniIdx == 0 { |
| 398 | location = t.uniUnit.Location(gs) |
| 399 | } else { |
nothing calls this directly
no test coverage detected