当前位置: 首页>>代码示例>>C++>>正文


C++ CSurface类代码示例

本文整理汇总了C++中CSurface的典型用法代码示例。如果您正苦于以下问题:C++ CSurface类的具体用法?C++ CSurface怎么用?C++ CSurface使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CSurface类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SetCaption

void CTestGame::Init()
{
    CGame::Init();

    SetCaption("Test Game");
    mouse->SetVisible(false);

    //create game space
    SDL_Rect bounds;
    bounds.x = 0;
    bounds.y = 0;
    bounds.w = GetScreenWidth();
    bounds.h = GetScreenHeight();
    space = new CEntitySpace(bounds);

    //create entity
    CSurface* surf = CSurface::Load("smile.png");
    surf->SetColorKey(255,0,106);
    entity = new CEntity(surf,10.0,false);
    entity->position.x = entity->GetWidth()/2;
    entity->position.y = entity->GetHeight()/2;

    space->Add(entity);

    //create segments
    seg = new CSegment(SDL_MapRGB(Display_Surface->GetSDLSurface()->format,
                                            0,0,0));
    seg->v1.x = 0;
    seg->v1.y = 500;
    seg->v2.x = 500;
    seg->v2.y = 500;

    space->Add(seg);
}
开发者ID:conwill708,项目名称:Code-Blocks-Projects,代码行数:34,代码来源:CTestGame.cpp

示例2: GetPointColor

BOOL GetPointColor(SPickQuery::SResult* R, u32& alpha)
{
    CSurface* surf			= R->e_mesh->GetSurfaceByFaceID(R->tag); VERIFY(surf);
    Shader_xrLC* c_sh		= EDevice.ShaderXRLC.Get(surf->_ShaderXRLCName());
    if (!c_sh->flags.bRendering) return FALSE;
    const Fvector2*			cuv[3];
    R->e_mesh->GetFaceTC	(R->tag,cuv);

    // barycentric coords
    // note: W,U,V order
    Fvector B;
    B.set	(1.0f - R->u - R->v,R->u,R->v);

    // calc UV
    Fvector2	uv;
    uv.x = cuv[0]->x*B.x + cuv[1]->x*B.y + cuv[2]->x*B.z;
    uv.y = cuv[0]->y*B.x + cuv[1]->y*B.y + cuv[2]->y*B.z;

    int U = iFloor(uv.x*float(surf->m_ImageData->w) + .5f);
    int V = iFloor(uv.y*float(surf->m_ImageData->h)+ .5f);
    U %= surf->m_ImageData->w;	if (U<0) U+=surf->m_ImageData->w;
    V %= surf->m_ImageData->h;	if (V<0) V+=surf->m_ImageData->h;

    alpha = color_get_A(surf->m_ImageData->layers.back()[V*surf->m_ImageData->w+U]);
    return TRUE;
}
开发者ID:AntonioModer,项目名称:xray-16,代码行数:26,代码来源:BuilderLODs.cpp

示例3: Export

void EDetail::Export(IWriter& F, LPCSTR tex_name, const Fvector2& offs, const Fvector2& scale, bool rot)
{
	R_ASSERT			(m_pRefs);
    CSurface* surf		= *m_pRefs->FirstSurface();
	R_ASSERT			(surf);
    // write data
	F.w_stringZ			(surf->_ShaderName());
	F.w_stringZ			(tex_name);//surf->_Texture());

    F.w_u32				(m_Flags.get());
    F.w_float			(m_fMinScale);
    F.w_float			(m_fMaxScale);

    F.w_u32				(number_vertices);
    F.w_u32				(number_indices);

    // remap UV
    EVertexIn* rm_vertices = xr_alloc<EVertexIn>(number_vertices);
    for (u32 k=0; k<number_vertices; k++) rm_vertices[k].remapUV(vertices[k],offs,scale,rot);
    
    F.w					(rm_vertices, 	number_vertices*sizeof(fvfVertexIn));
    F.w					(indices, 		number_indices*sizeof(WORD));

    xr_free				(rm_vertices);
}
开发者ID:OLR-xray,项目名称:OLR-3.0,代码行数:25,代码来源:EDetailModel.cpp

示例4: build_mesh

