[Interested?] OldSchool Library

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
sakya
Posts: 190
Joined: Fri Apr 28, 2006 5:48 pm
Contact:

Post by sakya »

Hi! :)

Sorry for the double post....
Just to inform I released a modified version of OSLib (called OSLib MOD).
More info here:
http://www.sakya.it/forums/viewtopic.php?f=7&t=10

Changelog:
-Added: oslSetReadKeysFunction(int (*sceCtrlReadBufferPositive)(SceCtrlData *pad_data, int count));
You can pass to it a function from a kernel prx, so you'll be able to read all buttons (VOLUME_UP, NOTE...)
oslUnsetReadKeysFunction();
-Added: All USB.c functions now works
-Added: OSL_VERSION
-Added: oslSetHoldForAnalog
-Added: support for intraFont.
-Added: Dialogs (message, error and net conf)
-Added: On Screen Keyboard
-Added: Save and load
-Fixed: Tagged MP3 and ATRAC3+ now works
-Fixed: osl_keys->analogToDPadSensivity now works correctly

Download: http://www.sakya.it/OSLib_MOD/downloads ... _1_0_0.rar
Source download: http://www.sakya.it/OSLib_MOD/downloads ... _0_src.rar
Documentation: http://www.sakya.it/OSLib_MOD/doc/html

Ciaooo
Sakya
Last edited by sakya on Tue Apr 15, 2008 11:21 pm, edited 1 time in total.
Drakon
Posts: 13
Joined: Tue Apr 08, 2008 3:46 pm
Location: Poznan - Poland
Contact:

Post by Drakon »

Loooooooo nice man :> Thanks for sharing :)
BlackShark
Posts: 11
Joined: Fri Mar 02, 2007 5:06 pm
Contact:

Post by BlackShark »

nice work, ill check it out now.
Programmer van der C
Sp3ct0r
Posts: 3
Joined: Wed Apr 16, 2008 7:19 am

Post by Sp3ct0r »

Sweet! This is just what I needed. Thanks man! :D
reefbarman
Posts: 87
Joined: Mon Jan 08, 2007 12:16 pm
Location: Australia

Post by reefbarman »

i love oslib and use it in most of my projects and this modified version jsut makes it so much better please keep up the good work, and keep the updates coming
sakya
Posts: 190
Joined: Fri Apr 28, 2006 5:48 pm
Contact:

Post by sakya »

Hi! :)
reefbarman wrote:i love oslib and use it in most of my projects and this modified version jsut makes it so much better please keep up the good work, and keep the updates coming
Thanks.
I just released a bugfix version 1.0.1. ;)
More details here:
http://www.sakya.it/forums/viewtopic.php?f=7&t=13

Ciaooo
Sakya
reefbarman
Posts: 87
Joined: Mon Jan 08, 2007 12:16 pm
Location: Australia

Post by reefbarman »

sakya wrote:Hi! :)
reefbarman wrote:i love oslib and use it in most of my projects and this modified version jsut makes it so much better please keep up the good work, and keep the updates coming
Thanks.
I just released a bugfix version 1.0.1. ;)
More details here:
http://www.sakya.it/forums/viewtopic.php?f=7&t=13

Ciaooo
Sakya
hi i just tried your oslib_mod in my app that already contained the original oslib and just did a complete swap, but after doing so i got some really strange things happening in my app the app has a cursor that moved by itself around the screen where it shouldn't without user control, this doesn't happen with the standard oslib


what change were made to the original functions that may cause the side affects im seeing?

thanks
sakya
Posts: 190
Joined: Fri Apr 28, 2006 5:48 pm
Contact:

Post by sakya »

Hi! :)
reefbarman wrote:i got some really strange things happening in my app the app has a cursor that moved by itself around the screen where it shouldn't without user control, this doesn't happen with the standard oslib
I don't know, I made some changes to controls but I don't have problems.
Can you post some code, please?

Ciaooo
Sakya
Alois2992
Posts: 7
Joined: Thu Nov 22, 2007 11:38 pm

OSLib and freetype

Post by Alois2992 »

Hi,

I just tried to render text with OSLib, but the fonts that came with OSLib didn't satisfy me. So I decided to try freetype on OSLib. Now I've some results but it doesn't work very well. The capitals begin to flicker after some seconds and I can't find a reason for this strange behaviour.

Here some Code:

Code: Select all

