You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
hello. i'm having an extremely strange issue. the following code freezes up when drawing 185 lines or more; it doesn't crash, it just stops updating or responding to input, and i have to kill it from the console with ctrl + c.
importstd.stdio;
import bindbc.sdl;
voidmain()
{
SDL_Window* window;
SDL_Renderer* renderer;
bool isRunning = true;
loadSDL();
SDL_Init(SDL_INIT_VIDEO);
enum windowSizeX = 512;
enum windowSizeY = 288;
enum windowTitle = "line test";
window = createWindow(windowSizeX, windowSizeY, windowTitle);
renderer = createRenderer(window);
int lines = 0;
while(isRunning)
{
SDL_Event currentSDLEvent;
while (SDL_PollEvent(¤tSDLEvent) !=0)
{
if (currentSDLEvent.type ==SDL_QUIT)
{
isRunning = false;
importcore.stdc.stdio: printf;
printf("quitting...\n");
}
}
SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0x00, 0xFF);
SDL_RenderClear(renderer); //required
SDL_SetRenderDrawColor(renderer, 0xFF, 0xFF, 0xFF, 0xFF);
drawLines(renderer, lines);
SDL_RenderPresent(renderer); //required
}
}
SDL_Window*createWindow(int windowSizeX, int windowSizeY, string windowTitle)
{
importstd.string: toStringz;
enum windowFlags = SDL_WINDOW_SHOWN;
SDL_Window* result = SDL_CreateWindow(
toStringz(windowTitle),
SDL_WINDOWPOS_UNDEFINED, // initial x positionSDL_WINDOWPOS_UNDEFINED, // initial y position
windowSizeX,
windowSizeY,
windowFlags
);
return result;
}
SDL_Renderer*createRenderer(SDL_Window* window)
{
enum rendererFlags = SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC;
enum SDL_firstAvailableDriver = -1;
SDL_Renderer* result = SDL_CreateRenderer(window, SDL_firstAvailableDriver, rendererFlags);
return result;
}
voiddrawLines(SDL_Renderer* renderer, refint noOfLines)
{
foreach(line; 0.. noOfLines +=1) // += is required?? ++ seemingly works fine
{
immutableint x = (line %100) *3;
immutableint y = (line /100) *3;
importstd.math;
immutable wtf = cast(int) (sin(cast(float)line) *4); // different multipliers have different results, eg:// 1 seemingly has no limit// 2 halts at 449// 3 halts at 371// 4, 5, 6, 7 halt at 185// 8, 9 halts at 356// 10 halts at 497
SDL_RenderDrawLine(renderer, x, y, x +1+ wtf, y +1); // the + 1s are required???
}
importstd.stdio: writeln;
writeln(noOfLines);
}
i haven't the foggiest idea why this would happen, least of all why += should be different from ++ - nor why the +1s seem to be required.
using version 1.5.0, dmd, windows 10.
The text was updated successfully, but these errors were encountered:
hello. i'm having an extremely strange issue. the following code freezes up when drawing 185 lines or more; it doesn't crash, it just stops updating or responding to input, and i have to kill it from the console with
ctrl + c
.i haven't the foggiest idea why this would happen, least of all why
+=
should be different from++
- nor why the+1
s seem to be required.using version 1.5.0, dmd, windows 10.
The text was updated successfully, but these errors were encountered: