Skip to content

Commit

Permalink
Merge branch 'development' into add_screenshot_1342
Browse files Browse the repository at this point in the history
  • Loading branch information
sabadam32 committed Apr 30, 2024
2 parents d9c0178 + 856689a commit 43e6ac5
Show file tree
Hide file tree
Showing 59 changed files with 2,879 additions and 619 deletions.
6 changes: 3 additions & 3 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ python:
- dev

# Build PDF & ePub
formats:
- epub
- pdf
# formats:
# - epub
# - pdf
2 changes: 1 addition & 1 deletion arcade/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0.0-dev.27
3.0.0-dev.28
2 changes: 2 additions & 0 deletions arcade/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ def get_timestamp(
from .draw_commands import draw_lrbt_rectangle_filled
from .draw_commands import draw_lrtb_rectangle_outline
from .draw_commands import draw_lrbt_rectangle_outline
from .draw_commands import draw_lbwh_rectangle_textured
from .draw_commands import draw_lrwh_rectangle_textured
from .draw_commands import draw_parabola_filled
from .draw_commands import draw_parabola_outline
Expand Down Expand Up @@ -340,6 +341,7 @@ def get_timestamp(
'draw_line',
'draw_line_strip',
'draw_lines',
'draw_lbwh_rectangle_textured',
'draw_lrtb_rectangle_filled',
'draw_lrbt_rectangle_filled',
'draw_lrtb_rectangle_outline',
Expand Down
43 changes: 35 additions & 8 deletions arcade/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
from arcade.types import Rect
from PIL import Image

from arcade.camera import Projector
from arcade.camera.default import DefaultProjector

LOG = logging.getLogger(__name__)

Expand Down Expand Up @@ -189,6 +187,7 @@ def __init__(
style=style,
)
self.register_event_type('on_update')
self.register_event_type('on_action')
except pyglet.window.NoSuchConfigException:
raise NoOpenGLException("Unable to create an OpenGL 3.3+ context. "
"Check to make sure your system supports OpenGL 3.3 or higher.")
Expand Down Expand Up @@ -219,8 +218,6 @@ def __init__(
self._background_color: Color = TRANSPARENT_BLACK

self._current_view: Optional[View] = None
self._default_camera = DefaultProjector(window=self)
self.current_camera: Projector = self._default_camera
self.textbox_time = 0.0
self.key: Optional[int] = None
self.flip_count: int = 0
Expand Down Expand Up @@ -539,6 +536,9 @@ def set_mouse_visible(self, visible: bool = True):
"""
super().set_mouse_visible(visible)

def on_action(self, action_name: str, state):
pass

def on_key_press(self, symbol: int, modifiers: int):
"""
Called once when a key gets pushed down.
Expand Down Expand Up @@ -610,8 +610,7 @@ def on_resize(self, width: int, height: int):
# The arcade context is not created at that time
if hasattr(self, "_ctx"):
# Retain projection scrolling if applied
self._ctx.viewport = (0, 0, width, height)
self.default_camera.use()
self.viewport = (0, 0, width, height)

def set_min_size(self, width: int, height: int):
""" Wrap the Pyglet window call to set minimum size
Expand Down Expand Up @@ -684,9 +683,37 @@ def default_camera(self):
"""
Provides a reference to the default arcade camera.
Automatically sets projection and view to the size
of the screen. Good for resetting the screen.
of the screen.
"""
return self._default_camera
return self._ctx._default_camera

@property
def current_camera(self):
"""
Get/Set the current camera. This represents the projector
currently being used to define the projection and view matrices.
"""
return self._ctx.current_camera

@current_camera.setter
def current_camera(self, next_camera):
self._ctx.current_camera = next_camera

@property
def viewport(self) -> tuple[int, int, int, int]:
"""
Get/Set the viewport of the window. This is the viewport used for
on-screen rendering. If the screen is in use it will also update the
default camera.
"""
return self.screen.viewport

@viewport.setter
def viewport(self, new_viewport: tuple[int, int, int, int]):
if self.screen == self._ctx.active_framebuffer:
self._ctx.viewport = new_viewport
else:
self.screen.viewport = new_viewport

def test(self, frames: int = 10):
"""
Expand Down
9 changes: 9 additions & 0 deletions arcade/camera/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
PerspectiveProjectionData
)

from arcade.camera.projection_functions import (
generate_view_matrix,
generate_orthographic_matrix,
generate_perspective_matrix
)

from arcade.camera.orthographic import OrthographicProjector
from arcade.camera.perspective import PerspectiveProjector

Expand All @@ -23,9 +29,12 @@
'Projection',
'Projector',
'CameraData',
'generate_view_matrix',
'OrthographicProjectionData',
'generate_orthographic_matrix',
'OrthographicProjector',
'PerspectiveProjectionData',
'generate_perspective_matrix',
'PerspectiveProjector',
'Camera2D',
'grips'
Expand Down
Loading

0 comments on commit 43e6ac5

Please sign in to comment.