本文整理汇总了C++中VertexShader::setIterationTimes方法的典型用法代码示例。如果您正苦于以下问题:C++ VertexShader::setIterationTimes方法的具体用法?C++ VertexShader::setIterationTimes怎么用?C++ VertexShader::setIterationTimes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VertexShader
的用法示例。
在下文中一共展示了VertexShader::setIterationTimes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
int width = 500;
int height = 500;
sf::RenderWindow window(sf::VideoMode(width,height),"soft-renderer");
if(glewInit()!=GLEW_OK){
cout << "error in glew";
return 0;
}
initialize();
VertexShader *vs = new VertexShader ;
vs->setIterationCompute(&iterationCompute);
vs->setIterationTimes(times);
FragShader *fs = new FragShader;
fs->setIterationCompute(&FragShaderIterCompute);
Pipeline::Config config;
config.height = height;
config.width = width;
config.primitiveType = TRIANGLES;
config.clearColor = glm::vec3(0.5f,0.0f,0.0f);
Pipeline pl;
pl.setConfig(config);
pl.attachVertShader(vs);
pl.attachFragShader(fs);
pl.render();
// sf::Clock clock;
// clock.restart();
while(window.isOpen()){
sf::Event event;
while(window.pollEvent(event)){
if(event.type == sf::Event::MouseButtonPressed){
int x = event.mouseButton.x;
int y = event.mouseButton.y;
vector< unsigned char > pixels( 1 * 1 * 4 );
glReadPixels(x,height-y,1,1,GL_RGBA,
GL_UNSIGNED_BYTE,
&pixels[0]);
cout << "r: " << (int)pixels[0] << endl;
cout << "g: " << (int)pixels[1] << endl;
cout << "b: " << (int)pixels[2] << endl;
cout << "a: " << (int)pixels[3] << endl;
cout << endl;
cout << "x: " << x << endl;
cout << "y: " << 800-y << endl;
cout << endl;
}
if (event.type == sf::Event::Closed) {
window.close();
}
if (event.type == sf::Event::Resized)
{
// adjust the viewport when the window is resized
glViewport(0, 0, event.size.width, event.size.height);
}
if (event.type == sf::Event::KeyPressed) {
glm::vec4 col(0);
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left))
{
col.x -= 0.05f;
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right))
{
col.x += 0.05f;
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up))
{
col.y += 0.05f;
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down))
{
col.y -= 0.05f;
}
glm::mat4 translate = glm::translate(glm::mat4(1),vec3(col));
MVP = translate * MVP;
pl.update();
}
glDrawPixels(width,height,GL_RGB,GL_FLOAT,pl.getColorBuffer());
window.display();
}
//.........这里部分代码省略.........