Exemplo n.º 1
0
hgeVertex* HGE_CALL HGE_Impl::Gfx_StartBatch(int prim_type, HTEXTURE tex, int blend, int *max_prim)
{
	if (m_vertices)
	{

		//Must render the batch now
		_render_batch();

		//start a new batch
		m_cur_prim_type = prim_type;

		if (m_cur_blend_mode != blend)
		{
			_SetBlendMode(blend);
		}

		if (m_cur_texture != tex)
		{
			m_pD3DDeviceContext->PSSetShaderResources(0, 1, NULL);
			m_cur_texture = tex;
		}

		*max_prim = VERTEX_BUFFER_SIZE / prim_type;
		return m_vertices;
	}
	else
	{
		return 0;
	}

}
Exemplo n.º 2
0
void HGE_CALL HGE_Impl::Gfx_RenderTriple(const hgeTriple *triple)
{
	if (m_vertices)
	{
		//Currently batching tri'es?
		if (m_cur_prim_type != HGEPRIM_TRIPLES ||
			//Will the buffer have enough space?
			m_prim_count >= VERTEX_BUFFER_SIZE / HGEPRIM_TRIPLES ||
			//Is there any texture related rendering?
			(m_cur_texture != triple->tex) ||
			//Currently lines only render in default mode
			m_cur_blend_mode != triple->blend)
		{
			//Must render the batch now
			_render_batch();

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

		memcpy(&m_vertices[m_prim_count*HGEPRIM_TRIPLES], triple->v, sizeof(hgeVertex)*HGEPRIM_TRIPLES);
		m_prim_count++;
	}
}
Exemplo n.º 3
0
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++;
	}
}
Exemplo n.º 4
0
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;
        }
Exemplo n.º 5
0
void CALL HGE_Impl::Gfx_RenderQuad(const hgeQuad *quad)
{

    glEnable(GL_TEXTURE_2D); // Enable Texture Mapping
    glBindTexture(GL_TEXTURE_2D, quad->tex);

    _SetBlendMode(quad->blend);


    //TODO: insert code here
    GLfloat verteces[12] = {
        quad->v[3].x, quad->v[3].y, quad->v[3].z,
        quad->v[2].x, quad->v[2].y, quad->v[2].z,
        quad->v[1].x, quad->v[1].y, quad->v[1].z,
        quad->v[0].x, quad->v[0].y, quad->v[0].z,
    };

    GLfloat texCoords[8] = {
        quad->v[3].tx, quad->v[3].ty,
        quad->v[2].tx, quad->v[2].ty,
        quad->v[1].tx, quad->v[1].ty,
        quad->v[0].tx, quad->v[0].ty,
    };
    GLubyte colors[16] = {
        (GLubyte)GETR(quad->v[3].col), (GLubyte)GETG(quad->v[3].col), (GLubyte)GETB(quad->v[3].col), (GLubyte)GETA(quad->v[3].col),
        (GLubyte)GETR(quad->v[2].col), (GLubyte)GETG(quad->v[2].col), (GLubyte)GETB(quad->v[2].col), (GLubyte)GETA(quad->v[2].col),
        (GLubyte)GETR(quad->v[1].col), (GLubyte)GETG(quad->v[1].col), (GLubyte)GETB(quad->v[1].col), (GLubyte)GETA(quad->v[1].col),
        (GLubyte)GETR(quad->v[0].col), (GLubyte)GETG(quad->v[0].col), (GLubyte)GETB(quad->v[0].col), (GLubyte)GETA(quad->v[0].col),

    };


    glVertexPointer(3, GL_FLOAT, 0, verteces);
    glEnableClientState(GL_VERTEX_ARRAY);

    glTexCoordPointer(2, GL_FLOAT, 0, texCoords);
    glEnableClientState(GL_TEXTURE_COORD_ARRAY);


    glColorPointer(4, GL_UNSIGNED_BYTE, 0, colors);
    glEnableClientState(GL_COLOR_ARRAY);

    glDrawArrays(GL_QUADS, 0, 4);

    glDisable(GL_TEXTURE_2D); // Enable Texture Mapping
    glDisable(GL_BLEND); // Enable Texture Mapping
    glBindTexture(GL_TEXTURE_2D, 0);


}
Exemplo n.º 6
0
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++;
	}
}