//------------------------------------------------------------------------------ // 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; } } }