Renderer test function in main.cpp

svn-id: r31832
This commit is contained in:
Vicent Marti 2008-05-02 17:53:21 +00:00
parent 4fd1f92901
commit b50d430192
3 changed files with 53 additions and 4 deletions

View file

@ -43,7 +43,11 @@
#include "gui/newgui.h" #include "gui/newgui.h"
#include "gui/message.h" #include "gui/message.h"
#if defined(_WIN32_WCE) #define _VECTOR_RENDERER_DBG 1
#if defined(_VECTOR_RENDERER_DBG)
#include "graphics/VectorRenderer.h"
#elif defined(_WIN32_WCE)
#include "backends/platform/wince/CELauncherDialog.h" #include "backends/platform/wince/CELauncherDialog.h"
#elif defined(__DC__) #elif defined(__DC__)
#include "backends/platform/dc/DCLauncherDialog.h" #include "backends/platform/dc/DCLauncherDialog.h"
@ -67,6 +71,13 @@ static bool launcherDialog(OSystem &system) {
// Clear the main screen // Clear the main screen
system.clearScreen(); system.clearScreen();
#if defined(_VECTOR_RENDERER_DBG)
Graphics::vector_renderer_test( &system );
return true;
#else
#if defined(_WIN32_WCE) #if defined(_WIN32_WCE)
CELauncherDialog dlg; CELauncherDialog dlg;
#elif defined(__DC__) #elif defined(__DC__)
@ -75,6 +86,8 @@ static bool launcherDialog(OSystem &system) {
GUI::LauncherDialog dlg; GUI::LauncherDialog dlg;
#endif #endif
return (dlg.runModal() != -1); return (dlg.runModal() != -1);
#endif // vector renderer debug
} }
static const Plugin *detectPlugin() { static const Plugin *detectPlugin() {

View file

@ -27,13 +27,43 @@
#include "graphics/surface.h" #include "graphics/surface.h"
#include "graphics/VectorRenderer.h" #include "graphics/VectorRenderer.h"
#include "graphics/colormasks.h" #include "graphics/colormasks.h"
#include "common/system.h"
namespace Graphics { namespace Graphics {
VectorRenderer *createRenderer() { VectorRenderer *createRenderer() {
return new VectorRendererAA<uint16,ColorMasks<565>>; return new VectorRendererSpec<uint16,ColorMasks<565>>;
} }
void vector_renderer_test( OSystem *_system ) {
VectorRenderer *vr = createRenderer();
Surface _screen;
_screen.create(_system->getOverlayWidth(), _system->getOverlayHeight(), sizeof(OverlayColor));
if (!_screen.pixels)
return;
_system->clearOverlay();
_system->grabOverlay((OverlayColor*)_screen.pixels, _screen.w);
vr->setSurface( &_screen );
vr->setColor( 255, 255, 255 );
_system->showOverlay();
while( true ) { // draw!!
vr->drawLine( 25, 100, 25, 150 );
_system->copyRectToOverlay((OverlayColor*)_screen.getBasePtr(0, 0), _screen.w, 0, 0, _screen.w, _screen.w);
_system->updateScreen();
_system->delayMillis(100);
}
_system->hideOverlay();
}
template<typename PixelType, typename PixelFormat> template<typename PixelType, typename PixelFormat>
void VectorRendererSpec<PixelType,PixelFormat>:: void VectorRendererSpec<PixelType,PixelFormat>::
drawLineAlg(int x1, int x2, int y1, int y2, int dx, int dy) { drawLineAlg(int x1, int x2, int y1, int y2, int dx, int dy) {
@ -83,8 +113,7 @@ drawLineAlg(int x1, int x2, int y1, int y2, int dx, int dy) {
template<typename PixelType, typename PixelFormat> template<typename PixelType, typename PixelFormat>
void VectorRendererAA<PixelType,PixelFormat>:: void VectorRendererAA<PixelType,PixelFormat>::
drawLineAlg(int x1, int x2, int y1, int y2, int dx, int dy) drawLineAlg(int x1, int x2, int y1, int y2, int dx, int dy) {
{
PixelType *ptr = (PixelType *)_activeSurface->getBasePtr(x1, y1); PixelType *ptr = (PixelType *)_activeSurface->getBasePtr(x1, y1);
int pitch = surfacePitch(); int pitch = surfacePitch();
int xdir = (x2 > x1) ? 1 : -1; int xdir = (x2 > x1) ? 1 : -1;

View file

@ -28,9 +28,12 @@
#include "common/scummsys.h" #include "common/scummsys.h"
#include "graphics/surface.h" #include "graphics/surface.h"
#include "common/system.h"
namespace Graphics { namespace Graphics {
void vector_renderer_test( OSystem *_system );
/** /**
* VectorRenderer: The core Vector Renderer Class * VectorRenderer: The core Vector Renderer Class
* *
@ -104,6 +107,10 @@ public:
*/ */
virtual void setColor(uint8 r, uint8 g, uint8 b, uint8 a) = 0; virtual void setColor(uint8 r, uint8 g, uint8 b, uint8 a) = 0;
virtual void setSurface( Surface *surface ){
_activeSurface = surface;
}
protected: protected:
/** /**