How did I Clone SDL_Surface?

Dear Developers,
How can I Clone the SDL_Surfaces?

1 Like

Now it works i fix it:

SDL_Surface* hWndButtonUp = NULL
SDL_Rect hWndFieldPos,pos; 

int hWndFieldposX = 150;
int hWndFieldposY = 100;

int ButtonX = 32; 
int ButtonY = 28; 

int hWndFieldMatrixX = 21;
int hWndFieldMatrixY = 11; 

int set_menu = 1;

//------------------------- 
class draw
{
 public: 
 draw(); 
 void hWndButton(); 
 //void ButtonEvent(); 
 private: 
};                
 
//------------------------
                 
draw::draw() 
{
  pos.x=hWndFieldposX;
  pos.y=hWndFieldposY; 
}
 
//---------------------------      
void draw::hWndButton() 
{ 
  for (int i=0; i<hWndFieldMatrixY; i++) //  Begin to draw 11 Fields down by:
  { 
   pos.x=hWndFieldposX; // pos X = 150...
   pos.y+=ButtonY; // then jumps  evey +28(ButtonY size)  pixel down...
   
   for (int j=0; j<hWndFieldMatrixX; j++) //draw every 11 Lines 21 times the Same Bmp...
   { 
    SDL_BlitSurface(hWndButtonUp,NULL,screenSurface,&pos); //first draw -
    pos.x+=ButtonX; // the Surface by: Field posX... 
    //AND THEN jumpt +X= 32(ButtonX  size)  to left side 21x11 times
   }   
 }
 pos.y = hWndFieldposY; //  then b jump back to Field Y  (100 )
}

And:

...
hWndButtonUp = SDL_LoadBMP ("32x28".bmp);
draw mydraw; 
...
while (quit == false)
{
  ....
  while (SDL_PollEvent(&event)) 
  {
   switch(event.type) 
   {
    // case SDL_MOUSEMOTION: 
    // break;
    case SDL_QUIT: 
    quit=true; 
    break; 
          
//FOR ANDROID Landscape/Portrait SCREEN

    if (event.type == SDL_WINDOWEVENT &&event.window.event ==       
        SDL_WINDOWEVENT_RESIZED) 
      { 
       screenSurface= SDL_GetWindowSurface(window); 
     }

   } //end of switch event
 } // end of poll.event

//----------------------------
     
 if (set_menu == 1)
{ 
  mydraw.hWndButton(); 
}

....
 SDL_UpdateWindowSurface(window);  
}
 ...
SDL_DestroyWindow(window); 
SDL_FreeSurface(screenSurface)
SDL_FreeSurface(YourSurface);  //*32x28 bmp
SDL_Quit(); 
return 0; 
}