I want to double buffer the ncurses library pad

  c++, ncurses
[I’m Japanese and using google translate to ask questions]

Thing you want to do

I want to double buffer the pad

Contents of question

The code inside the //// comment of the presentation code, but I want to know why double buffering is not performed.
void Screen::Renderer()const Function

Reference site A: https://docs.oracle.com/cd/E19455-01/816-3323/6m9k40u28/index.html

Reference site B: http://linuxmag.osdn.jp/Japanese/March2002/article233.shtml#233lfindex3

Reference site C: https://pubs.opengroup.org/onlinepubs/7908799/xcurses/newpad.html

Screen.cpp
#include "../header/Screen.hpp"


#include "../header/Character.hpp"
#include "../header/Color.hpp"
#include "../header/Vector.hpp"



// ######################## コンストラクタ ######################## 
Screen::Screen(int x,int y,int xMin,int yMin,int xMax,int yMax)
{

      //ウインドウ初期化
    //getmaxyx(stdscr,windowSize.y,windowSize.x);
    window = newpad(yMax - yMin,xMax - xMin);
    //prefresh(window,posY,posX,posY,posX,posY + sizeY,posX + sizeX);
    prefresh(window,y,x,yMin,xMin,yMax,xMax);

      position.x = x;
      position.y = y;

      size.x = xMax - xMin;
      size.y = yMax - yMin;
      
      maxSize = size.x * size.y;

      stage = std::make_unique<std::vector<Character>>(size.x * size.y);
      
      for(std::vector<Character>::iterator itr = stage->begin(); itr != stage->end(); itr++)
      {
            itr->chr = ' ';
            itr->color = GetColorNum(2,2);
            itr->type = 0;
      }
}


// ######################## 移動 ########################
void Screen::Move(int x,int y)
{
      position.x = x;
      position.y = y;

    prefresh(window,position.y,position.x,position.y,position.x,position.y + size.y,position.x + size.x);       
}


// ######################## 画面サイズ更新 ########################
void Screen::UpdateScreen()
{

}



// ######################## Update ########################
void Screen::Update()
{
      
}

// ######################## 文字設定 ######################## 
void Screen::Input(int x,int y,Character c)
{
      stage->at((y * size.x) + x) = c;
}

// ######################## 文字削除 ######################## 
void Screen::Delete(int x,int y)
{
      stage->at((y * size.x) + x).chr = ' ';
      stage->at((y * size.x) + x).color = 0;
      stage->at((y * size.x) + x).type = 0;
}
/////////////////////////////////////////////////////////////////////////////////////////
// ######################## Renderer ######################## 
void Screen::Renderer()const
{
      //clear();
      werase(window);
      //erase();

      for(int y = 0; y < size.y; y++)
      {
            for(int x = 0; x < size.x; x++)
            {
                  wattron(window,COLOR_PAIR(stage->at((y * size.x) + x).color));

                  mvwaddch(window,position.y + y,position.x + x,stage->at((y * size.x) + x).chr);
                  
                  wattroff(window,COLOR_PAIR(stage->at((y * size.x) + x).color));

            }
      }

      wrefresh(window); //描画
      //refresh();

}
/////////////////////////////////////////////////////////////////////////////////////////
// ######################## デストラクタ ######################## 
Screen::~Screen()
{


}

Source: Windows Questions C++

LEAVE A COMMENT