Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GLFW_TRANSPARENT_FRAMEBUFFER #1

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions GLFW.xs
Original file line number Diff line number Diff line change
Expand Up @@ -1343,6 +1343,8 @@ glfwGetMonitorPhysicalSize(GLFWmonitor* monitor, OUTLIST int widthMM, OUTLIST in
void
glfwGetMonitorPos(GLFWmonitor* monitor, OUTLIST int xpos, OUTLIST int ypos);

void
glfwGetMonitorWorkarea(GLFWmonitor* monitor, OUTLIST int xpos, OUTLIST int ypos, OUTLIST int width, OUTLIST int height);

void
glfwSetGamma(GLFWmonitor* monitor, float gamma);
Expand Down
97 changes: 97 additions & 0 deletions examples/windows.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#========================================================================
# Simple multi-window example
# Copyright (c) Camilla Löwy <[email protected]>
#
# This software is provided 'as-is', without any express or implied
# warranty. In no event will the authors be held liable for any damages
# arising from the use of this software.
#
# Permission is granted to anyone to use this software for any purpose,
# including commercial applications, and to alter it and redistribute it
# freely, subject to the following restrictions:
#
# 1. The origin of this software must not be misrepresented; you must not
# claim that you wrote the original software. If you use this software
# in a product, an acknowledgment in the product documentation would
# be appreciated but is not required.
#
# 2. Altered source versions must be plainly marked as such, and must not
# be misrepresented as being the original software.
#
# 3. This notice may not be removed or altered from any source
# distribution.
#
#========================================================================

use OpenGL::GLFW qw(:all);
use OpenGL::Modern qw(:all);
use OpenGL::Modern::Helpers qw(pack_GLfloat);

my $error_callback = sub {
my ( $error, $description ) = @_;
printf STDERR "Error #%d from perl: %s\n", $error, $description;
};

if ( !glfwInit() ) {
die "Failed to initialize GLFW\n";
}

glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
glfwWindowHint(GLFW_DECORATED, GLFW_FALSE);

my $monitor = glfwGetPrimaryMonitor();

my ($xpos,$ypos,$width,$height) = glfwGetMonitorWorkarea($monitor);

my %window;
my @colors = (
[ '0.95', '0.32', '0.11' ],
[ '0.50', '0.80', '0.16' ],
[ '0', '0.68', '0.94' ],
[ '0.98', '0.74', '0.04' ]
);

for (my $i = 0; $i < 4; $i++)
{
my $size = $height / 5;

glfwWindowHint(GLFW_FOCUS_ON_SHOW, GLFW_FALSE) if $i > 0;

$windows{$i} = glfwCreateWindow($size,$size,"Multi-Window Example",NULL,NULL);

if (!$windows{$i})
{
glfwSetErrorCallback( $error_callback );
die "glfwInit failed, $!\n"
}

glfwSetWindowPos($windows{$i}, $xpos + $size * (1 + ($i & 1)), $ypos + $size * (1 + ($i >> 1)));
glfwSetInputMode($windows{$i}, GLFW_STICKY_KEYS, GLFW_TRUE);

glfwMakeContextCurrent($windows{$i});
#gladLoadGL(glfwGetProcAddress);
glClearColor( $colors[$i][0] , $colors[$i][1] , $colors[$i][2] , 1 );
}

for (my $i = 0; $i < 4; $i++) {
glfwShowWindow($windows{$i});
}

for (;;)
{
for (my $i = 0; $i < 4; $i++)
{
glfwMakeContextCurrent($windows{$i});
glClear(GL_COLOR_BUFFER_BIT);
glfwSwapBuffers($windows{$i});

if (glfwWindowShouldClose($windows{$i}) ||
glfwGetKey($windows{$i}, GLFW_KEY_ESCAPE))
{
glfwTerminate();
exit;
}
}

glfwWaitEvents();
}
3 changes: 3 additions & 0 deletions glfw3.xs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ glfwGetMonitorPhysicalSize(GLFWmonitor* monitor, int* widthMM, int* heightMM);
void
glfwGetMonitorPos(GLFWmonitor* monitor, int* xpos, int* ypos);

void
glfwGetMonitorWorkarea (GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height);

void
glfwSetGamma(GLFWmonitor* monitor, float gamma);

Expand Down
5 changes: 5 additions & 0 deletions lib/OpenGL/GLFW.pm
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ use constant GLFW_VRESIZE_CURSOR => 0x00036006;
use constant GLFW_CONNECTED => 0x00040001;
use constant GLFW_DISCONNECTED => 0x00040002;
use constant GLFW_DONT_CARE => -1;
use constant GLFW_TRANSPARENT_FRAMEBUFFER => 0x0002000A;

require Exporter;

Expand Down Expand Up @@ -280,6 +281,7 @@ our %EXPORT_TAGS = ( 'all' => [ qw(
glfwGetMonitorName
glfwGetMonitorPhysicalSize
glfwGetMonitorPos
glfwGetMonitorWorkarea
glfwGetMonitors
glfwGetMouseButton
glfwGetPrimaryMonitor
Expand Down Expand Up @@ -586,6 +588,7 @@ our %EXPORT_TAGS = ( 'all' => [ qw(
GLFW_CONNECTED
GLFW_DISCONNECTED
GLFW_DONT_CARE
GLFW_TRANSPARENT_FRAMEBUFFER
glfwCreateWindowSurface
glfwGetInstanceProcAddress
glfwGetPhysicalDevicePresentationSupport
Expand Down Expand Up @@ -793,6 +796,8 @@ where
($widthMM, $heightMM) = glfwGetMonitorPhysicalSize($monitor)

($xpos, $ypos) = glfwGetMonitorPos($monitor)

($xpos, $ypos, $width, $height) = glfwGetMonitorWorkarea($monitor)

=head2 Gamma Settings

Expand Down