OSL_IMAGE* FontEngine::RenderString(std::string str, FE_Font* font, RenderColor color)
{
	if(!font->init)
	{
		//return new OSL_IMAGE;
	}
	OSL_IMAGE* img;
	std&#58;&#58;vector<OSL_IMAGE*> Images;
	
	
	//FT_GlyphSlot slot = font->face->glyph; // a small shortcut   
	
	int pen_x = 0; 
	//unsigned int n; 
	 
	for &#40;unsigned int n = 0; n < str.length&#40;&#41;; n++ &#41; 
	&#123;
		FT_Load_Glyph&#40; font->face, FT_Get_Char_Index&#40; font->face, str.at&#40;n&#41; &#41;, FT_LOAD_DEFAULT &#41;;
			//continue;

	
		FT_Glyph glyph;
    		FT_Get_Glyph&#40; font->face->glyph, &glyph &#41;;
		//	throw std&#58;&#58;runtime_error&#40;"FT_Get_Glyph failed"&#41;;

		//Convert the glyph to a bitmap.
		FT_Glyph_To_Bitmap&#40; &glyph, ft_render_mode_normal, 0, 1 &#41;;
		FT_BitmapGlyph bitmap_glyph = &#40;FT_BitmapGlyph&#41;glyph;

		//This reference will make accessing the bitmap easier
		FT_Bitmap& bitmap=bitmap_glyph->bitmap;

		//Use our helper function to get the widths of
		//the bitmap data that we will need in order to create
		//our texture.
		int width = next_p2&#40; bitmap.width &#41;;
		int height = next_p2&#40; bitmap.rows &#41;;
	
		//Allocate memory for the texture data.
		img = oslCreateImage&#40;width, height, OSL_IN_RAM, OSL_PF_8888&#41;;
		oslLockImage&#40;img&#41;;
		//Here we fill in the data for the expanded bitmap.
		//Notice that we are using two channel bitmap &#40;one for
		//luminocity and one for alpha&#41;, but we assign
		//both luminocity and alpha to the value that we
		//find in the FreeType bitmap. 
		//We use the ?&#58; operator so that value which we use
		//will be 0 if we are in the padding zone, and whatever
		//is the the Freetype bitmap otherwise.
		
		int *ptr = &#40;int *&#41;img->data;
		for&#40;int j=0; j <height;j++&#41;
		&#123;
			for&#40;int i=0; i < width; i++&#41;
			&#123;
				float alpha = &#40;i>=bitmap.width || j>=bitmap.rows&#41; ?
					0 &#58; bitmap.buffer&#91;i + bitmap.width*j&#93;;
				alpha /= 255 ;
				//fprintf&#40;stderr, "%i ", int&#40;alpha&#41;&#41;;
				*ptr++ = RGBA&#40;color.col.r, color.col.g, color.col.b, int&#40;color.col.a * alpha&#41;&#41;;
			&#125;
			//fprintf&#40;stderr, "\n"&#41;;
		&#125;// load glyph image into the slot &#40;erase previous one&#41; 
		oslUnlockImage&#40;img&#41;;
		//oslDrawImageXY&#40;img, pen_x, 0&#41;;
		//pen_x += img->sizeX;
		Images.push_back&#40;img&#41;;
			
	&#125;
	img = NULL;
	int width = 0;
	int height = 0;
	for&#40;unsigned int g = 0; g < Images.size&#40;&#41;; g++&#41;
	&#123;
		width += Images&#91;g&#93;->sizeX;
		if&#40;Images&#91;g&#93;->sizeY > height&#41;
		&#123;
			height = Images&#91;g&#93;->sizeY;
		&#125;
		
	&#125;
	//fprintf&#40;stderr, "width&#58; %i, height&#58; %i\n", width, height&#41;;
	img = oslCreateImage&#40;width, height, OSL_IN_VRAM, OSL_PF_8888&#41;;
	oslClearImage&#40;img, RGBA&#40;0, 0, 0, 0&#41;&#41;;
	oslSetAlphaWrite&#40;OSL_FXAW_SET, 255, 0&#41;;
	//But do not draw transparent pixels &#40;only those greater than 0&#41;.
	oslSetAlphaTest&#40;OSL_FXAT_GREATER, 0&#41;;

	oslSetDrawBuffer&#40;img&#41;;
	int posx = 0;
	for&#40;unsigned int g = 0; g < Images.size&#40;&#41;; g++&#41;
	&#123;
		oslDrawImageXY&#40;Images&#91;g&#93;, posx, 0&#41;;
		posx += Images&#91;g&#93;->sizeY;
		oslDeleteImage&#40;Images&#91;g&#93;&#41;;
	&#125;
	oslSetDrawBuffer&#40;OSL_DEFAULT_BUFFER&#41;;
	oslMoveImageTo&#40;	img, OSL_IN_RAM&#41;;
	return img;
&#125;
I hope someone or maybe even brunni can help me, it's really important
Sorry for my bad English... I'm still learning
Insert_witty_name
Posts: 376
Joined: Wed May 10, 2006 11:31 pm

Post by Insert_witty_name »

Using freetype at runtime like that is notoriously slow.

Hence why OSLib and other engines tend to use a bitmap font texture.
Post Reply