void RenderManagerGL2D::drawBlob(const Vector2& pos, const Color& col) { glEnable(GL_TEXTURE_2D); glEnable(GL_ALPHA_TEST); glDisable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE); //glLoadIdentity(); //glTranslatef(pos.x, pos.y, 0.6); glBindTexture(mBlob[0]); glColor3ubv(col.val); drawQuad2(pos.x, pos.y, 128.0, 128.0); glEnable(GL_BLEND); glColor4f(1.0, 1.0, 1.0, 1.0); glBindTexture(mBlobSpecular[0]); drawQuad2(pos.x, pos.y, 128.0, 128.0); glDisable(GL_BLEND); }
void drawTileBox(reVec3 a, reVec3 b) { glDisable(GL_CULL_FACE); drawQuad2(reVec3(a[0], a[1], a[2]), reVec3(a[0], b[1], b[2])); drawQuad2(reVec3(a[0], a[1], a[2]), reVec3(b[0], a[1], b[2])); drawQuad2(reVec3(a[0], a[1], a[2]), reVec3(b[0], a[1], a[2])); drawQuad2(reVec3(b[0], b[1], b[2]), reVec3(b[0], a[1], a[2])); drawQuad2(reVec3(b[0], b[1], b[2]), reVec3(a[0], b[1], a[2])); drawQuad2(reVec3(b[0], b[1], b[2]), reVec3(a[0], b[1], b[2])); glEnable(GL_CULL_FACE); }
void RenderManagerGL2D::drawImage(const std::string& filename, Vector2 position) { glEnable(GL_TEXTURE_2D); glEnable(GL_ALPHA_TEST); glDisable(GL_BLEND); BufferedImage* imageBuffer = mImageMap[filename]; if (!imageBuffer) { imageBuffer = new BufferedImage; SDL_Surface* newSurface = loadSurface(filename); imageBuffer->w = getNextPOT(newSurface->w); imageBuffer->h = getNextPOT(newSurface->h); imageBuffer->glHandle = loadTexture(newSurface, false); mImageMap[filename] = imageBuffer; } glColor4f(1.0, 1.0, 1.0, 1.0); glDisable(GL_BLEND); //glLoadIdentity(); //glTranslatef(position.x , position.y, 0.0); glBindTexture(imageBuffer->glHandle); drawQuad2(position.x, position.y, imageBuffer->w, imageBuffer->h); }
void RenderManagerGL2D::draw() { glClear(GL_DEPTH_BUFFER_BIT); if (!mDrawGame) return; // Background glDisable(GL_ALPHA_TEST); glColor4f(1.0, 1.0, 1.0, 1.0); glBindTexture(mBackground); glLoadIdentity(); drawQuad2(400.0, 300.0, 1024.0, 1024.0); if(mShowShadow) { // Generic shadow settings glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); // Blob shadows Vector2 pos; pos = blobShadowPosition(mLeftBlobPosition); glColor4ub(mLeftBlobColor.r, mLeftBlobColor.g, mLeftBlobColor.b, 128); glBindTexture(mBlobShadow[int(mLeftBlobAnimationState) % 5]); drawQuad2(pos.x, pos.y, 128.0, 32.0); pos = blobShadowPosition(mRightBlobPosition); glColor4ub(mRightBlobColor.r, mRightBlobColor.g, mRightBlobColor.b, 128); glBindTexture(mBlobShadow[int(mRightBlobAnimationState) % 5]); drawQuad2(pos.x, pos.y, 128.0, 32.0); // Ball shadow pos = ballShadowPosition(mBallPosition); glColor4f(1.0, 1.0, 1.0, 0.5); glBindTexture(mBallShadow); drawQuad2(pos.x, pos.y, 128.0, 32.0); glDisable(GL_BLEND); } glEnable(GL_ALPHA_TEST); // General object settings glBlendFunc(GL_SRC_ALPHA, GL_ONE); // The Ball glColor4f(1.0, 1.0, 1.0, 1.0); glBindTexture(mBall[int(mBallRotation / M_PI / 2 * 16) % 16]); /* float opacity = 0.0; for (std::list<Vector2>::iterator iter = mLastBallStates.begin(); iter != mLastBallStates.end(); ++iter) { // glColor4f(1.0 / MotionBlurIterations, // 1.0 / MotionBlurIterations, 1.0 / MotionBlurIterations, 1.0 - opacity); glColor4f(1.0, 1.0, 1.0, opacity); Vector2& ballPosition = *iter; */ drawQuad2(mBallPosition.x, mBallPosition.y, 64.0, 64.0); /* opacity += 0.1; } if (mLastBallStates.size() > MotionBlurIterations) mLastBallStates.pop_back(); glDisable(GL_BLEND); */ // blob normal // left blob glBindTexture(mBlob[int(mLeftBlobAnimationState) % 5]); glColor3ubv(mLeftBlobColor.val); drawQuad2(mLeftBlobPosition.x, mLeftBlobPosition.y, 128.0, 128.0); // right blob glBindTexture(mBlob[int(mRightBlobAnimationState) % 5]); glColor3ubv(mRightBlobColor.val); drawQuad2(mRightBlobPosition.x, mRightBlobPosition.y, 128.0, 128.0); // blob specular glEnable(GL_BLEND); glColor4f(1.0, 1.0, 1.0, 1.0); // left blob glBindTexture(mBlobSpecular[int(mLeftBlobAnimationState) % 5]); drawQuad2(mLeftBlobPosition.x, mLeftBlobPosition.y, 128.0, 128.0); // right blob glBindTexture(mBlobSpecular[int(mRightBlobAnimationState) % 5]); drawQuad2(mRightBlobPosition.x, mRightBlobPosition.y, 128.0, 128.0); glDisable(GL_BLEND); // Ball marker glDisable(GL_ALPHA_TEST); glDisable(GL_TEXTURE_2D); GLubyte markerColor = SDL_GetTicks() % 1000 >= 500 ? 255 : 0; glColor3ub(markerColor, markerColor, markerColor); drawQuad2(mBallPosition.x, 7.5, 5.0, 5.0); // Mouse marker // Position relativ zu BallMarker drawQuad2(mMouseMarkerPosition, 592.5, 5.0, 5.0); glEnable(GL_TEXTURE_2D); glEnable(GL_ALPHA_TEST); // Scores char textBuffer[64]; snprintf(textBuffer, 8, mLeftPlayerWarning ? "%02d!" : "%02d", mLeftPlayerScore); drawText(textBuffer, Vector2(24, 24), false); snprintf(textBuffer, 8, mRightPlayerWarning ? "%02d!" : "%02d", mRightPlayerScore); drawText(textBuffer, Vector2(728, 24), false); // Drawing the names drawText(mLeftPlayerName, Vector2(12, 550), false); drawText(mRightPlayerName, Vector2(788-(24*mRightPlayerName.length()), 550), false); // Drawing the clock drawText(mTime, Vector2(400 - mTime.length()*12, 24), false); }