Esempio n. 1
0
void Red3dInitScreen()
{
	
	intraFontInit();
    
	ltn = intraFontLoad("flash0:/font/ltn8.pgf", 0);
	if(!ltn) sceKernelExitGame();
	intraFontSetStyle(ltn, 1.0f, 0xFFFFFFFF, 0xBFBFBFBF, 0);
	
	void *fbp0 = vrelptr(valloc((FRAMEBUFFER_WIDTH * sizeof(unsigned int))   * SCREEN_HEIGHT));
	void *fbp1 = vrelptr(valloc((FRAMEBUFFER_WIDTH * sizeof(unsigned int))   * SCREEN_HEIGHT));
	void *zbp  = vrelptr(valloc((FRAMEBUFFER_WIDTH * sizeof(unsigned short)) * SCREEN_HEIGHT));
	
	pspDebugScreenInit();
	sceGuInit();
	sceGuStart(GU_DIRECT,list);

	sceGuDrawBuffer(GU_PSM_8888, fbp0, FRAMEBUFFER_WIDTH);
	sceGuDispBuffer(SCREEN_WIDTH, SCREEN_HEIGHT, fbp1, FRAMEBUFFER_WIDTH);
	sceGuDepthBuffer(zbp, FRAMEBUFFER_WIDTH);
	sceGuOffset(2048 - (SCREEN_WIDTH/2),2048 - (SCREEN_HEIGHT/2));
	sceGuViewport(2048, 2048, SCREEN_WIDTH, SCREEN_HEIGHT);
	sceGuDepthRange(65535, 0);
    sceGuScissor(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
    
    sceGuDepthFunc(GU_GEQUAL);
    sceGuEnable(GU_DEPTH_TEST);
	sceGuEnable(GU_SCISSOR_TEST);
	
	sceGuFrontFace(GU_CCW);
	sceGuShadeModel(GU_SMOOTH);
	sceGuEnable(GU_CULL_FACE);
	sceGuEnable(GU_CLIP_PLANES);
	
	sceGuEnable(GU_BLEND);
	sceGuBlendFunc(GU_ADD, GU_SRC_ALPHA, GU_ONE_MINUS_SRC_ALPHA, 0, 0);
	
	sceGuEnable(GU_TEXTURE_2D);
	sceGuTexFunc(GU_TFX_ADD,GU_TCC_RGBA);
	sceGuTexFilter(GU_LINEAR,GU_LINEAR);
	
	sceGuFinish();
	sceGuSync(0,0);
	
	Red3dSetupScreen();
	
}
byte* RenderTexture_GetTex(void)
{
	 byte *texture;
	 sceGuDrawBufferList(GU_PSM_4444,vrelptr(renderTarget), texture);
	 
	 

	 return reinterpret_cast<char*>(sceGeEdramGetAddr()) + reinterpret_cast<std::size_t>(vrelptr(renderTarget));
}
Esempio n. 3
0
	ya2d_Texture* ya2d_createTexture(int w, int h, int psm, ya2d_Place place)
	{
		ya2d_Texture* texp = (ya2d_Texture*)malloc(sizeof(ya2d_Texture));
		
		texp->imageWidth  = w;
		texp->imageHeight = h;
		texp->textureWidth  = next_pow2(w);
		texp->textureHeight = next_pow2(h);
		texp->centerX = (int)(w/2);
		texp->centerY = (int)(h/2);

		texp->texPSM = psm;
		texp->isSwizzled = 0;
		texp->hasAlpha   = 0;
		
		switch(psm)
		{
		case GU_PSM_4444:
		case GU_PSM_5650:
		case GU_PSM_5551:
			texp->rowBytes = texp->textureWidth * 2;
			break;
		case GU_PSM_8888:
		default:
			texp->rowBytes = texp->textureWidth * 4;
			break;
		}
			
		texp->dataLength = texp->rowBytes * texp->textureHeight;
		
		if(place == YA2D_VRAM)
		{
			if(texp->dataLength <= vlargestblock()) //enough free VRAM space
			{
				texp->data    = valloc(texp->dataLength);
				texp->rel_ptr = vrelptr(texp->data);
				texp->place   = YA2D_VRAM;
				return texp;
			}
		}
		texp->data    = malloc(texp->dataLength);
		texp->rel_ptr = texp->data;
		texp->place   = YA2D_RAM; 
		return texp;
	}