Esempio n. 1
0
void glwidget::draw_decorating_info()
{
    // draw_pointer
    draw_pointer(nav);
    // draw orientation
    draw_orientation(nav);


    //error OpenGL_drawer_2
    GLenum errCode;
    const GLubyte *errString;
    if((errCode=glGetError()) != GL_NO_ERROR)
      {
        errString = gluErrorString(errCode);
        std::cout<<"OPENGL ERROR : "<<errString<<std::endl;
        //exit(-2);
      }


    //update fps
    nav.increase_frame_number();
    nav.time()=t_timer.elapsed();
    if(nav.delta_time()>1000)
        nav.update_fps();


    //draw fps
    draw_fps();


    //draw bottom right zoom
    draw_camera_stat();
}
Esempio n. 2
0
void render_hud(int width,int height, ApplicationInfo app){
  for(int x = 0;x< app.hud.num_windows;x++){
    if(app.hud.windows[x].on) draw_window(app.hud.windows[x],app);
  }
  draw_fps(width,app);        //Draw last
  draw_userinput(height,app);  //So visible
}
Esempio n. 3
0
void draw(World * w)
{
	memset(screen_buffer, 0, sizeof(CHAR_INFO) * BUFFER_CX * BUFFER_CY);
	draw_map(w);
	draw_system(w);
	draw_fps();
	write_scr((CHAR_INFO *) screen_buffer, BUFFER_CX, BUFFER_CY);
}
void Renderer::Pass2(const Pipeline &pipeline, const PipelineContext &pipelineContext)
{
	//BEGIN PASS 2
	//
	//end of texture rendering
	//now we copy the texture from the FBO or framebuffer to
	//video texture memory and render fullscreen.

	/** Reset the viewport size */
#ifdef USE_FBO
	if (renderTarget->renderToTexture)
	{
		glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, this->renderTarget->fbuffer[1]);
		glViewport(0, 0, this->renderTarget->texsize, this->renderTarget->texsize);
	}
	else
#endif
		glViewport(0, 0, this->vw, this->vh);

	glBindTexture(GL_TEXTURE_2D, this->renderTarget->textureID[0]);

	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
#ifdef USE_GLES1
	glOrthof(-0.5, 0.5, -0.5, 0.5, -40, 40);
#else
	glOrtho(-0.5, 0.5, -0.5, 0.5, -40, 40);
#endif
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

	glLineWidth(this->renderTarget->texsize < 512 ? 1 : this->renderTarget->texsize / 512.0);

	CompositeOutput(pipeline, pipelineContext);

	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	glTranslatef(-0.5, -0.5, 0);

	// When console refreshes, there is a chance the preset has been changed by the user
	refreshConsole();
	draw_title_to_screen(false);
	if (this->showhelp % 2)
		draw_help();
	if (this->showtitle % 2)
		draw_title();
	if (this->showfps % 2)
		draw_fps(this->realfps);
	if (this->showpreset % 2)
		draw_preset();
	if (this->showstats % 2)
		draw_stats();
	glTranslatef(0.5, 0.5, 0);

#ifdef USE_FBO
	if (renderTarget->renderToTexture)
		glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
