#include <v_lib.h>

void	V_CALL	draw_string(void *param)
{
	glClearColor(1,1,1,1);
	glClear(GL_COLOR_BUFFER_BIT);
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	// glFrustum(-1,1,-1,1,2,100);
	glOrtho(-1,1,-1,1,-1,1);
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	vglSelectFont(param);
	glScalef(0.2f,0.2f,0.2f);
	glColor3f(1,0,0);
	glRectf(0,0,1,1);
	glColor3f(0,0,0);
	vglPuts("Привет !!!");
	vglSwapBuffers();
}

int main()
{
	vhandle_t fnt;
	void *pixbuf;
	u32_t w,h;
	logStartConsoleLog();
	logUpperLevel(LOG_TRACE);
	
	fnt=vglLoadBGIFont("../media/bgi-fonts/arus.chr");
	
	if(1 || vglCreateMappedWindow(480,480) == NULL)
	{
		if(vglCreateWindow("GL Text",0,0,480,480) == NULL)
		{
			puts("Unable to create GL viewport !");
			vglDestroyFont(fnt);
			return -1;
		}
	}
	
	draw_string(fnt);
	pixbuf=vglReadPixels(&w,&h);
	tgaSave("out.tga",w,h,pixbuf);
	memFree(pixbuf);

#ifdef	NO_CLIPBOARD
	vglDrawToMetafile("out.wmf",100,100,draw_string,(void*)fnt);
#else
	vglDrawToMetafile(libv_clipboard_name,100,100,draw_string,(void*)fnt);
#endif

	vglDestroyWindow(vglGetCurrentWindow());
	vglDestroyFont(fnt);

	memPrintStats();
	return 0;
}
