• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ csRef类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: FillWithColliderGeometry

    void csBulletCollider::FillWithColliderGeometry (
        csRef<iGeneralFactoryState> genmesh_fact)
    {
        // @@@ TODO
#if 0
        switch (geomType)
        {
        case BOX_COLLIDER_GEOMETRY:
        {
            SimdTransform trans;
            SimdVector3 max;
            SimdVector3 min;
            BoxShape*  b = (BoxShape*)pc->GetRigidBody ()->GetCollisionShape ();

            csBox3 box;
            for (int i = 0; i < b->GetNumVertices (); i++)
            {
                SimdVector3 vtx;
                b->GetVertex (i, vtx);
                box.AddBoundingVertexTest (csVector3 (vtx[0], vtx[1], vtx[2]));
            }
            genmesh_fact->GenerateBox (box);
            genmesh_fact->CalculateNormals ();
        }
        break;
        default:
            break;
        }
#endif
    }
开发者ID:yushiming,项目名称:CS,代码行数:30,代码来源:colliders.cpp


示例2: csTinyDocumentSystem

csPtr<iString> AssetManager::LoadDocument (iObjectRegistry* object_reg,
    csRef<iDocument>& doc,
    const char* vfspath, const char* file)
{
  doc.Invalidate ();
  csRef<iVFS> vfs = csQueryRegistry<iVFS> (object_reg);
  if (vfspath) vfs->PushDir (vfspath);

  csRef<iDataBuffer> buf = vfs->ReadFile (file);
  if (vfspath) vfs->PopDir ();
  if (!buf)
    return 0;	// No error, just a non-existing file.

  csRef<iDocumentSystem> docsys;
  docsys = csQueryRegistry<iDocumentSystem> (object_reg);
  if (!docsys)
    docsys.AttachNew (new csTinyDocumentSystem ());

  doc = docsys->CreateDocument ();
  const char* error = doc->Parse (buf->GetData ());
  if (error)
  {
    scfString* msg = new scfString ();;
    msg->Format ("Can't parse '%s': %s", file, error);
    doc.Invalidate ();
    return msg;
  }

  return 0;
}
开发者ID:Dracophoenix1,项目名称:ares,代码行数:30,代码来源:assetmanager.cpp


示例3: scfImplementationType

pawsFrameDrawable::pawsFrameDrawable(csRef<iDocumentNode> node)
    : scfImplementationType (this)
{
    defaultTransparentColourBlue  = -1;
    defaultTransparentColourGreen = -1;
    defaultTransparentColourRed   = -1;

    defaultAlphaValue = 0;

    // Read off the image and file vars
    imageFileLocation = node->GetAttributeValue("file");
    resourceName = node->GetAttributeValue("resource");

    csString typeStr(node->GetAttributeValue("type"));
    type = FDT_FULL;
    if (typeStr == "horizontal")
        type = FDT_HORIZONTAL;
    else if (typeStr == "vertical")
        type = FDT_VERTICAL;

    csRef<iDocumentNodeIterator> iter = node->GetNodes();
    while ( iter->HasNext() )
    {
        csRef<iDocumentNode> childNode = iter->Next();

        // Read the default alpha value.
        if (strcmp(childNode->GetValue(), "alpha") == 0)
            defaultAlphaValue = childNode->GetAttributeValueAsInt("level");

        // Read the default transparent colour.
        else if (strcmp(childNode->GetValue(), "trans") == 0)
        {
            defaultTransparentColourRed   = childNode->GetAttributeValueAsInt("r");
            defaultTransparentColourGreen = childNode->GetAttributeValueAsInt("g");
            defaultTransparentColourBlue  = childNode->GetAttributeValueAsInt("b");
        }

        else if (strcmp(childNode->GetValue(), "top_left") == 0)
            LoadPiece(childNode, FDP_TOP_LEFT);
        else if (strcmp(childNode->GetValue(), "top") == 0)
            LoadPiece(childNode, FDP_TOP);
        else if (strcmp(childNode->GetValue(), "top_right") == 0)
            LoadPiece(childNode, FDP_TOP_RIGHT);
        else if (strcmp(childNode->GetValue(), "left") == 0)
            LoadPiece(childNode, FDP_LEFT);
        else if (strcmp(childNode->GetValue(), "middle") == 0)
            LoadPiece(childNode, FDP_MIDDLE);
        else if (strcmp(childNode->GetValue(), "right") == 0)
            LoadPiece(childNode, FDP_RIGHT);
        else if (strcmp(childNode->GetValue(), "bottom_left") == 0)
            LoadPiece(childNode, FDP_BOTTOM_LEFT);
        else if (strcmp(childNode->GetValue(), "bottom") == 0)
            LoadPiece(childNode, FDP_BOTTOM);
        else if (strcmp(childNode->GetValue(), "bottom_right") == 0)
            LoadPiece(childNode, FDP_BOTTOM_RIGHT);
    }

}
开发者ID:garinh,项目名称:planeshift,代码行数:58,代码来源:pawsframedrawable.cpp


