本文整理汇总了C++中CIwMaterial类的典型用法代码示例。如果您正苦于以下问题:C++ CIwMaterial类的具体用法?C++ CIwMaterial怎么用?C++ CIwMaterial使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CIwMaterial类的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: IwAssertMsg
void CIwUIViewer::_LoadMaterial(const char* pRoot, const char* pFile, const char* pPath)
{
std::string objectName;
if (!ReadNameAttribute(pFile, objectName) || objectName != pRoot)
{
IwAssertMsg(VIEWER, false, ("Unexpected material data"));
return;
}
CIwMaterial* pMaterial = GetResNamed<CIwMaterial*>(m_ResGroup, pRoot, true);
if (!pMaterial && m_ResGroup)
{
pMaterial = new CIwMaterial;
pMaterial->SetName(pRoot);
m_ResGroup->AddRes(IW_GX_RESTYPE_MATERIAL, pMaterial);
}
if (pMaterial)
{
IwGetResManager()->AddLoadPath(pPath);
ParseContents(pMaterial, pFile);
IwGetResManager()->ClearLoadPaths();
}
else
IwAssertMsg(VIEWER, false, ("Could not find material: %s", pRoot));
}
示例3: IW_GX_ALLOC_MATERIAL
void SimpleMenu::smDrawSimpleMenuScrollbar(const CIwSVec2 & pos,const CIwSVec2 & size,const CIwSVec2 & spos,const CIwSVec2 & ssize)
{
CIwMaterial* m = IW_GX_ALLOC_MATERIAL();
CIwColour c;
c.Set(0xFFFFFFFF);
m->SetColAmbient(c);
m->SetAlphaMode(CIwMaterial::ALPHA_BLEND);
IwGxSetMaterial(m);
CIwSVec2* points = IW_GX_ALLOC(CIwSVec2,8);
CIwColour* cols = IW_GX_ALLOC(CIwColour,8);
points[0] = pos+CIwSVec2(0,0);
points[1] = pos+CIwSVec2(0,size.y);
points[2] = pos+CIwSVec2(size.x,size.y);
points[3] = pos+CIwSVec2(size.x,0);
c.Set(0x20,0x20,0x20,0x20);
cols[0] = cols[1] = cols[2] = cols[3] = c;
points[4] = spos+CIwSVec2(0,0);
points[5] = spos+CIwSVec2(0,ssize.y);
points[6] = spos+CIwSVec2(ssize.x,ssize.y);
points[7] = spos+CIwSVec2(ssize.x,0);
c.Set(0xFF,0xFF,0xFF,0x80);
cols[4] = cols[5] = cols[6] = cols[7] = c;
IwGxSetVertStreamScreenSpace(points,8);
IwGxSetColStream(cols);
IwGxDrawPrims(IW_GX_QUAD_LIST,0,8);
}
示例4: while
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++;
}
}
示例5: DrawRect
void DrawRect(int x, int y, int width, int height, uint8 r, uint8 g, uint8 b)
{
int right = x + width;
int bottom = y + height;
if (x < 0)
x = 0;
if (y < 0)
y = 0;
if (right > (int32)s3eSurfaceGetInt(S3E_SURFACE_WIDTH))
right = s3eSurfaceGetInt(S3E_SURFACE_WIDTH);
if (bottom > (int32)s3eSurfaceGetInt(S3E_SURFACE_HEIGHT))
bottom = s3eSurfaceGetInt(S3E_SURFACE_HEIGHT);
// Draw the text
IwGxSetScreenSpaceSlot(0);
CIwMaterial *fadeMat = IW_GX_ALLOC_MATERIAL();
fadeMat->SetAlphaMode(CIwMaterial::NONE);
fadeMat->SetShadeMode(CIwMaterial::SHADE_FLAT);
IwGxSetMaterial(fadeMat);
CIwColour* cols = IW_GX_ALLOC(CIwColour, 4);
for (int i = 0; i < 4; i++)
cols[i].Set(r, g, b);
CIwSVec2 xy(x, y);
CIwSVec2 wh(width, height);
IwGxDrawRectScreenSpace(&xy, &wh, cols);
}
示例6: IwGxClear
void SimpleMenu::smRenderLoading()
{
IwGxClear(IW_GX_DEPTH_BUFFER_F);
iwangle step = IW_GEOM_ONE/32;
g_toeLoadingAngle = (g_toeLoadingAngle+step) %IW_GEOM_ONE;
int32 h = (int32)IwGxGetScreenHeight();
int32 w = (int32)IwGxGetScreenWidth();
int32 x = w/2;
int32 y = h/2;
int r = (x<y)?(x/2):(y/2);
int r2 = r*8/10;
//iwfixed c = IwGeomCos(g_toeLoadingAngle);
//iwfixed s = IwGeomCos(g_toeLoadingAngle);
int32 vertices = 10*4;
CIwSVec2* v = IW_GX_ALLOC(CIwSVec2,vertices);
CIwColour* col = IW_GX_ALLOC(CIwColour,vertices);
int index = 0;
CIwColour c; c.Set(0xFFFFFFFF);
col[index] = c;
v[index++] = CIwSVec2(0,0);
col[index] = c;
v[index++] = CIwSVec2(0,h);
col[index] = c;
v[index++] = CIwSVec2(w,h);
col[index] = c;
v[index++] = CIwSVec2(w,0);
iwangle a = g_toeLoadingAngle;
int colS = 250/(vertices/4);
for (int i=1; i<(vertices/4);++i)
{
iwfixed c1 = IwGeomCos(a);
iwfixed s1 = IwGeomSin(a);
a += step;
iwfixed c2 = IwGeomCos(a);
iwfixed s2 = IwGeomSin(a);
c.r = c.g = c.b = 255-i*colS;
col[index] = c; v[index++] = CIwSVec2(x+c1*r/IW_GEOM_ONE,y+s1*r/IW_GEOM_ONE);
col[index] = c; v[index++] = CIwSVec2(x+c1*r2/IW_GEOM_ONE,y+s1*r2/IW_GEOM_ONE);
c.r = c.g = c.b = 255-(i+1)*colS;
col[index] = c; v[index++] = CIwSVec2(x+c2*r2/IW_GEOM_ONE,y+s2*r2/IW_GEOM_ONE);
col[index] = c; v[index++] = CIwSVec2(x+c2*r/IW_GEOM_ONE,y+s2*r/IW_GEOM_ONE);
}
CIwMaterial* m = IW_GX_ALLOC_MATERIAL();
m->SetColAmbient(255,255,255,255);
IwGxClear(IW_GX_DEPTH_BUFFER_F);
IwGxSetMaterial(m);
IwGxLightingOff();
IwGxSetVertStreamScreenSpace(v,vertices);
IwGxSetUVStream(0);
IwGxSetColStream(col);
IwGxDrawPrims(IW_GX_QUAD_LIST, 0, index);
IwGxFlush();
IwGxSwapBuffers();
IwGxClear(IW_GX_DEPTH_BUFFER_F);
}
示例7: SoftkeyRender
static void SoftkeyRender(const char* text, s3eDeviceSoftKeyPosition pos, void(*handler)())
{
// TODO: Hardocoded font width and height (boo!)
int width = 7;
int height = 30;
width *= strlen(text) * 2;
int x = 0;
int y = 0;
switch (pos)
{
case S3E_DEVICE_SOFTKEY_BOTTOM_LEFT:
y = IwGxGetScreenHeight() - height;
x = 0;
break;
case S3E_DEVICE_SOFTKEY_BOTTOM_RIGHT:
y = IwGxGetScreenHeight() - height;
x = IwGxGetScreenWidth() - width;
break;
case S3E_DEVICE_SOFTKEY_TOP_RIGHT:
y = 0;
x = IwGxGetScreenWidth() - width;
break;
case S3E_DEVICE_SOFTKEY_TOP_LEFT:
x = 0;
y = 0;
break;
}
CIwMaterial *fadeMat = IW_GX_ALLOC_MATERIAL();
fadeMat->SetAlphaMode(CIwMaterial::SUB);
IwGxSetMaterial(fadeMat);
IwGxPrintString(x + 10, y+10, text, false);
CIwColour* cols = IW_GX_ALLOC(CIwColour, 4);
memset(cols, 50, sizeof(CIwColour)*4);
if (s3ePointerGetState(S3E_POINTER_BUTTON_SELECT) & S3E_POINTER_STATE_PRESSED)
{
int pointerx = s3ePointerGetX();
int pointery = s3ePointerGetY();
if (pointerx >= x && pointerx <= x+width && pointery >=y && pointery <= y+height)
{
memset(cols, 15, sizeof(CIwColour)*4);
handler();
}
}
// Draw button area
CIwSVec2 XY(x, y-2), dXY(width, height);
IwGxDrawRectScreenSpace(&XY, &dXY, cols);
}
示例8: 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();
}
示例9: 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)
}
示例10: sprintf
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;
}
示例11: while
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++;
}
}
示例12: CIwMaterial
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;
}
示例13: 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);
}
示例14: 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();
}
示例15: 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;
}