MorphOS Developer            
            
            
            
                             
             
                Posts: 1520 from 2003/2/24            
            
                From: Finland            
    
            
                            
                
			
				ScalePixelArray() / ScalePixelArrayAlpha() is accelerated on the most common gfx cards.
Using GL to scale bitmaps requires more work in terms of setting up initial setup but this is what I use in Frodo port for TGL scaling:
Setup:
Quote:
STATIC ULONG mSetupTGL(struct Display_Data *data, ULONG width, ULONG height, ULONG depth)
{
	struct Library *TinyGLBase;
	TinyGLBase = OpenLibrary("tinygl.library", 0);
	if (TinyGLBase)
	{
		data->TinyGLBase = TinyGLBase;
		if ((__tglContext = GLInit()))
		{
			data->Texture = (GLubyte *)AllocTaskPooled(DISPLAY_X * DISPLAY_Y * 4 * sizeof(GLubyte));
			if (data->Texture)
			{
				if (data->RastPort.BitMap)
					data->RastPort.BitMap	= AllocBitMap(width, height, depth, BMF_DISPLAYABLE|BMF_MINPLANES, _screen(data->ehn.ehn_Object)->RastPort.BitMap);
				if (data->RastPort.BitMap && glAInitializeContextBitMap(data->RastPort.BitMap))
				{
					glViewport(0 , 0 , width , height);
					glClearColor(0.0, 0.0, 0.0, 1.0);
					glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
					glMatrixMode(GL_PROJECTION);
					glLoadIdentity();
					glWindowPos2f(0, 0);
					glPixelZoom(1.0f * (float)width/(float)DISPLAY_X, -1.0f * (float)height/(float)DISPLAY_Y);
					glColorTable(GL_COLOR_TABLE, GL_RGBA, 256, GL_RGBA, GL_UNSIGNED_BYTE, data->TGLColours);
					data->GLRender	= TRUE;
					return TRUE;
				}
			}
		}
	}
	mCleanupTGL(data);
	return FALSE;
}
Cleanup:
Quote:
STATIC VOID mCleanupTGL(struct Display_Data *data)
{
	struct Library *TinyGLBase = data->TinyGLBase;
	if (TinyGLBase)
	{
		if (__tglContext)
		{
			if (data->Texture)
				FreeTaskPooled(data->Texture, DISPLAY_X * DISPLAY_Y * 4 * sizeof(GLubyte));
			if (data->RastPort.BitMap)
				glADestroyContextBitMap();
			GLClose(__tglContext);
		}
		CloseLibrary(TinyGLBase);
		data->Texture		= NULL;
		data->TinyGLBase	= NULL;
		data->GLRender		= FALSE;
		__tglContext		= NULL;
	}
}
Scaling/drawing:
Quote:
STATIC VOID mUpdateTGL(struct Display_Data *data, struct RastPort *rp, ULONG mleft, ULONG mtop, ULONG mwidth, ULONG mheight, GLubyte *buf)
{
	struct Library *TinyGLBase = data->TinyGLBase;
	glDrawPixels(DISPLAY_X, DISPLAY_Y, GL_COLOR_INDEX, GL_UNSIGNED_BYTE, buf);
	glFinish();
	data->GfxBufOk	= TRUE;
	BltBitMapRastPort(data->RastPort.BitMap, 0, 0, rp, mleft, mtop , mwidth, mheight, 0xc0);
}
It is understandable if you dont want to go this route. It requires relatively lot code to get it done and this example is designed for LUT8 bitmaps.
I think it is better use SW scaling. With altivec optimizations it is very quick.
1 + 1 = 3 with very large values of 1