Advertisement Jump to content
Sign in to follow this  

Compiling in release mode

This topic is 5055 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Well I compiled my C++ SDL game project just fine. I go to compile both in release and debug mode. No errors, warnings, I don't even get a single runtime error in my game while running the debug executable. Flawless I suppose. Well I have a process that renders my texture tile across the screen because the game is tile-based, that work fine in the debug executable. When I go to run the release executable, it still renders my character and does everything else properly, but it isn't rendering the map! I have no idea why and it's really been bugging me. Maybe someone around here might have a clue as to why it won't. Here's my map rendering function:
void CSDL::Draw_Map_Base(SDL_Surface *screen, int x_offset, int y_offset, CBase &Base)
	int x_shift=0, y_shift=0, x_next=21, y_next=16;

	//Position check (for texture bleeding prevention)
	if( (x_offset + 640) > (Base.getMapXSize() * 32) ) { x_offset = ((Base.getMapXSize() * 32) - 640); }
	if( (y_offset + 480) > (Base.getMapYSize() * 32) ) { y_offset = ((Base.getMapYSize() * 32) - 480); }

	//Calculate new (x,y) pos in NMUs
	x_shift += (int)floor((double)x_offset/32);
	y_shift += (int)floor((double)y_offset/32);

	//Initial NMUs to start rendering at
	int y = y_shift;
	int x = x_shift;

	//Render loop
	for(; y < y_shift + y_next; y++)
		for(; x < x_shift + x_next; x++)
			DrawIMG( screen, &(*vecTextures)[Map[y][x].tile_ID].image, ((x*32) - x_offset), ((y*32) - y_offset) );

			//Check map bounds
			if((x_shift + 20) == Base.getMapXSize()){ x_next = 20; }
			else{ x_next = 21; }

		//Reset x counter
		x = x_shift;

		//Check map bounds
		if((y_shift + 15) == Base.getMapYSize()){ y_next = 15; }
		else{ y_next = 16; }
It runs fine, compiles fine, everything is smooth. Just my release executable isn't rendering the tiles in the background, so my player's image gets rendered where ever I move in the buffer and it's that ugly flickering thing you see in the void of other rendering APIs. I'm stumped. :<

Share this post

Link to post
Share on other sites
Because you say 'release' and 'debug' modes I will assume you are using MSVC. When running in debug mode in MSVC variables are initialized to sane values (0 or null, for example), but in release mode they are not. Often, when running in the IDE, this is the source of problems when switching modes. I don't know if this is what is causing your problem, but it's one possibility. I doubt it's your Draw_Map_Base method - at least, nothing jumps out at me that would be different in release and debug modes. Perhaps the problem lies in your DrawIMG method? Or your vecTextures member? Sprinkle some printf statements around your code to make sure everything is getting called and that your data is valid.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!