本文整理汇总了C++中GLWindow::update方法的典型用法代码示例。如果您正苦于以下问题:C++ GLWindow::update方法的具体用法?C++ GLWindow::update怎么用?C++ GLWindow::update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GLWindow
的用法示例。
在下文中一共展示了GLWindow::update方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char* argv[])
{
try
{
char* testname_args1[] = {"program.exe","antialias_amount=8 width=1280 height=720 window_name", " =multisampled is_antialiased=true"};
char* testname_args2[] = {"program.exe","width=1280 height=720", ""};
GLWindow glWindow = GLWindow(GLWindow::Settings(3, testname_args1));
GLWindow glWindow2 = GLWindow(GLWindow::Settings(3, testname_args2));
PCInputBinding b;
PCInputBinding b2;
b2.bindButtonDown('a', print);
b.bindButtonDown('a', playBeep);
b.bindButtonDown(PCInputBinding::MOUSE_BUTTON_4, button4);
b.bindButtonDown(PCInputBinding::MOUSE_BUTTON_5, button5);
std::function< void () > quit = std::bind(&GLWindow::close, &glWindow);
b.bindWindowClose( quit);
b.bindButtonDown(PCInputBinding::ESCAPE, quit);
//b.bindPowerStatusChange(powerTest);
b2.bindPowerStatusChange(powerTest);
quit = std::bind(&GLWindow::close, &glWindow2);
b2.bindButtonDown(PCInputBinding::ESCAPE, quit);
glWindow.use_binding(b);
glWindow2.use_binding(b2);
glWindow.bindContext();
glClearColor(1.0,0.0,0.0,1.0);
float dt=0.0;
bool once =false;
glWindow2.setTitle("Non-multisampled window test");
glWindow.setWindowLocation(100,100);
glWindow2.setWindowLocation(128,128);
while(glWindow.isValid() || glWindow2.isValid() )
{
dt += .001;
// std::cout<<dt<<std::endl;
std::stringstream sstr;
sstr<<"NON-MULTISAMPLED TEST:: BKGR COLOR INTERPOLATOR IS "<<(fabs(sin(dt)))<<std::endl;
std::string abc = sstr.str();
if(glWindow.bindContext()){
// glEnable(GL_MULTISAMPLE_ARB);
//the fact that we dont need the call to clear color here shows how the gl state is maintained separately between different rendering contexts
//glClearColor(1.0,0.0,0.0,1.0);
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_TRIANGLES);
//glClearColor(1.0,0.0,0.0,1.0);
//glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0,0.0,0.0);
glVertex3f(-1.0,1.0,0.0);
glColor3f(0.0,1.0,0.0);
glVertex3f(-1.0,-1.0,0.0);
glColor3f(0.0,0.0,1.0);
glVertex3f(1.0,-1.0,0.0);
glEnd();
glWindow.update();
glWindow.flush();
}
if(glWindow2.bindContext()){
glWindow2.setTitle(abc.c_str());
glClearColor(fabs(sin(dt)),1.0,0.0,1.0);
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_TRIANGLES);
//glClearColor(1.0,0.0,0.0,1.0);
//glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0,0.0,0.0);
glVertex3f(-1.0,1.0,0.0);
//.........这里部分代码省略.........
示例2: main
int main(int argc, char* argv[])
{
try
{
char* testname_args[] = {"program.exe","width=640 height=480 window_name", " =GL WINDOW TEST 1 is_fullscreen=false"};
GLWindow::Settings setts(3, testname_args) ;
GLWindow glWindow = GLWindow(setts);
setts.width=1280;
setts.height=720;
setts.is_fullscreen=true;
setts.is_antialiased = true;
setts.antialias_amount = 8;
//setts.match_resolution_exactly=true;
PCInputBinding b;
b.bindButtonDown('a', playBeep);
std::function< void () > quit = std::bind(&GLWindow::close, &glWindow);
b.bindButtonDown(PCInputBinding::ESCAPE, quit);
glWindow.use_binding(b);
std::cout<<"Supported resolutions "<<std::endl;
std::set<std::pair<int,int>> resolutions = glWindow.getResolutions();
for(std::set<std::pair<int,int>>::const_iterator it = resolutions.begin(); it != resolutions.end(); it++){
std::cout<<it->first<<"::"<<it->second<<std::endl;
}
glWindow.recreate(setts);
glClearColor(0,1,0,1);
std::cout<<"Recreated window width is "<<glWindow.getWidth()<<":::"<<glWindow.getHeight()<<std::endl;
while(glWindow.isValid())
{
// glViewport(0,0,glWindow.getWidth(),glWindow.getHeight());
//glWindow.bind();
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_TRIANGLES);
glClearColor(1.0,0.0,0.0,1.0);
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0,0.0,0.0);
glVertex3f(-1.0,1.0,0.0);
glColor3f(0.0,1.0,0.0);
glVertex3f(-1.0,-1.0,0.0);
glColor3f(0.0,0.0,1.0);
glVertex3f(1.0,-1.0,0.0);
glEnd();
glWindow.update();
glWindow.flush();
//
}
}
catch(std::exception& e)
{
std::cerr << e.what() << std::endl;
}
system("pause");
return 0;
}