Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Flock
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jonathan Kunstwald
Flock
Commits
e24103ab
Commit
e24103ab
authored
6 years ago
by
Jonathan Kunstwald
Browse files
Options
Downloads
Patches
Plain Diff
Code cleanup III
parent
7834586a
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
Flock/flock/src/util/TextureUtils.cc
+18
-20
18 additions, 20 deletions
Flock/flock/src/util/TextureUtils.cc
Flock/flock/src/util/TextureUtils.hh
+1
-1
1 addition, 1 deletion
Flock/flock/src/util/TextureUtils.hh
with
19 additions
and
21 deletions
Flock/flock/src/util/TextureUtils.cc
+
18
−
20
View file @
e24103ab
...
...
@@ -8,42 +8,42 @@ glow::SharedTexture2D flock::tex_utils::generateRandom1DTexture(int extent)
{
auto
tex
=
glow
::
Texture2D
::
create
(
extent
,
1
,
GL_RGBA
);
float
*
pRaw
=
new
float
[
extent
*
4
]
;
unsigned
const
size
=
static_cast
<
unsigned
>
(
extent
)
*
4
u
;
for
(
uint32_t
n
=
0
;
n
<
extent
*
4
;
n
++
)
pRaw
[
n
]
=
rand
()
/
(
float
)
RAND_MAX
;
std
::
vector
<
float
>
randomData
(
size
);
for
(
auto
n
=
0u
;
n
<
size
;
++
n
)
randomData
[
n
]
=
rand
()
/
static_cast
<
float
>
(
RAND_MAX
);
{
auto
boundTex
=
tex
->
bind
();
boundTex
.
setWrap
(
GL_REPEAT
,
GL_REPEAT
);
boundTex
.
setMinFilter
(
GL_LINEAR
);
boundTex
.
setMagFilter
(
GL_LINEAR
);
boundTex
.
setData
(
GL_RGBA
,
extent
,
1
,
GL_RGBA
,
GL_FLOAT
,
pRaw
);
boundTex
.
setData
(
GL_RGBA
,
extent
,
1
,
GL_RGBA
,
GL_FLOAT
,
randomData
.
data
()
);
}
delete
[]
pRaw
;
return
tex
;
}
glow
::
SharedTexture2D
flock
::
tex_utils
::
generateSpotTexture
(
int
width
,
int
height
)
glow
::
SharedTexture2D
flock
::
tex_utils
::
generateSpotTexture
(
unsigned
width
,
unsigned
height
)
{
auto
tex
=
glow
::
Texture2D
::
create
(
width
,
height
,
GL_RED
);
auto
tex
=
glow
::
Texture2D
::
create
(
static_cast
<
int
>
(
width
)
,
static_cast
<
int
>
(
height
)
,
GL_RED
);
u
int8_t
*
pRaw
=
new
uint8_t
[
width
*
height
]
;
u
nsigned
const
size
=
width
*
height
;
const
float
fMaxDist
=
(
float
)
sqrt
(
width
*
height
/
2.
f
);
for
(
uint32_t
y
=
0
;
y
<
height
;
y
++
)
{
for
(
uint32_t
x
=
0
;
x
<
width
;
x
++
)
std
::
vector
<
uint8_t
>
spotData
(
size
);
const
float
fMaxDist
=
std
::
sqrt
(
size
/
2.
f
);
for
(
auto
y
=
0u
;
y
<
height
;
++
y
)
for
(
auto
x
=
0u
;
x
<
width
;
++
x
)
{
float
length
=
(
float
)
sqrt
((
x
-
width
/
2.
f
)
*
(
x
-
width
/
2.
f
)
+
(
y
-
height
/
2.
f
)
*
(
y
-
height
/
2.
f
));
float
length
=
std
::
sqrt
((
x
-
width
/
2.
f
)
*
(
x
-
width
/
2.
f
)
+
(
y
-
height
/
2.
f
)
*
(
y
-
height
/
2.
f
));
float
fSpot
=
(
float
)
pow
f
((
fMaxDist
-
length
)
/
fMaxDist
,
8.
f
);
float
fSpot
=
std
::
pow
((
fMaxDist
-
length
)
/
fMaxDist
,
8.
f
);
fSpot
=
fSpot
>
1.
f
?
1.
f
:
fSpot
;
pRaw
[
x
+
y
*
width
]
=
fSpot
>
0
?
(
uint8_t
)(
fSpot
*
255.
f
)
:
0
;
}
spotData
[
x
+
y
*
width
]
=
fSpot
>
0
?
static_cast
<
uint8_t
>
(
fSpot
*
255.
f
)
:
0
;
}
{
...
...
@@ -51,11 +51,9 @@ glow::SharedTexture2D flock::tex_utils::generateSpotTexture(int width, int heigh
boundTex
.
setWrap
(
GL_CLAMP_TO_EDGE
,
GL_CLAMP_TO_EDGE
);
boundTex
.
setMagFilter
(
GL_LINEAR
);
boundTex
.
setMinFilter
(
GL_LINEAR_MIPMAP_LINEAR
);
boundTex
.
setData
(
GL_RED
,
width
,
height
,
GL_RED
,
GL_UNSIGNED_BYTE
,
pRaw
);
boundTex
.
setData
(
GL_RED
,
static_cast
<
int
>
(
width
)
,
static_cast
<
int
>
(
height
)
,
GL_RED
,
GL_UNSIGNED_BYTE
,
spotData
.
data
()
);
boundTex
.
generateMipmaps
();
}
delete
[]
pRaw
;
return
tex
;
}
This diff is collapsed.
Click to expand it.
Flock/flock/src/util/TextureUtils.hh
+
1
−
1
View file @
e24103ab
...
...
@@ -9,6 +9,6 @@ namespace flock
namespace
tex_utils
{
glow
::
SharedTexture2D
generateRandom1DTexture
(
int
extent
);
glow
::
SharedTexture2D
generateSpotTexture
(
int
width
,
int
height
);
glow
::
SharedTexture2D
generateSpotTexture
(
unsigned
width
,
unsigned
height
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment