本文整理汇总了C++中Uint16函数的典型用法代码示例。如果您正苦于以下问题:C++ Uint16函数的具体用法?C++ Uint16怎么用?C++ Uint16使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Uint16函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Uint16
Uint16 UNIX_ComputerSystem::getPrimaryStatus() const
{
return Uint16(DEFAULT_PRIMARY_STATUS);
}
示例2: Set
void CIMError::setErrorType(ErrorTypeEnum value, bool null)
{
Set(_inst, "ErrorType", Uint16(value), null);
}
示例3: send
void Split_UDP_Socket::send(const IPaddress &ip, const std::string &data) {
send(ip, data.c_str(), Uint16(data.size()));
}
示例4: setVibration
bool Joystick::setVibration(float left, float right, float duration)
{
left = std::min(std::max(left, 0.0f), 1.0f);
right = std::min(std::max(right, 0.0f), 1.0f);
if (left == 0.0f && right == 0.0f)
return setVibration();
if (!checkCreateHaptic())
return false;
Uint32 length = SDL_HAPTIC_INFINITY;
if (duration >= 0.0f)
{
float maxduration = std::numeric_limits<Uint32>::max() / 1000.0f;
length = Uint32(std::min(duration, maxduration) * 1000);
}
bool success = false;
unsigned int features = SDL_HapticQuery(haptic);
int axes = SDL_HapticNumAxes(haptic);
if ((features & SDL_HAPTIC_LEFTRIGHT) != 0)
{
memset(&vibration.effect, 0, sizeof(SDL_HapticEffect));
vibration.effect.type = SDL_HAPTIC_LEFTRIGHT;
vibration.effect.leftright.length = length;
vibration.effect.leftright.large_magnitude = Uint16(left * LOVE_UINT16_MAX);
vibration.effect.leftright.small_magnitude = Uint16(right * LOVE_UINT16_MAX);
success = runVibrationEffect();
}
// Some gamepad drivers only give support for controlling individual motors
// through a custom FF effect.
if (!success && isGamepad() && (features & SDL_HAPTIC_CUSTOM) && axes == 2)
{
// NOTE: this may cause issues with drivers which support custom effects
// but aren't similar to https://github.com/d235j/360Controller .
// Custom effect data is clamped to 0x7FFF in SDL.
vibration.data[0] = vibration.data[2] = Uint16(left * 0x7FFF);
vibration.data[1] = vibration.data[3] = Uint16(right * 0x7FFF);
memset(&vibration.effect, 0, sizeof(SDL_HapticEffect));
vibration.effect.type = SDL_HAPTIC_CUSTOM;
vibration.effect.custom.length = length;
vibration.effect.custom.channels = 2;
vibration.effect.custom.period = 10;
vibration.effect.custom.samples = 2;
vibration.effect.custom.data = vibration.data;
success = runVibrationEffect();
}
// Fall back to a simple sine wave if all else fails. This only supports a
// single strength value.
if (!success && (features & SDL_HAPTIC_SINE) != 0)
{
memset(&vibration.effect, 0, sizeof(SDL_HapticEffect));
vibration.effect.type = SDL_HAPTIC_SINE;
vibration.effect.periodic.length = length;
vibration.effect.periodic.period = 10;
float strength = std::max(left, right);
vibration.effect.periodic.magnitude = Sint16(strength * 0x7FFF);
success = runVibrationEffect();
}
if (success)
{
vibration.left = left;
vibration.right = right;
if (length == SDL_HAPTIC_INFINITY)
vibration.endtime = SDL_HAPTIC_INFINITY;
else
vibration.endtime = SDL_GetTicks() + length;
}
else
{
vibration.left = vibration.right = 0.0f;
vibration.endtime = SDL_HAPTIC_INFINITY;
}
return success;
}
示例5: Uint16
Uint16 ZoneMap::addEntity(Entity p_entity)
{
m_entities.push_back(p_entity);
return Uint16(m_entities.size());
}
示例6: Uint16
Uint16 UNIX_AssociatedProtocolController::getAccessState() const
{
return Uint16(0);
}
开发者ID:brunolauze,项目名称:openpegasus-providers-old,代码行数:4,代码来源:UNIX_AssociatedProtocolController_ZOS.hpp
示例7: Uint16
Uint16 UNIX_ClassifierFilterSet::getFilterListPosition() const
{
return Uint16(0);
}
示例8: _mkdir
void ZoneMap::save(std::string p_zoneName)
{
std::cout << "Saving map map\\zones\\" << p_zoneName << "... ";
m_mapName = p_zoneName;
std::ofstream _file;
_mkdir(std::string("map").c_str());
_mkdir(std::string("map\\zones").c_str());
_mkdir(std::string("map\\zones\\" + m_mapName).c_str());
_mkdir(std::string("map\\zones\\" + m_mapName + "\\entities").c_str());
// Save Info
_file.open(std::string("map\\zones\\" + m_mapName + "\\Info.cfg"), std::ios::binary);
{
FileExt::writeShort(_file, m_mapSize.x);
FileExt::writeShort(_file, m_mapSize.y);
}
_file.close();
// Save Ground
_file.open(std::string("map\\zones\\" + m_mapName + "\\Ground.tmf"), std::ios::binary);
{
Uint16 _tCount = 0;
Uint16 _tile = m_tileData[0][0][0];
for(Uint16 y = 0; y < m_mapSize.y; y++)
{
for(Uint16 x = 0; x < m_mapSize.x; x++)
{
if(_tile == m_tileData[0][x][y] && _tCount < 255)
_tCount++;
else
{
FileExt::writeShort(_file, _tCount);
FileExt::writeShort(_file, _tile);
_tCount = 1;
_tile = m_tileData[0][x][y];
}
}
}
if(_tCount != 0)
{
FileExt::writeShort(_file, _tCount);
FileExt::writeShort(_file, _tile);
}
}
_file.close();
// Save World
_file.open(std::string("map\\zones\\" + m_mapName + "\\World.tmf"), std::ios::binary);
{
FileExt::writeShort(_file, Uint16(m_worldObjects.size()));
std::vector<Uint8> _objData;
for(Uint16 i = 0; i < Uint16(m_worldObjects.size()); i++)
{
FileExt::writeChar(_file, Uint8(m_worldObjects[i].m_name.length()));
for(Uint16 j = 0; j < Uint16(min(m_worldObjects[i].m_name.length(), 128)); j++)
FileExt::writeChar(_file, Uint8(m_worldObjects[i].m_name[j]));
FileExt::writeShort(_file, Uint8(m_worldObjects[i].m_interactionType));
FileExt::writeShort(_file, Uint8(m_worldObjects[i].m_tileTex));
switch(m_worldObjects[i].m_interactionType)
{
case 0: // NONE
break;
case 1: // SOLID
break;
case 2: // SWITCH
FileExt::writeChar(_file, Uint8(m_worldObjects[i].m_frequency));
break;
case 3: // SOLID SWITCH
FileExt::writeChar(_file, Uint8(m_worldObjects[i].m_frequency));
break;
case 4: // PORTAL
FileExt::writeChar(_file, Uint8(m_worldObjects[i].m_frequency));
FileExt::writeChar(_file, Uint8(m_worldObjects[i].m_portalDest.length()));
for(Uint16 j = 0; j < Uint16(min(m_worldObjects[i].m_portalDest.length(), 128)); j++)
FileExt::writeChar(_file, Uint8(m_worldObjects[i].m_portalDest[j]));
FileExt::writeShort(_file, Uint8(m_worldObjects[i].m_destX));
FileExt::writeShort(_file, Uint8(m_worldObjects[i].m_destY));
break;
case 5: // DIRECTION
FileExt::writeChar(_file, Uint8(m_worldObjects[i].m_direction));
break;
case 6: // LIGHT
FileExt::writeChar(_file, Uint8(m_worldObjects[i].m_lightValue));
break;
}
}
Uint16 _tCount = 0;
Uint16 _tile = m_tileData[1][0][0];
for(Uint16 y = 0; y < m_mapSize.y; y++)
{
for(Uint16 x = 0; x < m_mapSize.x; x++)
{
if(_tile == m_tileData[1][x][y] && _tCount < 255)
_tCount++;
//.........这里部分代码省略.........
示例9: drive_resolve_primitive
void drive_resolve_primitive()
{
const char* env = getenv("PEGASUS_HOME");
String repositoryDir(env);
repositoryDir.append("/repository");
//String repositoryDir("c:/pegasus-cvs/pegasus/repository");
CIMNamespaceName _ns("root/cimv2");
CIMRepository *_rep = new CIMRepository(repositoryDir);
RepositoryQueryContext _query(_ns, _rep);
RepositoryQueryContext _query1(_ns, _rep);
try {
const CQLIdentifier _Id1(String("CIM_OperatingSystem"));
_query.insertClassPath(_Id1);
const CIMName _cimName(String("CIM_OperatingSystem"));
CIMInstance _i1(_cimName);
CIMProperty _p1(CIMName("Description"),CIMValue(String("Dave Rules")));
CIMProperty _p2(CIMName("EnabledState"),CIMValue(Uint16(2)));
CIMProperty _p3(CIMName("CurrentTimeZone"),CIMValue(Sint16(-600)));
CIMProperty _p4(CIMName("TimeOfLastStateChange"),
CIMValue(CIMDateTime(String("20040811105625.000000-360"))));
_i1.addProperty(_p1);
_i1.addProperty(_p2);
_i1.addProperty(_p3);
_i1.addProperty(_p4);
CQLChainedIdentifier ci1(
String("CIM_OperatingSystem.CIM_OperatingSystem::Description"));
CQLChainedIdentifier
ci2(String("CIM_OperatingSystem.CIM_OperatingSystem::EnabledState"));
CQLChainedIdentifier ci3(
String("CIM_OperatingSystem.CIM_OperatingSystem::CurrentTimeZone"));
CQLChainedIdentifier ci4(
String("CIM_OperatingSystem.CIM_OperatingSystem::TimeOfLastStateChange"));
CQLChainedIdentifier
ci5(String(
"CIM_OperatingSystem.CIM_EnabledLogicalElement::TimeOfLastStateChange"));
CQLChainedIdentifier
ci7(String("CIM_OperatingSystem"));
CQLChainedIdentifier
ci9(String(
"CIM_EnabledLogicalElement.CIM_OperatingSystem::CSCreationClassName"));
CQLChainedIdentifier
ci10(String("CIM_OperatingSystem.CIM_OperatingSystem::Bubba"));
CQLValue a1(ci1);
CQLValue a2(ci2);
CQLValue a3(ci3);
CQLValue a4(ci4);
CQLValue a5(ci5);
CQLValue a7(ci7);
CQLValue a9(ci9);
CQLValue a10(ci10);
CQLValue a11(_query.getClass(CIMName("CIM_OperatingSystem")));
a1.resolve(_i1, _query);
a2.resolve(_i1, _query);
a3.resolve(_i1, _query);
a4.resolve(_i1, _query);
a5.resolve(_i1, _query);
a7.resolve(_i1, _query);
a10.resolve(_i1, _query1);
a9.resolve(_i1, _query);
PEGASUS_TEST_ASSERT(a1 == CQLValue(String("Dave Rules")));
PEGASUS_TEST_ASSERT(a2 == CQLValue(Uint64(2)));
PEGASUS_TEST_ASSERT(a3 == CQLValue(Sint64(-600)));
PEGASUS_TEST_ASSERT(a4 == CQLValue(
CIMDateTime(String("20040811105625.000000-360"))));
PEGASUS_TEST_ASSERT(a5 == CQLValue(
CIMDateTime(String("20040811105625.000000-360"))));
//PEGASUS_TEST_ASSERT(a7 == CQLValue(_i1));
PEGASUS_TEST_ASSERT(a9.isNull());
PEGASUS_TEST_ASSERT(a10.isNull());
}
catch(Exception & e)
{
cout << e.getMessage() << endl;
PEGASUS_TEST_ASSERT(0);
}
delete _rep;
return;
}
示例10: clear
bool ZoneMap::load(std::string p_zoneName)
{
std::cout << "Loading map map\\zones\\" << p_zoneName << "... ";
std::ifstream _file;
_file.open(std::string("map\\zones\\" + p_zoneName + "\\Info.cfg").c_str(), std::ios::binary);
{
if(!_file.good())
{
std::cout << "No Info.cfg file found." << std::endl;
return false;
}
}
_file.close();
_file.open(std::string("map\\zones\\" + p_zoneName + "\\Ground.tmf").c_str(), std::ios::binary);
{
if(!_file.good())
{
std::cout << "No Ground.tmf file found." << std::endl;
return false;
}
}
_file.close();
_file.open(std::string("map\\zones\\" + p_zoneName + "\\World.tmf").c_str(), std::ios::binary);
{
if(!_file.good())
{
std::cout << "No World.tmf file found." << std::endl;
return false;
}
}
_file.close();
_file.open(std::string("map\\zones\\" + p_zoneName + "\\Entity.tmf").c_str(), std::ios::binary);
{
if(!_file.good())
{
std::cout << "No Entity.tmf file found." << std::endl;
return false;
}
}
_file.close();
_file.open(std::string("map\\zones\\" + p_zoneName + "\\Sky.tmf").c_str(), std::ios::binary);
{
if(!_file.good())
{
std::cout << "No Sky.tmf file found." << std::endl;
return false;
}
}
_file.close();
clear();
m_mapName = p_zoneName;
Uint32 _length, _index;
char* _data;
_file.open(std::string("map\\zones\\" + p_zoneName + "\\Info.cfg").c_str(), std::ios::binary);
{
_index = 0;
_file.seekg(0, _file.end);
_length = Uint32(_file.tellg());
_file.seekg(0, _file.beg);
_data = new char[_length];
_file.read(_data, _length);
m_mapSize.x = FileExt::readShort(_data, _index);
m_mapSize.y = FileExt::readShort(_data, _index);
init();
delete[] _data;
}
_file.close();
Uint16 _tileCount;
Uint16 _tileId, _mapIndex;
_file.open(std::string("map\\zones\\" + p_zoneName + "\\Ground.tmf").c_str(), std::ios::binary);
{
_mapIndex = 0;
_index = 0;
_file.seekg(0, _file.end);
_length = Uint32(_file.tellg());
_file.seekg(0, _file.beg);
_data = new char[_length];
_file.read(_data, _length);
while(_mapIndex < m_mapSize.x * m_mapSize.y && _index < _length)
{
_tileCount = FileExt::readShort(_data, _index);
_tileId = FileExt::readShort(_data, _index);
for(Uint16 i = 0; i < _tileCount; i++)
{
m_tileData[0][_mapIndex % m_mapSize.x][int(floor(GLfloat(_mapIndex) / m_mapSize.x))] = _tileId;
_mapIndex++;
//.........这里部分代码省略.........
示例11: drive_resolve_specialChars
void drive_resolve_specialChars()
{
const char* env = getenv("PEGASUS_HOME");
String repositoryDir(env);
repositoryDir.append("/repository");
//String repositoryDir("c:/pegasus-cvs/pegasus/repository");
CIMNamespaceName _ns("root/cimv2");
CIMRepository *_rep = new CIMRepository(repositoryDir);
RepositoryQueryContext _query(_ns, _rep);
RepositoryQueryContext _query1(_ns, _rep);
try {
const CQLIdentifier _Id1(String("CIM_OperatingSystem"));
_query.insertClassPath(_Id1);
const CIMName _cimName(String("CIM_OperatingSystem"));
CIMInstance _i1(_cimName);
CIMProperty _p1(CIMName("OSType"),CIMValue(Uint16(11)));
CIMProperty _p2(CIMName("Status"),CIMValue(String("Degraded")));
Array<Uint16> array16;
array16.append(Uint16(0));
array16.append(Uint16(1));
array16.append(Uint16(2));
array16.append(Uint16(3));
CIMProperty _p3(CIMName("OperationalStatus"),CIMValue(array16));
_i1.addProperty(_p1);
_i1.addProperty(_p2);
_i1.addProperty(_p3);
CQLChainedIdentifier ci1(String("CIM_OperatingSystem.OSType#OS400"));
CQLChainedIdentifier ci2(String("CIM_OperatingSystem.OSType#LINUX"));
CQLChainedIdentifier ci3(String("CIM_OperatingSystem.Status#Degraded"));
CQLChainedIdentifier ci5(String("CIM_OperatingSystem.Status#BOGUS"));
CQLChainedIdentifier ci6(
String("CIM_OperatingSystem.CIM_OperatingSystem::"
"OperationalStatus[2]"));
CQLValue a1(ci1);
CQLValue a2(ci2);
CQLValue a3(ci3);
CQLValue a5(ci5);
CQLValue a6(ci6);
a1.resolve(_i1, _query);
a2.resolve(_i1, _query);
a6.resolve(_i1, _query);
try
{
a3.resolve(_i1, _query);
PEGASUS_TEST_ASSERT(0);
}
catch(...)
{
PEGASUS_TEST_ASSERT(1);
}
try
{
a5.resolve(_i1, _query);
PEGASUS_TEST_ASSERT(0);
}
catch(...)
{
PEGASUS_TEST_ASSERT(1);
}
PEGASUS_TEST_ASSERT(a1 == CQLValue(Uint64(11)));
PEGASUS_TEST_ASSERT(a2 == CQLValue(Uint64(36)));
PEGASUS_TEST_ASSERT(a6 == CQLValue(Uint64(2)));
}
catch(Exception & e)
{
cout << e.getMessage() << endl;
PEGASUS_TEST_ASSERT(0);
}
delete _rep;
return;
}
示例12: drive_operation
//.........这里部分代码省略.........
array4.append(1);
array4.append(23);
array4.append(3);
array4.append(4);
array4.append(5);
array4.append(6);
array4.append(7);
array4.append(88);
array4.append(9);
array4.append(10);
Array<Sint64> array5;
array5.append(-1);
array5.append(2);
array5.append(3);
array5.append(4);
array5.append(5);
array5.append(-6);
array5.append(7);
array5.append(8);
array5.append(9);
array5.append(10);
array5.append(-3);
Array<Real64> array6;
array6.append(1.23);
array6.append(2.00);
array6.append(3.00);
array6.append(9.00);
array6.append(10.00);
array6.append(3.00);
array6.append(4.14);
array6.append(5.00);
array6.append(6.00);
array6.append(7.00);
array6.append(8.00);
CIMValue cv1(array1);
CIMValue cv2(array2);
CIMValue cv3(array3);
CIMValue cv4(array4);
CIMValue cv5(array5);
CIMValue cv6(array6);
CQLValue vr1(cv1);
CQLValue vr2(cv1);
CQLValue vr3(cv2);
CQLValue vr4(cv3);
CQLValue vr5(cv4);
CQLValue vr6(cv5);
CQLValue vr7(cv6);
PEGASUS_TEST_ASSERT(vr1 == vr2);
PEGASUS_TEST_ASSERT(vr1 == vr3);
PEGASUS_TEST_ASSERT(vr1 == vr4);
PEGASUS_TEST_ASSERT(vr4 == vr3);
PEGASUS_TEST_ASSERT(vr1 != vr5);
PEGASUS_TEST_ASSERT(vr3 != vr6);
PEGASUS_TEST_ASSERT(vr4 != vr7);
const CIMName _cimName(String("CIM_OperatingSystem"));
CIMInstance _i1(_cimName);
CIMProperty _p1(CIMName("Description"),CIMValue(String("Dave Rules")));
CIMProperty _p2(CIMName("EnabledState"),CIMValue(Uint16(2)));
CIMProperty _p3(CIMName("CurrentTimeZone"),CIMValue(Sint16(-600)));
CIMProperty _p4(CIMName("TimeOfLastStateChange"),
CIMValue(CIMDateTime(String("20040811105625.000000-360"))));
_i1.addProperty(_p1);
_i1.addProperty(_p2);
_i1.addProperty(_p3);
_i1.addProperty(_p4);
CIMInstance _i2(_cimName);
CIMProperty _p5(CIMName("Description"),
CIMValue(String("Dave Rules Everything")));
CIMProperty _p6(CIMName("EnabledState"),CIMValue(Uint16(2)));
CIMProperty _p7(CIMName("CurrentTimeZone"),CIMValue(Sint16(-600)));
CIMProperty _p8(CIMName("TimeOfLastStateChange"),
CIMValue(CIMDateTime(String("20040811105625.000000-360"))));
_i2.addProperty(_p5);
_i2.addProperty(_p6);
_i2.addProperty(_p7);
_i2.addProperty(_p8);
CQLValue cql1(_i1);
CQLValue cql2(_i1);
CQLValue cql3(_i2);
CQLValue cql4(_i2);
//PEGASUS_TEST_ASSERT(cql1 == cql1);
return;
}
示例13: main
int main(int argc, char **argv)
{
std::fprintf(stdout, "==========================================\n"
#ifdef HARDWARE_OPL3
" libADLMIDI demo utility (HW OPL)\n"
#else
" libADLMIDI demo utility\n"
#endif
"==========================================\n\n");
flushout(stdout);
if(argc < 2 || std::string(argv[1]) == "--help" || std::string(argv[1]) == "-h")
{
std::printf(
"Usage: adlmidi <midifilename> [ <options> ] [ <bank> [ <numchips> [ <numfourops>] ] ]\n"
" -p Enables adlib percussion instrument mode\n"
" -t Enables tremolo amplification mode\n"
" -v Enables vibrato amplification mode\n"
" -s Enables scaling of modulator volumes\n"
" -frb Enables full-ranged CC74 XG Brightness controller\n"
" -nl Quit without looping\n"
" -w Write WAV file rather than playing\n"
" -mb Run the test of multibank over embedded. 62, 14, 68, and 74'th banks will be combined into one\n"
" --solo <track> Selects a solo track to play\n"
" --only <track1,...,trackN> Selects a subset of tracks to play\n"
#ifndef HARDWARE_OPL3
" -fp Enables full-panning stereo support\n"
" --emu-nuked Uses Nuked OPL3 v 1.8 emulator\n"
" --emu-nuked7 Uses Nuked OPL3 v 1.7.4 emulator\n"
" --emu-dosbox Uses DosBox 0.74 OPL3 emulator\n"
#endif
"\n"
"Where <bank> - number of embeeded bank or filepath to custom WOPL bank file\n"
"\n"
"Note: To create WOPL bank files use OPL Bank Editor you can get here: \n"
"https://github.com/Wohlstand/OPL3BankEditor\n"
"\n"
);
// Get count of embedded banks (no initialization needed)
int banksCount = adl_getBanksCount();
//Get pointer to list of embedded bank names
const char *const *banknames = adl_getBankNames();
if(banksCount > 0)
{
std::printf(" Available embedded banks by number:\n\n");
for(int a = 0; a < banksCount; ++a)
std::printf("%10s%2u = %s\n", a ? "" : "Banks:", a, banknames[a]);
std::printf(
"\n"
" Use banks 2-5 to play Descent \"q\" soundtracks.\n"
" Look up the relevant bank number from descent.sng.\n"
"\n"
" The fourth parameter can be used to specify the number\n"
" of four-op channels to use. Each four-op channel eats\n"
" the room of two regular channels. Use as many as required.\n"
" The Doom & Hexen sets require one or two, while\n"
" Miles four-op set requires the maximum of numcards*6.\n"
"\n"
);
}
else
{
std::printf(" This build of libADLMIDI has no embedded banks!\n\n");
}
flushout(stdout);
return 0;
}
long sampleRate = 44100;
#ifndef HARDWARE_OPL3
//const unsigned MaxSamplesAtTime = 512; // 512=dbopl limitation
// How long is SDL buffer, in seconds?
// The smaller the value, the more often SDL_AudioCallBack()
// is called.
const double AudioBufferLength = 0.08;
// How much do WE buffer, in seconds? The smaller the value,
// the more prone to sound chopping we are.
const double OurHeadRoomLength = 0.1;
// The lag between visual content and audio content equals
// the sum of these two buffers.
#ifndef OUTPUT_WAVE_ONLY
SDL_AudioSpec spec;
SDL_AudioSpec obtained;
spec.freq = (int)sampleRate;
spec.format = AUDIO_S16SYS;
spec.channels = 2;
spec.samples = Uint16((double)spec.freq * AudioBufferLength);
spec.callback = SDL_AudioCallbackX;
#endif //OUTPUT_WAVE_ONLY
#endif //HARDWARE_OPL3
ADL_MIDIPlayer *myDevice;
//.........这里部分代码省略.........
示例14: TTF_OpenFont
void Font_FT::init(const String &filepath) {
TTF_Font *font = TTF_OpenFont(filepath.c_str(), int(get_text_height() * m_vratio + 0.5f));
if(!font)
throw Font_Init_Failure();
/*** Set Style ***/
if(is_bold() && is_italic())
TTF_SetFontStyle(font, TTF_STYLE_BOLD | TTF_STYLE_ITALIC);
else if(is_bold())
TTF_SetFontStyle(font, TTF_STYLE_BOLD);
else if(is_italic())
TTF_SetFontStyle(font, TTF_STYLE_ITALIC);
/*** Determine Width & Height ***/
float font_width = 0;
float font_height = 0;
SDL_Color color2 = {0xFF, 0xFF, 0xFF, 0xFF};
SDL_Surface *source[256] = {0};
for(unsigned char c = 1; c; ++c) {
Core::assert_no_error();
//char t[2] = {c, '\0'};
//source[c] = TTF_RenderText_Blended(font, t, color2);
source[c] = TTF_RenderGlyph_Blended(font, c, color2);
Core::print_error();
font_width = std::max(font_width, float(source[c] ? source[c]->w : 0));
font_height = std::max(font_height, float(source[c] ? source[c]->h : 0));
}
/*** Initialize Intermediate SDL Surface ***/
const int
next_w = int(pow(2.0f, ceil(log(float(16 * font_width))/log(2.0f)))),
next_h = int(pow(2.0f, ceil(log(float(16 * font_height))/log(2.0f))));
SDL_Surface *font_surface = SDL_CreateRGBSurface(SDL_SWSURFACE, next_w, next_h, 32, source[END_OF_TIME]->format->Rmask, source[END_OF_TIME]->format->Gmask, source[END_OF_TIME]->format->Bmask, source[END_OF_TIME]->format->Amask);
if(!font_surface) {
for(unsigned char c = 1; c; ++c)
SDL_FreeSurface(source[c]);
TTF_CloseFont(font);
if(next_h > 1024) {
m_vratio /= 2.0f;
init(filepath);
return;
}
else
throw Font_Init_Failure();
}
SDL_LockSurface(font_surface);
SDL_FillRect(font_surface, 0, SDL_MapRGBA(font_surface->format, 0, 0, 0, SDL_ALPHA_TRANSPARENT));
SDL_UnlockSurface(font_surface);
/*** Initialize Glyphs ***/
SDL_Rect dstrect = {0, 0, Uint16(font_width), Uint16(font_height)};
m_glyph[0] = 0;
for(unsigned char c = 1; c; ++c) {
dstrect.x = Sint16((c % 16) * font_width);
dstrect.y = Sint16((c / 16) * font_height);
m_glyph[c] = new Glyph(font, c, source[c], font_surface, dstrect, next_w, next_h, m_vratio);
}
/*** Correct Transparency ***/
const Uint32 transparent_white = font_surface->format->Rmask | font_surface->format->Gmask | font_surface->format->Bmask;
for(int i = 0; i < font_surface->h; ++i)
for(Uint32 * src = reinterpret_cast<Uint32 *>(font_surface->pixels) + i * font_surface->pitch / 4,
* src_end = src + font_surface->w;
src != src_end;
++src)
if(*src & font_surface->format->Rmask)
*src = transparent_white | ((*src & font_surface->format->Rmask) >> font_surface->format->Rshift << font_surface->format->Ashift);
/*** Initialize Final Texture ***/
m_texture = get_Video().create_Texture(font_surface, false);
TTF_CloseFont(font);
}
示例15: _generateIndication
void _generateIndication (
IndicationResponseHandler * handler,
const String & identifier)
{
if (_enabled)
{
CIMInstance indicationInstance (CIMName ("FailureTestIndication"));
CIMObjectPath path;
path.setNameSpace ("test/testProvider");
path.setClassName ("FailureTestIndication");
indicationInstance.setPath (path);
indicationInstance.addProperty
(CIMProperty ("IndicationIdentifier", identifier));
CIMDateTime currentDateTime = CIMDateTime::getCurrentDateTime ();
indicationInstance.addProperty
(CIMProperty ("IndicationTime", currentDateTime));
Array <String> correlatedIndications;
indicationInstance.addProperty
(CIMProperty ("CorrelatedIndications", correlatedIndications));
indicationInstance.addProperty
(CIMProperty ("Description", String ("Failure Test Indication")));
indicationInstance.addProperty
(CIMProperty ("AlertingManagedElement",
System::getFullyQualifiedHostName ()));
indicationInstance.addProperty
(CIMProperty ("AlertingElementFormat", Uint16 (0)));
indicationInstance.addProperty
(CIMProperty ("AlertType", Uint16 (1)));
indicationInstance.addProperty
(CIMProperty ("OtherAlertType", String ("Test")));
indicationInstance.addProperty
(CIMProperty ("PerceivedSeverity", Uint16 (2)));
indicationInstance.addProperty
(CIMProperty ("ProbableCause", Uint16 (1)));
indicationInstance.addProperty
(CIMProperty ("ProbableCauseDescription", String ("Test")));
indicationInstance.addProperty
(CIMProperty ("Trending", Uint16 (4)));
Array <String> recommendedActions;
recommendedActions.append ("Test");
indicationInstance.addProperty
(CIMProperty ("RecommendedActions", recommendedActions));
indicationInstance.addProperty
(CIMProperty ("EventID", String ("Test")));
CIMDateTime eventTime = CIMDateTime::getCurrentDateTime ();
indicationInstance.addProperty
(CIMProperty ("EventTime", eventTime));
indicationInstance.addProperty
(CIMProperty ("SystemCreationClassName",
System::getSystemCreationClassName ()));
indicationInstance.addProperty
(CIMProperty ("SystemName",
System::getFullyQualifiedHostName ()));
indicationInstance.addProperty
(CIMProperty ("ProviderName", _providerName));
CIMIndication cimIndication (indicationInstance);
handler->deliver (cimIndication);
}
}