当前位置: 首页>>代码示例>>C++>>正文


C++ debugAssertM函数代码示例

本文整理汇总了C++中debugAssertM函数的典型用法代码示例。如果您正苦于以下问题:C++ debugAssertM函数的具体用法?C++ debugAssertM怎么用?C++ debugAssertM使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了debugAssertM函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: alwaysAssertM

void SDLWindow::setGammaRamp(const Array<uint16>& gammaRamp) {
    alwaysAssertM(gammaRamp.size() >= 256, "Gamma ramp must have at least 256 entries");

    Log* debugLog = Log::common();

    uint16* ptr = const_cast<uint16*>(gammaRamp.getCArray());
    #ifdef WIN32
        // On windows, use the more reliable SetDeviceGammaRamp function.
        // It requires separate RGB gamma ramps.
        uint16 wptr[3 * 256];
        for (int i = 0; i < 256; ++i) {
            wptr[i] = wptr[i + 256] = wptr[i + 512] = ptr[i]; 
        }
        BOOL success = SetDeviceGammaRamp(wglGetCurrentDC(), wptr);
    #else
        bool success = (SDL_SetGammaRamp(ptr, ptr, ptr) != -1);
    #endif

    if (! success) {
        if (debugLog) {debugLog->println("Error setting gamma ramp!");}

        #ifdef WIN32
            debugAssertM(false, "Failed to set gamma ramp");
        #else
            if (debugLog) {debugLog->println(SDL_GetError());}
            debugAssertM(false, SDL_GetError());
        #endif
    }
}
开发者ID:luaman,项目名称:g3d-cpp,代码行数:29,代码来源:SDLWindow.cpp

示例2: debugAssertM

ColorRGB
ColorRGB::fromHSV(Vector3 const & hsv)
{
  debugAssertM((hsv[0] <= 1.0f && hsv[0] >= 0.0f)
            && (hsv[1] <= 1.0f && hsv[1] >= 0.0f)
            && (hsv[2] <= 1.0f && hsv[2] >= 0.0f), "ColorRGB: H, S, V must be in [0, 1]");

  int const i = std::min(5, (int)std::floor(6.0 * hsv[0]));
  Real const f = 6.0f * hsv[0] - i;
  Real const m = hsv[2] * (1.0f - (hsv[1]));
  Real const n = hsv[2] * (1.0f - (hsv[1] * f));
  Real const k = hsv[2] * (1.0f - (hsv[1] * (1 - f)));

  switch (i)
  {
    case 0: return ColorRGB(hsv[2], k, m);
    case 1: return ColorRGB(n, hsv[2], m);
    case 2: return ColorRGB(m, hsv[2], k);
    case 3: return ColorRGB(m, n, hsv[2]);
    case 4: return ColorRGB(k, m, hsv[2]);
    case 5: return ColorRGB(hsv[2], m, n);

    default: debugAssertM(false, "ColorRGB: Fell through switch when attempting conversion from HSV");
  }

  return ColorRGB::black();
}
开发者ID:sidch,项目名称:DGP,代码行数:27,代码来源:ColorRGB.cpp

示例3: debugAssertM

	Any::Data::~Data() {
		debugAssertM(referenceCount.value() <= 0, "Deleted while still referenced.");

		// Destruct but do not deallocate children
		switch (type) {
		case STRING:
			debugAssert(value.s != NULL);
			value.s->~basic_string();
			break;

		case ARRAY:
			debugAssert(value.a != NULL);
			value.a->~Array();
			break;

		case TABLE:
			debugAssert(value.t != NULL);
			value.t->~Table();
			break;

		default:
			// All other types should have a NULL value pointer (i.e., they were used just for name and comment fields)
			debugAssertM(value.s == NULL, "Corrupt Any::Data::Value");
		}

		value.s = NULL;
	}
开发者ID:lev1976g,项目名称:easywow,代码行数:27,代码来源:Any.cpp

示例4: debugAssertM

