本文整理汇总了C++中CIwMaterial::SetTexture方法的典型用法代码示例。如果您正苦于以下问题:C++ CIwMaterial::SetTexture方法的具体用法?C++ CIwMaterial::SetTexture怎么用?C++ CIwMaterial::SetTexture使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CIwMaterial
的用法示例。
在下文中一共展示了CIwMaterial::SetTexture方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: renderMap
void renderMap() {
IwGxLightingOff();
CIwMaterial* pMat = IW_GX_ALLOC_MATERIAL();
pMat->SetModulateMode(CIwMaterial::MODULATE_NONE);
pMat->SetTexture(mapTexture);
IwGxSetMaterial(pMat);
IwGxSetScreenSpaceSlot(-1);
float zoom = getMapZoom()->getZoom();
int16 hScrW = (double)IwGxGetScreenWidth()*0.5f;
int16 hScrH = (double)IwGxGetScreenHeight()*0.5f;
int16 x1 = hScrW - hScrW*zoom;
int16 x2 = hScrW + hScrW*zoom;
int16 y1 = hScrH - hScrH*zoom;
int16 y2 = hScrH + hScrH*zoom;
mapVertZoom[0].x = x1, mapVertZoom[0].y = y1;
mapVertZoom[1].x = x1, mapVertZoom[1].y = y2;
mapVertZoom[2].x = x2, mapVertZoom[2].y = y2;
mapVertZoom[3].x = x2, mapVertZoom[3].y = y1;
IwGxSetUVStream(mapDefaultUvs);
IwGxSetVertStreamScreenSpace(mapVertZoom, 4);
IwGxDrawPrims(IW_GX_QUAD_LIST, NULL, 4);
}
示例2: RenderElement
void MapBackground::RenderElement(CIwUIGraphics& parentGraphics)
{
// Render tiles for the background
std::list<MapTile*>::iterator iter = gVectorImageUrls.begin();
int i = 0;
while (iter != gVectorImageUrls.end())
{
MapTile* pTile = *iter;
if (pTile->pTexture)
{
//Calculate the top left of the map image
CIwSVec2 topLeft, bottomRight;
topLeft.x = pTile->location.x;
topLeft.y = pTile->location.y;
CIwUIRect rect(CIwVec2(topLeft.x, topLeft.y), CIwVec2(pTile->pTexture->GetWidth(), pTile->pTexture->GetHeight()));
CIwUIColour c(0xff,0xff,0xff,0xff);
CIwColour* wtf = IW_GX_ALLOC(CIwColour, 4);
CIwMaterial* pMat = IW_GX_ALLOC_MATERIAL();
pMat->SetModulateMode(CIwMaterial::MODULATE_NONE);
pMat->SetTexture(pTile->pTexture);
parentGraphics.DrawImage(pTile->pTexture, pMat, rect, CIwSVec2(0,0), CIwSVec2(4096, 4096), c, false);
}
iter++;
}
}
示例3: ImGui_Marmalade_RenderDrawLists
// This is the main rendering function that you have to implement and provide to ImGui (via setting up 'RenderDrawListsFn' in the ImGuiIO structure)
void ImGui_Marmalade_RenderDrawLists(ImDrawData* draw_data)
{
// Handle cases of screen coordinates != from framebuffer coordinates (e.g. retina displays)
ImGuiIO& io = ImGui::GetIO();
draw_data->ScaleClipRects(io.DisplayFramebufferScale);
// Render command lists
for(int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
const unsigned char* vtx_buffer = (const unsigned char*)&cmd_list->VtxBuffer.front();
const ImDrawIdx* idx_buffer = &cmd_list->IdxBuffer.front();
int nVert = cmd_list->VtxBuffer.size();
CIwFVec2* pVertStream = IW_GX_ALLOC(CIwFVec2, nVert);
CIwFVec2* pUVStream = IW_GX_ALLOC(CIwFVec2, nVert);
CIwColour* pColStream = IW_GX_ALLOC(CIwColour, nVert);
for( int i=0; i < nVert; i++ )
{
// TODO: optimize multiplication on gpu using vertex shader
pVertStream[i].x = cmd_list->VtxBuffer[i].pos.x * g_scale.x;
pVertStream[i].y = cmd_list->VtxBuffer[i].pos.y * g_scale.y;
pUVStream[i].x = cmd_list->VtxBuffer[i].uv.x;
pUVStream[i].y = cmd_list->VtxBuffer[i].uv.y;
pColStream[i] = cmd_list->VtxBuffer[i].col;
}
IwGxSetVertStreamScreenSpace(pVertStream, nVert);
IwGxSetUVStream(pUVStream);
IwGxSetColStream(pColStream, nVert);
IwGxSetNormStream(0);
for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
{
pcmd->UserCallback(cmd_list,pcmd);
}
else
{
CIwMaterial* pCurrentMaterial = IW_GX_ALLOC_MATERIAL();
pCurrentMaterial->SetShadeMode(CIwMaterial::SHADE_FLAT);
pCurrentMaterial->SetCullMode(CIwMaterial::CULL_NONE);
pCurrentMaterial->SetFiltering(false);
pCurrentMaterial->SetAlphaMode(CIwMaterial::ALPHA_BLEND);
pCurrentMaterial->SetDepthWriteMode(CIwMaterial::DEPTH_WRITE_NORMAL);
pCurrentMaterial->SetAlphaTestMode(CIwMaterial::ALPHATEST_DISABLED);
pCurrentMaterial->SetTexture((CIwTexture*)pcmd->TextureId);
IwGxSetMaterial(pCurrentMaterial);
IwGxDrawPrims(IW_GX_TRI_LIST, (uint16*)idx_buffer, pcmd->ElemCount);
}
idx_buffer += pcmd->ElemCount;
}
IwGxFlush();
}
// TODO: restore modified state (i.e. mvp matrix)
}
示例4: DrawPrimitives
void CzPlatformRender::DrawPrimitives(CzRenderPrim3* prims, CzRenderMaterial* materials, int num_prims, bool single_material)
{
while (num_prims-- > 0)
{
CIwMaterial::AlphaMode am = (CIwMaterial::AlphaMode)materials->AlphaMode; // TODO Add proper method to map Marmalade Alpha mode to Marmalade
int vc = prims->VertCount;
// Set up vertex streams
if (prims->UVs != NULL)
IwGxSetUVStream((CIwFVec2*)prims->UVs, 0);
else
IwGxSetUVStream(NULL);
if (prims->ModelSpace)
IwGxSetVertStreamModelSpace((CIwFVec3*)prims->Verts, vc);
else
IwGxSetVertStreamViewSpace((CIwFVec3*)prims->Verts, vc);
IwGxSetColStream((CIwColour*)prims->Colours);
IwGxSetNormStream((CIwFVec3*)prims->Normals);
CzTexture texture = materials->Image->getTexture();
CIwTexture* mt = static_cast<CIwTexture*>(texture);
bool filter;
if (materials->Image->isFilterSet())
filter = mt->GetFiltering();
else
filter = materials->Filter;
// Only create new render material if something important has changed
if (texture != CurrentTexture || CurrentAlphaMode != materials->AlphaMode || CurrentFilter != filter || CurrentTexture == NULL || CurrentTiled != materials->Tiled)
{
CIwMaterial* mat = IW_GX_ALLOC_MATERIAL();
mat->SetTexture(mt);
mat->SetDepthWriteMode(CIwMaterial::DEPTH_WRITE_DISABLED);
mat->SetClamping(!materials->Tiled);
mat->SetFiltering(filter);
mat->SetAlphaMode(am);
mat->SetCullMode(CIwMaterial::CULL_BACK);
// mat->SetCullMode(CIwMaterial::CULL_NONE);
IwGxSetMaterial(mat);
CurrentTexture = texture;
CurrentAlphaMode = materials->AlphaMode;
CurrentTiled = materials->Tiled;
CurrentFilter = filter;
}
else
{
RedundantTextureCalls++;
}
// Render the primitive
IwGxDrawPrims(CzToIwGxPrimType[prims->Type], prims->Indices, prims->IndicesCount);
// Move to next primitive
prims++;
if (!single_material)
materials++;
}
}
示例5: myIwGxDoneStars
void myIwGxDoneStars()
{
IwGxSetScreenSpaceSlot(3);
IwGxSetVertStreamScreenSpace( svertices, ssend_vertices );
CIwMaterial *pMat = IW_GX_ALLOC_MATERIAL();
pMat->SetAlphaMode( CIwMaterial::ALPHA_ADD );
pMat->SetTexture( star_texture );
pMat->SetColAmbient( 0xFF, 0xFF, 0xFF, 0xFF );
IwGxSetMaterial( pMat );
IwGxSetUVStream( suvdata );
IwGxSetColStream( scolors, ssend_vertices );
IwGxDrawPrims( IW_GX_QUAD_LIST, NULL, ssend_vertices );
IwGxFlush();
}
示例6: load
CIwMaterial* ResourceManager::load(const char* name, int* w, int* h) {
int width = 0, height = 0;
char res[MAX_RES_NAME] = {0};
sprintf(res, "images/%s/%s", desktop.getDevPath(), name);
IIter p = imgs->find(res);
if (p != imgs->end()) {
if (w != NULL) {
*w = p->second.width;
}
if (h != NULL) {
*h = p->second.height;
}
return p->second.mat;
}
CIwTexture* texture = new CIwTexture;
CIwImage image;
s3eFile* pFile = s3eFileOpen(res, "rb");
if (pFile) {
image.ReadFile(pFile);
width = image.GetWidth();
height = image.GetHeight();
s3eFileClose(pFile);
texture->CopyFromImage(&image);
texture->Upload();
} else {
delete texture;
texture = NULL;
}
CIwMaterial* mat = new CIwMaterial;
mat->SetTexture(texture);
SImg s;
s.texture = texture;
s.mat = mat;
s.width = width;
s.height = height;
imgs->insert(IPair(string(res), s));
if (w != NULL) {
*w = width;
}
if (h != NULL) {
*h = height;
}
return mat;
}
示例7: displayOnScreen
void Unit::displayOnScreen(int x, int y){
CIwMaterial *mat = new CIwMaterial();
mat->SetTexture((CIwTexture*)game->getSprites()->GetResHashed(getTextureName(), IW_GX_RESTYPE_TEXTURE));
mat->SetModulateMode(CIwMaterial::MODULATE_NONE);
mat->SetAlphaMode(CIwMaterial::ALPHA_DEFAULT);
IwGxSetMaterial(mat);
CIwSVec2 xy(x-45, y-45);
CIwSVec2 duv(IW_FIXED(1.0/numFrames), IW_GEOM_ONE);
static CIwSVec2 wh(90, 90);
static CIwSVec2 uv(IW_FIXED(0), IW_FIXED(0));
IwGxSetScreenSpaceSlot(1);
IwGxDrawRectScreenSpace(&xy, &wh, &uv, &duv);
delete mat;
}
示例8: renderCamera
void renderCamera() {
IwGxLightingOff();
// Refresh dynamic texture
if (g_CameraTexture != NULL)
g_CameraTexture->ChangeTexels((uint8*)g_pCameraTexelsRGB565, CIwImage::RGB_565);
CIwMaterial* pMat = IW_GX_ALLOC_MATERIAL();
pMat->SetModulateMode(CIwMaterial::MODULATE_NONE);
pMat->SetTexture(g_CameraTexture);
IwGxSetMaterial(pMat);
IwGxSetScreenSpaceSlot(-1);
IwGxSetUVStream(cameraUvs);
IwGxSetVertStreamScreenSpace(cameraVert, 4);
IwGxDrawPrims(IW_GX_QUAD_LIST, NULL, 4);
}
示例9: DrawTexture
void Graphics::DrawTexture(const Rect& screenCoords, int textureId, const Rect& textureCoord, float xOffset, float yOffset)
{
static CIwSVec2 textureUVs[4];
static CIwSVec2 screenXY[4];
static CIwMaterial material;
CIwTexture* texture = (CIwTexture*)ResourceManager::GetInstance().GetTexture(textureId)->GetData();
if (!texture)
return;
material.Reset();
material.SetAlphaMode(CIwMaterial::ALPHA_BLEND);
material.SetTexture(texture);
int16 width = texture->GetWidth();
int16 height = texture->GetHeight();
static const int16 uvSize = 4096;
// screen coordinates
screenXY[0] = CIwSVec2((int16)(screenCoords.left + xOffset), (int16)(screenCoords.top + yOffset));
screenXY[1] = CIwSVec2((int16)(screenCoords.left + xOffset), (int16)(screenCoords.bottom + yOffset));
screenXY[2] = CIwSVec2((int16)(screenCoords.right + xOffset), (int16)(screenCoords.top + yOffset));
screenXY[3] = CIwSVec2((int16)(screenCoords.right + xOffset), (int16)(screenCoords.bottom + yOffset));
// texture's UV coordinates
textureUVs[0] = CIwSVec2(((int16)textureCoord.left * uvSize) / width, ((int16)textureCoord.top * uvSize) / height);
textureUVs[1] = CIwSVec2(((int16)textureCoord.left * uvSize) / width, ((int16)textureCoord.bottom * uvSize) / height);
textureUVs[2] = CIwSVec2(((int16)textureCoord.right * uvSize) / width, ((int16)textureCoord.top * uvSize) / height);
textureUVs[3] = CIwSVec2(((int16)textureCoord.right * uvSize) / width, ((int16)textureCoord.bottom * uvSize) / height);
IwGxSetMaterial(&material);
IwGxSetUVStream(textureUVs);
IwGxSetColStream(NULL);
IwGxSetVertStreamScreenSpace(screenXY, 4);
IwGxDrawPrims(IW_GX_QUAD_STRIP, NULL, 4);
IwGxFlush();
}
示例10: CIwMaterial
CIwMaterial * CRenderer::GetMtlCached( CIwTexture * tex, CIwMaterial::AlphaMode blend )
{
MaterialContainer::iterator it = mMtlCache.begin(), ite = mMtlCache.end();
for (; it != ite; it++ )
{
if ( (*it)->GetTexture() == tex && (*it)->GetAlphaMode() == blend )
{
return *it;
}
}
CIwMaterial * pMat = new CIwMaterial();
pMat->SetTexture( tex );
pMat->SetAlphaMode( blend );
//pMat->SetBlendMode( CIwMaterial::BLEND_MODULATE_4X );
pMat->SetFiltering( true );
pMat->SetClamping(true);
mMtlCache.push_back( pMat );
return pMat;
}
示例11: IwGxGetScreenOrient
void Transitions2D::Fade(uint8 transitionSpeed, bool skipFirstAndLastFrame)
{
IwGxSetColClear(0, 0, 0, 0);
if (mStartTexture == NULL || mEndTexture == NULL)
return;
if (transitionSpeed == 0)
transitionSpeed = 1;
IwGxScreenOrient orient = IwGxGetScreenOrient();
if (isUsingPrivateTextures) IwGxSetScreenOrient(IW_GX_ORIENT_NONE);
int alpha = 0;
if (skipFirstAndLastFrame)
alpha += transitionSpeed;
CIwMaterial* startMat;
CIwMaterial* endMat;
while (alpha <= 255)
{
IwGxClear();
startMat = IW_GX_ALLOC_MATERIAL();
startMat->SetTexture(mStartTexture);
IwGxSetMaterial(startMat);
IwGxDrawRectScreenSpace(&CIwSVec2(0, 0), &CIwSVec2(mStartTexture->GetWidth(), mStartTexture->GetHeight()));
endMat = IW_GX_ALLOC_MATERIAL();
endMat->SetTexture(mEndTexture);
endMat->SetAlphaMode(CIwMaterial::ALPHA_BLEND);
endMat->SetColAmbient(255, 255, 255, alpha);
IwGxSetMaterial(endMat);
IwGxDrawRectScreenSpace(&CIwSVec2(0, 0), &CIwSVec2(mEndTexture->GetWidth(), mEndTexture->GetHeight()));
IwGxFlush();
IwGxSwapBuffers();
s3eDeviceYield(40);
alpha += transitionSpeed;
}
if (!skipFirstAndLastFrame)
{
IwGxClear();
endMat = IW_GX_ALLOC_MATERIAL();
endMat->SetTexture(mEndTexture);
IwGxSetMaterial(endMat);
IwGxDrawRectScreenSpace(&CIwSVec2(0, 0), &CIwSVec2(mEndTexture->GetWidth(), mEndTexture->GetHeight()));
IwGxFlush();
IwGxSwapBuffers();
}
if (isUsingPrivateTextures)
{
delete mStartTexture;
delete mEndTexture;
mStartTexture = NULL;
mEndTexture = NULL;
}
IwGxSetScreenOrient(orient);
}
示例12: DownloadTiles
void MapBackground::DownloadTiles()
{
CIwTexture* tx = (CIwTexture*)IwGetResManager()->GetResNamed("logo", IW_GX_RESTYPE_TEXTURE);
uint32 w1 = tx->GetWidth();
uint32 h1 = tx->GetHeight();
//static CIwSVec2 uvs[4] =
//{
// CIwSVec2(0 << 12, 0 << 12),
// CIwSVec2(0 << 12, 1 << 12),
// CIwSVec2(1 << 12, 1 << 12),
// CIwSVec2(1 << 12, 0 << 12),
//};
static CIwSVec2 uvs[4] =
{
CIwSVec2((0 << 12) + 10, (0 << 12) + 10),
CIwSVec2((0 << 12) + 10, (1 << 12) - 10),
CIwSVec2((1 << 12) - 10, (1 << 12) - 10),
CIwSVec2((1 << 12) - 10, (0 << 12) + 10),
};
int w = w1/2;
int h = h1/2;
int counter = 0;
while (true)
{
IwGetHTTPQueue()->Update();
IwGetNotificationHandler()->Update();
IwGetMultiplayerHandler()->Update();
IwGxClear(IW_GX_COLOUR_BUFFER_F | IW_GX_DEPTH_BUFFER_F);
CIwMaterial* pMat = IW_GX_ALLOC_MATERIAL();
pMat->SetModulateMode(CIwMaterial::MODULATE_NONE);
pMat->SetTexture(tx);
IwGxSetMaterial(pMat);
CIwMat rotMat;
rotMat.SetIdentity();
double perCentAngle = (counter / 80.0);
iwangle degAng = (iwangle)(IW_GEOM_ONE * perCentAngle);
rotMat.SetRotZ(degAng);
rotMat.t.z = -0x200;
IwGxSetViewMatrix(&rotMat);
CIwSVec3* pWSCoords= IW_GX_ALLOC(CIwSVec3, 4);
pWSCoords[0].x = -w; pWSCoords[0].y = -h;
pWSCoords[1].x = -w; pWSCoords[1].y = h;
pWSCoords[2].x = w; pWSCoords[2].y = h;
pWSCoords[3].x = w; pWSCoords[3].y = -h;
pWSCoords[0].z = pWSCoords[1].z = pWSCoords[2].z = pWSCoords[3].z = 0;
if (!g_bInProgress)
{
MapTile* pNextDownload = GetNextDownload(NULL);
if (pNextDownload)
{
IwGetNotificationHandler()->PushNotification((int)this, pNextDownload->szImageUrl, 10*1000);
g_bInProgress = true;
LoadMapTileImage(pNextDownload);
}
else
{
IwGetNotificationHandler()->ClearNotification((int)this);
break;
}
}
IwGxSetVertStreamWorldSpace(pWSCoords, 4);
IwGxSetUVStream(uvs);
IwGxDrawPrims(IW_GX_QUAD_LIST, NULL, 4);
IwGetNotificationHandler()->Render();
IwGxFlush();
IwGxSwapBuffers();
s3eDeviceYield(50);
counter++;
}
}
示例13: RenderBackgroundOnSurface
void MapBackground::RenderBackgroundOnSurface(CIw2DSurface* pSurface)
{
std::list<MapTile*>::iterator iter = gVectorImageUrls.begin();
// Set up a view matrix to rotate what we are viewing about the z-axis
// This normalizes the center of the screen to (0,0), so we need to offset
// our coordinates.
// We also need to scale in our X and Y directions.
CIwColour colClear;
colClear = IwGxGetColClear();
if (g_dAlpha < 0xFF)
{
IwGxSetColClear(0, 0, 0, 0);
}
CIwColour* cols = IW_GX_ALLOC(CIwColour, 4);
for (int i = 0; i < 4; ++i)
{
cols[i].r = cols[i].g = cols[i].b = 0xff;
cols[i].a = (uint8)g_dAlpha;
}
//static CIwSVec2 uvs[4] =
//{
// CIwSVec2(0 << 12, 0 << 12),
// CIwSVec2(0 << 12, 1 << 12),
// CIwSVec2(1 << 12, 1 << 12),
// CIwSVec2(1 << 12, 0 << 12),
//};
static CIwSVec2 uvs[4] =
{
CIwSVec2((0 << 12) + 1, (0 << 12) + 1),
CIwSVec2((0 << 12) + 1, (1 << 12) - 1),
CIwSVec2((1 << 12) - 1, (1 << 12) - 1),
CIwSVec2((1 << 12) - 1, (0 << 12) + 1),
};
static CIwSVec2 uvsRot[4] =
{
CIwSVec2((0 << 12) + 20, (0 << 12) + 20),
CIwSVec2((0 << 12) + 20, (1 << 12) - 20),
CIwSVec2((1 << 12) - 20, (1 << 12) - 20),
CIwSVec2((1 << 12) - 20, (0 << 12) + 20),
};
while (iter != gVectorImageUrls.end())
{
MapTile* pTile = *iter;
CIwTexture* pTexture = pTile->pTexture;
if (pTexture)
{
//Calculate the top left of the map image
CIwSVec2 topLeft = pTile->location;
CIwMaterial* pMat = IW_GX_ALLOC_MATERIAL();
pMat->SetAlphaMode(CIwMaterial::ALPHA_BLEND);
pMat->SetModulateMode(CIwMaterial::MODULATE_RGB);
// Use Texture on Material
pMat->SetTexture(pTexture);
IwGxSetMaterial(pMat);
int xOffset = IwGxGetScreenWidth() / 2;
int yOffset = IwGxGetScreenHeight() / 2;
CIwSVec3* pWSCoords= IW_GX_ALLOC(CIwSVec3, 4);
pWSCoords[0].x = topLeft.x; pWSCoords[0].y = topLeft.y;
pWSCoords[1].x = topLeft.x; pWSCoords[1].y = topLeft.y + 256;
pWSCoords[2].x = topLeft.x + 256; pWSCoords[2].y = topLeft.y + 256;
pWSCoords[3].x = topLeft.x + 256; pWSCoords[3].y = topLeft.y;
pWSCoords[0].z = pWSCoords[1].z = pWSCoords[2].z = pWSCoords[3].z = 0;
// Scale the coordinates by offsetting, scaling and rendering
for (int i = 0; i < 4; ++i)
{
pWSCoords[i].x -= xOffset;
pWSCoords[i].y -= yOffset;
}
IwGxSetVertStreamWorldSpace(pWSCoords, 4);
if (g_bScaledMode)
{
IwGxSetUVStream(uvsRot);
}
else
{
IwGxSetUVStream(uvs);
}
IwGxSetColStream(cols);
IwGxDrawPrims(IW_GX_QUAD_LIST, NULL, 4);
}
iter++;
}
IwGxSetColStream(NULL);
//IwGxSetColClear(colClear.r, colClear.g, colClear.b, colClear.a);
}
示例14: doMain
void doMain() {
if(s3ePointerGetInt(S3E_POINTER_MULTI_TOUCH_AVAILABLE)){
s3ePointerRegister(S3E_POINTER_TOUCH_EVENT, (s3eCallback)MultiTouchButtonCB, NULL);
s3ePointerRegister(S3E_POINTER_TOUCH_MOTION_EVENT, (s3eCallback)MultiTouchMotionCB, NULL);
} else {
s3ePointerRegister(S3E_POINTER_BUTTON_EVENT, (s3eCallback)SingleTouchButtonCB, NULL);
s3ePointerRegister(S3E_POINTER_MOTION_EVENT, (s3eCallback)SingleTouchMotionCB, NULL);
}
IwGetResManager()->LoadGroup("resource_groups/palate.group");
palateGroup = IwGetResManager()->GetGroupNamed("Palate");
std::vector<int> ui_texture_hashes;
uint background_hash = IwHashString("background_clean");
CIwResList* resources = palateGroup->GetListHashed(IwHashString("CIwTexture"));
for(CIwManaged** itr = resources->m_Resources.GetBegin(); itr != resources->m_Resources.GetEnd(); ++itr) {
if(background_hash != (*itr)->m_Hash) {
ui_texture_hashes.push_back((*itr)->m_Hash);
}
}
CIwMaterial* background = new CIwMaterial();
background->SetTexture((CIwTexture*)palateGroup->GetResNamed("background_clean", IW_GX_RESTYPE_TEXTURE));
background->SetModulateMode(CIwMaterial::MODULATE_NONE);
background->SetAlphaMode(CIwMaterial::ALPHA_DEFAULT);
unit_ui = new CIwMaterial();
unit_ui->SetModulateMode(CIwMaterial::MODULATE_NONE);
unit_ui->SetAlphaMode(CIwMaterial::ALPHA_DEFAULT);
unit_ui->SetTexture((CIwTexture*)palateGroup->GetResNamed("TAKE2", IW_GX_RESTYPE_TEXTURE));
CIwSVec2 bg_wh(320, 480);
CIwSVec2 ui_wh(80, 480);
CIwSVec2 ui_offset(240, 0);
CIwSVec2 uv(0, 0);
CIwSVec2 duv(IW_GEOM_ONE, IW_GEOM_ONE);
init();
IwGxLightingOff();
IwGxSetColClear(255, 255, 255, 255);
float worldScrollMultiplier = 0.75;
if(s3eDeviceGetInt(S3E_DEVICE_OS) == S3E_OS_ID_IPHONE) {
worldScrollMultiplier = 0.925;
}
while (1) {
int64 start = s3eTimerGetMs();
s3eDeviceYield(0);
s3eKeyboardUpdate();
s3ePointerUpdate();
if ((s3eKeyboardGetState(s3eKeyEsc) & S3E_KEY_STATE_DOWN)
|| (s3eKeyboardGetState(s3eKeyAbsBSK) & S3E_KEY_STATE_DOWN)
|| (s3eDeviceCheckQuitRequest())) {
break;
}
switch(currentState) {
case MAIN_MENU:
if(s3ePointerGetState(S3E_POINTER_BUTTON_SELECT) & S3E_POINTER_STATE_PRESSED) {
currentState = IN_GAME;
}
if(frameCount % FRAMES_PER_UPDATE == 0) {
mainMenu->tick();
}
mainMenu->render();
break;
case IN_GAME:
IwGxSetMaterial(background);
IwGxSetScreenSpaceSlot(-1);
IwGxDrawRectScreenSpace(&CIwSVec2::g_Zero, &bg_wh, &uv, &duv);
IwGxSetMaterial(unit_ui);
IwGxSetScreenSpaceSlot(1);
IwGxDrawRectScreenSpace(&ui_offset, &ui_wh, &uv, &duv);
if (worldScrollSpeed > .0005 || worldScrollSpeed < -.0005) {
game->rotate(worldScrollSpeed);
worldScrollSpeed *= worldScrollMultiplier;
}
if(frameCount % FRAMES_PER_UPDATE == 0) {
game->tick();
}
game->render();
if(!renderTouches()) {
break;
}
break;
}
//.........这里部分代码省略.........
示例15: BatchDrawPrims
// BatchDrawPrims - Currently only supports batching of Quad lists
void CzPlatformRender::BatchDrawPrims(bool filter)
{
if (NextMaterial == 0)
return;
// Allocate memory from data cache for verts, UV's and colours
for (int t = 0; t < NextMaterial; t++)
{
int prim_count = MaterialUsedCounts[t] * 4;
BatchVerts[t] = IW_GX_ALLOC(CzVec2, prim_count);
BatchUVs[t] = IW_GX_ALLOC(CzVec2, prim_count);
BatchColours[t] = IW_GX_ALLOC(CzColour, prim_count);
BatchIndices[t] = IW_GX_ALLOC(uint16, prim_count);
}
// Populate the data cache
CzRenderPrim** prims = Primitives;
for (int t = 0; t < NextPrimitive; t++)
{
CzRenderPrim *prim = *prims;
int mat_id = prim->MaterialID;
int idx = MaterialIndices[mat_id];
CzVec2* v = BatchVerts[mat_id] + idx;
CzVec2* uv = BatchUVs[mat_id] + idx;
CzColour* c = BatchColours[mat_id] + idx;
uint16* i = BatchIndices[mat_id] + idx;
for (int t2 = 0; t2 < 4; t2++)
{
v->x = (prim->Verts + t2)->x;
v->y = (prim->Verts + t2)->y;
uv->x = (prim->UVs + t2)->x;
uv->y = (prim->UVs + t2)->y;
c->set(*(prim->Colours + t2));
v++; uv++; c++;
}
// TODO: ERROR - Does not work with batched ngon
*i++ = idx;
*i++ = idx + 3;
*i++ = idx + 2;
*i++ = idx + 1;
MaterialIndices[mat_id] += 4;
prims++;
}
// Render batched streams
CzRenderMaterial** mats = Materials;
for (int t = 0; t < NextMaterial; t++)
{
int count = MaterialUsedCounts[t] * 4;
IwGxSetUVStream((CIwFVec2*)BatchUVs[t], 0);
IwGxSetVertStreamScreenSpace((CIwFVec2*)BatchVerts[t], count);
IwGxSetColStream((CIwColour*)(BatchColours[t]), count);
IwGxSetNormStream(NULL);
CIwMaterial* mat = IW_GX_ALLOC_MATERIAL();
CIwTexture* texture = static_cast<CIwTexture*>((*mats)->Image->getTexture());
mat->SetTexture(texture);
mat->SetDepthWriteMode(CIwMaterial::DEPTH_WRITE_DISABLED);
mat->SetClamping(false);
mat->SetFiltering(filter);
mat->SetAlphaMode(CIwMaterial::ALPHA_BLEND);
mat->SetCullMode(CIwMaterial::CULL_BACK);
// mat->SetCullMode(CIwMaterial::CULL_NONE);
IwGxSetMaterial(mat);
IwGxDrawPrims(IW_GX_QUAD_LIST, BatchIndices[t], count);
mats++;
}
// Reset batch pointers
for (int t = 0; t < NextMaterial; t++)
MaterialUsedCounts[t] = 0;
for (int t = 0; t < NextMaterial; t++)
MaterialIndices[t] = 0;
NextPrimitive = 0;
NextMaterial = 0;
}