本文整理汇总了C++中simulation::Player::getSensorByType方法的典型用法代码示例。如果您正苦于以下问题:C++ Player::getSensorByType方法的具体用法?C++ Player::getSensorByType怎么用?C++ Player::getSensorByType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类simulation::Player
的用法示例。
在下文中一共展示了Player::getSensorByType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawFunc
//------------------------------------------------------------------------------
// drawFunc()
//------------------------------------------------------------------------------
void Display::drawFunc()
{
Simulation::Player* own = getOwnship();
const Basic::Pair* pair = nullptr;
if (own != nullptr) pair = own->getSensorByType(typeid(RealBeamRadar));
const RealBeamRadar* rdr = nullptr;
if (pair != nullptr) rdr = static_cast<const RealBeamRadar*>( pair->object() );
const GLubyte* image = nullptr; // The image pixels
if (rdr != nullptr) image = rdr->getImage();
if (image != nullptr) {
// Image width (number of columns)
GLsizei imgWidth = rdr->getImageWidth();
// Image height (number of rows)
GLsizei imgHeight = rdr->getImageHeight();
GLint pixelSize = rdr->getPixelSize();
GLenum format = GL_RGB;
if (pixelSize == 4) format = GL_RGBA;
if (testTexture) {
// ---
// Draw using texture map
// ---
glEnable(GL_TEXTURE_2D);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
if (texture == 0) {
glGenTextures(1, &texture);
}
glBindTexture(GL_TEXTURE_2D, texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
// double start = getComputerTime();
glTexImage2D(GL_TEXTURE_2D, 0, pixelSize, imgWidth, imgHeight, 0, format, GL_UNSIGNED_BYTE, image);
// B SCAN
glBegin(GL_POLYGON);
glTexCoord2f( 1.0f, 1.0f );
glVertex2f( 1.0f, 1.0f );
glTexCoord2f( 0.0f, 1.0f );
glVertex2f( 0.0f, 1.0f );
glTexCoord2f( 0.0f, 0.0f );
glVertex2f( 0.0f, 0.0f );
glTexCoord2f( 1.0f, 0.0f );
glVertex2f( 1.0f, 0.0f );
glEnd();
glDisable(GL_TEXTURE_2D);
// double end = getComputerTime();
// double dtime = (end - start);
//std::cout << "glTexImage2D() dtime = " << dtime << std::endl;
}
else {
// ---
// Draw using glDrawPixels()
// ---
glRasterPos2f(0.0, 0.0);
//double start = getComputerTime();
glDrawPixels(imgWidth, imgHeight, format, GL_UNSIGNED_BYTE, image);
//double end = getComputerTime();
//double dtime = (end - start);
//std::cout << "glDrawPixels() dtime = " << dtime << std::endl;
}
}
}