Hello
I had a question, do we have to do something special when using a renderer created with
Code:
SDL_CreateSoftwareRenderer
because in my code when I use render created with
Code:
SDL_CreateRenderer
every thing is drawing great but when using
Code:
SDL_CreateSoftwareRenderer
some draw command do not have any effet one the surface whyle other are working great here is what I did
I used
Code:
SDL_CreateSoftwareRenderer
to creat a renderer which renders to a surface and then I display that surface (or use it) which is in fact the window surface. (I need a surface for some reason…).
The rendering is then made in a loop :
Code:
SDL_SetRenderDrawColor(gRenderer, 0XFF, 0XFF, 0X00, 0XFF);
SDL_RenderClear(gRenderer);
SDL_SetRenderDrawColor(gRenderer, 0X0F, 0X00, 0XF0, 0XFF);
SDL_SetRenderDrawColor(gRenderer, 0X0F, 0X00, 0XF0, 0XFF);
SDL_Rect rect;
rect.x = 0;
rect.y = 5;
rect.w = 10;
rect.h = 2;
SDL_RenderFillRect(gRenderer, &rect);
std::cout << "begin" << std::endl;
for (auto& i : zIndexOrder) {
//Rectangles[i]->get_x();
Rectangles[i]->updat_move_fnct();
if (Rectangles[i]->everyframe_fct != NULL)Rectangles[i]->everyframe_fct(Rectangles[i]);
//Rectangles[i]->index_th = i;
}
for (auto u : Underwindows)u->Refresh();
for (auto& i : zIndexOrder)Rectangles[i]->draw(this);
SDL_SetRenderDrawColor(gRenderer, 0X0F, 0X00, 0XF0, 0XFF);
rect.x = 0;
rect.y = 5;
rect.w = 5;
rect.h = 5;
SDL_RenderFillRect(gRenderer, &rect);
std::cout << "true RENDERER " << gRenderer << std::endl;
if (SOFTWARE_RENDERING) SDL_UpdateWindowSurface(gWindow);
else SDL_RenderPresent(gRenderer);
The two rectangle drawn here with
Code:
SDL_RenderFillRect(gRenderer, &rect);
draw fine but, in
Code:
ectangles[i]->draw(this);
If I make the same call It doesn’t work I mean I call
Code:
SDL_SetRenderDrawColor(f->get_screen_render(), 0X0F, 0X00, 0XF0, 0XFF);
SDL_Rect rect;
rect.x = 6;
rect.y = 5;
rect.w = 10;
rect.h = 55;
SDL_RenderFillRect(f->get_screen_render(), &rect);
in
Code:
rectangles[i]->draw(this);
and the rectangle doesn’t draw.
notice that the three rectangles are from different size to see the differences, the clear color is not the same as the draw color,
Code:
f->get_screen_render()
gives the same pointer to the renderer as the one in the two other call , and this part of the code is execute (I know this thanks to the console), and finally it executes between the two other draw. Note that those 3 rectangles ar only debug rectangle to show my problem but rectangle are drown on over parts.
I wonder why everything works with render created with
Code:
SDL_CreateRenderer
and not with
Code:
SDL_CreateSoftwareRenderer
Thank you