//----------------------------------------------------
IC bool build_mesh(const Fmatrix& parent, CEditableMesh* mesh, CGeomPartExtractor* extractor, u32 game_mtl_mask, BOOL ignore_shader)
{
	bool bResult 			= true;
    mesh->GenerateVNormals	(&parent);
    // fill faces
    for (SurfFaces::const_iterator sp_it=mesh->GetSurfFaces().begin(); sp_it!=mesh->GetSurfFaces().end(); sp_it++){
		const IntVec& face_lst 	= sp_it->second;
        CSurface* surf 		= sp_it->first;
		int gm_id			= surf->_GameMtl(); 
        if (gm_id==GAMEMTL_NONE_ID){ 
        	ELog.DlgMsg		(mtError,"Object '%s', surface '%s' contain invalid game material.",mesh->Parent()->m_LibName.c_str(),surf->_Name());
        	bResult 		= FALSE; 
            break; 
        }
        SGameMtl* M 		= GMLib.GetMaterialByID(gm_id);
        if (0==M){
        	ELog.DlgMsg		(mtError,"Object '%s', surface '%s' contain undefined game material.",mesh->Parent()->m_LibName.c_str(),surf->_Name());
        	bResult 		= FALSE; 
            break; 
        }
        if (!M->Flags.is(game_mtl_mask)) continue;

        // check engine shader compatibility
        if (!ignore_shader){
            IBlender* 		B = EDevice.Resources->_FindBlender(surf->_ShaderName()); 
            if (FALSE==B){
                ELog.Msg	(mtError,"Can't find engine shader '%s'. Object '%s', surface '%s'. Export interrupted.",surf->_ShaderName(),mesh->Parent()->m_LibName.c_str(),surf->_Name());
                bResult 	= FALSE; 
                break; 
            }
            if (TRUE==B->canBeLMAPped()){ 
                ELog.Msg	(mtError,"Object '%s', surface '%s' contain static engine shader - '%s'. Export interrupted.",mesh->Parent()->m_LibName.c_str(),surf->_Name(),surf->_ShaderName());
                bResult 	= FALSE; 
                break; 
            }
        }
                                                  
        const st_Face* faces	= mesh->GetFaces();        	VERIFY(faces);
        const Fvector*	vn	 	= mesh->GetVNormals();		VERIFY(vn);
        const Fvector*	pts 	= mesh->GetVertices();		VERIFY(pts);
	    for (IntVec::const_iterator f_it=face_lst.begin(); f_it!=face_lst.end(); f_it++){
			const st_Face& face = faces[*f_it];
            Fvector 		v[3],n[3];
            parent.transform_tiny	(v[0],pts[face.pv[0].pindex]);
            parent.transform_tiny	(v[1],pts[face.pv[1].pindex]);
            parent.transform_tiny	(v[2],pts[face.pv[2].pindex]);
            parent.transform_dir	(n[0],vn[*f_it*3+0]); n[0].normalize();
            parent.transform_dir	(n[1],vn[*f_it*3+1]); n[1].normalize();
            parent.transform_dir	(n[2],vn[*f_it*3+2]); n[2].normalize();
            const Fvector2*	uv[3];
            mesh->GetFaceTC			(*f_it,uv);
            extractor->AppendFace	(surf,v,n,uv);
        }
        if (!bResult) break;
    }
    mesh->UnloadVNormals	();
    return bResult;
}
开发者ID:AntonioModer,项目名称:xray-16,代码行数:59,代码来源:ESceneObjectToolsExportBreakable.cpp

示例5: OnDeviceCreate

void EDetail::OnDeviceCreate()
{
	if (!m_pRefs)		return;
    CSurface* surf		= *m_pRefs->FirstSurface();
    VERIFY				(surf);
    AnsiString	s_name	= surf->_ShaderName();
    AnsiString	t_name	= surf->_Texture();
	shader.create		(s_name.c_str(),t_name.c_str());
}
开发者ID:OLR-xray,项目名称:OLR-3.0,代码行数:9,代码来源:EDetailModel.cpp

示例6: new

// static creation methods
// creates object, calls second-phase, leaves on stack
CSurface* CSurface::NewLC(RWsSession& arWs, TInt aW, TInt aH, TInt aBpp)
{
   // allocate object on heap
   CSurface* newobj = new (ELeave) CSurface();
   // put on cleanup stack
   CleanupStack::PushL(newobj);
   // call second-phase constructor
   newobj->ConstructL(arWs, aW, aH, aBpp);
   return(newobj);
}
开发者ID:FlavioFalcao,项目名称:Wayfinder-CppCore-v2,代码行数:12,代码来源:Surface.cpp

示例7: R_ASSERT

