view TaskManager/Test/test_render/viewerSDL.cpp @ 168:cf2aa37d2fe7

Delete DrawSpan::get_pixel().
author gongo@localhost.localdomain
date Thu, 11 Dec 2008 10:38:28 +0900
parents 5c194c71eca8
children cd1c289f952d
line wrap: on
line source

#include "viewerSDL.h"
#include "Func.h"
#include "TaskManager.h"

extern void post2runLoop(void *);

extern

void
ViewerSDL::video_init()
{
    Uint32 sdl_flag = default_sdl_flag | SDL_INIT_VIDEO;
    Uint32 *p;

    if (SDL_Init(sdl_flag) < 0) {
	fprintf(stderr,"Couldn't initialize SDL: %s\n", SDL_GetError());
	exit(1);
    }

    screen = SDL_SetVideoMode(width, height, bpp, SDL_SWSURFACE);
    if (screen == NULL) {
	fprintf(stderr, "Couldn't set GL mode: %s\n", SDL_GetError());
	SDL_Quit();
	exit(1);
    }
    
    pixels = (Uint32*)screen->pixels;

    p = (Uint32*)manager->malloc(sizeof(int)*width*height);
    pixels = p;
    bitmap = SDL_CreateRGBSurfaceFrom((void *)p, width, height, 32,
				      width*4, redMask, greenMask,
				      blueMask, alphaMask);
}

void
ViewerSDL::clean_pixels()
{
    //bzero(pixels, sizeof(int)*width*height);
}

void
ViewerSDL::run_loop(void)
{
#if !defined(__LINUX__)
    SDL_BlitSurface(bitmap, NULL, screen, NULL);
    SDL_UpdateRect(screen, 0, 0, 0, 0);        
#endif

    Viewer::run_loop();
}

void
ViewerSDL::run_finish(void)
{
    SDL_FreeSurface(bitmap);

    Viewer::run_finish();
}