Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- ===============
- Filled Circle
- ===============
- */
- #include <SDL/SDL.h>
- #include <SDL/SDL_image.h>
- #include <math.h>
- #include <iostream>
- using namespace std;
- SDL_Surface *Screen = SDL_SetVideoMode(640,480,32,SDL_SWSURFACE);
- SDL_Surface* PixelSurface = SDL_CreateRGBSurface(SDL_HWSURFACE, 640, 480,
- Screen->format->BitsPerPixel,
- Screen->format->Rmask,
- Screen->format->Gmask,
- Screen->format->Bmask,
- Screen->format->Amask
- );
- void inline SDL_Draw()
- {
- int
- mouse_x = 0,
- mouse_y = 0,
- centerx = 100,
- centery = 100,
- radius = 50;
- int x, y,
- color = 0x00ff00;
- float
- two_pi = 360.283f,
- angle_inc = 1.0f/radius;
- for(float angle = 0.0f; angle<=two_pi; angle+=angle_inc)
- {
- unsigned int *ptr = static_cast <unsigned int *> (PixelSurface->pixels);
- x = centerx+radius*cos(angle);
- y = centery+radius*sin(angle);
- //set the centerx and y to the radius and = it color
- int offset = y * (PixelSurface->pitch/sizeof(unsigned int));
- ptr[offset + x] = color;
- ptr[centerx * radius] = color;
- }
- SDL_BlitSurface(PixelSurface,NULL,Screen,NULL);
- }
- int main(int argc, char *Argv[])
- {
- bool
- done = false;
- SDL_Event event;
- SDL_WM_SetCaption("Test","Test");
- while(!done)
- {
- SDL_Draw();
- while(SDL_PollEvent(&event))
- {
- switch(event.type)
- {
- case SDL_QUIT:
- return 0;
- break;
- }
- }
- SDL_Flip(Screen);
- SDL_FillRect(PixelSurface,NULL,0x000000);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement