Skip to content
Merged
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: 1 addition & 1 deletion tutorials/whippersnappy_tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@
},
"outputs": [],
"source": [
"Image(filename=outpath_gif)\n"
"display(Image(filename=outpath_gif))\n"
]
}
],
Expand Down
7 changes: 5 additions & 2 deletions whippersnappy/gl/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import logging
import os
import sys
import warnings
from typing import Any

import glfw
Expand Down Expand Up @@ -181,8 +182,10 @@ def init_window(width, height, title="PyOpenGL", visible=True):
window or False
GLFW window handle on success, or False on failure.
"""
if not glfw.init():
return False
with warnings.catch_warnings():
warnings.simplefilter("ignore")
if not glfw.init():
return False

glfw.window_hint(glfw.CONTEXT_VERSION_MAJOR, 3)
glfw.window_hint(glfw.CONTEXT_VERSION_MINOR, 3)
Expand Down
23 changes: 13 additions & 10 deletions whippersnappy/snap.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import logging
import os
import warnings

import glfw
import numpy as np
Expand Down Expand Up @@ -151,16 +152,18 @@ def snap1(
ref_height = 500
ui_scale = min(width / ref_width, height / ref_height)
try:
if glfw.init():
primary_monitor = glfw.get_primary_monitor()
if primary_monitor:
mode = glfw.get_video_mode(primary_monitor)
if width > mode.size.width:
logger.info("Requested width %d exceeds screen width %d, expect black bars",
width, mode.size.width)
elif height > mode.size.height:
logger.info("Requested height %d exceeds screen height %d, expect black bars",
height, mode.size.height)
with warnings.catch_warnings():
warnings.simplefilter("ignore")
if glfw.init():
primary_monitor = glfw.get_primary_monitor()
if primary_monitor:
mode = glfw.get_video_mode(primary_monitor)
if width > mode.size.width:
logger.info("Requested width %d exceeds screen width %d, expect black bars",
width, mode.size.width)
elif height > mode.size.height:
logger.info("Requested height %d exceeds screen height %d, expect black bars",
height, mode.size.height)
except Exception:
pass # headless — no monitor info available, that's fine

Expand Down