Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guys :)
I've been reading about libSDL (Simple Direct Media Layer), which is a portable library designed for creating games, emulators etc. i.e. applications that require graphical effects rather than using the old legacy console.
As a simple exercise I've been trying to emulate a console (not to the very extent), I've implemented the basics (putchar, puts, printf) and now I'm trying to implement a scroll() function which'll scroll i.e. copy from the 2nd row to the last row to the 1st row and the second last row. Here's how I do it:
C++
// End of screen?
if (screen_y >= GL_MAX_Y)
	{
		// Yes. Scroll
		// This basically involves copying a part of the screen on the screen itself
		SDL_Rect temp;
		temp.x = 0; // X co-ordinate 
		temp.y = FONT_HEIGHT; // Y-cord First Row (In scrolling, the 0th row is replaced by the 1st row)
		temp.h = GL_MAX_Y; // ...And copy till the last line
		temp.w = GL_MAX_X; // Width should be the screen
		// COPY!
		SDL_BlitSurface(screen, &temp, screen, NULL);
		// Set X to 0
		screen_x = 0;
		// Set Y to last row 
		screen_y = GL_MAX_Y - FONT_HEIGHT;
	}

This scrolls perfectly, but the last line is filled with junk from the first line.
Is there any way I can clear the last line of the screen?
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900