#endif
}
Esempio n. 5
0
void graph_main(){
	graph_enemy();//敵の描画
	graph_bom();//ボム
	graph_ch();//自機の描画
	graph_bullet();//弾の描画
	graph_board();//ボードの描画
	graph_board_states();//ボード情報の描画
	draw_fps(620,465);//fps描画
	graph_spell();//スペル文字の描画
}
Esempio n. 6
0
void View::pre_display()
{
  //info("display: lock");
  view_sync.enter();

  //begin time measuring
  double time_start = get_tick_count();

  //antialising is supported through accumulation buffer (FIXME: use ARB_MULTISAMPLE if available)
  if (!hq_frame)
  {
    clear_background();
    on_display();
  }
  else
  {
    display_antialiased();
    hq_frame = false;
  }

  if (b_help) draw_help();
  else if (b_scale) scale_dispatch();

  //draw current rendring time
# ifdef _DEBUG
  draw_fps();
# endif

  //wait to finish
  glFinish();

  //calculate statistics
  rendering_frames[rendering_frames_top] = get_tick_count() - time_start;
  rendering_frames_top = (rendering_frames_top + 1) % FPS_FRAME_SIZE;

  if (want_screenshot)
  {
    glReadBuffer(GL_BACK_LEFT);
    save_screenshot_internal(screenshot_filename.c_str());
    want_screenshot = false;
  }

  glutSwapBuffers();

  //frame synchronization
  frame_ready = true;
  view_sync.signal_drawing_finished();
  view_sync.leave();
}
Esempio n. 7
0
//--------------------------------------------------------------
void testApp::draw(){
	int x, y;
	
	ofBackground(255,0,0);
	
	float cut_x = 1.0;
	float cut_y = fabs(sin(TWO_PI * ((counter%60)/60.0f)));
	ofSetColor(0,255,255);
	ofRect(0,0,cut_x*ofGetWidth(),cut_y*ofGetHeight());
	
	draw_fps();
	
	// Draw to Facam!
	fakam.copyScreen();
}
Esempio n. 8
0
void
ScreenManager::draw(Compositor& compositor)
{
  assert(!m_screen_stack.empty());

  static Uint32 fps_ticks = SDL_GetTicks();

  // draw the actual screen
  m_screen_stack.back()->draw(compositor);

  // draw effects and hud
  auto& context = compositor.make_context(true);
  m_menu_manager->draw(context);

  if (m_screen_fade)
  {
    m_screen_fade->draw(context);
  }

  Console::current()->draw(context);

  if (g_config->show_fps)
  {
    draw_fps(context, m_fps);
  }

  if (g_config->show_player_pos)
  {
    draw_player_pos(context);
  }

  // render everything
  compositor.render();

  /* Calculate frames per second */
  if (g_config->show_fps)
  {
    static int frame_count = 0;
    ++frame_count;

    if (SDL_GetTicks() - fps_ticks >= 500)
    {
      m_fps = static_cast<float>(frame_count) / 0.5f;
      frame_count = 0;
      fps_ticks = SDL_GetTicks();
    }
  }
}
Esempio n. 9
0
void graph_pause(){
	graph_board();//ボードの描画
	graph_board_states();//ボード情報の描画
	draw_fps(620,465);//fps描画

	DrawStringToHandle(170,120,"PAUSE",color[0],font[1]);
	//リプレイ再生中は表示名を変更
	if(replay_flag == 1){
		DrawStringToHandle(170,240,"再生を続ける",color[0],font[0]);
		DrawStringToHandle(160,280,"タイトルに戻る",color[0],font[0]);
		DrawStringToHandle(170,320,"最初から再生",color[0],font[0]);
	}else{
		DrawStringToHandle(160,240,"ゲームを続ける",color[0],font[0]);
		DrawStringToHandle(160,280,"タイトルに戻る",color[0],font[0]);
		DrawStringToHandle(160,320,"最初から始める",color[0],font[0]);
	}
	DrawStringToHandle(140,240+(menu_state*40),"→",color[0],font[0]);
}
Esempio n. 10
0
int main(int argc, char **argv)
{
    CvCapture *capture  = 0;
    IplImage  *frame    = 0;
    CvSeq     *faces    = 0;
    FILE      *out_fp   = 0;
    
    char  key_pressed = 0;
    int   prev_faces  = 0;
    int   delay_mili  = 0;
    int n;

    clock_t start,end; /*  for measuring fps */

    distance_range distances[MAX_FACES];
    

    check_cli(argc,argv);

    printf("Registering camera input...\n");
    if( ( capture = cvCreateCameraCapture( CAM_DEV_NUM ) ) == NULL )
    {
        printf("Can't connect to the camera!\n");
        exit(1);
    }

    printf("Loading face classifier data...\n");
    cascade = ( CvHaarClassifierCascade *) cvLoad( haar_data_file, 0, 0, 0 );
    if( cascade == NULL )
    {
        printf("Can't load classifier data!\n");
        exit(1);
    }

    printf("Initializating font...\n");
    cvInitFont(&font, CV_FONT_HERSHEY_PLAIN, 1.0, 1.0, 0.0 );

    printf("Opening output file...\n");
    if( (out_fp = fopen(output_file,"w")) == NULL )
    {
        printf("Can't open output file: %s\n",output_file );
        usage(argv[0]);
        return -1;
    }


    /* Allocate calculation memory pool */
    storage = cvCreateMemStorage(0);

    /*  Create display window */
    if(!no_gui)
        cvNamedWindow( WINDOW_NAME, CV_WINDOW_AUTOSIZE );
    
    while(1) 
    {
        start = clock(); 

        frame = cvQueryFrame( capture );
        if(!frame)
            break;

        /* Get all the faces on the current frame */
        faces = detect_faces(frame);

        /* 
         * Differren number of faces detected, make sure it's not a 
         * single frame mistake (they happen randomly). 
         */
        if( faces->total != prev_faces && faces->total > 0)
        {
            /*  reopen file to clear it */
            fclose(out_fp);
            out_fp  = fopen(output_file, "w");
            prev_faces = faces->total;
            continue;
        }

        /*
         * Get distances between faces and the camera
         */
        n = get_distances(faces, distances);
        write_to_file(out_fp, distances, n);

        /*
         * Draw the result on the screen
         */
        if(!no_gui)
        {
            select_faces(frame, faces);
            draw_distances(frame, faces);
            draw_fps(frame,actual_fps);
            cvShowImage(WINDOW_NAME, frame);
        }

        /* 
         * Count the delay time to get wanted number of FPS. Time of execution
         * of previous functions has to be considered.
         */
        end = clock();
        delay_mili = (1/(double)wanted_fps)*1000; 
        delay_mili-= (int)(end-start)/(double)CLOCKS_PER_SEC*1000;
        if(delay_mili < MIN_FRAME_DELAY )
            delay_mili = MIN_FRAME_DELAY;
        
        /*
         * Check if the close button was pressed
         */
        key_pressed = cvWaitKey( delay_mili ) ;
        if( key_pressed == CLOSE_BUTTON) 
            break;
        
        end = clock();
        actual_fps = (int)round(1/((double)(end-start)/(double)CLOCKS_PER_SEC)); 
    }
    
    cvReleaseCapture( & capture );
    
    if(!no_gui)
        cvDestroyWindow( WINDOW_NAME );

    fclose(out_fp);
    free_camera_data();

    return 0;
}
Esempio n. 11
0
int main(){


    TempSettings gamesettings;

    gamesettings.mapw = 10;
    gamesettings.maph = 6;
    gamesettings.mapx = 0;
    gamesettings.mapy = 0;
    gamesettings.mapmidx = gamesettings.mapw/2.0;
    gamesettings.mapmidy = gamesettings.maph/2.0;
    gamesettings.window_width = 1300;
    gamesettings.window_height = 800;

    // initialize window, renderer, textures
    if (SDL_Init(SDL_INIT_EVERYTHING) != 0){
        std::cerr << "SDL_Init error: " << SDL_GetError() << std::endl;
        return 1;
    }

    if (TTF_Init() != 0){
        std::cerr << "TTF_Init error: " << SDL_GetError() << std::endl;
        SDL_Quit();
        return 1;
    }

    SDL_Window* window = SDL_CreateWindow("deathblade_floating", 0, 0, gamesettings.window_width, gamesettings.window_height, SDL_WINDOW_SHOWN);
    if (window == nullptr){
        std::cerr << "SDL_CreateWindow error: " << SDL_GetError() << std::endl;
        SDL_Quit();
        return 1;
    }

    SDL_Renderer* renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
    if (renderer == nullptr){
        std::cerr << "SDL_CreateRenderer error: " << SDL_GetError() << std::endl;
        SDL_DestroyWindow(window);
        SDL_Quit();
        return 1;
    }
    std::string resource_path = getResourcePath("");
    std::string charfile = resource_path + "initialcharacter.png";
    std::string bgfile = resource_path + "initialbackgroundtile.png";
    std::string starfile = resource_path + "star.png";
    std::string wallfile = resource_path + "wall.png";
    SDL_Texture* character_texture = IMG_LoadTexture(renderer, charfile.c_str());
    SDL_Texture* bgtile_texture = IMG_LoadTexture(renderer, bgfile.c_str());
    SDL_Texture* star_texture = IMG_LoadTexture(renderer, starfile.c_str());
    SDL_Texture* wall_texture = IMG_LoadTexture(renderer,wallfile.c_str());
    if (character_texture == nullptr || bgtile_texture == nullptr || star_texture == nullptr || wall_texture == nullptr){
            std::cerr << "IMG_LoadTexture error: " << SDL_GetError() << std::endl;
            SDL_DestroyTexture(character_texture);
            SDL_DestroyTexture(bgtile_texture);
            SDL_DestroyRenderer(renderer);
            SDL_DestroyWindow(window);
            SDL_Quit();
            return 1;
    }

    std::string fontfile = resource_path + "sample.ttf";
    TTF_Font* font = TTF_OpenFont(fontfile.c_str(), 15);
    if (font == NULL){
        std::cerr << "TTF_OpenFont error: " << SDL_GetError() << std::endl;
    }


	CameraControl camera(&gamesettings);
    ObjectController objects;
    DeveloperConsoleClass console(&gamesettings);
    console.add_controller(&console);
    console.add_controller(&camera);

    const double tilew = 0.5;
    const double tileh = 0.5;
    double mousex = gamesettings.mapmidx;
    double mousey = gamesettings.mapmidy;
    int mousepx = gamesettings.window_width/2;
    int mousepy = gamesettings.window_height/2;

    double wallthickness = 0.1;
    TextureWall bottomwall, topwall, leftwall, rightwall;
    bottomwall.x = gamesettings.mapw/2;
    bottomwall.y = gamesettings.maph+wallthickness/2;
    bottomwall.setTexture(wall_texture,gamesettings.mapw,wallthickness);
    objects.add_object(&bottomwall);

    topwall.x = gamesettings.mapw/2;
    topwall.y = -wallthickness/2;
    topwall.setTexture(wall_texture,gamesettings.mapw,wallthickness);
    objects.add_object(&topwall);

    leftwall.x = -wallthickness/2;
    leftwall.y = gamesettings.maph/2;
    leftwall.setTexture(wall_texture,wallthickness,gamesettings.maph);
    objects.add_object(&leftwall);

    rightwall.x = gamesettings.mapw + wallthickness/2;
    rightwall.y = gamesettings.maph/2;
    rightwall.setTexture(wall_texture,wallthickness,gamesettings.maph);
    objects.add_object(&rightwall);

    Player human;
    human.x = 5; human.y = 5;
    human.dx = -0.025; human.dy = -0.03;
    human.setTexture(character_texture, 0.05, 0.05);
    objects.add_object(&human);

    // map x [0, 10]
    // map y [0,  6]
    // star width 0.256
    std::vector<vec2d> star_positions = {
        vec2d(6,4),
        vec2d(3,4.1),
        vec2d(9,0.2),
        vec2d(1,0.4),
        vec2d(2,2.5),
        vec2d(3,2.5),
        vec2d(9,4.9),
        vec2d(0.2,5.1),
        vec2d(4.1,4.1)
    };
    std::vector<double> star_thetas = {
        0,
        45,
        15,
        60,
        85,
        4,
        50,
        66,
        31
    };

    std::vector<Star*> star_field;
    for(unsigned int i = 0; i < star_positions.size(); ++i){
        Star* newstar = new Star();

        newstar->x = star_positions[i].x;
        newstar->y = star_positions[i].y;
        newstar->setTexture(star_texture, 0.256, 0.256);

        if(i < star_thetas.size())
            newstar->rotate(star_thetas[i]*3.14159265359/180.0);


        star_field.push_back(newstar);
        objects.add_object(star_field[i]);

    }

    bool rightmouse_down = false;

    SDL_Event event;	
    bool quitnow = false;
    Uint32 fps_lastframe = SDL_GetTicks();
    while(!quitnow){
		
        int zoomdirection = 0;

        while(SDL_PollEvent(&event)){

            if (console.is_active()){
                if (event.type == SDL_KEYDOWN){
                    switch(event.key.keysym.sym){
                    case SDLK_BACKQUOTE:
                        console.toggle();
                        break;
                    case SDLK_BACKSPACE:
                        console.backspace();
                        break;
                    case SDLK_RETURN:
                    case SDLK_RETURN2:
                        console.enter();
                        break;
                    case SDLK_UP:
                        console.goback_inhistory();
                        break;
                    case SDLK_DOWN:
                        console.goforward_inhistory();
                        break;
                    default:
                        break;
                    }
                    console.render_current_command(renderer);

                }
                else if (event.type == SDL_TEXTINPUT && event.text.text[0] != '`'){
                    console.addinput(event.text.text);
                    console.render_current_command(renderer);
                }
                else if (event.type == SDL_MOUSEBUTTONDOWN){
                    if (event.button.button == SDL_BUTTON_LEFT){
                        if(!console.mouse_grab(true, event.button.x, event.button.y))
                            camera.mousecontrol_on();
                    }
                    //if (event.button.button == SDL_BUTTON_RIGHT)

                }
                else if (event.type == SDL_MOUSEBUTTONUP){
                    if (event.button.button == SDL_BUTTON_LEFT){
                        console.mouse_grab(false, -1,-1);
                        camera.mousecontrol_off();
                    }
                }
                else if (event.type == SDL_MOUSEMOTION){
                    mousepx = event.motion.x;
                    mousepy = event.motion.y;
                    console.handle_mouse(event.motion.xrel, event.motion.yrel);

                    if (camera.mouse_controlling()){
                        camera.mousecontrol_move(mousepx, mousepy, event.motion.xrel, event.motion.yrel,SDL_GetModState()==KMOD_LCTRL);
                    }
                    else{
                        mousex = camera.xfrompixel(event.motion.x, event.motion.y, db::Player);
                        mousey = camera.yfrompixel(event.motion.x, event.motion.y, db::Player);
                    }
                }
                else if (event.type == SDL_MOUSEWHEEL){
                    if(!console.scroll(event.wheel.y, mousepx, mousepy))
                        zoomdirection += event.wheel.y;
                }
                else if (event.type == SDL_QUIT){
                    quitnow = true;
                }

                continue;
            }

            // if console is not up
            if (event.type == SDL_KEYDOWN){
                switch(event.key.keysym.sym){
                case SDLK_ESCAPE:
                        quitnow = true;
                        break;
                case SDLK_BACKQUOTE:
                    console.toggle();
                    break;
                case SDLK_t:
                    if (!camera.is_tracking())
                        camera.track_object(&(human.x), &(human.y));
                    else
                        camera.stop_tracking();
                    break;
                case SDLK_w:
                case SDLK_UP:
                    camera.pan_updown(-1);
                    break;
                case SDLK_a:
                case SDLK_LEFT:
                    camera.pan_leftright(-1);
                    break;
                case SDLK_s:
                case SDLK_DOWN:
                    camera.pan_updown(1);
                    break;
                case SDLK_d:
                case SDLK_RIGHT:
                    camera.pan_leftright(1);
                    break;
                default:
                    break;
                }
            }
            else if (event.type == SDL_KEYUP){
                switch(event.key.keysym.sym){
                case SDLK_w:
                case SDLK_UP:
                    camera.pan_updown(0);
                    break;
                case SDLK_a:
                case SDLK_LEFT:
                    camera.pan_leftright(0);
                    break;
                case SDLK_s:
                case SDLK_DOWN:
                    camera.pan_updown(0);
                    break;
                case SDLK_d:
                case SDLK_RIGHT:
                    camera.pan_leftright(0);
                    break;
                default:
                    break;
                }
            }
            else if (event.type == SDL_MOUSEBUTTONDOWN){
                if (event.button.button == SDL_BUTTON_LEFT){
                    camera.mousecontrol_on();
                }
                else if (event.button.button == SDL_BUTTON_RIGHT){
                    rightmouse_down = true;
                    human.bound.xclick = camera.xfrompixel(event.button.x,event.button.y,db::Player);
                    human.bound.yclick = camera.yfrompixel(event.button.x,event.button.y,db::Player);
                    human.bound.xdrag = 0;
                    human.bound.ydrag = 0;
                    human.bound.enabled = true;
                }
            }
            else if (event.type == SDL_MOUSEBUTTONUP){
                if (event.button.button == SDL_BUTTON_LEFT){
                    camera.mousecontrol_off();
                }
                else if (event.button.button == SDL_BUTTON_RIGHT){
                    rightmouse_down = false;
                }
            }
            else if (event.type == SDL_MOUSEWHEEL){
                zoomdirection += event.wheel.y;
            }
            else if (event.type == SDL_MOUSEMOTION){
                mousepx = event.motion.x;
                mousepy = event.motion.y;

                if (camera.mouse_controlling()){
                    camera.mousecontrol_move(mousepx, mousepy, event.motion.xrel, event.motion.yrel,SDL_GetModState()==KMOD_LCTRL);
                }
                else{
                    mousex = camera.xfrompixel(event.motion.x, event.motion.y, db::Player);
                    mousey = camera.yfrompixel(event.motion.x, event.motion.y, db::Player);
                    if(mousepx <= 1) camera.pan_leftright(-1);
                    else if (mousepx >= (int)gamesettings.window_width-1) camera.pan_leftright(1);
                    else if (mousepx - event.motion.xrel <= 1) camera.pan_leftright(0);
                    else if (mousepx - event.motion.xrel >= (int)gamesettings.window_width-1) camera.pan_leftright(0);
                    if(mousepy <= 1) camera.pan_updown(-1);
                    else if (mousepy >= (int)gamesettings.window_height-1) camera.pan_updown(1);
                    else if (mousepy - event.motion.yrel <= 1) camera.pan_updown(0);
                    else if (mousepy - event.motion.yrel >= (int)gamesettings.window_height-1) camera.pan_updown(0);

                    if(rightmouse_down){
                        human.bound.xdrag += event.motion.xrel;
                        human.bound.ydrag += event.motion.yrel;
                    }
                }

            }
            else if (event.type == SDL_QUIT){
                quitnow = true;
            }
	
        }


        objects.step_time();

        SDL_SetRenderDrawColor(renderer, 0,0,0,255);
        SDL_RenderClear(renderer);

        camera.adjust_zoom(zoomdirection, mousex, mousey);
		
        for (double x = gamesettings.mapx+tilew/2; x < gamesettings.mapx+gamesettings.mapw+tilew/2; x += tilew){
            for (double y = gamesettings.mapy+tileh/2; y < gamesettings.mapy+gamesettings.maph+tileh/2; y += tileh){
                SDL_Rect dst = camera.calculate_display_destination(x,y,tilew,tileh,db::Floor);
                SDL_RenderCopyEx(renderer, bgtile_texture, NULL, &dst, -camera.camyaw*180.0/3.14156033, NULL, SDL_FLIP_NONE);
            }
        }

        objects.drawon(renderer, &camera);
        if(console.is_active()) console.drawon(renderer);
        human.bound.drawon(renderer, &camera);


        Uint32 fps_newframe = SDL_GetTicks();
        if((fps_newframe-fps_lastframe) < SCREEN_TICKS_PER_FRAME){
            SDL_Delay(SCREEN_TICKS_PER_FRAME - (fps_newframe-fps_lastframe));
        }
        draw_fps(renderer, font, 1.0/(fps_newframe/1000.0 - fps_lastframe/1000.0));
        fps_lastframe = fps_newframe;

        SDL_RenderPresent(renderer);
	}
    SDL_DestroyTexture(character_texture);
	SDL_DestroyTexture(bgtile_texture);
    SDL_DestroyRenderer(renderer);
    SDL_DestroyWindow(window);
    SDL_Quit();

    for(unsigned int i = 0; i < star_field.size(); ++i)
        delete star_field[i];

    return 0;
}