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


C++ Exception函数代码示例

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


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

示例1: CreateEvent

Mutex::Mutex() {
  hMutex = CreateEvent(NULL, FALSE, TRUE, NULL);
  if (hMutex == NULL) {
    throw Exception();
  }
}
开发者ID:respu,项目名称:yield,代码行数:6,代码来源:mutex.cpp

示例2: Exception

/** get the acceleration value of the MarkersReference */
void MarkersReference::getAccelerationValues(const SimTK::State &s, SimTK::Array_<Vec3> &accValues) const
{
    throw Exception("MarkersReference: getAccelerationValues not implemented.");
}
开发者ID:cinuized,项目名称:opensim-core,代码行数:5,代码来源:MarkersReference.cpp

示例3: HHVM_METHOD

static bool HHVM_METHOD(Collator, sortWithSortKeys, VRefParam arr) {
  FETCH_COL(data, this_, false);
  data->clearError();

  if (!arr.isArray()) {
    return true;
  }

  Array hash = arr.toArray();
  if (hash.size() == 0) {
    return true;
  }

  // Preallocate sort keys buffer
  size_t sortKeysOffset = 0;
  size_t sortKeysLength = DEF_SORT_KEYS_BUF_SIZE;
  char*  sortKeys = (char*)req::malloc(sortKeysLength);
  if (!sortKeys) {
    throw Exception("Out of memory");
  }
  SCOPE_EXIT{ req::free(sortKeys); };

  // Preallocate index buffer
  size_t sortIndexPos = 0;
  size_t sortIndexLength = DEF_SORT_KEYS_INDX_BUF_SIZE;
  auto   sortIndex = (collator_sort_key_index_t*)req::malloc(
                  sortIndexLength * sizeof(collator_sort_key_index_t));
  if (!sortIndex) {
    throw Exception("Out of memory");
  }
  SCOPE_EXIT{ req::free(sortIndex); };

  // Translate input hash to sortable index
  auto pos_limit = hash->iter_end();
  for (ssize_t pos = hash->iter_begin(); pos != pos_limit;
       pos = hash->iter_advance(pos)) {
    Variant val(hash->getValue(pos));

    // Convert to UTF16
    icu::UnicodeString strval;
    if (val.isString()) {
      UErrorCode error = U_ZERO_ERROR;
      strval = u16(val.toString(), error);
      if (U_FAILURE(error)) {
        return false;
      }
     }

    // Generate sort key
    int sortkey_len =
      ucol_getSortKey(data->collator(),
                      strval.getBuffer(), strval.length(),
                      (uint8_t*)(sortKeys + sortKeysOffset),
                      sortKeysLength - sortKeysOffset);

    // Check for key buffer overflow
    if (sortkey_len > (sortKeysLength - sortKeysOffset)) {
      int32_t inc = (sortkey_len > DEF_SORT_KEYS_BUF_INCREMENT)
                  ?  sortkey_len : DEF_SORT_KEYS_BUF_INCREMENT;
      sortKeysLength += inc;
      sortKeys = (char*)req::realloc(sortKeys, sortKeysLength);
      if (!sortKeys) {
        throw Exception("Out of memory");
      }
      sortkey_len =
        ucol_getSortKey(data->collator(),
                        strval.getBuffer(), strval.length(),
                        (uint8_t*)(sortKeys + sortKeysOffset),
                        sortKeysLength - sortKeysOffset);
      assert(sortkey_len <= (sortKeysLength - sortKeysOffset));
    }

    // Check for index buffer overflow
    if ((sortIndexPos + 1) > sortIndexLength) {
      sortIndexLength += DEF_SORT_KEYS_INDX_BUF_INCREMENT;
      sortIndex = (collator_sort_key_index_t*)req::realloc(sortIndex,
                      sortIndexLength * sizeof(collator_sort_key_index_t));
      if (!sortIndex) {
        throw Exception("Out of memory");
      }
    }

    // Initially store offset into buffer, update later to deal with reallocs
    sortIndex[sortIndexPos].key = (char*)sortKeysOffset;
    sortKeysOffset += sortkey_len;

    sortIndex[sortIndexPos].valPos = pos;
    ++sortIndexPos;
  }

  // Update keys to location in realloc'd buffer
  for (int i = 0; i < sortIndexPos; ++i) {
    sortIndex[i].key = sortKeys + (ptrdiff_t)sortIndex[i].key;
  }

  zend_qsort(sortIndex, sortIndexPos,
             sizeof(collator_sort_key_index_t),
             collator_cmp_sort_keys, nullptr);

  Array ret = Array::Create();
//.........这里部分代码省略.........
开发者ID:Fermi,项目名称:hhvm,代码行数:101,代码来源:ext_icu_collator.cpp

示例4: qc

void __fastcall TformEnterResults::btnOKClick(TObject *Sender)
{
	// TODO
	pResult result = new Result;
	VecpResult results;

	if (NULL == lines) {
		Application->MessageBox("No file loaded", "Error", MB_OK);
		return;
	}

	// parse
//	int 		patientID;
//	String		barcode;
//	TDateTime	startDate;
//	String		sampleType;
//	int			testID;
//	String		unit;
//	String		result;
//	TDateTime	dateAnalysed;
//	String		cuvetteType;
//	int			reagentID;
//	String		reagentLot;
//	String		notes;

	// following code copied from EditFormat - needs adapting or merging
	LQuery qc(frmBuddyLogin->qCentral);
	qc.setSQL("SELECT"
		" field_cid,"
		" filetype_cid,"
		" tag,"
		" tagcol,"
		" valcol,"
		" subcol,"
		" type,"
		" pos"
		" FROM g_comms_field WHERE id_filetype = :idfiletype"
		" AND status = 0"
		" ORDER BY pos"); // XXX
	qc.setParam("idfiletype", format->id);
	int count = qc.open();
	if (!MYDEBUG) {
		assert(count > 1);
	}
	VecpDatum vecpDatum;
	while (!qc.eof()) {
		Datum *newdatum = new Datum;
		newdatum->datumType     = (Datum::DatumType)qc.readInt("type");
		newdatum->id            = qc.readInt("field_cid");
		newdatum->id_filetype   = qc.readInt("filetype_cid");
		//newdatum->name          = qc.readString("name");
		newdatum->tag           = qc.readString("tag");
		newdatum->tagCol        = qc.readInt("tagcol");
		newdatum->valCol        = qc.readInt("valcol");
		newdatum->valSubCol     = qc.readInt("subcol");
		newdatum->pos     		= qc.readInt("pos");
		vecpDatum.push_back(newdatum);
		qc.next();
	}

//	TTreeNode * rootNode = NULL;
//	TTreeNode * resultNode = NULL;
//	TTreeNode * reagentNode = NULL;
	Datum * curdatum = new Datum;
	for (VecpDatum::const_iterator it = vecpDatum.begin(); it != vecpDatum.end(); it++) {
		// save the current node if it is a container node
		Datum * datum = *it;
		switch (datum->datumType) {
			case Datum::DATUM_ROOT:
				//rootNode = curNode;
				break;
			case Datum::DATUM_RESULT:
				//resultNode = curNode;
				break;
			case Datum::DATUM_REAGENT:
				//reagentNode = curNode;
				break;
			case Datum::DATUM_PID:
			case Datum::DATUM_BARCODE:
			case Datum::DATUM_STARTDATE:
			case Datum::DATUM_SAMPLETYPE:
			case Datum::DATUM_TID:
			case Datum::DATUM_UNIT:
			case Datum::DATUM_RESULTSTRING:
			case Datum::DATUM_DATEANALYSED:
			case Datum::DATUM_CUVETTE:
			case Datum::DATUM_REAGENTID:
			case Datum::DATUM_REAGENTLOT:
			case Datum::DATUM_NOTES:
				// do nothing
				break;
			default:
				throw Exception("Invalid datum type");
		}

		// and add next it to appropriate saved node
		curdatum = *it;
		switch (curdatum->datumType) {
			case Datum::DATUM_ROOT:
				throw "DATUM_ROOT should not be stored in database";
//.........这里部分代码省略.........
开发者ID:drkvogel,项目名称:retrasst,代码行数:101,代码来源:frmEnterResults.cpp

示例5: document_

  ConfigDocument::ConfigDocument(int& argc, 
				 char * argv[], 
				 const std::string& defaultname, 
				 const std::string& documentname,
				 const std::vector<std::string> &userPath ) :
    document_( new QDomDocument(documentname.c_str()) )
  {

    const char *name;
    char host[256];
    if (defaultname == "") {
      // determine the name of the config file
      ACE_OS::hostname(host, 256);
      name = host;
    } else {
      name = defaultname.c_str();
    }

    ACE_Arg_Shifter arg_shifter (argc, argv);
    while (arg_shifter.is_anything_left ()) {
//      char *current_arg = arg_shifter.get_current ();
      const ACE_TCHAR *current_arg = arg_shifter.get_current ();

      const char configFileOpt[] = "-MiroConfigFile";
      const int optLen = sizeof(configFileOpt) - 1;
      if (ACE_OS::strcasecmp(current_arg, configFileOpt) == 0) {
	arg_shifter.consume_arg();
	if (arg_shifter.is_parameter_next()) {
	  name = arg_shifter.get_current ();
	  arg_shifter.consume_arg();
	}
      }
      else if (ACE_OS::strncasecmp(current_arg, configFileOpt, optLen) == 0) {
	arg_shifter.consume_arg();
	// The rest of the argument is the ORB id...
        name = current_arg + optLen;
	// but we should skip an optional space...
	if (name[0] == ' ')
	  name++;
      }
      else
	arg_shifter.ignore_arg ();
    }

    std::string fileName = name;
    if (name == host)
      fileName += std::string(".xml");
    std::string fullName = Miro::findFile(fileName, userPath );

    if (fullName.length() == 0) {
      std::cerr << "File not found: " << fileName << std::endl;
      std::cerr << "No config file processing." << std::endl;
    } 
    else {
      QFile f(fullName.c_str());

      if (!f.open(IO_ReadOnly)) {
	std::cout << "error on open" << std::endl;
	throw CException(errno, std::strerror(errno));
      }
      QString parsingError;
      int line = 0;
      int column = 0;
      if (!document_->setContent(&f/*, &parsingError, &line, &column*/)) {
	f.close();
	std::stringstream ostr;
	ostr << "error parsing " << fullName << std::endl
	     << " in line " << line << " "
	     << ", column " << column << std::endl
	     << parsingError << std::endl;
	throw Exception(ostr.str());
      }
      f.close();
    }
  }
开发者ID:BackupTheBerlios,项目名称:miro-middleware-svn,代码行数:75,代码来源:ConfigDocument.cpp

示例6: Exception

void GL1TextureProvider::transform_coordinate(const PrimitivesArrayProvider::VertexData &attribute, std::vector<float> &transformed_data, int vertex_offset, int num_vertices, int total_vertices)
{
	if (attribute.type != type_float)
	{
		throw Exception("Implement me: Texture coord npot transformation (not float) (GL1 target)");
	}

	int desired_size = attribute.size * (total_vertices);
	if (transformed_data.size() < desired_size)
		transformed_data.resize(desired_size);

	int size = attribute.size;

	int stride_float;
	if (attribute.stride)
	{
		stride_float = (attribute.stride / sizeof(float));
	}
	else
	{
		stride_float = size;
	}

	int source_position = vertex_offset * stride_float;

	GL1VertexArrayBufferProvider *vertex_array_ptr = static_cast<GL1VertexArrayBufferProvider *>(attribute.array_provider);
	if (!vertex_array_ptr)
		throw Exception("Invalid BindBuffer Provider");

	const char *data_ptr = ((const char *) vertex_array_ptr->get_data()) + attribute.offset;

	float *src = (float *) data_ptr;
	float *dest = &transformed_data[vertex_offset * size];

	stride_float -= size;

	if (size==1)
	{
		for (int vertex_count=0; vertex_count < num_vertices; vertex_count++, source_position += stride_float)
		{
			*(dest++) = src[source_position++] * pot_ratio_width;
		}
	}
	else if (size==2)
	{
		for (int vertex_count=0; vertex_count < num_vertices; vertex_count++, source_position += stride_float)
		{
			*(dest++) = src[source_position++] * pot_ratio_width;
			*(dest++) = src[source_position++] * pot_ratio_height;
		}
	}
	else if (size==3)
	{
		for (int vertex_count=0; vertex_count < num_vertices; vertex_count++, source_position += stride_float)
		{
			*(dest++) = src[source_position++] * pot_ratio_width;
			*(dest++) = src[source_position++] * pot_ratio_height;
			*(dest++) = src[source_position++] * pot_ratio_depth;
		}
	}
}
开发者ID:ARMCoderCHS,项目名称:ClanLib,代码行数:61,代码来源:gl1_texture_provider.cpp

示例7: switch


//.........这里部分代码省略.........
		// TODO: Should this really be here?
		case tf_stencil_index1: gl_internal_format = GL_STENCIL_INDEX1; gl_pixel_format = GL_STENCIL_INDEX; break;
		case tf_stencil_index4: gl_internal_format = GL_STENCIL_INDEX4; gl_pixel_format = GL_STENCIL_INDEX; break;
		case tf_stencil_index8: gl_internal_format = GL_STENCIL_INDEX8; gl_pixel_format = GL_STENCIL_INDEX; break;
		case tf_stencil_index16: gl_internal_format = GL_STENCIL_INDEX16; gl_pixel_format = GL_STENCIL_INDEX; break;

		//case tf_r8: gl_internal_format = GL_R8; gl_pixel_format = GL_RED; break;
		//case tf_r8_snorm: gl_internal_format = GL_R8_SNORM; gl_pixel_format = GL_RED; break;
		//case tf_r16: gl_internal_format = GL_R16; gl_pixel_format = GL_RED; break;
		//case tf_r16_snorm: gl_internal_format = GL_R16_SNORM; gl_pixel_format = GL_RED; break;
		//case tf_rg8: gl_internal_format = GL_RG8; gl_pixel_format = GL_RG; break;
		//case tf_rg8_snorm: gl_internal_format = GL_RG8_SNORM; gl_pixel_format = GL_RG; break;
		//case tf_rg16: gl_internal_format = GL_RG16; gl_pixel_format = GL_RG; break;
		//case tf_rg16_snorm: gl_internal_format = GL_RG16_SNORM; gl_pixel_format = GL_RG; break;
		case tf_r3_g3_b2: gl_internal_format = GL_R3_G3_B2; gl_pixel_format = GL_RGB; break;
		case tf_rgb4: gl_internal_format = GL_RGB4; gl_pixel_format = GL_RGB; break;
		case tf_rgb5: gl_internal_format = GL_RGB5; gl_pixel_format = GL_RGB; break;
		case tf_rgb8: gl_internal_format = GL_RGB8; gl_pixel_format = GL_RGB; break;
		case tf_rgb10: gl_internal_format = GL_RGB10; gl_pixel_format = GL_RGB; break;
		case tf_rgb12: gl_internal_format = GL_RGB12; gl_pixel_format = GL_RGB; break;
		case tf_rgb16: gl_internal_format = GL_RGB16; gl_pixel_format = GL_RGB; break;
		//case tf_rgb16_snorm: gl_internal_format = GL_RGB16_SNORM; gl_pixel_format = GL_RGB; break;
		case tf_rgba2: gl_internal_format = GL_RGBA2; gl_pixel_format = GL_RGBA; break;
		case tf_rgba4: gl_internal_format = GL_RGBA4; gl_pixel_format = GL_RGBA; break;
		case tf_rgb5_a1: gl_internal_format = GL_RGB5_A1; gl_pixel_format = GL_RGBA; break;
		case tf_rgba8: gl_internal_format = GL_RGBA8; gl_pixel_format = GL_RGBA; break;
		case tf_bgra8: gl_internal_format = GL_RGBA8; gl_pixel_format = GL_BGRA; break;
		case tf_bgr8: gl_internal_format = GL_RGB8; gl_pixel_format = GL_BGR; break;
		//case tf_rgba8_snorm: gl_internal_format = GL_RGBA8_SNORM; gl_pixel_format = GL_RGBA; break;
		case tf_rgb10_a2: gl_internal_format = GL_RGB10_A2; gl_pixel_format = GL_RGBA; break;
		case tf_rgba12: gl_internal_format = GL_RGBA12; gl_pixel_format = GL_RGBA; break;
		case tf_rgba16: gl_internal_format = GL_RGBA16; gl_pixel_format = GL_RGBA; break;
		//case tf_rgba16_snorm: gl_internal_format = GL_RGBA16_SNORM; gl_pixel_format = GL_RGBA; break;
		//case tf_srgb8: gl_internal_format = GL_SRGB8; gl_pixel_format = GL_RGB; break;
		//case tf_srgb8_alpha8: gl_internal_format = GL_SRGB8_ALPHA8; gl_pixel_format = GL_RGBA; break;
		//case tf_r16f: gl_internal_format = GL_R16F; gl_pixel_format = GL_RED; break;
		//case tf_rg16f: gl_internal_format = GL_RG16F; gl_pixel_format = GL_RG; break;
		//case tf_rgb16f: gl_internal_format = GL_RGB16F; gl_pixel_format = GL_RGB; break;
		//case tf_rgba16f: gl_internal_format = GL_RGBA16F; gl_pixel_format = GL_RGBA; break;
		//case tf_r32f: gl_internal_format = GL_R32F; gl_pixel_format = GL_RED; break;
		//case tf_rg32f: gl_internal_format = GL_RG32F; gl_pixel_format = GL_RG; break;
		//case tf_rgb32f: gl_internal_format = GL_RGB32F; gl_pixel_format = GL_RGB; break;
		//case tf_rgba32f: gl_internal_format = GL_RGBA32F; gl_pixel_format = GL_RGBA; break;
		//case tf_r11f_g11f_b10f: gl_internal_format = GL_R11F_G11F_B10F; gl_pixel_format = GL_RGB; break;
		//case tf_rgb9_e5: gl_internal_format = GL_RGB9_E5; gl_pixel_format = GL_RGB; break;
		//case tf_r8i: gl_internal_format = GL_R8I; gl_pixel_format = GL_RED; break;
		//case tf_r8ui: gl_internal_format = GL_R8UI; gl_pixel_format = GL_RED; break;
		//case tf_r16i: gl_internal_format = GL_R16I; gl_pixel_format = GL_RED; break;
		//case tf_r16ui: gl_internal_format = GL_R16UI; gl_pixel_format = GL_RED; break;
		//case tf_r32i: gl_internal_format = GL_R32I; gl_pixel_format = GL_RED; break;
		//case tf_r32ui: gl_internal_format = GL_R32UI; gl_pixel_format = GL_RED; break;
		//case tf_rg8i: gl_internal_format = GL_RG8I; gl_pixel_format = GL_RG; break;
		//case tf_rg8ui: gl_internal_format = GL_RG8UI; gl_pixel_format = GL_RG; break;
		//case tf_rg16i: gl_internal_format = GL_RG16I; gl_pixel_format = GL_RG; break;
		//case tf_rg16ui: gl_internal_format = GL_RG16UI; gl_pixel_format = GL_RG; break;
		//case tf_rg32i: gl_internal_format = GL_RG32I; gl_pixel_format = GL_RG; break;
		//case tf_rg32ui: gl_internal_format = GL_RG32UI; gl_pixel_format = GL_RG; break;
		//case tf_rgb8i: gl_internal_format = GL_RGB8I; gl_pixel_format = GL_RGB; break;
		//case tf_rgb8ui: gl_internal_format = GL_RGB8UI; gl_pixel_format = GL_RGB; break;
		//case tf_rgb16i: gl_internal_format = GL_RGB16I; gl_pixel_format = GL_RGB; break;
		//case tf_rgb16ui: gl_internal_format = GL_RGB16UI; gl_pixel_format = GL_RGB; break;
		//case tf_rgb32i: gl_internal_format = GL_RGB32I; gl_pixel_format = GL_RGB; break;
		//case tf_rgb32ui: gl_internal_format = GL_RGB32UI; gl_pixel_format = GL_RGB; break;
		//case tf_rgba8i: gl_internal_format = GL_RGBA8I; gl_pixel_format = GL_RGBA; break;
		//case tf_rgba8ui: gl_internal_format = GL_RGBA8UI; gl_pixel_format = GL_RGBA; break;
		//case tf_rgba16i: gl_internal_format = GL_RGBA16I; gl_pixel_format = GL_RGBA; break;
		//case tf_rgba16ui: gl_internal_format = GL_RGBA16UI; gl_pixel_format = GL_RGBA; break;
		//case tf_rgba32i: gl_internal_format = GL_RGBA32I; gl_pixel_format = GL_RGBA; break;
		//case tf_rgba32ui: gl_internal_format = GL_RGBA32UI; gl_pixel_format = GL_RGBA; break;
		case tf_depth_component16: gl_internal_format = GL_DEPTH_COMPONENT16; gl_pixel_format = GL_DEPTH_COMPONENT; break;
		case tf_depth_component24: gl_internal_format = GL_DEPTH_COMPONENT24; gl_pixel_format = GL_DEPTH_COMPONENT; break;
		case tf_depth_component32: gl_internal_format = GL_DEPTH_COMPONENT32; gl_pixel_format = GL_DEPTH_COMPONENT; break;
		//case tf_depth_component32f: gl_internal_format = GL_DEPTH_COMPONENT32F; gl_pixel_format = GL_DEPTH_COMPONENT; break;
		//case tf_depth24_stencil8: gl_internal_format = GL_DEPTH24_STENCIL8; gl_pixel_format = GL_DEPTH_STENCIL; break;
		//case tf_depth32f_stencil8: gl_internal_format = GL_DEPTH32F_STENCIL8; gl_pixel_format = GL_DEPTH_STENCIL; break;

		//case tf_compressed_red: gl_internal_format = GL_COMPRESSED_RED; gl_pixel_format = GL_RED; break;
		//case tf_compressed_rg: gl_internal_format = GL_COMPRESSED_RG; gl_pixel_format = GL_RG; break;
		case tf_compressed_rgb: gl_internal_format = GL_COMPRESSED_RGB; gl_pixel_format = GL_RGB; break;
		case tf_compressed_rgba: gl_internal_format = GL_COMPRESSED_RGBA; gl_pixel_format = GL_RGBA; break;
		//case tf_compressed_srgb: gl_internal_format = GL_COMPRESSED_SRGB; gl_pixel_format = GL_RGB; break;
		//case tf_compressed_srgb_alpha: gl_internal_format = GL_COMPRESSED_SRGB_ALPHA; gl_pixel_format = GL_RGBA; break;
		//case tf_compressed_red_rgtc1: gl_internal_format = GL_COMPRESSED_RED_RGTC1; gl_pixel_format = GL_RED; break;
		//case tf_compressed_signed_red_rgtc1: gl_internal_format = GL_COMPRESSED_SIGNED_RED_RGTC1; gl_pixel_format = GL_RED; break;
		//case tf_compressed_rg_rgtc2: gl_internal_format = GL_COMPRESSED_RG_RGTC2; gl_pixel_format = GL_RG; break;
		//case tf_compressed_signed_rg_rgtc2: gl_internal_format = GL_COMPRESSED_SIGNED_RG_RGTC2; gl_pixel_format = GL_RG; break;

		case tf_compressed_rgb_s3tc_dxt1: gl_internal_format = GL_COMPRESSED_RGB_S3TC_DXT1_EXT; gl_pixel_format = GL_RGB; break;
		case tf_compressed_rgba_s3tc_dxt1: gl_internal_format = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; gl_pixel_format = GL_RGBA; break;
		case tf_compressed_rgba_s3tc_dxt3: gl_internal_format = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; gl_pixel_format = GL_RGBA; break;
		case tf_compressed_rgba_s3tc_dxt5: gl_internal_format = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; gl_pixel_format = GL_RGBA; break;
		//case tf_compressed_srgb_s3tc_dxt1: gl_internal_format = GL_COMPRESSED_SRGB_S3TC_DXT1_EXT; gl_pixel_format = GL_RGB; break;
		//case tf_compressed_srgb_alpha_s3tc_dxt1: gl_internal_format = GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT; gl_pixel_format = GL_RGBA; break;
		//case tf_compressed_srgb_alpha_s3tc_dxt3: gl_internal_format = GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT; gl_pixel_format = GL_RGBA; break;
		//case tf_compressed_srgb_alpha_s3tc_dxt5: gl_internal_format = GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT; gl_pixel_format = GL_RGBA; break;

		default:
			throw Exception(string_format("Unsupported TextureFormat (%1)", format));
	}
}
开发者ID:ARMCoderCHS,项目名称:ClanLib,代码行数:101,代码来源:gl1_texture_provider.cpp

示例8: BaseObjectWidget

FunctionWidget::FunctionWidget(QWidget *parent): BaseObjectWidget(parent, OBJ_FUNCTION)
{
	try
	{
		QStringList types;
		QGridLayout *grid=nullptr, *grid1=nullptr;
    QVBoxLayout *vlayout=nullptr;
    QSpacerItem *spacer=nullptr;

		map<QString, vector<QWidget *> > fields_map;
		map<QWidget *, vector<QString> > value_map;
		QFrame *frame=nullptr;

		Ui_FunctionWidget::setupUi(this);

		configureFormLayout(function_grid, OBJ_FUNCTION);
		connect(parent_form->apply_ok_btn,SIGNAL(clicked(bool)), this, SLOT(applyConfiguration(void)));

    source_code_hl=new SyntaxHighlighter(source_code_txt);
		source_code_cp=new CodeCompletionWidget(source_code_txt);

		ret_type=new PgSQLTypeWidget(this);
    vlayout=new QVBoxLayout;
    spacer=new QSpacerItem(5,5,QSizePolicy::Preferred,QSizePolicy::Expanding);
    vlayout->addWidget(ret_type);
    vlayout->addSpacerItem(spacer);

		return_tab=new ObjectTableWidget(ObjectTableWidget::ALL_BUTTONS ^
																			 ObjectTableWidget::UPDATE_BUTTON, true, this);
		return_tab->setColumnCount(2);
		return_tab->setHeaderLabel(trUtf8("Column"), 0);
    return_tab->setHeaderIcon(QPixmap(QString(":/icones/icones/column.png")),0);
		return_tab->setHeaderLabel(trUtf8("Type"), 1);
    return_tab->setHeaderIcon(QPixmap(QString(":/icones/icones/usertype.png")),1);

		parameters_tab=new ObjectTableWidget(ObjectTableWidget::ALL_BUTTONS ^
																					 ObjectTableWidget::UPDATE_BUTTON, true, this);
		parameters_tab->setColumnCount(4);
		parameters_tab->setHeaderLabel(trUtf8("Name"),0);
    parameters_tab->setHeaderIcon(QPixmap(QString(":/icones/icones/parameter.png")),0);
		parameters_tab->setHeaderLabel(trUtf8("Type"),1);
    parameters_tab->setHeaderIcon(QPixmap(QString(":/icones/icones/usertype.png")),1);
		parameters_tab->setHeaderLabel(trUtf8("Mode"),2);
		parameters_tab->setHeaderLabel(trUtf8("Default Value"),3);

		grid=new QGridLayout;
		grid->addWidget(parameters_tab,0,0,1,1);
		grid->setContentsMargins(4,4,4,4);
		func_config_twg->widget(1)->setLayout(grid);

		grid=dynamic_cast<QGridLayout *>(func_config_twg->widget(0)->layout());
    grid->addLayout(vlayout, grid->count(), 0, 1, 5);
		grid->addWidget(ret_table_gb, grid->count()-1, 0, 1, 5);

		grid1=new QGridLayout;
		grid1->addWidget(return_tab, 0, 0, 1, 1);
		grid1->setContentsMargins(2,2,2,2);
		ret_table_gb->setLayout(grid1);
		ret_table_gb->setVisible(false);

    fields_map[generateVersionsInterval(AFTER_VERSION, PgSQLVersions::PGSQL_VERSION_92)].push_back(leakproof_chk);
		frame=generateVersionWarningFrame(fields_map, &value_map);
		grid->addWidget(frame, grid->count()+1, 0, 1, 5);
		frame->setParent(func_config_twg->widget(0));

		parent_form->setMinimumSize(645, 675);

		SecurityType::getTypes(types);
		security_cmb->addItems(types);

		FunctionType::getTypes(types);
		func_type_cmb->addItems(types);

		BehaviorType::getTypes(types);
		behavior_cmb->addItems(types);

		connect(simple_rb, SIGNAL(clicked(bool)), this, SLOT(alternateReturnTypes(void)));
		connect(set_rb, SIGNAL(clicked(bool)), this, SLOT(alternateReturnTypes(void)));
		connect(table_rb, SIGNAL(clicked(bool)), this, SLOT(alternateReturnTypes(void)));
		connect(language_cmb, SIGNAL(currentIndexChanged(int)), this, SLOT(selectLanguage(void)));

		connect(parameters_tab, SIGNAL(s_rowAdded(int)), this, SLOT(showParameterForm()));
		connect(parameters_tab, SIGNAL(s_rowEdited(int)), this, SLOT(showParameterForm()));
		connect(return_tab, SIGNAL(s_rowAdded(int)), this, SLOT(showParameterForm()));
		connect(return_tab, SIGNAL(s_rowEdited(int)), this, SLOT(showParameterForm()));

		setRequiredField(language_lbl);
		setRequiredField(ret_method_lbl);
		setRequiredField(symbol_lbl);
		setRequiredField(library_lbl);
		setRequiredField(sourc_code_lbl);
    configureTabOrder();
	}
	catch(Exception &e)
	{
		throw Exception(e.getErrorMessage(),e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e);
	}
}
开发者ID:InnovaMex,项目名称:pgmodeler,代码行数:98,代码来源:functionwidget.cpp

示例9: while

void FunctionWidget::validateConfiguredFunction(void)
{
	vector<BaseObject *>::iterator itr, itr_end;
	vector<BaseObject *> obj_list;
	Conversion *conv=nullptr;
	Cast *cast=nullptr;
	Aggregate *aggr=nullptr;
	Language *lang=nullptr;
	Operator *oper=nullptr;
	Type *type=nullptr;
	Function *func=nullptr;
	BaseObject *object=nullptr;
	ObjectType obj_type;
	unsigned i1=0;

	func=dynamic_cast<Function *>(this->object);

	try
	{
		model->getObjectReferences(func, obj_list);
		itr=obj_list.begin();
		itr_end=obj_list.end();

		while(itr!=itr_end)
		{
			object=(*itr);
			obj_type=object->getObjectType();
			itr++;

			/* The validation of the function happens as follows:

				For each type of object in vector 'types' is obtained the list of objects.
				If there are elements in this list, the function is assigned for each element
				and these elements internally validates the function according to required by the
				each class rules.

				If the function is invalid the instances raises	exceptions accusing the error
				that is enough to check	the validity of the function in relation to objects that reference it. */
			if(obj_type==OBJ_CONVERSION)
			{
				conv=dynamic_cast<Conversion *>(object);
				if(conv->getConversionFunction()==func)
					conv->setConversionFunction(func);
			}
			else if(obj_type==OBJ_CAST)
			{
				cast=dynamic_cast<Cast *>(object);
				if(cast->getCastFunction()==func)
					cast->setCastFunction(func);
			}
			else if(obj_type==OBJ_AGGREGATE)
			{
				aggr=dynamic_cast<Aggregate *>(object);
				if(aggr->getFunction(Aggregate::FINAL_FUNC)==func)
					aggr->setFunction(Aggregate::FINAL_FUNC, func);
				else if(aggr->getFunction(Aggregate::TRANSITION_FUNC)==func)
					aggr->setFunction(Aggregate::TRANSITION_FUNC, func);
			}
			else if(obj_type==OBJ_TRIGGER)
			{
				dynamic_cast<Trigger *>(object)->setFunction(func);
			}
			else if(obj_type==OBJ_LANGUAGE)
			{
				lang=dynamic_cast<Language *>(object);

				for(i1=Language::VALIDATOR_FUNC; i1 <= Language::INLINE_FUNC; i1++)
				{
					if(lang->getFunction(i1)==func)
						lang->setFunction(func, i1);
				}
			}
			else if(obj_type==OBJ_OPERATOR)
			{
				oper=dynamic_cast<Operator *>(object);
				for(i1=Operator::FUNC_OPERATOR; i1 <= Operator::FUNC_RESTRICT; i1++)
				{
					if(oper->getFunction(i1)==func)
						oper->setFunction(func, i1);
				}
			}
			else if(obj_type==OBJ_TYPE)
			{
				type=dynamic_cast<Type *>(object);
				if(type->getConfiguration()==Type::BASE_TYPE)
				{
					for(i1=Type::INPUT_FUNC; i1 <=Type::ANALYZE_FUNC; i1++)
					{
						if(type->getFunction(i1)==func)
							type->setFunction(i1, func);
					}
				}
			}
			else if(obj_type==OBJ_EVENT_TRIGGER)
			{
				dynamic_cast<EventTrigger *>(object)->setFunction(func);
			}
		}
	}
	catch(Exception &e)
//.........这里部分代码省略.........
开发者ID:InnovaMex,项目名称:pgmodeler,代码行数:101,代码来源:functionwidget.cpp

示例10: HHVM_FUNCTION

bool HHVM_FUNCTION(trigger_error, const String& error_msg,
                   int error_type /* = k_E_USER_NOTICE */) {
  std::string msg = error_msg.data(); // not toCppString()
  if (UNLIKELY(g_context->getThrowAllErrors())) {
    throw Exception(folly::sformat("throwAllErrors: {}", error_type));
  }
  if (error_type == k_E_USER_ERROR) {
    g_context->handleError(msg, error_type, true,
                           ExecutionContext::ErrorThrowMode::IfUnhandled,
                           "\nFatal error: ");
    return true;
  }
  if (error_type == k_E_USER_WARNING) {
    g_context->handleError(msg, error_type, true,
                           ExecutionContext::ErrorThrowMode::Never,
                           "\nWarning: ");
    return true;
  }
  if (error_type == k_E_USER_NOTICE) {
    g_context->handleError(msg, error_type, true,
                           ExecutionContext::ErrorThrowMode::Never,
                           "\nNotice: ");
    return true;
  }
  if (error_type == k_E_USER_DEPRECATED) {
    g_context->handleError(msg, error_type, true,
                           ExecutionContext::ErrorThrowMode::Never,
                           "\nDeprecated: ");
    return true;
  }
  if (error_type == k_E_STRICT) {
    // So that we can raise strict warnings for mismatched
    // params in FCallBuiltin
    raise_strict_warning(msg);
    return true;
  }

  ActRec* fp = g_context->getStackFrame();

  if (fp->m_func->nativeFuncPtr() == (BuiltinFunction)HHVM_FN(trigger_error)) {
    fp = g_context->getOuterVMFrame(fp);
  }
  if (fp && fp->m_func->isBuiltin()) {
    if (error_type == k_E_ERROR) {
      raise_error_without_first_frame(msg);
      return true;
    }
    if (error_type == k_E_WARNING) {
      raise_warning_without_first_frame(msg);
      return true;
    }
    if (error_type == k_E_NOTICE) {
      raise_notice_without_first_frame(msg);
      return true;
    }
    if (error_type == k_E_DEPRECATED) {
      raise_deprecated_without_first_frame(msg);
      return true;
    }
    if (error_type == k_E_RECOVERABLE_ERROR) {
      raise_recoverable_error_without_first_frame(msg);
      return true;
    }
  }
  raise_warning("Invalid error type specified");
  return false;
}
开发者ID:MatmaRex,项目名称:hhvm,代码行数:67,代码来源:ext_std_errorfunc.cpp

示例11: BaseConfigWidget

SnippetsConfigWidget::SnippetsConfigWidget(QWidget * parent) : BaseConfigWidget(parent)
{
  QPixmap ico;
  QString gen_purpose=trUtf8("General purpose");
  map<QString, ObjectType> types_map;
  vector<ObjectType> types=BaseObject::getObjectTypes(true, {OBJ_RELATIONSHIP, OBJ_TAG, OBJ_TEXTBOX,
                                                             OBJ_PERMISSION, BASE_RELATIONSHIP });

  setupUi(this);

  for(ObjectType type : types)
    types_map[BaseObject::getTypeName(type)]=type;

  //Creates a combo with the accepted object type
  for(auto itr : types_map)
  {
    ico.load(QString(":/icones/icones/%1.png").arg(BaseObject::getSchemaName(itr.second)));
    applies_to_cmb->addItem(ico, itr.first, itr.second);
    filter_cmb->addItem(ico, itr.first, itr.second);
  }

  applies_to_cmb->insertItem(0, gen_purpose, BASE_OBJECT);
  applies_to_cmb->setCurrentIndex(0);

  filter_cmb->insertItem(0, gen_purpose, BASE_OBJECT);
  filter_cmb->insertItem(0, trUtf8("All snippets"));
  filter_cmb->setCurrentIndex(0);

  parsable_ht=new HintTextWidget(parsable_hint, this);
  parsable_ht->setText(parsable_chk->statusTip());

  placeholders_ht=new HintTextWidget(placeholders_hint, this);
  placeholders_ht->setText(placeholders_chk->statusTip());

  try
  {
    snippet_hl=new SyntaxHighlighter(snippet_txt, false);
    snippet_hl->loadConfiguration(GlobalAttributes::SQL_HIGHLIGHT_CONF_PATH);
  }
  catch(Exception &e)
  {
    throw Exception(e.getErrorMessage(),e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__,&e);
  }

  enableEditMode(false);

  connect(new_tb, SIGNAL(clicked()), this, SLOT(resetForm()));
  connect(edit_tb, SIGNAL(clicked()), this, SLOT(editSnippet()));
  connect(remove_tb, SIGNAL(clicked()), this, SLOT(removeSnippet()));
  connect(remove_all_tb, SIGNAL(clicked()), this, SLOT(removeAllSnippets()));
  connect(cancel_tb, &QToolButton::clicked, [=](){ enableEditMode(false); });
  connect(snippets_cmb, &QComboBox::currentTextChanged, [=](){ enableEditMode(false); });
  connect(id_edt, SIGNAL(textChanged(QString)), this, SLOT(enableSaveButtons()));
  connect(label_edt, SIGNAL(textChanged(QString)), this, SLOT(enableSaveButtons()));
  connect(snippet_txt, SIGNAL(textChanged()), this, SLOT(enableSaveButtons()));
  connect(parsable_chk, SIGNAL(toggled(bool)), this, SLOT(enableSaveButtons()));
  connect(filter_cmb, SIGNAL(currentIndexChanged(int)), this, SLOT(filterSnippets(int)));
  connect(update_tb, SIGNAL(clicked()), this, SLOT(handleSnippet()));
  connect(add_tb, SIGNAL(clicked()), this, SLOT(handleSnippet()));
  connect(parse_tb, SIGNAL(clicked()), this, SLOT(parseSnippet()));
  connect(parsable_chk, SIGNAL(toggled(bool)), placeholders_chk, SLOT(setEnabled(bool)));
}
开发者ID:Halfnhav,项目名称:pgmodeler,代码行数:62,代码来源:snippetsconfigwidget.cpp

示例12: Exception

void FileOutputStream::flush() {
	if (buf_pos > 0 && fwrite((void*) buffer, sizeof(char), buf_pos, fp) != buf_pos)
			throw Exception(Exception::ERR_FILE_WRITE);
	buf_pos = 0;
	fflush(fp);
}
开发者ID:herolic,项目名称:ppm,代码行数:6,代码来源:FileIOStream.cpp

示例13: while


//.........这里部分代码省略.........
        {
          //For commom broken reference, check if the object id is greater than the reference id
          if(obj_id > refs.back()->getObjectId())
          {
            obj=refs.back();
            obj_id=obj->getObjectId();
          }

          refs.pop_back();
        }
      }

			//Swap the id of the validation object and the found object (minor id)
			if(obj)
      {
        BaseObject::swapObjectsIds(info_obj, obj, true);
        aux_obj=obj;
      }
      else
      {
        BaseObject::updateObjectId(info_obj);
        aux_obj=info_obj;
      }

      if(aux_obj->getObjectType()==OBJ_VIEW)
      {
        vector<BaseRelationship *> base_rels=db_model->getRelationships(dynamic_cast<BaseTable *>(aux_obj));
        for(auto rel : base_rels)
          BaseObject::updateObjectId(rel);
      }

			sleepThread(5);
		}
		//Resolving no unique name by renaming the constraints/indexes
		else if(info.getValidationType()==ValidationInfo::NO_UNIQUE_NAME)
		{
			unsigned suffix=1;
			QString new_name;
			Table *table=nullptr;
			ObjectType obj_type;
			BaseObject *obj=info.getObject();
			TableObject *tab_obj=nullptr;

			/* If the last element of the referrer objects is a table or view the
			info object itself need to be renamed since tables and views will not be renamed */
			bool rename_obj=(refs.back()->getObjectType()==OBJ_TABLE ||
											 refs.back()->getObjectType()==OBJ_VIEW);

			if(rename_obj)
			{
				table=dynamic_cast<Table *>(dynamic_cast<TableObject *>(obj)->getParentTable());
				obj_type=obj->getObjectType();

				do
				{
					//Configures a new name for the object [name]_[suffix]
					new_name=QString("%1_%2").arg(obj->getName()).arg(suffix);
					suffix++;
				}
				//Generates a new name until no object is found on parent table
				while(table->getObjectIndex(new_name, obj_type) >= 0);

				//Renames the object
				obj->setName(new_name);
			}

			//Renaming the referrer objects
			while(!refs.empty() && !valid_canceled)
			{
				obj_type=refs.back()->getObjectType();
				tab_obj=dynamic_cast<TableObject *>(refs.back());

				//Tables and view aren't renamed only table child objects (constraints, indexes)
				if(tab_obj && !tab_obj->isAddedByRelationship())
				{
					table=dynamic_cast<Table *>(tab_obj->getParentTable());

					do
					{
						//Configures a new name for the object [name]_[suffix]
						new_name=QString("%1_%2").arg(refs.back()->getName()).arg(suffix);
						suffix++;
					}
					//Generates a new name until no object is found on parent table
					while(table->getObjectIndex(new_name, obj_type) >= 0);

					//Renames the referrer object
					refs.back()->setName(new_name);
				}

				refs.pop_back();
				sleepThread(5);
			}
		}
	}
	catch(Exception &e)
	{
		throw Exception(e.getErrorMessage(), e.getErrorType(),__PRETTY_FUNCTION__,__FILE__,__LINE__, &e);
	}
}
开发者ID:hana12169,项目名称:pgmodeler,代码行数:101,代码来源:modelvalidationhelper.cpp

