示例#1
0
void vidgu_init()
{

	g_pBlitBuff = (unsigned short *)(0x40000000 | (unsigned int)&g_BlitBuff);

	sceGuInit();

	// setup
	sceGuStart(GU_DIRECT,list);
	sceGuDrawBuffer(GU_PSM_5650,(void*)0,512);
	sceGuDispBuffer(480,272,(void*)0x88000,512);
	sceGuDepthBuffer((void*)0x110000,512);
	sceGuOffset(2048 - (480/2),2048 - (272/2));
	sceGuViewport(2048,2048,480,272);
	sceGuDepthRange(0xc350,0x2710);
	sceGuScissor(0,0,480,272);
	sceGuEnable(GU_SCISSOR_TEST);
	sceGuFrontFace(GU_CW);
	sceGuEnable(GU_TEXTURE_2D);
	sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT);
	sceGuFinish();
	sceGuSync(0,0);

	sceDisplayWaitVblankStart();
	sceGuDisplay(1);

}
示例#2
0
文件: main.c 项目: CDragu/pspsdk
void setupGu(void)
{
	sceGuInit();

	sceGuStart(GU_DIRECT, list);
	sceGuDrawBuffer(GU_PSM_8888, 0, BUF_WIDTH);
	sceGuDispBuffer(SCR_WIDTH, SCR_HEIGHT, (void*)0x88000, BUF_WIDTH);
	sceGuDepthBuffer((void*)0x110000, BUF_WIDTH);

	sceGuOffset(0, 0);

	sceGuScissor(0, 0, SCR_WIDTH, SCR_HEIGHT);
	sceGuEnable(GU_SCISSOR_TEST);

	sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0);
	sceGuEnable(GU_BLEND);

	//sceGuTexFunc(GU_TFX_MODULATE, GU_TCC_RGBA);
	//sceGuTexFilter(GU_LINEAR_MIPMAP_LINEAR, GU_NEAREST);
	//sceGuTexWrap(GU_REPEAT, GU_REPEAT);

	sceGuClearColor(0);
	sceGuClearDepth(0);
	sceGuClearStencil(0);

	sceGuFinish();
	sceGuSync(0, 0);
	
	sceDisplayWaitVblankStart();
	sceGuDisplay(GU_TRUE);
}
示例#3
0
文件: glib2d.c 项目: libcg/PSP_Bot
void _gInit()
{
  // Init & setup GU
  sceGuInit();
  sceGuStart(GU_DIRECT,list);

  sceGuDrawBuffer(GU_PSM_8888,(void*)FRAMEBUFFER_SIZE,PSP_LINE_SIZE);
  sceGuDispBuffer(G_SCR_W,G_SCR_H,(void*)0,PSP_LINE_SIZE);
  sceGuDepthBuffer((void*)(FRAMEBUFFER_SIZE*2),PSP_LINE_SIZE);
  sceGuOffset(2048-(G_SCR_W/2),2048-(G_SCR_H/2));
  sceGuViewport(2048,2048,G_SCR_W,G_SCR_H);

  gResetScissor();
  sceGuDepthRange(65535,0);
  sceGuClearDepth(65535);
  sceGuAlphaFunc(GU_GREATER,0,0xff);
  sceGuDepthFunc(GU_LEQUAL);
  sceGuBlendFunc(GU_ADD,GU_SRC_ALPHA,GU_ONE_MINUS_SRC_ALPHA,0,0);
  sceGuTexFunc(GU_TFX_MODULATE,GU_TCC_RGBA);
  sceGuTexFilter(GU_LINEAR,GU_LINEAR);
  sceGuShadeModel(GU_FLAT);

  sceGuDisable(GU_CULL_FACE);
  sceGuDisable(GU_CLIP_PLANES);
  sceGuDisable(GU_DITHER);
  sceGuEnable(GU_ALPHA_TEST);
  sceGuEnable(GU_SCISSOR_TEST);

  sceGuFinish();
  sceGuSync(0,0);
  sceDisplayWaitVblankStart();
  sceGuDisplay(GU_TRUE);

  init = G_TRUE;
}
示例#4
0
void testBlendFunc(const char *title, u32 prev, u32 c, int op, int src, int dst, u32 fixa, u32 fixb) {
	for (size_t i = 0; i < sizeof(copybuf) / 4; ++i) {
		copybuf[i] = prev;
	}
	sceKernelDcacheWritebackInvalidateAll();
	sceDmacMemcpy(sceGeEdramGetAddr(), copybuf, sizeof(copybuf));
	sceKernelDcacheWritebackInvalidateAll();

	sceGuStart(GU_DIRECT, list);

	sceGuEnable(GU_BLEND);
	sceGuBlendFunc(op, src, dst, fixa, fixb);

	sceGuEnable(GU_STENCIL_TEST);
	sceGuStencilFunc(GU_ALWAYS, 0xAA, 0xFF);
	sceGuStencilOp(GU_REPLACE, GU_REPLACE, GU_REPLACE);

	drawBoxCommands(c);

	sceGuFinish();
	sceGuSync(GU_SYNC_WAIT, GU_SYNC_WHAT_DONE);

	displayBuffer(title);

	sceGuDisable(GU_BLEND);
}
示例#5
0
void MasterGuRenderer::guInit() {
	DEBUG_ENTER_FUNC();

	sceGuInit();
	sceGuStart(0, _displayList);

	guProgramDisplayBufferSizes();

	sceGuOffset(2048 - (PSP_SCREEN_WIDTH / 2), 2048 - (PSP_SCREEN_HEIGHT / 2));
	sceGuViewport(2048, 2048, PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT);
	sceGuDepthRange(0xC350, 0x2710);
	sceGuDisable(GU_DEPTH_TEST);	// We'll use depth buffer area
	sceGuDepthMask(GU_TRUE);		// Prevent writes to depth buffer
	sceGuScissor(0, 0, PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT);
	sceGuEnable(GU_SCISSOR_TEST);
	sceGuFrontFace(GU_CW);
	sceGuEnable(GU_TEXTURE_2D);

	sceGuClear(GU_COLOR_BUFFER_BIT | GU_DEPTH_BUFFER_BIT);
	sceGuFinish();
	sceGuSync(0, 0);

	sceDisplayWaitVblankStart();
	sceGuDisplay(1);
}
示例#6
0
void psp_init(void)
{
	SceUID thid;
	char buff[128], *r;

	/* fw 1.5 sometimes returns 8002032c, although getcwd works */
	r = getcwd(buff, sizeof(buff));
	if (r) sceIoChdir(buff);

	main_thread_id = sceKernelGetThreadId();

	lprintf("running on %08x kernel\n", sceKernelDevkitVersion()),
	lprintf("entered psp_init, threadId %08x, priority %i\n", main_thread_id,
		sceKernelGetThreadCurrentPriority());

	thid = sceKernelCreateThread("update_thread", callback_thread, 0x11, 0xFA0, 0, NULL);
	if (thid >= 0)
	{
		sceKernelStartThread(thid, 0, 0);
	}

	/* video */
	sceDisplaySetMode(0, 480, 272);
	sceDisplaySetFrameBuf(VRAM_FB1, 512, PSP_DISPLAY_PIXEL_FORMAT_565, PSP_DISPLAY_SETBUF_NEXTFRAME);
	current_screen = 1;
	psp_screen = VRAM_FB0;

	/* gu */
	sceGuInit();

	sceGuStart(GU_DIRECT, guCmdList);
	sceGuDrawBuffer(GU_PSM_5650, (void *)VRAMOFFS_FB0, 512);
	sceGuDispBuffer(480, 272, (void *)VRAMOFFS_FB1, 512); // don't care
	sceGuClear(GU_COLOR_BUFFER_BIT | GU_DEPTH_BUFFER_BIT);
	sceGuDepthBuffer((void *)VRAMOFFS_DEPTH, 512);
	sceGuOffset(2048 - (480 / 2), 2048 - (272 / 2));
	sceGuViewport(2048, 2048, 480, 272);
	sceGuDepthRange(0xc350, 0x2710);
	sceGuScissor(0, 0, 480, 272);
	sceGuEnable(GU_SCISSOR_TEST);

	sceGuDepthMask(0xffff);
	sceGuDisable(GU_DEPTH_TEST);

	sceGuFrontFace(GU_CW);
	sceGuEnable(GU_TEXTURE_2D);
	sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGB);
	sceGuAmbientColor(0xffffffff);
	sceGuColor(0xffffffff);
	sceGuFinish();
	sceGuSync(0, 0);

	sceDisplayWaitVblankStart();
	sceGuDisplay(GU_TRUE);


	/* input */
	sceCtrlSetSamplingCycle(0);
	sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);
}
示例#7
0
文件: xtext.c 项目: Falaina/cspspemu
int xTextPrint(int x, int y, char* text)
{
    if (!x_current_font) return 0;
    if (!x_current_font->texture) return 0;
    
    float pos = (float)x;
	int len = strlen(text);
    int text_length = xTextLength(text, len);
    if (x_font_align == X_ALIGN_CENTER) pos -= 0.5f*text_length;
    else if (x_font_align == X_ALIGN_RIGHT) pos -= text_length;
    
    u16 char_width = x_current_font->texture->width/16;

    Text_Vert* vertices = (Text_Vert*)sceGuGetMemory(2*len*sizeof(Text_Vert));
    Text_Vert* vert_ptr = vertices;
    int i = 0;
    while (/* *text != '\0' && num >= 0 */ i < len)
    {
        int tx = (((u8)*text >> 0) & 0x0f) * char_width;
        int ty = (((u8)*text >> 4) & 0x0f) * char_width;

        vert_ptr->u = (s16)(tx);
        vert_ptr->v = (s16)(x_current_font->texture->height - ty);
		vert_ptr->color = x_font_color;
        vert_ptr->x = (int)(pos);
        vert_ptr->y = (int)(y);
        vert_ptr->z = 0.0f;
        
        vert_ptr += 1;
        pos += x_font_scale*x_current_font->widths[(u8)*text];

        vert_ptr->u = (s16)(tx + x_current_font->widths[(u8)*text]);
		vert_ptr->v = (s16)(x_current_font->texture->height - ty - char_width);
		vert_ptr->color = x_font_color;
        vert_ptr->x = (int)(pos);
        vert_ptr->y = (int)(y + x_font_scale*char_width);
        vert_ptr->z = 0.0f;
        
        vert_ptr += 1;
        text += 1;
        //num -= 1;
        i += 1;
    }

    xTexSetImage(x_current_font->texture);
    xGuSaveStates();
    sceGuEnable(GU_TEXTURE_2D);
    sceGuEnable(GU_BLEND);
    sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0);
    sceGuDisable(GU_DEPTH_TEST);
    sceGuDrawArray(GU_SPRITES, Text_Vert_vtype|GU_TRANSFORM_2D, 2*len, 0, vertices);
    xGuLoadStates();

    return (int)text_length;
}
示例#8
0
文件: Light.cpp 项目: PH3NIX/CubicVR
void Light::enable()
{
#ifdef ARCH_PSP
	sceGuEnable( GU_LIGHTING );		
	sceGuEnable( gl_lights[glLightId] );		
#else
#ifndef ARCH_DC
	glEnable(GL_LIGHTING);
	glEnable(glLightId);
#endif
#endif
};
示例#9
0
void drawTorus( int val )
{
    // setup a light

    ScePspFVector3 dir = { 0, 0, 1 };
    sceGuLight(0,GU_DIRECTIONAL,GU_DIFFUSE,&dir);
    sceGuLightColor(0,GU_DIFFUSE,0x00ff4040 );
    sceGuLightAtt(0,1.0f,0.0f,0.0f);
    sceGuAmbient(0x00202020);

    // setup texture
    sceGuDisable(GU_TEXTURE_2D);
    sceGuEnable(GU_LIGHTING);
    sceGuEnable(GU_LIGHT0);

    // setup matrices for torus

    sceGumMatrixMode(GU_PROJECTION);
    sceGumLoadIdentity();
    sceGumPerspective(75.0f,16.0f/9.0f,0.5f,1000.0f);

    sceGumMatrixMode(GU_VIEW);
    {
        ScePspFVector3 pos = {0.0f,0.0f,-2.5f};

        sceGumLoadIdentity();
        sceGumTranslate(&pos);
    }

    sceGumMatrixMode(GU_MODEL);
    {
        ScePspFVector3 rot = {val * 0.79f * (GU_PI/180.0f), val * 0.98f * (GU_PI/180.0f), val * 1.32f * (GU_PI/180.0f)};

        sceGumLoadIdentity();
        sceGumRotateXYZ(&rot);
    }

    // draw torus

    sceGuColor(0xffffff);
    sceGumDrawArray(GU_TRIANGLES,GU_NORMAL_32BITF|GU_VERTEX_32BITF|GU_INDEX_16BIT|GU_TRANSFORM_3D,sizeof(torus_indices)/sizeof(unsigned short),torus_indices,torus_vertices);


    // restore state

    sceGuDisable(GU_LIGHTING);
    sceGuDisable(GU_LIGHT0);
    sceGuEnable(GU_TEXTURE_2D);
}
		void SkyLight::Render()
		{
			sceGuEnable(GU_TEXTURE_2D);
			sceGuEnable(GU_BLEND);

			sceGuBlendFunc(GU_ADD, GU_FIX,GU_FIX, 0xFFFFFFFF, 0xFFFFFFFF);

			sceGumDrawArray(GU_TRIANGLE_STRIP, GU_TEXTURE_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_3D, 4, 0, skyVertices);

			sceGuDisable(GU_TEXTURE_2D);
			sceGuDisable(GU_BLEND);

			//make default blend function
			sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0);
		}