bool
BinaryOutputStream::_commit(bool flush, bool force)
{
  // If there is already an error, the commit fails
  if (!m_ok)
    return false;

  // Nothing to commit for memory streams
  if (m_path == "<memory>")
    return true;

  // Is there anything new to write?
  if (!force && m_bufferLen <= 0)
    return true;

  debugAssertM(m_beginEndBits == 0, getNameStr() + ": Missing endBits before commit");

//   // Make sure the directory exists
//   std::string dir = FilePath::parent(m_path);
//   if (!FileSystem::exists(dir))
//     if (!FileSystem::createDirectory(dir))
//     {
//       DGP_ERROR << "BinaryOutputStream: Could not create parent directory of '" << m_path << "'";
//       m_ok = false;
//     }

  FILE * file = NULL;
  if (m_ok)
  {
    char const * mode = (m_alreadyWritten > 0 ? "ab" : "wb");
    file = fopen(m_path.c_str(), mode);
    if (!file)
    {
      DGP_ERROR << "BinaryOutputStream: Could not open file '" << m_path << "' for writing";
      m_ok = false;
    }
  }

  if (m_ok)
  {
    if (m_buffer != NULL && m_bufferLen > 0)
    {
      size_t success = fwrite(m_buffer, (size_t)m_bufferLen, 1, file);
      debugAssertM(success == 1, getNameStr() + ": Could not write buffer contents to disk");
      (void)success;

      m_alreadyWritten += m_bufferLen;
      m_bufferLen = 0;
      m_pos = 0;
    }

    if (flush)
      fflush(file);

    fclose(file);
    file = NULL;
  }

  return m_ok;
}
开发者ID:sidch,项目名称:DGP,代码行数:60,代码来源:BinaryOutputStream.cpp

示例5: X

Radiance3 RayTracer::L_direct(const shared_ptr<Surfel>& surfel, const Vector3& wo, ThreadData& threadData) const {
    Radiance3 L;
    const Point3& X(surfel->position);
    const Vector3& n(surfel->shadingNormal);

    for (int i = 0; i < m_lighting.lightArray.size(); ++i) {
        const shared_ptr<Light> light(m_lighting.lightArray[i]);

        if (light->producesDirectIllumination()) {

            const Point3&  Y(light->frame().translation);
            const Vector3& wi((Y - X).direction());

            debugAssertM(X.isFinite(), "The surface is not at a finite location");
            debugAssertM(Y.isFinite(), "The light is not at a finite location");

            if ((! light->castsShadows()) || visible(Y, X, true)) {
                const Color3&      f(surfel->finiteScatteringDensity(wi, wo));
                const Biradiance3& B(light->biradiance(X));

                L += f * B * abs(wi.dot(n));
                debugAssertM(L.isFinite(), "Non-finite radiance in L_direct");
            }
        }
    }

    return L;
}
开发者ID:fwilliams,项目名称:G3D-Raytracer,代码行数:28,代码来源:RayTracer.cpp

示例6: debugAssert

// The following are called by the VARSystem.
void VAR::vertexPointer() const {
	debugAssert(valid());
	glEnableClientState(GL_VERTEX_ARRAY);
    debugAssertM(underlyingRepresentation != GL_UNSIGNED_INT, 
              "OpenGL does not support GL_UNSIGNED_INT as a vertex format.");
    debugAssertM(underlyingRepresentation != GL_UNSIGNED_SHORT, 
              "OpenGL does not support GL_UNSIGNED_SHORT as a vertex format.");
    debugAssertM(underlyingRepresentation != GL_UNSIGNED_BYTE, 
              "OpenGL does not support GL_UNSIGNED_BYTE as a vertex format.");
	glVertexPointer(elementSize / sizeOfGLFormat(underlyingRepresentation), 
                    underlyingRepresentation, elementSize, _pointer);
}
开发者ID:Jekls,项目名称:PhantomCore,代码行数:13,代码来源:VAR.cpp

示例7: debugAssertM

void VAR::set(int index, const void* value, GLenum glformat, size_t eltSize) {
    (void)glformat;
    debugAssertM(index < numElements && index >= 0, 
        "Cannot call VAR::set with out of bounds index");
    
    debugAssertM(glformat == underlyingRepresentation, 
        "Value argument to VAR::set must match the intialization type.");

    debugAssertM(eltSize == elementSize, 
        "Value argument to VAR::set must match the intialization type's memory footprint.");

    uploadToCard(value, index * eltSize, eltSize);
}
开发者ID:Jekls,项目名称:PhantomCore,代码行数:13,代码来源:VAR.cpp

示例8: debugAssert

void ReliableConduit::receiveIntoBuffer() {

    debugAssert(state == RECEIVING);
    debugAssert(messageType != 0);
    debugAssertM(receiveBufferUsedSize < messageSize, "Message already received.");
    debugAssertM(messageSize >= receiveBufferUsedSize, "Message size overflow.");

    // Read the data itself
    int ret = 0;
    uint32 left = messageSize - receiveBufferUsedSize;
    int count = 0;
    while ((ret != SOCKET_ERROR) && (left > 0) && (count < 10)) {

        ret = recv(sock, ((char*)receiveBuffer) + receiveBufferUsedSize, left, 0);

        if (ret > 0) {
            left -= ret;
            receiveBufferUsedSize += ret;
            bReceived += ret;

            if (left > 0) {
                // There's still more. Give the machine a chance to read
                // more data, but don't wait forever.

                ++count;
                System::sleep(0.001);
            }
        } else {
            // Something went wrong
            break;
        }
    }

    if ((ret == 0) || (ret == SOCKET_ERROR)) {

        if (nd->debugLog) {
            if (ret == SOCKET_ERROR) {
                nd->debugLog->printf("Call to recv failed.  ret = %d,"
                     " sizeof(messageSize) = %d\n", ret, messageSize);
                nd->debugLog->println(socketErrorCode());
            } else {
                nd->debugLog->printf("recv returned 0\n");
            }
        }
        nd->closesocket(sock);
        return;
    }

    ++mReceived;
}
开发者ID:luaman,项目名称:g3d-cpp,代码行数:50,代码来源:NetworkDevice.cpp