示例4: AddBatch

void csTextureList::AddBatch (csRef<iTextureLoaderIterator> itr, bool precache)
{
  CS::Threading::ScopedWriteLock lock(texLock);
  while(itr->HasNext())
  {
    iTextureWrapper* tex = itr->Next();
    Push(tex);
    if(precache && tex->GetTextureHandle())
    {
      tex->GetTextureHandle()->Precache();
    }
  }
}
开发者ID:garinh,项目名称:cs,代码行数:13,代码来源:texture.cpp


示例5: CopyXMLNode

void CopyXMLNode(csRef<iDocumentNode> source, csRef<iDocumentNode> target, int mode)
{
    if (mode == 0)
    {
        target->RemoveNodes();
        target->RemoveAttributes();
    }
    
    // copy nodes
    csRef<iDocumentNodeIterator> nodeIter = source->GetNodes();
    while (nodeIter->HasNext())
    {
        csRef<iDocumentNode> child = nodeIter->Next();
        csRef<iDocumentNode> targetChild = target->GetNode(child->GetValue());
        if (targetChild==NULL || mode==3)  // Mode 3 means don't merge tags but just insert multiples, so we create a new one here every time
        {
            targetChild = target->CreateNodeBefore(child->GetType());
            if (targetChild == NULL)
                assert(!"failed to create XML node, you are probably using wrong XML parser (xmlread instead of xmltiny)");
            targetChild->SetValue(child->GetValue());
        }
        CopyXMLNode(child, targetChild, mode);
    }
    
    // copy attributes
    csRef <iDocumentAttributeIterator> attrIter = source->GetAttributes();
    while (attrIter->HasNext())
    {
        csRef<iDocumentAttribute> attr = attrIter->Next();
        const char* attrName = attr->GetName();
        if (mode==1  ||  !target->GetAttribute(attrName))
            target->SetAttribute(attrName, attr->GetValue());
    }
}
开发者ID:Chettie,项目名称:Eulora-client,代码行数:34,代码来源:psxmlparser.cpp


示例6: AddBatch

void csMeshList::AddBatch (csRef<iMeshLoaderIterator> itr)
{
  CS::Threading::ScopedWriteLock lock(meshLock);
  while(itr->HasNext())
  {
    iMeshWrapper* obj = itr->Next();
    PrepareMesh (obj);
    const char* name = obj->QueryObject ()->GetName ();
    if (name)
      meshes_hash.Put (name, obj);
    obj->QueryObject ()->AddNameChangeListener (listener);
    list.Push (obj);
  }
}
开发者ID:garinh,项目名称:cs,代码行数:14,代码来源:meshobj.cpp


示例7: CS_ASSERT

void psCharAppearance::ProcessAttach(csRef<iMeshWrapper> meshWrap, csRef<iSpriteCal3DSocket> socket)
{
    if(!socket.IsValid())
        return;
    CS_ASSERT(socket.IsValid());
    
    meshWrap->GetFlags().Set(CS_ENTITY_NODECAL);
    const char* socketName = socket->GetName();

    // Given a socket name of "righthand", we're looking for a key in the form of "socket_righthand"
    csString keyName = "socket_";
    keyName += socketName;

    // Variables for transform to be specified
    float trans_x = 0, trans_y = 0.0, trans_z = 0, rot_x = -PI/2, rot_y = 0, rot_z = 0;
    csRef<iObjectIterator> it = meshWrap->GetFactory()->QueryObject()->GetIterator();

    while ( it->HasNext() )
    {
        csRef<iKeyValuePair> key ( scfQueryInterface<iKeyValuePair> (it->Next()));
        if (key && keyName == key->GetKey())
        {
            sscanf(key->GetValue(),"%f,%f,%f,%f,%f,%f",&trans_x,&trans_y,&trans_z,&rot_x,&rot_y,&rot_z);
        }
    }

    meshWrap->QuerySceneNode()->SetParent( baseMesh->QuerySceneNode ());
    socket->SetMeshWrapper( meshWrap );
    socket->SetTransform( csTransform(csZRotMatrix3(rot_z)*csYRotMatrix3(rot_y)*csXRotMatrix3(rot_x), csVector3(trans_x,trans_y,trans_z)) );

    usedSlots.PushSmart(socketName);
}
开发者ID:garinh,项目名称:planeshift,代码行数:32,代码来源:charapp.cpp


