void Render_OpenGL31::renderTexture(PGE_Texture *texture, float x, float y, float w, float h, float ani_top, float ani_bottom, float ani_left, float ani_right) { if(!texture) return; PGE_RectF rect = MapToGl(x, y, w, h); setRenderTexture(texture->texture); setAlphaBlending(); GLdouble Vertices[] = { rect.left(), rect.top(), 0, rect.right(), rect.top(), 0, rect.right(), rect.bottom(), 0, rect.left(), rect.bottom(), 0 }; GLfloat TexCoord[] = { ani_left, ani_top, ani_right, ani_top, ani_right, ani_bottom, ani_left, ani_bottom }; GLubyte indices[] = { 0, 1, 3, 2 }; glColorPointer(4, GL_FLOAT, 0, color_binded_texture); GLERRORCHECK(); glVertexPointer(3, GL_DOUBLE, 0, Vertices); GLERRORCHECK(); glTexCoordPointer(2, GL_FLOAT, 0, TexCoord); GLERRORCHECK(); glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_BYTE, indices); GLERRORCHECK(); setUnbindTexture(); }
void Render_OpenGL31::renderRectBR(float _left, float _top, float _right, float _bottom, GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) { PGE_RectF rect = MapToGlSI(_left, _top, _right, _bottom); setRenderColors(); setAlphaBlending(); GLdouble Vertices[] = { rect.left(), rect.top(), 0, rect.right(), rect.top(), 0, rect.right(), rect.bottom(), 0, rect.left(), rect.bottom(), 0 }; GLfloat Colors[] = { red, green, blue, alpha, red, green, blue, alpha, red, green, blue, alpha, red, green, blue, alpha }; GLubyte indices[] = { 0, 1, 2, 0, 2, 3 }; glVertexPointer(3, GL_DOUBLE, 0, Vertices); GLERRORCHECK(); glColorPointer(4, GL_FLOAT, 0, Colors); GLERRORCHECK(); glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, indices); GLERRORCHECK(); }
void EGLView::setGLDefaultValues(void) { // This method SHOULD be called only after openGLView_ was initialized CCAssert(m_pobOpenGLView, "opengl view should not be null"); setAlphaBlending(true); // XXX: Fix me, should enable/disable depth test according the depth format as cocos2d-iphone did // [self setDepthTest: view_.depthFormat]; setDepthTest(false); setProjection(m_eProjection); // set other opengl default values glClearColor(0.0f, 0.0f, 0.0f, 1.0f); }
void wyDirector::onSurfaceCreated() { // set flag m_surfaceCreated = true; // get GL thread id tagGLThread(); // 返回OpenGL支持的最大贴图尺寸,设置到wyDevice::maxTextureSize glGetIntegerv(GL_MAX_TEXTURE_SIZE, &wyDevice::maxTextureSize); // 选项:禁用抖动特效,以提高性能。 glDisable(GL_DITHER); // 对透视进行修正 glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST); // enable alpha blending setAlphaBlending(true); // disable depth test setDepthTest(m_enableDepthTest); // 指定象素的算法 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // 选项:禁用光照特效 glDisable(GL_LIGHTING); // 禁用剪刀测试 glDisable(GL_SCISSOR_TEST); // 选择平滑方式 glShadeModel(GL_FLAT); // 设置背景色黑色 glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // enable event gEventDispatcher->setDispatchEvent(true); // notify listener notifySurfaceCreated(); }
void CCDirector::setGLDefaultValues(void) { // This method SHOULD be called only after openGLView_ was initialized CCAssert(m_pobOpenGLView, "opengl view should not be null"); setAlphaBlending(true); setDepthTest(true); setProjection(m_eProjection); // set other opengl default values glClearColor(0.0f, 0.0f, 0.0f, 1.0f); #if CC_DIRECTOR_FAST_FPS if (! m_pFPSLabel) { m_pFPSLabel = CCLabelTTF::labelWithString(" 00.0", "Arial", 24); m_pFPSLabel->retain(); } #endif }
void Render_OpenGL31::renderRect(float x, float y, float w, float h, GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha, bool filled) { PGE_RectF rect = MapToGl(x, y, w, h); setRenderColors(); setAlphaBlending(); GLdouble Vertices[] = { rect.left(), rect.top(), 0, rect.right(), rect.top(), 0, rect.right(), rect.bottom(), 0, rect.left(), rect.bottom(), 0 }; GLfloat Colors[] = { red, green, blue, alpha, red, green, blue, alpha, red, green, blue, alpha, red, green, blue, alpha }; glVertexPointer(3, GL_DOUBLE, 0, Vertices); GLERRORCHECK(); glColorPointer(4, GL_FLOAT, 0, Colors); GLERRORCHECK(); if(filled) { GLubyte indices[] = { 0, 1, 2, 0, 2, 3 }; glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, indices); GLERRORCHECK(); } else { glDrawArrays(GL_LINE_LOOP, 0, 4); GLERRORCHECK(); } }
void Render_OpenGL31::BindTexture(PGE_Texture *texture) { setRenderTexture(texture->texture); setAlphaBlending(); }