GP32 Text


seth

Member
Joined
Apr 28, 2003
Messages
171
Code:
#include "gpdef.h"
#include "gpstdlib.h"
#include "gpgraphic.h"
#include "gpmain.h"




GPDRAWSURFACE	gpDraw[2];

char g_string[256];

int    nflip = 0;

void GpMain(void *arg)
{
 
 
 Init();
 GameEngine;
 AllDraw();

}


void Init()
{

  int i;
  GpClockSpeedChange(132000000, 0x24001, 2);

 
  nflip = 1;

 
  for(i = 0; i < 2; i++)
  {
    GpLcdSurfaceGet(&gpDraw[i], i); 
  } 
 
  GpRectFill(NULL, &gpDraw[nflip], 0, 0, gpDraw[nflip].buf_w, gpDraw[nflip].buf_h, 0xff);

}




void GameEngine()
{
  while(1)
  {
   
     
    GpSurfaceFlip(&gpDraw[nflip++]);
    nflip &= 0x01;

  }
}



void AllDraw()
{
	int cx, cy = 10, cw, ch;

	
	
	//to draw text at the center of screen
	gp_str_func.strcpy(g_string, "screen center");
	cw = GpTextWidthGet(g_string);
	ch = GpTextHeightGet(g_string);
	cx = (LCD_WIDTH - cw) / 2;
	cy = (LCD_HEIGHT - ch) / 2;
	GpTextOut(NULL, &gpDraw, cx, cy, g_string, 0x02);
	while(1);

}



im trying to get my text in the bottom right hand corner but i cant seem to get the cords right

also can somone give me an example of the key gets for the buttons(A,B,Select,Start) the gp32 example pack only has the movment pad

and how would i make a block of text disaperee after a certain amount of time?
 
in Alldraw try this:

GpTextOut(NULL, gpdraw[nflip], cx, cy, g_string, 0x02);
 
GpTextOut(NULL, &gpdraw[nflip], cx, cy, g_string, 0x02);
i have forgat the "&" :rolleyes:
 
its an expression.

i mean it wont draw the text period(at all)
 
there is a big problem in your source:
In function GameEngine you enter in an eternal loop with while(1) before drawing anything on screen :rolleyes:
You should call Alldraw from your function game engine, or delete this while from GameEngine and put it into GpMain aroun line AllDraw()
 
gpdraw undeclared it's normal, your variable is called gpDraw

Add the prototypes or your functiuns after the includes, and global variables or type your function in order of use for exemple first Init, then AllDraw, follow by GameEngine and finally GpMain :)
 
Code:
#include "gpdef.h"
#include "gpstdlib.h"
#include "gpgraphic.h"
#include "gpmain.h"
#include "gpfont.h"

GPDRAWSURFACE gpDraw[2];
char g_string[256];
int nflip=0;

void Init()
{
	int i;
	GpClockSpeedChange(132000000, 0x24001, 2);
	nflip=1;
	for (i=0; i<2; i++)
	{
  GpLcdSurfaceGet(&gpDraw[i], i);
	}
	GpRectFill(NULL, &gpDraw[nflip], 0, 0, gpDraw[nflip].buf_w, gpDraw[nflip].buf_h, 0xff);
}

void GameEngine()
{
	GpSurfaceFlip(&gpDraw[nflip++]);
	nflip&=0x01;
}

void AllDraw()
{
	int cx, cy=10, cw, ch;
	gp_str_func.strcpy(g_string, "screen center");
	cw=GpTextWidthGet(g_string);
	ch=GpTextHeightGet(g_string);
	cx=(GPC_LCD_WIDTH-cw)/2;
	cy=(GPC_LCD_HEIGHT-cy)/2;
	GpTextOut(NULL, &gpDraw[nflip], cx, cy, g_string, 0x02);
}
void GpMain(void *arg)
{
	Init();
	while (1)
         {
                AllDraw();
        GameEngine();
         }
}
On my computer this work i only test it with geepee 32 not on my GP 32, and using SDT as compiler
 
I edit the code check out the nw version!!!
What errors do you get ???
 
still the text flickers in geepee 32


and besides you still havent anwsered the mina qustion:how do i change the position of the text?
 
Back
Top