示例14: Exception

void ModelValidationHelper::validateModel(void)
{
	if(!db_model)
		throw Exception(ERR_OPR_NOT_ALOC_OBJECT,__PRETTY_FUNCTION__,__FILE__,__LINE__);

	try
	{
		ObjectType types[]={ OBJ_ROLE, OBJ_TABLESPACE, OBJ_SCHEMA, OBJ_LANGUAGE, OBJ_FUNCTION,
												 OBJ_TYPE, OBJ_DOMAIN, OBJ_SEQUENCE, OBJ_OPERATOR, OBJ_OPFAMILY,
												 OBJ_OPCLASS, OBJ_COLLATION, OBJ_TABLE, OBJ_EXTENSION, OBJ_VIEW, OBJ_RELATIONSHIP },
								aux_types[]={ OBJ_TABLE, OBJ_VIEW },
               tab_obj_types[]={ OBJ_CONSTRAINT, OBJ_INDEX },
        obj_type;
		unsigned i, i1, cnt, aux_cnt=sizeof(aux_types)/sizeof(ObjectType),
						count=sizeof(types)/sizeof(ObjectType), count1=sizeof(tab_obj_types)/sizeof(ObjectType);
		BaseObject *object=nullptr, *refer_obj=nullptr;
		vector<BaseObject *> refs, refs_aux, *obj_list=nullptr;
		vector<BaseObject *>::iterator itr;
		TableObject *tab_obj=nullptr;
		Table *table=nullptr, *ref_tab=nullptr, *recv_tab=nullptr;
		Constraint *constr=nullptr;
		Relationship *rel=nullptr;
		map<QString, vector<BaseObject *> > dup_objects;
		map<QString, vector<BaseObject *> >::iterator mitr;
		QString name, signal_msg="`%1' (%2)";

		warn_count=error_count=progress=0;
		val_infos.clear();
		valid_canceled=false;

		/* Step 1: Validating broken references. This situation happens when a object references another
		whose id is smaller than the id of the first one. */
		for(i=0; i < count && !valid_canceled; i++)
		{
			obj_list=db_model->getObjectList(types[i]);
			itr=obj_list->begin();

			while(itr!=obj_list->end()&& !valid_canceled)
			{
				object=(*itr);
        obj_type=object->getObjectType();
				itr++;

				//Excluding the validation of system objects (created automatically)
				if(!object->isSystemObject())
				{
					emit s_objectProcessed(signal_msg.arg(object->getName()).arg(object->getTypeName()), object->getObjectType());

					/* Special validation case: For generalization and copy relationships validates the ids of participant tables.
					 * Reference table cannot own an id greater thant receiver table */
          if(obj_type==OBJ_RELATIONSHIP)
					{
						rel=dynamic_cast<Relationship *>(object);
						if(rel->getRelationshipType()==Relationship::RELATIONSHIP_GEN ||
							 rel->getRelationshipType()==Relationship::RELATIONSHIP_DEP)
						{
							recv_tab=rel->getReceiverTable();
							ref_tab=rel->getReferenceTable();

							if(ref_tab->getObjectId() > recv_tab->getObjectId())
							{
								object=ref_tab;
								refs_aux.push_back(recv_tab);
							}
						}
					}
					else
					{
						db_model->getObjectReferences(object, refs);
						refs_aux.clear();

						while(!refs.empty() && !valid_canceled)
						{
							//Checking if the referrer object is a table object. In this case its parent table is considered
							tab_obj=dynamic_cast<TableObject *>(refs.back());
							constr=dynamic_cast<Constraint *>(tab_obj);

							/* If the current referrer object has an id less than reference object's id
						then it will be pushed into the list of invalid references. The only exception is
						for foreign keys that are discarded from any validation since they are always created
						at end of code defintion being free of any reference breaking. */
							if(object != refs.back() &&
								 (!constr || (constr && constr->getConstraintType()!=ConstraintType::foreign_key)) &&
								 ((!tab_obj && refs.back()->getObjectId() <= object->getObjectId()) ||
									(tab_obj && !tab_obj->isAddedByRelationship() &&
									 tab_obj->getParentTable()->getObjectId() <= object->getObjectId())))
							{
								if(tab_obj)
									refer_obj=tab_obj->getParentTable();
								else
									refer_obj=refs.back();

								//Push the referrer object only if not exists on the list
								if(std::find(refs_aux.begin(), refs_aux.end(), refer_obj)==refs_aux.end())
									refs_aux.push_back(refer_obj);
							}

							refs.pop_back();
						}

//.........这里部分代码省略.........
开发者ID:hana12169,项目名称:pgmodeler,代码行数:101,代码来源:modelvalidationhelper.cpp

示例15: throw_if_disposed

void GL1TextureProvider::create(int new_width, int new_height, int new_depth, int array_size, TextureFormat texture_format, int levels)
{
	throw_if_disposed();

	GLint gl_internal_format;
	GLenum gl_pixel_format;
	to_opengl_textureformat(texture_format, gl_internal_format, gl_pixel_format);

	if ( (new_width > 32768) || (new_width < 1) )
	{
		throw Exception("Invalid texture width in the GL1 target");
	}

	if ( (texture_type == GL_TEXTURE_2D) || (texture_type == GL_TEXTURE_3D) )
	{
		if ( (new_height > 32768) || (new_height < 1) )
		{
			throw Exception("Invalid texture height in the GL1 target");
		}
	}

	if ( texture_type == GL_TEXTURE_3D )
	{
		if ( (new_depth > 32768) || (new_depth < 1) )
		{
			throw Exception("Invalid texture depth in the GL1 target");
		}
	}

	width = new_width;
	height = new_height;
	depth = new_depth;
	GL1TextureStateTracker state_tracker(texture_type, handle);

#ifndef __ANDROID__
	if (texture_type == GL_TEXTURE_1D)
	{
		pot_width = get_next_power_of_two(new_width);
		if (pot_width == new_width)
		{
			power_of_two_texture=true;
		}
		else
		{
			power_of_two_texture=false;
		}

		pot_ratio_width = (float) width / pot_width;
		glTexImage1D(
			GL_TEXTURE_1D,			// target
			0,						// level
			gl_internal_format,		// internalformat
			pot_width,				// width
			0,						// border
			gl_pixel_format,		// format
			GL_UNSIGNED_BYTE,		// type (it really doesn't matter since nothing is uploaded)
			nullptr);						// texels (0 to avoid uploading)
	}
#endif
	if (texture_type == GL_TEXTURE_2D)
	{
		pot_width = get_next_power_of_two(new_width);
		pot_height = get_next_power_of_two(new_height);
		if ( (pot_width == new_width) && (pot_height == new_height))
		{
			power_of_two_texture=true;
		}
		else
		{
			power_of_two_texture=false;
		}
		pot_ratio_width = (float) width / pot_width;
		pot_ratio_height = (float) height / pot_height;

		glTexImage2D(
			GL_TEXTURE_2D,			// target
			0,						// level
			gl_internal_format,		// internalformat
			pot_width,				// width
			pot_height,				// height
			0,						// border
			gl_pixel_format,		// format 
			GL_UNSIGNED_BYTE,		// type (it really doesn't matter since nothing is uploaded)
			nullptr);						// texels (0 to avoid uploading)

		// Clear the whole texture if it is npot
		if (!power_of_two_texture)
		{
			PixelBuffer image = PixelBuffer(pot_width, pot_height, tf_rgba8);
			void *data = image.get_data();
			memset(data, 0, pot_width * pot_height * 4);

			GLenum format;
			GLenum type;
			to_opengl_pixelformat(image, format, type);

			glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
			const int bytesPerPixel = image.get_bytes_per_pixel();
#ifndef __ANDROID__
			glPixelStorei(GL_UNPACK_ROW_LENGTH, image.get_pitch() / bytesPerPixel);
//.........这里部分代码省略.........
开发者ID:ARMCoderCHS,项目名称:ClanLib,代码行数:101,代码来源:gl1_texture_provider.cpp


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