示例9: getRootKeyFromString

bool RegistryUtil::writeString(const std::string& key, const std::string& value, const std::string& data) {
    size_t pos = key.find('\\', 0);
    if (pos == std::string::npos) {
        return false;
    }

    HKEY hkey = getRootKeyFromString(key.c_str(), pos);

    if (hkey == NULL) {
        return false;
    }

    HKEY openKey;
    int32 result = RegOpenKeyExA(hkey, (key.c_str() + pos + 1), 0, KEY_WRITE, &openKey);
    debugAssert(result == ERROR_SUCCESS || result == ERROR_FILE_NOT_FOUND);

    if (result == ERROR_SUCCESS) {
        alwaysAssertM(data.size() < 0xFFFFFFFE, "String too long");
        result = RegSetValueExA(openKey, value.c_str(), 0, REG_SZ, reinterpret_cast<const BYTE*>(data.c_str()), (int)(data.size() + 1));                
        debugAssertM(result == ERROR_SUCCESS, "Could not write registry key value.");

        RegCloseKey(openKey);
    }
    return (result == ERROR_SUCCESS);
}
开发者ID:A7med-Shoukry,项目名称:g3d,代码行数:25,代码来源:RegistryUtil.cpp

示例10: switch

void Image3unorm8::load(const String& filename) {
    shared_ptr<Image> image = Image::fromFile(filename);
    if (image->format() != ImageFormat::RGB8()) {
        image->convertToRGB8();
    }

    switch (image->format()->code)
    {
        case ImageFormat::CODE_L8:
            copyArray(static_cast<const Color1unorm8*>(image->toPixelTransferBuffer()->buffer()), image->width(), image->height());
            break;
        case ImageFormat::CODE_L32F:
            copyArray(static_cast<const Color1*>(image->toPixelTransferBuffer()->buffer()), image->width(), image->height());
            break;
        case ImageFormat::CODE_RGB8:
            copyArray(static_cast<const Color3unorm8*>(image->toPixelTransferBuffer()->buffer()), image->width(), image->height());
            break;
        case ImageFormat::CODE_RGB32F:
            copyArray(static_cast<const Color3*>(image->toPixelTransferBuffer()->buffer()), image->width(), image->height());
            break;
        case ImageFormat::CODE_RGBA8:
            copyArray(static_cast<const Color4unorm8*>(image->toPixelTransferBuffer()->buffer()), image->width(), image->height());
            break;
        case ImageFormat::CODE_RGBA32F:
            copyArray(static_cast<const Color4*>(image->toPixelTransferBuffer()->buffer()), image->width(), image->height());
            break;
        default:
            debugAssertM(false, "Trying to load unsupported image format");
            break;
    }

    setChanged(true);
}
开发者ID:elfprince13,项目名称:G3D10,代码行数:33,代码来源:Image3unorm8.cpp

示例11: L

Radiance3 RayTracer::L_scatteredSpecularIndirect(const shared_ptr<Surfel>& surfel, const Vector3& wo, int bouncesLeft, Random& rnd) const{
    Radiance3 L(0,0,0);
    if (bouncesLeft > 0){
        G3D::UniversalSurfel::ImpulseArray impulses;

        //Downcast to universalSurfel to allow getting impulses
        const shared_ptr<UniversalSurfel>& u = dynamic_pointer_cast<UniversalSurfel>(surfel);
        debugAssertM(notNull(u), "Encountered a Surfel that was not a UniversalSurfel");
        
        //Find the impulses on the surface
        u->getImpulses(PathDirection::EYE_TO_SOURCE, wo, impulses);

        //For each impulses, recursively computed the radiance from that direction
        for (int i = 0; i < impulses.size(); ++i){
            Vector3 wi = impulses[i].direction;
            Color3 magnitude = impulses[i].magnitude;
            ++m_stats->indirectRays;
            L += L_i(surfel->position, wi, bouncesLeft - 1, rnd) * magnitude;
        }
        
        //If we enable path tracing, also cast a random ray from the surfel
        //Technically it is not SpecularIndirect. But as it is not used often, I'm going to leave it here
        if (m_settings.enablePathTracing){
            Vector3 wi = Vector3::hemiRandom(surfel->shadingNormal, rnd);
            L += L_i(surfel->position, wi, bouncesLeft - 1, rnd) * surfel->finiteScatteringDensity(wi,wo) * abs(wi.dot(surfel->shadingNormal));
        }
    }
    return L;
}
开发者ID:fjnoyp,项目名称:ProceduralCityGenerator-100-hours,代码行数:29,代码来源:RayTracer.cpp

