This seems neater than exposing get_id() methods to the public.
Texture2D::AsyncLoader still uses get_id() on the PBO for now, since
it's not reasonably possible to name that class as a friend.
*/
class Buffer
{
+ friend class PipelineState;
+ friend class VertexSetup;
+
private:
unsigned id;
unsigned size;
unsigned height = min(source->get_height(), target.get_height());
if(ARB_direct_state_access)
- glBlitNamedFramebuffer(source->get_id(), target.get_id(), 0, 0, width, height, 0, 0, width, height, buffers, GL_NEAREST);
+ glBlitNamedFramebuffer(source->id, target.id, 0, 0, width, height, 0, 0, width, height, buffers, GL_NEAREST);
else
{
- glBindFramebuffer(GL_READ_FRAMEBUFFER, source->get_id());
- glBindFramebuffer(GL_DRAW_FRAMEBUFFER, target.get_id());
+ glBindFramebuffer(GL_READ_FRAMEBUFFER, source->id);
+ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, target.id);
target.refresh();
glBlitFramebuffer(0, 0, width, height, 0, 0, width, height, buffers, GL_NEAREST);
- glBindFramebuffer(GL_FRAMEBUFFER, source->get_id());
+ glBindFramebuffer(GL_FRAMEBUFFER, source->id);
}
}
const Attachment &attch = attachments[i];
if(attch.tex)
{
- GLenum type = attch.tex->get_target();
if(ARB_direct_state_access)
{
- if(type==GL_TEXTURE_2D || type==GL_TEXTURE_2D_MULTISAMPLE || attch.layer<0)
- glNamedFramebufferTexture(id, gl_attach_point, attch.tex->get_id(), attch.level);
+ if(attch.tex->target==GL_TEXTURE_2D || attch.tex->target==GL_TEXTURE_2D_MULTISAMPLE || attch.layer<0)
+ glNamedFramebufferTexture(id, gl_attach_point, attch.tex->id, attch.level);
else
- glNamedFramebufferTextureLayer(id, gl_attach_point, attch.tex->get_id(), attch.level, attch.layer);
+ glNamedFramebufferTextureLayer(id, gl_attach_point, attch.tex->id, attch.level, attch.layer);
}
- else if(type==GL_TEXTURE_2D || type==GL_TEXTURE_2D_MULTISAMPLE)
- glFramebufferTexture2D(GL_FRAMEBUFFER, gl_attach_point, type, attch.tex->get_id(), attch.level);
+ else if(attch.tex->target==GL_TEXTURE_2D || attch.tex->target==GL_TEXTURE_2D_MULTISAMPLE)
+ glFramebufferTexture2D(GL_FRAMEBUFFER, gl_attach_point, attch.tex->target, attch.tex->id, attch.level);
else if(attch.layer<0)
- glFramebufferTexture(GL_FRAMEBUFFER, gl_attach_point, attch.tex->get_id(), attch.level);
- else if(type==GL_TEXTURE_2D_ARRAY)
- glFramebufferTextureLayer(GL_FRAMEBUFFER, gl_attach_point, attch.tex->get_id(), attch.level, attch.layer);
- else if(type==GL_TEXTURE_3D)
- glFramebufferTexture3D(GL_FRAMEBUFFER, gl_attach_point, type, attch.tex->get_id(), attch.level, attch.layer);
- else if(type==GL_TEXTURE_CUBE_MAP)
- glFramebufferTexture2D(GL_FRAMEBUFFER, gl_attach_point, get_gl_cube_face(static_cast<TextureCubeFace>(attch.layer)), attch.tex->get_id(), attch.level);
+ glFramebufferTexture(GL_FRAMEBUFFER, gl_attach_point, attch.tex->id, attch.level);
+ else if(attch.tex->target==GL_TEXTURE_2D_ARRAY)
+ glFramebufferTextureLayer(GL_FRAMEBUFFER, gl_attach_point, attch.tex->id, attch.level, attch.layer);
+ else if(attch.tex->target==GL_TEXTURE_3D)
+ glFramebufferTexture3D(GL_FRAMEBUFFER, gl_attach_point, attch.tex->target, attch.tex->id, attch.level, attch.layer);
+ else if(attch.tex->target==GL_TEXTURE_CUBE_MAP)
+ glFramebufferTexture2D(GL_FRAMEBUFFER, gl_attach_point, get_gl_cube_face(static_cast<TextureCubeFace>(attch.layer)), attch.tex->id, attch.level);
}
else if(ARB_direct_state_access)
glNamedFramebufferTexture(id, gl_attach_point, 0, 0);
for(Attachment &a: attachments)
if(a.tex)
{
- GLenum type = a.tex->get_target();
unsigned w = 0;
unsigned h = 0;
- if(type==GL_TEXTURE_2D)
+ if(a.tex->target==GL_TEXTURE_2D)
{
Texture2D *tex = static_cast<Texture2D *>(a.tex);
w = max(tex->get_width()>>a.level, 1U);
h = max(tex->get_height()>>a.level, 1U);
}
- else if(type==GL_TEXTURE_2D_MULTISAMPLE)
+ else if(a.tex->target==GL_TEXTURE_2D_MULTISAMPLE)
{
Texture2DMultisample *tex = static_cast<Texture2DMultisample *>(a.tex);
w = tex->get_width();
h = tex->get_height();
}
- else if(type==GL_TEXTURE_3D || type==GL_TEXTURE_2D_ARRAY)
+ else if(a.tex->target==GL_TEXTURE_3D || a.tex->target==GL_TEXTURE_2D_ARRAY)
{
Texture3D *tex = static_cast<Texture3D *>(a.tex);
w = max(tex->get_width()>>a.level, 1U);
h = max(tex->get_height()>>a.level, 1U);
}
- else if(type==GL_TEXTURE_CUBE_MAP)
+ else if(a.tex->target==GL_TEXTURE_CUBE_MAP)
{
w = max(static_cast<TextureCube *>(a.tex)->get_size()>>a.level, 1U);
h = w;
*/
class Framebuffer
{
+ friend class Commands;
+ friend class PipelineState;
+
private:
struct Attachment
{
void refresh() const { if(dirty) update(); }
- unsigned get_id() const { return id; }
-
void set_debug_name(const std::string &);
static Framebuffer &system();
{
if(mask&FRAMEBUFFER)
{
- glBindFramebuffer(GL_FRAMEBUFFER, framebuffer ? framebuffer->get_id() : 0);
+ glBindFramebuffer(GL_FRAMEBUFFER, framebuffer ? framebuffer->id : 0);
if(framebuffer)
{
framebuffer->refresh();
}
if(mask&SHPROG)
- glUseProgram(shprog ? shprog->get_id() : 0);
+ glUseProgram(shprog ? shprog->id : 0);
if(mask&VERTEX_SETUP)
{
- glBindVertexArray(vertex_setup ? vertex_setup->get_id() : 0);
+ glBindVertexArray(vertex_setup ? vertex_setup->id : 0);
if(vertex_setup)
{
static Require _req(MSP_primitive_restart);
if(t.texture && t.sampler)
{
if(ARB_direct_state_access)
- glBindTextureUnit(t.binding, t.texture->get_id());
+ glBindTextureUnit(t.binding, t.texture->id);
else
{
glActiveTexture(GL_TEXTURE0+t.binding);
- if(bound_tex_targets[t.binding] && static_cast<int>(t.texture->get_target())!=bound_tex_targets[t.binding])
+ if(bound_tex_targets[t.binding] && static_cast<int>(t.texture->target)!=bound_tex_targets[t.binding])
glBindTexture(bound_tex_targets[t.binding], 0);
- glBindTexture(t.texture->get_target(), t.texture->get_id());
+ glBindTexture(t.texture->target, t.texture->id);
}
- bound_tex_targets[t.binding] = t.texture->get_target();
+ bound_tex_targets[t.binding] = t.texture->target;
- glBindSampler(t.binding, t.sampler->get_id());
- t.sampler->refresh();
+ glBindSampler(t.binding, t.sampler->id);
}
t.changed = false;
if(u.binding>=0)
{
const BufferBackedUniformBlock *block = static_cast<const BufferBackedUniformBlock *>(u.block);
- glBindBufferRange(GL_UNIFORM_BUFFER, u.binding, block->get_buffer()->get_id(), block->get_offset(), block->get_data_size());
+ glBindBufferRange(GL_UNIFORM_BUFFER, u.binding, block->get_buffer()->id, block->get_offset(), block->get_data_size());
bound_uniform_blocks[u.binding] = 1;
}
else
*/
class Program
{
+ friend class PipelineState;
+
public:
class Loader: public DataFile::CollectionObjectLoader<Program>
{
const AttributeInfo &get_attribute_info(const std::string &) const;
int get_attribute_location(const std::string &) const;
- unsigned get_id() const { return id; }
-
void set_debug_name(const std::string &);
private:
void set_stage_debug_name(unsigned, Stage);
*/
class Sampler
{
+ friend class PipelineState;
+
public:
class Loader: public DataFile::ObjectLoader<Sampler>
{
void refresh() const { if(dirty_params) update(); }
- unsigned get_id() const { return id; }
-
void set_debug_name(const std::string &);
};
*/
class Texture: public Resource
{
+ friend class Framebuffer;
+ friend class PipelineState;
protected:
class Loader: public DataFile::CollectionObjectLoader<Texture>
{
with the defined storage. Semantics depend on the type of texture. */
virtual void image(const Graphics::Image &, unsigned = 0) = 0;
- GLenum get_target() const { return target; }
- unsigned get_id() const { return id; }
-
virtual std::uint64_t get_data_size() const { return 0; }
void set_debug_name(const std::string &);
if(dirty&INDEX_BUFFER)
{
if(direct)
- glVertexArrayElementBuffer(id, index_buffer->get_id());
+ glVertexArrayElementBuffer(id, index_buffer->id);
else
- glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, index_buffer->get_id());
+ glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, index_buffer->id);
}
dirty = 0;
if(!direct)
{
Buffer::unbind_scratch();
- glBindBuffer(GL_ARRAY_BUFFER, array.get_buffer()->get_id());
+ glBindBuffer(GL_ARRAY_BUFFER, array.get_buffer()->id);
}
const VertexFormat &fmt = array.get_format();
unsigned stride = fmt.stride();
if(direct)
{
- glVertexArrayVertexBuffer(id, binding, array.get_buffer()->get_id(), 0, stride);
+ glVertexArrayVertexBuffer(id, binding, array.get_buffer()->id, 0, stride);
glVertexArrayBindingDivisor(id, binding, divisor);
}
*/
class VertexSetup
{
+ friend class PipelineState;
+
private:
enum ComponentMask
{
public:
void refresh() const { if(dirty) update(); }
- unsigned get_id() const { return id; }
-
void unload();
void set_debug_name(const std::string &);