示例8: scfImplementationType

pawsImageDrawable::pawsImageDrawable(csRef<iDocumentNode> node)
                 : scfImplementationType (this)
{
    debugImageErrors = true;
    defaultTransparentColourBlue  = -1;
    defaultTransparentColourGreen = -1;
    defaultTransparentColourRed   = -1;

    defaultAlphaValue = 0;

    // Read off the image and file vars
    imageFileLocation = node->GetAttributeValue( "file" );
    resourceName = node->GetAttributeValue( "resource" );

    tiled = node->GetAttributeValueAsBool("tiled");

    csRef<iDocumentNodeIterator> iter = node->GetNodes();
    while ( iter->HasNext() )
    {
        csRef<iDocumentNode> childNode = iter->Next();       

        // Read the texture rectangle for this image.
        if ( strcmp( childNode->GetValue(), "texturerect" ) == 0 )
        {
            textureRectangle.xmin = childNode->GetAttributeValueAsInt("x");
            textureRectangle.ymin = childNode->GetAttributeValueAsInt("y");

            int width = childNode->GetAttributeValueAsInt("width");
            int height = childNode->GetAttributeValueAsInt("height");

            textureRectangle.SetSize(width, height);
        }

        // Read the default alpha value.
        if ( strcmp( childNode->GetValue(), "alpha" ) == 0 )
        {
            defaultAlphaValue = childNode->GetAttributeValueAsInt("level");            
        }

        // Read the default transparent colour.
        if ( strcmp( childNode->GetValue(), "trans" ) == 0 )
        {
            defaultTransparentColourRed   = childNode->GetAttributeValueAsInt("r");            
            defaultTransparentColourGreen = childNode->GetAttributeValueAsInt("g");            
            defaultTransparentColourBlue  = childNode->GetAttributeValueAsInt("b");                                    
        }
    }

    PreparePixmap();
}
开发者ID:garinh,项目名称:planeshift,代码行数:50,代码来源:pawsimagedrawable.cpp


示例9: GetTiNodeChildren

void csTinyXmlNode::RemoveNodes (csRef<iDocumentNodeIterator> children)
{
  if ((node->Type() != TiDocumentNode::ELEMENT)
    && (node->Type() != TiDocumentNode::DOCUMENT)) return;
  TiDocumentNodeChildren* node_children = GetTiNodeChildren ();

  while (children->HasNext ())
  {
    csRef<iDocumentNode> n = children->Next ();
    csTinyXmlNode* tiNode = static_cast<csTinyXmlNode*>((iDocumentNode*)n);
    node_children->RemoveChild (tiNode->GetTiNode ());
  }
  lastChild = 0;
}
开发者ID:GameLemur,项目名称:Crystal-Space,代码行数:14,代码来源:xmltiny.cpp


示例10: PlaySound

bool PawsManager::PlaySound(csRef<iSndSysData> sounddata)
{
    if(!useSounds)
        return true;

    // If there is no sound loader or renderer, sound loading and playing will not be performed
    if (!sounddata.IsValid() || !soundrenderer.IsValid() )
        return false;

    // Create a stream for this sound
    csRef<iSndSysStream> sndstream=soundrenderer->CreateStream(sounddata,CS_SND3D_DISABLE);
    if (!sndstream.IsValid())
      return false;

    // This stream should unregister (and all sources) automatically when it's done playing
    sndstream->SetAutoUnregister(true);

    // Create a source just for this sound.
    csRef<iSndSysSource> source=soundrenderer->CreateSource(sndstream);
    if (!source.IsValid())
    {
      soundrenderer->RemoveStream(sndstream);
      return false;
    }

      source->SetVolume(volume);
    sndstream->Unpause();

    // Although we lose the reference, the CS sound renderer holds a reference to the source until playback is complete
    return true;
}
开发者ID:garinh,项目名称:planeshift,代码行数:31,代码来源:pawsmanager.cpp


