Hello sdl,
like in subject.
right now, i am doing like this:
(using pixel rgba because of different bpp)
(using three tables because of… eer… making nights if you
have prerendered screen of scene in games such baldurs gate - when
you want make night you just exchange r with b values)
void UpdateScroll(long ofx, long ofy)
{
unsigned long ah1,ah2;
unsigned long offset_z;
for (ah1=0;ah1<600;ah1++)
{
for (ah2=0;ah2<800;ah2++)
{
offset_z=(3200*(ah1+ofy))+ofx+ah2;
SDL_pixelRGBA(background,ah2,ah1,vaddr_r[offset_z],
vaddr_g[offset_z], vaddr_b[offset_z],255);
}
}
}
screen init… isn’t it better to use hwsurface with doublebuf ? but
when i do, pixelrgba is extreme slow… any ideas why?
screen = SDL_SetVideoMode(800, 600, 16,
(SDL_FULLSCREEN|SDL_SWSURFACE));
and mainloop looks like this:
while ( klawiatura[SDLK_ESCAPE]!=SDL_PRESSED )
{
SDL_PollEvent(&event);
SDL_BlitSurface(mouse_save,NULL,screen,&mouse_rect); // bufor na ekran
SDL_GetMouseState(&mouse_x, &mouse_y);
mouse_rect.x=mouse_x; mouse_rect.y=mouse_y;
mouse_rect.h=32; mouse_rect.w=32;
if (mouse_x<5&&offset_x>5)
{
offset_x-=50;
UpdateScroll(offset_x,offset_y);
SDL_BlitSurface(background,0,screen,0);
}
if (mouse_x>795&&offset_x<2400)
{
offset_x+=50;
UpdateScroll(offset_x,offset_y);
SDL_BlitSurface(background,0,screen,0);
}
if (mouse_y<5&&offset_y>5)
{
offset_y-=50;
UpdateScroll(offset_x,offset_y);
SDL_BlitSurface(background,0,screen,0);
}
if (mouse_y>595&&offset_y<1600)
{
offset_y+=50;
UpdateScroll(offset_x,offset_y);
SDL_BlitSurface(background,0,screen,0);
}
SDL_BlitSurface(screen,&mouse_rect,mouse_save,NULL); // tlo do bufora
SDL_BlitSurface(mouse_cursor,NULL,screen,&mouse_rect); // mysz na ekran
SDL_UpdateRect(screen,0,0,0,0);
SDL_PumpEvents(); // odswiez eventy
klawiatura = SDL_GetKeyState(NULL); // odswiez
}
mkey, any ideas, how to make it faster ? divide whole screen
into little ie. 32x32 surfaces ? sound pity, isn't it ?--
Best regards,
firefox mailto:@palpetine
–
Okresl Swoje potrzeby - my znajdziemy oferte za Ciebie!
[ http://oferty.onet.pl ]