Jump to content
    

Быстрое отображение динамических данных

Посоветуйте, пожалуйста, на какой основе сделать быстрое графическое отображение

динамических данных в Windows? (1000 линий 30 fps)

(Direct2d , DirectX, OpenGL или что-то еще ?)

Share this post


Link to post
Share on other sites

Какие данные?

30 fps - это видео/кино.

Если речь о 2- и 3-мерных графиках, то если они будут дергаться со скоростью 30 fps, глазам будет некомфортно.

А вообще я делал спектроанализатор в WPF на С#, скорости хватало. Точнее, графика - в WPF, остальное (работа со звуковой картой, БПФ) - просто на Си. Еще точнее, БПФ - открытый пакет fftw.org, звуковуха из winAPI

Share this post


Link to post
Share on other sites

fltk 100000 рандомных линий отрисовывает примерно 480мс.

opengl даже через glbegin/end на каждую линию - за почти те же 580мс успевает отрисовать миллион линий.

 

 

#include "FL/Fl.h"
#include "FL/fl_draw.h"
#include "FL/Fl_Double_Window.h"
#include "FL/Fl_GL_Window.h"
#include <FL/gl.h>

#include "stdlib.h"

#pragma comment (lib, "fltk.lib")
#pragma comment (lib, "opengl32.lib")
#pragma comment (lib, "fltkgl.lib")


class MyWindow : public Fl_Double_Window {
  void draw(){
    for(int i = 0; i<100000; i++){
      fl_color(rand()*255/RAND_MAX,rand()*255/RAND_MAX,rand()*255/RAND_MAX);
      fl_line(rand()*1000/RAND_MAX,rand()*1000/RAND_MAX,rand()*1000/RAND_MAX,rand()*1000/RAND_MAX);
    }
  }
public:
  MyWindow(int X, int Y, int W, int H, const char *L) : Fl_Double_Window(X, Y, W, H, L) {}
};

class MyGLWindow : public Fl_Gl_Window {
  void draw(){
    if (!valid()) {
      glLoadIdentity();
      glViewport(0,0,w(),h());
      glOrtho(-w(),w(),-h(),h(),-1,1);
    }
    glClear(GL_COLOR_BUFFER_BIT);
    for(int i = 0; i<1000000; i++){
      glColor3f(1.0f*rand()/RAND_MAX, 1.0f*rand()/RAND_MAX, 1.0f*rand()/RAND_MAX);
      glBegin(GL_LINE_STRIP); 
      glVertex2f(w()*(2.0f*rand()/RAND_MAX-1), h()*(2.0f*rand()/RAND_MAX-1)); 
      glVertex2f(w()*(2.0f*rand()/RAND_MAX-1), h()*(2.0f*rand()/RAND_MAX-1)); 
      glEnd();
    }
  }
public:
  MyGLWindow(int X, int Y, int W, int H, const char *L) : Fl_Gl_Window(X, Y, W, H, L) {}
};


void callback(void * w) {
  static int t0 = GetTickCount();
  int t1 = GetTickCount();
  printf("%d\n",t1-t0);
  t0 = t1;
  ((MyGLWindow *)w)->redraw();
  Fl::repeat_timeout(1.0/50, callback, w);
}

int main(){
//  MyWindow win(100,100,1000,1000,"Test");
  MyGLWindow win(100,100,1000,1000,"Test");
  win.show();
  Fl::add_timeout(1.0/50, callback, &win);
  return(Fl::run());
}

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...