From 15feca28cf4bb5d5ad31127eb84fbe073028f67f Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sat, 24 Mar 2007 00:39:49 +0000 Subject: [PATCH] bind --- stepmania/src/RageDisplay.cpp | 44 +++++++++++++++++++++++++++++++++++ stepmania/src/RageDisplay.h | 5 +++- 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/stepmania/src/RageDisplay.cpp b/stepmania/src/RageDisplay.cpp index 20895fa227..1a49f1bb04 100644 --- a/stepmania/src/RageDisplay.cpp +++ b/stepmania/src/RageDisplay.cpp @@ -416,6 +416,21 @@ RageDisplay::RageDisplay() g_ViewStack = MatrixStack(); g_WorldStack = MatrixStack(); g_TextureStack = MatrixStack(); + + // Register with Lua. + { + Lua *L = LUA->Get(); + lua_pushstring( L, "DISPLAY" ); + this->PushSelf( L ); + lua_settable( L, LUA_GLOBALSINDEX ); + LUA->Release( L ); + } +} + +RageDisplay::~RageDisplay() +{ + // Unregister with Lua. + LUA->UnsetGlobal( "DISPLAY" ); } const RageMatrix* RageDisplay::GetCentering() const @@ -955,6 +970,35 @@ void RageCompiledGeometry::Set( const vector &vMeshes, bool bNeedsNormal Change( vMeshes ); } +// lua start +#include "LuaBinding.h" +class LunaRageDisplay: public Luna +{ +public: + static int GetDisplayWidth( T* p, lua_State *L ) + { + VideoModeParams params = p->GetActualVideoModeParams(); + LuaHelpers::Push( L, params.width ); + return 1; + } + + static int GetDisplayHeight( T* p, lua_State *L ) + { + VideoModeParams params = p->GetActualVideoModeParams(); + LuaHelpers::Push( L, params.height ); + return 1; + } + + LunaRageDisplay() + { + ADD_METHOD( GetDisplayWidth ); + ADD_METHOD( GetDisplayHeight ); + } +}; + +LUA_REGISTER_CLASS( RageDisplay ) +// lua end + /* * Copyright (c) 2001-2004 Chris Danford, Glenn Maynard * All rights reserved. diff --git a/stepmania/src/RageDisplay.h b/stepmania/src/RageDisplay.h index eda7ce176b..657b7b6b17 100644 --- a/stepmania/src/RageDisplay.h +++ b/stepmania/src/RageDisplay.h @@ -172,7 +172,7 @@ public: virtual const PixelFormatDesc *GetPixelFormatDesc( PixelFormat pf ) const = 0; RageDisplay(); - virtual ~RageDisplay() { } + virtual ~RageDisplay(); virtual RString Init( const VideoModeParams &p, bool bAllowUnacceleratedRenderer ) = 0; @@ -378,6 +378,9 @@ public: RageSurface *CreateSurfaceFromPixfmt( PixelFormat pixfmt, void *pixels, int width, int height, int pitch ); PixelFormat FindPixelFormat( int bpp, int Rmask, int Gmask, int Bmask, int Amask, bool realtime=false ); + // Lua + void PushSelf( lua_State *L ); + protected: RageMatrix GetPerspectiveMatrix( float fovy, float aspect, float zNear, float zFar );