Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Johannes Braun
glare
Commits
a409dfd7
Commit
a409dfd7
authored
Jun 11, 2017
by
Johannes Braun
Browse files
Added self-deleting OpenGL handle types.
parent
35445028
Changes
12
Hide whitespace changes
Inline
Side-by-side
src/libraries/engine/Time.h
View file @
a409dfd7
...
...
@@ -144,9 +144,9 @@ namespace glare
class
Query
{
public:
Query
()
{
gl
::
genQueries
(
1
,
&
m_id
);
};
explicit
Query
(
GLuint
id
)
:
m_
id
(
id
)
{
};
~
Query
()
{
gl
::
deleteQueries
(
1
,
&
m_id
);
};
Query
()
{
m_handle
.
generate
(
);
};
explicit
Query
(
GLuint
id
)
{
m_
handle
.
reset
(
id
)
;
};
~
Query
()
{};
Query
(
Query
&&
)
=
delete
;
Query
&
operator
=
(
Query
&&
other
)
=
delete
;
...
...
@@ -155,7 +155,7 @@ namespace glare
/**
* \brief Begins the Query GL_TIME_ELAPSED.
*/
void
issue
()
const
{
gl
::
beginQuery
(
gl
::
QueryTarget
::
eTimeElapsed
,
m_
id
);
};
void
issue
()
const
{
gl
::
beginQuery
(
gl
::
QueryTarget
::
eTimeElapsed
,
m_
handle
);
};
/**
* \brief Ends the Query GL_TIME_ELAPSED, waits for the result and returns it.
...
...
@@ -164,12 +164,12 @@ namespace glare
GLuint64
get
()
const
{
gl
::
endQuery
(
gl
::
QueryTarget
::
eTimeElapsed
);
GLuint64
result
;
gl
::
getQueryObjectui64v
(
m_
id
,
gl
::
QueryObject
::
eResult
,
&
result
);
gl
::
getQueryObjectui64v
(
m_
handle
,
gl
::
QueryObject
::
eResult
,
&
result
);
return
result
;
};
private:
GLuint
m_id
;
gl
::
handle
::
query
m_handle
;
};
ClockGL
();
...
...
src/libraries/engine/graphics/ImageTexture2D.h
View file @
a409dfd7
...
...
@@ -111,7 +111,7 @@ namespace glare
gl
::
TextureFilterMin
m_filter_min
;
gl
::
TextureFilterMag
m_filter_mag
;
unsigned
m_texture_id
;
gl
::
handle
::
texture
m_handle
;
uint64_t
m_texture_id_bindless
;
uint64_t
m_image_id_bindless
;
};
...
...
@@ -281,21 +281,20 @@ namespace glare
template
<
gl
::
TextureFormat
Format
,
gl
::
TextureInternalFormat
InternalFormat
,
gl
::
Type
T
>
Texture
<
Format
,
InternalFormat
,
T
>::
Texture
(
uint32_t
width
,
uint32_t
height
,
tex_type
*
data
,
gl
::
TextureFilterMin
min
,
gl
::
TextureFilterMag
mag
)
{
gl
::
genTextures
(
1
,
&
m_texture_id
);
m_handle
.
generate
(
);
m_filter_min
=
min
;
m_filter_mag
=
mag
;
resize
(
width
,
height
,
data
);
gl
::
bindTexture
(
gl
::
TextureTarget
::
e2D
,
m_
texture_id
);
m_texture_id_bindless
=
gl
::
getTextureHandle
(
m_
texture_id
);
m_image_id_bindless
=
gl
::
getImageHandle
(
m_
texture_id
,
0
,
false
,
0
,
gl
::
ImageUnitFormat
(
InternalFormat
));
gl
::
bindTexture
(
gl
::
TextureTarget
::
e2D
,
m_
handle
);
m_texture_id_bindless
=
gl
::
getTextureHandle
(
m_
handle
);
m_image_id_bindless
=
gl
::
getImageHandle
(
m_
handle
,
0
,
false
,
0
,
gl
::
ImageUnitFormat
(
InternalFormat
));
gl
::
bindTexture
(
gl
::
TextureTarget
::
e2D
,
0
);
}
template
<
gl
::
TextureFormat
Format
,
gl
::
TextureInternalFormat
InternalFormat
,
gl
::
Type
T
>
Texture
<
Format
,
InternalFormat
,
T
>::~
Texture
()
{
glDeleteTextures
(
1
,
&
m_texture_id
);
gl
::
makeTextureHandleNonResident
(
m_texture_id_bindless
);
gl
::
makeImageHandleNonResident
(
m_image_id_bindless
);
}
...
...
@@ -305,7 +304,7 @@ namespace glare
{
m_width
=
width
;
m_height
=
height
;
gl
::
bindTexture
(
gl
::
TextureTarget
::
e2D
,
m_
texture_id
);
gl
::
bindTexture
(
gl
::
TextureTarget
::
e2D
,
m_
handle
);
gl
::
textureParameter
(
gl
::
TextureTarget
::
e2D
,
gl
::
TextureParameter
::
eWrapS
,
gl
::
TextureWrapMode
::
eRepeat
);
gl
::
textureParameter
(
gl
::
TextureTarget
::
e2D
,
gl
::
TextureParameter
::
eWrapT
,
gl
::
TextureWrapMode
::
eRepeat
);
gl
::
textureParameter
(
gl
::
TextureTarget
::
e2D
,
gl
::
TextureParameter
::
eMagFilter
,
m_filter_mag
);
...
...
@@ -321,7 +320,7 @@ namespace glare
{
m_filter_min
=
min
;
m_filter_mag
=
mag
;
gl
::
bindTexture
(
gl
::
TextureTarget
::
e2D
,
m_
texture_id
);
gl
::
bindTexture
(
gl
::
TextureTarget
::
e2D
,
m_
handle
);
gl
::
textureParameter
(
gl
::
TextureTarget
::
e2D
,
gl
::
TextureParameter
::
eMagFilter
,
m_filter_mag
);
gl
::
textureParameter
(
gl
::
TextureTarget
::
e2D
,
gl
::
TextureParameter
::
eMinFilter
,
m_filter_min
);
gl
::
bindTexture
(
gl
::
TextureTarget
::
e2D
,
0
);
...
...
@@ -330,7 +329,7 @@ namespace glare
template
<
gl
::
TextureFormat
Format
,
gl
::
TextureInternalFormat
InternalFormat
,
gl
::
Type
T
>
void
Texture
<
Format
,
InternalFormat
,
T
>::
bindToShader
(
std
::
shared_ptr
<
ShaderProgram
>
shader
,
std
::
string
uniform_name
)
const
{
gl
::
bindTexture
(
gl
::
TextureTarget
::
e2D
,
m_
texture_id
);
gl
::
bindTexture
(
gl
::
TextureTarget
::
e2D
,
m_
handle
);
gl
::
makeTextureHandleResident
(
m_texture_id_bindless
);
shader
->
updateUniformPointer
(
uniform_name
,
m_texture_id_bindless
);
...
...
@@ -340,7 +339,7 @@ namespace glare
template
<
gl
::
TextureFormat
Format
,
gl
::
TextureInternalFormat
InternalFormat
,
gl
::
Type
T
>
void
Texture
<
Format
,
InternalFormat
,
T
>::
bindToShader
(
const
ShaderProgram
&
shader
,
std
::
string
uniform_name
)
const
{
gl
::
bindTexture
(
gl
::
TextureTarget
::
e2D
,
m_
texture_id
);
gl
::
bindTexture
(
gl
::
TextureTarget
::
e2D
,
m_
handle
);
gl
::
makeTextureHandleResident
(
m_texture_id_bindless
);
shader
.
updateUniformPointer
(
uniform_name
,
m_texture_id_bindless
);
gl
::
makeTextureHandleNonResident
(
m_texture_id_bindless
);
...
...
@@ -359,13 +358,13 @@ namespace glare
template
<
gl
::
TextureFormat
Format
,
gl
::
TextureInternalFormat
InternalFormat
,
gl
::
Type
T
>
GLuint
Texture
<
Format
,
InternalFormat
,
T
>::
getID
()
const
{
return
m_
texture_id
;
return
m_
handle
;
}
template
<
gl
::
TextureFormat
Format
,
gl
::
TextureInternalFormat
InternalFormat
,
gl
::
Type
T
>
GLuint64
Texture
<
Format
,
InternalFormat
,
T
>::
getResidentTextureID
()
const
{
gl
::
bindTexture
(
gl
::
TextureTarget
::
e2D
,
m_
texture_id
);
gl
::
bindTexture
(
gl
::
TextureTarget
::
e2D
,
m_
handle
);
gl
::
makeTextureHandleResident
(
m_texture_id_bindless
);
return
m_texture_id_bindless
;
}
...
...
src/libraries/engine/graphics/ImageTexture2DMultisample.h
View file @
a409dfd7
...
...
@@ -45,7 +45,7 @@ namespace glare
unsigned
m_width
;
unsigned
m_height
;
unsigned
m_samples
;
unsigned
m_texture_
id
;
gl
::
handle
::
texture
m_texture_
handle
;
uint64_t
m_texture_id_bindless
;
};
...
...
@@ -68,18 +68,17 @@ namespace glare
template
<
gl
::
TextureInternalFormat
InternalFormat
,
gl
::
Type
T
>
TextureMultisampled
<
InternalFormat
,
T
>::
TextureMultisampled
(
unsigned
width
,
unsigned
height
,
unsigned
samples
)
{
gl
::
genTextures
(
1
,
&
m_texture_id
);
m_texture_handle
.
generate
(
);
resize
(
width
,
height
,
samples
);
gl
::
bindTexture
(
gl
::
TextureTarget
::
e2DMultisample
,
m_texture_
id
);
m_texture_id_bindless
=
gl
::
getTextureHandle
(
m_texture_
id
);
gl
::
bindTexture
(
gl
::
TextureTarget
::
e2DMultisample
,
m_texture_
handle
);
m_texture_id_bindless
=
gl
::
getTextureHandle
(
m_texture_
handle
);
gl
::
bindTexture
(
gl
::
TextureTarget
::
e2DMultisample
,
0
);
}
template
<
gl
::
TextureInternalFormat
InternalFormat
,
gl
::
Type
T
>
TextureMultisampled
<
InternalFormat
,
T
>::~
TextureMultisampled
()
{
glDeleteTextures
(
1
,
&
m_texture_id
);
gl
::
makeTextureHandleNonResident
(
m_texture_id_bindless
);
}
...
...
@@ -89,7 +88,7 @@ namespace glare
m_width
=
width
;
m_height
=
height
;
m_samples
=
samples
;
gl
::
bindTexture
(
gl
::
TextureTarget
::
e2DMultisample
,
m_texture_
id
);
gl
::
bindTexture
(
gl
::
TextureTarget
::
e2DMultisample
,
m_texture_
handle
);
gl
::
pixelStorei
(
gl
::
PixelStoreAlignment
::
eUnpack
,
1
);
gl
::
textureImage2DMultisample
(
gl
::
TextureImageTargetMultisample2D
::
e2DMultisample
,
samples
,
InternalFormat
,
width
,
height
,
false
);
gl
::
bindTexture
(
gl
::
TextureTarget
::
e2DMultisample
,
0
);
...
...
@@ -98,7 +97,7 @@ namespace glare
template
<
gl
::
TextureInternalFormat
InternalFormat
,
gl
::
Type
T
>
void
TextureMultisampled
<
InternalFormat
,
T
>::
bindToShader
(
std
::
shared_ptr
<
ShaderProgram
>
shader
,
std
::
string
uniform_name
)
const
{
gl
::
bindTexture
(
gl
::
TextureTarget
::
e2DMultisample
,
m_texture_
id
);
gl
::
bindTexture
(
gl
::
TextureTarget
::
e2DMultisample
,
m_texture_
handle
);
gl
::
makeTextureHandleResident
(
m_texture_id_bindless
);
shader
->
updateUniformUInt64
(
uniform_name
,
m_texture_id_bindless
);
gl
::
makeTextureHandleNonResident
(
m_texture_id_bindless
);
...
...
@@ -107,7 +106,7 @@ namespace glare
template
<
gl
::
TextureInternalFormat
InternalFormat
,
gl
::
Type
T
>
void
TextureMultisampled
<
InternalFormat
,
T
>::
bindToShader
(
const
ShaderProgram
&
shader
,
std
::
string
uniform_name
)
const
{
gl
::
bindTexture
(
gl
::
TextureTarget
::
e2DMultisample
,
m_texture_
id
);
gl
::
bindTexture
(
gl
::
TextureTarget
::
e2DMultisample
,
m_texture_
handle
);
gl
::
makeTextureHandleResident
(
m_texture_id_bindless
);
shader
.
updateUniformUInt64
(
uniform_name
,
m_texture_id_bindless
);
gl
::
makeTextureHandleNonResident
(
m_texture_id_bindless
);
...
...
@@ -116,13 +115,13 @@ namespace glare
template
<
gl
::
TextureInternalFormat
InternalFormat
,
gl
::
Type
T
>
GLuint
TextureMultisampled
<
InternalFormat
,
T
>::
getID
()
const
{
return
m_texture_
id
;
return
m_texture_
handle
;
}
template
<
gl
::
TextureInternalFormat
InternalFormat
,
gl
::
Type
T
>
GLuint64
TextureMultisampled
<
InternalFormat
,
T
>::
getResidentTextureID
()
const
{
gl
::
bindTexture
(
gl
::
TextureTarget
::
e2DMultisample
,
m_texture_
id
);
gl
::
bindTexture
(
gl
::
TextureTarget
::
e2DMultisample
,
m_texture_
handle
);
gl
::
makeTextureHandleResident
(
m_texture_id_bindless
);
return
m_texture_id_bindless
;
}
...
...
src/libraries/engine/graphics/ImageTexture3D.h
View file @
a409dfd7
...
...
@@ -53,7 +53,7 @@ namespace glare
gl
::
TextureFilterMin
m_filter_min
;
gl
::
TextureFilterMag
m_filter_mag
;
unsigned
m_texture_
id
;
gl
::
handle
::
texture
m_texture_
handle
;
uint64_t
m_texture_id_bindless
;
uint64_t
m_image_id_bindless
;
};
...
...
@@ -83,21 +83,20 @@ namespace glare
template
<
gl
::
TextureFormat
Format
,
gl
::
TextureInternalFormat
InternalFormat
,
gl
::
Type
T
>
Texture3D
<
Format
,
InternalFormat
,
T
>::
Texture3D
(
unsigned
width
,
unsigned
height
,
unsigned
depth
,
tex_type
*
data
,
gl
::
TextureFilterMin
min
,
gl
::
TextureFilterMag
mag
)
{
gl
::
genTextures
(
1
,
&
m_texture_id
);
m_texture_handle
.
generate
(
);
m_filter_min
=
min
;
m_filter_mag
=
mag
;
resize
(
width
,
height
,
depth
,
data
);
gl
::
bindTexture
(
gl
::
TextureTarget
::
e3D
,
m_texture_
id
);
m_texture_id_bindless
=
gl
::
getTextureHandle
(
m_texture_
id
);
m_image_id_bindless
=
gl
::
getImageHandle
(
m_texture_
id
,
0
,
true
,
0
,
gl
::
ImageUnitFormat
(
InternalFormat
));
gl
::
bindTexture
(
gl
::
TextureTarget
::
e3D
,
m_texture_
handle
);
m_texture_id_bindless
=
gl
::
getTextureHandle
(
m_texture_
handle
);
m_image_id_bindless
=
gl
::
getImageHandle
(
m_texture_
handle
,
0
,
true
,
0
,
gl
::
ImageUnitFormat
(
InternalFormat
));
gl
::
bindTexture
(
gl
::
TextureTarget
::
e3D
,
0
);
}
template
<
gl
::
TextureFormat
Format
,
gl
::
TextureInternalFormat
InternalFormat
,
gl
::
Type
T
>
Texture3D
<
Format
,
InternalFormat
,
T
>::~
Texture3D
()
{
glDeleteTextures
(
1
,
&
m_texture_id
);
gl
::
makeTextureHandleNonResident
(
m_texture_id_bindless
);
gl
::
makeImageHandleNonResident
(
m_image_id_bindless
);
}
...
...
@@ -108,7 +107,7 @@ namespace glare
m_width
=
width
;
m_height
=
height
;
m_depth
=
depth
;
gl
::
bindTexture
(
gl
::
TextureTarget
::
e3D
,
m_texture_
id
);
gl
::
bindTexture
(
gl
::
TextureTarget
::
e3D
,
m_texture_
handle
);
gl
::
textureParameter
(
gl
::
TextureTarget
::
e3D
,
gl
::
TextureParameter
::
eWrapS
,
gl
::
TextureWrapMode
::
eRepeat
);
gl
::
textureParameter
(
gl
::
TextureTarget
::
e3D
,
gl
::
TextureParameter
::
eWrapT
,
gl
::
TextureWrapMode
::
eRepeat
);
gl
::
textureParameter
(
gl
::
TextureTarget
::
e3D
,
gl
::
TextureParameter
::
eMagFilter
,
m_filter_mag
);
...
...
@@ -124,7 +123,7 @@ namespace glare
{
m_filter_min
=
min
;
m_filter_mag
=
mag
;
gl
::
bindTexture
(
gl
::
TextureTarget
::
e3D
,
m_texture_
id
);
gl
::
bindTexture
(
gl
::
TextureTarget
::
e3D
,
m_texture_
handle
);
gl
::
textureParameter
(
gl
::
TextureTarget
::
e3D
,
gl
::
TextureParameter
::
eMagFilter
,
m_filter_mag
);
gl
::
textureParameter
(
gl
::
TextureTarget
::
e3D
,
gl
::
TextureParameter
::
eMinFilter
,
m_filter_min
);
gl
::
bindTexture
(
gl
::
TextureTarget
::
e3D
,
0
);
...
...
@@ -133,7 +132,7 @@ namespace glare
template
<
gl
::
TextureFormat
Format
,
gl
::
TextureInternalFormat
InternalFormat
,
gl
::
Type
T
>
void
Texture3D
<
Format
,
InternalFormat
,
T
>::
bindToShader
(
std
::
shared_ptr
<
ShaderProgram
>
shader
,
std
::
string
uniform_name
)
const
{
gl
::
bindTexture
(
gl
::
TextureTarget
::
e3D
,
m_texture_
id
);
gl
::
bindTexture
(
gl
::
TextureTarget
::
e3D
,
m_texture_
handle
);
gl
::
makeTextureHandleResident
(
m_texture_id_bindless
);
shader
->
updateUniformUInt64
(
uniform_name
,
m_texture_id_bindless
);
gl
::
makeTextureHandleNonResident
(
m_texture_id_bindless
);
...
...
@@ -142,7 +141,7 @@ namespace glare
template
<
gl
::
TextureFormat
Format
,
gl
::
TextureInternalFormat
InternalFormat
,
gl
::
Type
T
>
void
Texture3D
<
Format
,
InternalFormat
,
T
>::
bindToShader
(
const
ShaderProgram
&
shader
,
std
::
string
uniform_name
)
const
{
gl
::
bindTexture
(
gl
::
TextureTarget
::
e3D
,
m_texture_
id
);
gl
::
bindTexture
(
gl
::
TextureTarget
::
e3D
,
m_texture_
handle
);
gl
::
makeTextureHandleResident
(
m_texture_id_bindless
);
shader
.
updateUniformUInt64
(
uniform_name
,
m_texture_id_bindless
);
gl
::
makeTextureHandleNonResident
(
m_texture_id_bindless
);
...
...
@@ -160,13 +159,13 @@ namespace glare
template
<
gl
::
TextureFormat
Format
,
gl
::
TextureInternalFormat
InternalFormat
,
gl
::
Type
T
>
GLuint
Texture3D
<
Format
,
InternalFormat
,
T
>::
getID
()
const
{
return
m_texture_
id
;
return
m_texture_
handle
;
}
template
<
gl
::
TextureFormat
Format
,
gl
::
TextureInternalFormat
InternalFormat
,
gl
::
Type
T
>
GLuint64
Texture3D
<
Format
,
InternalFormat
,
T
>::
getResidentTextureID
()
const
{
gl
::
bindTexture
(
gl
::
TextureTarget
::
e3D
,
m_texture_
id
);
gl
::
bindTexture
(
gl
::
TextureTarget
::
e3D
,
m_texture_
handle
);
gl
::
makeTextureHandleResident
(
m_texture_id_bindless
);
return
m_texture_id_bindless
;
}
...
...
src/libraries/engine/rendering/Framebuffer.cpp
View file @
a409dfd7
...
...
@@ -9,7 +9,7 @@ namespace glare
Framebuffer
::
Framebuffer
(
unsigned
int
width
,
unsigned
int
height
)
:
m_width
(
width
),
m_height
(
height
)
{
gl
::
genFramebuffers
(
1
,
&
m_framebuffer_id
);
m_handle
.
generate
(
);
}
void
Framebuffer
::
resize
(
unsigned
int
width
,
unsigned
int
height
)
...
...
@@ -30,7 +30,7 @@ namespace glare
void
Framebuffer
::
activateDepthAttachment
()
{
gl
::
bindFramebuffer
(
gl
::
FramebufferTarget
::
eDefault
,
m_
framebuffer_id
);
gl
::
bindFramebuffer
(
gl
::
FramebufferTarget
::
eDefault
,
m_
handle
);
m_depth_attachment
=
std
::
make_unique
<
Texture_Float
<
gl
::
TextureFormat
::
eDepthComponent
,
gl
::
TextureInternalFormat
::
eDepthComponent32Float
>>
(
m_width
,
m_height
,
nullptr
);
...
...
@@ -50,7 +50,7 @@ namespace glare
void
Framebuffer
::
addColorAttachment
(
gl
::
Attachment
attachment_type
)
{
gl
::
bindFramebuffer
(
gl
::
FramebufferTarget
::
eDefault
,
m_
framebuffer_id
);
gl
::
bindFramebuffer
(
gl
::
FramebufferTarget
::
eDefault
,
m_
handle
);
auto
attachment
=
new
TextureRGBA_32F
(
m_width
,
m_height
,
nullptr
);
m_color_attachments
.
emplace_back
(
attachment
);
...
...
@@ -73,7 +73,6 @@ namespace glare
Framebuffer
::~
Framebuffer
()
{
gl
::
deleteFramebuffers
(
1
,
&
m_framebuffer_id
);
}
void
Framebuffer
::
record
(
std
::
function
<
void
()
>
render_function
)
const
...
...
@@ -119,7 +118,7 @@ namespace glare
void
Framebuffer
::
activate
()
const
{
gl
::
bindFramebuffer
(
gl
::
FramebufferTarget
::
eDefault
,
m_
framebuffer_id
);
gl
::
bindFramebuffer
(
gl
::
FramebufferTarget
::
eDefault
,
m_
handle
);
}
void
Framebuffer
::
deactivate
()
...
...
@@ -130,7 +129,7 @@ namespace glare
FramebufferMultisample
::
FramebufferMultisample
(
unsigned
int
width
,
unsigned
int
height
,
unsigned
samples
)
:
m_width
(
width
),
m_height
(
height
),
m_samples
(
samples
)
{
gl
::
genFramebuffers
(
1
,
&
m_framebuffer_id
);
m_handle
.
generate
(
);
}
void
FramebufferMultisample
::
resize
(
unsigned
int
width
,
unsigned
int
height
,
unsigned
samples
)
...
...
@@ -152,7 +151,7 @@ namespace glare
void
FramebufferMultisample
::
activateDepthAttachment
()
{
gl
::
bindFramebuffer
(
gl
::
FramebufferTarget
::
eDefault
,
m_
framebuffer_id
);
gl
::
bindFramebuffer
(
gl
::
FramebufferTarget
::
eDefault
,
m_
handle
);
m_depth_attachment
=
std
::
make_unique
<
TextureMultisampled_Float
<
gl
::
TextureInternalFormat
::
eDepthComponent32Float
>>
(
m_width
,
m_height
,
m_samples
);
...
...
@@ -172,7 +171,7 @@ namespace glare
void
FramebufferMultisample
::
addColorAttachment
(
gl
::
Attachment
attachment_type
)
{
gl
::
bindFramebuffer
(
gl
::
FramebufferTarget
::
eDefault
,
m_
framebuffer_id
);
gl
::
bindFramebuffer
(
gl
::
FramebufferTarget
::
eDefault
,
m_
handle
);
auto
attachment
=
new
TextureMultisampledRGBA_32F
(
m_width
,
m_height
,
m_samples
);
m_color_attachments
.
emplace_back
(
attachment
);
...
...
@@ -195,7 +194,6 @@ namespace glare
FramebufferMultisample
::~
FramebufferMultisample
()
{
gl
::
deleteFramebuffers
(
1
,
&
m_framebuffer_id
);
}
void
FramebufferMultisample
::
record
(
std
::
function
<
void
()
>
render_function
)
const
...
...
@@ -241,7 +239,7 @@ namespace glare
void
FramebufferMultisample
::
activate
()
const
{
gl
::
bindFramebuffer
(
gl
::
FramebufferTarget
::
eDefault
,
m_
framebuffer_id
);
gl
::
bindFramebuffer
(
gl
::
FramebufferTarget
::
eDefault
,
m_
handle
);
}
void
FramebufferMultisample
::
deactivate
()
...
...
src/libraries/engine/rendering/Framebuffer.h
View file @
a409dfd7
...
...
@@ -40,7 +40,7 @@ namespace glare
void
addColorAttachment
(
gl
::
Attachment
attachment_type
);
void
activateDepthAttachment
();
unsigned
m_
framebuffer
_id
;
gl
::
handle
::
framebuffer
m_handle
;
unsigned
int
m_width
;
unsigned
int
m_height
;
...
...
@@ -82,7 +82,7 @@ namespace glare
void
addColorAttachment
(
gl
::
Attachment
attachment_type
);
void
activateDepthAttachment
();
unsigned
m_
framebuffer
_id
;
gl
::
handle
::
framebuffer
m_handle
;
unsigned
m_samples
;
unsigned
int
m_width
;
...
...
src/libraries/engine/rendering/Shader.cpp
View file @
a409dfd7
...
...
@@ -419,51 +419,51 @@ namespace glare
Shader
::
Shader
(
gl
::
ShaderType
type
)
{
m_shader_
id
=
gl
::
createShader
(
type
);
m_shader_
handle
.
generate
(
type
);
}
Shader
::
Shader
(
gl
::
ShaderType
shader_type
,
fs
::
path
path
)
:
Shader
(
shader_type
)
{
m_shader_id
=
gl
::
createShader
(
shader_type
);
std
::
string
source
=
loadText
((
asset
(
"/shaders/"
))
/
path
);
compileSource
(
source
);
}
void
Shader
::
compileSource
(
const
std
::
string
&
source
)
const
void
Shader
::
compileSource
(
const
std
::
string
&
source
)
{
auto
extensions
=
ShaderLoader
::
loadExtensions
(
source
);
ShaderLoader
::
checkExtensions
(
extensions
);
const
char
*
source_chars
=
source
.
c_str
();
gl
::
shaderSource
(
m_shader_
id
,
1
,
&
source_chars
,
nullptr
);
gl
::
shaderSource
(
m_shader_
handle
,
1
,
&
source_chars
,
nullptr
);
const
char
*
root
=
"/."
;
int
count
=
1
;
if
(
glfwExtensionSupported
(
"GL_ARB_shading_language_include"
))
{
gl
::
compileShaderInclude
(
m_shader_
id
,
1
,
&
root
,
nullptr
);
gl
::
compileShaderInclude
(
m_shader_
handle
,
1
,
&
root
,
nullptr
);
}
else
{
gl
::
compileShader
(
m_shader_
id
);
gl
::
compileShader
(
m_shader_
handle
);
}
int
success
=
0
;
gl
::
getShaderiv
(
m_shader_
id
,
gl
::
GetShaderParameter
::
eCompileStatus
,
&
success
);
gl
::
getShaderiv
(
m_shader_
handle
,
gl
::
GetShaderParameter
::
eCompileStatus
,
&
success
);
if
(
!
success
)
{
int
logSize
=
200
;
gl
::
getShaderiv
(
m_shader_
id
,
gl
::
GetShaderParameter
::
eLogInfoLength
,
&
logSize
);
gl
::
getShaderiv
(
m_shader_
handle
,
gl
::
GetShaderParameter
::
eLogInfoLength
,
&
logSize
);
char
*
log
=
new
char
[
logSize
];
gl
::
getShaderInfoLog
(
m_shader_
id
,
logSize
,
&
logSize
,
log
);
gl
::
getShaderInfoLog
(
m_shader_
handle
,
logSize
,
&
logSize
,
log
);
Log_Error
<<
log
;
gl
::
deleteShader
(
m_shader_id
);
m_shader_handle
.
reset
(
);
delete
[]
log
;
}
else
...
...
@@ -474,17 +474,15 @@ namespace glare
Shader
::~
Shader
()
{
gl
::
deleteShader
(
m_shader_id
);
}
VertexArray
::
VertexArray
()
{
gl
::
gen
V
erte
xArrays
(
1
,
&
m_array_id
);
m_handle
.
gener
a
te
(
);
}
VertexArray
::~
VertexArray
()
{
gl
::
deleteVertexArrays
(
1
,
&
m_array_id
);
}
void
VertexArray
::
draw
(
gl
::
PrimitiveType
primitive
,
size_t
count
,
int
first
)
const
...
...
@@ -511,7 +509,7 @@ namespace glare
void
VertexArray
::
bind
()
const
{
gl
::
bindVertexArray
(
m_
array_id
);
gl
::
bindVertexArray
(
m_
handle
);
}
void
VertexArray
::
unbind
()
...
...
src/libraries/engine/rendering/Shader.h
View file @
a409dfd7
...
...
@@ -100,17 +100,17 @@ namespace glare
~
Shader
();
void
compileSource
(
const
std
::
string
&
source
)
const
;
void
compileSource
(
const
std
::
string
&
source
);
//Getters
unsigned
getID
()
const
{
return
m_shader_
id
;
return
m_shader_
handle
;
}
private:
unsigned
m_shader_
id
;
gl
::
handle
::
shader
m_shader_
handle
;
};
/**
...
...
@@ -171,7 +171,7 @@ namespace glare
uint64_t
makeResident
(
gl
::
Access
access
);
private:
unsigned
m_buffer_id
=
0
;
gl
::
handle
::
buffer
m_handle
;
uint64_t
m_bindless_address
=
0
;
};
...
...
@@ -187,16 +187,16 @@ namespace glare
void
drawElements
(
gl
::
PrimitiveType
primitive
,
size_t
count
,
gl
::
Type
indices_type
,
const
Buffer
<
gl
::
BufferType
::
eElementArray
>
&
element_array_buffer
)
const
;
void
bind
()
const
;
static
void
unbind
();
unsigned
id
()
const
{
return
m_
array_id
;
}
unsigned
id
()
const
{
return
m_
handle
;
}
private:
unsigned
m_array_id
;
gl
::
handle
::
vertex_array
m_handle
;
};
template
<
gl
::
BufferType
Type
>
Buffer
<
Type
>::
Buffer
()
{
gl
::
genBuffers
(
1
,
&
m_buffer_id
);
m_handle
.
generate
(
);
}
template
<
gl
::
BufferType
Type
>
...
...
@@ -217,24 +217,23 @@ namespace glare
template
<
gl
::
BufferType
Type
>
Buffer
<
Type
>::~
Buffer
()
{
if
(
gl
::
isNamedBufferResident
(
m_
buffer_id
))
if
(
gl
::
isNamedBufferResident
(
m_
handle
))
{
gl
::
makeNamedBufferNonResident
(
m_
buffer_id
);
gl
::
makeNamedBufferNonResident
(
m_
handle
);
}
gl
::
deleteBuffers
(
1
,
&
m_buffer_id
);
}
template
<
gl
::
BufferType
Type
>
void
Buffer
<
Type
>::
bind
()
const
{
gl
::
bindBuffer
(
Type
,
m_
buffer_id
);
gl
::
bindBuffer
(
Type
,
m_
handle
);
}
template
<
gl
::
BufferType
Type
>
void
Buffer
<
Type
>::
setData
(
size_t
size
,
gl
::
BufferUsage
mode
,
const
void
*
data
)
const
{
bind
();
gl
::
namedBufferData
(
m_
buffer_id
,
size
,
data
,
mode
);
gl
::
namedBufferData
(
m_
handle
,
size
,
data
,
mode
);
}
template
<
gl
::
BufferType
Type
>
...
...
@@ -249,13 +248,13 @@ namespace glare
ReturnType
*
Buffer
<
Type
>::
map
(
size_t
offset
,
size_t
size
,
gl
::
BufferMapBit
map_access
)
const
{
bind
();
return
reinterpret_cast
<
ReturnType
*>
(
gl
::
mapNamedBufferRange
(
m_
buffer_id
,
offset
,
size
,
map_access
));
return
reinterpret_cast
<
ReturnType
*>
(
gl
::
mapNamedBufferRange
(
m_
handle
,
offset
,
size
,
map_access
));
}
template
<
gl
::
BufferType
Type
>
void
Buffer
<
Type
>::
unmap
()
const
{
gl
::
unmapNamedBuffer
(
m_
buffer_id
);
gl
::
unmapNamedBuffer
(
m_
handle
);
}
template
<
gl
::
BufferType
Type
>
...
...
@@ -264,7 +263,7 @@ namespace glare
bind
();
void
*
output
=
map
(
offset
,
size
,
gl
::
BufferMapBit
::
eRead
);
memcpy
(
out_data
,
output
,
size
);
gl
::
unmapNamedBuffer
(
m_
buffer_id
);
gl
::
unmapNamedBuffer
(
m_
handle
);
}
template
<
gl
::
BufferType
Type
>
...
...
@@ -280,7 +279,7 @@ namespace glare
void
Buffer
<
Type
>::
bindToCurrentShader
(
int
binding_point
)
const
{
bind
();
gl
::
bindBufferBase
(
Type
,
binding_point
,
m_
buffer_id
);
gl
::
bindBufferBase
(
Type
,
binding_point
,
m_
handle
);
}
template
<
gl
::
BufferType
Type
>
...
...
@@ -306,12 +305,12 @@ namespace glare
uint64_t
Buffer
<
Type
>::
makeResident
(
gl
::
Access
access
)
{
bind
();
if
(
!
gl
::
isNamedBufferResident
(
m_
buffer_id
))
if
(
!
gl
::
isNamedBufferResident
(
m_
handle
))
{
gl
::
makeNamedBufferResident
(
m_
buffer_id
,
access
);
gl
::
getNamedBufferParameterui64v
(
m_
buffer_id
,
gl
::
GetNamedBufferParameters
::
eGPUAddress
,
&
m_bindless_address
);
gl
::
makeNamedBufferResident
(
m_
handle
,
access
);
gl
::
getNamedBufferParameterui64v
(
m_
handle
,
gl
::
GetNamedBufferParameters
::
eGPUAddress
,
&
m_bindless_address
);
}
assert
(
gl
::
isNamedBufferResident
(
m_
buffer_id
));