示例11: csScanPluginDirs

csRef<iStringArray> csScanPluginDirs (csPathsList* dirs, 
				    csRef<iStringArray>& plugins)
{
  iStringArray* messages = 0;

  if (!plugins)
    plugins.AttachNew (new scfStringArray ());

  for (size_t i = 0; i < dirs->Length (); i++)
  {
    iStringArray* dirMessages = 0;
    InternalScanPluginDir (dirMessages, (*dirs)[i].path, plugins, 
      (*dirs)[i].scanRecursive);
    
    if (dirMessages != 0)
    {
      csString tmp;
      tmp.Format ("The following error(s) occured while scanning '%s':",
	(*dirs)[i].path.GetDataSafe ());

      AppendStrVecString (messages, tmp);

      for (size_t i = 0; i < dirMessages->GetSize(); i++)
      {
	tmp.Format (" %s", dirMessages->Get (i));
	AppendStrVecString (messages, tmp);
      }
      dirMessages->DecRef();
    }
  }
	 
  return csPtr<iStringArray> (messages);
}
开发者ID:garinh,项目名称:cs,代码行数:33,代码来源:scanplugins.cpp


示例12: UpdateInstancingParams

static void UpdateInstancingParams (bool allDataDirty,
                                    const DataArray& array,
                                    csRef<iRenderBuffer>& buffer,
                                    csShaderVariable* sv)
{
  bool updateData = allDataDirty;
  if (!buffer
    || (buffer->GetElementCount() != array.Capacity()))
  {
    buffer = csRenderBuffer::CreateRenderBuffer (array.Capacity(),
                                                 CS_BUF_STREAM, CS_BUFCOMP_FLOAT,
                                                 sizeof (typename DataArray::ValueType) / sizeof(float));
    sv->SetValue (buffer);
    updateData = true;
  }
  if (updateData) buffer->SetData (array.GetArray());
}
开发者ID:Tank-D,项目名称:Shards,代码行数:17,代码来源:meshgen.cpp


示例13: SendStatDRMessage

bool psServerVitals::SendStatDRMessage(uint32_t clientnum, EID eid, int flags, csRef<PlayerGroup> group)
{
    bool backup=0;
    if (flags)
    {
        backup = statsDirty ? true : false;
        statsDirty = flags;
    }
    else if (version % 10 == 0)  // every 10th msg to this person, send everything
        statsDirty = DIRTY_VITAL_ALL;

    if (!statsDirty)
        return false;

    csArray<float> fVitals;
    csArray<uint32_t> uiVitals;

    if (statsDirty & DIRTY_VITAL_HP)
        fVitals.Push(PERCENT_VALUE(VITAL_HITPOINTS));

    if (statsDirty & DIRTY_VITAL_HP_RATE)
        fVitals.Push(PERCENT_RATE(VITAL_HITPOINTS));

    if (statsDirty & DIRTY_VITAL_MANA)
        fVitals.Push(PERCENT_VALUE(VITAL_MANA));

    if (statsDirty & DIRTY_VITAL_MANA_RATE)
        fVitals.Push(PERCENT_RATE(VITAL_MANA));

    // Physical Stamina
    if (statsDirty & DIRTY_VITAL_PYSSTAMINA)
        fVitals.Push(PERCENT_VALUE(VITAL_PYSSTAMINA));

    if (statsDirty & DIRTY_VITAL_PYSSTAMINA_RATE)
        fVitals.Push(PERCENT_RATE(VITAL_PYSSTAMINA));

    // Mental Stamina
    if (statsDirty & DIRTY_VITAL_MENSTAMINA)
        fVitals.Push(PERCENT_VALUE(VITAL_MENSTAMINA));

    if (statsDirty & DIRTY_VITAL_MENSTAMINA_RATE)
        fVitals.Push(PERCENT_RATE(VITAL_MENSTAMINA));

    if (statsDirty & DIRTY_VITAL_EXPERIENCE)
        uiVitals.Push(GetExp());

    if (statsDirty & DIRTY_VITAL_PROGRESSION)
        uiVitals.Push(GetPP());

    psStatDRMessage msg(clientnum, eid, fVitals, uiVitals, ++version, statsDirty);
    if (group == NULL)
        msg.SendMessage();
    else
        group->Broadcast(msg.msg);

    statsDirty = backup;
    return true;
}
开发者ID:garinh,项目名称:planeshift,代码行数:58,代码来源:servervitals.cpp


