Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
VkCV Framework
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor 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
Vulkan2021
VkCV Framework
Commits
96193aaf
Commit
96193aaf
authored
4 years ago
by
Sebastian Gaida
Browse files
Options
Downloads
Patches
Plain Diff
[
#8
] add basic Window-Class
parent
3baef895
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!9
Resolve "Window creation"
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
config/Sources.cmake
+2
-0
2 additions, 0 deletions
config/Sources.cmake
projects/first_triangle/src/main.cpp
+14
-0
14 additions, 0 deletions
projects/first_triangle/src/main.cpp
src/vkcv/Window.cpp
+50
-0
50 additions, 0 deletions
src/vkcv/Window.cpp
src/vkcv/Window.hpp
+41
-0
41 additions, 0 deletions
src/vkcv/Window.hpp
with
107 additions
and
0 deletions
config/Sources.cmake
+
2
−
0
View file @
96193aaf
...
@@ -2,6 +2,8 @@
...
@@ -2,6 +2,8 @@
set
(
vkcv_sources
set
(
vkcv_sources
${
vkcv_source
}
/vkcv/Context.hpp
${
vkcv_source
}
/vkcv/Context.hpp
${
vkcv_source
}
/vkcv/Context.cpp
${
vkcv_source
}
/vkcv/Context.cpp
${
vkcv_source
}
/vkcv/Window.hpp
${
vkcv_source
}
/vkcv/Window.cpp
${
vkcv_source
}
/vkcv/CoreManager.hpp
${
vkcv_source
}
/vkcv/CoreManager.hpp
${
vkcv_source
}
/vkcv/CoreManager.cpp
${
vkcv_source
}
/vkcv/CoreManager.cpp
)
)
This diff is collapsed.
Click to expand it.
projects/first_triangle/src/main.cpp
+
14
−
0
View file @
96193aaf
#include
<iostream>
#include
<iostream>
#include
<vkcv/Context.hpp>
#include
<vkcv/Context.hpp>
#include
<vkcv/Window.hpp>
#include
<vkcv/CoreManager.hpp>
int
main
(
int
argc
,
const
char
**
argv
)
{
int
main
(
int
argc
,
const
char
**
argv
)
{
vkcv
::
initGLFW
();
vkcv
::
Window
window
=
vkcv
::
Window
::
create
(
"first triangle"
,
800
,
600
,
false
);
vkcv
::
Context
context
=
vkcv
::
Context
::
create
(
vkcv
::
Context
context
=
vkcv
::
Context
::
create
(
"First Triangle"
,
"First Triangle"
,
VK_MAKE_VERSION
(
0
,
0
,
1
)
VK_MAKE_VERSION
(
0
,
0
,
1
)
...
@@ -23,5 +33,9 @@ int main(int argc, const char** argv) {
...
@@ -23,5 +33,9 @@ int main(int argc, const char** argv) {
default:
std
::
cout
<<
"Unknown GPU vendor?! Either you're on an exotic system or your driver is broken..."
<<
std
::
endl
;
default:
std
::
cout
<<
"Unknown GPU vendor?! Either you're on an exotic system or your driver is broken..."
<<
std
::
endl
;
}
}
while
(
window
.
isWindowOpen
())
{
window
.
pollEvents
();
}
vkcv
::
terminateGLFW
();
return
0
;
return
0
;
}
}
This diff is collapsed.
Click to expand it.
src/vkcv/Window.cpp
0 → 100644
+
50
−
0
View file @
96193aaf
#include
"Window.hpp"
#include
"CoreManager.hpp"
namespace
vkcv
{
Window
::
Window
(
GLFWwindow
*
window
)
:
m_window
(
window
)
{
}
Window
::~
Window
()
{
glfwDestroyWindow
(
m_window
);
vkcv
::
terminateGLFW
();
}
Window
Window
::
create
(
const
char
*
windowTitle
,
int
width
,
int
height
,
bool
resizable
)
{
vkcv
::
initGLFW
();
width
=
width
<=
0
?
1
:
width
;
height
=
height
<=
0
?
1
:
height
;
glfwWindowHint
(
GLFW_CLIENT_API
,
GLFW_NO_API
);
glfwWindowHint
(
GLFW_RESIZABLE
,
resizable
?
GLFW_TRUE
:
GLFW_FALSE
);
GLFWwindow
*
window
;
window
=
glfwCreateWindow
(
width
,
height
,
windowTitle
,
nullptr
,
nullptr
);
return
Window
(
window
);
}
bool
Window
::
isWindowOpen
()
const
{
return
!
glfwWindowShouldClose
(
m_window
);
}
void
Window
::
pollEvents
()
{
glfwPollEvents
();
}
GLFWwindow
*
Window
::
getWindow
()
const
{
return
m_window
;
}
int
Window
::
getWidth
()
const
{
int
width
;
glfwGetWindowSize
(
m_window
,
&
width
,
nullptr
);
return
width
;
}
int
Window
::
getHeight
()
const
{
int
height
;
glfwGetWindowSize
(
m_window
,
nullptr
,
&
height
);
return
height
;
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/vkcv/Window.hpp
0 → 100644
+
41
−
0
View file @
96193aaf
#pragma once
#include
<vulkan/vulkan.hpp>
#define GLFW_INCLUDE_VULKAN
#include
<GLFW/glfw3.h>
namespace
vkcv
{
class
Window
final
{
private:
explicit
Window
(
GLFWwindow
*
window
);
GLFWwindow
*
m_window
;
public:
static
Window
create
(
const
char
*
windowTitle
,
int
width
=
-
1
,
int
height
=
-
1
,
bool
resizable
=
false
);
[[
nodiscard
]]
bool
isWindowOpen
()
const
;
static
void
pollEvents
();
[[
nodiscard
]]
GLFWwindow
*
getWindow
()
const
;
[[
nodiscard
]]
int
getWidth
()
const
;
[[
nodiscard
]]
int
getHeight
()
const
;
Window
&
operator
=
(
const
Window
&
other
)
=
delete
;
Window
&
operator
=
(
Window
&&
other
)
=
default
;
virtual
~
Window
();
};
}
\ No newline at end of file
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