示例#11
0
void ya2d_drawRotateTexture(ya2d_Texture *texp, int x, int y, float angle)
{
        if(!texp->data) return;

		sceGuEnable(GU_TEXTURE_2D);

		sceGuTexMode(texp->texPSM, 0, 0, texp->isSwizzled);
		sceGuTexFunc(GU_TFX_REPLACE, texp->hasAlpha ? GU_TCC_RGBA : GU_TCC_RGB);
		
        ya2d_setTexture(texp);
			
		sceGumPushMatrix(); 
		sceGumLoadIdentity();
		{
			ScePspFVector3 pos = {x + (float)texp->centerX, y + (float)texp->centerY, 0.0f};
			sceGumTranslate(&pos);
			sceGumRotateZ(angle);
		}

		ya2d_FloatTextureVertex *vertices = (ya2d_FloatTextureVertex *)sceGuGetMemory(4 * sizeof(ya2d_FloatTextureVertex));
		
		vertices[0] = (ya2d_FloatTextureVertex){0.0f, 0.0f, (float)-texp->centerX, (float)-texp->centerY, 0.0f};
        vertices[1] = (ya2d_FloatTextureVertex){0.0f, 1.0f, (float)-texp->centerX, (float)texp->centerY, 0.0f};
        vertices[2] = (ya2d_FloatTextureVertex){1.0f, 0.0f, (float)texp->centerX, (float)-texp->centerY, 0.0f};
        vertices[3] = (ya2d_FloatTextureVertex){1.0f, 1.0f, (float)texp->centerX, (float)texp->centerY, 0.0f};
        
		sceGumDrawArray(GU_TRIANGLE_STRIP, GU_TEXTURE_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_3D, 4, 0, vertices);
        
        sceKernelDcacheWritebackRange(vertices, 4 * sizeof(ya2d_FloatTextureVertex));
        sceGumPopMatrix(); 
}
示例#12
0
void pgeTextureActivate(pgeTexture *texture)
{		
	if(texture->format == PGE_PIXEL_FORMAT_T4)
	{
		sceGuClutMode(texture->palFormat, 0, 0xff, 0);
		sceGuClutLoad(2, texture->palette);
	}
	else if(texture->format == PGE_PIXEL_FORMAT_T8)
	{
		sceGuClutMode(texture->palFormat, 0, 0xff, 0);
		sceGuClutLoad(32, texture->palette);
	}

	sceGuEnable(GU_TEXTURE_2D);
	sceGuTexWrap(GU_REPEAT, GU_REPEAT);
	sceGuTexFilter(GU_NEAREST, GU_NEAREST);
	sceGuTexFunc(pgeTextureMode, GU_TCC_RGBA);
	sceGuTexEnvColor(0xFFFFFFFF);
	sceGuColor(0xFFFFFFFF);
	sceGuAmbientColor(0xFFFFFFFF);
	sceGuTexOffset(0.0f, 0.0f);
	sceGuTexScale(1.0f/(float)texture->textureWidth, 1.0f/(float)texture->textureHeight);

	sceGuTexMode(texture->format, 0, 0, texture->swizzled);
	sceGuTexImage(0, texture->textureWidth, texture->textureHeight, texture->textureWidth, texture->data);
}
示例#13
0
void nextBoxHasColor(int *x, int *y, HasColorMode mode)
{
	VertexColor *sendVertices = mode & HASCOLOR_RGBA_TRANSPARENT ? transparentColorVertices : colorVertices;

	sendVertices[0].x = *x;
	sendVertices[0].y = *y;
	sendVertices[1].x = *x + 40;
	sendVertices[1].y = *y + 20;
	*x += 47;
	if (*x >= 470) {
		*x = 10;
		*y += 26;
	}
	sceKernelDcacheWritebackRange(sendVertices, sizeof(colorVertices));

	sceGuEnable(GU_TEXTURE_2D);
	sceGuTexMode(GU_PSM_T8, 0, 0, GU_FALSE);
	sceGuTexFunc(GU_TFX_DECAL, mode & HASCOLOR_RGB ? GU_TCC_RGB : GU_TCC_RGBA);
	sceGuTexImage(0, 4, 4, 16, imageData);

	sceGuDrawArray(GU_SPRITES, GU_COLOR_8888 | GU_TEXTURE_16BIT | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, NULL, sendVertices);
	sceGuFinish();
	sceGuSync(GU_SYNC_LIST, GU_SYNC_WHAT_DONE);
	sceGuSync(0, 0);
	sceGuStart(GU_DIRECT, list);
}
示例#14
0
void Red3dSetupLight(ScePspFVector3 pos, u32 dif, u32 spec)
{
	
	sceGuEnable(GU_LIGHTING);
	sceGuEnable(GU_LIGHT0);
	sceGuEnable(GU_LIGHT1);
	sceGuEnable(GU_LIGHT2);
	sceGuEnable(GU_LIGHT3);
	
	int lightnumber = 0;
	sceGuLight(lightnumber,GU_POINTLIGHT,GU_DIFFUSE_AND_SPECULAR,&pos);
	sceGuLightColor(lightnumber,GU_DIFFUSE,dif);
	sceGuLightColor(lightnumber,GU_SPECULAR,spec);
	sceGuLightAtt(lightnumber,0.0f,1.0f,0.0f);
	sceGuSpecular(12.0f);
	sceGuAmbient(0x00222222);
}
示例#15
0
void Red3dPrintf(const char *message, float font_size, int x, int y, u32 fg_color, u32 bg_color, ...)
{
	sceGuEnable(GU_TEXTURE_2D);
	sceGuEnable(GU_BLEND);
	char buffer[256];
	va_list ap;
	
	va_start(ap, message);
	vsnprintf(buffer, 256, message, ap);
	va_end(ap);
	buffer[255] = 0;
	
	intraFontSetStyle(ltn, font_size, fg_color, bg_color, 0);
	intraFontPrint(ltn, x, y, buffer);
	sceGuDisable(GU_BLEND);
	sceGuDisable(GU_TEXTURE_2D);
}
示例#16
0
void drawBG()
{
	sceGuSendCommandi(GE_CMD_MATERIALUPDATE, 0xFF);
	sceGuSendCommandi(GE_CMD_MATERIALAMBIENT, 0x550055);
	sceGuEnable(GU_TEXTURE_2D);
	sceGuTexMode(GU_PSM_T8, 0, 0, GU_FALSE);
	sceGuTexFunc(GU_TFX_DECAL, GU_TCC_RGBA);
	sceGuTexImage(0, 4, 4, 16, bgData);

	sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, NULL, bg);
}
示例#17
0
文件: glib2d.c 项目: libcg/PSP_Bot
void gEnd()
{
  if (!obj_begin || obj_list_size <= 0)
  {
    obj_begin = G_FALSE;
    return;
  }

  // Manage pspgu extensions
  if (obj_use_z)          sceGuEnable(GU_DEPTH_TEST);
  else                    sceGuDisable(GU_DEPTH_TEST);
  if (obj_use_blend)      sceGuEnable(GU_BLEND);
  else                    sceGuDisable(GU_BLEND);
  if (obj_use_vert_color) sceGuColor(WHITE);
  else                    sceGuColor(obj_list[0].color);
  if (!obj_use_tex)       sceGuDisable(GU_TEXTURE_2D);
  else
  {
    sceGuEnable(GU_TEXTURE_2D);
    if (obj_use_tex_linear) sceGuTexFilter(GU_LINEAR,GU_LINEAR);
    else                    sceGuTexFilter(GU_NEAREST,GU_NEAREST);
    if (obj_use_tex_repeat) sceGuTexWrap(GU_REPEAT,GU_REPEAT);
    else                    sceGuTexWrap(GU_CLAMP,GU_CLAMP);
    // Load texture
    sceGuTexMode(GU_PSM_8888,0,0,obj_tex->swizzled);
    sceGuTexImage(0,obj_tex->tw,obj_tex->th,obj_tex->tw,obj_tex->data);
  }

  switch (obj_type)
  {
    case RECTS: _gEndRects(); break;
    case LINES: _gEndLines(); break;
    case QUADS: _gEndQuads(); break;
  }

  sceGuColor(WHITE);
  sceGuEnable(GU_BLEND);

  obj_begin = G_FALSE;
  if (obj_use_z) zclear = G_TRUE;
}
示例#18
0
int os_fb_init(int argc, char** argv) {
	int i;
	if (os_byte_fb != NULL)
		return 1;
	//os_byte_fb = //(os_byte_t*) malloc(640*480*4);
	os_byte_fb = pixels;

	for (i = 0; i < 256; ++i) {
		os_fb_palette[i].r = 0;
		os_fb_palette[i].g = 0;
		os_fb_palette[i].b = 0;
	}

	pspDebugScreenInit();
	SetupCallbacks();

	sceGuInit();

	// setup
	sceGuStart(0,list);
	sceGuDrawBuffer(GE_PSM_4444,(void*)0,512);
	sceGuDispBuffer(480,272,(void*)0x88000,512);
	sceGuDepthBuffer((void*)0x110000,512);
	sceGuOffset(2048 - (480/2),2048 - (272/2));
	sceGuViewport(2048,2048,480,272);
	sceGuDepthRange(0xc350,0x2710);
	sceGuScissor(0,0,480,272);
	sceGuEnable(GU_STATE_SCISSOR);
	sceGuFrontFace(GE_FACE_CW);
	sceGuEnable(GU_STATE_TEXTURE);
	sceGuClear(GE_CLEAR_COLOR|GE_CLEAR_DEPTH);
	sceGuFinish();
	sceGuSync(0,0);

	sceDisplayWaitVblankStart();
	sceGuDisplay(1);

	return 0;
///	return x11_display_init(640, 480, "dacube2", argc, argv);
}
示例#19
0
 virtual void draw() {
     sceGuEnable(GU_TEXTURE_2D);
     sceGuTexMode(GU_PSM_8888, 0, 0, GU_FALSE);
     sceGuEnable(GU_BLEND);
     sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0);
     sceGuTexImage(0, 256, 256, 256, data_.get().data());
     sceGuTexFunc(GU_TFX_MODULATE, GU_TCC_RGBA);
     sceGuTexFilter(GU_LINEAR, GU_LINEAR);
     bright_texture_vertex * const vertex = static_cast<bright_texture_vertex *>(sceGuGetMemory(2 * sizeof(*vertex)));
     vertex[0].u = u_;
     vertex[0].v = v_;
     vertex[0].color = color_ | static_cast<boost::uint32_t>(alpha_) << 24;
     vertex[0].x = x_;
     vertex[0].y = y_;
     vertex[0].z = 0.f;
     vertex[1].u = u_ + u_size_;
     vertex[1].v = v_ + v_size_;
     vertex[1].color = color_ | static_cast<boost::uint32_t>(alpha_) << 24;
     vertex[1].x = x_ + width_;
     vertex[1].y = y_ + height_;
     vertex[1].z = 0.f;
     sceGuDrawArray(GU_SPRITES, GU_TEXTURE_32BITF | GU_COLOR_8888 | GU_VERTEX_32BITF | GU_TRANSFORM_2D, 2, 0, vertex);
 }
