I ran it through valgrind at work (valgrind newb) and got tons of errors, most of them seem to be culminating in the actual sdl libraries. I was able to find one area where I was making a mistake. Not to say something else I am doing is wrong...just wanted to get any opinions on this code.
loop through a block of pixels and make them all green.
//Init code
Uint32* surfacePixelData;
Uint32 temppixel;
//on view load
pixel_surface = SDL_CreateRGBSurface(0,640,480,32,0,0,0,0);
temppixel = SDL_MapRGB(pixel_surface->format, 30,250 ,60);
This is the offending code - happens every frame
//Draw a block of pixels and test speed
if ( SDL_MUSTLOCK(pixel_surface) )
SDL_LockSurface(pixel_surface);
surfacePixelData = (Uint32*)pixel_surface->pixels;
///RESOUCE HOG
for(x = 0; x < 460; x++){
for( y = 0; y < 620; y++){
surfacePixelData[(640 * x) + y] = temppixel;
//SDL_RenderDrawPoint(thisRenderer, x, y);//really slow like 1fps
}
}
if ( SDL_MUSTLOCK(pixel_surface) )
SDL_UnlockSurface(pixel_surface);
pixel_texture = SDL_CreateTextureFromSurface( thisRenderer, pixel_surface );
SDL_SetRenderDrawColor(thisRenderer, 0, 250, 0, 255);
d.w = 640; d.h = 480;
d.x = 10; d.y = 10;
SDL_RenderCopy(thisRenderer, pixel_texture, NULL, &d);
SDL_RenderPresent(thisRenderer);
When this is commented out, my executable takes up 20mb as reported by task manger
When run executable size increases drastically to the point where I run out of memory.
Thank you