bool SceneBuilder::BuildSOMModel()
{
	BOOL bResult 	= TRUE;
	CMemoryWriter 	F;

    F.open_chunk	(0);
    F.w_u32			(0);
    F.close_chunk	();

    F.open_chunk	(1);
    ObjectList& lst = Scene->ListObj(OBJCLASS_SCENEOBJECT);
    for (ObjectIt it=lst.begin(); it!=lst.end(); it++){
    	CSceneObject* S 	= (CSceneObject*)(*it);
    	CEditableObject* E	= S->GetReference(); R_ASSERT(E);
    	if (E->m_Flags.is(CEditableObject::eoSoundOccluder)){ 
            Fvector 		v;
            const Fmatrix&	parent = S->_Transform();
            for (EditMeshIt m_it=E->FirstMesh(); m_it!=E->LastMesh(); m_it++){
                for (SurfFacesPairIt sf_it=(*m_it)->m_SurfFaces.begin(); sf_it!=(*m_it)->m_SurfFaces.end(); sf_it++){
                	CSurface* surf 		= sf_it->first;
                    int gm_id			= surf->_GameMtl(); 
                    if (gm_id==GAMEMTL_NONE_ID){ 
                        ELog.DlgMsg		(mtError,"Object '%s', surface '%s' contain invalid game material.",(*m_it)->Parent()->m_LibName.c_str(),surf->_Name());
                        bResult 		= FALSE; 
                        break; 
                    }
                    SGameMtl* mtl 		= GMLib.GetMaterialByID(gm_id);
                    if (0==mtl){
                        ELog.DlgMsg		(mtError,"Object '%s', surface '%s' contain undefined game material.",(*m_it)->Parent()->m_LibName.c_str(),surf->_Name());
                        bResult 		= FALSE; 
                        break; 
                    }
                    BOOL b2Sided 		= surf->m_Flags.is(CSurface::sf2Sided);
                    IntVec& i_lst		= sf_it->second;
                    for (IntIt i_it=i_lst.begin(); i_it!=i_lst.end(); i_it++){
                        st_Face& face 	= (*m_it)->m_Faces[*i_it];
                        for (int k=0; k<3; k++){
                            parent.transform_tiny(v,(*m_it)->m_Verts[face.pv[k].pindex]);
                            F.w_fvector3(v);
                        }
                        F.w_u32			(b2Sided);
                        F.w_float		(mtl->fSndOcclusionFactor);
                    }
                }
            }
        }
    }
    BOOL bValid = !!F.chunk_size()&&bResult;
    F.close_chunk();
    if (bValid){
	    xr_string som_name 	= MakeLevelPath("level.som");
	    bValid				= F.save_to(som_name.c_str());
    }
	return bValid;
}
开发者ID:OLR-xray,项目名称:OLR-3.0,代码行数:55,代码来源:BuilderOGF.cpp

示例8: FindSurfaceByName

CSurface* CEditableObject::CreateSurface(LPCSTR m_name, SXRShaderData& d)
{
	CSurface* S			= FindSurfaceByName(m_name);
	if (!S){
		S				= new CSurface();
		S->SetName		(m_name);
		if (!ParseMAMaterial(S,d)){ xr_delete(S); return 0; }
		m_Surfaces.push_back(S);
	}
	return S;
}
开发者ID:2asoft,项目名称:xray,代码行数:11,代码来源:MayaExport.cpp

示例9: VERIFY

bool EDetailManager::GetSummaryInfo(SSceneSummary* inf)
{
	for (DetailIt it=objects.begin(); it!=objects.end(); it++){
    	((EDetail*)(*it))->OnDeviceCreate();
        CEditableObject* E 	= ((EDetail*)(*it))->m_pRefs;
		if (!E)				continue;
	    CSurface* surf		= *E->FirstSurface(); VERIFY(surf);
		inf->AppendTexture	(surf->_Texture(),SSceneSummary::sttDO,0,0,"$DETAILS$");
    }
    return true;
}
开发者ID:2asoft,项目名称:xray,代码行数:11,代码来源:ESceneDOTools.cpp

示例10: Draw

void CStatBox::Draw(CSurface* display,int x,int y)
{
    CSurface* line;
    int drawy = y;
    for(int i = 0; i<lines->size(); i++)
    {
        line = lines->at(i);
        if(line != NULL)
        {
            line->Draw(display,x,drawy);
            drawy += line->GetHeight() + STATBOX_LINE_PADDING;
        }
    }
}
开发者ID:conwill708,项目名称:Code-Blocks-Projects,代码行数:14,代码来源:CStatBox.cpp

示例11: LoadGpuProcessorL