示例#20
0
void Sprite::Draw()
{
    sceGumPushMatrix();

    ScePspFVector3 loc = {posX,posY,0.0f};
    sceGumTranslate(&loc);

    sceGuEnable(GU_TEXTURE_2D);
    TextureManager::Instance()->SetTexture(imageName,GU_NEAREST,GU_NEAREST);

    sceGumDrawArray(GU_TRIANGLE_STRIP,GU_TEXTURE_32BITF|GU_VERTEX_32BITF|GU_TRANSFORM_3D, 4, 0, vertices);

    sceGuDisable(GU_TEXTURE_2D);
    sceGumPopMatrix();
}
示例#21
0
void Texture::use()
{
#ifdef ARCH_PSP
	sceGuEnable( GU_TEXTURE_2D );
	sceGuTexFilter( GU_LINEAR, GU_LINEAR );	
	sceGuTexMode( GU_PSM_8888, 0, 0, psp_texture.Swizzled() );	
 	sceGuTexImage( 0, psp_texture.Width(), psp_texture.Height(), psp_texture.Width(), psp_texture.Image() );
	sceGuTexFunc( GU_TFX_MODULATE, GU_TCC_RGB );
	sceGuTexScale( 1.0f, 1.0f );                    // No scaling
	sceGuTexOffset( 0.0f, 0.0f );		
#else
	glEnable(GL_TEXTURE_2D);
	glBindTexture(GL_TEXTURE_2D,glTexId);
#endif
};
示例#22
0
void drawTexFlush(int width, int height, int stride, int texfmt, const void *tex, const void *clut, int clutfmt, int blocks, const void *verts, int indexMask) {
	sceGuStart(GU_DIRECT, list);

	sceGuEnable(GU_TEXTURE_2D);
	sceGuTexMode(texfmt, 0, 0, GU_FALSE);
	sceGuTexFunc(GU_TFX_DECAL, GU_TCC_RGB);
	sceGuTexImage(0, width, height, stride, tex);

	sceGuClutLoad(blocks, clut);
	sceGuClutMode(clutfmt, 0, indexMask, 0);
	sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, NULL, verts);

	sceGuFinish();
	sceGuSync(0, 0);
}
示例#23
0
int MFRenderer_CreateDisplay()
{
	gDisplay.width = SCR_WIDTH;
	gDisplay.height = SCR_HEIGHT;
	gDisplay.wide = true;

	gCurrentViewport.x = 0.0f;
	gCurrentViewport.y = 0.0f;
	gCurrentViewport.width = SCR_WIDTH;
	gCurrentViewport.height = SCR_HEIGHT;

	sceGuInit();

	sceGuStart(GU_DIRECT, displayList);
	sceGuDrawBuffer(GU_PSM_8888, (void*)0, BUF_WIDTH);
	sceGuDispBuffer(SCR_WIDTH, SCR_HEIGHT, (void*)FRAME_SIZE, BUF_WIDTH);
	sceGuDepthBuffer((void*)(FRAME_SIZE*2), BUF_WIDTH);
	sceGuOffset(2048 - (SCR_WIDTH/2), 2048 - (SCR_HEIGHT/2));
	sceGuViewport(2048, 2048, SCR_WIDTH, SCR_HEIGHT);
	sceGuDepthRange(0x0, 0xFFFF);
	sceGuScissor(0, 0, SCR_WIDTH, SCR_HEIGHT);
	sceGuEnable(GU_SCISSOR_TEST);
	sceGuDepthFunc(GU_LEQUAL);
	sceGuEnable(GU_DEPTH_TEST);
	sceGuFrontFace(GU_CCW); // NOTE: not CCW
	sceGuShadeModel(GU_SMOOTH);
	sceGuDisable(GU_CULL_FACE);
	sceGuEnable(GU_TEXTURE_2D);
	sceGuFinish();
	sceGuSync(0, 0);

	sceDisplayWaitVblankStart();
	sceGuDisplay(GU_TRUE);

	return 0;
}
示例#24
0
void
psp_sdl_gu_init(void)
{
	sceGuStart(GU_DIRECT,list);
	sceGuEnable(GU_TEXTURE_2D);
	sceGuTexMode(GU_PSM_5650, 0, 0, GU_FALSE);
	sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGB);
	sceGuTexFilter(GU_LINEAR, GU_LINEAR);
	sceGuDisable(GU_BLEND);
  sceGuDisable(GU_DEPTH_TEST);
	sceGuFinish();
	sceGuSync(0, 0);

  sceDisplayWaitVblankStart();
}
示例#25
0
void init()
{
	void *fbp0 = 0;
 
	sceGuInit();
	sceGuStart(GU_DIRECT, list);
	sceGuDrawBuffer(GU_PSM_8888, fbp0, BUF_WIDTH);
	sceGuDispBuffer(SCR_WIDTH, SCR_HEIGHT, fbp0, BUF_WIDTH);
	sceGuScissor(0, 0, SCR_WIDTH, SCR_HEIGHT);
	sceGuEnable(GU_SCISSOR_TEST);
	sceGuFinish();
	sceGuSync(0, 0);
 
	sceDisplayWaitVblankStart();
	sceGuDisplay(1);
}
示例#26
0
static void gba_upload_vram (void)
{
   sceGuDisable(GU_SCISSOR_TEST);
   sceGuDisable(GU_DEPTH_TEST);

   sceGuEnable(GU_TEXTURE_2D);

   sceGuTexMode(GU_PSM_T8, 0, 0, GU_FALSE);
   sceGuClutMode(GU_PSM_5551,0,0xFF,0);
   sceGuClutLoad(32, index_copy_clut);


   sceGuDrawBufferList(GU_PSM_5551, GBA_VRAMTEXTURE_8bit_GU, 128);
   sceGuTexImage(0, 128, 256, 128, vram);
   sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT |
         GU_TRANSFORM_2D, 2, NULL,(void*)(vram_cache_coords_8bit));

   sceGuDrawBufferList(GU_PSM_5551, (u16*)GBA_VRAMTEXTURE_8bit_GU + (128*256), 128);
   sceGuTexImage(0, 128, 256, 128, vram + (128*256));
   sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT |
         GU_TRANSFORM_2D, 2, NULL,(void*)(vram_cache_coords_8bit));

   sceGuDrawBufferList(GU_PSM_5551, (u16*)GBA_VRAMTEXTURE_8bit_GU + (128*256*2), 128);
   sceGuTexImage(0, 128, 256, 128, vram + (128*256) * 2);
   sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT |
         GU_TRANSFORM_2D, 2, NULL,(void*)(vram_cache_coords_8bit));

   sceGuTexMode(GU_PSM_T4, 0, 0, GU_FALSE);
   sceGuClutMode(GU_PSM_5551,0,0xFF,0);
   sceGuClutLoad(32, index_copy_clut);

   sceGuDrawBufferList(GU_PSM_5551, GBA_VRAMTEXTURE_4bit_GU, 256);
   sceGuTexImage(0, 256, 256, 256, vram);
   sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT |
         GU_TRANSFORM_2D, 2, NULL,(void*)(vram_cache_coords_4bit));

   sceGuDrawBufferList(GU_PSM_5551, (u16*)GBA_VRAMTEXTURE_4bit_GU + (256*256) , 256);
   sceGuTexImage(0, 256, 256, 256, vram + (256 * 256 / 2));
   sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT |
         GU_TRANSFORM_2D, 2, NULL,(void*)(vram_cache_coords_4bit));

   sceGuDrawBufferList(GU_PSM_5551, (u16*)GBA_VRAMTEXTURE_4bit_GU + (256*256) * 2, 256);
   sceGuTexImage(0, 256, 256, 256, vram + (256 * 256 / 2)*2);
   sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT |
         GU_TRANSFORM_2D, 2, NULL,(void*)(vram_cache_coords_4bit));

}
示例#27
0
    void ya2d_drawTexture(ya2d_Texture *texp, int x, int y)
    {
        if(!texp->data) return;
        
		sceGuEnable(GU_TEXTURE_2D);

		sceGuTexMode(texp->texPSM, 0, 0, texp->isSwizzled);
		sceGuTexFunc(GU_TFX_REPLACE, texp->hasAlpha ? GU_TCC_RGBA : GU_TCC_RGB);
		
        ya2d_setTexture(texp);		

		if(texp->textureWidth <= YA2D_TEXTURE_SLICE)
		{
			ya2d_TextureVertex *vertices = (ya2d_TextureVertex *)sceGuGetMemory(4 * sizeof(ya2d_TextureVertex));

			vertices[0] = (ya2d_TextureVertex){0, 0, x, y, 0};
			vertices[1] = (ya2d_TextureVertex){0, texp->textureHeight, x, y+texp->textureHeight, 0};
			vertices[2] = (ya2d_TextureVertex){texp->textureWidth, 0, x+texp->textureWidth, y, 0};
			vertices[3] = (ya2d_TextureVertex){texp->textureWidth, texp->textureHeight, x+texp->textureWidth, y+texp->textureHeight, 0};

			sceGumDrawArray(GU_TRIANGLE_STRIP, GU_TEXTURE_16BIT|GU_VERTEX_16BIT|GU_TRANSFORM_2D, 4, 0, vertices);
			
			sceKernelDcacheWritebackRange(vertices, 4 * sizeof(ya2d_TextureVertex));
		}
		else //Fast draw for big textures
		{
			int i;
			for(i = 0; i < texp->textureWidth; i+= YA2D_TEXTURE_SLICE)
			{
				/*
				ya2d_TextureVertex *vertices = (ya2d_TextureVertex *)sceGuGetMemory(4 * sizeof(ya2d_TextureVertex));
				vertices[0] = (ya2d_TextureVertex){i, 0, x+i, y, 0};
				vertices[1] = (ya2d_TextureVertex){i+YA2D_TEXTURE_SLICE, 0, x+i+YA2D_TEXTURE_SLICE, y, 0};
				vertices[2] = (ya2d_TextureVertex){i, texp->textureHeight, x+i, y+texp->textureHeight, 0};
				vertices[3] = (ya2d_TextureVertex){i+YA2D_TEXTURE_SLICE, texp->textureHeight, x+i+YA2D_TEXTURE_SLICE, y+texp->textureHeight, 0};
				sceGumDrawArray(GU_TRIANGLE_STRIP, GU_TEXTURE_16BIT|GU_VERTEX_16BIT|GU_TRANSFORM_2D, 4, 0, vertices);
				sceKernelDcacheWritebackRange(vertices, 4 * sizeof(ya2d_TextureVertex));
				*/
				
				ya2d_TextureVertex *vertices = (ya2d_TextureVertex *)sceGuGetMemory(2 * sizeof(ya2d_TextureVertex));
				vertices[0] = (ya2d_TextureVertex){i, 0, x+i, y, 0};
				vertices[1] = (ya2d_TextureVertex){i+YA2D_TEXTURE_SLICE, texp->textureHeight, x+i+YA2D_TEXTURE_SLICE, y+texp->textureHeight, 0};
				sceGumDrawArray(GU_SPRITES, GU_TEXTURE_16BIT|GU_VERTEX_16BIT|GU_TRANSFORM_2D, 2, 0, vertices);
				sceKernelDcacheWritebackRange(vertices, 2 * sizeof(ya2d_TextureVertex));
			}			
		}   
    }
