Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as text by ja2 ( 17 years ago )
#include <SDL/SDL.h>
#include <stdio.h>

#define SCRX 800
#define SCRY 600
#define TICK_MAX 129

char sdloutput(short * schedTrace)
{
	SDL_Surface * scr;
	int i;

	SDL_PixelFormat * pixelformat;
	Uint32 taskcol[6];

	SDL_Rect dest;
	short taskBlockX = SCRX / TICK_MAX;
	short taskBlockY = 10;

	short tick, task;

	if (SDL_Init(SDL_INIT_VIDEO) != 0)
	{
		printf("Error: SDL_Init()
");
		return 1;
	}

	scr = SDL_SetVideoMode(SCRX, SCRY, 16, 0);

	pixelformat = scr->format;

	////////////////////
	// Set up colors
	////////////////////
	taskcol[0] = SDL_MapRGB(pixelformat, 0x88, 0x88, 0x88);
	taskcol[1] = SDL_MapRGB(pixelformat, 0xff, 0x00, 0x00);
	taskcol[2] = SDL_MapRGB(pixelformat, 0x00, 0xff, 0x00);
	taskcol[3] = SDL_MapRGB(pixelformat, 0x00, 0x00, 0xff);
	taskcol[4] = SDL_MapRGB(pixelformat, 0xff, 0xff, 0x00);

	/////////////////
	//SDL_FillRect
	/////////////////
	for (i = 1; i < TICK_MAX - 1; ++i)
	{
		tick = schedTrace[2 * i];
		task = schedTrace[2 * i + 1];
		dest.x = tick * taskBlockX;
		dest.y = (5 - task) * taskBlockY;
		dest.w = taskBlockX;
		dest.h = taskBlockY;
		SDL_FillRect(scr, &dest, taskcol[task]);

		//Plot tickmark
		dest.x = tick * taskBlockX;
		dest.y = (6) * taskBlockY;
		dest.w = 1;
		dest.h = taskBlockY / 2;
		SDL_FillRect(scr, &dest, taskcol[0]);

	}
	SDL_UpdateRect(scr, 0, 0, 0, 0);
	
	printf("
Press a key");
	getc(stdin);
	SDL_FreeSurface(scr);
	SDL_Quit();

	return 0;

 

Revise this Paste

Your Name: Code Language: