//========================================================================== void MyGlWindow::draw() //========================================================================== { glViewport(0,0,w(),h()); // clear the window, be sure to clear the Z-Buffer too glClearColor(0.2f,0.2f,.2f,0); // background should be blue glClearStencil(0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); glEnable(GL_DEPTH); glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); // now draw the ground plane setProjection(); setupFloor(); glPushMatrix(); drawFloor(50,32); glPopMatrix(); // now to draw the shadows setupLight(); // Add a sphere to the scene. glBegin(GL_LINES); glColor3f(1,0,0); glVertex3f(0,0,0); glVertex3f(0,100,0); glColor3f(0,1,0); glVertex3f(0,0,0); glVertex3f(100,0,0); glColor3f(0,0,1); glVertex3f(0,0,0); glVertex3f(0,0,100); glEnd(); setupShadows(); drawStuff(); unsetupShadows(); // Enable blending glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); drawStuff(); }
void go() { if(lookAround) { drawStuff(); return; } float xt; glClear(GL_ACCUM_BUFFER_BIT); for(xt = (float)-EYEDX; xt < EYEDX; xt += EYEDX / 10.0){ vv(xt); drawStuff(); glAccum(GL_ACCUM,0.05); } glAccum(GL_RETURN,1.0); glFlush(); }
void AGOSEngine::monsterDamageEvent(VgaTimerEntry * vte, uint dx) { // Draws damage indicator gauge when monster hit _nextVgaTimerToProcess = vte + 1; if (!_opcode178Var1) { drawStuff(_image3, 275 + _opcode178Var2 * 4); _opcode178Var2++; if (_opcode178Var2 >= 10 || _opcode178Var2 == dx) { _opcode178Var1 = 1; vte->delay = 16 - dx; } else { vte->delay = 1; } } else if (_opcode178Var2) { _opcode178Var2--; drawStuff(_image4, 275 + _opcode178Var2 * 4); vte->delay = 3; } else { deleteVgaEvent(vte); } }
Mode PlayMode::frame() { if(!paused) { background->draw(); if(!handleInput()) return MENU; if(!crashed) { moveField(); background->update(); updatePlayer(); generateWalls(); generateObstacles(); generateItems(); } updatePlayerTail(); particles->draw(0); particles->draw(2); drawStuff(); particles->draw(4); drawPlayer(); particles->draw(1); floating->draw(); collisionDetect(); obstacleCounter(); drawScorePanel(); if(crashed && !gameOverExplosionTime--) { globalStore->seconds = playtime / 60; globalStore->score = score; globalStore->obstacles = passed; globalStore->stars = collected; storage->read(); storage->insert(score); return GAMEOVER; } particles->update(); floating->update(); } else { drawPauseScreen(); if(!handleInput()) return MENU; } return PLAY; }
void runMainLoop() { BOOL running = TRUE; while (running) { // OpenGL rendering goes here... glClear(GL_COLOR_BUFFER_BIT); drawStuff(); Texture_activate(texture); RenderBatch_render(renderBatch); // Swap front and back rendering buffers glfwSwapBuffers(); afterDrawing(); // Check if ESC key was pressed or window was closed running = !glfwGetKey(GLFW_KEY_ESC) && glfwGetWindowParam(GLFW_OPENED); } }
bool Device::eventFilter(QObject *object, QEvent *event) { if (event->type() == QEvent::Paint && object == pMainScreen) { // qDebug()<<"Screen Width: "<<pMainScreen->geometry().width(); // qDebug()<<"Screen Height: "<<pMainScreen->geometry().height(); QPainter p(pMainScreen); p.fillRect(pMainScreen->rect(), QColor(0,0xff,0,60)); drawStuff(&p); return true; } else if (event->type() == QEvent::KeyRelease) { int key = ((QKeyEvent*)event)->key(); if (key == Qt::Key_Escape) { qApp->quit(); return true; } } return false; }
//The almighty display function void display( void ) { /* THE BOX */ glViewport( 0, 0, 800, 600 ); glMatrixMode( GL_PROJECTION ); glLoadIdentity(); gluOrtho2D( 0, 800, 0, 600 ); glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); /* ANGULAR VIEWPORT */ glViewport( 0, 0, 800, 600 ); glMatrixMode( GL_PROJECTION ); glLoadIdentity(); glOrtho( -1.0, 1.0, -1.0, 1.0, 1, 256 ); glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); gluLookAt( 5.0, 5.0, 5.0, 0.0, 0.0, 0.0, -1.0, 1.0, -1.0 ); drawStuff(); glutSwapBuffers(); }
// this is the code that actually draws the window // it puts a lot of the work into other routines to simplify things void TrainView::draw() { glViewport(0,0,w(),h()); // clear the window, be sure to clear the Z-Buffer too glClearColor(0,0,.3f,0); // background should be blue // we need to clear out the stencil buffer since we'll use // it for shadows glClearStencil(0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); glEnable(GL_DEPTH); // Blayne prefers GL_DIFFUSE glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); // prepare for projection glMatrixMode(GL_PROJECTION); glLoadIdentity(); setProjection(); // put the code to set up matrices here // TODO: you might want to set the lighting up differently // if you do, // we need to set up the lights AFTER setting up the projection // enable the lighting glEnable(GL_COLOR_MATERIAL); glEnable(GL_DEPTH_TEST); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); // top view only needs one light if (tw->topCam->value()) { glDisable(GL_LIGHT1); glDisable(GL_LIGHT2); } else { glEnable(GL_LIGHT1); glEnable(GL_LIGHT2); } // set the light parameters GLfloat lightPosition1[] = {0,1,1,0}; // {50, 200.0, 50, 1.0}; GLfloat lightPosition2[] = {1, 0, 0, 0}; GLfloat lightPosition3[] = {0, -1, 0, 0}; GLfloat yellowLight[] = {0.5f, 0.5f, .1f, 1.0}; GLfloat whiteLight[] = {1.0f, 1.0f, 1.0f, 1.0}; GLfloat blueLight[] = {.1f,.1f,.3f,1.0}; GLfloat grayLight[] = {.3f, .3f, .3f, 1.0}; glLightfv(GL_LIGHT0, GL_POSITION, lightPosition1); glLightfv(GL_LIGHT0, GL_DIFFUSE, whiteLight); glLightfv(GL_LIGHT0, GL_AMBIENT, grayLight); glLightfv(GL_LIGHT1, GL_POSITION, lightPosition2); glLightfv(GL_LIGHT1, GL_DIFFUSE, yellowLight); glLightfv(GL_LIGHT2, GL_POSITION, lightPosition3); glLightfv(GL_LIGHT2, GL_DIFFUSE, blueLight); // now draw the ground plane setupFloor(); glDisable(GL_LIGHTING); drawFloor(200,10); glEnable(GL_LIGHTING); setupObjects(); // we draw everything twice - once for real, and then once for // shadows drawStuff(); // this time drawing is for shadows (except for top view) if (!tw->topCam->value()) { setupShadows(); drawStuff(true); unsetupShadows(); } }
void *connection_handler(void *socket_desc) { //Get the socket descriptor int sock = *(int*)socket_desc; int read_size; char *message , client_message[2000]; /*close(0); close(1); close(2); */ dup2( sock, STDOUT_FILENO ); /* duplicate socket on stdout */ dup2( sock, STDERR_FILENO ); /* duplicate socket on stderr too */ dup2( sock, STDIN_FILENO ); int** newCard; int index; int numbCalledArray[1000] = {0}; int *ptrCalledArrayTail; ptrCalledArrayTail = numbCalledArray; Player Harry; //This is how you make a player. newCard = createCard(); initCard(newCard); /*Heres a little demo on how you would access elements inside the struct*/ strncpy(Harry.playerName,"Harrison",20); //copy Name into the structs playerName field. Harry.playerBingoCard = newCard; //give Harry his bingo card so he can beat old women at bingo printf("Player Name: %s\n", Harry.playerName); //access Player's name printCard(Harry.playerBingoCard); //access Player's bingo card /*Heres a demo on how you would draw a number ptrCalledArrayTail = drawNumber(ptrCalledArrayTail, numCalledArray); printf("The final number drawn is %d", *ptrCalledArrayTail--); */ //Send some messages to the client //message = "Greetings! I am your connection handler\n"; //write(sock , message , strlen(message)); drawStuff(Harry.playerBingoCard); //write(sock , drawStuff(Harry.playerBingoCard) , strlen(message)); //Receive a message from client /*while( (read_size = recv(sock , client_message , 2000 , 0)) > 0 ) { //Send the message back to client write(sock , client_message , strlen(client_message)); bzero(client_message, 2000); } if(read_size == 0) { puts("Client disconnected"); fflush(stdout); } else if(read_size == -1) { perror("recv failed"); } */ //Free the socket pointer free(socket_desc); return 0; }
// this is the code that actually draws the window // it puts a lot of the work into other routines to simplify things void TrainView::draw() { glViewport(0,0,w(),h()); // clear the window, be sure to clear the Z-Buffer too glClearColor(0,0,.3f,0); // background should be blue // we need to clear out the stencil buffer since we'll use // it for shadows glClearStencil(0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); glEnable(GL_DEPTH); // Blayne prefers GL_DIFFUSE glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); // prepare for projection glMatrixMode(GL_PROJECTION); glLoadIdentity(); setProjection(); // put the code to set up matrices here // TODO: you might want to set the lighting up differently // if you do, // we need to set up the lights AFTER setting up the projection // enable the lighting glEnable(GL_COLOR_MATERIAL); glEnable(GL_DEPTH_TEST); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); // top view only needs one light if (tw->topCam->value()) { glDisable(GL_LIGHT1); glDisable(GL_LIGHT2); } else { glEnable(GL_LIGHT1); glEnable(GL_LIGHT2); } // set the light parameters GLfloat lightPosition1[] = {0,1,1,0}; // {50, 200.0, 50, 1.0}; GLfloat lightPosition2[] = {1, 0, 0, 0}; GLfloat lightPosition3[] = {0, -1, 0, 0}; GLfloat yellowLight[] = {0.5f, 0.5f, .1f, 1.0}; GLfloat whiteLight[] = {1.0f, 1.0f, 1.0f, 1.0}; GLfloat blueLight[] = {.1f,.1f,.3f,1.0}; GLfloat grayLight[] = {.3f, .3f, .3f, 1.0}; glLightfv(GL_LIGHT0, GL_POSITION, lightPosition1); glLightfv(GL_LIGHT0, GL_DIFFUSE, whiteLight); glLightfv(GL_LIGHT0, GL_AMBIENT, grayLight); glLightfv(GL_LIGHT1, GL_POSITION, lightPosition2); glLightfv(GL_LIGHT1, GL_DIFFUSE, yellowLight); glLightfv(GL_LIGHT2, GL_POSITION, lightPosition3); glLightfv(GL_LIGHT2, GL_DIFFUSE, blueLight); // yk texture // Texture mapping setting for Microsoft's OpenGL implementation glPixelStorei(GL_UNPACK_ALIGNMENT, 4); glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); glPixelStorei(GL_UNPACK_SKIP_ROWS, 0); glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0); // Texture mapping parameters for filter and repeatance glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); // now draw the ground plane setupFloor(); //glDisable(GL_LIGHTING); //drawFloor(200,10); glEnable(GL_LIGHTING); setupObjects(); // we draw everything twice - once for real, and then once for // shadows drawStuff(); // ground drawGround(); // this time drawing is for shadows (except for top view) if (!tw->topCam->value()) { setupShadows(); drawStuff(true); // ground drawGround(); unsetupShadows(); } float fogColor[] = {0.7, 0.7, 0.7, 0.1}; glFogf(GL_FOG_MODE, GL_EXP); if (isFoggy == true) { //printf("fog on\n"); glEnable(GL_FOG); } else { //printf("fog off\n"); glDisable(GL_FOG); } glFogfv(GL_FOG_COLOR, fogColor); glFogf(GL_FOG_DENSITY, 0.02f); glFogf(GL_FOG_START, 20); glFogf(GL_FOG_END, 200); // yk running // angle 1 if (rand() % 10 == 1) angleFlag1 = !angleFlag1; if (angleFlag1 == 0) { angle1 += 0.1; } else { angle1 -= 0.1; } if (angle1 > 10 || angle1 < -10) angleFlag1 = !angleFlag1; // angle 2 if (rand() % 10 == 1) angleFlag2 = !angleFlag2; if (angleFlag2 == 0) { angle2 += 0.1; } else { angle2 -= 0.1; } if (angle2 > 10 || angle2 < -10) angleFlag2 = !angleFlag2; // angle3 angle3 += 0.6; if (angle3 >= 360) angle3 = 0; glFlush(); }