示例14: GetNodeXML

csString GetNodeXML(csRef<iDocumentNode> node, bool childrenOnly)
{
    psString xml;
    csRef<iDocumentNodeIterator> nodes;
    csRef<iDocumentAttributeIterator> attrs;
    
    if (!childrenOnly)
        xml.Format("<%s", node->GetValue());
    
    attrs = node->GetAttributes();
    while (attrs->HasNext())
    {
        csRef<iDocumentAttribute> attr = attrs->Next();
    csString escpxml = EscpXML(attr->GetValue());
        xml.AppendFmt(" %s=\"%s\"", attr->GetName(), escpxml.GetData() );
    }
    if (!childrenOnly)
        xml += ">";
    

    nodes = node->GetNodes();
    if (nodes->HasNext())
    {
        while (nodes->HasNext())
        {
            csRef<iDocumentNode> child = nodes->Next();
            if (child->GetType() == CS_NODE_TEXT)
            {
                // add the node-content to the string..but escape special XML chars in it
                xml += EscpXML(child->GetContentsValue());
            }
            else
            {
                xml += GetNodeXML(child);
            }
        }
    }
    if (!childrenOnly)
    {
        // add the node-content to the string..but escape special XML chars in it
        xml += EscpXML(node->GetContentsValue());
        xml.AppendFmt("</%s>", node->GetValue());
    }
    return xml;
}
开发者ID:Chettie,项目名称:Eulora-client,代码行数:45,代码来源:psxmlparser.cpp


示例15:

csRef < iDocumentNode > MD32spr::CreateValueNode(csRef < iDocumentNode >
						 &parent, const char *name,
						 const char *value)
{
  csRef < iDocumentNode > child =
    parent->CreateNodeBefore(CS_NODE_ELEMENT, 0);
  child->SetValue(name);
  csRef < iDocumentNode > text =
    child->CreateNodeBefore(CS_NODE_TEXT, 0);
  text->SetValue(value);
  return child;
}
开发者ID:crystalspace,项目名称:CS,代码行数:12,代码来源:md32spr.cpp


示例16: SetFont

void G2DTestSystemDriver::BlitTest ()
{
  int w = myG2D->GetWidth ();
  int h = myG2D->GetHeight ();
  myG2D->SetClipRect(0,0,w,h);
  myG2D->DrawBox(0,0,w,h, dsteel);
  
  SetFont (fontItalic);
  WriteCentered (0,-16*8, white, -1, "BLIT() TEST");

  SetFont (fontLarge);
  WriteCentered (0,-16*7, black, dsteel, "This will test whether iGraphics2D->Blit() works correctly");
  WriteCentered (0,-16*6, black, dsteel, "on this canvas.");

  WriteCentered (0,-16*4, black, dsteel, "You should see an image of an arrow and the word %s.",
		 CS::Quote::Double ("up"));
  WriteCentered (0,-16*3, black, dsteel, "It is surrounded by a green rectangle, and the image");
  WriteCentered (0,-16*2, black, dsteel, "itself has a black border. No red should be visible");
  WriteCentered (0,-16*1, black, dsteel, "and the border has to be complete, too.");

  if (blitTestImage.IsValid ())
  {
    const int imW = blitTestImage->GetWidth ();
    const int imH = blitTestImage->GetHeight ();
    const int bx = (w - imW) / 2;
    const int by = h / 2;
    DrawClipRect (bx, by, imW + 1, imH + 1);
    myG2D->Blit (bx + 1, by + 1, imW, imH, 
      (unsigned char*)blitTestImage->GetImageData ());
  }
}
开发者ID:crystalspace,项目名称:CS,代码行数:31,代码来源:g2dtest.cpp


示例17: DrawWindowScreen

