void ninePatch::draw(float left, float right, float bottom, float top) { int currenttexture; glGetIntegerv(GL_TEXTURE_BINDING_2D, ¤ttexture); if (currenttexture != texture) glBindTexture(GL_TEXTURE_2D, texture); texturedQuad(left, left + soffsleft, bottom, bottom - soffsbottom, 0, toffsleft, 0, toffsbottom); texturedQuad(left + soffsleft, right - soffsright, bottom, bottom - soffsbottom, toffsleft, toffsright, 0, toffsbottom); texturedQuad(right - soffsright, right, bottom, bottom - soffsbottom, toffsright, 1.0, 0, toffsbottom); texturedQuad(left, left + soffsleft, bottom - soffsbottom, top + soffstop, 0, toffsleft, toffsbottom, toffstop); texturedQuad(left + soffsleft, right - soffsright, bottom - soffsbottom, top + soffstop, toffsleft, toffsright, toffsbottom, toffstop); texturedQuad(right - soffsright, right, bottom - soffsbottom, top + soffstop, toffsright, 1.0, toffsbottom, toffstop); texturedQuad(left, left + soffsleft, top + soffstop, top, 0, toffsleft, toffstop, 1); texturedQuad(left + soffsleft, right - soffsright, top + soffstop, top, toffsleft, toffsright, toffstop, 1); texturedQuad(right - soffsright, right, top + soffstop, top, toffsright, 1.0, toffstop, 1); }
void FakeSSSPass::render(ofFbo& readFbo, ofFbo& writeFbo, ofTexture& depthTex) { writeFbo.begin(); shader.begin(); shader.setUniformTexture("Texture", readFbo.getTextureReference(), 0); shader.setUniform3f("LightPosition", lightPosition.x, lightPosition.y, lightPosition.z); shader.setUniform1f("MaterialThickness", materialThickness); shader.setUniform3f("ExtinctionCoefficient", extinctionCoefficient.x, extinctionCoefficient.y, extinctionCoefficient.z); shader.setUniform4f("LightColor", lightColor.x, lightColor.y, lightColor.z, 1.0); shader.setUniform4f("BaseColor", baseColor.x, baseColor.y, baseColor.z, 1.0); shader.setUniform4f("SpecColor", specularColor.y, specularColor.y, specularColor.z, 1.0 ); shader.setUniform1f("SpecPower", specular); shader.setUniform1f("RimScalar", rimScale); shader.setUniform1f("AttenuationOffset", attenuationOffset); texturedQuad(0, 0, writeFbo.getWidth(), writeFbo.getHeight()); shader.end(); writeFbo.end(); }
void GpuParticles::update() { fbos[1 - currentReadFbo].begin(false); glPushAttrib(GL_ENABLE_BIT); // we set up no camera model and ignore the modelview and projection matrices // in the vertex shader, we make a viewport large enought to ensure the shader // is executed for each pixel glViewport(0, 0, width, height); glDisable(GL_BLEND); ofSetColor(255, 255, 255); fbos[1 - currentReadFbo].activateAllDrawBuffers(); updateShader.begin(); ofNotifyEvent(updateEvent, updateShader, this); setUniforms(updateShader); texturedQuad(-1, -1, 2, 2, width, height); updateShader.end(); glPopAttrib(); fbos[1 - currentReadFbo].end(); currentReadFbo = 1 - currentReadFbo; }
void Animal::switchToDead() { stopMoving(); texturedQuad(_dead); _isDead = true; }
void workshopScene::render(sceneInfo &info) { glMatrixMode( GL_PROJECTION ); glLoadIdentity(); glFrustum((-1.f * info.width) / info.height, (1.f * info.width) / info.height, -1.f, 1.f, 1.f, 1000.f); glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); btQuaternion invrotate = camera.orientation.inverse(); glRotatef(invrotate.getAngle() * RAD_TO_DEGREES, invrotate.getAxis().getX(), invrotate.getAxis().getY(), invrotate.getAxis().getZ()); glTranslatef(-camera.position.getX(), -camera.position.getY(), -camera.position.getZ()); GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 }; GLfloat mat_shininess[] = { 50.0 }; GLfloat light_position[] = { 1.2, 1.1, 1.0, 0.0 }; glShadeModel (GL_SMOOTH); glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess); glLightfv(GL_LIGHT0, GL_POSITION, light_position); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); glEnable(GL_COLOR_MATERIAL); glColor3f(1.f, 1.f, 1.f); glEnable(GL_CULL_FACE); gWorld->render(); if (axisHasFirst) { glColor3f(1, 0, 0); btTransform trans = ((btRigidBody*)(axisResult.m_collisionObject))->getCenterOfMassTransform(); btVector3 start = trans * axisFirstPivot; btVector3 end = trans * (axisFirstPivot + axisFirstNormal * 0.5); glBegin(GL_LINES); glVertex3f(start.getX(), start.getY(), start.getZ()); glVertex3f(end.getX(), end.getY(), end.getZ()); glEnd(); } glPushAttrib(GL_ENABLE_BIT); glDisable(GL_CULL_FACE); glDisable(GL_LIGHTING); glDisable(GL_DEPTH_TEST); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0.f, info.width, info.height, 0.f, -1.f, 1.f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glEnable(GL_TEXTURE_2D); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glColor3f(1.f, 1.f, 1.f); panel.draw(0, UI_SIZE + 16, info.height, 0); glPushAttrib(GL_SCISSOR_BIT); glEnable(GL_SCISSOR_TEST); glScissor(8, 8, UI_SIZE, info.height - 16); for (unsigned int i = 0; i < thumbnails.size(); i++) { int basex = 8; int basey = 8 + (UI_SIZE + 8) * i; if (i == selectedItem) glColor3f(1.f, 1.f, 0.5f); else glColor3f(1.f, 1.f, 1.f); button.draw(basex, basex + UI_SIZE, basey + UI_SIZE, basey); glBindTexture(GL_TEXTURE_2D, thumbnails[i]); texturedQuad(basex + 8, basex + (UI_SIZE - 8), basey + (UI_SIZE - 8), basey + 8); } glPopAttrib(); panel.draw(UI_SIZE + 16, info.width, info.height, info.height - UI_SMALL - 16); glColor3f(1.f, 1.f, 1.f); for (unsigned int i = 0; i < tooltextures.size(); i++) { int basex = UI_SIZE + 16 + 8 + (UI_SMALL + 8) * i; int basey = info.height - 8 - UI_SMALL; if (i == selectedTool) glColor3f(1.f, 1.f, 0.5f); else glColor3f(1.f, 1.f, 1.f); button.draw(basex, basex + UI_SMALL, basey + UI_SMALL, basey); glBindTexture(GL_TEXTURE_2D, tooltextures[i]); texturedQuad(basex + 8, basex + UI_SMALL - 8, basey + UI_SMALL - 8, basey + 8); } glColor3f(1.f, 1.f, 1.f); if (info.captureMouse) { if (mousevelx * mousevelx + mousevely * mousevely < 1.f) glColor3f(1, 0, 0); glBindTexture(GL_TEXTURE_2D, cursor); texturedQuad(cursorx, cursorx + 20, cursory + 20, cursory); glBindTexture(GL_TEXTURE_2D, 0); glBegin(GL_LINES); glVertex2f(cursorx, cursory); glVertex2f(cursorx + mousevelx, cursory + mousevely); glEnd(); } if (mousevelx * mousevelx + mousevely * mousevely < 1.f && mouseRayCallback.hasHit()) showBubble(cursorx, cursory, gWorld->findObj((btRigidBody*)mouseRayCallback.m_collisionObject)->tag); /*glBindTexture(GL_TEXTURE_2D, font); info.keybuffer.push_back(0); print(100, 100, &info.keybuffer[0]); glBindTexture(GL_TEXTURE_2D, stbfont); texturedQuad(100, 200, 500, 400); stbprint(100, 300, &info.keybuffer[0]); info.keybuffer.erase(info.keybuffer.end() - 1);*/ glPopAttrib(); }
void workshopScene::renderChar(int x, int y, char c) { texturedQuad(x, x + 8, y, y + 8, 0.f, 1.f, 1.f - c / 128.f, 1.f - (c + 1) / 128.f); }