For gba have a look at my scrolling with key input example. (http://itaprogaming.free.fr/download/scroll.zip) it is on http://itaprogaming.free.fr/ there you will find much more information.

Some step by step for gba:
1) Download the freepascal compiler for gba.
http://www.freepascal.org/down2/arm/...pascal.org.var
2) Install it.
3)Download my example and put it in the examples folder of freepascal compiler you just installed.
4)Execute build .bat . It will use the makefile.
5)Now you will get an .gba file.
4)Load that gba file with the gba-emulator.

If you want to look the source take a peek in main.pp. Ignore the other files. You may even delete the bmp and .c files. They are inbetween steps.

Compiling for the nds is even easier:
1) Download the freepascal for nds
2) Install it
3) Create a build.bat with the following lines:

Code:
ppcarmnds -g --gc-sections -Tnds openglex1.pas
ndstool -c openglex1.nds -9 openglex1.arm9.bin
dsbuild openglex1.nds -o openglex1.nds.gba
del *.bin
del *.o
del *.elf
4) this will give you an .nds file that you can use with your nds emulator.

Using the .gba and .nds on real hardware requires additional hardware. And insturction would be specific to the hardware device. I personally use an M3 adapter with passcard.

in case you want to know what openglex1.pas is:
Code:
program helloworld;

{$apptype arm9} //...or arm7
{$define ARM9}   //...or arm7, according to apptype

{$mode objfpc}   // required for some libc funcs implementation

uses
  ctypes; // required by nds headers!

{$include nds.inc}  // headers!


var
	i: integer;

function DrawGlScene(): shortint;  
begin
	//glLoadIdentity();									// Reset The Current Modelview Matrix
	glTranslatef(-1.5,0.0,-6.0);					// Move Left 1.5 Units And Into The Screen 6.0										
	glBegin(GL_TRIANGLES);						// Drawing Using Triangles
		glVertex3f( 0.0, 1.0, 0.0);				// Top
		glVertex3f(-1.0,-1.0, 0.0);				// Bottom Left
		glVertex3f( 1.0,-1.0, 0.0);				// Bottom Right
	glEnd();							// Finished Drawing The Triangle

	glTranslatef(3.0,0.0,0.0);					// Move Right 3 Units

	glBegin(GL_QUADS);						// Draw A Quad
		glVertex3f(-1.0, 1.0, 0.0);				// Top Left
		glVertex3f( 1.0, 1.0, 0.0);				// Top Right
		glVertex3f( 1.0,-1.0, 0.0);				// Bottom Right
		glVertex3f(-1.0,-1.0, 0.0);				// Bottom Left
	glEnd();							// Done Drawing The Quad


	result := GL_TRUE;
end;

begin

	
	// Turn on everything
	powerON(POWER_ALL);

	
	consoleDemoInit();
	
	// Setup the Main screen for 3D 
	videoSetMode(MODE_0_3D);
	
	printf('Hello OpenGL!'+#10);
	printf('www.pascalgamedevelopment.com'+#10);
	printf('http://itaprogaming.free.fr/'+#10);
	printf('http://3das.noeska.com');

	// IRQ basic setup
	//irqInitHandler(irqDefaultHandler);
	//irqSet(IRQ_VBLANK, 0);

	// Set our viewport to be the same size as the screen
	glViewPort(0,0,255,191);
	
	// Specify the Clear Color and Depth 
	glClearColor(0,0,0);
	glClearDepth($7FFF);
	
	while true do
	begin
		// Reset the screen and setup the view
		glReset();
		gluPerspective(35, 256.0 / 192.0, 0.1, 40);
		gluLookAt(	0.0, 0.0, 1.0,		
					0.0, 0.0, 0.0,		
					0.0, 1.0, 0.0);
					
		glPolyFmt(POLY_ALPHA(31) OR POLY_CULL_NONE);
		
		// Set the current matrix to be the model matrix
		glMatrixMode(GL_MODELVIEW);
		
		//Push our original Matrix onto the stack (save state)
		glPushMatrix();	
		glColor3f (1.0,1.0,1.0);								
		DrawGLScene();
		
		// Pop our Matrix from the stack (restore state)
		glPopMatrix(1);
		// flush to screen	
		glFlush();
	end;
end.