示例#28
0
static void psp_set_texture_frame(void *data, const void *frame, bool rgb32,
                               unsigned width, unsigned height, float alpha)
{
   psp1_video_t *psp = (psp1_video_t*)data;

   (void) rgb32;
   (void) alpha;

#ifdef DEBUG
   /* psp->menu.frame buffer size is (480 * 272)*2 Bytes */
   rarch_assert((width*height) < (480 * 272));
#endif

   psp_set_screen_coords(psp->menu.frame_coords, 0, 0,
         SCEGU_SCR_WIDTH, SCEGU_SCR_HEIGHT, 0);
   psp_set_tex_coords(psp->menu.frame_coords, width, height);

   sceKernelDcacheWritebackRange(frame, width * height * 2);

   sceGuStart(GU_DIRECT, psp->main_dList);
   sceGuCopyImage(GU_PSM_4444, 0, 0, width, height, width,
         (void*)frame, 0, 0, width, psp->menu.frame);
   sceGuFinish();

   sceGuStart(GU_SEND, psp->menu.dList);
   sceGuTexMode(GU_PSM_4444, 0, 0, GU_FALSE);
   sceGuTexFunc(GU_TFX_REPLACE, GU_TCC_RGB);
   sceGuTexFilter(GU_LINEAR, GU_LINEAR);
   sceGuTexImage(0, next_pow2(width), next_pow2(height), width, psp->menu.frame);
   sceGuEnable(GU_BLEND);

#if 0
   /* default blending */
   sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0);
