Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Project_Phoenix
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LuFG VR VIS
VR-Group
Project_Phoenix
Merge requests
!158
#473 resize companion window
Code
Review changes
Check out branch
Download
Patches
Plain diff
Open
#473 resize companion window
feature/#473_resize_companion_window
into
master
Overview
6
Commits
9
Pipelines
0
Changes
4
1 unresolved thread
Hide all comments
Open
Jan Delember
requested to merge
feature/#473_resize_companion_window
into
master
6 years ago
Overview
6
Commits
9
Pipelines
0
Changes
4
1 unresolved thread
Hide all comments
Expand
1
0
Merge request reports
Compare
master
master (base)
and
latest version
latest version
02e2bfce
9 commits,
6 years ago
4 files
+
75
−
33
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
4
Search (e.g. *.vue) (Ctrl+P)
library/phx/rendering/render_passes/blit_pass.cpp
+
60
−
25
Options
@@ -22,39 +22,74 @@
#include
"phx/rendering/render_passes/blit_pass.hpp"
#include
<memory>
#include
"phx/suppress_warnings.hpp"
namespace
phx
{
SUPPRESS_WARNINGS_BEGIN
#include
"gl/texture.hpp"
#include
"glm/vec2.hpp"
SUPPRESS_WARNINGS_END
BlitPass
::
BlitPass
(
RenderTarget
*
render_target
)
:
render_target_
(
render_target
)
{}
namespace
phx
{
void
BlitPass
::
Initialize
()
{
default_framebuffer_
=
std
::
make_unique
<
gl
::
framebuffer
>
(
0
);
BlitPass
::
BlitPass
(
gl
::
framebuffer
*
source
,
gl
::
framebuffer
*
target
)
:
source_
(
source
)
{
target_
=
target
;
}
BlitPass
::
BlitPass
(
gl
::
framebuffer
*
source
,
Window
*
target
)
:
source_
(
source
)
{
target_
=
target
;
}
void
BlitPass
::
Initialize
()
{}
void
BlitPass
::
Execute
()
{
const
glm
::
uvec2
&
source_dims
=
render_target_
->
GetDimensions
();
const
GLint
source_width
=
static_cast
<
int
>
(
source_dims
.
x
);
const
GLint
source_height
=
static_cast
<
int
>
(
source_dims
.
y
);
GLint
target_dims
[
4
]
=
{
0
};
glGetIntegerv
(
GL_VIEWPORT
,
target_dims
);
const
GLint
target_width
=
target_dims
[
2
];
const
GLint
target_height
=
target_dims
[
3
];
GLint
source_x
=
0
;
GLint
source_y
=
0
;
if
(
target_width
<
source_width
)
{
source_x
=
(
source_width
-
target_width
)
/
2
;
gl
::
framebuffer
default_framebuffer
(
0
);
GLint
viewport
[
4
]
=
{
0
};
glGetIntegerv
(
GL_VIEWPORT
,
viewport
);
const
auto
viewport_size
=
glm
::
ivec2
{
viewport
[
2
],
viewport
[
3
]};
glm
::
ivec2
source_size
;
if
(
source_
)
{
const
auto
type
=
source_
->
object_type
(
GL_COLOR_ATTACHMENT0
);
const
auto
name
=
source_
->
object_name
(
GL_COLOR_ATTACHMENT0
);
if
(
type
==
GL_TEXTURE
)
{
gl
::
texture_2d
texture
(
name
);
source_size
=
{
texture
.
width
(),
texture
.
height
()};
}
else
if
(
type
==
GL_RENDERBUFFER
)
{
gl
::
renderbuffer
renderbuffer
(
name
);
source_size
=
{
renderbuffer
.
width
(),
renderbuffer
.
height
()};
}
else
/* type == GL_NONE || type == GL_FRAMEBUFFER_DEFAULT */
{
source_size
=
viewport_size
;
}
}
else
{
source_
=
&
default_framebuffer
;
source_size
=
viewport_size
;
}
if
(
target_height
<
source_height
)
{
source_y
=
(
source_height
-
target_height
)
/
2
;
glm
::
ivec2
target_size
;
gl
::
framebuffer
*
target
=
nullptr
;
if
(
target_
.
type
()
==
typeid
(
gl
::
framebuffer
*
))
{
target
=
boost
::
get
<
gl
::
framebuffer
*>
(
target_
);
const
auto
type
=
target
->
object_type
(
GL_COLOR_ATTACHMENT0
);
const
auto
name
=
target
->
object_name
(
GL_COLOR_ATTACHMENT0
);
if
(
type
==
GL_TEXTURE
)
{
gl
::
texture_2d
texture
(
name
);
target_size
=
{
texture
.
width
(),
texture
.
height
()};
}
else
if
(
type
==
GL_RENDERBUFFER
)
{
gl
::
renderbuffer
renderbuffer
(
name
);
target_size
=
{
renderbuffer
.
width
(),
renderbuffer
.
height
()};
}
else
/* type == GL_NONE || type == GL_FRAMEBUFFER_DEFAULT */
{
target_size
=
viewport_size
;
}
}
else
{
target
=
&
default_framebuffer
;
target_size
=
boost
::
get
<
Window
*>
(
target_
)
->
GetSize
();
}
default_framebuffer_
->
blit
(
*
render_target_
,
source_x
,
source_y
,
target_width
,
target_height
,
0
,
0
,
target_width
,
target_height
,
GL_COLOR_BUFFER_BIT
|
GL_DEPTH_BUFFER_BIT
,
GL_NEAREST
);
target
->
blit
(
*
source_
,
0
,
0
,
source_size
[
0
],
source_size
[
1
],
0
,
0
,
target_size
[
0
],
target_size
[
1
],
GL_COLOR_BUFFER_BIT
|
GL_DEPTH_BUFFER_BIT
,
GL_NEAREST
);
}
}
// namespace phx
Loading