SDL_RenderDrawPoints odd behaviour

Hello All,

I have been working for a little more than a year with SDL and I either have come across with a potential bug or I’m simply going the wrong way on which I would like to have your feedback/advice.

The questions is, are there known limitations or bugs on the use of the SDL_RenderDrawPoints function?

What I’m trying to do is use it to erase/draw a relatively large number of points on a layer which will be done every frame, I’m using dynamic arrays of SDL_Point as a parameter but I’ve tried with static ones having similar results which vary depending on the number of points, for instance:

  1. It draws up to a certain number of points, such number is unpredictable.
  2. A low number of points, let’s say around 2000 are usually drawn, however during execution they unexpectedly could stop being draw and start being drawn again.

I’ve put together an piece of code that exemplifies the issue (the process of the code needs to be killed manually):--------------------
#include
#include <SDL2/SDL.h>
using namespace std;
SDL_Window *sdlWindow;
SDL_Renderer *sdlRenderer;
bool blittcond = false;
Uint32 timecall(Uint32 interval, void *param);
int main(int argc, char *argv[])
{
SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER);
SDL_SetHint(SDL_HINT_RENDER_DRIVER, “direct3d”);
sdlWindow = SDL_CreateWindow(“Test 1”, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,1280,720,SDL_WINDOW_RESIZABLE);
sdlRenderer = SDL_CreateRenderer(sdlWindow,-1, SDL_RENDERER_ACCELERATED|SDL_RENDERER_TARGETTEXTURE);
SDL_SetRenderDrawBlendMode(sdlRenderer,SDL_BLENDMODE_NONE);
SDL_Point *points = new SDL_Point[10000];
//SDL_Point points[10000];
int i, j, n = 0;
for (j = 0; j <= 100;j++)
{
for(i = 0; i <= 100;i++)
{
points[n].x = 300+i;
points[n].y = 300+j;
++n;
}
}
while(true)
{
SDL_SetRenderDrawColor(sdlRenderer, 0, 0, 0xff, 0xff);
SDL_RenderFillRect(sdlRenderer,0);
SDL_SetRenderDrawColor(sdlRenderer, 0xff, 0xff, 0xff, 0xff);
SDL_RenderDrawPoints(sdlRenderer,points,4471);
//SDL_RenderDrawPoints(sdlRenderer,points,4472);
//SDL_RenderDrawPoints(sdlRenderer,points,10000);
SDL_RenderPresent(sdlRenderer);
cout<<" refreshing ";
}
return 0;
}


On my PC this code draws the 4471 points I’m asking the function to draw, however if I ask for 4472 it does not draw them, I don’t know if the results vary from one PC/OS to another, I’m using Win XP.

Best regards
Gabriel


Gabriel Alejandro Banales Fabian

Working on a 2D game engine based on SDL since 2012

Hello,

I guess it is due to the old OS I’m using, I had been using Direct3D 9.0c and I switched to OpenGl which did fix my problem:

SDL_SetHint(SDL_HINT_RENDER_DRIVER, “opengl”);

So I hope this my help if anybody is working on an environment like mine.------------------------
Gabriel Alejandro Banales Fabian

Working on a 2D game engine based on SDL since 2012

You could also batch them in groups of, say, 1000. The overhead of calling
DrawPoints a few times isn’t significant, and it might work around some
internal driver limitation.On Fri, Nov 8, 2013 at 7:43 PM, gabf83 wrote:

Hello,

I guess it is due to the old OS I’m using, I had been using Direct3D 9.0c
and I switched to OpenGl which did fix my problem:

SDL_SetHint(SDL_HINT_RENDER_DRIVER, “opengl”);

So I hope this my help if anybody is working on an environment like mine.


Gabriel Alejandro Banales Fabian

Working on a 2D game engine based on SDL since 2012


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Hi, thanks for your reply I appreciate it, well that did cross my mind, actually I’m pretty sure it would work, I did something similar by using SDL_RenderDrawPoint instead to draw point by point, it works though it impacts the performance a great deal as expected.

Sam Lantinga wrote:> You could also batch them in groups of, say, 1000. ?The overhead of calling DrawPoints a few times isn’t significant, and it might work around some internal driver limitation.

On Fri, Nov 8, 2013 at 7:43 PM, gabf83 <@gabf83 (@gabf83)> wrote:

   	Hello,

I guess it is due to the old OS I’m using, I had been using Direct3D 9.0c and I switched to OpenGl which did fix my problem:

SDL_SetHint(SDL_HINT_RENDER_DRIVER, “opengl”);

So I hope this my help if anybody is working on an environment like mine.

Gabriel Alejandro Banales Fabian

Working on a 2D game engine based on SDL since 2012


SDL mailing list
SDL at lists.libsdl.org (SDL at lists.libsdl.org)
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org (http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org)


Gabriel Alejandro Banales Fabian

Working on a 2D game engine based on SDL since 2012