#endif
   sceGuBlendFunc(GU_ADD, GU_FIX, GU_FIX, 0xF0F0F0F0, 0x0F0F0F0F);
;
   sceGuDrawArray(GU_SPRITES, GU_TEXTURE_32BITF | GU_VERTEX_32BITF | 
         GU_TRANSFORM_2D, PSP_FRAME_VERTEX_COUNT, NULL,
         psp->menu.frame_coords);
   sceGuFinish();

}
示例#29
0
void drawCube( Texture* texture, int val )
{
    // setup matrices for cube

    sceGumMatrixMode(GU_PROJECTION);
    sceGumLoadIdentity();
    sceGumPerspective(75.0f,16.0f/9.0f,0.5f,1000.0f);

    sceGumMatrixMode(GU_VIEW);
    {
        ScePspFVector3 pos = {0.0f,0.0f,-2.5f};

        sceGumLoadIdentity();
        sceGumTranslate(&pos);
    }

    sceGumMatrixMode(GU_MODEL);
    {
        ScePspFVector3 rot = {val * 0.263f * (GU_PI/180.0f), val * 0.32f * (GU_PI/180.0f), val * 0.44f * (GU_PI/180.0f)};

        sceGumLoadIdentity();
        sceGumRotateXYZ(&rot);
    }

    // setup texture

    sceGuTexMode(texture->format,0,0,0);
    sceGuTexImage(texture->mipmap,texture->width,texture->height,texture->stride,texture->data);
    sceGuTexFunc(GU_TFX_ADD,GU_TCC_RGB);
    sceGuTexFilter(GU_LINEAR,GU_LINEAR);
    sceGuTexScale(1.0f,1.0f);
    sceGuTexOffset(0.0f,0.0f);
    sceGuAmbientColor(0xffffffff);

    sceGuEnable(GU_TEXTURE_2D);

    // draw cube

    sceGumDrawArray(GU_TRIANGLES,GU_TEXTURE_32BITF|GU_COLOR_8888|GU_VERTEX_32BITF|GU_TRANSFORM_3D,12*3,0,cube_vertices);

    sceGuDisable(GU_TEXTURE_2D);
}
示例#30
0
void init() { 
	sceGuInit();
	sceGuStart(GU_DIRECT, list);
	sceGuDrawBuffer(GU_PSM_8888, fbp0, 512);
	sceGuDispBuffer(480, 272, fbp0, 512);
	sceGuDepthBuffer(dbp0, 512);
	sceGuOffset(2048 - (240 / 2), 2048 - (136 / 2));
	sceGuViewport(2048, 2048, 240, 136);
	sceGuDepthRange(65535, 0);
	sceGuDepthMask(0);
	sceGuScissor(0, 0, 480, 272);
	sceGuEnable(GU_SCISSOR_TEST);
	sceGuFrontFace(GU_CW);
	sceGuShadeModel(GU_SMOOTH);
	sceGuDisable(GU_TEXTURE_2D);

	ScePspFMatrix4 ones = {
		{1, 0, 0, 0},
		{0, 1, 0, 0},
		{0, 0, 1, 0},
		{0, 0, 0, 1},
	};

	sceGuSetMatrix(GU_MODEL, &ones);
	sceGuSetMatrix(GU_VIEW, &ones);
	sceGuSetMatrix(GU_PROJECTION, &ones);

	sceGuFinish();
	sceGuSync(0, 0);
 
	sceDisplayWaitVblankStart();
	sceGuDisplay(1);

	memset(copybuf, 0x44, sizeof(copybuf));
	sceKernelDcacheWritebackInvalidateAll();
	sceDmacMemcpy(sceGeEdramGetAddr(), copybuf, sizeof(copybuf));
	sceKernelDcacheWritebackInvalidateAll();

	displayBuffer("Initial");
}