void CEglTest_TestStep_StressLoad::LoadGpuProcessorL()
    {
    CSurface  *surface = CSurface::SurfaceFactoryL(ESurfTypeEglWindow);
    CleanupStack::PushL(surface);
    surface->CreateL(EStandard128sqSurface, TPoint(128, 128));
    TRgb bg = TRgb(0x55, 0x88, 0xff);   // Cyan/turqoise-ish.  
    TRgb fg = TRgb(0xff, 0x11, 0x22);   // Red (sort of)
    while(!__e32_atomic_load_acq32(&iStopThreadFlag[EThreadLoadGpuProcessor])) 
        {
            surface->DrawContentL(bg);
            surface->DrawComplexL(fg);
            surface->SubmitContent(ETrue);
        }
    CleanupStack::PopAndDestroy(surface);
    eglReleaseThread();
    }
开发者ID:cdaffara,项目名称:symbiandump-os1,代码行数:16,代码来源:egltest_endpoint_stressload.cpp

示例12: ShowBitmap

//-----------------------------------------------------------------------------
// Name: 
// Desc: 
//-----------------------------------------------------------------------------
HRESULT CDisplay::ShowBitmap( HBITMAP hbm, LPDIRECTDRAWPALETTE pPalette )
{
    if( NULL == m_pddsFrontBuffer ||  NULL == m_pddsBackBuffer )
        return E_POINTER;

    // Set the palette before loading the bitmap
    if( pPalette )
        m_pddsFrontBuffer->SetPalette( pPalette );

    CSurface backBuffer;
    backBuffer.Create( m_pddsBackBuffer );

    if( FAILED( backBuffer.DrawBitmap( hbm, 0, 0, 0, 0 ) ) )
        return E_FAIL;

    return Present();
}
开发者ID:galek,项目名称:xform-megatexture,代码行数:21,代码来源:ddutil.cpp

示例13: CalcHeight

int CStatBox::CalcHeight()
{
    //find sum of line heights, plus padding
    int height = 0;
    CSurface* line;
    for(int i = 0; i<lines->size(); i++)
    {
        line = lines->at(i);

        if(line != NULL)
        {
            height += line->GetHeight();
        }
    }
    height += (lines->size() - 1) * STATBOX_LINE_PADDING;
    return height;
}
开发者ID:conwill708,项目名称:Code-Blocks-Projects,代码行数:17,代码来源:CStatBox.cpp

示例14: ENGINE_ASSERT

void CEglTest_TestStep_StressLoad::LoadGpuMemoryL()
    {
    const TInt KMaxSurfaceAllocs = 1000;
    CSurface **surfaces = new CSurface*[KMaxSurfaceAllocs];
    ENGINE_ASSERT(surfaces);
    TInt nSurfaces = 0;
    TInt err;
    while(!__e32_atomic_load_acq32(&iStopThreadFlag[EThreadLoadGpuMemory]))     
        {
        ENGINE_ASSERT(nSurfaces < KMaxSurfaceAllocs);
        CSurface* s = CSurface::SurfaceFactoryL(ESurfTypePBuffer);
        if (s)
            {
            TRAP(err, s->CreateL(ELargeSurface));
            if (err == KErrNone)
                {
                surfaces[nSurfaces++] = s;
                TRAP(err, s->DrawContentL(TRgb(0x10, 0x20, 0xB0)));
                }
            else
                {
                delete s;
                s = NULL;
                }
            }
        if (!s)
            {
            User::After(100 * 1000);
            TInt nRelease = nSurfaces / 4;
            for(TInt i = 0; i < nRelease; i++)
                {
                delete surfaces[--nSurfaces];
                surfaces[nSurfaces] = NULL;
                }
            User::After(100 * 1000); // 100 ms. 
            }
        }
    while(nSurfaces)
        {
        delete surfaces[--nSurfaces];
        }
    delete [] surfaces;
    eglReleaseThread();
    }
开发者ID:cdaffara,项目名称:symbiandump-os1,代码行数:44,代码来源:egltest_endpoint_stressload.cpp

示例15: Render

void Font::Render(const string &str, int x, int y, dword height, dword style, D3DXCOLOR color, int maxWidth, bool fade, Align alignment)
{
    CSurface texture;
    RenderToTexture(texture, str, height, style, color, maxWidth, fade);

    if (alignment != Left)
    {
        word *wcBuf = StringToWChar(str);
        dword dwRequiredWidth;
        m_pFont->GetTextExtent(wcBuf, -1, &dwRequiredWidth);
        delete [] wcBuf;

        if (alignment == Center)
            x -= (dwRequiredWidth / 2);
        else if (alignment == Right)
            x -= dwRequiredWidth;
    }

    texture.Render(x, y);
}
开发者ID:ToadKing,项目名称:RetroArch-Rpi,代码行数:20,代码来源:Font.cpp


注:本文中的CSurface类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。