void G2DTestSystemDriver::DrawWindowResizeScreen ()
{
  DrawWindowScreen ();

  myG2D->AllowResize (true);
  myG2D->DrawBox (0, myG2D->GetHeight () / 2 + 16, myG2D->GetWidth (), 16 * 4, blue);
  SetFont (fontLarge);

  WriteCentered (0, 16*1, white, -1, "Now resizing should be enabled. Try to resize the");
  WriteCentered (0, 16*2, white, -1, "window: you should be either unable to do it (if");
  WriteCentered (0, 16*3, white, -1, "canvas driver does not support resize) or see");
  WriteCentered (0, 16*4, white, -1, "the current window size in top-right corner.");

  SetFont (fontCourier);
  WriteCentered (2, 0, green, -1, "press any key to continue");
}
开发者ID:crystalspace,项目名称:CS,代码行数:16,代码来源:g2dtest.cpp


示例18:

void G2DTestSystemDriver::SetCustomCursor ()
{
  if (cursorPlugin)
  {
    cursorPlugin->SwitchCursor ("Hand");
  }
}
开发者ID:crystalspace,项目名称:CS,代码行数:7,代码来源:g2dtest.cpp


示例19: LayerSampler

 LayerSampler (int basemap_w, int basemap_h, MaterialLayer* layer)
  : textureScale (layer->texture_scale)
 {
   float layer_needed_x = float (basemap_w) / textureScale.x;
   float layer_needed_y = float (basemap_h) / textureScale.y;
   iImage* layerImage = layer->GetImage();
   int mip_x = csFindNearestPowerOf2 (
     int (ceil (layerImage->GetWidth() / layer_needed_x)));
   int mip_y = csFindNearestPowerOf2 (
     int (ceil (layerImage->GetHeight() / layer_needed_y)));
   int mip = csMax (
     csClamp (csLog2 (mip_x), csLog2 (layerImage->GetWidth()), 0),
     csClamp (csLog2 (mip_y), csLog2 (layerImage->GetHeight()), 0));
   img = GetImageMip (layerImage, mip);
   img_w = img->GetWidth();
   img_h = img->GetHeight();
 }
开发者ID:garinh,项目名称:cs,代码行数:17,代码来源:basemapgen.cpp


示例20: rng

void G2DTestSystemDriver::DrawTextTest ()
{
  // Draw a grid of lines so that transparent text background will be visible
  int w = myG2D->GetWidth ();
  int h = myG2D->GetHeight ();
  int i;
  for (i = 0; i < w; i += 4)
  {
    myG2D->DrawLine (float(i), 0.0f, float(i) + 50.0f, float(h), dsteel);
    myG2D->DrawLine (float(w - i), 0.0f, float(w - i) - 50.0f, float(h), dsteel);
  }

  SetFont (fontItalic);
  WriteCentered (0,-16*7, white, -1, "TEXT DRAWING TEST");

  SetFont (fontLarge);
  WriteCentered (0,-16*5,   blue,    -1, "This is blue text with transparent background");
  WriteCentered (0,-16*4,  green,  blue, "This is green text on blue background");
  WriteCentered (0,-16*3, yellow,  gray, "Yellow text on gray background");
  WriteCentered (0,-16*2,    red, black, "Red text on black background");
  WriteCentered (0,-16*1,  black, white, "Black text on white background");

  SetFont (fontCourier);
  int sx = 0, sy = h / 2 + 48, sw = w, sh = h / 2 - 48;
  myG2D->DrawBox (sx, sy, sw, sh, dsteel);
  const char *text = "Crystal Space rulez";
  int tw, th;
  font->GetDimensions (text, tw, th);
  size_t cc = strlen (text);

  // Test text drawing performance for 1/4 seconds
  int colors [4] = { red, green, blue, yellow };
  sx += 20; sw -= 40 + tw;
  sy += 10; sh -= 20 + th;
  csRandomGen rng (csGetTicks ());
  csTicks start_time = csGetTicks (), delta_time;
  size_t char_count = 0;
  do
  {
    for (i = 0; i < 2000; i++)
    {
      float x = sx + rng.Get () * sw;
      float y = sy + rng.Get () * sh;
      myG2D->Write (font, int(x), int(y), colors [rng.Get (4)], black, text);
      char_count += cc;
    }
    myG2D->PerformExtension ("flush");
    delta_time = csGetTicks () - start_time;
  } while (delta_time < 500);
  float perf = char_count * (1000.0f / delta_time);
  SetFont (fontLarge);
  WriteCentered (0, 16*1, green, black, " Performance: %20.1f characters/second ", perf);
}
开发者ID:crystalspace,项目名称:CS,代码行数:53,代码来源:g2dtest.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ csString类代码示例发布时间:2022-05-31
下一篇:
C++ csArray类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap