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
b3c5ceea
Commit
b3c5ceea
authored
Aug 24, 2017
by
Johannes Braun
Browse files
Added instanced collector and the ability to render instanced objects with the pathtracer
parent
e3ee56f2
Changes
14
Hide whitespace changes
Inline
Side-by-side
src/libraries/core/base/buffer.h
View file @
b3c5ceea
...
...
@@ -81,6 +81,26 @@ namespace glare::core
template
<
typename
TReturn
=
void
>
TReturn
*
map
(
size_t
count
,
gl
::
BufferMapBit
flags
)
const
;
void
unmap
()
const
;
template
<
typename
T
>
struct
MappedBuffer
{
MappedBuffer
(
Buffer
*
buffer
,
gl
::
BufferMapBit
flags
,
size_t
offset
=
0
);
~
MappedBuffer
();
T
&
operator
[](
size_t
idx
);
const
T
&
operator
[](
size_t
idx
)
const
;
T
&
at
(
size_t
idx
);
const
T
&
at
(
size_t
idx
)
const
;
private:
T
*
m_data
;
Buffer
*
m_buffer
;
};
template
<
typename
T
>
MappedBuffer
<
T
>
mapScoped
(
size_t
offset
,
gl
::
BufferMapBit
flags
);
template
<
typename
T
>
MappedBuffer
<
T
>
mapScoped
(
gl
::
BufferMapBit
flags
);
int64_t
size
()
const
;
protected:
...
...
@@ -91,7 +111,55 @@ namespace glare::core
// -------------------------------------------------------------------------------------------------------------------------
// --- IMPLEMENTATIONS -----------------------------------------------------------------------------------------------------
// -------------------------------------------------------------------------------------------------------------------------
template
<
typename
T
>
Buffer
::
MappedBuffer
<
T
>::
MappedBuffer
(
Buffer
*
buffer
,
gl
::
BufferMapBit
flags
,
size_t
offset
=
0
)
:
m_buffer
(
buffer
),
m_data
(
buffer
->
map
<
T
>
(
buffer
->
size
()
/
sizeof
(
T
),
offset
,
flags
))
{
}
template
<
typename
T
>
Buffer
::
MappedBuffer
<
T
>::~
MappedBuffer
()
{
m_buffer
->
unmap
();
}
template
<
typename
T
>
T
&
Buffer
::
MappedBuffer
<
T
>::
operator
[](
size_t
idx
)
{
return
m_data
[
idx
];
}
template
<
typename
T
>
const
T
&
Buffer
::
MappedBuffer
<
T
>::
operator
[](
size_t
idx
)
const
{
return
m_data
[
idx
];
}
template
<
typename
T
>
T
&
Buffer
::
MappedBuffer
<
T
>::
at
(
size_t
idx
)
{
if
(
idx
>=
m_buffer
->
size
())
throw
std
::
out_of_range
(
"Trying to access an out-of-bounds element."
);
return
(
*
this
)[
idx
];
}
template
<
typename
T
>
const
T
&
Buffer
::
MappedBuffer
<
T
>::
at
(
size_t
idx
)
const
{
return
at
(
idx
);
}
template
<
typename
T
>
Buffer
::
MappedBuffer
<
T
>
Buffer
::
mapScoped
(
size_t
offset
,
gl
::
BufferMapBit
flags
)
{
return
MappedBuffer
<
T
>
(
this
,
flags
,
offset
);
}
template
<
typename
T
>
Buffer
::
MappedBuffer
<
T
>
Buffer
::
mapScoped
(
gl
::
BufferMapBit
flags
)
{
return
MappedBuffer
<
T
>
(
this
,
flags
);
}
template
<
typename
T
>
void
Buffer
::
upload
(
size_t
count
,
const
T
*
data
,
gl
::
BufferUsage
usage
)
const
{
...
...
src/libraries/core/base/program.cpp
View file @
b3c5ceea
...
...
@@ -56,12 +56,12 @@ namespace glare::core
for
(
int
i
=
0
;
i
<
num_uniforms
;
++
i
)
{
UniformInfo
data
;
int
length
=
max_length
;
char
*
name
=
new
char
[
length
];
gl
::
getActiveUniform
(
m_handle
,
i
,
length
,
&
data
.
size
,
&
data
.
type
,
name
);
data
.
name
=
name
;
data
.
index
=
uniformLocation
(
name
);
int
length
=
max_length
;
char
*
name
=
new
char
[
length
];
gl
::
getActiveUniform
(
m_handle
,
i
,
length
,
&
data
.
size
,
&
data
.
type
,
name
);
data
.
name
=
name
;
data
.
index
=
uniformLocation
(
name
);
m_uniforms
[
data
.
name
]
=
data
;
if
(
data
.
size
>
1
&&
std
::
string
(
data
.
name
.
data
()
+
data
.
name
.
length
()
-
3
)
==
"[0]"
)
...
...
@@ -92,18 +92,18 @@ namespace glare::core
for
(
int
sr
=
0
;
sr
<
num_subroutines
;
++
sr
)
{
int
length
;
char
*
name
=
new
char
[
max_length
];
gl
::
getActiveSubroutineName
(
m_handle
,
shader
->
type
(),
sr
,
max_length
,
&
length
,
name
);
SubroutineInfo
info
;
info
.
index
=
sr
;
info
.
name
=
name
;
info
.
shader_type
=
shader
->
type
();
m_subroutines
[
info
.
name
].
emplace
(
info
.
shader_type
,
info
);
delete
[]
name
;
int
length
;
char
*
name
=
new
char
[
max_length
];
gl
::
getActiveSubroutineName
(
m_handle
,
shader
->
type
(),
sr
,
max_length
,
&
length
,
name
);
SubroutineInfo
info
;
info
.
index
=
sr
;
info
.
name
=
name
;
info
.
shader_type
=
shader
->
type
();
m_subroutines
[
info
.
name
].
emplace
(
info
.
shader_type
,
info
);
delete
[]
name
;
}
}
...
...
@@ -219,163 +219,163 @@ namespace glare::core
{
switch
(
type
)
{
case
gl
::
UniformType
::
eFloat
:
gl
::
programUniform1f
(
m_handle
,
location
,
*
(
reinterpret_cast
<
const
float
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eFloat2
:
gl
::
programUniform2fv
(
m_handle
,
location
,
1
,
(
reinterpret_cast
<
const
float
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eFloat3
:
gl
::
programUniform3fv
(
m_handle
,
location
,
1
,
(
reinterpret_cast
<
const
float
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eFloat4
:
gl
::
programUniform4fv
(
m_handle
,
location
,
1
,
(
reinterpret_cast
<
const
float
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eDouble
:
gl
::
programUniform1d
(
m_handle
,
location
,
*
(
reinterpret_cast
<
const
double
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eDouble2
:
gl
::
programUniform2dv
(
m_handle
,
location
,
1
,
(
reinterpret_cast
<
const
double
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eDouble3
:
gl
::
programUniform3dv
(
m_handle
,
location
,
1
,
(
reinterpret_cast
<
const
double
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eDouble4
:
gl
::
programUniform4dv
(
m_handle
,
location
,
1
,
(
reinterpret_cast
<
const
double
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eBool
:
case
gl
::
UniformType
::
eInt
:
gl
::
programUniform1i
(
m_handle
,
location
,
*
(
reinterpret_cast
<
const
int
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eBool2
:
case
gl
::
UniformType
::
eInt2
:
gl
::
programUniform2iv
(
m_handle
,
location
,
1
,
(
reinterpret_cast
<
const
int
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eBool3
:
case
gl
::
UniformType
::
eInt3
:
gl
::
programUniform3iv
(
m_handle
,
location
,
1
,
(
reinterpret_cast
<
const
int
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eBool4
:
case
gl
::
UniformType
::
eInt4
:
gl
::
programUniform4iv
(
m_handle
,
location
,
1
,
(
reinterpret_cast
<
const
int
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eUInt
:
gl
::
programUniform1ui
(
m_handle
,
location
,
*
(
reinterpret_cast
<
const
unsigned
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eUInt2
:
gl
::
programUniform2uiv
(
m_handle
,
location
,
1
,
(
reinterpret_cast
<
const
unsigned
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eUInt3
:
gl
::
programUniform3uiv
(
m_handle
,
location
,
1
,
(
reinterpret_cast
<
const
unsigned
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eUInt4
:
gl
::
programUniform4uiv
(
m_handle
,
location
,
1
,
(
reinterpret_cast
<
const
unsigned
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eFloatMat2
:
gl
::
programUniformMatrix2fv
(
m_handle
,
location
,
1
,
false
,
(
reinterpret_cast
<
const
float
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eFloatMat3
:
gl
::
programUniformMatrix3fv
(
m_handle
,
location
,
1
,
false
,
(
reinterpret_cast
<
const
float
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eFloatMat4
:
gl
::
programUniformMatrix4fv
(
m_handle
,
location
,
1
,
false
,
(
reinterpret_cast
<
const
float
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eFloatMat2x3
:
gl
::
programUniformMatrix2x3fv
(
m_handle
,
location
,
1
,
false
,
(
reinterpret_cast
<
const
float
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eFloatMat2x4
:
gl
::
programUniformMatrix2x4fv
(
m_handle
,
location
,
1
,
false
,
(
reinterpret_cast
<
const
float
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eFloatMat3x2
:
gl
::
programUniformMatrix3x2fv
(
m_handle
,
location
,
1
,
false
,
(
reinterpret_cast
<
const
float
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eFloatMat3x4
:
gl
::
programUniformMatrix3x4fv
(
m_handle
,
location
,
1
,
false
,
(
reinterpret_cast
<
const
float
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eFloatMat4x2
:
gl
::
programUniformMatrix4x2fv
(
m_handle
,
location
,
1
,
false
,
(
reinterpret_cast
<
const
float
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eFloatMat4x3
:
gl
::
programUniformMatrix4x3fv
(
m_handle
,
location
,
1
,
false
,
(
reinterpret_cast
<
const
float
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eDoubleMat2
:
gl
::
programUniformMatrix2dv
(
m_handle
,
location
,
1
,
false
,
(
reinterpret_cast
<
const
double
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eDoubleMat3
:
gl
::
programUniformMatrix3dv
(
m_handle
,
location
,
1
,
false
,
(
reinterpret_cast
<
const
double
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eDoubleMat4
:
gl
::
programUniformMatrix4dv
(
m_handle
,
location
,
1
,
false
,
(
reinterpret_cast
<
const
double
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eDoubleMat2x3
:
gl
::
programUniformMatrix2x3dv
(
m_handle
,
location
,
1
,
false
,
(
reinterpret_cast
<
const
double
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eDoubleMat2x4
:
gl
::
programUniformMatrix2x4dv
(
m_handle
,
location
,
1
,
false
,
(
reinterpret_cast
<
const
double
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eDoubleMat3x2
:
gl
::
programUniformMatrix3x2dv
(
m_handle
,
location
,
1
,
false
,
(
reinterpret_cast
<
const
double
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eDoubleMat3x4
:
gl
::
programUniformMatrix3x4dv
(
m_handle
,
location
,
1
,
false
,
(
reinterpret_cast
<
const
double
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eDoubleMat4x2
:
gl
::
programUniformMatrix4x2dv
(
m_handle
,
location
,
1
,
false
,
(
reinterpret_cast
<
const
double
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eDoubleMat4x3
:
gl
::
programUniformMatrix4x3dv
(
m_handle
,
location
,
1
,
false
,
(
reinterpret_cast
<
const
double
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eGPUAddress
:
case
gl
::
UniformType
::
eUInt64
:
gl
::
programUniformui64
(
m_handle
,
location
,
*
(
reinterpret_cast
<
const
uint64_t
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eSampler1d
:
case
gl
::
UniformType
::
eSampler2d
:
case
gl
::
UniformType
::
eSampler3d
:
case
gl
::
UniformType
::
eSamplerCube
:
case
gl
::
UniformType
::
eSampler1dShadow
:
case
gl
::
UniformType
::
eSampler2dShadow
:
case
gl
::
UniformType
::
eSampler1dArray
:
case
gl
::
UniformType
::
eSampler2dArray
:
case
gl
::
UniformType
::
eSampler1dArrayShadow
:
case
gl
::
UniformType
::
eSampler2dArrayShadow
:
case
gl
::
UniformType
::
eSampler2dMultisample
:
case
gl
::
UniformType
::
eSampler2dMultisampleArray
:
case
gl
::
UniformType
::
eSamplerCubeShadow
:
case
gl
::
UniformType
::
eSamplerBuffer
:
case
gl
::
UniformType
::
eSampler2dRect
:
case
gl
::
UniformType
::
eSampler2dRectShadow
:
case
gl
::
UniformType
::
eIntSampler1d
:
case
gl
::
UniformType
::
eIntSampler2d
:
case
gl
::
UniformType
::
eIntSampler3d
:
case
gl
::
UniformType
::
eIntSamplerCube
:
case
gl
::
UniformType
::
eIntSampler1dArray
:
case
gl
::
UniformType
::
eIntSampler2dArray
:
case
gl
::
UniformType
::
eIntSampler2dMultisample
:
case
gl
::
UniformType
::
eIntSampler2dMultisampleArray
:
case
gl
::
UniformType
::
eIntSamplerBuffer
:
case
gl
::
UniformType
::
eIntSampler2dRect
:
case
gl
::
UniformType
::
eUIntSampler1d
:
case
gl
::
UniformType
::
eUIntSampler2d
:
case
gl
::
UniformType
::
eUIntSampler3d
:
case
gl
::
UniformType
::
eUIntSamplerCube
:
case
gl
::
UniformType
::
eUIntSampler1dArray
:
case
gl
::
UniformType
::
eUIntSampler2dArray
:
case
gl
::
UniformType
::
eUIntSampler2dMultisample
:
case
gl
::
UniformType
::
eUIntSampler2dMultisampleArray
:
case
gl
::
UniformType
::
eUIntSamplerBuffer
:
case
gl
::
UniformType
::
eUIntSampler2dRect
:
case
gl
::
UniformType
::
eImage1d
:
case
gl
::
UniformType
::
eImage2d
:
case
gl
::
UniformType
::
eImage3d
:
case
gl
::
UniformType
::
eImage2dRect
:
case
gl
::
UniformType
::
eFloat
:
gl
::
programUniform1f
(
m_handle
,
location
,
*
(
reinterpret_cast
<
const
float
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eFloat2
:
gl
::
programUniform2fv
(
m_handle
,
location
,
1
,
(
reinterpret_cast
<
const
float
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eFloat3
:
gl
::
programUniform3fv
(
m_handle
,
location
,
1
,
(
reinterpret_cast
<
const
float
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eFloat4
:
gl
::
programUniform4fv
(
m_handle
,
location
,
1
,
(
reinterpret_cast
<
const
float
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eDouble
:
gl
::
programUniform1d
(
m_handle
,
location
,
*
(
reinterpret_cast
<
const
double
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eDouble2
:
gl
::
programUniform2dv
(
m_handle
,
location
,
1
,
(
reinterpret_cast
<
const
double
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eDouble3
:
gl
::
programUniform3dv
(
m_handle
,
location
,
1
,
(
reinterpret_cast
<
const
double
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eDouble4
:
gl
::
programUniform4dv
(
m_handle
,
location
,
1
,
(
reinterpret_cast
<
const
double
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eBool
:
case
gl
::
UniformType
::
eInt
:
gl
::
programUniform1i
(
m_handle
,
location
,
*
(
reinterpret_cast
<
const
int
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eBool2
:
case
gl
::
UniformType
::
eInt2
:
gl
::
programUniform2iv
(
m_handle
,
location
,
1
,
(
reinterpret_cast
<
const
int
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eBool3
:
case
gl
::
UniformType
::
eInt3
:
gl
::
programUniform3iv
(
m_handle
,
location
,
1
,
(
reinterpret_cast
<
const
int
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eBool4
:
case
gl
::
UniformType
::
eInt4
:
gl
::
programUniform4iv
(
m_handle
,
location
,
1
,
(
reinterpret_cast
<
const
int
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eUInt
:
gl
::
programUniform1ui
(
m_handle
,
location
,
*
(
reinterpret_cast
<
const
unsigned
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eUInt2
:
gl
::
programUniform2uiv
(
m_handle
,
location
,
1
,
(
reinterpret_cast
<
const
unsigned
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eUInt3
:
gl
::
programUniform3uiv
(
m_handle
,
location
,
1
,
(
reinterpret_cast
<
const
unsigned
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eUInt4
:
gl
::
programUniform4uiv
(
m_handle
,
location
,
1
,
(
reinterpret_cast
<
const
unsigned
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eFloatMat2
:
gl
::
programUniformMatrix2fv
(
m_handle
,
location
,
1
,
false
,
(
reinterpret_cast
<
const
float
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eFloatMat3
:
gl
::
programUniformMatrix3fv
(
m_handle
,
location
,
1
,
false
,
(
reinterpret_cast
<
const
float
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eFloatMat4
:
gl
::
programUniformMatrix4fv
(
m_handle
,
location
,
1
,
false
,
(
reinterpret_cast
<
const
float
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eFloatMat2x3
:
gl
::
programUniformMatrix2x3fv
(
m_handle
,
location
,
1
,
false
,
(
reinterpret_cast
<
const
float
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eFloatMat2x4
:
gl
::
programUniformMatrix2x4fv
(
m_handle
,
location
,
1
,
false
,
(
reinterpret_cast
<
const
float
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eFloatMat3x2
:
gl
::
programUniformMatrix3x2fv
(
m_handle
,
location
,
1
,
false
,
(
reinterpret_cast
<
const
float
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eFloatMat3x4
:
gl
::
programUniformMatrix3x4fv
(
m_handle
,
location
,
1
,
false
,
(
reinterpret_cast
<
const
float
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eFloatMat4x2
:
gl
::
programUniformMatrix4x2fv
(
m_handle
,
location
,
1
,
false
,
(
reinterpret_cast
<
const
float
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eFloatMat4x3
:
gl
::
programUniformMatrix4x3fv
(
m_handle
,
location
,
1
,
false
,
(
reinterpret_cast
<
const
float
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eDoubleMat2
:
gl
::
programUniformMatrix2dv
(
m_handle
,
location
,
1
,
false
,
(
reinterpret_cast
<
const
double
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eDoubleMat3
:
gl
::
programUniformMatrix3dv
(
m_handle
,
location
,
1
,
false
,
(
reinterpret_cast
<
const
double
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eDoubleMat4
:
gl
::
programUniformMatrix4dv
(
m_handle
,
location
,
1
,
false
,
(
reinterpret_cast
<
const
double
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eDoubleMat2x3
:
gl
::
programUniformMatrix2x3dv
(
m_handle
,
location
,
1
,
false
,
(
reinterpret_cast
<
const
double
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eDoubleMat2x4
:
gl
::
programUniformMatrix2x4dv
(
m_handle
,
location
,
1
,
false
,
(
reinterpret_cast
<
const
double
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eDoubleMat3x2
:
gl
::
programUniformMatrix3x2dv
(
m_handle
,
location
,
1
,
false
,
(
reinterpret_cast
<
const
double
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eDoubleMat3x4
:
gl
::
programUniformMatrix3x4dv
(
m_handle
,
location
,
1
,
false
,
(
reinterpret_cast
<
const
double
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eDoubleMat4x2
:
gl
::
programUniformMatrix4x2dv
(
m_handle
,
location
,
1
,
false
,
(
reinterpret_cast
<
const
double
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eDoubleMat4x3
:
gl
::
programUniformMatrix4x3dv
(
m_handle
,
location
,
1
,
false
,
(
reinterpret_cast
<
const
double
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eGPUAddress
:
case
gl
::
UniformType
::
eUInt64
:
gl
::
programUniformui64
(
m_handle
,
location
,
*
(
reinterpret_cast
<
const
uint64_t
*>
(
data
)));
break
;
case
gl
::
UniformType
::
eSampler1d
:
case
gl
::
UniformType
::
eSampler2d
:
case
gl
::
UniformType
::
eSampler3d
:
case
gl
::
UniformType
::
eSamplerCube
:
case
gl
::
UniformType
::
eSampler1dShadow
:
case
gl
::
UniformType
::
eSampler2dShadow
:
case
gl
::
UniformType
::
eSampler1dArray
:
case
gl
::
UniformType
::
eSampler2dArray
:
case
gl
::
UniformType
::
eSampler1dArrayShadow
:
case
gl
::
UniformType
::
eSampler2dArrayShadow
:
case
gl
::
UniformType
::
eSampler2dMultisample
:
case
gl
::
UniformType
::
eSampler2dMultisampleArray
:
case
gl
::
UniformType
::
eSamplerCubeShadow
:
case
gl
::
UniformType
::
eSamplerBuffer
:
case
gl
::
UniformType
::
eSampler2dRect
:
case
gl
::
UniformType
::
eSampler2dRectShadow
:
case
gl
::
UniformType
::
eIntSampler1d
:
case
gl
::
UniformType
::
eIntSampler2d
:
case
gl
::
UniformType
::
eIntSampler3d
:
case
gl
::
UniformType
::
eIntSamplerCube
:
case
gl
::
UniformType
::
eIntSampler1dArray
:
case
gl
::
UniformType
::
eIntSampler2dArray
:
case
gl
::
UniformType
::
eIntSampler2dMultisample
:
case
gl
::
UniformType
::
eIntSampler2dMultisampleArray
:
case
gl
::
UniformType
::
eIntSamplerBuffer
:
case
gl
::
UniformType
::
eIntSampler2dRect
:
case
gl
::
UniformType
::
eUIntSampler1d
:
case
gl
::
UniformType
::
eUIntSampler2d
:
case
gl
::
UniformType
::
eUIntSampler3d
:
case
gl
::
UniformType
::
eUIntSamplerCube
:
case
gl
::
UniformType
::
eUIntSampler1dArray
:
case
gl
::
UniformType
::
eUIntSampler2dArray
:
case
gl
::
UniformType
::
eUIntSampler2dMultisample
:
case
gl
::
UniformType
::
eUIntSampler2dMultisampleArray
:
case
gl
::
UniformType
::
eUIntSamplerBuffer
:
case
gl
::
UniformType
::
eUIntSampler2dRect
:
case
gl
::
UniformType
::
eImage1d
:
case
gl
::
UniformType
::
eImage2d
:
case
gl
::
UniformType
::
eImage3d
:
case
gl
::
UniformType
::
eImage2dRect
:
case
gl
::
UniformType
::
eImageCube
:
case
gl
::
UniformType
::
eImageBuffer
:
case
gl
::
UniformType
::
eImage1dArray
:
...
...
@@ -403,7 +403,7 @@ namespace glare::core
case
gl
::
UniformType
::
eUIntImage2dMultisample
:
case
gl
::
UniformType
::
eUIntImage2dMultisampleArray
:
case
gl
::
UniformType
::
eUIntImageAtomicCounter
:
gl
::
programUniformui64
(
m_handle
,
location
,
*
reinterpret_cast
<
const
uint64_t
*>
(
data
));
gl
::
programUniformui64
(
m_handle
,
location
,
*
reinterpret_cast
<
const
uint64_t
*>
(
data
));
break
;
}
}
...
...
src/libraries/core/numeric/geometry.h
View file @
b3c5ceea
...
...
@@ -140,7 +140,7 @@ namespace math
std
::
vector
<
math
::
Bounds
>
threaded_bounds
(
concurrency
);
#pragma omp parallel for default(none) num_threads(concurrency) schedule(static)
for
(
auto
i
=
0
;
i
<
container
.
size
();
++
i
)
for
(
auto
i
=
0
;
i
<
static_cast
<
int
>
(
container
.
size
()
)
;
++
i
)
{
//calculate triangle centroid
threaded_bounds
[
omp_get_thread_num
()].
expand
(
make_value
(
container
[
i
],
static_cast
<
size_t
>
(
i
)));
...
...
src/libraries/core/objects/mesh.cpp
View file @
b3c5ceea
#include
"mesh.h"
#include
"util/padding.h"
namespace
glare
::
core
{
Mesh
::
Mesh
(
std
::
vector
<
math
::
Vertex
>
&
vertices
,
std
::
vector
<
unsigned
int
>
&
indices
)
:
m_vertices
(
std
::
move
(
vertices
)),
m_indices
(
std
::
move
(
indices
))
int64_t
Mesh
::
m_current_id
=
0
;
Mesh
::
Mesh
(
std
::
vector
<
math
::
Vertex
>
&
vertices
,
std
::
vector
<
unsigned
int
>
&
indices
)
:
m_id
(
++
m_current_id
),
m_vertices
(
std
::
move
(
vertices
)),
m_indices
(
std
::
move
(
indices
))
{
initialize
();
}
Mesh
::
Mesh
()
:
m_id
(
++
m_current_id
)
{
m_vertices
.
push_back
({
glm
::
vec4
(
1.
f
,
1.
f
,
-
1.
f
,
1
),
...
...
@@ -113,19 +117,15 @@ namespace glare::core
{
computeTangents
();
m_array_buffer
=
std
::
make_unique
<
Buffer
>
();
m_element_array_buffer
=
std
::
make_unique
<
Buffer
>
();
m_vertex_array
=
std
::
make_unique
<
VertexArray
>
();
m_array_buffer
->
upload
(
m_vertices
,
gl
::
BufferUsage
::
eStaticDraw
);
m_element_array_buffer
->
upload
(
m_indices
,
gl
::
BufferUsage
::
eStaticDraw
);
m_array_buffer
.
upload
(
m_vertices
,
gl
::
BufferUsage
::
eStaticDraw
);
m_element_array_buffer
.
upload
(
m_indices
,
gl
::
BufferUsage
::
eStaticDraw
);
m_vertex_array
->
linkAttribute
(
m_array_buffer
->
id
(),
static_cast
<
unsigned
>
(
VertexAttribLocation
::
ePosition
),
4
,
gl
::
Type
::
eFloat
,
false
,
sizeof
(
math
::
Vertex
),
0
);
m_vertex_array
->
linkAttribute
(
m_array_buffer
->
id
(),
static_cast
<
unsigned
>
(
VertexAttribLocation
::
eNormal
),
4
,
gl
::
Type
::
eFloat
,
false
,
sizeof
(
math
::
Vertex
),
sizeof
(
glm
::
vec4
));
m_vertex_array
->
linkAttribute
(
m_array_buffer
->
id
(),
static_cast
<
unsigned
>
(
VertexAttribLocation
::
eTexcoord
),
2
,
gl
::
Type
::
eFloat
,
false
,
sizeof
(
math
::
Vertex
),
2
*
sizeof
(
glm
::
vec4
));
//Length of 2, but there is a padding in-between.
m_vertex_array
->
linkAttribute
(
m_array_buffer
->
id
(),
static_cast
<
unsigned
>
(
VertexAttribLocation
::
eTangent
),
4
,
gl
::
Type
::
eFloat
,
false
,
sizeof
(
math
::
Vertex
),
3
*
sizeof
(
glm
::
vec4
));
m_vertex_array
->
linkAttribute
(
m_array_buffer
->
id
(),
static_cast
<
unsigned
>
(
VertexAttribLocation
::
eBitangend
),
4
,
gl
::
Type
::
eFloat
,
false
,
sizeof
(
math
::
Vertex
),
4
*
sizeof
(
glm
::
vec4
));
m_vertex_array
->
linkIndices
(
m_element_array_buffer
->
id
());
m_vertex_array
.
linkAttribute
(
m_array_buffer
.
id
(),
static_cast
<
unsigned
>
(
VertexAttribLocation
::
ePosition
),
4
,
gl
::
Type
::
eFloat
,
false
,
sizeof
(
math
::
Vertex
),
offset_of
(
&
math
::
Vertex
::
position
)
);
m_vertex_array
.
linkAttribute
(
m_array_buffer
.
id
(),
static_cast
<
unsigned
>
(
VertexAttribLocation
::
eNormal
),
4
,
gl
::
Type
::
eFloat
,
false
,
sizeof
(
math
::
Vertex
),
offset_of
(
&
math
::
Vertex
::
normal
));
m_vertex_array
.
linkAttribute
(
m_array_buffer
.
id
(),
static_cast
<
unsigned
>
(
VertexAttribLocation
::
eTexcoord
),
2
,
gl
::
Type
::
eFloat
,
false
,
sizeof
(
math
::
Vertex
),
offset_of
(
&
math
::
Vertex
::
texcoord
));
m_vertex_array
.
linkAttribute
(
m_array_buffer
.
id
(),
static_cast
<
unsigned
>
(
VertexAttribLocation
::
eTangent
),
4
,
gl
::
Type
::
eFloat
,
false
,
sizeof
(
math
::
Vertex
),
offset_of
(
&
math
::
Vertex
::
tangent
));
m_vertex_array
.
linkAttribute
(
m_array_buffer
.
id
(),
static_cast
<
unsigned
>
(
VertexAttribLocation
::
eBitangend
),
4
,
gl
::
Type
::
eFloat
,
false
,
sizeof
(
math
::
Vertex
),
offset_of
(
&
math
::
Vertex
::
bitangent
));
m_vertex_array
.
linkIndices
(
m_element_array_buffer
.
id
());
}
const
std
::
vector
<
math
::
Vertex
>&
Mesh
::
getVertices
()
const
...
...
@@ -138,10 +138,6 @@ namespace glare::core
return
m_indices
;
}
Mesh
::~
Mesh
()
{
}
void
Mesh
::
computeTangents
()
{
...
...
@@ -179,8 +175,13 @@ namespace glare::core
void
Mesh
::
draw
()
{
m_vertex_array
->
bind
();
m_vertex_array
.
bind
();
gl
::
drawElements
(
gl
::
PrimitiveType
::
eTriangles
,
m_indices
.
size
(),
gl
::
Type
::
eUInt
,
nullptr
);
m_vertex_array
->
unbind
();
m_vertex_array
.
unbind
();
}
int64_t
Mesh
::
id
()
const
{
return
m_id
;
}
}
src/libraries/core/objects/mesh.h
View file @
b3c5ceea
...
...
@@ -27,7 +27,7 @@ namespace glare::core
Mesh
();
Mesh
(
std
::
vector
<
math
::
Vertex
>
&
vertices
,
std
::
vector
<
unsigned
int
>
&
indices
);
virtual
~
Mesh
();
virtual
~
Mesh
()
=
default
;
virtual
void
draw
();
...
...
@@ -36,15 +36,19 @@ namespace glare::core
const
std
::
vector
<
math
::
Vertex
>&
getVertices
()
const
;
const
std
::
vector
<
unsigned
>&
getIndices
()
const
;
int64_t
id
()
const
;
protected:
static
int64_t
m_current_id
;
const
int64_t
m_id
;
void
computeTangents
();
std
::
vector
<
math
::
Vertex
>
m_vertices
;
std
::
vector
<
unsigned
int
>
m_indices
;
std
::
unique_ptr
<
Buffer
>
m_array_buffer
;
std
::
unique_ptr
<
Buffer
>
m_element_array_buffer
;
std
::
unique_ptr
<
VertexArray
>
m_vertex_array
;