mirror of
https://github.com/CrispyPin/sinpin-vr.git
synced 2024-11-10 04:20:25 +01:00
grab entire screen(s), lower framerate
This commit is contained in:
parent
06d9b171a0
commit
2242c2c824
1 changed files with 12 additions and 6 deletions
18
src/main.cpp
18
src/main.cpp
|
@ -9,8 +9,10 @@
|
||||||
|
|
||||||
static vr::ETrackingUniverseOrigin TRACKING_UNIVERSE = vr::ETrackingUniverseOrigin::TrackingUniverseStanding;
|
static vr::ETrackingUniverseOrigin TRACKING_UNIVERSE = vr::ETrackingUniverseOrigin::TrackingUniverseStanding;
|
||||||
|
|
||||||
#define WIDTH 1024
|
#define FRAMERATE 30
|
||||||
#define HEIGHT 1024
|
|
||||||
|
uint16_t width;
|
||||||
|
uint16_t height;
|
||||||
|
|
||||||
Display *xdisplay;
|
Display *xdisplay;
|
||||||
Window root_window;
|
Window root_window;
|
||||||
|
@ -32,12 +34,16 @@ int main(int argc, char **argv)
|
||||||
assert(xdisplay != nullptr);
|
assert(xdisplay != nullptr);
|
||||||
printf("Created X11 display\n");
|
printf("Created X11 display\n");
|
||||||
root_window = XRootWindow(xdisplay, 0);
|
root_window = XRootWindow(xdisplay, 0);
|
||||||
|
XWindowAttributes attributes;
|
||||||
|
XGetWindowAttributes(xdisplay, root_window, &attributes);
|
||||||
|
width = attributes.width;
|
||||||
|
height = attributes.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
assert(glfwInit() == true);
|
assert(glfwInit() == true);
|
||||||
glfwWindowHint(GLFW_VISIBLE, false);
|
glfwWindowHint(GLFW_VISIBLE, false);
|
||||||
gl_window = glfwCreateWindow(WIDTH, HEIGHT, "Overlay", nullptr, nullptr);
|
gl_window = glfwCreateWindow(width, height, "Overlay", nullptr, nullptr);
|
||||||
assert(gl_window != nullptr);
|
assert(gl_window != nullptr);
|
||||||
glfwMakeContextCurrent(gl_window);
|
glfwMakeContextCurrent(gl_window);
|
||||||
printf("Created GLFW context\n");
|
printf("Created GLFW context\n");
|
||||||
|
@ -82,8 +88,8 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
auto frame = XGetImage(xdisplay, root_window, 0, 0, WIDTH, HEIGHT, AllPlanes, ZPixmap);
|
auto frame = XGetImage(xdisplay, root_window, 0, 0, width, height, AllPlanes, ZPixmap);
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, WIDTH, HEIGHT, 0, GL_BGRA, GL_UNSIGNED_BYTE, frame->data);
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, frame->data);
|
||||||
XDestroyImage(frame);
|
XDestroyImage(frame);
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -97,7 +103,7 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
glfwSwapBuffers(gl_window);
|
glfwSwapBuffers(gl_window);
|
||||||
|
|
||||||
ovr_overlay->WaitFrameSync(20);
|
usleep(1000000 / FRAMERATE);
|
||||||
}
|
}
|
||||||
cleanup();
|
cleanup();
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in a new issue