Forum > Games
Why SDL_RenderDrawPoints() doesn't work?
Edson:
I'm new on SDL2 and maybe I'm doing something wrong, but, Can someone tell me why this code works perfectly :
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- for i := 0 to nPnts-1 do begin SDL_RenderDrawPoint( sdlRenderer, sdlPoints1[i]^.x, sdlPoints1[i]^.y); end;
And this fails >:(:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- SDL_RenderDrawPoints( sdlRenderer, sdlPoints1[0], nPnts);
The last code just draw some points in ramdom locations of a line (apparently).
I'm using Lazarus 1.8.0 - FPC 3.0.4 in Windows 7.
Paul_:
"It fails" .. does not define the problem and also without rest of code and variables related to SDL_RenderDrawPoints( sdlRenderer, sdlPoints1[0], nPnts) it's hard to help.
But probably you don't have defined sdlPoints1 in right way.
Edson:
--- Quote from: Paul_ on March 18, 2018, 08:53:31 pm ---"It fails" .. does not define the problem and also without rest of code and variables related to SDL_RenderDrawPoints( sdlRenderer, sdlPoints1[0], nPnts) it's hard to help.
But probably you don't have defined sdlPoints1 in right way.
--- End quote ---
Hi. I have a test project.
It needs SDL2.dll to compile.
Paul_:
Original tutorial code (https://www.freepascal-meets-sdl.net/chapter-5-drawing-primitives/) shows some points but maybe only 10 instead of 500? :)
EDIT: this works for me:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---var sdlPoints1 : array[0..499] of TSDL_Point;begin for i := 0 to 499 do begin sdlPoints1[i].x := x + i; sdlPoints1[i].y := y + i; end; SDL_RenderDrawPoints(sdlRenderer, sdlPoints1, 500);end;
It's bit weird because function variable parameter is defined as "points: PSDL_Point"
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- PSDL_Point = ^TSDL_Point; TSDL_Point = record x: SInt32; y: SInt32; end; function SDL_RenderDrawPoints(renderer: PSDL_Renderer; points: PSDL_Point; count: SInt32): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_RenderDrawPoints' {$ENDIF} {$ENDIF};
Edson:
--- Quote from: Paul_ on March 19, 2018, 10:44:06 am ---Original tutorial code (https://www.freepascal-meets-sdl.net/chapter-5-drawing-primitives/) shows some points but maybe only 10 instead of 500? :)
EDIT: this works for me:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---var sdlPoints1 : array[0..499] of TSDL_Point;begin for i := 0 to 499 do begin sdlPoints1[i].x := x + i; sdlPoints1[i].y := y + i; end; SDL_RenderDrawPoints(sdlRenderer, sdlPoints1, 500);end;
--- End quote ---
Yes I have been following that tutorial. Maybe it has an error and the correct form is using TSDL_Point. Considering SDL2 come from C language, it's possible some strange behaviour in Pascal.
It works for me too, using TSDL_Point. Thanks for helping.
The bad news is that using SDL_RenderDrawPoints() is as slow as using SDL_RenderDrawPoint() for each point.
Navigation
[0] Message Index
[#] Next page