本文整理汇总了C++中CBitmap::Bind方法的典型用法代码示例。如果您正苦于以下问题:C++ CBitmap::Bind方法的具体用法?C++ CBitmap::Bind怎么用?C++ CBitmap::Bind使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBitmap
的用法示例。
在下文中一共展示了CBitmap::Bind方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RenderSoftGlare
void RenderSoftGlare (CFloatVector *sprite, CFloatVector *vCenter, int nTexture, float fIntensity, int bAdditive, int bColored)
{
tRgbaColorf color;
tTexCoord2f tcGlare [4] = {{{0,0}},{{1,0}},{{1,1}},{{0,1}}};
int i;
CBitmap* bmP = NULL;
if (gameStates.render.bQueryCoronas) {
glDisable (GL_TEXTURE_2D);
glBlendFunc (GL_ONE, GL_ZERO);
}
else {
glEnable (GL_TEXTURE_2D);
glDepthFunc (GL_ALWAYS);
if (bAdditive)
glBlendFunc (GL_ONE, GL_ONE);
if (!(bmP = bAdditive ? bmpGlare : bmpCorona))
return;
}
if (gameStates.render.bAmbientColor)
color = gameData.render.color.textures [nTexture].color;
else
color.red = color.green = color.blue = X2F (IsLight (nTexture)) / 2;
if (!bColored)
color.red = color.green = color.blue = (color.red + color.green + color.blue) / 4;
if (gameOptions [0].render.coronas.nStyle == 1)
fIntensity = float (sqrt (fIntensity));
if (bAdditive)
glColor4f (fIntensity * color.red, fIntensity * color.green, fIntensity * color.blue, 1);
else
glColor4f (color.red, color.green, color.blue, fIntensity);
if (ogl.EnableClientStates (gameStates.render.bQueryCoronas == 0, 0, 0, GL_TEXTURE0)) {
if (!gameStates.render.bQueryCoronas) {
bmP->Bind (1);
OglTexCoordPointer (2, GL_FLOAT, 0, tcGlare);
}
OglVertexPointer (3, GL_FLOAT, sizeof (CFloatVector), sprite);
OglDrawArrays (GL_QUADS, 0, 4);
ogl.DisableClientStates (gameStates.render.bQueryCoronas == 0, 0, 0, GL_TEXTURE0);
}
else {
if (gameStates.render.bQueryCoronas == 0)
bmP->Bind (1);
glBegin (GL_QUADS);
for (i = 0; i < 4; i++) {
glTexCoord2fv (reinterpret_cast<GLfloat*> (tcGlare + i));
glVertex3fv (reinterpret_cast<GLfloat*> (sprite + i));
}
glEnd ();
}
if (!gameStates.render.bQueryCoronas && bAdditive)
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
RenderCoronaOutline (sprite, vCenter);
if (gameStates.render.bQueryCoronas != 2) {
glEnable (GL_DEPTH_TEST);
if (gameStates.render.bQueryCoronas == 1)
glDepthFunc (GL_LEQUAL);
}
}
示例2: RenderHardGlare
void RenderHardGlare (CFloatVector *sprite, CFloatVector *vCenter, int nTexture, float fLight,
float fIntensity, tIntervalf *zRangeP, int bAdditive, int bColored)
{
tTexCoord2f tcGlare [4] = {{{0,0}},{{1,0}},{{1,1}},{{0,1}}};
tRgbaColorf color;
CBitmap* bmP;
int i;
fLight /= 4;
if (fLight < 0.01f)
return;
color.alpha = vCenter->Mag ();
if (color.alpha < zRangeP->fRad)
fIntensity *= color.alpha / zRangeP->fRad;
if (gameStates.render.bAmbientColor) {
color = gameData.render.color.textures [nTexture].color;
color.alpha = (float) (color.red * 3 + color.green * 5 + color.blue * 2) / 30 * 2;
}
else {
color.alpha = X2F (IsLight (nTexture));
color.red = color.green = color.blue = color.alpha / 2;
color.alpha *= 2.0f / 3.0f;
}
if (!bColored)
color.red = color.green = color.blue = (color.red + color.green + color.blue) / 4;
color.alpha *= fIntensity * fIntensity;
if (color.alpha < 0.01f)
return;
glEnable (GL_TEXTURE_2D);
if (!(bmP = bAdditive ? bmpGlare : bmpCorona))
return;
bmP->SetTranspType (-1);
if (bmP->Bind (1))
return;
bmP->Texture ()->Wrap (GL_CLAMP);
glDisable (GL_CULL_FACE);
if (bAdditive) {
fLight *= color.alpha;
glBlendFunc (GL_ONE, GL_ONE);
}
glColor4fv (reinterpret_cast<GLfloat*> (&color));
glBegin (GL_QUADS);
for (i = 0; i < 4; i++) {
glTexCoord2fv (reinterpret_cast<GLfloat*> (tcGlare + i));
glVertex3fv (reinterpret_cast<GLfloat*> (sprite + i));
}
glEnd ();
if (bAdditive)
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable (GL_CULL_FACE);
RenderCoronaOutline (sprite, vCenter);
}
示例3: RenderShadowTexture
void RenderShadowTexture (void)
{
if (!(shadowProg ||
(CreateShaderProg (&shadowProg) &&
CreateShaderFunc (&shadowProg, &shadowFS, &shadowVS, pszShadowFS, pszShadowVS, 1) &&
LinkShaderProg (&shadowProg))))
return;
glMatrixMode (GL_MODELVIEW);
glPushMatrix ();
glLoadIdentity ();
glMatrixMode (GL_PROJECTION);
glPushMatrix ();
glLoadIdentity ();
glOrtho (0, 1, 1, 0, 0, 1);
glDisable (GL_DEPTH_TEST);
glDepthMask (0);
#if 1
glDisable (GL_BLEND);
#else
glEnable (GL_BLEND);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
#endif
glEnable (GL_TEXTURE_2D);
ogl.SelectTMU (GL_TEXTURE0);
shadowBuf.SetTranspType (0);
if (shadowBuf.Bind (0))
return;
glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
#if 0
glUseProgramObject (shadowProg);
glUniform1i (glGetUniformLocation (shadowProg, "shadowTex"), 0);
#endif
glBegin (GL_QUADS);
glTexCoord2d (0,0);
glVertex2d (0,0);
glTexCoord2d (1,0);
glVertex2d (0.5,0);
glTexCoord2d (1,-1);
glVertex2d (0.5,0.5);
glTexCoord2d (0,-1);
glVertex2d (0,0.5);
glEnd ();
if (ogl.m_states.bShadersOk)
glUseProgramObject (0);
glEnable (GL_DEPTH_TEST);
glDepthMask (1);
glPopMatrix ();
glMatrixMode (GL_MODELVIEW);
glPopMatrix ();
}
示例4: LoadAddonBitmap
int LoadAddonBitmap (CBitmap **bmPP, const char *pszName, int *bHaveP)
{
if (!*bHaveP) {
char szFilename [FILENAME_LEN];
CFile cf;
sprintf (szFilename, "%s/d2x-xl/%s", gameFolders.szTextureDir [2], pszName);
if (!cf.Exist (szFilename, "", 0))
sprintf (szFilename, "%s/d2x-xl/%s", gameFolders.szTextureDir [0], pszName);
CBitmap *bmP = CreateAndReadTGA (szFilename);
if (!bmP)
*bHaveP = -1;
else {
*bHaveP = 1;
bmP->SetFrameCount ();
bmP->SetTranspType (-1);
bmP->Bind (1);
}
*bmPP = bmP;
}
return *bHaveP > 0;
}
示例5: LoadBackground
CBitmap* CBackgroundManager::LoadBackground (char* filename)
{
int width, height;
if (PCXGetDimensions (filename, &width, &height) != PCX_ERROR_NONE) {
Error ("Could not open menu background file <%s>\n", filename);
return NULL;
}
CBitmap* bmP;
if (!(bmP = CBitmap::Create (0, width, height, 1))) {
Error ("Not enough memory for menu backgroun\n");
return NULL;
}
if (PCXReadBitmap (filename, bmP, bmP->Mode (), 0) != PCX_ERROR_NONE) {
Error ("Could not read menu background file <%s>\n", filename);
return NULL;
}
bmP->SetName (filename);
bmP->SetTranspType (3);
bmP->Bind (0);
return bmP;
}
示例6: Render
int CParticle::Render (float brightness)
{
CFixVector hp;
GLfloat d, u, v;
CBitmap* bmP;
tRgbaColorf pc;
tParticleVertex* pb;
CFloatVector vOffset, vCenter;
int i, nFrame, nType = m_nType, bEmissive = m_bEmissive;
float decay = (nType == BUBBLE_PARTICLES) ? 1.0f : (float) m_nLife / (float) m_nTTL;
static int nFrames = 1;
static float deltaUV = 1.0f;
static tSinCosf sinCosPart [PARTICLE_POSITIONS];
static int bInitSinCos = 1;
static CFloatMatrix mRot;
if (m_nDelay > 0)
return 0;
if ((nType < 0) || (nType >= PARTICLE_TYPES))
return 0;
if (!(bmP = bmpParticle [0][nType]))
return 0;
if (bmP->CurFrame ())
bmP = bmP->CurFrame ();
if (gameOpts->render.bDepthSort > 0) {
hp = m_vTransPos;
if ((particleManager.LastType () != nType) || (brightness != bufferBrightness) || (bBufferEmissive != bEmissive)) {
particleManager.FlushBuffer (brightness);
particleManager.SetLastType (nType);
bBufferEmissive = bEmissive;
ogl.SelectTMU (GL_TEXTURE0, true);
if (bmP->Bind (0))
return 0;
nFrames = nParticleFrames [0][nType];
deltaUV = 1.0f / (float) nFrames;
if (m_bEmissive)
//glBlendFunc (GL_ONE, GL_ONE);
glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_COLOR);
else
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
}
else if (gameOpts->render.particles.bSort) {
hp = m_vTransPos;
if ((particleManager.LastType () != nType) || (brightness != bufferBrightness)) {
particleManager.FlushBuffer (brightness);
particleManager.SetLastType (nType);
if (bmP->Bind (0))
return 0;
nFrames = nParticleFrames [0][nType];
deltaUV = 1.0f / (float) nFrames;
if (m_bEmissive)
glBlendFunc (GL_ONE, GL_ONE);
else
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
}
else
transformation.Transform(hp, m_vPos, 0);
if (m_bBright)
brightness = (float) sqrt (brightness);
if (nType == SMOKE_PARTICLES) {
if (m_nFade > 0) {
if (m_color [0].green < m_color [1].green) {
#if SMOKE_SLOWMO
m_color [0].green += 1.0f / 20.0f / (float) gameStates.gameplay.slowmo [0].fSpeed;
#else
m_color [0].green += 1.0f / 20.0f;
#endif
if (m_color [0].green > m_color [1].green) {
m_color [0].green = m_color [1].green;
m_nFade--;
}
}
if (m_color [0].blue < m_color [1].blue) {
#if SMOKE_SLOWMO
m_color [0].blue += 1.0f / 10.0f / (float) gameStates.gameplay.slowmo [0].fSpeed;
#else
m_color [0].blue += 1.0f / 10.0f;
#endif
if (m_color [0].blue > m_color [1].blue) {
m_color [0].blue = m_color [1].blue;
m_nFade--;
}
}
}
else if (m_nFade == 0) {
m_color [0].red = m_color [1].red * RANDOM_FADE;
m_color [0].green = m_color [1].green * RANDOM_FADE;
m_color [0].blue = m_color [1].blue * RANDOM_FADE;
m_nFade = -1;
}
}
pc = m_color [0];
//pc.alpha *= /*gameOpts->render.particles.bDisperse ? decay2 :*/ decay;
if ((nType == SMOKE_PARTICLES) || (nType == BUBBLE_PARTICLES)) {
char nFrame = ((nType == BUBBLE_PARTICLES) && !gameOpts->render.particles.bWobbleBubbles) ? 0 : m_nFrame;
u = (float) (nFrame % nFrames) * deltaUV;
v = (float) (nFrame / nFrames) * deltaUV;
//.........这里部分代码省略.........
示例7: Draw
int CSubModel::Draw (CObject *objP, CModel *po, float *fLight)
{
CFace* pf;
CFaceVert* pfv;
CFloatVector* pv, * pvn, * phv;
tFaceColor* pvc, vc, sc = {{1,1,1,1}};
CBitmap *bmP;
int h, i, j;
int bBright = EGI_FLAG (bBrightObjects, 0, 1, 0);
int bDynLighting = gameStates.render.bApplyDynLight;
float fl, r, g, b, fAlpha = po->m_fAlpha;
#if DBG_SHADOWS
if (bShadowTest && (bShadowTest < 4))
return 1;
#endif
pv = m_rotVerts.Buffer ();
pvn = m_normals.Buffer ();
pvc = m_vertColors.Buffer ();
//memset (pvc, 0, m_nVerts * sizeof (tFaceColor));
glEnable (GL_CULL_FACE);
OglCullFace (0);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
if (!bDynLighting) {
sc = *lightManager.AvgSgmColor (objP->info.nSegment, &objP->info.position.vPos);
if (sc.index != gameStates.render.nFrameFlipFlop + 1)
sc.color.red = sc.color.green = sc.color.blue = 1;
}
for (i = m_faces.m_nFaces, pf = m_faces.m_list.Buffer (); i; i--, pf++) {
if (pf->m_bReverse)
glFrontFace (GL_CCW);
pfv = pf->m_verts;
#if 0
if (!(gameStates.ogl.bUseTransform || OOF_FrontFace (pso, pf)))
continue;
#endif
if (pf->m_bTextured) {
#if DBG
fl = pf->m_vNormal * mView.FVec();
fl = 0.75f + 0.25f * fl;
fl = fl * *fLight;
#else
fl = *fLight * (0.75f - 0.25f * (pf->m_vNormal * mView.FVec ()));
#endif
if (fl > 1)
fl = 1;
// fl = 1.0f;
bmP = po->m_textures.m_bitmaps + pf->m_texProps.nTexId;
if (bmP->Texture () && ((int) bmP->Texture ()->Handle () < 0))
bmP->Texture ()->SetHandle (0);
bmP->SetTranspType (0);
if (bmP->Bind (1))
return 0;
bmP->Texture ()->Wrap (GL_REPEAT);
if (m_nFlags & (bDynLighting ? OOF_SOF_THRUSTER : (OOF_SOF_GLOW | OOF_SOF_THRUSTER))) {
glColor4f (fl * m_glowInfo.m_color.red,
fl * m_glowInfo.m_color.green,
fl * m_glowInfo.m_color.blue,
m_pfAlpha [pfv->m_nIndex] * fAlpha);
}
else if (!bDynLighting) {
#if 0
fl = (float) sqrt (fl);
#endif
if (bBright)
#if 1
fl += (1 - fl) / 2;
#else
fl = (float) sqrt (fl);
#endif
glColor4f (sc.color.red * fl, sc.color.green * fl, sc.color.blue * fl,
m_pfAlpha [pfv->m_nIndex] * fAlpha);
}
glBegin (GL_TRIANGLE_FAN);
for (j = pf->m_nVerts; j; j--, pfv++) {
phv = pv + (h = pfv->m_nIndex);
if (bDynLighting) {
if (pvc [h].index != gameStates.render.nFrameFlipFlop + 1)
G3VertexColor (reinterpret_cast<CFloatVector3*> (pvn + h), reinterpret_cast<CFloatVector3*> (phv), -1, pvc + h, NULL, 1, 0, 0);
vc.color.red = (float) sqrt (pvc [h].color.red);
vc.color.green = (float) sqrt (pvc [h].color.green);
vc.color.blue = (float) sqrt (pvc [h].color.blue);
if (bBright) {
#if 1
vc.color.red += (1 - vc.color.red) / 2;
vc.color.green += (1 - vc.color.green) / 2;
vc.color.blue += (1 - vc.color.blue) / 2;
#else
vc.color.red = (float) sqrt (vc.color.red);
vc.color.green = (float) sqrt (vc.color.green);
vc.color.blue = (float) sqrt (vc.color.blue);
#endif
}
OglColor4sf (vc.color.red, vc.color.green, vc.color.blue, m_pfAlpha [pfv->m_nIndex] * fAlpha);
}
glTexCoord2f (pfv->m_fu, pfv->m_fv);
glVertex3fv (reinterpret_cast<GLfloat*> (phv));
//glVertex4f (phv->m_x, phv->m_y, phv->m_z, 0.5);
}
glEnd ();
//.........这里部分代码省略.........