//------------------------------------------------------------------------------- // @ Player::Render() //------------------------------------------------------------------------------- // Render stuff //------------------------------------------------------------------------------- void Player::Render() { // build 4x4 matrix IvMatrix44 transform(mRotate); transform(0,0) *= mScale; transform(1,0) *= mScale; transform(2,0) *= mScale; transform(0,1) *= mScale; transform(1,1) *= mScale; transform(2,1) *= mScale; transform(0,2) *= mScale; transform(1,2) *= mScale; transform(2,2) *= mScale; transform(0,3) = mTranslate.x; transform(1,3) = mTranslate.y; transform(2,3) = mTranslate.z; IvSetWorldMatrix(transform); // disable blending SetBlendFuncs(kNoneBlendMode); // set base texture mTextureUniform->SetValue(mBaseTexture); // draw inner, opaque cylinder DrawCylinder(); // push transform with larger scale for outside cylinder IvMatrix44 transformOutside(mRotate); float outerScale = mScale * 1.2f; transformOutside(0,0) *= outerScale; transformOutside(1,0) *= outerScale; transformOutside(2,0) *= outerScale; transformOutside(0,1) *= outerScale; transformOutside(1,1) *= outerScale; transformOutside(2,1) *= outerScale; transformOutside(0,2) *= outerScale; transformOutside(1,2) *= outerScale; transformOutside(2,2) *= outerScale; transformOutside(0,3) = mTranslate.x; transformOutside(1,3) = mTranslate.y; transformOutside(2,3) = mTranslate.z; IvSetWorldMatrix(transformOutside); SetBlendFuncs(mBlendMode); // set blending texture mTextureUniform->SetValue(mBlendTextures[mCurrentBlendTexIndex]); // draw larger, blended cylinder DrawCylinder(); } // End of Player::Render()
void Render() { float alpha = GetTickCount()/10.0f; glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); glColor3f(1,1,1); DrawLight(); DrawGround(); DrawCylinder(alpha, true); DrawCylinder(alpha, false); }
static void DrawScene(void) { int i; glEnable(GL_LIGHTING); for (i = 0; i < NUM_CYLINDERS; i++) { DrawCylinder(&Cylinders[i]); } glDisable(GL_LIGHTING); if (1) DrawLightSource(); /* ground plane */ if (1) { GLfloat k = 10.0, g = GroundY; CheckError(__LINE__); glPushMatrix(); glColor3fv(GroundColor); glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, GroundColor); glNormal3f(0, 1, 0); glBegin(GL_POLYGON); glVertex3f(-k, g, -k); glVertex3f( k, g, -k); glVertex3f( k, g, k); glVertex3f(-k, g, k); glEnd(); glPopMatrix(); } CheckError(__LINE__); }
void Handle::draw(const Vector3 &color) const { for (unsigned int i = 0; i < players.size(); i++) { players[i]->draw(color); } for (unsigned int i = 0; i < balls.size(); i++) { balls[i]->draw(Vector3(0,0,0)); } glColor3fv(color.toArray()); DrawCylinder(radius,ROD_LENGTH,centerofmass,rotationaxis.getOrentiation()); DrawCylinder(radius/2,ROD_LENGTH,centerofmass,rotationaxis.getOrentiation()); }
void QSegmentWidget::clearSegments(int cyl, const SegmentList &s) { Q_ASSERT(cyl >= 0 && cyl < m_cylinders.size()); Cylinder &cylinder = m_cylinders[cyl]; DrawCylinder(cylinder, s, true); update(); }
void CPFA_qt_user_functions::DrawOnRobot(CFootBotEntity& entity) { CPFA_controller& c = dynamic_cast<CPFA_controller&>(entity.GetControllableEntity().GetController()); if(c.IsHoldingFood() == true) { DrawCylinder(CVector3(0.0, 0.0, 0.3), CQuaternion(), loopFunctions.FoodRadius, 0.025, CColor::BLACK); } if(loopFunctions.DrawIDs == 1) { /* Disable lighting, so it does not interfere with the chosen text color */ glDisable(GL_LIGHTING); /* Disable face culling to be sure the text is visible from anywhere */ glDisable(GL_CULL_FACE); /* Set the text color */ CColor cColor(CColor::BLACK); glColor3ub(cColor.GetRed(), cColor.GetGreen(), cColor.GetBlue()); /* The position of the text is expressed wrt the reference point of the footbot * For a foot-bot, the reference point is the center of its base. * See also the description in * $ argos3 -q foot-bot */ // Disable for now //GetOpenGLWidget().renderText(0.0, 0.0, 0.5, // position // entity.GetId().c_str()); // text /* Restore face culling */ glEnable(GL_CULL_FACE); /* Restore lighting */ glEnable(GL_LIGHTING); } }
// Called to draw scene objects void DrawModels(void) { GLint uniformLoc = glGetUniformLocation(progObj[whichShader], "sampler0"); if (uniformLoc != -1) { glUniform1i(uniformLoc, 0); } uniformLoc = glGetUniformLocation(progObj[whichShader], "lightPos0"); if (uniformLoc != -1) { glUniform3fv(uniformLoc, 1, lightPos0); } // Draw box to demonstrate low-geometry, high-detail glColor3f(0.8f, 0.5f, 0.3f); switch (whichShape) { case CYLINDER: DrawCylinder(25.0f, 70.0f, 25, 20.0f, 10.0f); break; case TORUS: DrawTorus(20.0f, 15.0f, 50, 25, 40.0f, 12.0f); break; default: DrawBox(70.0f, 10.0f); break; } }
void CPFA_qt_user_functions::DrawPheromones() { Real x, y, weight; vector<CVector2> trail; CColor trailColor = CColor::GREEN, pColor = CColor::GREEN; for(size_t i = 0; i < loopFunctions.PheromoneList.size(); i++) { x = loopFunctions.PheromoneList[i].GetLocation().GetX(); y = loopFunctions.PheromoneList[i].GetLocation().GetY(); if(loopFunctions.DrawTrails == 1) { trail = loopFunctions.PheromoneList[i].GetTrail(); weight = loopFunctions.PheromoneList[i].GetWeight(); if(weight > 0.25 && weight <= 1.0) // [ 100.0% , 25.0% ) pColor = trailColor = CColor::GREEN; else if(weight > 0.05 && weight <= 0.25) // [ 25.0% , 5.0% ) pColor = trailColor = CColor::YELLOW; else // [ 5.0% , 0.0% ] pColor = trailColor = CColor::RED; CRay3 ray; size_t j = 0; for(j = 1; j < trail.size(); j++) { ray = CRay3(CVector3(trail[j - 1].GetX(), trail[j - 1].GetY(), 0.01), CVector3(trail[j].GetX(), trail[j].GetY(), 0.01)); DrawRay(ray, trailColor, 1.0); } DrawCylinder(CVector3(x, y, 0.0), CQuaternion(), loopFunctions.FoodRadius, 0.025, pColor); } else { weight = loopFunctions.PheromoneList[i].GetWeight(); if(weight > 0.25 && weight <= 1.0) // [ 100.0% , 25.0% ) pColor = CColor::GREEN; else if(weight > 0.05 && weight <= 0.25) // [ 25.0% , 5.0% ) pColor = CColor::YELLOW; else // [ 5.0% , 0.0% ] pColor = CColor::RED; DrawCylinder(CVector3(x, y, 0.0), CQuaternion(), loopFunctions.FoodRadius, 0.025, pColor); } } }
void DrawMaennchen(float angle) { //float overallScaleFactor = 0.2 * cos(GL_PI / 200 * angle) + 1; float jumpFactor = abs(cos(GL_PI/10 * angle)); /** * Rumpf zeichnen **/ modelViewMatrix.PushMatrix(); modelViewMatrix.Rotate(angle, 0, -1, 0); // generelle Verschiebung aus dem Mittelpunkt heraus modelViewMatrix.Translate(200.0f, 0.0f, 0.0f); // Verschiebung fuer Huepfbahn modelViewMatrix.Translate(0.0f, 30 * jumpFactor, 0); //modelViewMatrix.Scale(overallScaleFactor, overallScaleFactor, overallScaleFactor); modelViewMatrix.PushMatrix(); modelViewMatrix.Scale(0.9, 1.0, 0.7); shaderManager.UseStockShader(GLT_SHADER_FLAT_ATTRIBUTES, transformPipeline.GetModelViewProjectionMatrix()); DrawCylinder(); modelViewMatrix.PopMatrix(); // Hals modelViewMatrix.PushMatrix(); modelViewMatrix.Translate(0.0f, 55.0f, 0.0f); modelViewMatrix.PushMatrix(); modelViewMatrix.Scale(0.25, 0.15, 0.25); shaderManager.UseStockShader(GLT_SHADER_FLAT_ATTRIBUTES, transformPipeline.GetModelViewProjectionMatrix()); DrawCylinder(); modelViewMatrix.PopMatrix(); // Kopf modelViewMatrix.PushMatrix(); modelViewMatrix.Translate(0.0f, 40.0f, 0.0f); modelViewMatrix.Scale(0.72, 0.72, 0.72); shaderManager.UseStockShader(GLT_SHADER_FLAT_ATTRIBUTES, transformPipeline.GetModelViewProjectionMatrix()); DrawSphere(); modelViewMatrix.PopMatrix(); modelViewMatrix.PopMatrix(); // Giedmaßen zeichnen - abhaengig vom Rumpf! DrawLimbs(angle); modelViewMatrix.PopMatrix(); }
void DrawCylinder(int n, float rota, float width) { glPushMatrix(); glColor3f(rval/n, gval/n, bval/n); glRotatef(rota, 0.0, 1.0, 0.0); gluCylinder(cylinder, width, width * wfactor, n * 0.5, cylquality, 1); glTranslatef(0.0, 0.0, -n * 0.5); gluCylinder(cylinder, width * wfactor, width, n * 0.5, cylquality, 1); if(n > 1) { float r = rota * rotfactor; glRotatef(90.0, 1.0, 0.0, 0.0); DrawCylinder(n - 1, r, width * wfactor); glTranslatef(0.0, n, 0.0); DrawCylinder(n - 1, -r, width * wfactor); } glPopMatrix(); }
void CChildView::OnGLDraw(CDC *pDC) { GLfloat gray = 0.3f; glClearColor(gray, gray, gray, 0.0f) ; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // // Set up the camera // int wid, hit; GetSize(wid, hit); m_camera.Apply(wid, hit); // // Some standard parameters // // Enable depth test glEnable(GL_DEPTH_TEST); // Cull backfacing polygons glCullFace(GL_BACK); glEnable(GL_CULL_FACE); // Enable lighting glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); GLfloat lightpos[] = {0.5, 2.0, 1.0, 0}; glLightfv(GL_LIGHT0, GL_POSITION, lightpos); glEnable(GL_LIGHT1); GLfloat secondlightcolor[] = {0.2f, 0.8f, 0.2f, 1.0f}; GLfloat secondlightpos[] = {-5.0f, -5.0f, 5.0f, 1.0f}; glLightfv(GL_LIGHT1, GL_DIFFUSE, secondlightcolor); glLightfv(GL_LIGHT1, GL_SPECULAR, secondlightcolor); glLightfv(GL_LIGHT1, GL_POSITION, secondlightpos); // Enable or disable the wireframe mode glPolygonMode(GL_FRONT, m_wireframe ? GL_LINE : GL_FILL); glPushMatrix(); DrawChisel(); glPopMatrix(); glPushMatrix(); DrawCylinder(); glPopMatrix(); glPushMatrix(); glTranslated(-10,-7, -15); DrawEnvironment(); glPopMatrix(); glFlush(); }
void CPFA_qt_user_functions::DrawFidelity() { Real x, y; for(size_t i = 0; i < loopFunctions.FidelityList.size(); i++) { x = loopFunctions.FidelityList[i].GetX(); y = loopFunctions.FidelityList[i].GetY(); DrawCylinder(CVector3(x, y, 0.0), CQuaternion(), loopFunctions.FoodRadius, 0.025, CColor::CYAN); } }
void BulletOpenGLApplication::DrawShape(btScalar* transform, const btCollisionShape* pShape, const btVector3 &color) { // set the color glColor3f(color.x(), color.y(), color.z()); // push the matrix stack glPushMatrix(); glMultMatrixf(transform); // make a different draw call based on the object type switch(pShape->getShapeType()) { // an internal enum used by Bullet for boxes case BOX_SHAPE_PROXYTYPE: { // assume the shape is a box, and typecast it const btBoxShape* box = static_cast<const btBoxShape*>(pShape); // get the 'halfSize' of the box btVector3 halfSize = box->getHalfExtentsWithMargin(); // draw the box DrawBox(halfSize); break; } /*ADD*/ case SPHERE_SHAPE_PROXYTYPE: /*ADD*/ { /*ADD*/ // assume the shape is a sphere and typecast it /*ADD*/ const btSphereShape* sphere = static_cast<const btSphereShape*>(pShape); /*ADD*/ // get the sphere's size from the shape /*ADD*/ float radius = sphere->getMargin(); /*ADD*/ // draw the sphere /*ADD*/ DrawSphere(radius); /*ADD*/ break; /*ADD*/ } /*ADD*/ /*ADD*/ case CYLINDER_SHAPE_PROXYTYPE: /*ADD*/ { /*ADD*/ // assume the object is a cylinder /*ADD*/ const btCylinderShape* pCylinder = static_cast<const btCylinderShape*>(pShape); /*ADD*/ // get the relevant data /*ADD*/ float radius = pCylinder->getRadius(); /*ADD*/ float halfHeight = pCylinder->getHalfExtentsWithMargin()[1]; /*ADD*/ // draw the cylinder /*ADD*/ DrawCylinder(radius,halfHeight); /*ADD*/ /*ADD*/ break; /*ADD*/ } default: // unsupported type break; } // pop the stack glPopMatrix(); }
//Renders, scales, rotates and translates the cylinder void BaseCylinder::Render() { // Model matrix : an identity matrix (model will be at the origin) glm::mat4 model = glm::mat4(1.0f); model = glm::translate(model, glm::vec3(position));//Translate to the cylinder's position model = glm::rotate(model, rotation_angle, glm::vec3(0, 1, 0));//Rotate the cylinder model = glm::scale(model, scale); glUniformMatrix4fv(model_id, 1, GL_FALSE, &model[0][0]); DrawCylinder(); rotation_angle += rotation_speed; }
void DisplayWindow() { mat4 m; glClearColor(0.4, 0.4, 0.2, 1); glClear(GL_COLOR_BUFFER_BIT+GL_DEPTH_BUFFER_BIT); m = Mult(projectionMatrix, modelViewMatrix); glUniformMatrix4fv(glGetUniformLocation(g_shader, "matrix"), 1, GL_TRUE, m.m); DrawCylinder(); glutSwapBuffers(); };
void DrawScene(HWND hwnd, HDC dc, int ticks) { PAINTSTRUCT ps; dc = BeginPaint(hwnd, &ps); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glRotatef(ticks * 0.01, 0.0, 1.0, -0.5); angle += ticks * 0.01; colorh += ticks * 0.003; if (colorh > 360.0) colorh -= 360.0; HLStoRGB(colorh, 1.0, 0.7, &rval, &gval, &bval); DrawCylinder(lvls, angle, 0.2); SwapBuffers(dc); EndPaint(hwnd, &ps); }
// draw function for adding graphics to a foot-bot void iAnt_qt_user_functions::DrawFood(CFootBotEntity& entity) { iAnt_controller& c = dynamic_cast<iAnt_controller&> (entity.GetControllableEntity().GetController()); UpdateDrawInWorldData(c); if(c.IsHoldingFood() == true) { //#ifdef __APPLE__ //Edit here for drawing trails DrawCylinder(CVector3(0.0f, 0.0f, 0.3f), CQuaternion(), 0.05f, 0.025f, CColor::BLACK); //#else // DrawCylinder(0.05f, 0.025f, CVector3(0.0f, 0.0f, 0.3f), CColor::BLACK); //#endif } }
void DrawBaeumchen() { // Boden modelViewMatrix.PushMatrix(); modelViewMatrix.PushMatrix(); modelViewMatrix.Translate(0, -25, 0); modelViewMatrix.Scale(20, -0.01, 20); shaderManager.UseStockShader(GLT_SHADER_FLAT_ATTRIBUTES, transformPipeline.GetModelViewProjectionMatrix()); modelViewMatrix.PopMatrix(); DrawCube(); // Baumstamm modelViewMatrix.PushMatrix(); modelViewMatrix.Translate(0, 0.0, 0); modelViewMatrix.PushMatrix(); modelViewMatrix.Scale(0.3, 0.5, 0.3); shaderManager.UseStockShader(GLT_SHADER_FLAT_ATTRIBUTES, transformPipeline.GetModelViewProjectionMatrix()); modelViewMatrix.PopMatrix(); DrawCylinder(); //unterster Kegel modelViewMatrix.PushMatrix(); modelViewMatrix.Translate(0, 25.0, 0); modelViewMatrix.Scale(1.5, 1.5, 1.5); shaderManager.UseStockShader(GLT_SHADER_FLAT_ATTRIBUTES, transformPipeline.GetModelViewProjectionMatrix()); DrawCone(); // mittlerer Kegel modelViewMatrix.PushMatrix(); modelViewMatrix.Translate(0, 40.0, 0); modelViewMatrix.Scale(0.75, 0.75, 0.75); shaderManager.UseStockShader(GLT_SHADER_FLAT_ATTRIBUTES, transformPipeline.GetModelViewProjectionMatrix()); DrawCone(); // Spitze modelViewMatrix.PushMatrix(); modelViewMatrix.Translate(0, 50.0, 0); modelViewMatrix.Scale(0.75, 0.75, 0.75); shaderManager.UseStockShader(GLT_SHADER_FLAT_ATTRIBUTES, transformPipeline.GetModelViewProjectionMatrix()); DrawCone(); modelViewMatrix.PopMatrix(); modelViewMatrix.PopMatrix(); modelViewMatrix.PopMatrix(); modelViewMatrix.PopMatrix(); modelViewMatrix.PopMatrix(); }
//Renders and rotates a planet support pole void PlanetSupportPole::Render() { // Model matrix : an identity matrix (model will be at the origin) glm::mat4 model = glm::mat4(1.0f); model = glm::rotate(model, rotation, glm::vec3(0, 1, 0));//Rotates the pole around the origin model = glm::translate(model, position); if (is_horizontal) model = glm::rotate(model, 90.f, glm::vec3(1,0,0));//if it's a horizontal pole rotate 90 degrees, default is vertical model = glm::scale(model, scale); glUniformMatrix4fv(model_id, 1, GL_FALSE, &model[0][0]); DrawCylinder(); rotation += rotation_speed; }
void dSceneRender::DrawArrow (int segments, dFloat radius, dFloat heigh, const dVector& stemColor, const dVector& tipColor) { dMatrix matrix (dGetIdentityMatrix()); matrix.m_posit.m_x = heigh / 2.0f; PushMatrix(matrix); SetColor(stemColor); DrawCylinder(segments, radius, heigh); dFloat tipLength = heigh / 3.0f; matrix.m_posit.m_x = (heigh + tipLength) / 2.0f; PushMatrix(matrix); SetColor(tipColor); DrawCone(segments, radius * 2.0f, tipLength); PopMatrix(); PopMatrix(); }
// Called to draw scene objects void DrawModels(void) { M3DVector3f lightPosEye; M3DMatrix44f mv, mv2; M3DMatrix44f mv2IT_4x4; GLfloat mv2IT_3x3[9]; GLint i; // Transform light position to eye space glGetFloatv(GL_MODELVIEW_MATRIX, mv); m3dTransformVector3(lightPosEye, lightPos, mv); glUniform3fv(lightPosLoc, 1, lightPosEye); // Setup modelview matrices for upper arm glPushMatrix(); glRotatef(elbowBend, 0.0f, 0.0f, 1.0f); glTranslatef(-50.0f, 0.0f, 0.0f); glGetFloatv(GL_MODELVIEW_MATRIX, mv2); glPopMatrix(); glTranslatef(-50.0f, 0.0f, 0.0f); glUniformMatrix4fv(mv2Loc, 1, GL_FALSE, mv2); m3dInvertMatrix44(mv2IT_4x4, mv2); // Take upper left 3x3 for 2nd normal matrix for (i = 0; i < 9; i++) { mv2IT_3x3[i] = mv2IT_4x4[((i/3)*4)+(i%3)]; } glUniformMatrix3fv(mv2ITLoc, 1, GL_TRUE, mv2IT_3x3); // Draw upper arm cylinder glColor3f(0.0f, 0.0f, 0.90f); // Blue // 50 long, 10 shoulder, 9 elbow, with weights applied to second half DrawCylinder(50.0f, 15.0f, 9.0f, 1.0f, 0.5f); // Setup modelview matrices for forearm glTranslatef(50.0f, 0.0f, 0.0f); glPushMatrix(); glGetFloatv(GL_MODELVIEW_MATRIX, mv2); glPopMatrix(); glRotatef(elbowBend, 0.0f, 0.0f, 1.0f); glUniformMatrix4fv(mv2Loc, 1, GL_FALSE, mv2); m3dInvertMatrix44(mv2IT_4x4, mv2); // Take upper left 3x3 for 2nd normal matrix for (i = 0; i < 9; i++) { mv2IT_3x3[i] = mv2IT_4x4[((i/3)*4)+(i%3)]; } glUniformMatrix3fv(mv2ITLoc, 1, GL_TRUE, mv2IT_3x3); // Draw forearm cylinder glColor3f(0.9f, 0.0f, 0.0f); // Red // 40 long, 9 elbow, 5 wrist, with weights applied to first half DrawCylinder(40.0f, 9.0f, 5.0f, 0.5f, 1.0f); }
int main() { // Initialization //-------------------------------------------------------------------------------------- int screenWidth = 800; int screenHeight = 450; InitWindow(screenWidth, screenHeight, "raylib [models] example - geometric shapes"); // Define the camera to look into our 3d world Camera camera = {{ 0.0f, 10.0f, 10.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, FOVY_PERSPECTIVE, CAMERA_PERSPECTIVE }; SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- // Main game loop while (!WindowShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- if (IsKeyPressed(KEY_SPACE)) { if (camera.type == CAMERA_PERSPECTIVE) { camera.fovy = WIDTH_ORTHOGRAPHIC; camera.type = CAMERA_ORTHOGRAPHIC; } else { camera.fovy = FOVY_PERSPECTIVE; camera.type = CAMERA_PERSPECTIVE; } } //---------------------------------------------------------------------------------- // Draw //---------------------------------------------------------------------------------- BeginDrawing(); ClearBackground(RAYWHITE); BeginMode3D(camera); DrawCube((Vector3){-4.0f, 0.0f, 2.0f}, 2.0f, 5.0f, 2.0f, RED); DrawCubeWires((Vector3){-4.0f, 0.0f, 2.0f}, 2.0f, 5.0f, 2.0f, GOLD); DrawCubeWires((Vector3){-4.0f, 0.0f, -2.0f}, 3.0f, 6.0f, 2.0f, MAROON); DrawSphere((Vector3){-1.0f, 0.0f, -2.0f}, 1.0f, GREEN); DrawSphereWires((Vector3){1.0f, 0.0f, 2.0f}, 2.0f, 16, 16, LIME); DrawCylinder((Vector3){4.0f, 0.0f, -2.0f}, 1.0f, 2.0f, 3.0f, 4, SKYBLUE); DrawCylinderWires((Vector3){4.0f, 0.0f, -2.0f}, 1.0f, 2.0f, 3.0f, 4, DARKBLUE); DrawCylinderWires((Vector3){4.5f, -1.0f, 2.0f}, 1.0f, 1.0f, 2.0f, 6, BROWN); DrawCylinder((Vector3){1.0f, 0.0f, -4.0f}, 0.0f, 1.5f, 3.0f, 8, GOLD); DrawCylinderWires((Vector3){1.0f, 0.0f, -4.0f}, 0.0f, 1.5f, 3.0f, 8, PINK); DrawGrid(10, 1.0f); // Draw a grid EndMode3D(); DrawText("Press Spacebar to switch camera type", 10, GetScreenHeight() - 30, 20, DARKGRAY); if (camera.type == CAMERA_ORTHOGRAPHIC) DrawText("ORTHOGRAPHIC", 10, 40, 20, BLACK); else if (camera.type == CAMERA_PERSPECTIVE) DrawText("PERSPECTIVE", 10, 40, 20, BLACK); DrawFPS(10, 10); EndDrawing(); //---------------------------------------------------------------------------------- } // De-Initialization //-------------------------------------------------------------------------------------- CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- return 0; }
void HandRenderer::DrawFinger(VistaTransformMatrix matOrigin, float fFingerDiameter, float fLRFactor, float fAng1F, float fAng1A, float fLen1, float fAng2, float fLen2, float fAng3, float fLen3, bool bThumb) { // @todo invert axis here for left/right hand? // rotate locally around X for flexion/extension VistaAxisAndAngle aaaX = VistaAxisAndAngle(VistaVector3D(1,0,0), 0.0); // rotate locally around Z for adduction/abduction VistaAxisAndAngle aaaZ = VistaAxisAndAngle(VistaVector3D(0,0,1), 0.0); VistaTransformMatrix matModel; // final applied transform VistaTransformMatrix matTransform; // auxiliary for // accumulative transforms VistaTransformMatrix matSphereScale; // reused sphere scale matSphereScale.SetToScaleMatrix(fFingerDiameter); // start at first joint matModel = matOrigin * matSphereScale; if(!bThumb) { DrawSphere(matModel); } else { matOrigin *= VistaTransformMatrix( VistaAxisAndAngle(VistaVector3D(0,1,0), Vista::DegToRad(-90*fLRFactor))); } // first joint abduction rotation aaaZ.m_fAngle = Vista::DegToRad(fAng1A*fLRFactor); matTransform = VistaTransformMatrix(aaaZ); matOrigin *= matTransform; // first joint flexion rotation aaaX.m_fAngle = Vista::DegToRad(-fAng1F); matTransform = VistaTransformMatrix(aaaX); matOrigin *= matTransform; // move to center of first segment matTransform.SetToTranslationMatrix( VistaVector3D(0, fLen1/1000.0f/2.0f, 0)); matOrigin *= matTransform; // set scale and draw first segment if(bThumb) { matTransform.SetToScaleMatrix( fFingerDiameter*1.5f, fLen1/1000.0f*1.5f, fFingerDiameter*1.5f); matModel = matOrigin * matTransform; DrawSphere(matModel); } else { matTransform.SetToScaleMatrix( fFingerDiameter, fLen1/1000.0f, fFingerDiameter); matModel = matOrigin * matTransform; DrawCylinder(matModel); } // move to second joint matTransform.SetToTranslationMatrix( VistaVector3D(0, fLen1/1000.0f/2.0f, 0)); matOrigin *= matTransform; // draw scaled sphere matModel = matOrigin * matSphereScale; DrawSphere(matModel); // second joint flexion rotation aaaX.m_fAngle = Vista::DegToRad(-fAng2); matTransform = VistaTransformMatrix(aaaX); matOrigin *= matTransform; // move to center of second segment matTransform.SetToTranslationMatrix( VistaVector3D(0, fLen2/1000.0f/2.0f, 0)); // rotation missing here matOrigin *= matTransform; // set scale and draw second segment cylinder matTransform.SetToScaleMatrix( fFingerDiameter, fLen2/1000.0f, fFingerDiameter); matModel = matOrigin * matTransform; DrawCylinder(matModel); // move to third joint matTransform.SetToTranslationMatrix( VistaVector3D(0, fLen2/1000.0f/2.0f, 0)); // rotation missing here matOrigin *= matTransform; // draw scaled sphere matModel = matOrigin * matSphereScale; DrawSphere(matModel); // third joint flexion rotation aaaX.m_fAngle = Vista::DegToRad(-fAng3); matTransform = VistaTransformMatrix(aaaX); matOrigin *= matTransform; // move to center of third segment matTransform.SetToTranslationMatrix( VistaVector3D(0, fLen3/1000.0f/2.0f, 0)); // rotation missing here matOrigin *= matTransform; // set scale and draw third segment cylinder matTransform.SetToScaleMatrix( fFingerDiameter, fLen3/1000.0f, fFingerDiameter); matModel = matOrigin * matTransform; DrawCylinder(matModel); // move to tip matTransform.SetToTranslationMatrix( VistaVector3D(0, fLen3/1000.0f/2.0f, 0)); // rotation missing here matOrigin *= matTransform; // draw scaled sphere matModel = matOrigin * matSphereScale; DrawSphere(matModel); }
void HandRenderer::DrawHand(HandModel *pModel, HandGeometry *pGeometry) { VistaTransformMatrix matModel; VistaTransformMatrix matTransform; VistaTransformMatrix matOrigin; // these go to extra vis parameter class for model pso yo float fPalmWidth = 0.09; float fPalmBottomRadius = 0.01; float fPalmDiameter = fPalmWidth/2.0f; float fFingerDiameter = fPalmWidth/4.0f; // for now we average the metacarpal lengths for palm height float fPalmHeight = (pGeometry->GetExtent(HandGeometry::I_MC) + pGeometry->GetExtent(HandGeometry::M_MC) + pGeometry->GetExtent(HandGeometry::R_MC) + pGeometry->GetExtent(HandGeometry::L_MC))/4.0f/1000.0f; // @todo get hand geometry straight, palm is too small... fPalmHeight -= fPalmBottomRadius * 2.0f; float fLRFactor = (pModel->GetType() == HandModel::LEFT_HAND) ? -1.0f : 1.0f; // for now we will upload the same model transform matrix in // advance to calling glDrawArrays. If this turns out to be // slow, we might upload all the model matrices at once at the // beginning and use DrawArraysInstanced to look up the // specific matrix in the vertex shader by the instance id. matOrigin.Compose( pModel->GetPosition(), pModel->GetOrientation(), VistaVector3D(1,1,1)); // bottom palm cap matTransform.Compose( VistaVector3D(0, fPalmBottomRadius, 0), VistaQuaternion(), VistaVector3D(fPalmWidth, fPalmBottomRadius*2.0f, fPalmDiameter)); matModel = matOrigin * matTransform; DrawSphere(matModel); // top palm cap matTransform.Compose( VistaVector3D(0, fPalmBottomRadius+fPalmHeight, 0), VistaQuaternion(), VistaVector3D(fPalmWidth, fPalmBottomRadius*2.0f, fPalmDiameter)); matModel = matOrigin * matTransform; DrawSphere(matModel); // palm cylinder matTransform.Compose( VistaVector3D(0, fPalmBottomRadius + fPalmHeight/2.0f, 0), VistaQuaternion(), VistaVector3D(fPalmWidth, fPalmHeight, fPalmDiameter)); matModel = matOrigin * matTransform; DrawCylinder(matModel); // draw the fingers for(int finger = 0 ; finger < 4 ; finger++) { matTransform.SetToTranslationMatrix( VistaVector3D((-fPalmWidth/2.0f + fPalmWidth/8.0f + finger*fPalmWidth/4.0f) * fLRFactor, fPalmBottomRadius + fPalmHeight, 0)); DrawFinger( matOrigin * matTransform, fFingerDiameter, fLRFactor, pModel->GetJointAngle(4*(1+finger)), pModel->GetJointAngle(4*(1+finger)+1), pGeometry->GetExtent(3+4*finger+1), pModel->GetJointAngle(4*(1+finger)+2), pGeometry->GetExtent(3+4*finger+2), pModel->GetJointAngle(4*(1+finger)+3), pGeometry->GetExtent(3+4*finger+3), false); } // draw the thumb matTransform.SetToTranslationMatrix( VistaVector3D((-fPalmWidth/2.0f + fPalmWidth/4.0f)*fLRFactor, fPalmBottomRadius, 0)); DrawFinger( matOrigin * matTransform, fFingerDiameter*1.2, fLRFactor, pModel->GetJointAngle(HandModel::T_CMC_F), pModel->GetJointAngle(HandModel::T_CMC_A), pGeometry->GetExtent(HandGeometry::T_MC), pModel->GetJointAngle(HandModel::T_MCP), pGeometry->GetExtent(HandGeometry::T_PP), pModel->GetJointAngle(HandModel::T_IP), pGeometry->GetExtent(HandGeometry::T_DP), true); matModel = VistaTransformMatrix( 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0); DrawCylinder(matModel); }
// Called to draw scene objects void DrawModels(void) { GLTVector3 lightPosEye; GLTMatrix mv, mv2; // Transform light position to eye space glGetFloatv(GL_MODELVIEW_MATRIX, mv); gltTransformPoint(lightPos, mv, lightPosEye); if (useHighLevel) { glUniform3fvARB(lightPosLoc, 1, lightPosEye); } else { glProgramLocalParameter4fvARB(GL_VERTEX_PROGRAM_ARB, LIGHT_POS_SLOT, lightPosEye); } // Setup modelview matrices for upper arm glPushMatrix(); glRotatef(elbowBend, 0.0f, 0.0f, 1.0f); glTranslatef(-50.0f, 0.0f, 0.0f); glGetFloatv(GL_MODELVIEW_MATRIX, mv2); glPopMatrix(); glTranslatef(-50.0f, 0.0f, 0.0f); if (useHighLevel) { GLTMatrix mv2IT_4x4; GLfloat mv2IT_3x3[9]; GLint i; glUniformMatrix4fvARB(mv2Loc, 1, GL_FALSE, mv2); gltInvertMatrix(mv2, mv2IT_4x4); // Take upper left 3x3 for 2nd normal matrix for (i = 0; i < 9; i++) { mv2IT_3x3[i] = mv2IT_4x4[((i/3)*4)+(i%3)]; } glUniformMatrix3fvARB(mv2ITLoc, 1, GL_TRUE, mv2IT_3x3); } else { glMatrixMode(GL_MATRIX0_ARB); glLoadMatrixf(mv2); glMatrixMode(GL_MODELVIEW); } // Draw upper arm cylinder glColor3f(0.0f, 0.0f, 0.90f); // Blue // 50 long, 10 shoulder, 9 elbow, with weights applied to second half DrawCylinder(50.0f, 15.0f, 9.0f, 1.0f, 0.5f); // Setup modelview matrices for forearm glTranslatef(50.0f, 0.0f, 0.0f); glPushMatrix(); glGetFloatv(GL_MODELVIEW_MATRIX, mv2); glPopMatrix(); glRotatef(elbowBend, 0.0f, 0.0f, 1.0f); if (useHighLevel) { GLTMatrix mv2IT_4x4; GLfloat mv2IT_3x3[9]; GLint i; glUniformMatrix4fvARB(mv2Loc, 1, GL_FALSE, mv2); gltInvertMatrix(mv2, mv2IT_4x4); // Take upper left 3x3 for 2nd normal matrix for (i = 0; i < 9; i++) { mv2IT_3x3[i] = mv2IT_4x4[((i/3)*4)+(i%3)]; } glUniformMatrix3fvARB(mv2ITLoc, 1, GL_TRUE, mv2IT_3x3); } else { glMatrixMode(GL_MATRIX0_ARB); glLoadMatrixf(mv2); glMatrixMode(GL_MODELVIEW); } // Draw forearm cylinder glColor3f(0.9f, 0.0f, 0.0f); // Red // 40 long, 9 elbow, 5 wrist, with weights applied to first half DrawCylinder(40.0f, 9.0f, 5.0f, 0.5f, 1.0f); }
void iAnt_qt_user_functions::DrawInWorld() { foodPositions = loopFunctions->GetFoodPositions(); pheromonePositions = loopFunctions->GetPheromonePositions(); fidelityPositions = loopFunctions->GetFidelityPositions(); CVector3 np(nestPosition.GetX(), nestPosition.GetY(), 0.001f); Real height = foodRadius / 2.0; //#ifdef __APPLE__ CQuaternion q; //#endif // draw the nest //#ifdef __APPLE__ DrawCircle(np, q, nestRadius, CColor::GRAY80); //#else // DrawCircle(nestRadius, np, CColor::GRAY80); //#endif if(foodPositions.size() > 0) { Real x, y; CVector3 p3d; // draw the food items for(size_t i = 0; i < foodPositions.size(); i++) { x = foodPositions[i].GetX(); y = foodPositions[i].GetY(); p3d = CVector3(x, y, 0.0); //#ifdef __APPLE__ DrawCylinder(p3d, q, foodRadius, height, CColor::BLACK); //#else // DrawCylinder(foodRadius, height, p3d, CColor::BLACK); //#endif } // draw the pheromone positions for(size_t i = 0; i < pheromonePositions.size(); i++) { if(pheromonePositions[i] != nestPosition) { x = pheromonePositions[i].GetX(); y = pheromonePositions[i].GetY(); p3d = CVector3(x, y, 0.0); //#ifdef __APPLE__ DrawCylinder(p3d, q, foodRadius, height, CColor::RED); //#else // DrawCylinder(foodRadius, height, p3d, CColor::RED); //#endif } } // draw the fidelity positions for(size_t i = 0; i < fidelityPositions.size(); i++) { if(fidelityPositions[i] != nestPosition) { x = fidelityPositions[i].GetX(); y = fidelityPositions[i].GetY(); p3d = CVector3(x, y, 0.0); //#ifdef __APPLE__ DrawCylinder(p3d, q, foodRadius, height, CColor::BLUE); //#else // DrawCylinder(foodRadius, height, p3d, CColor::BLUE); //#endif } } } }
int main() { // Initialization //-------------------------------------------------------------------------------------- int screenWidth = 800; int screenHeight = 450; InitWindow(screenWidth, screenHeight, "raylib [models] example - geometric shapes"); // Define the camera to look into our 3d world Camera camera = {{ 0.0f, 10.0f, 10.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f }; SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- // Main game loop while (!WindowShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- // TODO: Update your variables here //---------------------------------------------------------------------------------- // Draw //---------------------------------------------------------------------------------- BeginDrawing(); ClearBackground(RAYWHITE); Begin3dMode(camera); DrawCube((Vector3){-4.0f, 0.0f, 2.0f}, 2.0f, 5.0f, 2.0f, RED); DrawCubeWires((Vector3){-4.0f, 0.0f, 2.0f}, 2.0f, 5.0f, 2.0f, GOLD); DrawCubeWires((Vector3){-4.0f, 0.0f, -2.0f}, 3.0f, 6.0f, 2.0f, MAROON); DrawSphere((Vector3){-1.0f, 0.0f, -2.0f}, 1.0f, GREEN); DrawSphereWires((Vector3){1.0f, 0.0f, 2.0f}, 2.0f, 16, 16, LIME); DrawCylinder((Vector3){4.0f, 0.0f, -2.0f}, 1.0f, 2.0f, 3.0f, 4, SKYBLUE); DrawCylinderWires((Vector3){4.0f, 0.0f, -2.0f}, 1.0f, 2.0f, 3.0f, 4, DARKBLUE); DrawCylinderWires((Vector3){4.5f, -1.0f, 2.0f}, 1.0f, 1.0f, 2.0f, 6, BROWN); DrawCylinder((Vector3){1.0f, 0.0f, -4.0f}, 0.0f, 1.5f, 3.0f, 8, GOLD); DrawCylinderWires((Vector3){1.0f, 0.0f, -4.0f}, 0.0f, 1.5f, 3.0f, 8, PINK); DrawGrid(10, 1.0f); // Draw a grid End3dMode(); DrawFPS(10, 10); EndDrawing(); //---------------------------------------------------------------------------------- } // De-Initialization //-------------------------------------------------------------------------------------- CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- return 0; }
void FNavLinkRenderingProxy::DrawLinks(FPrimitiveDrawInterface* PDI, TArray<FNavLinkDrawing>& OffMeshPointLinks, TArray<FNavLinkSegmentDrawing>& OffMeshSegmentLinks, TArray<float>& StepHeights, FMaterialRenderProxy* const MeshColorInstance, uint32 AgentMask) { static const FColor LinkColor(0,0,166); static const float LinkArcThickness = 3.f; static const float LinkArcHeight = 0.4f; if (StepHeights.Num() == 0) { StepHeights.Add(FNavigationSystem::FallbackAgentHeight / 2); } for (int32 LinkIndex = 0; LinkIndex < OffMeshPointLinks.Num(); ++LinkIndex) { const FNavLinkDrawing& Link = OffMeshPointLinks[LinkIndex]; if ((Link.SupportedAgentsBits & AgentMask) == 0) { continue; } const uint32 Segments = FPlatformMath::Max<uint32>(LinkArcHeight*(Link.Right-Link.Left).Size()/10, 8); DrawArc(PDI, Link.Left, Link.Right, LinkArcHeight, Segments, Link.Color, SDPG_World, 3.5f); const FVector VOffset(0,0,FVector::Dist(Link.Left, Link.Right)*1.333f); switch (Link.Direction) { case ENavLinkDirection::LeftToRight: DrawArrowHead(PDI, Link.Right, Link.Left+VOffset, 30.f, Link.Color, SDPG_World, 3.5f); break; case ENavLinkDirection::RightToLeft: DrawArrowHead(PDI, Link.Left, Link.Right+VOffset, 30.f, Link.Color, SDPG_World, 3.5f); break; case ENavLinkDirection::BothWays: default: DrawArrowHead(PDI, Link.Right, Link.Left+VOffset, 30.f, Link.Color, SDPG_World, 3.5f); DrawArrowHead(PDI, Link.Left, Link.Right+VOffset, 30.f, Link.Color, SDPG_World, 3.5f); break; } // draw snap-spheres on both ends if (Link.SnapHeight < 0) { for (int32 StepHeightIndex = 0; StepHeightIndex < StepHeights.Num(); ++StepHeightIndex) { DrawCylinder(PDI, Link.Right, FVector(1, 0, 0), FVector(0, 1, 0), FVector(0, 0, 1), Link.SnapRadius, StepHeights[StepHeightIndex], 10, MeshColorInstance, SDPG_World); DrawCylinder(PDI, Link.Left, FVector(1, 0, 0), FVector(0, 1, 0), FVector(0, 0, 1), Link.SnapRadius, StepHeights[StepHeightIndex], 10, MeshColorInstance, SDPG_World); } } else { DrawCylinder(PDI, Link.Right, FVector(1, 0, 0), FVector(0, 1, 0), FVector(0, 0, 1), Link.SnapRadius, Link.SnapHeight, 10, MeshColorInstance, SDPG_World); DrawCylinder(PDI, Link.Left, FVector(1, 0, 0), FVector(0, 1, 0), FVector(0, 0, 1), Link.SnapRadius, Link.SnapHeight, 10, MeshColorInstance, SDPG_World); } } static const float SegmentArcHeight = 0.25f; for (int32 LinkIndex = 0; LinkIndex < OffMeshSegmentLinks.Num(); ++LinkIndex) { const FNavLinkSegmentDrawing& Link = OffMeshSegmentLinks[LinkIndex]; if ((Link.SupportedAgentsBits & AgentMask) == 0) { continue; } const uint32 SegmentsStart = FPlatformMath::Max<uint32>(SegmentArcHeight*(Link.RightStart-Link.LeftStart).Size()/10, 8); const uint32 SegmentsEnd = FPlatformMath::Max<uint32>(SegmentArcHeight*(Link.RightEnd-Link.LeftEnd).Size()/10, 8); DrawArc(PDI, Link.LeftStart, Link.RightStart, SegmentArcHeight, SegmentsStart, Link.Color, SDPG_World, 3.5f); DrawArc(PDI, Link.LeftEnd, Link.RightEnd, SegmentArcHeight, SegmentsEnd, Link.Color, SDPG_World, 3.5f); const FVector VOffset(0,0,FVector::Dist(Link.LeftStart, Link.RightStart)*1.333f); switch (Link.Direction) { case ENavLinkDirection::LeftToRight: DrawArrowHead(PDI, Link.RightStart, Link.LeftStart+VOffset, 30.f, Link.Color, SDPG_World, 3.5f); DrawArrowHead(PDI, Link.RightEnd, Link.LeftEnd+VOffset, 30.f, Link.Color, SDPG_World, 3.5f); break; case ENavLinkDirection::RightToLeft: DrawArrowHead(PDI, Link.LeftStart, Link.RightStart+VOffset, 30.f, Link.Color, SDPG_World, 3.5f); DrawArrowHead(PDI, Link.LeftEnd, Link.RightEnd+VOffset, 30.f, Link.Color, SDPG_World, 3.5f); break; case ENavLinkDirection::BothWays: default: DrawArrowHead(PDI, Link.RightStart, Link.LeftStart+VOffset, 30.f, Link.Color, SDPG_World, 3.5f); DrawArrowHead(PDI, Link.RightEnd, Link.LeftEnd+VOffset, 30.f, Link.Color, SDPG_World, 3.5f); DrawArrowHead(PDI, Link.LeftStart, Link.RightStart+VOffset, 30.f, Link.Color, SDPG_World, 3.5f); DrawArrowHead(PDI, Link.LeftEnd, Link.RightEnd+VOffset, 30.f, Link.Color, SDPG_World, 3.5f); break; } // draw snap-spheres on both ends if (Link.SnapHeight < 0) { for (int32 StepHeightIndex = 0; StepHeightIndex < StepHeights.Num(); ++StepHeightIndex) { DrawCylinder(PDI, Link.RightStart, FVector(1, 0, 0), FVector(0, 1, 0), FVector(0, 0, 1), Link.SnapRadius, StepHeights[StepHeightIndex], 10, MeshColorInstance, SDPG_World); DrawCylinder(PDI, Link.RightEnd, FVector(1, 0, 0), FVector(0, 1, 0), FVector(0, 0, 1), Link.SnapRadius, StepHeights[StepHeightIndex], 10, MeshColorInstance, SDPG_World); DrawCylinder(PDI, Link.LeftStart, FVector(1, 0, 0), FVector(0, 1, 0), FVector(0, 0, 1), Link.SnapRadius, StepHeights[StepHeightIndex], 10, MeshColorInstance, SDPG_World); DrawCylinder(PDI, Link.LeftEnd, FVector(1, 0, 0), FVector(0, 1, 0), FVector(0, 0, 1), Link.SnapRadius, StepHeights[StepHeightIndex], 10, MeshColorInstance, SDPG_World); } } else { DrawCylinder(PDI, Link.RightStart, FVector(1, 0, 0), FVector(0, 1, 0), FVector(0, 0, 1), Link.SnapRadius, Link.SnapHeight, 10, MeshColorInstance, SDPG_World); DrawCylinder(PDI, Link.RightEnd, FVector(1, 0, 0), FVector(0, 1, 0), FVector(0, 0, 1), Link.SnapRadius, Link.SnapHeight, 10, MeshColorInstance, SDPG_World); DrawCylinder(PDI, Link.LeftStart, FVector(1, 0, 0), FVector(0, 1, 0), FVector(0, 0, 1), Link.SnapRadius, Link.SnapHeight, 10, MeshColorInstance, SDPG_World); DrawCylinder(PDI, Link.LeftEnd, FVector(1, 0, 0), FVector(0, 1, 0), FVector(0, 0, 1), Link.SnapRadius, Link.SnapHeight, 10, MeshColorInstance, SDPG_World); } } }
void DrawCylinderChain(std::list<Cylinder> cylinders) { for(std::list<Cylinder>::iterator it = cylinders.begin(); it != cylinders.end(); it++) { DrawCylinder(*it); } }
void UpdateDrawOneFrame(void) { // Update //---------------------------------------------------------------------------------- if (!onTransition) { switch(currentScreen) { case LOADING: { // Update LOADING screen variables framesCounter++; // Count frames if ((loadBarWidth < loadBarMaxWidth) && ((framesCounter%30) == 0)) loadBarWidth++; if (IsKeyDown(KEY_SPACE) && (loadBarWidth < loadBarMaxWidth)) loadBarWidth += 4; if (IsKeyPressed(KEY_ENTER) && (loadBarWidth >= loadBarMaxWidth)) TransitionToScreen(LOGO); } break; case LOGO: { // Update LOGO screen variables if (logoScreenState == 0) // State 0: Small box blinking { framesCounter++; if (framesCounter == 120) { logoScreenState = 1; framesCounter = 0; // Reset counter... will be used later... } } else if (logoScreenState == 1) // State 1: Top and left bars growing { topSideRecWidth += 4; leftSideRecHeight += 4; if (topSideRecWidth == 256) logoScreenState = 2; } else if (logoScreenState == 2) // State 2: Bottom and right bars growing { bottomSideRecWidth += 4; rightSideRecHeight += 4; if (bottomSideRecWidth == 256) { lettersCounter = 0; for (int i = 0; i < strlen(msgBuffer); i++) msgBuffer[i] = ' '; logoScreenState = 3; } } else if (logoScreenState == 3) // State 3: Letters appearing (one by one) { framesCounter++; // Every 12 frames, one more letter! if ((framesCounter%12) == 0) raylibLettersCount++; switch (raylibLettersCount) { case 1: raylib[0] = 'r'; break; case 2: raylib[1] = 'a'; break; case 3: raylib[2] = 'y'; break; case 4: raylib[3] = 'l'; break; case 5: raylib[4] = 'i'; break; case 6: raylib[5] = 'b'; break; default: break; } if (raylibLettersCount >= 10) { // Write raylib description messages if ((framesCounter%2) == 0) lettersCounter++; if (!msgLogoADone) { if (lettersCounter <= strlen(msgLogoA)) strncpy(msgBuffer, msgLogoA, lettersCounter); else { for (int i = 0; i < strlen(msgBuffer); i++) msgBuffer[i] = ' '; lettersCounter = 0; msgLogoADone = true; } } else if (!msgLogoBDone) { if (lettersCounter <= strlen(msgLogoB)) strncpy(msgBuffer, msgLogoB, lettersCounter); else { msgLogoBDone = true; framesCounter = 0; } } } } // Press enter to change to MODULES screen if (IsKeyPressed(KEY_ENTER) && msgLogoBDone) TransitionToScreen(MODULES); else if (IsKeyPressed(KEY_BACKSPACE)) TransitionToScreen(LOGO); } break; case MODULES: { // Update MODULES screen variables here! framesCounter++; if (IsKeyPressed(KEY_RIGHT) && (selectedModule < 5)) { selectedModule++; framesCounter = 0; } else if (IsKeyPressed(KEY_LEFT) && (selectedModule > 0)) { selectedModule--; framesCounter = 0; } if (selectedModule == CORE) { if ((framesCounter > 60) && (windowOffset < 40)) { windowOffset++; ballPosition.x++; ballPosition.y++; } if (framesCounter > 140) { if (IsKeyDown('A')) ballPosition.x -= 5; if (IsKeyDown('D')) ballPosition.x += 5; if (IsKeyDown('W')) ballPosition.y -= 5; if (IsKeyDown('S')) ballPosition.y += 5; if (IsKeyPressed('1')) coreWindow = 1; if (IsKeyPressed('2')) coreWindow = 2; if (IsKeyPressed('3')) coreWindow = 3; if (IsKeyPressed('4')) coreWindow = 4; } } if (selectedModule == TEXTURES) scaleFactor = (sinf(2*PI/240*framesCounter) + 1.0f)/2; if (selectedModule == AUDIO) { if (IsKeyPressed(KEY_SPACE) && !MusicIsPlaying()) PlayMusicStream("resources/audio/guitar_noodling.ogg"); // Play music stream if (IsKeyPressed('S')) { StopMusicStream(); timePlayed = 0.0f; for (int i = 0; i < MAX_BALLS; i++) { soundBallsPosition[i] = (Vector2){ 650 + 560/2 + GetRandomValue(-280, 280), 220 + 200 + GetRandomValue(-200, 200) }; soundBallsColor[i] = (Color){ GetRandomValue(0, 255), GetRandomValue(0, 255), GetRandomValue(0, 255), 255 }; soundBallsRadius[i] = GetRandomValue(2, 50); soundBallsAlpha[i] = 1.0f; soundBallsActive[i] = false; } } if (MusicIsPlaying()) { timePlayed = GetMusicTimePlayed() / GetMusicTimeLength() * 100 * 4; if ((framesCounter%10) == 0) { for (int i = 0; i < MAX_BALLS; i++) { if (!soundBallsActive[i]) { soundBallsActive[i] = true; break; } } } for (int i = 0; i < MAX_BALLS; i++) { if (soundBallsActive[i]) soundBallsAlpha[i] -= 0.005f; if (soundBallsAlpha[i] <= 0) { soundBallsActive[i] = false; // Reset ball random soundBallsPosition[i] = (Vector2){ 650 + 560/2 + GetRandomValue(-280, 280), 220 + 200 + GetRandomValue(-200, 200) }; soundBallsColor[i] = (Color){ GetRandomValue(0, 255), GetRandomValue(0, 255), GetRandomValue(0, 255), 255 }; soundBallsRadius[i] = GetRandomValue(2, 60); soundBallsAlpha[i] = 1.0f; } } } if (IsKeyPressed('N')) PlaySound(fxWav); //if (IsKeyPressed('M')) PlaySound(fxOgg); } // Press enter to change to ENDING screen if (IsKeyPressed(KEY_ENTER)) TransitionToScreen(ENDING); else if (IsKeyPressed(KEY_BACKSPACE)) TransitionToScreen(LOGO); } break; case PONG: { // Update SECRET screen variables here! framesCounter++; if (IsKeyPressed('P')) pongPaused = !pongPaused; if (!pongPaused) { pongBallPosition.x += pongBallSpeed.x; pongBallPosition.y += pongBallSpeed.y; if ((pongBallPosition.x >= screenWidth - 5) || (pongBallPosition.x <= 5)) pongBallSpeed.x *= -1; if ((pongBallPosition.y >= screenHeight - 5) || (pongBallPosition.y <= 5)) pongBallSpeed.y *= -1; if (IsKeyDown(KEY_UP) || IsKeyDown('W')) { pongPlayerRec.y -= 5; pongAutoMode = false; pongAutoCounter = 180; } else if (IsKeyDown(KEY_DOWN) || IsKeyDown('S')) { pongPlayerRec.y += 5; pongAutoMode = false; pongAutoCounter = 180; } else if (pongAutoCounter > 0) { pongAutoCounter--; if (pongAutoCounter == 0) pongAutoMode = true; } if ((pongBallPosition.x < 600) && pongAutoMode) { if (pongBallPosition.y > (pongPlayerRec.y + pongPlayerRec.height/2)) pongPlayerRec.y += 5; else if (pongBallPosition.y < (pongPlayerRec.y + pongPlayerRec.height/2)) pongPlayerRec.y -= 5; } if (pongPlayerRec.y <= 0) pongPlayerRec.y = 0; else if ((pongPlayerRec.y + pongPlayerRec.height) >= screenHeight) pongPlayerRec.y = screenHeight - pongPlayerRec.height; if (pongBallPosition.x > screenWidth - 600) { if (pongBallPosition.y > (pongEnemyRec.y + pongEnemyRec.height/2)) pongEnemyRec.y += 5; else if (pongBallPosition.y < (pongEnemyRec.y + pongEnemyRec.height/2)) pongEnemyRec.y -= 5; if (pongEnemyRec.y <= 0) pongEnemyRec.y = 0; else if ((pongEnemyRec.y + pongEnemyRec.height) >= screenHeight) pongEnemyRec.y = screenHeight - pongEnemyRec.height; } if ((CheckCollisionCircleRec(pongBallPosition, 10, pongPlayerRec)) || (CheckCollisionCircleRec(pongBallPosition, 10, pongEnemyRec))) pongBallSpeed.x *= -1; if (pongBallPosition.x >= screenWidth - 5) pongScorePlayer++; else if (pongBallPosition.x <= 5) pongScoreEnemy++; } // Press enter to move back to MODULES screen if (IsKeyPressed(KEY_ENTER)) TransitionToScreen(ENDING); if (IsKeyPressed(KEY_BACKSPACE)) TransitionToScreen(ENDING); } break; case ENDING: { // Update ENDING screen framesCounter++; // Press enter to move back to MODULES screen if (IsKeyPressed(KEY_ENTER)) TransitionToScreen(PONG); if (IsKeyPressed(KEY_BACKSPACE)) TransitionToScreen(MODULES); } break; default: break; } if ((currentScreen != LOADING) && (timeCounter < totalTime)) timeCounter++; } else UpdateTransition(); // Update transition (fade-in, fade-out) //---------------------------------------------------------------------------------- // Draw //---------------------------------------------------------------------------------- BeginDrawing(); ClearBackground(RAYWHITE); switch(currentScreen) { case LOADING: { // Draw LOADING screen if ((loadBarWidth < loadBarMaxWidth) && ((framesCounter/40)%2)) DrawText(msgLoading, 360, 240, 40, DARKGRAY); DrawRectangle(360 - 4, 300 - 4, loadBarMaxWidth + 8, 60 + 8, LIGHTGRAY); DrawRectangle(360, 300, loadBarWidth - 1, 60, DARKGRAY); DrawRectangleLines(360 - 4, 300 - 5, loadBarMaxWidth + 8, 60 + 8, DARKGRAY); if (loadBarWidth >= loadBarMaxWidth) { //DrawText(msgLoading, 360, 240, 40, DARKGRAY); if ((framesCounter/30)%2) DrawText(msgPressEnter, screenWidth/2 - MeasureText(msgPressEnter, 40)/2 + 20, 400, 40, DARKGRAY); } else DrawText("PRESS SPACE to ACCELERATE LOADING! ;)", screenWidth/2 - 200, 400, 20, LIGHTGRAY); } break; case LOGO: { // Draw LOGO screen if (logoScreenState == 0) { if ((framesCounter/15)%2) DrawRectangle(logoPositionX, logoPositionY - 60, 16, 16, BLACK); } else if (logoScreenState == 1) { DrawRectangle(logoPositionX, logoPositionY - 60, topSideRecWidth, 16, BLACK); DrawRectangle(logoPositionX, logoPositionY - 60, 16, leftSideRecHeight, BLACK); } else if (logoScreenState == 2) { DrawRectangle(logoPositionX, logoPositionY - 60, topSideRecWidth, 16, BLACK); DrawRectangle(logoPositionX, logoPositionY - 60, 16, leftSideRecHeight, BLACK); DrawRectangle(logoPositionX + 240, logoPositionY - 60, 16, rightSideRecHeight, BLACK); DrawRectangle(logoPositionX, logoPositionY + 240 - 60, bottomSideRecWidth, 16, BLACK); } else if (logoScreenState == 3) { DrawRectangle(logoPositionX, logoPositionY - 60, topSideRecWidth, 16, BLACK); DrawRectangle(logoPositionX, logoPositionY + 16 - 60, 16, leftSideRecHeight - 32, BLACK); DrawRectangle(logoPositionX + 240, logoPositionY + 16 - 60, 16, rightSideRecHeight - 32, BLACK); DrawRectangle(logoPositionX, logoPositionY + 240 - 60, bottomSideRecWidth, 16, BLACK); DrawRectangle(screenWidth/2 - 112, screenHeight/2 - 112 - 60, 224, 224, RAYWHITE); DrawText(raylib, screenWidth/2 - 44, screenHeight/2 + 48 - 60, 50, BLACK); if (!msgLogoADone) DrawText(msgBuffer, screenWidth/2 - MeasureText(msgLogoA, 30)/2, 460, 30, GRAY); else { DrawText(msgLogoA, screenWidth/2 - MeasureText(msgLogoA, 30)/2, 460, 30, GRAY); if (!msgLogoBDone) DrawText(msgBuffer, screenWidth/2 - MeasureText(msgLogoB, 30)/2, 510, 30, GRAY); else { DrawText(msgLogoB, screenWidth/2 - MeasureText(msgLogoA, 30)/2, 510, 30, GRAY); if ((framesCounter > 90) && ((framesCounter/30)%2)) DrawText("PRESS ENTER to CONTINUE", 930, 650, 20, GRAY); } } } } break; case MODULES: { // Draw MODULES screen DrawTexture(raylibLogoB, 40, 40, WHITE); DrawText("raylib is composed of 6 main modules:", 128 + 40 + 30, 50, 20, GRAY); if (framesCounter < 120) { if (((framesCounter/30)%2) == 0) DrawRectangle(128 + 40 + 30 - 4 + 175*selectedModule, 128 + 40 - 70 - 8 - 4, 158, 78, RED); } else DrawRectangle(128 + 40 + 30 - 4 + 175*selectedModule, 128 + 40 - 70 - 8 - 4, 158, 78, RED); if (selectedModule != AUDIO) { DrawTriangle((Vector2){950 - 40, 685 - 10}, (Vector2){950 - 60, 685}, (Vector2){950 - 40, 685 + 10}, GRAY); DrawTriangle((Vector2){950 - 30, 685 - 10}, (Vector2){950 - 30, 685 + 10}, (Vector2){950 - 10, 685}, GRAY); DrawText("PRESS RIGHT or LEFT to EXPLORE MODULES", 960, 680, 10, GRAY); } switch (selectedModule) { case CORE: { DrawText("This module give you functions to:", 48, 200, 10, GetColor(0x5c5a5aff)); DrawTextEx(fontRomulus, "Open-Close Window", (Vector2){ 48, 230 }, GetFontBaseSize(fontRomulus)*2, 4, GetColor(0x5c5a5aff)); DrawTextEx(fontRomulus, "Manage Drawing Area", (Vector2){ 48, 260 }, GetFontBaseSize(fontRomulus)*2, 4, GetColor(0x5c5a5aff)); DrawTextEx(fontRomulus, "Manage Inputs", (Vector2){ 48, 290 }, GetFontBaseSize(fontRomulus)*2, 4, GetColor(0x5c5a5aff)); DrawTextEx(fontRomulus, "Manage Timming", (Vector2){ 48, 320 }, GetFontBaseSize(fontRomulus)*2, 4, GetColor(0x5c5a5aff)); DrawTextEx(fontRomulus, "Auxiliar Functions", (Vector2){ 48, 350 }, GetFontBaseSize(fontRomulus)*2, 4, GetColor(0x5c5a5aff)); switch (coreWindow) { case 1: DrawTexture(raylibWindow, 520, 220, WHITE); break; case 2: DrawTextureEx(raylibWindow01, (Vector2){ 450, 220 - 45 }, 0.0f, 4.0f, WHITE); break; case 3: DrawTextureEx(raylibWindow02, (Vector2){ 430, 220 - 40 }, 0.0f, 4.0f, WHITE); break; case 4: DrawTextureEx(raylibWindow03, (Vector2){ 470, 220 - 65 }, 0.0f, 4.0f, WHITE); break; default: DrawTexture(raylibWindow, 520, 220, WHITE); break; } if (framesCounter > 140) DrawText("Check the possible windows raylib can run on. PRESS KEY: 1, 2, 3 or 4", 520 + 8 + windowOffset + 160, 220 + windowOffset + 10, 10, LIGHTGRAY); DrawText("Compile raylib C code for the folowing platforms:", 48, 400, 10, MAROON); DrawTextureRec(platforms, (Rectangle){ 0, 0, platforms.width, platforms.height}, (Vector2){ 75, 420 }, WHITE); DrawRectangle(520 + 8 + windowOffset, 220 + 31 + windowOffset, 640, 360, RAYWHITE); DrawRectangleLines(520 + 8 + windowOffset - 1, 220 + 31 + windowOffset - 2, 640 + 2, 360 + 2, GRAY); DrawFPS(520 + 8 + windowOffset + 10, 220 + 31 + windowOffset + 10); DrawRectangle(ballPosition.x - 50, ballPosition.y - 50, 100, 100, Fade(MAROON, 0.5f)); DrawRectangleRec(GetCollisionRec((Rectangle){ 520 + 8 + windowOffset - 1, 220 + 31 + windowOffset - 1, 640 + 2, 360 + 2 }, (Rectangle){ (int)ballPosition.x - 50, (int)ballPosition.y - 50, 100, 100 }), MAROON); if (framesCounter > 140) { DrawTextEx(fontMecha, "MOVE ME", (Vector2){ ballPosition.x - 26, ballPosition.y - 20 }, GetFontBaseSize(fontMecha), 2, BLACK); DrawTextEx(fontMecha, "[ W A S D ]", (Vector2){ ballPosition.x - 36, ballPosition.y }, GetFontBaseSize(fontMecha), 2, BLACK); } } break; case SHAPES: { DrawText("This module give you functions to:", 48, 200, 10, GetColor(0xcd5757ff)); DrawTextEx(fontRomulus, "Draw Basic Shapes", (Vector2){ 48, 230 }, GetFontBaseSize(fontRomulus)*2, 4, GetColor(0xcd5757ff)); DrawTextEx(fontRomulus, "Basic Collision Detection", (Vector2){ 48, 260 }, GetFontBaseSize(fontRomulus)*2, 4, GetColor(0xcd5757ff)); DrawCircle(screenWidth/4, 120 + 240, 35, DARKBLUE); DrawCircleGradient(screenWidth/4, 220 + 240, 60, GREEN, SKYBLUE); DrawCircleLines(screenWidth/4, 340 + 240, 80, DARKBLUE); DrawRectangle(screenWidth/4*2 - 110, 100 + 180, 220, 100, LIME); DrawRectangleGradient(screenWidth/4*2 - 90, 170 + 240, 180, 130, MAROON, GOLD); DrawRectangleLines(screenWidth/4*2 - 80, 320 + 240, 160, 80, ORANGE); DrawTriangle((Vector2){screenWidth/4*3, 60 + 220}, (Vector2){screenWidth/4*3 - 60, 160 + 220}, (Vector2){screenWidth/4*3 + 60, 160 + 220}, VIOLET); DrawTriangleLines((Vector2){screenWidth/4*3, 140 + 220}, (Vector2){screenWidth/4*3 - 60, 210 + 260}, (Vector2){screenWidth/4*3 + 60, 210 + 260}, SKYBLUE); DrawPoly((Vector2){screenWidth/4*3, 320 + 240}, 6, 80, 0, BROWN); } break; case TEXTURES: { DrawText("This module give you functions to:", 48, 200, 10, GetColor(0x60815aff)); DrawTextEx(fontRomulus, "Load Images and Textures", (Vector2){ 48, 230 }, GetFontBaseSize(fontRomulus)*2, 4, GetColor(0x60815aff)); DrawTextEx(fontRomulus, "Draw Textures", (Vector2){ 48, 260 }, GetFontBaseSize(fontRomulus)*2, 4, GetColor(0x60815aff)); DrawRectangle(138, 348, 260, 260, GRAY); DrawTexturePro(lena, (Rectangle){ 0, 0, lena.width, lena.height }, (Rectangle){ 140 + 128, 350 + 128, lena.width/2*scaleFactor, lena.height/2*scaleFactor }, (Vector2){ lena.width/4*scaleFactor, lena.height/4*scaleFactor }, 0.0f, WHITE); DrawTexture(lena, 600, 180, Fade(WHITE, 0.3f)); DrawTextureRec(lena, (Rectangle){ 225, 240, 155, 50 }, (Vector2){ 600 + 256 - 82 + 50, 180 + 241 }, PINK); DrawTexturePro(mandrill, (Rectangle){ 0, 0, mandrill.width, mandrill.height }, (Rectangle){ screenWidth/2 - 40, 350 + 128, mandrill.width/2, mandrill.height/2 }, (Vector2){ mandrill.width/4, mandrill.height/4 }, framesCounter, GOLD); } break; case TEXT: { DrawText("This module give you functions to:", 48, 200, 10, GetColor(0x377764ff)); DrawTextEx(fontRomulus, "Load SpriteFonts", (Vector2){ 48, 230 }, GetFontBaseSize(fontRomulus)*2, 4, GetColor(0x377764ff)); DrawTextEx(fontRomulus, "Draw Text", (Vector2){ 48, 260 }, GetFontBaseSize(fontRomulus)*2, 4, GetColor(0x377764ff)); DrawTextEx(fontRomulus, "Text Formatting", (Vector2){ 48, 290 }, GetFontBaseSize(fontRomulus)*2, 4, GetColor(0x377764ff)); DrawTexture(texAlagard, 60, 360, WHITE); DrawTextEx(fontMechaC, msg1, (Vector2){ 540 + 168, 210 }, GetFontBaseSize(fontMechaC), -3, WHITE); DrawTextEx(fontAlagardC, msg2, (Vector2){ 460 + 140, 260 }, GetFontBaseSize(fontAlagardC), -2, WHITE); DrawTextEx(fontJupiterC, msg3, (Vector2){ 640 + 70, 300 }, GetFontBaseSize(fontJupiterC), 2, WHITE); DrawTextEx(fontAlagard, "It also includes some...", (Vector2){ 650 + 70, 400 }, GetFontBaseSize(fontAlagard)*2, 2, MAROON); DrawTextEx(fontPixelplay, "...free fonts in rBMF format...", (Vector2){ 705 - 26, 450 }, GetFontBaseSize(fontPixelplay)*2, 4, ORANGE); DrawTextEx(fontMecha, "...to be used even in...", (Vector2){ 700 + 40, 500 }, GetFontBaseSize(fontMecha)*2, 4, DARKGREEN); DrawTextEx(fontSetback, "...comercial projects...", (Vector2){ 710, 550 }, GetFontBaseSize(fontSetback)*2, 4, DARKBLUE); DrawTextEx(fontRomulus, "...completely for free!", (Vector2){ 710 + 17, 600 }, GetFontBaseSize(fontRomulus)*2, 3, DARKPURPLE); DrawText("This is a custom font spritesheet, raylib can load it automatically!", 228, 360 + 295, 10, GRAY); } break; case MODELS: { DrawText("This module give you functions to:", 48, 200, 10, GetColor(0x417794ff)); DrawTextEx(fontRomulus, "Draw Geometric Models", (Vector2){ 48, 230 }, GetFontBaseSize(fontRomulus)*2, 4, GetColor(0x417794ff)); DrawTextEx(fontRomulus, "Load 3D Models", (Vector2){ 48, 260 }, GetFontBaseSize(fontRomulus)*2, 4, GetColor(0x417794ff)); DrawTextEx(fontRomulus, "Draw 3D Models", (Vector2){ 48, 290 }, GetFontBaseSize(fontRomulus)*2, 4, GetColor(0x417794ff)); Begin3dMode(camera); DrawCube((Vector3){-4, 0, 2}, 2, 5, 2, RED); DrawCubeWires((Vector3){-4, 0, 2}, 2, 5, 2, GOLD); DrawCubeWires((Vector3){-4, 0, -2}, 3, 6, 2, MAROON); DrawSphere((Vector3){-1, 0, -2}, 1, GREEN); DrawSphereWires((Vector3){1, 0, 2}, 2, 16, 16, LIME); DrawCylinder((Vector3){4, 0, -2}, 1, 2, 3, 4, SKYBLUE); DrawCylinderWires((Vector3){4, 0, -2}, 1, 2, 3, 4, DARKBLUE); DrawCylinderWires((Vector3){4.5, -1, 2}, 1, 1, 2, 6, BROWN); DrawCylinder((Vector3){1, 0, -4}, 0, 1.5, 3, 8, GOLD); DrawCylinderWires((Vector3){1, 0, -4}, 0, 1.5, 3, 8, PINK); DrawModelEx(cat, (Vector3){ 8.0f, 0.0f, 2.0f }, (Vector3){ 0.0f, 0.5f*framesCounter, 0.0f }, (Vector3){ 0.1f, 0.1f, 0.1f }, WHITE); DrawGizmo((Vector3){ 8.0f, 0.0f, 2.0f }); DrawGrid(10.0, 1.0); // Draw a grid End3dMode(); DrawFPS(900, 220); } break; case AUDIO: { DrawText("This module give you functions to:", 48, 200, 10, GetColor(0x8c7539ff)); DrawTextEx(fontRomulus, "Load and Play Sounds", (Vector2){ 48, 230 }, GetFontBaseSize(fontRomulus)*2, 4, GetColor(0x8c7539ff)); DrawTextEx(fontRomulus, "Play Music (streaming)", (Vector2){ 48, 260 }, GetFontBaseSize(fontRomulus)*2, 4, GetColor(0x8c7539ff)); DrawText("PRESS SPACE to START PLAYING MUSIC", 135, 350, 20, GRAY); DrawRectangle(150, 390, 400, 12, LIGHTGRAY); DrawRectangle(150, 390, (int)timePlayed, 12, MAROON); if (MusicIsPlaying()) { DrawText("PRESS 'S' to STOP PLAYING MUSIC", 165, 425, 20, GRAY); for (int i = 0; i < MAX_BALLS; i++) { if (soundBallsActive[i]) DrawPoly(soundBallsPosition[i], 18, soundBallsRadius[i], 0.0f, Fade(soundBallsColor[i], soundBallsAlpha[i])); } } DrawText("PRESS 'N' to PLAY a SOUND", 200, 540, 20, VIOLET); if ((framesCounter/30)%2) DrawText("PRESS ENTER to CONTINUE", 930, 650, 20, GRAY); } break; default: break; } // Draw modules menu DrawRectangle(128 + 40 + 30, 128 + 40 - 70 - 8, 150, 70, GetColor(0x898888ff)); DrawRectangle(128 + 40 + 30 + 8, 128 + 40 - 70, 150 - 16, 70 - 16, GetColor(0xe1e1e1ff)); DrawText("CORE", 128 + 40 + 30 + 8 + 38, 128 + 40 - 50, 20, GetColor(0x5c5a5aff)); DrawRectangle(128 + 40 + 30 + 175, 128 + 40 - 70 - 8, 150, 70, GetColor(0xe66666ff)); DrawRectangle(128 + 40 + 30 + 8 + 175, 128 + 40 - 70, 150 - 16, 70 - 16, GetColor(0xf0d6d6ff)); DrawText("SHAPES", 128 + 40 + 30 + 8 + 175 + 28, 128 + 40 - 50, 20, GetColor(0xcd5757ff)); DrawRectangle(128 + 40 + 30 + 175*2, 128 + 40 - 70 - 8, 150, 70, GetColor(0x75a06dff)); DrawRectangle(128 + 40 + 30 + 8 + 175*2, 128 + 40 - 70, 150 - 16, 70 - 16, GetColor(0xc8eabfff)); DrawText("TEXTURES", 128 + 40 + 30 + 175*2 + 8 + 9, 128 + 40 - 50, 20, GetColor(0x60815aff)); DrawRectangle(128 + 40 + 30 + 175*3, 128 + 40 - 70 - 8, 150, 70, GetColor(0x52b296ff)); DrawRectangle(128 + 40 + 30 + 8 + 175*3, 128 + 40 - 70, 150 - 16, 70 - 16, GetColor(0xbef0ddff)); DrawText("TEXT", 128 + 40 + 30 + 8 + 175*3 + 38, 128 + 40 - 50, 20, GetColor(0x377764ff)); DrawRectangle(128 + 40 + 30 + 175*4, 128 + 40 - 70 - 8, 150, 70, GetColor(0x5d9cbdff)); DrawRectangle(128 + 40 + 30 + 8 + 175*4, 128 + 40 - 70, 150 - 16, 70 - 16, GetColor(0xbedce8ff)); DrawText("MODELS", 128 + 40 + 30 + 8 + 175*4 + 28, 128 + 40 - 50, 20, GetColor(0x417794ff)); DrawRectangle(128 + 40 + 30 + 175*5, 128 + 40 - 70 - 8, 150, 70, GetColor(0xd3b157ff)); DrawRectangle(128 + 40 + 30 + 8 + 175*5, 128 + 40 - 70, 150 - 16, 70 - 16, GetColor(0xebddaeff)); DrawText("AUDIO", 128 + 40 + 30 + 8 + 175*5 + 36, 128 + 40 - 50, 20, GetColor(0x8c7539ff)); } break; case ENDING: { // Draw ENDING screen DrawTextEx(fontAlagard, "LEARN VIDEOGAMES PROGRAMMING", (Vector2){ screenWidth/2 - MeasureTextEx(fontAlagard, "LEARN VIDEOGAMES PROGRAMMING", GetFontBaseSize(fontAlagard)*4, 4).x/2, 80 }, GetFontBaseSize(fontAlagard)*4, 4, MAROON); DrawTexture(raylibLogoA, logoPositionX, logoPositionY - 40, WHITE); DrawText(msgWeb, screenWidth/2 - MeasureText(msgWeb, 40)/2, 470, 40, DARKGRAY); if (framesCounter > 60) DrawText(msgCredits, screenWidth/2 - MeasureText(msgCredits, 30)/2, 550, 30, GRAY); if (framesCounter > 120) if ((framesCounter/30)%2) DrawText("PRESS ENTER to CONTINUE", screenWidth/2 - MeasureText("PRESS ENTER to CONTINUE", 20)/2, 640, 20, LIGHTGRAY); } break; case PONG: { // Pong DrawCircleV(pongBallPosition, 10, LIGHTGRAY); DrawRectangleRec(pongPlayerRec, GRAY); DrawRectangleRec(pongEnemyRec, GRAY); DrawText(FormatText("%02i", pongScorePlayer), 150, 10, 80, LIGHTGRAY); DrawText(FormatText("%02i", pongScoreEnemy), screenWidth - MeasureText("00", 80) - 150, 10, 80, LIGHTGRAY); if (pongPaused) if ((framesCounter/30)%2) DrawText("GAME PAUSED [P]", screenWidth/2 - 100, 40, 20, MAROON); } break; default: break; } if (currentScreen != LOADING) DrawRectangle(0, screenHeight - 10, ((float)timeCounter/(float)totalTime)*screenWidth, 10, LIGHTGRAY); if (onTransition) DrawTransition(); EndDrawing(); //---------------------------------------------------------------------------------- }