示例12: m_specification

ParticleSystemModel::Emitter::Emitter(const Specification& s) : m_specification(s) {
    switch (s.shapeType) {
    case Shape::Type::MESH:
        // Load the mesh
        debugAssertM(false, "TODO");
        break;

    case Shape::Type::BOX:
        m_spawnShape = shared_ptr<Shape>(new BoxShape(s.box));
        break;

    case Shape::Type::CYLINDER:
        m_spawnShape = shared_ptr<Shape>(new CylinderShape(s.cylinder));
        break;

    case Shape::Type::SPHERE:
        m_spawnShape = shared_ptr<Shape>(new SphereShape(s.sphere));
        break;

    default:
        alwaysAssertM(false, "Illegal spawn shape");
    }

    m_material = ParticleMaterial::create(s.material);
}
开发者ID:lieff,项目名称:g3d,代码行数:25,代码来源:ParticleSystemModel.cpp

示例13: ReferenceCountedObject_refCount

ReferenceCountedObject::ReferenceCountedObject() : 
    ReferenceCountedObject_refCount(0), 
    ReferenceCountedObject_weakPointer(0) {

    debugAssertM(isValidHeapPointer(this), 
        "Reference counted objects must be allocated on the heap.");
}
开发者ID:Sandshroud,项目名称:Sandshroud-Prodigy,代码行数:7,代码来源:ReferenceCount.cpp

示例14: alwaysAssertM

void VAR::update(
    const void*         sourcePtr,
    int                 _numElements,
    GLenum              glformat,
    size_t              eltSize) {

	size_t size = eltSize * _numElements;

    alwaysAssertM(size <= _maxSize,
        "A VAR can only be updated with an array that is smaller "
        "or equal size (in bytes) to the original array.");

    alwaysAssertM(generation == area->currentGeneration(),
        "The VARArea has been reset since this VAR was created.");

	numElements              = _numElements;
    underlyingRepresentation = glformat;
	elementSize              = eltSize;

    debugAssertM(
        (elementSize % sizeOfGLFormat(underlyingRepresentation)) == 0,
        "Sanity check failed on OpenGL data format; you may"
        " be using an unsupported type in a vertex array.");
	
	// Upload the data
    if (size > 0) {
        uploadToCard(sourcePtr, 0, size);
    }
}
开发者ID:Jekls,项目名称:PhantomCore,代码行数:29,代码来源:VAR.cpp

示例15: tileSheet

shared_ptr<TileSheet> TileSheet::create(const Any& any) {
	shared_ptr<TileSheet> tileSheet(new TileSheet());

	AnyTableReader r(any);

	Any legend;
	r.getIfPresent("legend", legend);
	for (Table<String, Any>::Iterator it = legend.table().begin(); it.hasMore(); ++it) {
		const String& mapLabel = it.key();
        const shared_ptr<Tile>& tile = Tile::create(mapLabel, it.value());

		// TODO: Switch to report
		debugAssertM(! tileSheet->m_tileByID.containsKey(tile->id()), "Duplicate tile ID");

		tileSheet->m_tileByID.set(tile->id(), tile);
		tileSheet->m_tileByMapLabel.set(tile->mapLabel(), tile);
	}

    r.getFilenameIfPresent("color", tileSheet->m_colorFilename);
    r.getFilenameIfPresent("blueprint", tileSheet->m_blueprintFilename);

    // Even though we lazy load these (since the server can't load graphics),
    // we check immediately to ensure that the files exist
    if (! FileSystem::exists(tileSheet->m_colorFilename)) {
        report("File not found: \"" + tileSheet->m_colorFilename + "\".", ReportLevel::ERROR);
    }

    if (! FileSystem::exists(tileSheet->m_blueprintFilename)) {
        report("File not found: \"" + tileSheet->m_blueprintFilename + "\".", ReportLevel::ERROR);
    }

	r.verifyDone();

	return tileSheet;
}
开发者ID:franmgee,项目名称:openheist,代码行数:35,代码来源:TileSheet.cpp


注:本文中的debugAssertM函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。