コード例 #1
0
ファイル: graphics.cpp プロジェクト: piaoasd123/Fwankie
void HGE_CALL HGE_Impl::Gfx_EndScene()
{
	_render_batch(true);
	m_pSwapChain->Present(0, 0);
	// 	pD3DDevice->EndScene();
	// 	if (!pCurTarget) pD3DDevice->Present(NULL, NULL, NULL, NULL);
}
コード例 #2
0
ファイル: graphics.cpp プロジェクト: piaoasd123/Fwankie
void HGE_CALL HGE_Impl::Gfx_RenderLine(float x1, float y1, float x2, float y2, hgeU32 color, float z)
{
	if (m_vertices)
	{
		//Currently batching lines?
		if (m_cur_prim_type != HGEPRIM_LINES ||
			//Will the buffer have enough space?
			m_prim_count >= VERTEX_BUFFER_SIZE / HGEPRIM_LINES ||
			//Is there any texture related rendering?
			m_cur_texture ||
			//Currently lines only render in default mode
			m_cur_blend_mode != BLEND_DEFAULT)
		{
			//Must render the batch now
			_render_batch();

			//start a new batch
			m_cur_prim_type = HGEPRIM_LINES;
			if (m_cur_blend_mode != BLEND_DEFAULT)
			{
				_SetBlendMode(BLEND_DEFAULT);
			}
			if (m_cur_texture)
			{
				m_pD3DDeviceContext->PSSetShaderResources(0, 1, NULL);
				m_cur_texture = NULL;
			}
		}

		int i = m_prim_count * HGEPRIM_LINES;
		m_vertices[i] = { x1, y1, z, color, .0f, .0f };
		m_vertices[i + 1] = { x2, y2, z, color, .0f, .0f };
		m_prim_count++;
	}
}
コード例 #3
0
ファイル: graphics.cpp プロジェクト: funcman/bsgl
void CALL BSGL_Impl::Gfx_RenderTriple(const bsglTriple* triple) {
    if( (CurPrimType != BSGLPRIM_TRIPLES)
    ||  (nPrim >= VERTEX_BUFFER_SIZE/BSGLPRIM_TRIPLES)
    ||  (CurTexture != triple->tex)
    ||  (CurBlendMode != triple->blend) ) {
        _render_batch();

        CurPrimType = BSGLPRIM_TRIPLES;
        if( CurBlendMode != triple->blend ) {
            _SetBlendMode(triple->blend);
        }
        if( CurTexture != triple->tex ) {
            if( triple->tex ) {
#if !defined(Q_OS_IOS) && !defined(Q_OS_ANDROID)
                glBindTexture(GL_TEXTURE_2D, *(GLuint*)triple->tex);
            }else {
                glBindTexture(GL_TEXTURE_2D, 0);
#else
                setTextureUnit(*(GLuint*)triple->tex);
            }else {
                setTextureUnit(0);
#endif
            }
            CurTexture = triple->tex;
        }
コード例 #4
0
ファイル: system.cpp プロジェクト: cscjx321/hge_game
void CALL HGE_Impl::System_SetStateBool(hgeBoolState state, bool value)
{
	switch(state)
	{
		case HGE_WINDOWED:		if(VertArray || hwndParent) break;
								if(pD3DDevice && bWindowed != value)
								{
									if(d3dppW.BackBufferFormat==D3DFMT_UNKNOWN || d3dppFS.BackBufferFormat==D3DFMT_UNKNOWN) break;

									if(bWindowed) GetWindowRect(hwnd, &rectW);
									bWindowed=value;
									if(bWindowed) d3dpp=&d3dppW;
									else d3dpp=&d3dppFS;

									if(_format_id(d3dpp->BackBufferFormat) < 4) nScreenBPP=16;
									else nScreenBPP=32;

									_GfxRestore();
									_AdjustWindow();
								}
								else bWindowed=value;
								break;

		case HGE_ZBUFFER:		if(!pD3DDevice)	bZBuffer=value;
								break;

		case HGE_TEXTUREFILTER: bTextureFilter=value;
								if(pD3DDevice)
								{
									_render_batch();
									if(bTextureFilter)
									{
										pD3DDevice->SetTextureStageState(0,D3DTSS_MAGFILTER,D3DTEXF_LINEAR);
										pD3DDevice->SetTextureStageState(0,D3DTSS_MINFILTER,D3DTEXF_LINEAR);
									}
									else
									{
										pD3DDevice->SetTextureStageState(0,D3DTSS_MAGFILTER,D3DTEXF_POINT);
										pD3DDevice->SetTextureStageState(0,D3DTSS_MINFILTER,D3DTEXF_POINT);
									}
								}
								break;

		case HGE_USESOUND:		if(bUseSound!=value)
								{
									bUseSound=value;
									if(bUseSound && hwnd) _SoundInit();
									if(!bUseSound && hwnd) _SoundDone();
								}
								break;

		case HGE_HIDEMOUSE:		bHideMouse=value; break;

		case HGE_DONTSUSPEND:	bDontSuspend=value; break;

		#ifdef DEMO
		case HGE_SHOWSPLASH:	bDMO=value; break;
		#endif
	}
}
コード例 #5
0
ファイル: graphics.cpp プロジェクト: meesokim/bluemsx-wii
void CALL HGE_Impl::Gfx_SetClipping(int x, int y, int w, int h)
{
    D3DVIEWPORT8 vp;
    int scr_width, scr_height;

    if(!pCurTarget) {
        scr_width=pHGE->System_GetStateInt(HGE_SCREENWIDTH);
        scr_height=pHGE->System_GetStateInt(HGE_SCREENHEIGHT);
    }
    else {
        scr_width=Texture_GetWidth((HTEXTURE)pCurTarget->pTex);
        scr_height=Texture_GetHeight((HTEXTURE)pCurTarget->pTex);
    }

    if(!w) {
        vp.X=0;
        vp.Y=0;
        vp.Width=scr_width;
        vp.Height=scr_height;
    }
    else
    {
        if(x<0) { w+=x; x=0; }
        if(y<0) { h+=y; y=0; }

        if(x+w > scr_width) w=scr_width-x;
        if(y+h > scr_height) h=scr_height-y;

        vp.X=x;
        vp.Y=y;
        vp.Width=w;
        vp.Height=h;
    }

    vp.MinZ=0.0f;
    vp.MaxZ=1.0f;

    _render_batch();
    pD3DDevice->SetViewport(&vp);

    D3DXMATRIX tmp;
    D3DXMatrixScaling(&matProj, 1.0f, -1.0f, 1.0f);
    D3DXMatrixTranslation(&tmp, -0.5f, +0.5f, 0.0f);
    D3DXMatrixMultiply(&matProj, &matProj, &tmp);
    D3DXMatrixOrthoOffCenterLH(&tmp, (float)vp.X, (float)(vp.X+vp.Width), -((float)(vp.Y+vp.Height)), -((float)vp.Y), vp.MinZ, vp.MaxZ);
    D3DXMatrixMultiply(&matProj, &matProj, &tmp);
#ifdef UNDER_CE
    pD3DDevice->SetTransform(D3DTS_PROJECTION, (D3DMMATRIX*)&matProj, D3DMFMT_D3DMVALUE_FLOAT);
#else
    pD3DDevice->SetTransform(D3DTS_PROJECTION, &matProj);
#endif
}
コード例 #6
0
ファイル: graphics.cpp プロジェクト: piaoasd123/Fwankie
void HGE_CALL HGE_Impl::Gfx_RenderQuad(const hgeQuad *quad)
{
	if (m_vertices)
	{
		//Currently batching quads?
		if (m_cur_prim_type != HGEPRIM_QUADS ||
			//Will the buffer have enough space?
			m_prim_count >= VERTEX_BUFFER_SIZE / HGEPRIM_QUADS ||
			//Is there any texture related rendering?
			(m_cur_texture != quad->tex) ||
			//Currently lines only render in default mode
			m_cur_blend_mode != quad->blend)
		{
			//Must render the batch now
			_render_batch();

			//start a new batch
			m_cur_prim_type = HGEPRIM_QUADS;
			if (m_cur_blend_mode != quad->blend)
			{
				//_SetBlendMode(quad->blend);
			}
			if (m_cur_texture != quad->tex)
			{
				auto* pTex = (CTextureList*)quad->tex;
				m_pD3DDeviceContext->PSSetShaderResources(0, 1, &(pTex->m_pSRV));
				m_cur_texture = quad->tex;
			}
		}

		//First triangle: 0 1 2
		memcpy(
			&m_vertices[m_prim_count*HGEPRIM_QUADS],
			&(quad->v[0]),
			sizeof(hgeVertex)*HGEPRIM_QUADS / 2);
		//Second triangle 1 2 3
		memcpy(
			&m_vertices[m_prim_count*HGEPRIM_QUADS + HGEPRIM_QUADS / 2],
			&(quad->v[1]),
			sizeof(hgeVertex)*HGEPRIM_QUADS / 2);
		m_prim_count++;
	}
}
コード例 #7
0
ファイル: graphics.cpp プロジェクト: piaoasd123/Fwankie
//deprecated
void HGE_CALL HGE_Impl::Gfx_SetTransform(float x, float y, float dx, float dy, float rot, float hscale, float vscale)
{
	// 	D3DXMATRIX tmp;
	// 
	// 	if (vscale == 0.0f) D3DXMatrixIdentity(&matView);
	// 	else
	// 	{
	// 		D3DXMatrixTranslation(&matView, -x, -y, 0.0f);
	// 		D3DXMatrixScaling(&tmp, hscale, vscale, 1.0f);
	// 		D3DXMatrixMultiply(&matView, &matView, &tmp);
	// 		D3DXMatrixRotationZ(&tmp, -rot);
	// 		D3DXMatrixMultiply(&matView, &matView, &tmp);
	// 		D3DXMatrixTranslation(&tmp, x + dx, y + dy, 0.0f);
	// 		D3DXMatrixMultiply(&matView, &matView, &tmp);
	// 	}

	_render_batch();
	//pd3dDevice->SetTransform(D3DTS_VIEW, &matView);
}
コード例 #8
0
ファイル: graphics.cpp プロジェクト: meesokim/bluemsx-wii
void CALL HGE_Impl::Gfx_RenderQuad(const hgeQuad *quad)
{
	if(VertArray)
	{
		if(CurPrimType!=HGEPRIM_QUADS || nPrim>=VERTEX_BUFFER_SIZE/HGEPRIM_QUADS || CurTexture!=quad->tex || CurBlendMode!=quad->blend)
		{
			_render_batch();

			CurPrimType=HGEPRIM_QUADS;
			if(CurBlendMode != quad->blend) _SetBlendMode(quad->blend);
			if(quad->tex != CurTexture)
			{
				pD3DDevice->SetTexture( 0, (LPDIRECT3DTEXTURE8)quad->tex );
				CurTexture = quad->tex;
			}
		}

		memcpy(&VertArray[nPrim*HGEPRIM_QUADS], quad->v, sizeof(hgeVertex)*HGEPRIM_QUADS);
		nPrim++;
	}
}
コード例 #9
0
ファイル: graphics.cpp プロジェクト: meesokim/bluemsx-wii
void CALL HGE_Impl::Gfx_EndScene()
{
    _render_batch(true);
    pD3DDevice->EndScene();
    if(!pCurTarget) pD3DDevice->Present( NULL, NULL, NULL, NULL );
}
コード例 #10
0
ファイル: graphics.cpp プロジェクト: piaoasd123/Fwankie
void HGE_CALL HGE_Impl::Gfx_SetClipping(int x, int y, int w, int h)
{
	// Set the viewport
	D3D11_VIEWPORT vp;
	ZeroMemory(&vp, sizeof(D3D11_VIEWPORT));

	vp.TopLeftX = 0;
	vp.TopLeftY = 0;
	vp.Width = nScreenWidth;
	vp.Height = nScreenHeight;


	int scr_width, scr_height;

	if (!pCurTarget)
	{
		scr_width = pHGE->System_GetStateInt(HGE_SCREENWIDTH);
		scr_height = pHGE->System_GetStateInt(HGE_SCREENHEIGHT);
	}
	else
	{
		scr_width = Texture_GetWidth((HTEXTURE)pCurTarget->pTex);
		scr_height = Texture_GetHeight((HTEXTURE)pCurTarget->pTex);
	}

	if (!w)
	{
		vp.TopLeftX = 0;
		vp.TopLeftY = 0;
		vp.Width = scr_width;
		vp.Height = scr_height;
	}
	else
	{
		if (x<0) { w += x; x = 0; }
		if (y<0) { h += y; y = 0; }

		if (x + w > scr_width) w = scr_width - x;
		if (y + h > scr_height) h = scr_height - y;

		vp.TopLeftX = x;
		vp.TopLeftY = y;
		vp.Width = w;
		vp.Height = h;
	}

	vp.MinDepth = 0.0f;
	vp.MaxDepth = 1.0f;

	_render_batch();
	m_pD3DDeviceContext->RSSetViewports(1, &vp);

	//Adjust scaling and orthogonal arguments accordingly.
	// 	D3DXMATRIX tmp;
	// 	D3DXMatrixScaling(&matProj, 1.0f, -1.0f, 1.0f);
	// 	D3DXMatrixTranslation(&tmp, -0.5f, +0.5f, 0.0f);
	// 	D3DXMatrixMultiply(&matProj, &matProj, &tmp);
	// 	D3DXMatrixOrthoOffCenterLH(&tmp, (float)vp.TopLeftX, (float)(vp.TopLeftX + vp.Width), -((float)(vp.TopLeftY + vp.Height)), -((float)vp.TopLeftY), vp.MinDepth, vp.MaxDepth);
	// 	D3DXMatrixMultiply(&matProj, &matProj, &tmp);
	//pD3DDevice->SetTransform(D3DTS_PROJECTION, &matProj);
}
コード例 #11
0
ファイル: graphics.cpp プロジェクト: funcman/bsgl
void CALL BSGL_Impl::Gfx_EndScene() {
    _render_batch(true);
}