MCPcopy Create free account
hub / github.com/davideberly/GeometricTools / EnableTextures

Method EnableTextures

GTE/Graphics/GL46/GL46Engine.cpp:584–623  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

582}
583
584void GL46Engine::EnableTextures(Shader const* shader, GLuint program)
585{
586 int32_t const index = TextureSingle::shaderDataLookup;
587 for (auto const& ts : shader->GetData(index))
588 {
589 if (!ts.object)
590 {
591 LogError(ts.name + " is null texture.");
592 }
593
594 auto texture = static_cast<GL46TextureSingle*>(Bind(ts.object));
595 if (!texture)
596 {
597 LogError("Failed to bind texture.");
598 }
599
600 // By convension, ts.isGpuWritable is true for "image*" and false
601 // for "sampler*".
602 GLuint handle = texture->GetGLHandle();
603 if (ts.isGpuWritable)
604 {
605 // For "image*" objects in the shader, use "readonly" or
606 // "writeonly" attributes in the layout to control R/W/RW access
607 // using shader compiler and then connect as GL_READ_WRITE here.
608 // Always bind level 0 and all layers.
609 GLint unit = mTextureImageUnitMap.AcquireUnit(program, ts.bindPoint);
610 glUniform1i(ts.bindPoint, unit);
611 uint32_t format = texture->GetTexture()->GetFormat();
612 GLuint internalFormat = texture->GetInternalFormat(format);
613 glBindImageTexture(unit, handle, 0, GL_TRUE, 0, GL_READ_WRITE, internalFormat);
614 }
615 else
616 {
617 GLint unit = mTextureSamplerUnitMap.AcquireUnit(program, ts.bindPoint);
618 glUniform1i(ts.bindPoint, unit);
619 glActiveTexture(GL_TEXTURE0 + unit);
620 glBindTexture(texture->GetTarget(), handle);
621 }
622 }
623}
624
625void GL46Engine::DisableTextures(Shader const* shader, GLuint program)
626{

Callers

nothing calls this directly

Calls 11

glUniform1iFunction · 0.85
glBindImageTextureFunction · 0.85
glActiveTextureFunction · 0.85
glBindTextureFunction · 0.85
GetGLHandleMethod · 0.80
AcquireUnitMethod · 0.80
GetInternalFormatMethod · 0.80
GetTargetMethod · 0.80
GetDataMethod · 0.45
GetFormatMethod · 0.45
GetTextureMethod · 0.45

Tested by

no test coverage detected