# HG changeset patch # User John Tsiombikas # Date 1421211076 -7200 # Node ID 1b39a1b46319babe4108b01f5182750eb509f23a initial 0.4.4 diff -r 000000000000 -r 1b39a1b46319 .hgignore --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.hgignore Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,6 @@ +\.o$ +\.swp$ +\.d$ +^Samples/ +^Firmware/ +^ConfigUtil/ diff -r 000000000000 -r 1b39a1b46319 3rdParty/EDID/edid.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/3rdParty/EDID/edid.cpp Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,446 @@ +/* + * Copyright 2007 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, and/or sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/* Author: Soren Sandmann */ +#include "edid.h" +#include +#include +#include +#include + + +static int get_bit(int in, int bit) { + return (in & (1 << bit)) >> bit; +} + +static int get_bits(int in, int begin, int end) { + int mask = (1 << (end - begin + 1)) - 1; + + return (in >> begin) & mask; +} + +static bool decode_header(const uint8_t *edid) { + if (memcmp(edid, "\x00\xff\xff\xff\xff\xff\xff\x00", 8) == 0) + return true; + return false; +} + +static int decode_vendor_and_product_identification(const uint8_t *edid, MonitorInfo *info) { + + /* Manufacturer Code */ + info->manufacturer_code[0] = get_bits(edid[0x08], 2, 6); + info->manufacturer_code[1] = get_bits(edid[0x08], 0, 1) << 3; + info->manufacturer_code[1] |= get_bits(edid[0x09], 5, 7); + info->manufacturer_code[2] = get_bits(edid[0x09], 0, 4); + info->manufacturer_code[3] = '\0'; + + info->manufacturer_code[0] += 'A' - 1; + info->manufacturer_code[1] += 'A' - 1; + info->manufacturer_code[2] += 'A' - 1; + + /* Product Code */ + info->product_code = edid[0x0b] << 8 | edid[0x0a]; + + /* Serial Number */ + info->serial_number = edid[0x0c] | edid[0x0d] << 8 | edid[0x0e] << 16 | edid[0x0f] << 24; + + /* Week and Year */ + bool is_model_year = false; + switch (edid[0x10]) { + case 0x00: + info->production_week = -1; + break; + + case 0xff: + info->production_week = -1; + is_model_year = true; + break; + + default: + info->production_week = edid[0x10]; + break; + } + + if (is_model_year) { + info->production_year = -1; + info->model_year = 1990 + edid[0x11]; + } else { + info->production_year = 1990 + edid[0x11]; + info->model_year = -1; + } + + return true; +} + +static bool decode_edid_version(const uint8_t *edid, MonitorInfo *info) { + info->major_version = edid[0x12]; + info->minor_version = edid[0x13]; + return true; +} + +static bool decode_display_parameters(const uint8_t *edid, MonitorInfo *info) { + /* Digital vs Analog */ + info->is_digital = get_bit(edid[0x14], 7); + + if (info->is_digital) { + static const int bit_depth[8] = { -1, 6, 8, 10, 12, 14, 16, -1 }; + static const Interface interfaces[6] = { UNDEFINED, DVI, HDMI_A, HDMI_B, MDDI, DISPLAY_PORT }; + + int bits = get_bits(edid[0x14], 4, 6); + info->connector.digital.bits_per_primary = bit_depth[bits]; + + bits = get_bits(edid[0x14], 0, 3); + if (bits <= 5) + info->connector.digital.interface = interfaces[bits]; + else + info->connector.digital.interface = UNDEFINED; + } else { + int bits = get_bits(edid[0x14], 5, 6); + static const double levels[][3] = { // + { 0.7, 0.3, 1.0 }, // + { 0.714, 0.286, 1.0 }, // + { 1.0, 0.4, 1.4 }, // + { 0.7, 0.0, 0.7 }, // + }; + + info->connector.analog.video_signal_level = levels[bits][0]; + info->connector.analog.sync_signal_level = levels[bits][1]; + info->connector.analog.total_signal_level = levels[bits][2]; + info->connector.analog.blank_to_black = get_bit(edid[0x14], 4); + info->connector.analog.separate_hv_sync = get_bit(edid[0x14], 3); + info->connector.analog.composite_sync_on_h = get_bit(edid[0x14], 2); + info->connector.analog.composite_sync_on_green = get_bit(edid[0x14], 1); + info->connector.analog.serration_on_vsync = get_bit(edid[0x14], 0); + } + + /* Screen Size / Aspect Ratio */ + if (edid[0x15] == 0 && edid[0x16] == 0) { + info->width_mm = -1; + info->height_mm = -1; + info->aspect_ratio = -1.0; + } else if (edid[0x16] == 0) { + info->width_mm = -1; + info->height_mm = -1; + info->aspect_ratio = 100.0 / (edid[0x15] + 99); + } else if (edid[0x15] == 0) { + info->width_mm = -1; + info->height_mm = -1; + info->aspect_ratio = 100.0 / (edid[0x16] + 99); + info->aspect_ratio = 1 / info->aspect_ratio; /* portrait */ + } else { + info->width_mm = 10 * edid[0x15]; + info->height_mm = 10 * edid[0x16]; + } + + /* Gamma */ + if (edid[0x17] == 0xFF) + info->gamma = -1.0; + else + info->gamma = (edid[0x17] + 100.0) / 100.0; + + /* Features */ + info->standby = get_bit(edid[0x18], 7); + info->suspend = get_bit(edid[0x18], 6); + info->active_off = get_bit(edid[0x18], 5); + + if (info->is_digital) { + info->connector.digital.rgb444 = 1; + if (get_bit(edid[0x18], 3)) + info->connector.digital.ycrcb444 = 1; + if (get_bit(edid[0x18], 4)) + info->connector.digital.ycrcb422 = 1; + } else { + int bits = get_bits(edid[0x18], 3, 4); + ColorType color_type[4] = { MONOCHROME, RGB, OTHER_COLOR, UNDEFINED_COLOR }; + + info->connector.analog.color_type = color_type[bits]; + } + + info->srgb_is_standard = get_bit(edid[0x18], 2); + + /* In 1.3 this is called "has preferred timing" */ + info->preferred_timing_includes_native = get_bit(edid[0x18], 1); + + /* FIXME: In 1.3 this indicates whether the monitor accepts GTF */ + info->continuous_frequency = get_bit(edid[0x18], 0); + return true; +} + +static double decode_fraction(int high, int low) { + double result = 0.0; + high = (high << 2) | low; + for (int i = 0; i < 10; ++i) + result += get_bit(high, i) * pow(2, i - 10); + return result; +} + +static bool decode_color_characteristics(const uint8_t *edid, MonitorInfo *info) { + info->red_x = decode_fraction(edid[0x1b], get_bits(edid[0x19], 6, 7)); + info->red_y = decode_fraction(edid[0x1c], get_bits(edid[0x19], 5, 4)); + info->green_x = decode_fraction(edid[0x1d], get_bits(edid[0x19], 2, 3)); + info->green_y = decode_fraction(edid[0x1e], get_bits(edid[0x19], 0, 1)); + info->blue_x = decode_fraction(edid[0x1f], get_bits(edid[0x1a], 6, 7)); + info->blue_y = decode_fraction(edid[0x20], get_bits(edid[0x1a], 4, 5)); + info->white_x = decode_fraction(edid[0x21], get_bits(edid[0x1a], 2, 3)); + info->white_y = decode_fraction(edid[0x22], get_bits(edid[0x1a], 0, 1)); + + return true; +} + +static bool decode_established_timings(const uint8_t *edid, MonitorInfo *info) { + static const Timing established[][8] = { // + { { 800, 600, 60 }, { 800, 600, 56 }, // + { 640, 480, 75 }, { 640, 480, 72 }, // + { 640, 480, 67 }, { 640, 480, 60 }, // + { 720, 400, 88 }, { 720, 400, 70 } }, // + { { 1280, 1024, 75 }, { 1024, 768, 75 }, // + { 1024, 768, 70 }, { 1024, 768, 60 }, // + { 1024, 768, 87 }, { 832, 624, 75 }, // + { 800, 600, 75 }, { 800, 600, 72 } }, // + { { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, // + { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 1152, 870, 75 } }, // + }; + + int idx = 0; + for (int i = 0; i < 3; ++i) { + for (int j = 0; j < 8; ++j) { + int byte = edid[0x23 + i]; + + if (get_bit(byte, j) && established[i][j].frequency != 0) + info->established[idx++] = established[i][j]; + } + } + return true; +} + +static bool decode_standard_timings(const uint8_t *edid, MonitorInfo *info) { + int i; + + for (i = 0; i < 8; i++) { + int first = edid[0x26 + 2 * i]; + int second = edid[0x27 + 2 * i]; + + if (first != 0x01 && second != 0x01) { + int w = 8 * (first + 31); + int h = 0; + + switch (get_bits(second, 6, 7)) { + case 0x00: + h = (w / 16) * 10; + break; + case 0x01: + h = (w / 4) * 3; + break; + case 0x02: + h = (w / 5) * 4; + break; + case 0x03: + h = (w / 16) * 9; + break; + } + + info->standard[i].width = w; + info->standard[i].height = h; + info->standard[i].frequency = get_bits(second, 0, 5) + 60; + } + } + + return true; +} + +static void decode_lf_string(const uint8_t *s, int n_chars, char *result) { + int i; + for (i = 0; i < n_chars; ++i) { + if (s[i] == 0x0a) { + *result++ = '\0'; + break; + } else if (s[i] == 0x00) { + /* Convert embedded 0's to spaces */ + *result++ = ' '; + } else { + *result++ = s[i]; + } + } +} + +static void decode_display_descriptor(const uint8_t *desc, MonitorInfo *info) { + switch (desc[0x03]) { + case 0xFC: + decode_lf_string(desc + 5, 13, info->dsc_product_name); + break; + case 0xFF: + decode_lf_string(desc + 5, 13, info->dsc_serial_number); + break; + case 0xFE: + decode_lf_string(desc + 5, 13, info->dsc_string); + break; + case 0xFD: + /* Range Limits */ + break; + case 0xFB: + /* Color Point */ + break; + case 0xFA: + /* Timing Identifications */ + break; + case 0xF9: + /* Color Management */ + break; + case 0xF8: + /* Timing Codes */ + break; + case 0xF7: + /* Established Timings */ + break; + case 0x10: + break; + } +} + +static void decode_detailed_timing(const uint8_t *timing, DetailedTiming *detailed) { + int bits; + StereoType stereo[] = { // + NO_STEREO, NO_STEREO, // + FIELD_RIGHT, FIELD_LEFT, // + TWO_WAY_RIGHT_ON_EVEN, TWO_WAY_LEFT_ON_EVEN, // + FOUR_WAY_INTERLEAVED, // + SIDE_BY_SIDE // + }; + + detailed->pixel_clock = (timing[0x00] | timing[0x01] << 8) * 10000; + detailed->h_addr = timing[0x02] | ((timing[0x04] & 0xf0) << 4); + detailed->h_blank = timing[0x03] | ((timing[0x04] & 0x0f) << 8); + detailed->v_addr = timing[0x05] | ((timing[0x07] & 0xf0) << 4); + detailed->v_blank = timing[0x06] | ((timing[0x07] & 0x0f) << 8); + detailed->h_front_porch = timing[0x08] | get_bits(timing[0x0b], 6, 7) << 8; + detailed->h_sync = timing[0x09] | get_bits(timing[0x0b], 4, 5) << 8; + detailed->v_front_porch = get_bits(timing[0x0a], 4, 7) | get_bits(timing[0x0b], 2, 3) << 4; + detailed->v_sync = get_bits(timing[0x0a], 0, 3) | get_bits(timing[0x0b], 0, 1) << 4; + detailed->width_mm = timing[0x0c] | get_bits(timing[0x0e], 4, 7) << 8; + detailed->height_mm = timing[0x0d] | get_bits(timing[0x0e], 0, 3) << 8; + detailed->right_border = timing[0x0f]; + detailed->top_border = timing[0x10]; + detailed->interlaced = get_bit(timing[0x11], 7); + + /* Stereo */ + bits = get_bits(timing[0x11], 5, 6) << 1 | get_bit(timing[0x11], 0); + detailed->stereo = stereo[bits]; + + /* Sync */ + bits = timing[0x11]; + + detailed->digital_sync = get_bit(bits, 4); + if (detailed->digital_sync) { + detailed->connector.digital.composite = !get_bit(bits, 3); + if (detailed->connector.digital.composite) { + detailed->connector.digital.serrations = get_bit(bits, 2); + detailed->connector.digital.negative_vsync = 0; + } else { + detailed->connector.digital.serrations = 0; + detailed->connector.digital.negative_vsync = !get_bit(bits, 2); + } + detailed->connector.digital.negative_hsync = !get_bit(bits, 0); + } else { + detailed->connector.analog.bipolar = get_bit(bits, 3); + detailed->connector.analog.serrations = get_bit(bits, 2); + detailed->connector.analog.sync_on_green = !get_bit(bits, 1); + } +} + +static bool decode_descriptors(const uint8_t *edid, MonitorInfo *info) { + int timing_idx = 0; + for (int i = 0; i < 4; ++i) { + int index = 0x36 + i * 18; + if (edid[index + 0] == 0x00 && edid[index + 1] == 0x00) { + decode_display_descriptor(edid + index, info); + } else { + decode_detailed_timing(edid + index, &(info->detailed_timings[timing_idx++])); + } + } + info->n_detailed_timings = timing_idx; + return true; +} + +static void decode_check_sum(const uint8_t *edid, MonitorInfo *info) { + uint8_t check = 0; + for (int i = 0; i < 128; ++i) + check += edid[i]; + info->checksum = check; +} + +MonitorInfo * decode_edid(const uint8_t *edid) { + MonitorInfo *info = new MonitorInfo(); + decode_check_sum(edid, info); + if (decode_header(edid) && // + decode_vendor_and_product_identification(edid, info) && // + decode_edid_version(edid, info) && // + decode_display_parameters(edid, info) && // + decode_color_characteristics(edid, info) && // + decode_established_timings(edid, info) && // + decode_standard_timings(edid, info) && // + decode_descriptors(edid, info)) { + return info; + } else { + delete info; + return 0; + } +} + +static uint8_t * get_property(Display *dpy, RROutput output, Atom atom, int *len) { + unsigned char *prop; + int actual_format; + unsigned long nitems, bytes_after; + Atom actual_type; + uint8_t *result = NULL; + + XRRGetOutputProperty(dpy, output, atom, 0, 100, False, False, + AnyPropertyType, &actual_type, &actual_format, &nitems, &bytes_after, &prop); + + if (actual_type == XA_INTEGER && actual_format == 8) { + result = new uint8_t[nitems]; + memcpy(result, prop, nitems); + if (len) + *len = nitems; + } + XFree(prop); + return result; +} + +MonitorInfo * read_edid_data(Display * disp, RROutput id) { + int len; + Atom edid_atom = XInternAtom(disp, "EDID", false); + uint8_t *edid = get_property(disp, id, edid_atom, &len); + if (!edid) { + edid_atom = XInternAtom(disp, "EDID_DATA", false); + edid = get_property(disp, id, edid_atom, &len); + } + + MonitorInfo * result = 0; + if (edid) { + if (len % 128 == 0) { + result = decode_edid(edid); + } + delete[] edid; + } + + return result; +} diff -r 000000000000 -r 1b39a1b46319 3rdParty/EDID/edid.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/3rdParty/EDID/edid.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,174 @@ +#include +#include + +/* + * Copyright 2007 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, and/or sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/* Author: Soren Sandmann */ + +typedef enum { + UNDEFINED, + DVI, + HDMI_A, + HDMI_B, + MDDI, + DISPLAY_PORT +} Interface; + +typedef enum { + UNDEFINED_COLOR, + MONOCHROME, + RGB, + OTHER_COLOR +} ColorType; + +typedef enum { + NO_STEREO, + FIELD_RIGHT, + FIELD_LEFT, + TWO_WAY_RIGHT_ON_EVEN, + TWO_WAY_LEFT_ON_EVEN, + FOUR_WAY_INTERLEAVED, + SIDE_BY_SIDE +} StereoType; + +struct Timing { + int width; + int height; + int frequency; +}; + +struct DetailedTiming { + int pixel_clock; + int h_addr; + int h_blank; + int h_sync; + int h_front_porch; + int v_addr; + int v_blank; + int v_sync; + int v_front_porch; + int width_mm; + int height_mm; + int right_border; + int top_border; + int interlaced; + StereoType stereo; + + int digital_sync; + union { + struct { + int bipolar; + int serrations; + int sync_on_green; + } analog; + + struct { + int composite; + int serrations; + int negative_vsync; + int negative_hsync; + } digital; + } connector; +}; + +struct MonitorInfo { + int checksum; + char manufacturer_code[4]; + int product_code; + unsigned int serial_number; + + int production_week; /* -1 if not specified */ + int production_year; /* -1 if not specified */ + int model_year; /* -1 if not specified */ + + int major_version; + int minor_version; + + int is_digital; + + union { + struct { + int bits_per_primary; + Interface interface; + int rgb444; + int ycrcb444; + int ycrcb422; + } digital; + + struct { + double video_signal_level; + double sync_signal_level; + double total_signal_level; + + int blank_to_black; + + int separate_hv_sync; + int composite_sync_on_h; + int composite_sync_on_green; + int serration_on_vsync; + ColorType color_type; + } analog; + } connector; + + int width_mm; /* -1 if not specified */ + int height_mm; /* -1 if not specified */ + double aspect_ratio; /* -1.0 if not specififed */ + + double gamma; /* -1.0 if not specified */ + + int standby; + int suspend; + int active_off; + + int srgb_is_standard; + int preferred_timing_includes_native; + int continuous_frequency; + + double red_x; + double red_y; + double green_x; + double green_y; + double blue_x; + double blue_y; + double white_x; + double white_y; + + Timing established[24]; /* Terminated by 0x0x0 */ + Timing standard[8]; + + int n_detailed_timings; + DetailedTiming detailed_timings[4]; /* If monitor has a preferred + * mode, it is the first one + * (whether it has, is + * determined by the + * preferred_timing_includes + * bit. + */ + + /* Optional product description */ + char dsc_serial_number[14]; + char dsc_product_name[14]; + char dsc_string[14]; /* Unspecified ASCII data */ +}; + +MonitorInfo * read_edid_data(Display * disp, RROutput id); diff -r 000000000000 -r 1b39a1b46319 3rdParty/TinyXml/tinyxml2.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/3rdParty/TinyXml/tinyxml2.cpp Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,2101 @@ +/* +Original code by Lee Thomason (www.grinninglizard.com) + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any +damages arising from the use of this software. + +Permission is granted to anyone to use this software for any +purpose, including commercial applications, and to alter it and +redistribute it freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must +not claim that you wrote the original software. If you use this +software in a product, an acknowledgment in the product documentation +would be appreciated but is not required. + +2. Altered source versions must be plainly marked as such, and +must not be misrepresented as being the original software. + +3. This notice may not be removed or altered from any source +distribution. +*/ + +#include "tinyxml2.h" + +#include // yes, this one new style header, is in the Android SDK. +# ifdef ANDROID_NDK +# include +#else +# include +#endif + +static const char LINE_FEED = (char)0x0a; // all line endings are normalized to LF +static const char LF = LINE_FEED; +static const char CARRIAGE_RETURN = (char)0x0d; // CR gets filtered out +static const char CR = CARRIAGE_RETURN; +static const char SINGLE_QUOTE = '\''; +static const char DOUBLE_QUOTE = '\"'; + +// Bunch of unicode info at: +// http://www.unicode.org/faq/utf_bom.html +// ef bb bf (Microsoft "lead bytes") - designates UTF-8 + +static const unsigned char TIXML_UTF_LEAD_0 = 0xefU; +static const unsigned char TIXML_UTF_LEAD_1 = 0xbbU; +static const unsigned char TIXML_UTF_LEAD_2 = 0xbfU; + + +#define DELETE_NODE( node ) { \ + if ( node ) { \ + MemPool* pool = node->_memPool; \ + node->~XMLNode(); \ + pool->Free( node ); \ + } \ + } +#define DELETE_ATTRIBUTE( attrib ) { \ + if ( attrib ) { \ + MemPool* pool = attrib->_memPool; \ + attrib->~XMLAttribute(); \ + pool->Free( attrib ); \ + } \ + } + +namespace tinyxml2 +{ + +struct Entity { + const char* pattern; + int length; + char value; +}; + +static const int NUM_ENTITIES = 5; +static const Entity entities[NUM_ENTITIES] = { + { "quot", 4, DOUBLE_QUOTE }, + { "amp", 3, '&' }, + { "apos", 4, SINGLE_QUOTE }, + { "lt", 2, '<' }, + { "gt", 2, '>' } +}; + + +StrPair::~StrPair() +{ + Reset(); +} + + +void StrPair::Reset() +{ + if ( _flags & NEEDS_DELETE ) { + delete [] _start; + } + _flags = 0; + _start = 0; + _end = 0; +} + + +void StrPair::SetStr( const char* str, int flags ) +{ + Reset(); + size_t len = strlen( str ); + _start = new char[ len+1 ]; + memcpy( _start, str, len+1 ); + _end = _start + len; + _flags = flags | NEEDS_DELETE; +} + + +char* StrPair::ParseText( char* p, const char* endTag, int strFlags ) +{ + TIXMLASSERT( endTag && *endTag ); + + char* start = p; // fixme: hides a member + char endChar = *endTag; + size_t length = strlen( endTag ); + + // Inner loop of text parsing. + while ( *p ) { + if ( *p == endChar && strncmp( p, endTag, length ) == 0 ) { + Set( start, p, strFlags ); + return p + length; + } + ++p; + } + return 0; +} + + +char* StrPair::ParseName( char* p ) +{ + char* start = p; + + if ( !start || !(*start) ) { + return 0; + } + + while( *p && ( + XMLUtil::IsAlphaNum( (unsigned char) *p ) + || *p == '_' + || *p == ':' + || (*p == '-' && p>start ) // can be in a name, but not lead it. + || (*p == '.' && p>start ) )) { // can be in a name, but not lead it. + ++p; + } + + if ( p > start ) { + Set( start, p, 0 ); + return p; + } + return 0; +} + + +void StrPair::CollapseWhitespace() +{ + // Trim leading space. + _start = XMLUtil::SkipWhiteSpace( _start ); + + if ( _start && *_start ) { + char* p = _start; // the read pointer + char* q = _start; // the write pointer + + while( *p ) { + if ( XMLUtil::IsWhiteSpace( *p )) { + p = XMLUtil::SkipWhiteSpace( p ); + if ( *p == 0 ) { + break; // don't write to q; this trims the trailing space. + } + *q = ' '; + ++q; + } + *q = *p; + ++q; + ++p; + } + *q = 0; + } +} + + +const char* StrPair::GetStr() +{ + if ( _flags & NEEDS_FLUSH ) { + *_end = 0; + _flags ^= NEEDS_FLUSH; + + if ( _flags ) { + char* p = _start; // the read pointer + char* q = _start; // the write pointer + + while( p < _end ) { + if ( (_flags & NEEDS_NEWLINE_NORMALIZATION) && *p == CR ) { + // CR-LF pair becomes LF + // CR alone becomes LF + // LF-CR becomes LF + if ( *(p+1) == LF ) { + p += 2; + } + else { + ++p; + } + *q++ = LF; + } + else if ( (_flags & NEEDS_NEWLINE_NORMALIZATION) && *p == LF ) { + if ( *(p+1) == CR ) { + p += 2; + } + else { + ++p; + } + *q++ = LF; + } + else if ( (_flags & NEEDS_ENTITY_PROCESSING) && *p == '&' ) { + // Entities handled by tinyXML2: + // - special entities in the entity table [in/out] + // - numeric character reference [in] + // 中 or 中 + + if ( *(p+1) == '#' ) { + char buf[10] = { 0 }; + int len; + p = const_cast( XMLUtil::GetCharacterRef( p, buf, &len ) ); + for( int i=0; i(p); + // Check for BOM: + if ( *(pu+0) == TIXML_UTF_LEAD_0 + && *(pu+1) == TIXML_UTF_LEAD_1 + && *(pu+2) == TIXML_UTF_LEAD_2 ) { + *bom = true; + p += 3; + } + return p; +} + + +void XMLUtil::ConvertUTF32ToUTF8( unsigned long input, char* output, int* length ) +{ + const unsigned long BYTE_MASK = 0xBF; + const unsigned long BYTE_MARK = 0x80; + const unsigned long FIRST_BYTE_MARK[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC }; + + if (input < 0x80) { + *length = 1; + } + else if ( input < 0x800 ) { + *length = 2; + } + else if ( input < 0x10000 ) { + *length = 3; + } + else if ( input < 0x200000 ) { + *length = 4; + } + else { + *length = 0; // This code won't covert this correctly anyway. + return; + } + + output += *length; + + // Scary scary fall throughs. + switch (*length) { + case 4: + --output; + *output = (char)((input | BYTE_MARK) & BYTE_MASK); + input >>= 6; + case 3: + --output; + *output = (char)((input | BYTE_MARK) & BYTE_MASK); + input >>= 6; + case 2: + --output; + *output = (char)((input | BYTE_MARK) & BYTE_MASK); + input >>= 6; + case 1: + --output; + *output = (char)(input | FIRST_BYTE_MARK[*length]); + default: + break; + } +} + + +const char* XMLUtil::GetCharacterRef( const char* p, char* value, int* length ) +{ + // Presume an entity, and pull it out. + *length = 0; + + if ( *(p+1) == '#' && *(p+2) ) { + unsigned long ucs = 0; + ptrdiff_t delta = 0; + unsigned mult = 1; + + if ( *(p+2) == 'x' ) { + // Hexadecimal. + if ( !*(p+3) ) { + return 0; + } + + const char* q = p+3; + q = strchr( q, ';' ); + + if ( !q || !*q ) { + return 0; + } + + delta = q-p; + --q; + + while ( *q != 'x' ) { + if ( *q >= '0' && *q <= '9' ) { + ucs += mult * (*q - '0'); + } + else if ( *q >= 'a' && *q <= 'f' ) { + ucs += mult * (*q - 'a' + 10); + } + else if ( *q >= 'A' && *q <= 'F' ) { + ucs += mult * (*q - 'A' + 10 ); + } + else { + return 0; + } + mult *= 16; + --q; + } + } + else { + // Decimal. + if ( !*(p+2) ) { + return 0; + } + + const char* q = p+2; + q = strchr( q, ';' ); + + if ( !q || !*q ) { + return 0; + } + + delta = q-p; + --q; + + while ( *q != '#' ) { + if ( *q >= '0' && *q <= '9' ) { + ucs += mult * (*q - '0'); + } + else { + return 0; + } + mult *= 10; + --q; + } + } + // convert the UCS to UTF-8 + ConvertUTF32ToUTF8( ucs, value, length ); + return p + delta + 1; + } + return p+1; +} + + +void XMLUtil::ToStr( int v, char* buffer, int bufferSize ) +{ + TIXML_SNPRINTF( buffer, bufferSize, "%d", v ); +} + + +void XMLUtil::ToStr( unsigned v, char* buffer, int bufferSize ) +{ + TIXML_SNPRINTF( buffer, bufferSize, "%u", v ); +} + + +void XMLUtil::ToStr( bool v, char* buffer, int bufferSize ) +{ + TIXML_SNPRINTF( buffer, bufferSize, "%d", v ? 1 : 0 ); +} + + +void XMLUtil::ToStr( float v, char* buffer, int bufferSize ) +{ + TIXML_SNPRINTF( buffer, bufferSize, "%g", v ); +} + + +void XMLUtil::ToStr( double v, char* buffer, int bufferSize ) +{ + TIXML_SNPRINTF( buffer, bufferSize, "%g", v ); +} + + +bool XMLUtil::ToInt( const char* str, int* value ) +{ + if ( TIXML_SSCANF( str, "%d", value ) == 1 ) { + return true; + } + return false; +} + +bool XMLUtil::ToUnsigned( const char* str, unsigned *value ) +{ + if ( TIXML_SSCANF( str, "%u", value ) == 1 ) { + return true; + } + return false; +} + +bool XMLUtil::ToBool( const char* str, bool* value ) +{ + int ival = 0; + if ( ToInt( str, &ival )) { + *value = (ival==0) ? false : true; + return true; + } + if ( StringEqual( str, "true" ) ) { + *value = true; + return true; + } + else if ( StringEqual( str, "false" ) ) { + *value = false; + return true; + } + return false; +} + + +bool XMLUtil::ToFloat( const char* str, float* value ) +{ + if ( TIXML_SSCANF( str, "%f", value ) == 1 ) { + return true; + } + return false; +} + +bool XMLUtil::ToDouble( const char* str, double* value ) +{ + if ( TIXML_SSCANF( str, "%lf", value ) == 1 ) { + return true; + } + return false; +} + + +char* XMLDocument::Identify( char* p, XMLNode** node ) +{ + XMLNode* returnNode = 0; + char* start = p; + p = XMLUtil::SkipWhiteSpace( p ); + if( !p || !*p ) { + return p; + } + + // What is this thing? + // - Elements start with a letter or underscore, but xml is reserved. + // - Comments: + // + // With a special case: + // + // + // + // + // Where the closing element (/foo) *must* be the next thing after the opening + // element, and the names must match. BUT the tricky bit is that the closing + // element will be read by the child. + // + // 'endTag' is the end tag for this node, it is returned by a call to a child. + // 'parentEnd' is the end tag for the parent, which is filled in and returned. + + while( p && *p ) { + XMLNode* node = 0; + + p = _document->Identify( p, &node ); + if ( p == 0 || node == 0 ) { + break; + } + + StrPair endTag; + p = node->ParseDeep( p, &endTag ); + if ( !p ) { + DELETE_NODE( node ); + node = 0; + if ( !_document->Error() ) { + _document->SetError( XML_ERROR_PARSING, 0, 0 ); + } + break; + } + + // We read the end tag. Return it to the parent. + if ( node->ToElement() && node->ToElement()->ClosingType() == XMLElement::CLOSING ) { + if ( parentEnd ) { + *parentEnd = static_cast(node)->_value; + } + node->_memPool->SetTracked(); // created and then immediately deleted. + DELETE_NODE( node ); + return p; + } + + // Handle an end tag returned to this level. + // And handle a bunch of annoying errors. + XMLElement* ele = node->ToElement(); + if ( ele ) { + if ( endTag.Empty() && ele->ClosingType() == XMLElement::OPEN ) { + _document->SetError( XML_ERROR_MISMATCHED_ELEMENT, node->Value(), 0 ); + p = 0; + } + else if ( !endTag.Empty() && ele->ClosingType() != XMLElement::OPEN ) { + _document->SetError( XML_ERROR_MISMATCHED_ELEMENT, node->Value(), 0 ); + p = 0; + } + else if ( !endTag.Empty() ) { + if ( !XMLUtil::StringEqual( endTag.GetStr(), node->Value() )) { + _document->SetError( XML_ERROR_MISMATCHED_ELEMENT, node->Value(), 0 ); + p = 0; + } + } + } + if ( p == 0 ) { + DELETE_NODE( node ); + node = 0; + } + if ( node ) { + this->InsertEndChild( node ); + } + } + return 0; +} + +// --------- XMLText ---------- // +char* XMLText::ParseDeep( char* p, StrPair* ) +{ + const char* start = p; + if ( this->CData() ) { + p = _value.ParseText( p, "]]>", StrPair::NEEDS_NEWLINE_NORMALIZATION ); + if ( !p ) { + _document->SetError( XML_ERROR_PARSING_CDATA, start, 0 ); + } + return p; + } + else { + int flags = _document->ProcessEntities() ? StrPair::TEXT_ELEMENT : StrPair::TEXT_ELEMENT_LEAVE_ENTITIES; + if ( _document->WhitespaceMode() == COLLAPSE_WHITESPACE ) { + flags |= StrPair::COLLAPSE_WHITESPACE; + } + + p = _value.ParseText( p, "<", flags ); + if ( !p ) { + _document->SetError( XML_ERROR_PARSING_TEXT, start, 0 ); + } + if ( p && *p ) { + return p-1; + } + } + return 0; +} + + +XMLNode* XMLText::ShallowClone( XMLDocument* doc ) const +{ + if ( !doc ) { + doc = _document; + } + XMLText* text = doc->NewText( Value() ); // fixme: this will always allocate memory. Intern? + text->SetCData( this->CData() ); + return text; +} + + +bool XMLText::ShallowEqual( const XMLNode* compare ) const +{ + return ( compare->ToText() && XMLUtil::StringEqual( compare->ToText()->Value(), Value() )); +} + + +bool XMLText::Accept( XMLVisitor* visitor ) const +{ + return visitor->Visit( *this ); +} + + +// --------- XMLComment ---------- // + +XMLComment::XMLComment( XMLDocument* doc ) : XMLNode( doc ) +{ +} + + +XMLComment::~XMLComment() +{ +} + + +char* XMLComment::ParseDeep( char* p, StrPair* ) +{ + // Comment parses as text. + const char* start = p; + p = _value.ParseText( p, "-->", StrPair::COMMENT ); + if ( p == 0 ) { + _document->SetError( XML_ERROR_PARSING_COMMENT, start, 0 ); + } + return p; +} + + +XMLNode* XMLComment::ShallowClone( XMLDocument* doc ) const +{ + if ( !doc ) { + doc = _document; + } + XMLComment* comment = doc->NewComment( Value() ); // fixme: this will always allocate memory. Intern? + return comment; +} + + +bool XMLComment::ShallowEqual( const XMLNode* compare ) const +{ + return ( compare->ToComment() && XMLUtil::StringEqual( compare->ToComment()->Value(), Value() )); +} + + +bool XMLComment::Accept( XMLVisitor* visitor ) const +{ + return visitor->Visit( *this ); +} + + +// --------- XMLDeclaration ---------- // + +XMLDeclaration::XMLDeclaration( XMLDocument* doc ) : XMLNode( doc ) +{ +} + + +XMLDeclaration::~XMLDeclaration() +{ + //printf( "~XMLDeclaration\n" ); +} + + +char* XMLDeclaration::ParseDeep( char* p, StrPair* ) +{ + // Declaration parses as text. + const char* start = p; + p = _value.ParseText( p, "?>", StrPair::NEEDS_NEWLINE_NORMALIZATION ); + if ( p == 0 ) { + _document->SetError( XML_ERROR_PARSING_DECLARATION, start, 0 ); + } + return p; +} + + +XMLNode* XMLDeclaration::ShallowClone( XMLDocument* doc ) const +{ + if ( !doc ) { + doc = _document; + } + XMLDeclaration* dec = doc->NewDeclaration( Value() ); // fixme: this will always allocate memory. Intern? + return dec; +} + + +bool XMLDeclaration::ShallowEqual( const XMLNode* compare ) const +{ + return ( compare->ToDeclaration() && XMLUtil::StringEqual( compare->ToDeclaration()->Value(), Value() )); +} + + + +bool XMLDeclaration::Accept( XMLVisitor* visitor ) const +{ + return visitor->Visit( *this ); +} + +// --------- XMLUnknown ---------- // + +XMLUnknown::XMLUnknown( XMLDocument* doc ) : XMLNode( doc ) +{ +} + + +XMLUnknown::~XMLUnknown() +{ +} + + +char* XMLUnknown::ParseDeep( char* p, StrPair* ) +{ + // Unknown parses as text. + const char* start = p; + + p = _value.ParseText( p, ">", StrPair::NEEDS_NEWLINE_NORMALIZATION ); + if ( !p ) { + _document->SetError( XML_ERROR_PARSING_UNKNOWN, start, 0 ); + } + return p; +} + + +XMLNode* XMLUnknown::ShallowClone( XMLDocument* doc ) const +{ + if ( !doc ) { + doc = _document; + } + XMLUnknown* text = doc->NewUnknown( Value() ); // fixme: this will always allocate memory. Intern? + return text; +} + + +bool XMLUnknown::ShallowEqual( const XMLNode* compare ) const +{ + return ( compare->ToUnknown() && XMLUtil::StringEqual( compare->ToUnknown()->Value(), Value() )); +} + + +bool XMLUnknown::Accept( XMLVisitor* visitor ) const +{ + return visitor->Visit( *this ); +} + +// --------- XMLAttribute ---------- // +char* XMLAttribute::ParseDeep( char* p, bool processEntities ) +{ + // Parse using the name rules: bug fix, was using ParseText before + p = _name.ParseName( p ); + if ( !p || !*p ) { + return 0; + } + + // Skip white space before = + p = XMLUtil::SkipWhiteSpace( p ); + if ( !p || *p != '=' ) { + return 0; + } + + ++p; // move up to opening quote + p = XMLUtil::SkipWhiteSpace( p ); + if ( *p != '\"' && *p != '\'' ) { + return 0; + } + + char endTag[2] = { *p, 0 }; + ++p; // move past opening quote + + p = _value.ParseText( p, endTag, processEntities ? StrPair::ATTRIBUTE_VALUE : StrPair::ATTRIBUTE_VALUE_LEAVE_ENTITIES ); + return p; +} + + +void XMLAttribute::SetName( const char* n ) +{ + _name.SetStr( n ); +} + + +XMLError XMLAttribute::QueryIntValue( int* value ) const +{ + if ( XMLUtil::ToInt( Value(), value )) { + return XML_NO_ERROR; + } + return XML_WRONG_ATTRIBUTE_TYPE; +} + + +XMLError XMLAttribute::QueryUnsignedValue( unsigned int* value ) const +{ + if ( XMLUtil::ToUnsigned( Value(), value )) { + return XML_NO_ERROR; + } + return XML_WRONG_ATTRIBUTE_TYPE; +} + + +XMLError XMLAttribute::QueryBoolValue( bool* value ) const +{ + if ( XMLUtil::ToBool( Value(), value )) { + return XML_NO_ERROR; + } + return XML_WRONG_ATTRIBUTE_TYPE; +} + + +XMLError XMLAttribute::QueryFloatValue( float* value ) const +{ + if ( XMLUtil::ToFloat( Value(), value )) { + return XML_NO_ERROR; + } + return XML_WRONG_ATTRIBUTE_TYPE; +} + + +XMLError XMLAttribute::QueryDoubleValue( double* value ) const +{ + if ( XMLUtil::ToDouble( Value(), value )) { + return XML_NO_ERROR; + } + return XML_WRONG_ATTRIBUTE_TYPE; +} + + +void XMLAttribute::SetAttribute( const char* v ) +{ + _value.SetStr( v ); +} + + +void XMLAttribute::SetAttribute( int v ) +{ + char buf[BUF_SIZE]; + XMLUtil::ToStr( v, buf, BUF_SIZE ); + _value.SetStr( buf ); +} + + +void XMLAttribute::SetAttribute( unsigned v ) +{ + char buf[BUF_SIZE]; + XMLUtil::ToStr( v, buf, BUF_SIZE ); + _value.SetStr( buf ); +} + + +void XMLAttribute::SetAttribute( bool v ) +{ + char buf[BUF_SIZE]; + XMLUtil::ToStr( v, buf, BUF_SIZE ); + _value.SetStr( buf ); +} + +void XMLAttribute::SetAttribute( double v ) +{ + char buf[BUF_SIZE]; + XMLUtil::ToStr( v, buf, BUF_SIZE ); + _value.SetStr( buf ); +} + +void XMLAttribute::SetAttribute( float v ) +{ + char buf[BUF_SIZE]; + XMLUtil::ToStr( v, buf, BUF_SIZE ); + _value.SetStr( buf ); +} + + +// --------- XMLElement ---------- // +XMLElement::XMLElement( XMLDocument* doc ) : XMLNode( doc ), + _closingType( 0 ), + _rootAttribute( 0 ) +{ +} + + +XMLElement::~XMLElement() +{ + while( _rootAttribute ) { + XMLAttribute* next = _rootAttribute->_next; + DELETE_ATTRIBUTE( _rootAttribute ); + _rootAttribute = next; + } +} + + +XMLAttribute* XMLElement::FindAttribute( const char* name ) +{ + XMLAttribute* a = 0; + for( a=_rootAttribute; a; a = a->_next ) { + if ( XMLUtil::StringEqual( a->Name(), name ) ) { + return a; + } + } + return 0; +} + + +const XMLAttribute* XMLElement::FindAttribute( const char* name ) const +{ + XMLAttribute* a = 0; + for( a=_rootAttribute; a; a = a->_next ) { + if ( XMLUtil::StringEqual( a->Name(), name ) ) { + return a; + } + } + return 0; +} + + +const char* XMLElement::Attribute( const char* name, const char* value ) const +{ + const XMLAttribute* a = FindAttribute( name ); + if ( !a ) { + return 0; + } + if ( !value || XMLUtil::StringEqual( a->Value(), value )) { + return a->Value(); + } + return 0; +} + + +const char* XMLElement::GetText() const +{ + if ( FirstChild() && FirstChild()->ToText() ) { + return FirstChild()->ToText()->Value(); + } + return 0; +} + + +XMLError XMLElement::QueryIntText( int* ival ) const +{ + if ( FirstChild() && FirstChild()->ToText() ) { + const char* t = FirstChild()->ToText()->Value(); + if ( XMLUtil::ToInt( t, ival ) ) { + return XML_SUCCESS; + } + return XML_CAN_NOT_CONVERT_TEXT; + } + return XML_NO_TEXT_NODE; +} + + +XMLError XMLElement::QueryUnsignedText( unsigned* uval ) const +{ + if ( FirstChild() && FirstChild()->ToText() ) { + const char* t = FirstChild()->ToText()->Value(); + if ( XMLUtil::ToUnsigned( t, uval ) ) { + return XML_SUCCESS; + } + return XML_CAN_NOT_CONVERT_TEXT; + } + return XML_NO_TEXT_NODE; +} + + +XMLError XMLElement::QueryBoolText( bool* bval ) const +{ + if ( FirstChild() && FirstChild()->ToText() ) { + const char* t = FirstChild()->ToText()->Value(); + if ( XMLUtil::ToBool( t, bval ) ) { + return XML_SUCCESS; + } + return XML_CAN_NOT_CONVERT_TEXT; + } + return XML_NO_TEXT_NODE; +} + + +XMLError XMLElement::QueryDoubleText( double* dval ) const +{ + if ( FirstChild() && FirstChild()->ToText() ) { + const char* t = FirstChild()->ToText()->Value(); + if ( XMLUtil::ToDouble( t, dval ) ) { + return XML_SUCCESS; + } + return XML_CAN_NOT_CONVERT_TEXT; + } + return XML_NO_TEXT_NODE; +} + + +XMLError XMLElement::QueryFloatText( float* fval ) const +{ + if ( FirstChild() && FirstChild()->ToText() ) { + const char* t = FirstChild()->ToText()->Value(); + if ( XMLUtil::ToFloat( t, fval ) ) { + return XML_SUCCESS; + } + return XML_CAN_NOT_CONVERT_TEXT; + } + return XML_NO_TEXT_NODE; +} + + + +XMLAttribute* XMLElement::FindOrCreateAttribute( const char* name ) +{ + XMLAttribute* last = 0; + XMLAttribute* attrib = 0; + for( attrib = _rootAttribute; + attrib; + last = attrib, attrib = attrib->_next ) { + if ( XMLUtil::StringEqual( attrib->Name(), name ) ) { + break; + } + } + if ( !attrib ) { + attrib = new (_document->_attributePool.Alloc() ) XMLAttribute(); + attrib->_memPool = &_document->_attributePool; + if ( last ) { + last->_next = attrib; + } + else { + _rootAttribute = attrib; + } + attrib->SetName( name ); + attrib->_memPool->SetTracked(); // always created and linked. + } + return attrib; +} + + +void XMLElement::DeleteAttribute( const char* name ) +{ + XMLAttribute* prev = 0; + for( XMLAttribute* a=_rootAttribute; a; a=a->_next ) { + if ( XMLUtil::StringEqual( name, a->Name() ) ) { + if ( prev ) { + prev->_next = a->_next; + } + else { + _rootAttribute = a->_next; + } + DELETE_ATTRIBUTE( a ); + break; + } + prev = a; + } +} + + +char* XMLElement::ParseAttributes( char* p ) +{ + const char* start = p; + XMLAttribute* prevAttribute = 0; + + // Read the attributes. + while( p ) { + p = XMLUtil::SkipWhiteSpace( p ); + if ( !p || !(*p) ) { + _document->SetError( XML_ERROR_PARSING_ELEMENT, start, Name() ); + return 0; + } + + // attribute. + if ( XMLUtil::IsAlpha( *p ) ) { + XMLAttribute* attrib = new (_document->_attributePool.Alloc() ) XMLAttribute(); + attrib->_memPool = &_document->_attributePool; + attrib->_memPool->SetTracked(); + + p = attrib->ParseDeep( p, _document->ProcessEntities() ); + if ( !p || Attribute( attrib->Name() ) ) { + DELETE_ATTRIBUTE( attrib ); + _document->SetError( XML_ERROR_PARSING_ATTRIBUTE, start, p ); + return 0; + } + // There is a minor bug here: if the attribute in the source xml + // document is duplicated, it will not be detected and the + // attribute will be doubly added. However, tracking the 'prevAttribute' + // avoids re-scanning the attribute list. Preferring performance for + // now, may reconsider in the future. + if ( prevAttribute ) { + prevAttribute->_next = attrib; + } + else { + _rootAttribute = attrib; + } + prevAttribute = attrib; + } + // end of the tag + else if ( *p == '/' && *(p+1) == '>' ) { + _closingType = CLOSED; + return p+2; // done; sealed element. + } + // end of the tag + else if ( *p == '>' ) { + ++p; + break; + } + else { + _document->SetError( XML_ERROR_PARSING_ELEMENT, start, p ); + return 0; + } + } + return p; +} + + +// +// +// foobar +// +char* XMLElement::ParseDeep( char* p, StrPair* strPair ) +{ + // Read the element name. + p = XMLUtil::SkipWhiteSpace( p ); + if ( !p ) { + return 0; + } + + // The closing element is the form. It is + // parsed just like a regular element then deleted from + // the DOM. + if ( *p == '/' ) { + _closingType = CLOSING; + ++p; + } + + p = _value.ParseName( p ); + if ( _value.Empty() ) { + return 0; + } + + p = ParseAttributes( p ); + if ( !p || !*p || _closingType ) { + return p; + } + + p = XMLNode::ParseDeep( p, strPair ); + return p; +} + + + +XMLNode* XMLElement::ShallowClone( XMLDocument* doc ) const +{ + if ( !doc ) { + doc = _document; + } + XMLElement* element = doc->NewElement( Value() ); // fixme: this will always allocate memory. Intern? + for( const XMLAttribute* a=FirstAttribute(); a; a=a->Next() ) { + element->SetAttribute( a->Name(), a->Value() ); // fixme: this will always allocate memory. Intern? + } + return element; +} + + +bool XMLElement::ShallowEqual( const XMLNode* compare ) const +{ + const XMLElement* other = compare->ToElement(); + if ( other && XMLUtil::StringEqual( other->Value(), Value() )) { + + const XMLAttribute* a=FirstAttribute(); + const XMLAttribute* b=other->FirstAttribute(); + + while ( a && b ) { + if ( !XMLUtil::StringEqual( a->Value(), b->Value() ) ) { + return false; + } + a = a->Next(); + b = b->Next(); + } + if ( a || b ) { + // different count + return false; + } + return true; + } + return false; +} + + +bool XMLElement::Accept( XMLVisitor* visitor ) const +{ + if ( visitor->VisitEnter( *this, _rootAttribute ) ) { + for ( const XMLNode* node=FirstChild(); node; node=node->NextSibling() ) { + if ( !node->Accept( visitor ) ) { + break; + } + } + } + return visitor->VisitExit( *this ); +} + + +// --------- XMLDocument ----------- // +XMLDocument::XMLDocument( bool processEntities, Whitespace whitespace ) : + XMLNode( 0 ), + _writeBOM( false ), + _processEntities( processEntities ), + _errorID( XML_NO_ERROR ), + _whitespace( whitespace ), + _errorStr1( 0 ), + _errorStr2( 0 ), + _charBuffer( 0 ) +{ + _document = this; // avoid warning about 'this' in initializer list +} + + +XMLDocument::~XMLDocument() +{ + DeleteChildren(); + delete [] _charBuffer; + +#if 0 + textPool.Trace( "text" ); + elementPool.Trace( "element" ); + commentPool.Trace( "comment" ); + attributePool.Trace( "attribute" ); +#endif + +#ifdef DEBUG + if ( Error() == false ) { + TIXMLASSERT( _elementPool.CurrentAllocs() == _elementPool.Untracked() ); + TIXMLASSERT( _attributePool.CurrentAllocs() == _attributePool.Untracked() ); + TIXMLASSERT( _textPool.CurrentAllocs() == _textPool.Untracked() ); + TIXMLASSERT( _commentPool.CurrentAllocs() == _commentPool.Untracked() ); + } +#endif +} + + +void XMLDocument::InitDocument() +{ + _errorID = XML_NO_ERROR; + _errorStr1 = 0; + _errorStr2 = 0; + + delete [] _charBuffer; + _charBuffer = 0; +} + + +XMLElement* XMLDocument::NewElement( const char* name ) +{ + XMLElement* ele = new (_elementPool.Alloc()) XMLElement( this ); + ele->_memPool = &_elementPool; + ele->SetName( name ); + return ele; +} + + +XMLComment* XMLDocument::NewComment( const char* str ) +{ + XMLComment* comment = new (_commentPool.Alloc()) XMLComment( this ); + comment->_memPool = &_commentPool; + comment->SetValue( str ); + return comment; +} + + +XMLText* XMLDocument::NewText( const char* str ) +{ + XMLText* text = new (_textPool.Alloc()) XMLText( this ); + text->_memPool = &_textPool; + text->SetValue( str ); + return text; +} + + +XMLDeclaration* XMLDocument::NewDeclaration( const char* str ) +{ + XMLDeclaration* dec = new (_commentPool.Alloc()) XMLDeclaration( this ); + dec->_memPool = &_commentPool; + dec->SetValue( str ? str : "xml version=\"1.0\" encoding=\"UTF-8\"" ); + return dec; +} + + +XMLUnknown* XMLDocument::NewUnknown( const char* str ) +{ + XMLUnknown* unk = new (_commentPool.Alloc()) XMLUnknown( this ); + unk->_memPool = &_commentPool; + unk->SetValue( str ); + return unk; +} + + +XMLError XMLDocument::LoadFile( const char* filename ) +{ + DeleteChildren(); + InitDocument(); + FILE* fp = 0; + +#if defined(_MSC_VER) && (_MSC_VER >= 1400 ) + errno_t err = fopen_s(&fp, filename, "rb" ); + if ( !fp || err) { +#else + fp = fopen( filename, "rb" ); + if ( !fp) { +#endif + SetError( XML_ERROR_FILE_NOT_FOUND, filename, 0 ); + return _errorID; + } + LoadFile( fp ); + fclose( fp ); + return _errorID; +} + + +XMLError XMLDocument::LoadFile( FILE* fp ) +{ + DeleteChildren(); + InitDocument(); + + fseek( fp, 0, SEEK_END ); + size_t size = ftell( fp ); + fseek( fp, 0, SEEK_SET ); + + if ( size == 0 ) { + return _errorID; + } + + _charBuffer = new char[size+1]; + size_t read = fread( _charBuffer, 1, size, fp ); + if ( read != size ) { + SetError( XML_ERROR_FILE_READ_ERROR, 0, 0 ); + return _errorID; + } + + _charBuffer[size] = 0; + + const char* p = _charBuffer; + p = XMLUtil::SkipWhiteSpace( p ); + p = XMLUtil::ReadBOM( p, &_writeBOM ); + if ( !p || !*p ) { + SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 ); + return _errorID; + } + + ParseDeep( _charBuffer + (p-_charBuffer), 0 ); + return _errorID; +} + + +XMLError XMLDocument::SaveFile( const char* filename, bool compact ) +{ + FILE* fp = 0; +#if defined(_MSC_VER) && (_MSC_VER >= 1400 ) + errno_t err = fopen_s(&fp, filename, "w" ); + if ( !fp || err) { +#else + fp = fopen( filename, "w" ); + if ( !fp) { +#endif + SetError( XML_ERROR_FILE_COULD_NOT_BE_OPENED, filename, 0 ); + return _errorID; + } + SaveFile(fp, compact); + fclose( fp ); + return _errorID; +} + + +XMLError XMLDocument::SaveFile( FILE* fp, bool compact ) +{ + XMLPrinter stream( fp, compact ); + Print( &stream ); + return _errorID; +} + + +XMLError XMLDocument::Parse( const char* p, size_t len ) +{ + DeleteChildren(); + InitDocument(); + + if ( !p || !*p ) { + SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 ); + return _errorID; + } + if ( len == (size_t)(-1) ) { + len = strlen( p ); + } + _charBuffer = new char[ len+1 ]; + memcpy( _charBuffer, p, len ); + _charBuffer[len] = 0; + + p = XMLUtil::SkipWhiteSpace( p ); + p = XMLUtil::ReadBOM( p, &_writeBOM ); + if ( !p || !*p ) { + SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 ); + return _errorID; + } + + ParseDeep( _charBuffer, 0 ); + return _errorID; +} + + +void XMLDocument::Print( XMLPrinter* streamer ) +{ + XMLPrinter stdStreamer( stdout ); + if ( !streamer ) { + streamer = &stdStreamer; + } + Accept( streamer ); +} + + +void XMLDocument::SetError( XMLError error, const char* str1, const char* str2 ) +{ + _errorID = error; + _errorStr1 = str1; + _errorStr2 = str2; +} + + +void XMLDocument::PrintError() const +{ + if ( _errorID ) { + static const int LEN = 20; + char buf1[LEN] = { 0 }; + char buf2[LEN] = { 0 }; + + if ( _errorStr1 ) { + TIXML_SNPRINTF( buf1, LEN, "%s", _errorStr1 ); + } + if ( _errorStr2 ) { + TIXML_SNPRINTF( buf2, LEN, "%s", _errorStr2 ); + } + + printf( "XMLDocument error id=%d str1=%s str2=%s\n", + _errorID, buf1, buf2 ); + } +} + + +XMLPrinter::XMLPrinter( FILE* file, bool compact ) : + _elementJustOpened( false ), + _firstElement( true ), + _fp( file ), + _depth( 0 ), + _textDepth( -1 ), + _processEntities( true ), + _compactMode( compact ) +{ + for( int i=0; i'] = true; // not required, but consistency is nice + _buffer.Push( 0 ); +} + + +void XMLPrinter::Print( const char* format, ... ) +{ + va_list va; + va_start( va, format ); + + if ( _fp ) { + vfprintf( _fp, format, va ); + } + else { + // This seems brutally complex. Haven't figured out a better + // way on windows. +#ifdef _MSC_VER + int len = -1; + int expand = 1000; + while ( len < 0 ) { + len = vsnprintf_s( _accumulator.Mem(), _accumulator.Capacity(), _TRUNCATE, format, va ); + if ( len < 0 ) { + expand *= 3/2; + _accumulator.PushArr( expand ); + } + } + char* p = _buffer.PushArr( len ) - 1; + memcpy( p, _accumulator.Mem(), len+1 ); +#else + int len = vsnprintf( 0, 0, format, va ); + // Close out and re-start the va-args + va_end( va ); + va_start( va, format ); + char* p = _buffer.PushArr( len ) - 1; + vsnprintf( p, len+1, format, va ); +#endif + } + va_end( va ); +} + + +void XMLPrinter::PrintSpace( int depth ) +{ + for( int i=0; i 0 && *q < ENTITY_RANGE ) { + // Check for entities. If one is found, flush + // the stream up until the entity, write the + // entity, and keep looking. + if ( flag[(unsigned)(*q)] ) { + while ( p < q ) { + Print( "%c", *p ); + ++p; + } + for( int i=0; i 0) ) { + Print( "%s", p ); + } +} + + +void XMLPrinter::PushHeader( bool writeBOM, bool writeDec ) +{ + static const unsigned char bom[] = { TIXML_UTF_LEAD_0, TIXML_UTF_LEAD_1, TIXML_UTF_LEAD_2, 0 }; + if ( writeBOM ) { + Print( "%s", bom ); + } + if ( writeDec ) { + PushDeclaration( "xml version=\"1.0\"" ); + } +} + + +void XMLPrinter::OpenElement( const char* name ) +{ + if ( _elementJustOpened ) { + SealElement(); + } + _stack.Push( name ); + + if ( _textDepth < 0 && !_firstElement && !_compactMode ) { + Print( "\n" ); + PrintSpace( _depth ); + } + + Print( "<%s", name ); + _elementJustOpened = true; + _firstElement = false; + ++_depth; +} + + +void XMLPrinter::PushAttribute( const char* name, const char* value ) +{ + TIXMLASSERT( _elementJustOpened ); + Print( " %s=\"", name ); + PrintString( value, false ); + Print( "\"" ); +} + + +void XMLPrinter::PushAttribute( const char* name, int v ) +{ + char buf[BUF_SIZE]; + XMLUtil::ToStr( v, buf, BUF_SIZE ); + PushAttribute( name, buf ); +} + + +void XMLPrinter::PushAttribute( const char* name, unsigned v ) +{ + char buf[BUF_SIZE]; + XMLUtil::ToStr( v, buf, BUF_SIZE ); + PushAttribute( name, buf ); +} + + +void XMLPrinter::PushAttribute( const char* name, bool v ) +{ + char buf[BUF_SIZE]; + XMLUtil::ToStr( v, buf, BUF_SIZE ); + PushAttribute( name, buf ); +} + + +void XMLPrinter::PushAttribute( const char* name, double v ) +{ + char buf[BUF_SIZE]; + XMLUtil::ToStr( v, buf, BUF_SIZE ); + PushAttribute( name, buf ); +} + + +void XMLPrinter::CloseElement() +{ + --_depth; + const char* name = _stack.Pop(); + + if ( _elementJustOpened ) { + Print( "/>" ); + } + else { + if ( _textDepth < 0 && !_compactMode) { + Print( "\n" ); + PrintSpace( _depth ); + } + Print( "", name ); + } + + if ( _textDepth == _depth ) { + _textDepth = -1; + } + if ( _depth == 0 && !_compactMode) { + Print( "\n" ); + } + _elementJustOpened = false; +} + + +void XMLPrinter::SealElement() +{ + _elementJustOpened = false; + Print( ">" ); +} + + +void XMLPrinter::PushText( const char* text, bool cdata ) +{ + _textDepth = _depth-1; + + if ( _elementJustOpened ) { + SealElement(); + } + if ( cdata ) { + Print( "" ); + } + else { + PrintString( text, true ); + } +} + +void XMLPrinter::PushText( int value ) +{ + char buf[BUF_SIZE]; + XMLUtil::ToStr( value, buf, BUF_SIZE ); + PushText( buf, false ); +} + + +void XMLPrinter::PushText( unsigned value ) +{ + char buf[BUF_SIZE]; + XMLUtil::ToStr( value, buf, BUF_SIZE ); + PushText( buf, false ); +} + + +void XMLPrinter::PushText( bool value ) +{ + char buf[BUF_SIZE]; + XMLUtil::ToStr( value, buf, BUF_SIZE ); + PushText( buf, false ); +} + + +void XMLPrinter::PushText( float value ) +{ + char buf[BUF_SIZE]; + XMLUtil::ToStr( value, buf, BUF_SIZE ); + PushText( buf, false ); +} + + +void XMLPrinter::PushText( double value ) +{ + char buf[BUF_SIZE]; + XMLUtil::ToStr( value, buf, BUF_SIZE ); + PushText( buf, false ); +} + + +void XMLPrinter::PushComment( const char* comment ) +{ + if ( _elementJustOpened ) { + SealElement(); + } + if ( _textDepth < 0 && !_firstElement && !_compactMode) { + Print( "\n" ); + PrintSpace( _depth ); + } + _firstElement = false; + Print( "", comment ); +} + + +void XMLPrinter::PushDeclaration( const char* value ) +{ + if ( _elementJustOpened ) { + SealElement(); + } + if ( _textDepth < 0 && !_firstElement && !_compactMode) { + Print( "\n" ); + PrintSpace( _depth ); + } + _firstElement = false; + Print( "", value ); +} + + +void XMLPrinter::PushUnknown( const char* value ) +{ + if ( _elementJustOpened ) { + SealElement(); + } + if ( _textDepth < 0 && !_firstElement && !_compactMode) { + Print( "\n" ); + PrintSpace( _depth ); + } + _firstElement = false; + Print( "", value ); +} + + +bool XMLPrinter::VisitEnter( const XMLDocument& doc ) +{ + _processEntities = doc.ProcessEntities(); + if ( doc.HasBOM() ) { + PushHeader( true, false ); + } + return true; +} + + +bool XMLPrinter::VisitEnter( const XMLElement& element, const XMLAttribute* attribute ) +{ + OpenElement( element.Name() ); + while ( attribute ) { + PushAttribute( attribute->Name(), attribute->Value() ); + attribute = attribute->Next(); + } + return true; +} + + +bool XMLPrinter::VisitExit( const XMLElement& ) +{ + CloseElement(); + return true; +} + + +bool XMLPrinter::Visit( const XMLText& text ) +{ + PushText( text.Value(), text.CData() ); + return true; +} + + +bool XMLPrinter::Visit( const XMLComment& comment ) +{ + PushComment( comment.Value() ); + return true; +} + +bool XMLPrinter::Visit( const XMLDeclaration& declaration ) +{ + PushDeclaration( declaration.Value() ); + return true; +} + + +bool XMLPrinter::Visit( const XMLUnknown& unknown ) +{ + PushUnknown( unknown.Value() ); + return true; +} + +} // namespace tinyxml2 + diff -r 000000000000 -r 1b39a1b46319 3rdParty/TinyXml/tinyxml2.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/3rdParty/TinyXml/tinyxml2.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,1911 @@ +/* +Original code by Lee Thomason (www.grinninglizard.com) + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any +damages arising from the use of this software. + +Permission is granted to anyone to use this software for any +purpose, including commercial applications, and to alter it and +redistribute it freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must +not claim that you wrote the original software. If you use this +software in a product, an acknowledgment in the product documentation +would be appreciated but is not required. + +2. Altered source versions must be plainly marked as such, and +must not be misrepresented as being the original software. + +3. This notice may not be removed or altered from any source +distribution. +*/ + +#ifndef TINYXML2_INCLUDED +#define TINYXML2_INCLUDED + +#if defined(ANDROID_NDK) || defined(__BORLANDC__) +# include +# include +# include +# include +# include +# include +#else +# include +# include +# include +# include +# include +# include +#endif + +/* + TODO: intern strings instead of allocation. +*/ +/* + gcc: + g++ -Wall -DDEBUG tinyxml2.cpp xmltest.cpp -o gccxmltest.exe + + Formatting, Artistic Style: + AStyle.exe --style=1tbs --indent-switches --break-closing-brackets --indent-preprocessor tinyxml2.cpp tinyxml2.h +*/ + +#if defined( _DEBUG ) || defined( DEBUG ) || defined (__DEBUG__) +# ifndef DEBUG +# define DEBUG +# endif +#endif + + +#if defined(DEBUG) +# if defined(_MSC_VER) +# define TIXMLASSERT( x ) if ( !(x)) { __debugbreak(); } //if ( !(x)) WinDebugBreak() +# elif defined (ANDROID_NDK) +# include +# define TIXMLASSERT( x ) if ( !(x)) { __android_log_assert( "assert", "grinliz", "ASSERT in '%s' at %d.", __FILE__, __LINE__ ); } +# else +# include +# define TIXMLASSERT assert +# endif +# else +# define TIXMLASSERT( x ) {} +#endif + + +#if defined(_MSC_VER) && (_MSC_VER >= 1400 ) +// Microsoft visual studio, version 2005 and higher. +/*int _snprintf_s( + char *buffer, + size_t sizeOfBuffer, + size_t count, + const char *format [, + argument] ... +);*/ +inline int TIXML_SNPRINTF( char* buffer, size_t size, const char* format, ... ) +{ + va_list va; + va_start( va, format ); + int result = vsnprintf_s( buffer, size, _TRUNCATE, format, va ); + va_end( va ); + return result; +} +#define TIXML_SSCANF sscanf_s +#else +// GCC version 3 and higher +//#warning( "Using sn* functions." ) +#define TIXML_SNPRINTF snprintf +#define TIXML_SSCANF sscanf +#endif + +static const int TIXML2_MAJOR_VERSION = 1; +static const int TIXML2_MINOR_VERSION = 0; +static const int TIXML2_PATCH_VERSION = 9; + +namespace tinyxml2 +{ +class XMLDocument; +class XMLElement; +class XMLAttribute; +class XMLComment; +class XMLNode; +class XMLText; +class XMLDeclaration; +class XMLUnknown; + +class XMLPrinter; + +/* + A class that wraps strings. Normally stores the start and end + pointers into the XML file itself, and will apply normalization + and entity translation if actually read. Can also store (and memory + manage) a traditional char[] +*/ +class StrPair +{ +public: + enum { + NEEDS_ENTITY_PROCESSING = 0x01, + NEEDS_NEWLINE_NORMALIZATION = 0x02, + COLLAPSE_WHITESPACE = 0x04, + + TEXT_ELEMENT = NEEDS_ENTITY_PROCESSING | NEEDS_NEWLINE_NORMALIZATION, + TEXT_ELEMENT_LEAVE_ENTITIES = NEEDS_NEWLINE_NORMALIZATION, + ATTRIBUTE_NAME = 0, + ATTRIBUTE_VALUE = NEEDS_ENTITY_PROCESSING | NEEDS_NEWLINE_NORMALIZATION, + ATTRIBUTE_VALUE_LEAVE_ENTITIES = NEEDS_NEWLINE_NORMALIZATION, + COMMENT = NEEDS_NEWLINE_NORMALIZATION + }; + + StrPair() : _flags( 0 ), _start( 0 ), _end( 0 ) {} + ~StrPair(); + + void Set( char* start, char* end, int flags ) { + Reset(); + _start = start; + _end = end; + _flags = flags | NEEDS_FLUSH; + } + + const char* GetStr(); + + bool Empty() const { + return _start == _end; + } + + void SetInternedStr( const char* str ) { + Reset(); + _start = const_cast(str); + } + + void SetStr( const char* str, int flags=0 ); + + char* ParseText( char* in, const char* endTag, int strFlags ); + char* ParseName( char* in ); + +private: + void Reset(); + void CollapseWhitespace(); + + enum { + NEEDS_FLUSH = 0x100, + NEEDS_DELETE = 0x200 + }; + + // After parsing, if *end != 0, it can be set to zero. + int _flags; + char* _start; + char* _end; +}; + + +/* + A dynamic array of Plain Old Data. Doesn't support constructors, etc. + Has a small initial memory pool, so that low or no usage will not + cause a call to new/delete +*/ +template +class DynArray +{ +public: + DynArray< T, INIT >() { + _mem = _pool; + _allocated = INIT; + _size = 0; + } + + ~DynArray() { + if ( _mem != _pool ) { + delete [] _mem; + } + } + + void Push( T t ) { + EnsureCapacity( _size+1 ); + _mem[_size++] = t; + } + + T* PushArr( int count ) { + EnsureCapacity( _size+count ); + T* ret = &_mem[_size]; + _size += count; + return ret; + } + + T Pop() { + return _mem[--_size]; + } + + void PopArr( int count ) { + TIXMLASSERT( _size >= count ); + _size -= count; + } + + bool Empty() const { + return _size == 0; + } + + T& operator[](int i) { + TIXMLASSERT( i>= 0 && i < _size ); + return _mem[i]; + } + + const T& operator[](int i) const { + TIXMLASSERT( i>= 0 && i < _size ); + return _mem[i]; + } + + int Size() const { + return _size; + } + + int Capacity() const { + return _allocated; + } + + const T* Mem() const { + return _mem; + } + + T* Mem() { + return _mem; + } + +private: + void EnsureCapacity( int cap ) { + if ( cap > _allocated ) { + int newAllocated = cap * 2; + T* newMem = new T[newAllocated]; + memcpy( newMem, _mem, sizeof(T)*_size ); // warning: not using constructors, only works for PODs + if ( _mem != _pool ) { + delete [] _mem; + } + _mem = newMem; + _allocated = newAllocated; + } + } + + T* _mem; + T _pool[INIT]; + int _allocated; // objects allocated + int _size; // number objects in use +}; + + +/* + Parent virtual class of a pool for fast allocation + and deallocation of objects. +*/ +class MemPool +{ +public: + MemPool() {} + virtual ~MemPool() {} + + virtual int ItemSize() const = 0; + virtual void* Alloc() = 0; + virtual void Free( void* ) = 0; + virtual void SetTracked() = 0; +}; + + +/* + Template child class to create pools of the correct type. +*/ +template< int SIZE > +class MemPoolT : public MemPool +{ +public: + MemPoolT() : _root(0), _currentAllocs(0), _nAllocs(0), _maxAllocs(0), _nUntracked(0) {} + ~MemPoolT() { + // Delete the blocks. + for( int i=0; i<_blockPtrs.Size(); ++i ) { + delete _blockPtrs[i]; + } + } + + virtual int ItemSize() const { + return SIZE; + } + int CurrentAllocs() const { + return _currentAllocs; + } + + virtual void* Alloc() { + if ( !_root ) { + // Need a new block. + Block* block = new Block(); + _blockPtrs.Push( block ); + + for( int i=0; ichunk[i].next = &block->chunk[i+1]; + } + block->chunk[COUNT-1].next = 0; + _root = block->chunk; + } + void* result = _root; + _root = _root->next; + + ++_currentAllocs; + if ( _currentAllocs > _maxAllocs ) { + _maxAllocs = _currentAllocs; + } + _nAllocs++; + _nUntracked++; + return result; + } + virtual void Free( void* mem ) { + if ( !mem ) { + return; + } + --_currentAllocs; + Chunk* chunk = (Chunk*)mem; +#ifdef DEBUG + memset( chunk, 0xfe, sizeof(Chunk) ); +#endif + chunk->next = _root; + _root = chunk; + } + void Trace( const char* name ) { + printf( "Mempool %s watermark=%d [%dk] current=%d size=%d nAlloc=%d blocks=%d\n", + name, _maxAllocs, _maxAllocs*SIZE/1024, _currentAllocs, SIZE, _nAllocs, _blockPtrs.Size() ); + } + + void SetTracked() { + _nUntracked--; + } + + int Untracked() const { + return _nUntracked; + } + + enum { COUNT = 1024/SIZE }; // Some compilers do not accept to use COUNT in private part if COUNT is private + +private: + union Chunk { + Chunk* next; + char mem[SIZE]; + }; + struct Block { + Chunk chunk[COUNT]; + }; + DynArray< Block*, 10 > _blockPtrs; + Chunk* _root; + + int _currentAllocs; + int _nAllocs; + int _maxAllocs; + int _nUntracked; +}; + + + +/** + Implements the interface to the "Visitor pattern" (see the Accept() method.) + If you call the Accept() method, it requires being passed a XMLVisitor + class to handle callbacks. For nodes that contain other nodes (Document, Element) + you will get called with a VisitEnter/VisitExit pair. Nodes that are always leafs + are simply called with Visit(). + + If you return 'true' from a Visit method, recursive parsing will continue. If you return + false, no children of this node or its sibilings will be visited. + + All flavors of Visit methods have a default implementation that returns 'true' (continue + visiting). You need to only override methods that are interesting to you. + + Generally Accept() is called on the TiXmlDocument, although all nodes support visiting. + + You should never change the document from a callback. + + @sa XMLNode::Accept() +*/ +class XMLVisitor +{ +public: + virtual ~XMLVisitor() {} + + /// Visit a document. + virtual bool VisitEnter( const XMLDocument& /*doc*/ ) { + return true; + } + /// Visit a document. + virtual bool VisitExit( const XMLDocument& /*doc*/ ) { + return true; + } + + /// Visit an element. + virtual bool VisitEnter( const XMLElement& /*element*/, const XMLAttribute* /*firstAttribute*/ ) { + return true; + } + /// Visit an element. + virtual bool VisitExit( const XMLElement& /*element*/ ) { + return true; + } + + /// Visit a declaration. + virtual bool Visit( const XMLDeclaration& /*declaration*/ ) { + return true; + } + /// Visit a text node. + virtual bool Visit( const XMLText& /*text*/ ) { + return true; + } + /// Visit a comment node. + virtual bool Visit( const XMLComment& /*comment*/ ) { + return true; + } + /// Visit an unknown node. + virtual bool Visit( const XMLUnknown& /*unknown*/ ) { + return true; + } +}; + + +/* + Utility functionality. +*/ +class XMLUtil +{ +public: + // Anything in the high order range of UTF-8 is assumed to not be whitespace. This isn't + // correct, but simple, and usually works. + static const char* SkipWhiteSpace( const char* p ) { + while( !IsUTF8Continuation(*p) && isspace( *reinterpret_cast(p) ) ) { + ++p; + } + return p; + } + static char* SkipWhiteSpace( char* p ) { + while( !IsUTF8Continuation(*p) && isspace( *reinterpret_cast(p) ) ) { + ++p; + } + return p; + } + static bool IsWhiteSpace( char p ) { + return !IsUTF8Continuation(p) && isspace( static_cast(p) ); + } + + inline static bool StringEqual( const char* p, const char* q, int nChar=INT_MAX ) { + int n = 0; + if ( p == q ) { + return true; + } + while( *p && *q && *p == *q && n(const_cast(this)->FirstChildElement( value )); + } + + /// Get the last child node, or null if none exists. + const XMLNode* LastChild() const { + return _lastChild; + } + + XMLNode* LastChild() { + return const_cast(const_cast(this)->LastChild() ); + } + + /** Get the last child element or optionally the last child + element with the specified name. + */ + const XMLElement* LastChildElement( const char* value=0 ) const; + + XMLElement* LastChildElement( const char* value=0 ) { + return const_cast(const_cast(this)->LastChildElement(value) ); + } + + /// Get the previous (left) sibling node of this node. + const XMLNode* PreviousSibling() const { + return _prev; + } + + XMLNode* PreviousSibling() { + return _prev; + } + + /// Get the previous (left) sibling element of this node, with an opitionally supplied name. + const XMLElement* PreviousSiblingElement( const char* value=0 ) const ; + + XMLElement* PreviousSiblingElement( const char* value=0 ) { + return const_cast(const_cast(this)->PreviousSiblingElement( value ) ); + } + + /// Get the next (right) sibling node of this node. + const XMLNode* NextSibling() const { + return _next; + } + + XMLNode* NextSibling() { + return _next; + } + + /// Get the next (right) sibling element of this node, with an opitionally supplied name. + const XMLElement* NextSiblingElement( const char* value=0 ) const; + + XMLElement* NextSiblingElement( const char* value=0 ) { + return const_cast(const_cast(this)->NextSiblingElement( value ) ); + } + + /** + Add a child node as the last (right) child. + */ + XMLNode* InsertEndChild( XMLNode* addThis ); + + XMLNode* LinkEndChild( XMLNode* addThis ) { + return InsertEndChild( addThis ); + } + /** + Add a child node as the first (left) child. + */ + XMLNode* InsertFirstChild( XMLNode* addThis ); + /** + Add a node after the specified child node. + */ + XMLNode* InsertAfterChild( XMLNode* afterThis, XMLNode* addThis ); + + /** + Delete all the children of this node. + */ + void DeleteChildren(); + + /** + Delete a child of this node. + */ + void DeleteChild( XMLNode* node ); + + /** + Make a copy of this node, but not its children. + You may pass in a Document pointer that will be + the owner of the new Node. If the 'document' is + null, then the node returned will be allocated + from the current Document. (this->GetDocument()) + + Note: if called on a XMLDocument, this will return null. + */ + virtual XMLNode* ShallowClone( XMLDocument* document ) const = 0; + + /** + Test if 2 nodes are the same, but don't test children. + The 2 nodes do not need to be in the same Document. + + Note: if called on a XMLDocument, this will return false. + */ + virtual bool ShallowEqual( const XMLNode* compare ) const = 0; + + /** Accept a hierarchical visit of the nodes in the TinyXML DOM. Every node in the + XML tree will be conditionally visited and the host will be called back + via the TiXmlVisitor interface. + + This is essentially a SAX interface for TinyXML. (Note however it doesn't re-parse + the XML for the callbacks, so the performance of TinyXML is unchanged by using this + interface versus any other.) + + The interface has been based on ideas from: + + - http://www.saxproject.org/ + - http://c2.com/cgi/wiki?HierarchicalVisitorPattern + + Which are both good references for "visiting". + + An example of using Accept(): + @verbatim + TiXmlPrinter printer; + tinyxmlDoc.Accept( &printer ); + const char* xmlcstr = printer.CStr(); + @endverbatim + */ + virtual bool Accept( XMLVisitor* visitor ) const = 0; + + // internal + virtual char* ParseDeep( char*, StrPair* ); + +protected: + XMLNode( XMLDocument* ); + virtual ~XMLNode(); + XMLNode( const XMLNode& ); // not supported + XMLNode& operator=( const XMLNode& ); // not supported + + XMLDocument* _document; + XMLNode* _parent; + mutable StrPair _value; + + XMLNode* _firstChild; + XMLNode* _lastChild; + + XMLNode* _prev; + XMLNode* _next; + +private: + MemPool* _memPool; + void Unlink( XMLNode* child ); +}; + + +/** XML text. + + Note that a text node can have child element nodes, for example: + @verbatim + This is bold + @endverbatim + + A text node can have 2 ways to output the next. "normal" output + and CDATA. It will default to the mode it was parsed from the XML file and + you generally want to leave it alone, but you can change the output mode with + SetCDATA() and query it with CDATA(). +*/ +class XMLText : public XMLNode +{ + friend class XMLBase; + friend class XMLDocument; +public: + virtual bool Accept( XMLVisitor* visitor ) const; + + virtual XMLText* ToText() { + return this; + } + virtual const XMLText* ToText() const { + return this; + } + + /// Declare whether this should be CDATA or standard text. + void SetCData( bool isCData ) { + _isCData = isCData; + } + /// Returns true if this is a CDATA text element. + bool CData() const { + return _isCData; + } + + char* ParseDeep( char*, StrPair* endTag ); + virtual XMLNode* ShallowClone( XMLDocument* document ) const; + virtual bool ShallowEqual( const XMLNode* compare ) const; + +protected: + XMLText( XMLDocument* doc ) : XMLNode( doc ), _isCData( false ) {} + virtual ~XMLText() {} + XMLText( const XMLText& ); // not supported + XMLText& operator=( const XMLText& ); // not supported + +private: + bool _isCData; +}; + + +/** An XML Comment. */ +class XMLComment : public XMLNode +{ + friend class XMLDocument; +public: + virtual XMLComment* ToComment() { + return this; + } + virtual const XMLComment* ToComment() const { + return this; + } + + virtual bool Accept( XMLVisitor* visitor ) const; + + char* ParseDeep( char*, StrPair* endTag ); + virtual XMLNode* ShallowClone( XMLDocument* document ) const; + virtual bool ShallowEqual( const XMLNode* compare ) const; + +protected: + XMLComment( XMLDocument* doc ); + virtual ~XMLComment(); + XMLComment( const XMLComment& ); // not supported + XMLComment& operator=( const XMLComment& ); // not supported + +private: +}; + + +/** In correct XML the declaration is the first entry in the file. + @verbatim + + @endverbatim + + TinyXML2 will happily read or write files without a declaration, + however. + + The text of the declaration isn't interpreted. It is parsed + and written as a string. +*/ +class XMLDeclaration : public XMLNode +{ + friend class XMLDocument; +public: + virtual XMLDeclaration* ToDeclaration() { + return this; + } + virtual const XMLDeclaration* ToDeclaration() const { + return this; + } + + virtual bool Accept( XMLVisitor* visitor ) const; + + char* ParseDeep( char*, StrPair* endTag ); + virtual XMLNode* ShallowClone( XMLDocument* document ) const; + virtual bool ShallowEqual( const XMLNode* compare ) const; + +protected: + XMLDeclaration( XMLDocument* doc ); + virtual ~XMLDeclaration(); + XMLDeclaration( const XMLDeclaration& ); // not supported + XMLDeclaration& operator=( const XMLDeclaration& ); // not supported +}; + + +/** Any tag that tinyXml doesn't recognize is saved as an + unknown. It is a tag of text, but should not be modified. + It will be written back to the XML, unchanged, when the file + is saved. + + DTD tags get thrown into TiXmlUnknowns. +*/ +class XMLUnknown : public XMLNode +{ + friend class XMLDocument; +public: + virtual XMLUnknown* ToUnknown() { + return this; + } + virtual const XMLUnknown* ToUnknown() const { + return this; + } + + virtual bool Accept( XMLVisitor* visitor ) const; + + char* ParseDeep( char*, StrPair* endTag ); + virtual XMLNode* ShallowClone( XMLDocument* document ) const; + virtual bool ShallowEqual( const XMLNode* compare ) const; + +protected: + XMLUnknown( XMLDocument* doc ); + virtual ~XMLUnknown(); + XMLUnknown( const XMLUnknown& ); // not supported + XMLUnknown& operator=( const XMLUnknown& ); // not supported +}; + + +enum XMLError { + XML_NO_ERROR = 0, + XML_SUCCESS = 0, + + XML_NO_ATTRIBUTE, + XML_WRONG_ATTRIBUTE_TYPE, + + XML_ERROR_FILE_NOT_FOUND, + XML_ERROR_FILE_COULD_NOT_BE_OPENED, + XML_ERROR_FILE_READ_ERROR, + XML_ERROR_ELEMENT_MISMATCH, + XML_ERROR_PARSING_ELEMENT, + XML_ERROR_PARSING_ATTRIBUTE, + XML_ERROR_IDENTIFYING_TAG, + XML_ERROR_PARSING_TEXT, + XML_ERROR_PARSING_CDATA, + XML_ERROR_PARSING_COMMENT, + XML_ERROR_PARSING_DECLARATION, + XML_ERROR_PARSING_UNKNOWN, + XML_ERROR_EMPTY_DOCUMENT, + XML_ERROR_MISMATCHED_ELEMENT, + XML_ERROR_PARSING, + + XML_CAN_NOT_CONVERT_TEXT, + XML_NO_TEXT_NODE +}; + + +/** An attribute is a name-value pair. Elements have an arbitrary + number of attributes, each with a unique name. + + @note The attributes are not XMLNodes. You may only query the + Next() attribute in a list. +*/ +class XMLAttribute +{ + friend class XMLElement; +public: + /// The name of the attribute. + const char* Name() const { + return _name.GetStr(); + } + /// The value of the attribute. + const char* Value() const { + return _value.GetStr(); + } + /// The next attribute in the list. + const XMLAttribute* Next() const { + return _next; + } + + /** IntAttribute interprets the attribute as an integer, and returns the value. + If the value isn't an integer, 0 will be returned. There is no error checking; + use QueryIntAttribute() if you need error checking. + */ + int IntValue() const { + int i=0; + QueryIntValue( &i ); + return i; + } + /// Query as an unsigned integer. See IntAttribute() + unsigned UnsignedValue() const { + unsigned i=0; + QueryUnsignedValue( &i ); + return i; + } + /// Query as a boolean. See IntAttribute() + bool BoolValue() const { + bool b=false; + QueryBoolValue( &b ); + return b; + } + /// Query as a double. See IntAttribute() + double DoubleValue() const { + double d=0; + QueryDoubleValue( &d ); + return d; + } + /// Query as a float. See IntAttribute() + float FloatValue() const { + float f=0; + QueryFloatValue( &f ); + return f; + } + + /** QueryIntAttribute interprets the attribute as an integer, and returns the value + in the provided paremeter. The function will return XML_NO_ERROR on success, + and XML_WRONG_ATTRIBUTE_TYPE if the conversion is not successful. + */ + XMLError QueryIntValue( int* value ) const; + /// See QueryIntAttribute + XMLError QueryUnsignedValue( unsigned int* value ) const; + /// See QueryIntAttribute + XMLError QueryBoolValue( bool* value ) const; + /// See QueryIntAttribute + XMLError QueryDoubleValue( double* value ) const; + /// See QueryIntAttribute + XMLError QueryFloatValue( float* value ) const; + + /// Set the attribute to a string value. + void SetAttribute( const char* value ); + /// Set the attribute to value. + void SetAttribute( int value ); + /// Set the attribute to value. + void SetAttribute( unsigned value ); + /// Set the attribute to value. + void SetAttribute( bool value ); + /// Set the attribute to value. + void SetAttribute( double value ); + /// Set the attribute to value. + void SetAttribute( float value ); + +private: + enum { BUF_SIZE = 200 }; + + XMLAttribute() : _next( 0 ) {} + virtual ~XMLAttribute() {} + + XMLAttribute( const XMLAttribute& ); // not supported + void operator=( const XMLAttribute& ); // not supported + void SetName( const char* name ); + + char* ParseDeep( char* p, bool processEntities ); + + mutable StrPair _name; + mutable StrPair _value; + XMLAttribute* _next; + MemPool* _memPool; +}; + + +/** The element is a container class. It has a value, the element name, + and can contain other elements, text, comments, and unknowns. + Elements also contain an arbitrary number of attributes. +*/ +class XMLElement : public XMLNode +{ + friend class XMLBase; + friend class XMLDocument; +public: + /// Get the name of an element (which is the Value() of the node.) + const char* Name() const { + return Value(); + } + /// Set the name of the element. + void SetName( const char* str, bool staticMem=false ) { + SetValue( str, staticMem ); + } + + virtual XMLElement* ToElement() { + return this; + } + virtual const XMLElement* ToElement() const { + return this; + } + virtual bool Accept( XMLVisitor* visitor ) const; + + /** Given an attribute name, Attribute() returns the value + for the attribute of that name, or null if none + exists. For example: + + @verbatim + const char* value = ele->Attribute( "foo" ); + @endverbatim + + The 'value' parameter is normally null. However, if specified, + the attribute will only be returned if the 'name' and 'value' + match. This allow you to write code: + + @verbatim + if ( ele->Attribute( "foo", "bar" ) ) callFooIsBar(); + @endverbatim + + rather than: + @verbatim + if ( ele->Attribute( "foo" ) ) { + if ( strcmp( ele->Attribute( "foo" ), "bar" ) == 0 ) callFooIsBar(); + } + @endverbatim + */ + const char* Attribute( const char* name, const char* value=0 ) const; + + /** Given an attribute name, IntAttribute() returns the value + of the attribute interpreted as an integer. 0 will be + returned if there is an error. For a method with error + checking, see QueryIntAttribute() + */ + int IntAttribute( const char* name ) const { + int i=0; + QueryIntAttribute( name, &i ); + return i; + } + /// See IntAttribute() + unsigned UnsignedAttribute( const char* name ) const { + unsigned i=0; + QueryUnsignedAttribute( name, &i ); + return i; + } + /// See IntAttribute() + bool BoolAttribute( const char* name ) const { + bool b=false; + QueryBoolAttribute( name, &b ); + return b; + } + /// See IntAttribute() + double DoubleAttribute( const char* name ) const { + double d=0; + QueryDoubleAttribute( name, &d ); + return d; + } + /// See IntAttribute() + float FloatAttribute( const char* name ) const { + float f=0; + QueryFloatAttribute( name, &f ); + return f; + } + + /** Given an attribute name, QueryIntAttribute() returns + XML_NO_ERROR, XML_WRONG_ATTRIBUTE_TYPE if the conversion + can't be performed, or XML_NO_ATTRIBUTE if the attribute + doesn't exist. If successful, the result of the conversion + will be written to 'value'. If not successful, nothing will + be written to 'value'. This allows you to provide default + value: + + @verbatim + int value = 10; + QueryIntAttribute( "foo", &value ); // if "foo" isn't found, value will still be 10 + @endverbatim + */ + XMLError QueryIntAttribute( const char* name, int* value ) const { + const XMLAttribute* a = FindAttribute( name ); + if ( !a ) { + return XML_NO_ATTRIBUTE; + } + return a->QueryIntValue( value ); + } + /// See QueryIntAttribute() + XMLError QueryUnsignedAttribute( const char* name, unsigned int* value ) const { + const XMLAttribute* a = FindAttribute( name ); + if ( !a ) { + return XML_NO_ATTRIBUTE; + } + return a->QueryUnsignedValue( value ); + } + /// See QueryIntAttribute() + XMLError QueryBoolAttribute( const char* name, bool* value ) const { + const XMLAttribute* a = FindAttribute( name ); + if ( !a ) { + return XML_NO_ATTRIBUTE; + } + return a->QueryBoolValue( value ); + } + /// See QueryIntAttribute() + XMLError QueryDoubleAttribute( const char* name, double* value ) const { + const XMLAttribute* a = FindAttribute( name ); + if ( !a ) { + return XML_NO_ATTRIBUTE; + } + return a->QueryDoubleValue( value ); + } + /// See QueryIntAttribute() + XMLError QueryFloatAttribute( const char* name, float* value ) const { + const XMLAttribute* a = FindAttribute( name ); + if ( !a ) { + return XML_NO_ATTRIBUTE; + } + return a->QueryFloatValue( value ); + } + + /// Sets the named attribute to value. + void SetAttribute( const char* name, const char* value ) { + XMLAttribute* a = FindOrCreateAttribute( name ); + a->SetAttribute( value ); + } + /// Sets the named attribute to value. + void SetAttribute( const char* name, int value ) { + XMLAttribute* a = FindOrCreateAttribute( name ); + a->SetAttribute( value ); + } + /// Sets the named attribute to value. + void SetAttribute( const char* name, unsigned value ) { + XMLAttribute* a = FindOrCreateAttribute( name ); + a->SetAttribute( value ); + } + /// Sets the named attribute to value. + void SetAttribute( const char* name, bool value ) { + XMLAttribute* a = FindOrCreateAttribute( name ); + a->SetAttribute( value ); + } + /// Sets the named attribute to value. + void SetAttribute( const char* name, double value ) { + XMLAttribute* a = FindOrCreateAttribute( name ); + a->SetAttribute( value ); + } + + /** + Delete an attribute. + */ + void DeleteAttribute( const char* name ); + + /// Return the first attribute in the list. + const XMLAttribute* FirstAttribute() const { + return _rootAttribute; + } + /// Query a specific attribute in the list. + const XMLAttribute* FindAttribute( const char* name ) const; + + /** Convenience function for easy access to the text inside an element. Although easy + and concise, GetText() is limited compared to getting the TiXmlText child + and accessing it directly. + + If the first child of 'this' is a TiXmlText, the GetText() + returns the character string of the Text node, else null is returned. + + This is a convenient method for getting the text of simple contained text: + @verbatim + This is text + const char* str = fooElement->GetText(); + @endverbatim + + 'str' will be a pointer to "This is text". + + Note that this function can be misleading. If the element foo was created from + this XML: + @verbatim + This is text + @endverbatim + + then the value of str would be null. The first child node isn't a text node, it is + another element. From this XML: + @verbatim + This is text + @endverbatim + GetText() will return "This is ". + */ + const char* GetText() const; + + /** + Convenience method to query the value of a child text node. This is probably best + shown by example. Given you have a document is this form: + @verbatim + + 1 + 1.4 + + @endverbatim + + The QueryIntText() and similar functions provide a safe and easier way to get to the + "value" of x and y. + + @verbatim + int x = 0; + float y = 0; // types of x and y are contrived for example + const XMLElement* xElement = pointElement->FirstChildElement( "x" ); + const XMLElement* yElement = pointElement->FirstChildElement( "y" ); + xElement->QueryIntText( &x ); + yElement->QueryFloatText( &y ); + @endverbatim + + @returns XML_SUCCESS (0) on success, XML_CAN_NOT_CONVERT_TEXT if the text cannot be converted + to the requested type, and XML_NO_TEXT_NODE if there is no child text to query. + + */ + XMLError QueryIntText( int* ival ) const; + /// See QueryIntText() + XMLError QueryUnsignedText( unsigned* uval ) const; + /// See QueryIntText() + XMLError QueryBoolText( bool* bval ) const; + /// See QueryIntText() + XMLError QueryDoubleText( double* dval ) const; + /// See QueryIntText() + XMLError QueryFloatText( float* fval ) const; + + // internal: + enum { + OPEN, // + CLOSED, // + CLOSING // + }; + int ClosingType() const { + return _closingType; + } + char* ParseDeep( char* p, StrPair* endTag ); + virtual XMLNode* ShallowClone( XMLDocument* document ) const; + virtual bool ShallowEqual( const XMLNode* compare ) const; + +private: + XMLElement( XMLDocument* doc ); + virtual ~XMLElement(); + XMLElement( const XMLElement& ); // not supported + void operator=( const XMLElement& ); // not supported + + XMLAttribute* FindAttribute( const char* name ); + XMLAttribute* FindOrCreateAttribute( const char* name ); + //void LinkAttribute( XMLAttribute* attrib ); + char* ParseAttributes( char* p ); + + int _closingType; + // The attribute list is ordered; there is no 'lastAttribute' + // because the list needs to be scanned for dupes before adding + // a new attribute. + XMLAttribute* _rootAttribute; +}; + + +enum Whitespace { + PRESERVE_WHITESPACE, + COLLAPSE_WHITESPACE +}; + + +/** A Document binds together all the functionality. + It can be saved, loaded, and printed to the screen. + All Nodes are connected and allocated to a Document. + If the Document is deleted, all its Nodes are also deleted. +*/ +class XMLDocument : public XMLNode +{ + friend class XMLElement; +public: + /// constructor + XMLDocument( bool processEntities = true, Whitespace = PRESERVE_WHITESPACE ); + ~XMLDocument(); + + virtual XMLDocument* ToDocument() { + return this; + } + virtual const XMLDocument* ToDocument() const { + return this; + } + + /** + Parse an XML file from a character string. + Returns XML_NO_ERROR (0) on success, or + an errorID. + + You may optionally pass in the 'nBytes', which is + the number of bytes which will be parsed. If not + specified, TinyXML will assume 'xml' points to a + null terminated string. + */ + XMLError Parse( const char* xml, size_t nBytes=(size_t)(-1) ); + + /** + Load an XML file from disk. + Returns XML_NO_ERROR (0) on success, or + an errorID. + */ + XMLError LoadFile( const char* filename ); + + /** + Load an XML file from disk. You are responsible + for providing and closing the FILE*. + + Returns XML_NO_ERROR (0) on success, or + an errorID. + */ + XMLError LoadFile( FILE* ); + + /** + Save the XML file to disk. + Returns XML_NO_ERROR (0) on success, or + an errorID. + */ + XMLError SaveFile( const char* filename, bool compact = false ); + + /** + Save the XML file to disk. You are responsible + for providing and closing the FILE*. + + Returns XML_NO_ERROR (0) on success, or + an errorID. + */ + XMLError SaveFile( FILE* fp, bool compact = false ); + + bool ProcessEntities() const { + return _processEntities; + } + Whitespace WhitespaceMode() const { + return _whitespace; + } + + /** + Returns true if this document has a leading Byte Order Mark of UTF8. + */ + bool HasBOM() const { + return _writeBOM; + } + /** Sets whether to write the BOM when writing the file. + */ + void SetBOM( bool useBOM ) { + _writeBOM = useBOM; + } + + /** Return the root element of DOM. Equivalent to FirstChildElement(). + To get the first node, use FirstChild(). + */ + XMLElement* RootElement() { + return FirstChildElement(); + } + const XMLElement* RootElement() const { + return FirstChildElement(); + } + + /** Print the Document. If the Printer is not provided, it will + print to stdout. If you provide Printer, this can print to a file: + @verbatim + XMLPrinter printer( fp ); + doc.Print( &printer ); + @endverbatim + + Or you can use a printer to print to memory: + @verbatim + XMLPrinter printer; + doc->Print( &printer ); + // printer.CStr() has a const char* to the XML + @endverbatim + */ + void Print( XMLPrinter* streamer=0 ); + virtual bool Accept( XMLVisitor* visitor ) const; + + /** + Create a new Element associated with + this Document. The memory for the Element + is managed by the Document. + */ + XMLElement* NewElement( const char* name ); + /** + Create a new Comment associated with + this Document. The memory for the Comment + is managed by the Document. + */ + XMLComment* NewComment( const char* comment ); + /** + Create a new Text associated with + this Document. The memory for the Text + is managed by the Document. + */ + XMLText* NewText( const char* text ); + /** + Create a new Declaration associated with + this Document. The memory for the object + is managed by the Document. + + If the 'text' param is null, the standard + declaration is used.: + @verbatim + + @endverbatim + */ + XMLDeclaration* NewDeclaration( const char* text=0 ); + /** + Create a new Unknown associated with + this Document. The memory forthe object + is managed by the Document. + */ + XMLUnknown* NewUnknown( const char* text ); + + /** + Delete a node associated with this document. + It will be unlinked from the DOM. + */ + void DeleteNode( XMLNode* node ) { + node->_parent->DeleteChild( node ); + } + + void SetError( XMLError error, const char* str1, const char* str2 ); + + /// Return true if there was an error parsing the document. + bool Error() const { + return _errorID != XML_NO_ERROR; + } + /// Return the errorID. + XMLError ErrorID() const { + return _errorID; + } + /// Return a possibly helpful diagnostic location or string. + const char* GetErrorStr1() const { + return _errorStr1; + } + /// Return a possibly helpful secondary diagnostic location or string. + const char* GetErrorStr2() const { + return _errorStr2; + } + /// If there is an error, print it to stdout. + void PrintError() const; + + // internal + char* Identify( char* p, XMLNode** node ); + + virtual XMLNode* ShallowClone( XMLDocument* /*document*/ ) const { + return 0; + } + virtual bool ShallowEqual( const XMLNode* /*compare*/ ) const { + return false; + } + +private: + XMLDocument( const XMLDocument& ); // not supported + void operator=( const XMLDocument& ); // not supported + void InitDocument(); + + bool _writeBOM; + bool _processEntities; + XMLError _errorID; + Whitespace _whitespace; + const char* _errorStr1; + const char* _errorStr2; + char* _charBuffer; + + MemPoolT< sizeof(XMLElement) > _elementPool; + MemPoolT< sizeof(XMLAttribute) > _attributePool; + MemPoolT< sizeof(XMLText) > _textPool; + MemPoolT< sizeof(XMLComment) > _commentPool; +}; + + +/** + A XMLHandle is a class that wraps a node pointer with null checks; this is + an incredibly useful thing. Note that XMLHandle is not part of the TinyXML + DOM structure. It is a separate utility class. + + Take an example: + @verbatim + + + + + + + @endverbatim + + Assuming you want the value of "attributeB" in the 2nd "Child" element, it's very + easy to write a *lot* of code that looks like: + + @verbatim + XMLElement* root = document.FirstChildElement( "Document" ); + if ( root ) + { + XMLElement* element = root->FirstChildElement( "Element" ); + if ( element ) + { + XMLElement* child = element->FirstChildElement( "Child" ); + if ( child ) + { + XMLElement* child2 = child->NextSiblingElement( "Child" ); + if ( child2 ) + { + // Finally do something useful. + @endverbatim + + And that doesn't even cover "else" cases. XMLHandle addresses the verbosity + of such code. A XMLHandle checks for null pointers so it is perfectly safe + and correct to use: + + @verbatim + XMLHandle docHandle( &document ); + XMLElement* child2 = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).FirstChild().NextSibling().ToElement(); + if ( child2 ) + { + // do something useful + @endverbatim + + Which is MUCH more concise and useful. + + It is also safe to copy handles - internally they are nothing more than node pointers. + @verbatim + XMLHandle handleCopy = handle; + @endverbatim + + See also XMLConstHandle, which is the same as XMLHandle, but operates on const objects. +*/ +class XMLHandle +{ +public: + /// Create a handle from any node (at any depth of the tree.) This can be a null pointer. + XMLHandle( XMLNode* node ) { + _node = node; + } + /// Create a handle from a node. + XMLHandle( XMLNode& node ) { + _node = &node; + } + /// Copy constructor + XMLHandle( const XMLHandle& ref ) { + _node = ref._node; + } + /// Assignment + XMLHandle& operator=( const XMLHandle& ref ) { + _node = ref._node; + return *this; + } + + /// Get the first child of this handle. + XMLHandle FirstChild() { + return XMLHandle( _node ? _node->FirstChild() : 0 ); + } + /// Get the first child element of this handle. + XMLHandle FirstChildElement( const char* value=0 ) { + return XMLHandle( _node ? _node->FirstChildElement( value ) : 0 ); + } + /// Get the last child of this handle. + XMLHandle LastChild() { + return XMLHandle( _node ? _node->LastChild() : 0 ); + } + /// Get the last child element of this handle. + XMLHandle LastChildElement( const char* _value=0 ) { + return XMLHandle( _node ? _node->LastChildElement( _value ) : 0 ); + } + /// Get the previous sibling of this handle. + XMLHandle PreviousSibling() { + return XMLHandle( _node ? _node->PreviousSibling() : 0 ); + } + /// Get the previous sibling element of this handle. + XMLHandle PreviousSiblingElement( const char* _value=0 ) { + return XMLHandle( _node ? _node->PreviousSiblingElement( _value ) : 0 ); + } + /// Get the next sibling of this handle. + XMLHandle NextSibling() { + return XMLHandle( _node ? _node->NextSibling() : 0 ); + } + /// Get the next sibling element of this handle. + XMLHandle NextSiblingElement( const char* _value=0 ) { + return XMLHandle( _node ? _node->NextSiblingElement( _value ) : 0 ); + } + + /// Safe cast to XMLNode. This can return null. + XMLNode* ToNode() { + return _node; + } + /// Safe cast to XMLElement. This can return null. + XMLElement* ToElement() { + return ( ( _node && _node->ToElement() ) ? _node->ToElement() : 0 ); + } + /// Safe cast to XMLText. This can return null. + XMLText* ToText() { + return ( ( _node && _node->ToText() ) ? _node->ToText() : 0 ); + } + /// Safe cast to XMLUnknown. This can return null. + XMLUnknown* ToUnknown() { + return ( ( _node && _node->ToUnknown() ) ? _node->ToUnknown() : 0 ); + } + /// Safe cast to XMLDeclaration. This can return null. + XMLDeclaration* ToDeclaration() { + return ( ( _node && _node->ToDeclaration() ) ? _node->ToDeclaration() : 0 ); + } + +private: + XMLNode* _node; +}; + + +/** + A variant of the XMLHandle class for working with const XMLNodes and Documents. It is the + same in all regards, except for the 'const' qualifiers. See XMLHandle for API. +*/ +class XMLConstHandle +{ +public: + XMLConstHandle( const XMLNode* node ) { + _node = node; + } + XMLConstHandle( const XMLNode& node ) { + _node = &node; + } + XMLConstHandle( const XMLConstHandle& ref ) { + _node = ref._node; + } + + XMLConstHandle& operator=( const XMLConstHandle& ref ) { + _node = ref._node; + return *this; + } + + const XMLConstHandle FirstChild() const { + return XMLConstHandle( _node ? _node->FirstChild() : 0 ); + } + const XMLConstHandle FirstChildElement( const char* value=0 ) const { + return XMLConstHandle( _node ? _node->FirstChildElement( value ) : 0 ); + } + const XMLConstHandle LastChild() const { + return XMLConstHandle( _node ? _node->LastChild() : 0 ); + } + const XMLConstHandle LastChildElement( const char* _value=0 ) const { + return XMLConstHandle( _node ? _node->LastChildElement( _value ) : 0 ); + } + const XMLConstHandle PreviousSibling() const { + return XMLConstHandle( _node ? _node->PreviousSibling() : 0 ); + } + const XMLConstHandle PreviousSiblingElement( const char* _value=0 ) const { + return XMLConstHandle( _node ? _node->PreviousSiblingElement( _value ) : 0 ); + } + const XMLConstHandle NextSibling() const { + return XMLConstHandle( _node ? _node->NextSibling() : 0 ); + } + const XMLConstHandle NextSiblingElement( const char* _value=0 ) const { + return XMLConstHandle( _node ? _node->NextSiblingElement( _value ) : 0 ); + } + + + const XMLNode* ToNode() const { + return _node; + } + const XMLElement* ToElement() const { + return ( ( _node && _node->ToElement() ) ? _node->ToElement() : 0 ); + } + const XMLText* ToText() const { + return ( ( _node && _node->ToText() ) ? _node->ToText() : 0 ); + } + const XMLUnknown* ToUnknown() const { + return ( ( _node && _node->ToUnknown() ) ? _node->ToUnknown() : 0 ); + } + const XMLDeclaration* ToDeclaration() const { + return ( ( _node && _node->ToDeclaration() ) ? _node->ToDeclaration() : 0 ); + } + +private: + const XMLNode* _node; +}; + + +/** + Printing functionality. The XMLPrinter gives you more + options than the XMLDocument::Print() method. + + It can: + -# Print to memory. + -# Print to a file you provide. + -# Print XML without a XMLDocument. + + Print to Memory + + @verbatim + XMLPrinter printer; + doc->Print( &printer ); + SomeFunction( printer.CStr() ); + @endverbatim + + Print to a File + + You provide the file pointer. + @verbatim + XMLPrinter printer( fp ); + doc.Print( &printer ); + @endverbatim + + Print without a XMLDocument + + When loading, an XML parser is very useful. However, sometimes + when saving, it just gets in the way. The code is often set up + for streaming, and constructing the DOM is just overhead. + + The Printer supports the streaming case. The following code + prints out a trivially simple XML file without ever creating + an XML document. + + @verbatim + XMLPrinter printer( fp ); + printer.OpenElement( "foo" ); + printer.PushAttribute( "foo", "bar" ); + printer.CloseElement(); + @endverbatim +*/ +class XMLPrinter : public XMLVisitor +{ +public: + /** Construct the printer. If the FILE* is specified, + this will print to the FILE. Else it will print + to memory, and the result is available in CStr(). + If 'compact' is set to true, then output is created + with only required whitespace and newlines. + */ + XMLPrinter( FILE* file=0, bool compact = false ); + ~XMLPrinter() {} + + /** If streaming, write the BOM and declaration. */ + void PushHeader( bool writeBOM, bool writeDeclaration ); + /** If streaming, start writing an element. + The element must be closed with CloseElement() + */ + void OpenElement( const char* name ); + /// If streaming, add an attribute to an open element. + void PushAttribute( const char* name, const char* value ); + void PushAttribute( const char* name, int value ); + void PushAttribute( const char* name, unsigned value ); + void PushAttribute( const char* name, bool value ); + void PushAttribute( const char* name, double value ); + /// If streaming, close the Element. + void CloseElement(); + + /// Add a text node. + void PushText( const char* text, bool cdata=false ); + /// Add a text node from an integer. + void PushText( int value ); + /// Add a text node from an unsigned. + void PushText( unsigned value ); + /// Add a text node from a bool. + void PushText( bool value ); + /// Add a text node from a float. + void PushText( float value ); + /// Add a text node from a double. + void PushText( double value ); + + /// Add a comment + void PushComment( const char* comment ); + + void PushDeclaration( const char* value ); + void PushUnknown( const char* value ); + + virtual bool VisitEnter( const XMLDocument& /*doc*/ ); + virtual bool VisitExit( const XMLDocument& /*doc*/ ) { + return true; + } + + virtual bool VisitEnter( const XMLElement& element, const XMLAttribute* attribute ); + virtual bool VisitExit( const XMLElement& element ); + + virtual bool Visit( const XMLText& text ); + virtual bool Visit( const XMLComment& comment ); + virtual bool Visit( const XMLDeclaration& declaration ); + virtual bool Visit( const XMLUnknown& unknown ); + + /** + If in print to memory mode, return a pointer to + the XML file in memory. + */ + const char* CStr() const { + return _buffer.Mem(); + } + /** + If in print to memory mode, return the size + of the XML file in memory. (Note the size returned + includes the terminating null.) + */ + int CStrSize() const { + return _buffer.Size(); + } + +private: + void SealElement(); + void PrintSpace( int depth ); + void PrintString( const char*, bool restrictedEntitySet ); // prints out, after detecting entities. + void Print( const char* format, ... ); + + bool _elementJustOpened; + bool _firstElement; + FILE* _fp; + int _depth; + int _textDepth; + bool _processEntities; + bool _compactMode; + + enum { + ENTITY_RANGE = 64, + BUF_SIZE = 200 + }; + bool _entityFlag[ENTITY_RANGE]; + bool _restrictedEntityFlag[ENTITY_RANGE]; + + DynArray< const char*, 10 > _stack; + DynArray< char, 20 > _buffer; +#ifdef _MSC_VER + DynArray< char, 20 > _accumulator; +#endif +}; + + +} // tinyxml2 + + +#endif // TINYXML2_INCLUDED diff -r 000000000000 -r 1b39a1b46319 ConfigureDebian.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ConfigureDebian.sh Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,49 @@ +#!/bin/bash + +############################################################################# +# +# Filename : ConfigurePermissionsAndPackages.sh +# Content : Linux file for installing prerequisite libraries and the +# permissions file for the USB HID device +# Created : 2013 +# Authors : Simon Hallam and Brant Lewis +# Copyright : Copyright 2013 OculusVR, Inc. All Rights Reserved +# Instruction : Ensure that the install.sh has execute permissions. +# Navigate to a command shell, enter: +# +# ./install.sh +# +# Enter the administrator password for sudo access. +# +# Notes : UBUNTU 13 USERS +# --------------- +# The OculusConfigUtil does not currently support Ubuntu 13 +# out of the box. If you see an error similar to this upon +# launching OculusConfigUtil: +# +# "error while loading shared libraries: libudev.so.0" +# +# Then please try the following solution, until we officially +# support Ubuntu 13: +# +# cd /lib/x86_64-linux-gnu/ +# sudo ln -sf libudev.so.1 libudev.so.0 +# +############################################################################# + +echo "Installing OculusVR Rift udev rules file..." +sudo cp ./LibOVR/90-oculus.rules /lib/udev/rules.d +echo "Installing libudev..." +sudo apt-get install libudev-dev +echo "Installing libxext..." +sudo apt-get install libxext-dev +echo "Installing mesa-common..." +sudo apt-get install mesa-common-dev +echo "Installing freeglut3..." +sudo apt-get install freeglut3-dev +echo "Installing Xrandr..." +sudo apt-get install libxrandr-dev +echo "Installing uuid" +sudo apt-get install uuid-dev +echo "Installation complete" + diff -r 000000000000 -r 1b39a1b46319 LINUX_README --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LINUX_README Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,57 @@ +WHAT SETUP IS REQUIRED? + + * Appropriate permissions for Oculus hidraw devices. See + LibOVR/90-oculus.rules and ConfigureDebian.sh. + * Use a multihead setup with one X screen spanning both displays (such as + NVidia TwinView) or place the rift on an independent X screen. + * Ensure oculusd is running when using the rift. + +BUILD INSTRUCTIONS + + After installing the appropriate packages issue 'make' in the root of + the SDK directory. This will build a release version of Oculus World Demo + (OWD). To generate debug symbols use 'make DEBUG=1'. + +HOW DO I RUN OCULUS WORLD DEMO (OWD)? + + Either run the binary directly from the output directory, or use 'make run'. + +SHOULD I ROTATE MY DEVICE'S SCREEN? + + Manual screen rotation is not recommended. If your window is fullscreen on a + rift device, set the ovrDistortionCap_LinuxDevFullscreen distortion cap to + have the SDK automatically rotate the distortion mesh on appropriate devices. + Be aware you will have to account for window size. You can use + OVR::SDKWindow::findDevScreenForHMD (Displays/OVR_Linux_SDKWindow.h) to + return the screen offset and dimensions necessary to size your Linux window. + See Samples/CommonSrc/Platform/Linux_Platform.cpp for an example. + +TWINVIEW + + You must sync to the Rift's display device for a smooth experience when using + TwinView. To consistently sync to the rift with TwinView setups, set the + __GL_SYNC_DISPLAY_DEVICE environment variable to the appropriate display + device before X starts. For example in your /etc/profile you could place the + following: + + export __GL_SYNC_DISPLAY_DEVICE="DFP-1" + + if your rift corresponds to DFP-1. + +STARTING THE TRACKING SERVICE AUTOMATICALLY + + Start the tracking service when a user is logged in using Xsession files. + +UBUNTU USERS + + There was a ubuntu-specific kernel bug which affected HID devices in 14.04. + If you are receiving feature report failures try upgrading your distro + (dist-upgrade). + +KNOWN ISSUES + + * OWD vsync initially disabled on Radeon proprietary. + * Frame loss on NVidia TwinView setups. Use an independent X screen for an + optimal experience. + * Mesa DK2 latency tester does not function properly in OWD. + diff -r 000000000000 -r 1b39a1b46319 LibOVR/90-oculus.rules --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/90-oculus.rules Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,2 @@ +# Oculus HID Sensor naming and permissioning +KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{idVendor}=="2833", MODE="0666" diff -r 000000000000 -r 1b39a1b46319 LibOVR/Include/OVR.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Include/OVR.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,36 @@ +/************************************************************************************ + +Filename : OVR.h +Content : The main public interface to Oculus for C++ Developers. + Includes C API and helper classes. + +Copyright : Copyright 2014 Oculus VR, LLC. All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +*************************************************************************************/ + +#ifndef OVR_h +#define OVR_h + +#include "OVR_Version.h" + +#include "../Src/Kernel/OVR_Math.h" + +#include "../Src/OVR_CAPI.h" + +#endif + diff -r 000000000000 -r 1b39a1b46319 LibOVR/Include/OVR_Kernel.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Include/OVR_Kernel.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,42 @@ +/************************************************************************************ + +Filename : OVRKernel.h +Content : This contains references to all OVR Kernel headers in Src folder. + Should be generated automatically based on PublicHeader tags. + +Copyright : Copyright 2014 Oculus VR, LLC. All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +*************************************************************************************/ + +#ifndef OVR_h +#define OVR_h + +#include "../Src/Kernel/OVR_Types.h" +#include "../Src/Kernel/OVR_Allocator.h" +#include "../Src/Kernel/OVR_RefCount.h" +#include "../Src/Kernel/OVR_Log.h" +#include "../Src/Kernel/OVR_Math.h" +#include "../Src/Kernel/OVR_System.h" +#include "../Src/Kernel/OVR_Nullptr.h" +#include "../Src/Kernel/OVR_String.h" +#include "../Src/Kernel/OVR_Array.h" +#include "../Src/Kernel/OVR_Timer.h" +#include "../Src/Kernel/OVR_SysFile.h" + +#endif + diff -r 000000000000 -r 1b39a1b46319 LibOVR/Include/OVR_Version.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Include/OVR_Version.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,35 @@ +/************************************************************************************ + +Filename : OVRVersion.h +Content : + +Copyright : Copyright 2014 Oculus VR, LLC. All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +*************************************************************************************/ + +#ifndef _OVR_VERSION_H +#define _OVR_VERSION_H + +#define OVR_MAJOR_VERSION 0 +#define OVR_MINOR_VERSION 4 +#define OVR_BUILD_VERSION 4 +#define OVR_VERSION_STRING "0.4.4" + +#define OVR_DK2_LATEST_FIRMWARE_MAJOR_VERSION 2 +#define OVR_DK2_LATEST_FIRMWARE_MINOR_VERSION 12 +#endif diff -r 000000000000 -r 1b39a1b46319 LibOVR/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Makefile Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,156 @@ +############################################################################# +# +# Filename : Makefile +# Content : Makefile for building Linux version of: libovr +# Created : 2014 +# Authors : Simon Hallam, Peter Giokaris, Chris Taylor +# Copyright : Copyright 2014 OculusVR, Inc. All Rights Reserved +# Instruction : The g++ compiler and standard lib packages need to be +# installed on the system. Navigate in a shell to the +# directory where this Makefile is located and enter: +# +# make builds the release version for the +# current architecture +# make clean delete intermediate release object files +# and the library file +# make DEBUG=1 builds the debug version for the current +# architecture +# make clean DEBUG=1 deletes intermediate debug object files +# and the library file +# +# Output : Relative to the directory this Makefile lives in, libraries +# are built at the following locations depending upon the +# architecture of the system you are running: +# +# ./Lib/Linux/Debug/i386/libovr.a +# ./Lib/Linux/Debug/x86_64/libovr.a +# ./Lib/Linux/Release/i386/libovr.a +# ./Lib/Linux/Release/x86_64/libovr.a +# +############################################################################# + +####### Include auxiliary makefiles in current directory +-include Makefile.*[^~] + +####### Detect system architecture + +SYSARCH = i386 +ifeq ($(shell uname -m),x86_64) +SYSARCH = x86_64 +endif + +####### Compiler, tools and options + +CXX = g++ +LINK = +DELETEFILE = rm -f + +####### Detect debug or release + +COMMONFLAGS = -Wall -Wextra -Werror -pipe -fPIC -msse2 + +DEBUG ?= 0 +CXXFLAGS ?= +ifeq ($(DEBUG), 1) + CXXFLAGS += $(COMMONFLAGS) -DDEBUG -DOVR_BUILD_DEBUG -g + RELEASETYPE ?= Debug +else + CXXFLAGS += $(COMMONFLAGS) -O2 -fno-strict-aliasing + RELEASETYPE ?= Release +endif + +####### Paths + +LIBOVRPATH = . +3RDPARTYPATH = ../3rdParty +INCPATH = -I. -I.. -I$(LIBOVRPATH)/Include -I$(LIBOVRPATH)/Src +OBJPATH = ./Obj/Linux/$(RELEASETYPE)/$(SYSARCH) +PREFIX = /usr/local + +####### Files + +TARGET_DIR = ./Lib/Linux/$(RELEASETYPE)/$(SYSARCH) +STATIC_NAME = libovr.a +STATIC_TARGET = $(TARGET_DIR)/$(STATIC_NAME) +LIBOVR_INST_HDR = Src/OVR_CAPI.h Src/OVR_CAPI_Keys.h Src/OVR_CAPI_GL.h + +####### Rules + +all: $(STATIC_TARGET) + +OTHER_SOURCE = $(3RDPARTYPATH)/EDID/edid.cpp \ + $(3RDPARTYPATH)/TinyXml/tinyxml2.cpp + +OTHER_OBJECTS = $(OTHER_SOURCE:.cpp=.o) + +LIBOVR_SOURCE = $(LIBOVRPATH)/Src/Net/OVR_BitStream.cpp \ + $(LIBOVRPATH)/Src/Net/OVR_Unix_Socket.cpp \ + $(LIBOVRPATH)/Src/Net/OVR_NetworkPlugin.cpp \ + $(LIBOVRPATH)/Src/Net/OVR_PacketizedTCPSocket.cpp \ + $(LIBOVRPATH)/Src/Net/OVR_RPC1.cpp \ + $(LIBOVRPATH)/Src/Net/OVR_Session.cpp \ + $(LIBOVRPATH)/Src/Net/OVR_Socket.cpp \ + $(LIBOVRPATH)/Src/Service/Service_NetClient.cpp \ + $(LIBOVRPATH)/Src/Service/Service_NetSessionCommon.cpp \ + $(LIBOVRPATH)/Src/Tracking/Tracking_SensorStateReader.cpp \ + $(LIBOVRPATH)/Src/Displays/OVR_Display.cpp \ + $(LIBOVRPATH)/Src/Displays/OVR_Linux_Display.cpp \ + $(LIBOVRPATH)/Src/Displays/OVR_Linux_SDKWindow.cpp \ + $(LIBOVRPATH)/Src/CAPI/CAPI_DistortionRenderer.cpp \ + $(LIBOVRPATH)/Src/CAPI/CAPI_HSWDisplay.cpp \ + $(LIBOVRPATH)/Src/CAPI/CAPI_FrameTimeManager.cpp \ + $(LIBOVRPATH)/Src/CAPI/CAPI_HMDRenderState.cpp \ + $(LIBOVRPATH)/Src/CAPI/CAPI_HMDState.cpp \ + $(LIBOVRPATH)/Src/CAPI/CAPI_LatencyStatistics.cpp \ + $(LIBOVRPATH)/Src/CAPI/GL/CAPI_GL_DistortionRenderer.cpp \ + $(LIBOVRPATH)/Src/CAPI/GL/CAPI_GL_HSWDisplay.cpp \ + $(LIBOVRPATH)/Src/CAPI/GL/CAPI_GL_Util.cpp \ + $(LIBOVRPATH)/Src/CAPI/GL/CAPI_GLE.cpp \ + $(LIBOVRPATH)/Src/Kernel/OVR_Alg.cpp \ + $(LIBOVRPATH)/Src/Kernel/OVR_Allocator.cpp \ + $(LIBOVRPATH)/Src/Kernel/OVR_Atomic.cpp \ + $(LIBOVRPATH)/Src/Kernel/OVR_CRC32.cpp \ + $(LIBOVRPATH)/Src/Kernel/OVR_DebugHelp.cpp \ + $(LIBOVRPATH)/Src/Kernel/OVR_File.cpp \ + $(LIBOVRPATH)/Src/Kernel/OVR_FileFILE.cpp \ + $(LIBOVRPATH)/Src/Kernel/OVR_Lockless.cpp \ + $(LIBOVRPATH)/Src/Kernel/OVR_Log.cpp \ + $(LIBOVRPATH)/Src/Kernel/OVR_Math.cpp \ + $(LIBOVRPATH)/Src/Kernel/OVR_RefCount.cpp \ + $(LIBOVRPATH)/Src/Kernel/OVR_SharedMemory.cpp \ + $(LIBOVRPATH)/Src/Kernel/OVR_Std.cpp \ + $(LIBOVRPATH)/Src/Kernel/OVR_String.cpp \ + $(LIBOVRPATH)/Src/Kernel/OVR_String_FormatUtil.cpp \ + $(LIBOVRPATH)/Src/Kernel/OVR_String_PathUtil.cpp \ + $(LIBOVRPATH)/Src/Kernel/OVR_SysFile.cpp \ + $(LIBOVRPATH)/Src/Kernel/OVR_System.cpp \ + $(LIBOVRPATH)/Src/Kernel/OVR_ThreadsPthread.cpp \ + $(LIBOVRPATH)/Src/Kernel/OVR_ThreadCommandQueue.cpp \ + $(LIBOVRPATH)/Src/Kernel/OVR_Timer.cpp \ + $(LIBOVRPATH)/Src/Kernel/OVR_UTF8Util.cpp \ + $(LIBOVRPATH)/Src/Util/Util_Interface.cpp \ + $(LIBOVRPATH)/Src/Util/Util_LatencyTest2Reader.cpp \ + $(LIBOVRPATH)/Src/Util/Util_Render_Stereo.cpp \ + $(LIBOVRPATH)/Src/Util/Util_SystemInfo.cpp \ + $(LIBOVRPATH)/Src/Util/Util_SystemGUI.cpp \ + $(LIBOVRPATH)/Src/OVR_CAPI.cpp \ + $(LIBOVRPATH)/Src/OVR_SerialFormat.cpp \ + $(LIBOVRPATH)/Src/OVR_JSON.cpp \ + $(LIBOVRPATH)/Src/OVR_Profile.cpp \ + $(LIBOVRPATH)/Src/OVR_Stereo.cpp + +LIBOVR_OBJECTS = $(patsubst $(LIBOVRPATH)%.cpp,$(OBJPATH)%.o,$(LIBOVR_SOURCE)) + +OBJECTS = $(OTHER_OBJECTS) $(LIBOVR_OBJECTS) + +$(OBJPATH)/%.o: %.cpp + @mkdir -p $(dir $@) + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +$(STATIC_TARGET): $(OBJECTS) + @mkdir -p $(@D) + ar rvs $(STATIC_TARGET) $(OBJECTS) + +clean: + -$(DELETEFILE) $(OBJECTS) + -$(DELETEFILE) $(STATIC_TARGET) diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/CAPI/CAPI_DistortionRenderer.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/CAPI/CAPI_DistortionRenderer.cpp Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,157 @@ +/************************************************************************************ + +Filename : CAPI_DistortionRenderer.cpp +Content : Combines all of the rendering state associated with the HMD +Created : February 2, 2014 +Authors : Michael Antonov + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#include "CAPI_DistortionRenderer.h" + +#if defined (OVR_OS_WIN32) + +// TBD: Move to separate config file that handles back-ends. +#define OVR_D3D_VERSION 11 +#include "D3D1X/CAPI_D3D1X_DistortionRenderer.h" +#undef OVR_D3D_VERSION + +#define OVR_D3D_VERSION 10 +#include "D3D1X/CAPI_D3D1X_DistortionRenderer.h" +#undef OVR_D3D_VERSION + +#define OVR_D3D_VERSION 9 +#include "D3D9/CAPI_D3D9_DistortionRenderer.h" +#undef OVR_D3D_VERSION + +#endif + +#include "GL/CAPI_GL_DistortionRenderer.h" + +namespace OVR { namespace CAPI { + +//------------------------------------------------------------------------------------- +// ***** DistortionRenderer + +// TBD: Move to separate config file that handles back-ends. + +DistortionRenderer::CreateFunc DistortionRenderer::APICreateRegistry[ovrRenderAPI_Count] = +{ + 0, // None + &GL::DistortionRenderer::Create, + 0, // Android_GLES +#if defined (OVR_OS_WIN32) + &D3D9::DistortionRenderer::Create, + &D3D10::DistortionRenderer::Create, + &D3D11::DistortionRenderer::Create +#else + 0, + 0, + 0 +#endif +}; + +void DistortionRenderer::SetLatencyTestColor(unsigned char* color) +{ + if(color) + { + LatencyTestDrawColor[0] = color[0]; + LatencyTestDrawColor[1] = color[1]; + LatencyTestDrawColor[2] = color[2]; + } + + LatencyTestActive = color != NULL; +} + +void DistortionRenderer::SetLatencyTest2Color(unsigned char* color) +{ + if(color) + { + LatencyTest2DrawColor[0] = color[0]; + LatencyTest2DrawColor[1] = color[1]; + LatencyTest2DrawColor[2] = color[2]; + } + + LatencyTest2Active = color != NULL; +} + +void DistortionRenderer::GetOverdriveScales(float& outRiseScale, float& outFallScale) +{ + outRiseScale = 0.1f; + outFallScale = 0.05f; // falling issues are hardly visible +} + +double DistortionRenderer::WaitTillTime(double absTime) +{ + double initialTime = ovr_GetTimeInSeconds(); + if (initialTime >= absTime) + return 0.0; + + double newTime = initialTime; + + while (newTime < absTime) + { +// TODO: Needs further testing before enabling it on all Windows configs +#if 0 //def OVR_OS_WIN32 + double remainingWaitTime = absTime - newTime; + + // don't yield if <2ms + if(remainingWaitTime > 0.002) + { + // round down wait time to closest 1 ms + int roundedWaitTime = (remainingWaitTime * 1000); + + waitableTimerInterval.QuadPart = -10000LL; // 10000 * 100 ns = 1 ms + waitableTimerInterval.QuadPart *= roundedWaitTime; + + SetWaitableTimer(timer, &waitableTimerInterval, 0, NULL, NULL, TRUE); + DWORD waitResult = WaitForSingleObject(timer, roundedWaitTime + 3); // give 3 ms extra time + OVR_UNUSED(waitResult); + +#ifdef OVR_BUILD_DEBUG + double sleptTime = ovr_GetTimeInSeconds() - newTime; + // Make sure we didn't sleep too long and it is reliable, otherwise we might miss v-sync causing a stutter + if (sleptTime > (roundedWaitTime + 2) * 0.001) + { + OVR_DEBUG_LOG_TEXT( + ("[DistortionRenderer::WaitTillTime] Sleep interval too long: %f\n", sleptTime)); + } + else + { + OVR_ASSERT(WAIT_OBJECT_0 == waitResult); + } +#endif + } + else +#endif + { + for (int j = 0; j < 5; j++) + OVR_PROCESSOR_PAUSE(); + } + + newTime = ovr_GetTimeInSeconds(); + } + + // How long we waited + return newTime - initialTime; +} + +}} // namespace OVR::CAPI + diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/CAPI/CAPI_DistortionRenderer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/CAPI/CAPI_DistortionRenderer.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,167 @@ +/************************************************************************************ + +Filename : CAPI_DistortionRenderer.h +Content : Abstract interface for platform-specific rendering of distortion +Created : February 2, 2014 +Authors : Michael Antonov + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#ifndef OVR_CAPI_DistortionRenderer_h +#define OVR_CAPI_DistortionRenderer_h + +#include "CAPI_HMDRenderState.h" +#include "CAPI_FrameTimeManager.h" + +typedef void (*PostDistortionCallback)(void* pRenderContext); + +namespace OVR { namespace CAPI { + +//------------------------------------------------------------------------------------- +// ***** CAPI::DistortionRenderer + +// DistortionRenderer implements rendering of distortion and other overlay elements +// in platform-independent way. +// Platform-specific renderer back ends for CAPI are derived from this class. + +class DistortionRenderer : public RefCountBase +{ + // Quiet assignment compiler warning. + void operator = (const DistortionRenderer&) { } +public: + + DistortionRenderer(ovrRenderAPIType api, ovrHmd hmd, + FrameTimeManager& timeManager, + const HMDRenderState& renderState) : + LastUsedOverdriveTextureIndex(-1), + LatencyTestActive(false), + LatencyTest2Active(false), + RenderAPI(api), + HMD(hmd), + TimeManager(timeManager), + RState(renderState), + GfxState(), + RegisteredPostDistortionCallback(NULL) + { +#ifdef OVR_OS_WIN32 + timer = CreateWaitableTimer(NULL, TRUE, NULL); + OVR_ASSERT(timer != NULL); +#endif + } + virtual ~DistortionRenderer() + { + } + + + // Configures the Renderer based on externally passed API settings. Must be + // called before use. + // Under D3D, apiConfig includes D3D Device pointer, back buffer and other + // needed structures. + virtual bool Initialize(const ovrRenderAPIConfig* apiConfig) = 0; + + // Submits one eye texture for rendering. This is in the separate method to + // allow "submit as you render" scenarios on horizontal screens where one + // eye can be scanned out before the other. + virtual void SubmitEye(int eyeId, const ovrTexture* eyeTexture) = 0; + + // Finish the frame, optionally swapping buffers. + // Many implementations may actually apply the distortion here. + virtual void EndFrame(bool swapBuffers) = 0; + + void RegisterPostDistortionCallback(PostDistortionCallback postDistortionCallback) + { + RegisteredPostDistortionCallback = postDistortionCallback; + } + + // Stores the current graphics pipeline state so it can be restored later. + void SaveGraphicsState() { if (GfxState && !(RState.DistortionCaps & ovrDistortionCap_NoRestore)) GfxState->Save(); } + + // Restores the saved graphics pipeline state. + void RestoreGraphicsState() { if (GfxState && !(RState.DistortionCaps & ovrDistortionCap_NoRestore)) GfxState->Restore(); } + + // *** Creation Factory logic + + ovrRenderAPIType GetRenderAPI() const { return RenderAPI; } + + // Creation function for this interface, registered for API. + typedef DistortionRenderer* (*CreateFunc)(ovrHmd hmd, + FrameTimeManager &timeManager, + const HMDRenderState& renderState); + + static CreateFunc APICreateRegistry[ovrRenderAPI_Count]; + + // Color is expected to be 3 byte RGB + void SetLatencyTestColor(unsigned char* color); + void SetLatencyTest2Color(unsigned char* color); + +protected: + // Used for pixel luminance overdrive on DK2 displays + // A copy of back buffer images will be ping ponged + // TODO: figure out 0 dynamically based on DK2 latency? + static const int NumOverdriveTextures = 2; + int LastUsedOverdriveTextureIndex; + + bool LatencyTestActive; + unsigned char LatencyTestDrawColor[3]; + bool LatencyTest2Active; + unsigned char LatencyTest2DrawColor[3]; + + bool IsOverdriveActive() + { + // doesn't make sense to use overdrive when vsync is disabled as we cannot guarantee + // when the rendered frame will be displayed + return LastUsedOverdriveTextureIndex >= 0 && + !((RState.EnabledHmdCaps & ovrHmdCap_NoVSync) > 0) && + (RState.DistortionCaps & ovrDistortionCap_Chromatic); + } + + void GetOverdriveScales(float& outRiseScale, float& outFallScale); + + double WaitTillTime(double absTime); + +#ifdef OVR_OS_WIN32 + HANDLE timer; + LARGE_INTEGER waitableTimerInterval; +#endif + + class GraphicsState : public RefCountBase + { + public: + GraphicsState() : IsValid(false) {} + virtual ~GraphicsState() {} + virtual void Save() = 0; + virtual void Restore() = 0; + + protected: + bool IsValid; + }; + + const ovrRenderAPIType RenderAPI; + const ovrHmd HMD; + FrameTimeManager& TimeManager; + const HMDRenderState& RState; + Ptr GfxState; + PostDistortionCallback RegisteredPostDistortionCallback; +}; + +}} // namespace OVR::CAPI + + +#endif // OVR_CAPI_DistortionRenderer_h diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/CAPI/CAPI_FrameTimeManager.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/CAPI/CAPI_FrameTimeManager.cpp Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,946 @@ +/************************************************************************************ + +Filename : CAPI_FrameTimeManager.cpp +Content : Manage frame timing and pose prediction for rendering +Created : November 30, 2013 +Authors : Volga Aksoy, Michael Antonov + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#include "CAPI_FrameTimeManager.h" + +#include "../Kernel/OVR_Log.h" + +namespace OVR { namespace CAPI { + + +//------------------------------------------------------------------------------------- +// ***** FrameLatencyTracker + + +FrameLatencyTracker::FrameLatencyTracker() +{ + Reset(); +} + + +void FrameLatencyTracker::Reset() +{ + TrackerEnabled = true; + WaitMode = SampleWait_Zeroes; + MatchCount = 0; + memset(FrameEndTimes, 0, sizeof(FrameEndTimes)); + FrameIndex = 0; + //FrameDeltas + RenderLatencySeconds = 0.0; + TimewarpLatencySeconds = 0.0; + LatencyRecordTime = 0.0; + + FrameDeltas.Clear(); +} + + +unsigned char FrameLatencyTracker::GetNextDrawColor() +{ + if (!TrackerEnabled || (WaitMode == SampleWait_Zeroes) || + (FrameIndex >= FramesTracked)) + { + return (unsigned char)Util::FrameTimeRecord::ReadbackIndexToColor(0); + } + + OVR_ASSERT(FrameIndex < FramesTracked); + return (unsigned char)Util::FrameTimeRecord::ReadbackIndexToColor(FrameIndex+1); +} + + +void FrameLatencyTracker::SaveDrawColor(unsigned char drawColor, double endFrameTime, + double renderIMUTime, double timewarpIMUTime ) +{ + if (!TrackerEnabled || (WaitMode == SampleWait_Zeroes)) + return; + + if (FrameIndex < FramesTracked) + { + OVR_ASSERT(Util::FrameTimeRecord::ReadbackIndexToColor(FrameIndex+1) == drawColor); + OVR_UNUSED(drawColor); + + // saves {color, endFrame time} + FrameEndTimes[FrameIndex].ReadbackIndex = FrameIndex + 1; + FrameEndTimes[FrameIndex].TimeSeconds = endFrameTime; + FrameEndTimes[FrameIndex].RenderIMUTimeSeconds = renderIMUTime; + FrameEndTimes[FrameIndex].TimewarpIMUTimeSeconds= timewarpIMUTime; + FrameEndTimes[FrameIndex].MatchedRecord = false; + FrameIndex++; + } + else + { + // If the request was outstanding for too long, switch to zero mode to restart. + if (endFrameTime > (FrameEndTimes[FrameIndex-1].TimeSeconds + 0.15)) + { + if (MatchCount == 0) + { + // If nothing was matched, we have no latency reading. + RenderLatencySeconds = 0.0; + TimewarpLatencySeconds = 0.0; + } + + WaitMode = SampleWait_Zeroes; + MatchCount = 0; + FrameIndex = 0; + } + } +} + + +void FrameLatencyTracker::MatchRecord(const Util::FrameTimeRecordSet &r) +{ + if (!TrackerEnabled) + return; + + if (WaitMode == SampleWait_Zeroes) + { + // Do we have all zeros? + if (r.IsAllZeroes()) + { + OVR_ASSERT(FrameIndex == 0); + WaitMode = SampleWait_Match; + MatchCount = 0; + } + return; + } + + // We are in Match Mode. Wait until all colors are matched or timeout, + // at which point we go back to zeros. + + for (int i = 0; i < FrameIndex; i++) + { + int recordIndex = 0; + int consecutiveMatch = 0; + + OVR_ASSERT(FrameEndTimes[i].ReadbackIndex != 0); + + if (r.FindReadbackIndex(&recordIndex, FrameEndTimes[i].ReadbackIndex)) + { + // Advance forward to see that we have several more matches. + int ri = recordIndex + 1; + int j = i + 1; + + consecutiveMatch++; + + for (; (j < FrameIndex) && (ri < Util::FrameTimeRecordSet::RecordCount); j++, ri++) + { + if (r[ri].ReadbackIndex != FrameEndTimes[j].ReadbackIndex) + break; + consecutiveMatch++; + } + + // Match at least 2 items in the row, to avoid accidentally matching color. + if (consecutiveMatch > 1) + { + // Record latency values for all but last samples. Keep last 2 samples + // for the future to simplify matching. + for (int q = 0; q < consecutiveMatch; q++) + { + const Util::FrameTimeRecord &scanoutFrame = r[recordIndex+q]; + FrameTimeRecordEx &renderFrame = FrameEndTimes[i+q]; + + if (!renderFrame.MatchedRecord) + { + double deltaSeconds = scanoutFrame.TimeSeconds - renderFrame.TimeSeconds; + if (deltaSeconds > 0.0) + { + FrameDeltas.AddTimeDelta(deltaSeconds); + + // FIRMWARE HACK: don't take new readings if they're 10ms higher than previous reading + // but only do that for 1 second, after that accept it regardless of the timing difference + double newRenderLatency = scanoutFrame.TimeSeconds - renderFrame.RenderIMUTimeSeconds; + if( newRenderLatency < RenderLatencySeconds + 0.01 || + scanoutFrame.TimeSeconds > LatencyRecordTime + 1.0) + { + LatencyRecordTime = scanoutFrame.TimeSeconds; + RenderLatencySeconds = scanoutFrame.TimeSeconds - renderFrame.RenderIMUTimeSeconds; + TimewarpLatencySeconds = (renderFrame.TimewarpIMUTimeSeconds == 0.0) ? 0.0 : + (scanoutFrame.TimeSeconds - renderFrame.TimewarpIMUTimeSeconds); + } + } + + renderFrame.MatchedRecord = true; + MatchCount++; + } + } + + // Exit for. + break; + } + } + } // for ( i => FrameIndex ) + + + // If we matched all frames, start over. + if (MatchCount == FramesTracked) + { + WaitMode = SampleWait_Zeroes; + MatchCount = 0; + FrameIndex = 0; + } +} + +bool FrameLatencyTracker::IsLatencyTimingAvailable() +{ + return ovr_GetTimeInSeconds() < (LatencyRecordTime + 2.0); +} + +void FrameLatencyTracker::GetLatencyTimings(float& latencyRender, float& latencyTimewarp, float& latencyPostPresent) +{ + if (!IsLatencyTimingAvailable()) + { + latencyRender = 0.0f; + latencyTimewarp = 0.0f; + latencyPostPresent = 0.0f; + } + else + { + latencyRender = (float)RenderLatencySeconds; + latencyTimewarp = (float)TimewarpLatencySeconds; + latencyPostPresent = (float)FrameDeltas.GetMedianTimeDelta(); + } +} + + +//------------------------------------------------------------------------------------- +// ***** FrameTimeManager + +FrameTimeManager::FrameTimeManager(bool vsyncEnabled) : + RenderInfo(), + FrameTimeDeltas(), + DistortionRenderTimes(), + ScreenLatencyTracker(), + VsyncEnabled(vsyncEnabled), + DynamicPrediction(true), + SdkRender(false), + //DirectToRift(false), Initialized below. + //VSyncToScanoutDelay(0.0), Initialized below. + //NoVSyncToScanoutDelay(0.0), Initialized below. + ScreenSwitchingDelay(0.0), + FrameTiming(), + LocklessTiming(), + RenderIMUTimeSeconds(0.0), + TimewarpIMUTimeSeconds(0.0) +{ + // If driver is in use, + DirectToRift = !Display::InCompatibilityMode(false); + if (DirectToRift) + { + // The latest driver provides a post-present vsync-to-scan-out delay + // that is roughly zero. The latency tester will provide real numbers + // but when it is unavailable for some reason, we should default to + // an expected value. + VSyncToScanoutDelay = 0.0001f; + } + else + { + // HACK: SyncToScanoutDelay observed close to 1 frame in video cards. + // Overwritten by dynamic latency measurement on DK2. + VSyncToScanoutDelay = 0.013f; + } + NoVSyncToScanoutDelay = 0.004f; +} + +void FrameTimeManager::Init(HmdRenderInfo& renderInfo) +{ + // Set up prediction distances. + // With-Vsync timings. + RenderInfo = renderInfo; + + ScreenSwitchingDelay = RenderInfo.Shutter.PixelSettleTime * 0.5f + + RenderInfo.Shutter.PixelPersistence * 0.5f; +} + +void FrameTimeManager::ResetFrameTiming(unsigned frameIndex, + bool dynamicPrediction, + bool sdkRender) +{ + DynamicPrediction = dynamicPrediction; + SdkRender = sdkRender; + + FrameTimeDeltas.Clear(); + DistortionRenderTimes.Clear(); + ScreenLatencyTracker.Reset(); + //Revisit dynamic pre-Timewarp delay adjustment logic + //TimewarpAdjuster.Reset(); + + FrameTiming.FrameIndex = frameIndex; + FrameTiming.NextFrameTime = 0.0; + FrameTiming.ThisFrameTime = 0.0; + FrameTiming.Inputs.FrameDelta = calcFrameDelta(); + // This one is particularly critical, and has been missed in the past because + // this init function wasn't called for app-rendered. + FrameTiming.Inputs.ScreenDelay = calcScreenDelay(); + FrameTiming.Inputs.TimewarpWaitDelta = 0.0f; + + LocklessTiming.SetState(FrameTiming); +} + + +double FrameTimeManager::calcFrameDelta() const +{ + // Timing difference between frame is tracked by FrameTimeDeltas, or + // is a hard-coded value of 1/FrameRate. + double frameDelta; + + if (!VsyncEnabled) + { + frameDelta = 0.0; + } + else if (FrameTimeDeltas.GetCount() > 3) + { + frameDelta = FrameTimeDeltas.GetMedianTimeDelta(); + if (frameDelta > (RenderInfo.Shutter.VsyncToNextVsync + 0.001)) + frameDelta = RenderInfo.Shutter.VsyncToNextVsync; + } + else + { + frameDelta = RenderInfo.Shutter.VsyncToNextVsync; + } + + return frameDelta; +} + + +double FrameTimeManager::calcScreenDelay() const +{ + double screenDelay = ScreenSwitchingDelay; + double measuredVSyncToScanout; + + // Use real-time DK2 latency tester HW for prediction if its is working. + // Do sanity check under 60 ms + if (!VsyncEnabled) + { + screenDelay += NoVSyncToScanoutDelay; + } + else if ( DynamicPrediction && + (ScreenLatencyTracker.FrameDeltas.GetCount() > 3) && + (measuredVSyncToScanout = ScreenLatencyTracker.FrameDeltas.GetMedianTimeDelta(), + (measuredVSyncToScanout > -0.0001) && (measuredVSyncToScanout < 0.06)) ) + { + screenDelay += measuredVSyncToScanout; + } + else + { + screenDelay += VSyncToScanoutDelay; + } + + return screenDelay; +} + +double FrameTimeManager::calcTimewarpWaitDelta() const +{ + // If timewarp timing hasn't been calculated, we should wait. + if (!VsyncEnabled) + return 0.0; + + if (SdkRender) + { + if (NeedDistortionTimeMeasurement()) + return 0.0; + return -(DistortionRenderTimes.GetMedianTimeDelta() + 0.0035); + + //Revisit dynamic pre-Timewarp delay adjustment logic + /*return -(DistortionRenderTimes.GetMedianTimeDelta() + 0.002 + + TimewarpAdjuster.GetDelayReduction());*/ + } + + // Just a hard-coded "high" value for game-drawn code. + // TBD: Just return 0 and let users calculate this themselves? + return -0.004; + + //Revisit dynamic pre-Timewarp delay adjustment logic + //return -(0.003 + TimewarpAdjuster.GetDelayReduction()); +} + +//Revisit dynamic pre-Timewarp delay adjustment logic +/* +void FrameTimeManager::updateTimewarpTiming() +{ + // If timewarp timing changes based on this sample, update it. + double newTimewarpWaitDelta = calcTimewarpWaitDelta(); + if (newTimewarpWaitDelta != FrameTiming.Inputs.TimewarpWaitDelta) + { + FrameTiming.Inputs.TimewarpWaitDelta = newTimewarpWaitDelta; + LocklessTiming.SetState(FrameTiming); + } +} +*/ + +void FrameTimeManager::Timing::InitTimingFromInputs(const FrameTimeManager::TimingInputs& inputs, + HmdShutterTypeEnum shutterType, + double thisFrameTime, unsigned int frameIndex) +{ + // ThisFrameTime comes from the end of last frame, unless it it changed. + double nextFrameBase; + double frameDelta = inputs.FrameDelta; + + FrameIndex = frameIndex; + + ThisFrameTime = thisFrameTime; + NextFrameTime = ThisFrameTime + frameDelta; + nextFrameBase = NextFrameTime + inputs.ScreenDelay; + MidpointTime = nextFrameBase + frameDelta * 0.5; + TimewarpPointTime = (inputs.TimewarpWaitDelta == 0.0) ? + 0.0 : (NextFrameTime + inputs.TimewarpWaitDelta); + + // Calculate absolute points in time when eye rendering or corresponding time-warp + // screen edges will become visible. + // This only matters with VSync. + switch(shutterType) + { + case HmdShutter_RollingTopToBottom: + EyeRenderTimes[0] = MidpointTime; + EyeRenderTimes[1] = MidpointTime; + TimeWarpStartEndTimes[0][0] = nextFrameBase; + TimeWarpStartEndTimes[0][1] = nextFrameBase + frameDelta; + TimeWarpStartEndTimes[1][0] = nextFrameBase; + TimeWarpStartEndTimes[1][1] = nextFrameBase + frameDelta; + break; + case HmdShutter_RollingLeftToRight: + EyeRenderTimes[0] = nextFrameBase + frameDelta * 0.25; + EyeRenderTimes[1] = nextFrameBase + frameDelta * 0.75; + + /* + // TBD: MA: It is probably better if mesh sets it up per-eye. + // Would apply if screen is 0 -> 1 for each eye mesh + TimeWarpStartEndTimes[0][0] = nextFrameBase; + TimeWarpStartEndTimes[0][1] = MidpointTime; + TimeWarpStartEndTimes[1][0] = MidpointTime; + TimeWarpStartEndTimes[1][1] = nextFrameBase + frameDelta; + */ + + // Mesh is set up to vary from Edge of scree 0 -> 1 across both eyes + TimeWarpStartEndTimes[0][0] = nextFrameBase; + TimeWarpStartEndTimes[0][1] = nextFrameBase + frameDelta; + TimeWarpStartEndTimes[1][0] = nextFrameBase; + TimeWarpStartEndTimes[1][1] = nextFrameBase + frameDelta; + + break; + case HmdShutter_RollingRightToLeft: + + EyeRenderTimes[0] = nextFrameBase + frameDelta * 0.75; + EyeRenderTimes[1] = nextFrameBase + frameDelta * 0.25; + + // This is *Correct* with Tom's distortion mesh organization. + TimeWarpStartEndTimes[0][0] = nextFrameBase ; + TimeWarpStartEndTimes[0][1] = nextFrameBase + frameDelta; + TimeWarpStartEndTimes[1][0] = nextFrameBase ; + TimeWarpStartEndTimes[1][1] = nextFrameBase + frameDelta; + break; + case HmdShutter_Global: + // TBD + EyeRenderTimes[0] = MidpointTime; + EyeRenderTimes[1] = MidpointTime; + TimeWarpStartEndTimes[0][0] = MidpointTime; + TimeWarpStartEndTimes[0][1] = MidpointTime; + TimeWarpStartEndTimes[1][0] = MidpointTime; + TimeWarpStartEndTimes[1][1] = MidpointTime; + break; + default: + break; + } +} + + +double FrameTimeManager::BeginFrame(unsigned frameIndex) +{ + RenderIMUTimeSeconds = 0.0; + TimewarpIMUTimeSeconds = 0.0; + + // TPH - putting an assert so this doesn't remain a hidden problem. + OVR_ASSERT(FrameTiming.Inputs.ScreenDelay != 0); + + // ThisFrameTime comes from the end of last frame, unless it it changed. + double thisFrameTime = (FrameTiming.NextFrameTime != 0.0) ? + FrameTiming.NextFrameTime : ovr_GetTimeInSeconds(); + + // We are starting to process a new frame... + FrameTiming.InitTimingFromInputs(FrameTiming.Inputs, RenderInfo.Shutter.Type, + thisFrameTime, frameIndex); + + return FrameTiming.ThisFrameTime; +} + + +void FrameTimeManager::EndFrame() +{ + // Record timing since last frame; must be called after Present & sync. + FrameTiming.NextFrameTime = ovr_GetTimeInSeconds(); + if (FrameTiming.ThisFrameTime > 0.0) + { + //Revisit dynamic pre-Timewarp delay adjustment logic + /* + double actualFrameDelta = FrameTiming.NextFrameTime - FrameTiming.ThisFrameTime; + + if (VsyncEnabled) + TimewarpAdjuster.UpdateTimewarpWaitIfSkippedFrames(this, actualFrameDelta, + FrameTiming.NextFrameTime); + + FrameTimeDeltas.AddTimeDelta(actualFrameDelta); + */ + FrameTimeDeltas.AddTimeDelta(FrameTiming.NextFrameTime - FrameTiming.ThisFrameTime); + FrameTiming.Inputs.FrameDelta = calcFrameDelta(); + } + + // Write to Lock-less + LocklessTiming.SetState(FrameTiming); +} + +// Thread-safe function to query timing for a future frame + +FrameTimeManager::Timing FrameTimeManager::GetFrameTiming(unsigned frameIndex) +{ + Timing frameTiming = LocklessTiming.GetState(); + + if (frameTiming.ThisFrameTime == 0.0) + { + // If timing hasn't been initialized, starting based on "now" is the best guess. + frameTiming.InitTimingFromInputs(frameTiming.Inputs, RenderInfo.Shutter.Type, + ovr_GetTimeInSeconds(), frameIndex); + } + + else if (frameIndex > frameTiming.FrameIndex) + { + unsigned frameDelta = frameIndex - frameTiming.FrameIndex; + double thisFrameTime = frameTiming.NextFrameTime + + double(frameDelta-1) * frameTiming.Inputs.FrameDelta; + // Don't run away too far into the future beyond rendering. + OVR_DEBUG_LOG_COND(frameDelta >= 6, ("GetFrameTiming is 6 or more frames in future beyond rendering!")); + + frameTiming.InitTimingFromInputs(frameTiming.Inputs, RenderInfo.Shutter.Type, + thisFrameTime, frameIndex); + } + + return frameTiming; +} + + +double FrameTimeManager::GetEyePredictionTime(ovrEyeType eye, unsigned int frameIndex) +{ + if (VsyncEnabled) + { + FrameTimeManager::Timing frameTiming = GetFrameTiming(frameIndex); + + // Special case: ovrEye_Count predicts to midpoint + return (eye == ovrEye_Count) ? frameTiming.MidpointTime : frameTiming.EyeRenderTimes[eye]; + } + + // No VSync: Best guess for the near future + return ovr_GetTimeInSeconds() + ScreenSwitchingDelay + NoVSyncToScanoutDelay; +} + +ovrTrackingState FrameTimeManager::GetEyePredictionTracking(ovrHmd hmd, ovrEyeType eye, unsigned int frameIndex) +{ + double eyeRenderTime = GetEyePredictionTime(eye, frameIndex); + ovrTrackingState eyeState = ovrHmd_GetTrackingState(hmd, eyeRenderTime); + + // Record view pose sampling time for Latency reporting. + if (RenderIMUTimeSeconds == 0.0) + { + // TODO: Figure out why this are not as accurate as ovr_GetTimeInSeconds() + //RenderIMUTimeSeconds = eyeState.RawSensorData.TimeInSeconds; + RenderIMUTimeSeconds = ovr_GetTimeInSeconds(); + } + + return eyeState; +} + +Posef FrameTimeManager::GetEyePredictionPose(ovrHmd hmd, ovrEyeType eye) +{ + double eyeRenderTime = GetEyePredictionTime(eye, 0); + ovrTrackingState eyeState = ovrHmd_GetTrackingState(hmd, eyeRenderTime); + + // Record view pose sampling time for Latency reporting. + if (RenderIMUTimeSeconds == 0.0) + { + // TODO: Figure out why this are not as accurate as ovr_GetTimeInSeconds() + //RenderIMUTimeSeconds = eyeState.RawSensorData.TimeInSeconds; + RenderIMUTimeSeconds = ovr_GetTimeInSeconds(); + } + + return eyeState.HeadPose.ThePose; +} + +void FrameTimeManager::GetTimewarpPredictions(ovrEyeType eye, double timewarpStartEnd[2]) +{ + if (VsyncEnabled) + { + timewarpStartEnd[0] = FrameTiming.TimeWarpStartEndTimes[eye][0]; + timewarpStartEnd[1] = FrameTiming.TimeWarpStartEndTimes[eye][1]; + return; + } + + // Free-running, so this will be displayed immediately. + // Unfortunately we have no idea which bit of the screen is actually going to be displayed. + // TODO: guess which bit of the screen is being displayed! + // (e.g. use DONOTWAIT on present and see when the return isn't WASSTILLWAITING?) + + // We have no idea where scan-out is currently, so we can't usefully warp the screen spatially. + timewarpStartEnd[0] = ovr_GetTimeInSeconds() + ScreenSwitchingDelay + NoVSyncToScanoutDelay; + timewarpStartEnd[1] = timewarpStartEnd[0]; +} + + +void FrameTimeManager::GetTimewarpMatrices(ovrHmd hmd, ovrEyeType eyeId, + ovrPosef renderPose, ovrMatrix4f twmOut[2], + double debugTimingOffsetInSeconds) +{ + if (!hmd) + { + return; + } + + double timewarpStartEnd[2] = { 0.0, 0.0 }; + GetTimewarpPredictions(eyeId, timewarpStartEnd); + + //TPH, to vary timing, to allow developers to debug, to shunt the predicted time forward + //and back, and see if the SDK is truly delivering the correct time. Also to allow + //illustration of the detrimental effects when this is not done right. + timewarpStartEnd[0] += debugTimingOffsetInSeconds; + timewarpStartEnd[1] += debugTimingOffsetInSeconds; + + + //HMDState* p = (HMDState*)hmd; + ovrTrackingState startState = ovrHmd_GetTrackingState(hmd, timewarpStartEnd[0]); + ovrTrackingState endState = ovrHmd_GetTrackingState(hmd, timewarpStartEnd[1]); + + if (TimewarpIMUTimeSeconds == 0.0) + { + // TODO: Figure out why this are not as accurate as ovr_GetTimeInSeconds() + //TimewarpIMUTimeSeconds = startState.RawSensorData.TimeInSeconds; + TimewarpIMUTimeSeconds = ovr_GetTimeInSeconds(); + } + + Quatf quatFromStart = startState.HeadPose.ThePose.Orientation; + Quatf quatFromEnd = endState.HeadPose.ThePose.Orientation; + Quatf quatFromEye = renderPose.Orientation; //EyeRenderPoses[eyeId].Orientation; + quatFromEye.Invert(); // because we need the view matrix, not the camera matrix + + Quatf timewarpStartQuat = quatFromEye * quatFromStart; + Quatf timewarpEndQuat = quatFromEye * quatFromEnd; + + Matrix4f timewarpStart(timewarpStartQuat); + Matrix4f timewarpEnd(timewarpEndQuat); + + + // The real-world orientations have: X=right, Y=up, Z=backwards. + // The vectors inside the mesh are in NDC to keep the shader simple: X=right, Y=down, Z=forwards. + // So we need to perform a similarity transform on this delta matrix. + // The verbose code would look like this: + /* + Matrix4f matBasisChange; + matBasisChange.SetIdentity(); + matBasisChange.M[0][0] = 1.0f; + matBasisChange.M[1][1] = -1.0f; + matBasisChange.M[2][2] = -1.0f; + Matrix4f matBasisChangeInv = matBasisChange.Inverted(); + matRenderFromNow = matBasisChangeInv * matRenderFromNow * matBasisChange; + */ + // ...but of course all the above is a constant transform and much more easily done. + // We flip the signs of the Y&Z row, then flip the signs of the Y&Z column, + // and of course most of the flips cancel: + // +++ +-- +-- + // +++ -> flip Y&Z columns -> +-- -> flip Y&Z rows -> -++ + // +++ +-- -++ + timewarpStart.M[0][1] = -timewarpStart.M[0][1]; + timewarpStart.M[0][2] = -timewarpStart.M[0][2]; + timewarpStart.M[1][0] = -timewarpStart.M[1][0]; + timewarpStart.M[2][0] = -timewarpStart.M[2][0]; + + timewarpEnd .M[0][1] = -timewarpEnd .M[0][1]; + timewarpEnd .M[0][2] = -timewarpEnd .M[0][2]; + timewarpEnd .M[1][0] = -timewarpEnd .M[1][0]; + timewarpEnd .M[2][0] = -timewarpEnd .M[2][0]; + + twmOut[0] = timewarpStart; + twmOut[1] = timewarpEnd; +} + + +// Used by renderer to determine if it should time distortion rendering. +bool FrameTimeManager::NeedDistortionTimeMeasurement() const +{ + if (!VsyncEnabled) + return false; + return DistortionRenderTimes.GetCount() < DistortionRenderTimes.Capacity; +} + + +void FrameTimeManager::AddDistortionTimeMeasurement(double distortionTimeSeconds) +{ + DistortionRenderTimes.AddTimeDelta(distortionTimeSeconds); + + //Revisit dynamic pre-Timewarp delay adjustment logic + //updateTimewarpTiming(); + + // If timewarp timing changes based on this sample, update it. + double newTimewarpWaitDelta = calcTimewarpWaitDelta(); + if (newTimewarpWaitDelta != FrameTiming.Inputs.TimewarpWaitDelta) + { + FrameTiming.Inputs.TimewarpWaitDelta = newTimewarpWaitDelta; + LocklessTiming.SetState(FrameTiming); + } +} + + +void FrameTimeManager::UpdateFrameLatencyTrackingAfterEndFrame( + unsigned char frameLatencyTestColor[3], + const Util::FrameTimeRecordSet& rs) +{ + // FrameTiming.NextFrameTime in this context (after EndFrame) is the end frame time. + ScreenLatencyTracker.SaveDrawColor(frameLatencyTestColor[0], + FrameTiming.NextFrameTime, + RenderIMUTimeSeconds, + TimewarpIMUTimeSeconds); + + ScreenLatencyTracker.MatchRecord(rs); + + // If screen delay changed, update timing. + double newScreenDelay = calcScreenDelay(); + if (newScreenDelay != FrameTiming.Inputs.ScreenDelay) + { + FrameTiming.Inputs.ScreenDelay = newScreenDelay; + LocklessTiming.SetState(FrameTiming); + } +} + + +//----------------------------------------------------------------------------------- +//Revisit dynamic pre-Timewarp delay adjustment logic +/* +void FrameTimeManager::TimewarpDelayAdjuster::Reset() +{ + State = State_WaitingToReduceLevel; + DelayLevel = 0; + InitialFrameCounter = 0; + TimewarpDelayReductionSeconds = 0.0; + DelayLevelFinishTime = 0.0; + + memset(WaitTimeIndexForLevel, 0, sizeof(WaitTimeIndexForLevel)); + // If we are at level 0, waits are infinite. + WaitTimeIndexForLevel[0] = MaxTimeIndex; +} + + +void FrameTimeManager::TimewarpDelayAdjuster:: + UpdateTimewarpWaitIfSkippedFrames(FrameTimeManager* manager, + double measuredFrameDelta, double nextFrameTime) +{ + // Times in seconds + const static double delayTimingTiers[7] = { 1.0, 5.0, 15.0, 30.0, 60.0, 120.0, 1000000.0 }; + + const double currentFrameDelta = manager->FrameTiming.Inputs.FrameDelta; + + + // Once we detected frame spike, we skip several frames before testing again. + if (InitialFrameCounter > 0) + { + InitialFrameCounter --; + return; + } + + // Skipped frame would usually take 2x longer then regular frame + if (measuredFrameDelta > currentFrameDelta * 1.8) + { + if (State == State_WaitingToReduceLevel) + { + // If we got here, escalate the level again. + if (DelayLevel < MaxDelayLevel) + { + DelayLevel++; + InitialFrameCounter = 3; + } + } + + else if (State == State_VerifyingAfterReduce) + { + // So we went down to this level and tried to wait to see if there was + // as skipped frame and there is -> go back up a level and incrment its timing tier + if (DelayLevel < MaxDelayLevel) + { + DelayLevel++; + State = State_WaitingToReduceLevel; + + // For higher level delays reductions, i.e. more then half a frame, + // we don't go into the infinite wait tier. + int maxTimingTier = MaxTimeIndex; + if (DelayLevel > MaxInfiniteTimingLevel) + maxTimingTier--; + + if (WaitTimeIndexForLevel[DelayLevel] < maxTimingTier ) + WaitTimeIndexForLevel[DelayLevel]++; + } + } + + DelayLevelFinishTime = nextFrameTime + + delayTimingTiers[WaitTimeIndexForLevel[DelayLevel]]; + TimewarpDelayReductionSeconds = currentFrameDelta * 0.125 * DelayLevel; + manager->updateTimewarpTiming(); + + } + + else if (nextFrameTime > DelayLevelFinishTime) + { + if (State == State_WaitingToReduceLevel) + { + if (DelayLevel > 0) + { + DelayLevel--; + State = State_VerifyingAfterReduce; + // Always use 1 sec to see if "down sampling mode" caused problems + DelayLevelFinishTime = nextFrameTime + 1.0f; + } + } + else if (State == State_VerifyingAfterReduce) + { + // Prior display level successfully reduced, + // try to see we we could go down further after wait. + WaitTimeIndexForLevel[DelayLevel+1] = 0; + State = State_WaitingToReduceLevel; + DelayLevelFinishTime = nextFrameTime + + delayTimingTiers[WaitTimeIndexForLevel[DelayLevel]]; + } + + // TBD: Update TimeWarpTiming + TimewarpDelayReductionSeconds = currentFrameDelta * 0.125 * DelayLevel; + manager->updateTimewarpTiming(); + } + + + //static int oldDelayLevel = 0; + + //if (oldDelayLevel != DelayLevel) + //{ + //OVR_DEBUG_LOG(("DelayLevel:%d tReduction = %0.5f ", DelayLevel, TimewarpDelayReductionSeconds)); + //oldDelayLevel = DelayLevel; + //} + } + */ + +//----------------------------------------------------------------------------------- +// ***** TimeDeltaCollector + +void TimeDeltaCollector::AddTimeDelta(double timeSeconds) +{ + // avoid adding invalid timing values + if(timeSeconds < 0.0f) + return; + + if (Count == Capacity) + { + for(int i=0; i< Count-1; i++) + TimeBufferSeconds[i] = TimeBufferSeconds[i+1]; + Count--; + } + TimeBufferSeconds[Count++] = timeSeconds; + + ReCalcMedian = true; +} + +// KevinJ: Better median function +double CalculateListMedianRecursive(const double inputList[TimeDeltaCollector::Capacity], int inputListLength, int lessThanSum, int greaterThanSum) +{ + double lessThanMedian[TimeDeltaCollector::Capacity], greaterThanMedian[TimeDeltaCollector::Capacity]; + int lessThanMedianListLength = 0, greaterThanMedianListLength = 0; + double median = inputList[0]; + int i; + for (i = 1; i < inputListLength; i++) + { + // If same value, spread among lists evenly + if (inputList[i] < median || ((i & 1) == 0 && inputList[i] == median)) + lessThanMedian[lessThanMedianListLength++] = inputList[i]; + else + greaterThanMedian[greaterThanMedianListLength++] = inputList[i]; + } + if (lessThanMedianListLength + lessThanSum == greaterThanMedianListLength + greaterThanSum + 1 || + lessThanMedianListLength + lessThanSum == greaterThanMedianListLength + greaterThanSum - 1) + return median; + + if (lessThanMedianListLength + lessThanSum < greaterThanMedianListLength + greaterThanSum) + { + lessThanMedian[lessThanMedianListLength++] = median; + return CalculateListMedianRecursive(greaterThanMedian, greaterThanMedianListLength, lessThanMedianListLength + lessThanSum, greaterThanSum); + } + else + { + greaterThanMedian[greaterThanMedianListLength++] = median; + return CalculateListMedianRecursive(lessThanMedian, lessThanMedianListLength, lessThanSum, greaterThanMedianListLength + greaterThanSum); + } +} +// KevinJ: Excludes Firmware hack +double TimeDeltaCollector::GetMedianTimeDeltaNoFirmwareHack() const +{ + if (ReCalcMedian) + { + ReCalcMedian = false; + Median = CalculateListMedianRecursive(TimeBufferSeconds, Count, 0, 0); + } + return Median; +} +double TimeDeltaCollector::GetMedianTimeDelta() const +{ + if(ReCalcMedian) + { + double SortedList[Capacity]; + bool used[Capacity]; + + memset(used, 0, sizeof(used)); + SortedList[0] = 0.0; // In case Count was 0... + + // Probably the slowest way to find median... + for (int i=0; i= NextFrameTime, since that's the time we expect next + // vsync to succeed. + double ThisFrameTime; + double TimewarpPointTime; + double NextFrameTime; + double MidpointTime; + double EyeRenderTimes[2]; + double TimeWarpStartEndTimes[2][2]; + + Timing() + { + memset(this, 0, sizeof(Timing)); + } + + void InitTimingFromInputs(const TimingInputs& inputs, HmdShutterTypeEnum shutterType, + double thisFrameTime, unsigned int frameIndex); + }; + + + // Called on startup to provided data on HMD timing. + void Init(HmdRenderInfo& renderInfo); + + // Called with each new ConfigureRendering. + void ResetFrameTiming(unsigned frameIndex, + bool dynamicPrediction, bool sdkRender); + + void SetVsync(bool enabled) { VsyncEnabled = enabled; } + + // BeginFrame returns time of the call + // TBD: Should this be a predicted time value instead ? + double BeginFrame(unsigned frameIndex); + void EndFrame(); + + // Thread-safe function to query timing for a future frame + Timing GetFrameTiming(unsigned frameIndex); + + // if eye == ovrEye_Count, timing is for MidpointTime as opposed to any specific eye + double GetEyePredictionTime(ovrEyeType eye, unsigned int frameIndex); + ovrTrackingState GetEyePredictionTracking(ovrHmd hmd, ovrEyeType eye, unsigned int frameIndex); + Posef GetEyePredictionPose(ovrHmd hmd, ovrEyeType eye); + + void GetTimewarpPredictions(ovrEyeType eye, double timewarpStartEnd[2]); + void GetTimewarpMatrices(ovrHmd hmd, ovrEyeType eye, ovrPosef renderPose, ovrMatrix4f twmOut[2],double debugTimingOffsetInSeconds = 0.0); + + // Used by renderer to determine if it should time distortion rendering. + bool NeedDistortionTimeMeasurement() const; + void AddDistortionTimeMeasurement(double distortionTimeSeconds); + + + // DK2 Latency test interface + + // Get next draw color for DK2 latency tester (3-byte RGB) + void GetFrameLatencyTestDrawColor(unsigned char outColor[3]) + { + outColor[0] = ScreenLatencyTracker.GetNextDrawColor(); + outColor[1] = ScreenLatencyTracker.IsLatencyTimingAvailable() ? 255 : 0; + outColor[2] = ScreenLatencyTracker.IsLatencyTimingAvailable() ? 0 : 255; + } + + // Must be called after EndFrame() to update latency tester timings. + // Must pass color reported by NextFrameColor for this frame. + void UpdateFrameLatencyTrackingAfterEndFrame(unsigned char frameLatencyTestColor[3], + const Util::FrameTimeRecordSet& rs); + + void GetLatencyTimings(float& latencyRender, float& latencyTimewarp, float& latencyPostPresent) + { + return ScreenLatencyTracker.GetLatencyTimings(latencyRender, latencyTimewarp, latencyPostPresent); + } + + const Timing& GetFrameTiming() const { return FrameTiming; } + +private: + double calcFrameDelta() const; + double calcScreenDelay() const; + double calcTimewarpWaitDelta() const; + + //Revisit dynamic pre-Timewarp delay adjustment logic + /* + void updateTimewarpTiming(); + + + + // TimewarpDelayAdjuster implements a simple state machine that reduces the amount + // of time-warp waiting based on skipped frames. + struct TimewarpDelayAdjuster + { + enum StateInLevel + { + // We are ok at this level, and will be waiting for some time before trying to reduce. + State_WaitingToReduceLevel, + // After decrementing a level, we are verifying that this won't cause skipped frames. + State_VerifyingAfterReduce + }; + + enum { + MaxDelayLevel = 5, + MaxInfiniteTimingLevel = 3, + MaxTimeIndex = 6 + }; + + StateInLevel State; + // Current level. Higher levels means larger delay reduction (smaller overall time-warp delay). + int DelayLevel; + // Index for the amount of time we'd wait in this level. If attempt to decrease level fails, + // with is incrementing causing the level to become "sticky". + int WaitTimeIndexForLevel[MaxTimeIndex + 1]; + // We skip few frames after each escalation to avoid too rapid of a reduction. + int InitialFrameCounter; + // What th currect "reduction" currently is. + double TimewarpDelayReductionSeconds; + // When we should try changing the level again. + double DelayLevelFinishTime; + + public: + TimewarpDelayAdjuster() { Reset(); } + + void Reset(); + + void UpdateTimewarpWaitIfSkippedFrames(FrameTimeManager* manager, + double measuredFrameDelta, + double nextFrameTime); + + double GetDelayReduction() const { return TimewarpDelayReductionSeconds; } + }; + */ + + + HmdRenderInfo RenderInfo; + // Timings are collected through a median filter, to avoid outliers. + TimeDeltaCollector FrameTimeDeltas; + TimeDeltaCollector DistortionRenderTimes; + FrameLatencyTracker ScreenLatencyTracker; + + // Timing changes if we have no Vsync (all prediction is reduced to fixed interval). + bool VsyncEnabled; + // Set if we are rendering via the SDK, so DistortionRenderTimes is valid. + bool DynamicPrediction; + // Set if SDk is doing the rendering. + bool SdkRender; + // Direct to rift. + bool DirectToRift; + + // Total frame delay due to VsyncToFirstScanline, persistence and settle time. + // Computed from RenderInfor.Shutter. + double VSyncToScanoutDelay; + double NoVSyncToScanoutDelay; + double ScreenSwitchingDelay; + + //Revisit dynamic pre-Timewarp delay adjustment logic + //TimewarpDelayAdjuster TimewarpAdjuster; + + // Current (or last) frame timing info. Used as a source for LocklessTiming. + Timing FrameTiming; + // TBD: Don't we need NextFrame here as well? + LocklessUpdater LocklessTiming; + + // IMU Read timings + double RenderIMUTimeSeconds; + double TimewarpIMUTimeSeconds; +}; + + +}} // namespace OVR::CAPI + +#endif // OVR_CAPI_FrameTimeManager_h diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/CAPI/CAPI_HMDRenderState.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/CAPI/CAPI_HMDRenderState.cpp Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,143 @@ +/************************************************************************************ + +Filename : OVR_CAPI_HMDRenderState.cpp +Content : Combines all of the rendering state associated with the HMD +Created : February 2, 2014 +Authors : Michael Antonov + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#include "CAPI_HMDRenderState.h" + +namespace OVR { namespace CAPI { + + +//------------------------------------------------------------------------------------- +// ***** HMDRenderState + +ovrHmdDesc HMDRenderState::GetDesc() const +{ + ovrHmdDesc d; + memset(&d, 0, sizeof(d)); + + d.Type = ovrHmd_Other; + + d.ProductName = OurHMDInfo.ProductName; + d.Manufacturer = OurHMDInfo.Manufacturer; + d.Resolution.w = OurHMDInfo.ResolutionInPixels.w; + d.Resolution.h = OurHMDInfo.ResolutionInPixels.h; + d.WindowsPos.x = OurHMDInfo.DesktopX; + d.WindowsPos.y = OurHMDInfo.DesktopY; + d.DisplayDeviceName = OurHMDInfo.DisplayDeviceName; + d.DisplayId = OurHMDInfo.DisplayId; + d.VendorId = (short)OurHMDInfo.VendorId; + d.ProductId = (short)OurHMDInfo.ProductId; + d.FirmwareMajor = (short)OurHMDInfo.FirmwareMajor; + d.FirmwareMinor = (short)OurHMDInfo.FirmwareMinor; + d.CameraFrustumFarZInMeters = OurHMDInfo.CameraFrustumFarZInMeters; + d.CameraFrustumHFovInRadians = OurHMDInfo.CameraFrustumHFovInRadians; + d.CameraFrustumNearZInMeters = OurHMDInfo.CameraFrustumNearZInMeters; + d.CameraFrustumVFovInRadians = OurHMDInfo.CameraFrustumVFovInRadians; + + OVR_strcpy(d.SerialNumber, sizeof(d.SerialNumber), OurHMDInfo.PrintedSerial.ToCStr()); + + d.HmdCaps = ovrHmdCap_Present | ovrHmdCap_NoVSync; + d.TrackingCaps = ovrTrackingCap_MagYawCorrection | ovrTrackingCap_Orientation; + d.DistortionCaps = ovrDistortionCap_Chromatic | ovrDistortionCap_TimeWarp | + ovrDistortionCap_Vignette | ovrDistortionCap_SRGB | + ovrDistortionCap_FlipInput | ovrDistortionCap_ProfileNoTimewarpSpinWaits | + ovrDistortionCap_HqDistortion | ovrDistortionCap_LinuxDevFullscreen; + +#if defined(OVR_OS_WIN32) || defined(OVR_OS_WIN64) + // TODO: this gets enabled for everything, but is only applicable for DX11+ + d.DistortionCaps |= ovrDistortionCap_ComputeShader; +#endif + + if( OurHMDInfo.InCompatibilityMode ) + d.HmdCaps |= ovrHmdCap_ExtendDesktop; + + if (strstr(OurHMDInfo.ProductName, "DK1")) + { + d.Type = ovrHmd_DK1; + } + else if (strstr(OurHMDInfo.ProductName, "DK2")) + { + d.Type = ovrHmd_DK2; + d.HmdCaps |= ovrHmdCap_LowPersistence | ovrHmdCap_DynamicPrediction; + d.TrackingCaps |= ovrTrackingCap_Position; + d.DistortionCaps |= ovrDistortionCap_Overdrive; + } + + const DistortionRenderDesc& leftDistortion = Distortion[0]; + const DistortionRenderDesc& rightDistortion = Distortion[1]; + + // The suggested FOV (assuming eye rotation) + d.DefaultEyeFov[0] = CalculateFovFromHmdInfo(StereoEye_Left, leftDistortion, RenderInfo, OVR_DEFAULT_EXTRA_EYE_ROTATION); + d.DefaultEyeFov[1] = CalculateFovFromHmdInfo(StereoEye_Right, rightDistortion, RenderInfo, OVR_DEFAULT_EXTRA_EYE_ROTATION); + + // FOV extended across the entire screen + d.MaxEyeFov[0] = GetPhysicalScreenFov(StereoEye_Left, leftDistortion); + d.MaxEyeFov[1] = GetPhysicalScreenFov(StereoEye_Right, rightDistortion); + + if (OurHMDInfo.Shutter.Type == HmdShutter_RollingRightToLeft) + { + d.EyeRenderOrder[0] = ovrEye_Right; + d.EyeRenderOrder[1] = ovrEye_Left; + } + else + { + d.EyeRenderOrder[0] = ovrEye_Left; + d.EyeRenderOrder[1] = ovrEye_Right; + } + + // MA: Taking this out on purpose. + // Important information for those that are required to do their own timing, + // because of shortfalls in timing code. + //d.VsyncToNextVsync = OurHMDInfo.Shutter.VsyncToNextVsync; + //d.PixelPersistence = OurHMDInfo.Shutter.PixelPersistence; + + return d; +} + + +ovrSizei HMDRenderState::GetFOVTextureSize(int eye, ovrFovPort fov, float pixelsPerDisplayPixel) const +{ + OVR_ASSERT((unsigned)eye < 2); + StereoEye seye = (eye == ovrEye_Left) ? StereoEye_Left : StereoEye_Right; + return CalculateIdealPixelSize(seye, Distortion[eye], fov, pixelsPerDisplayPixel); +} + +ovrEyeRenderDesc HMDRenderState::CalcRenderDesc(ovrEyeType eyeType, const ovrFovPort& fov) const +{ + const HmdRenderInfo& hmdri = RenderInfo; + StereoEye eye = (eyeType == ovrEye_Left) ? StereoEye_Left : StereoEye_Right; + ovrEyeRenderDesc e0; + + e0.Eye = eyeType; + e0.Fov = fov; + e0.HmdToEyeViewOffset = CalculateEyeVirtualCameraOffset(hmdri, eye, false); + e0.DistortedViewport = GetFramebufferViewport(eye, hmdri); + e0.PixelsPerTanAngleAtCenter = Distortion[0].PixelsPerTanAngleAtCenter; + + return e0; +} + +}} // namespace OVR::CAPI + diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/CAPI/CAPI_HMDRenderState.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/CAPI/CAPI_HMDRenderState.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,74 @@ +/************************************************************************************ + +Filename : CAPI_HMDRenderState.h +Content : Combines all of the rendering state associated with the HMD +Created : February 2, 2014 +Authors : Michael Antonov + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#ifndef OVR_CAPI_HMDRenderState_h +#define OVR_CAPI_HMDRenderState_h + +#include "../OVR_CAPI.h" +#include "../Kernel/OVR_Math.h" +#include "../Util/Util_Render_Stereo.h" +#include "../Service/Service_NetSessionCommon.h" + +namespace OVR { namespace CAPI { + +using namespace OVR::Util::Render; + + +//------------------------------------------------------------------------------------- +// ***** HMDRenderState + +// Combines all of the rendering setup information about one HMD. +// This structure only ever exists inside HMDState, but this +// declaration is in a separate file to reduce #include dependencies. +// All actual lifetime and update control is done by the surrounding HMDState. +struct HMDRenderState +{ + // Utility query functions. + ovrHmdDesc GetDesc() const; + ovrSizei GetFOVTextureSize(int eye, ovrFovPort fov, float pixelsPerDisplayPixel) const; + ovrEyeRenderDesc CalcRenderDesc(ovrEyeType eyeType, const ovrFovPort& fov) const; + + HMDInfo OurHMDInfo; + + HmdRenderInfo RenderInfo; + DistortionRenderDesc Distortion[2]; + ovrEyeRenderDesc EyeRenderDesc[2]; + + // Clear color used for distortion + float ClearColor[4]; + + // Pose at which last time the eye was rendered, as submitted by EndEyeRender. + ovrPosef EyeRenderPoses[2]; + + // Capabilities passed to Configure. + unsigned EnabledHmdCaps; + unsigned DistortionCaps; // enum ovrDistortionCaps +}; + + +}} // namespace OVR::CAPI + +#endif // OVR_CAPI_HMDState_h diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/CAPI/CAPI_HMDState.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/CAPI/CAPI_HMDState.cpp Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,816 @@ +/************************************************************************************ + +Filename : CAPI_HMDState.cpp +Content : State associated with a single HMD +Created : January 24, 2014 +Authors : Michael Antonov + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#include "CAPI_HMDState.h" +#include "../OVR_Profile.h" +#include "../Service/Service_NetClient.h" +#ifdef OVR_OS_WIN32 +#include "../Displays/OVR_Win32_ShimFunctions.h" +#endif + + +namespace OVR { namespace CAPI { + + +// Accessed via HMDState::GetHMDStateList() +static OVR::List hmdStateList; // List of all created HMDStates. + + +//------------------------------------------------------------------------------------- +// ***** HMDState + +HMDState::HMDState(const OVR::Service::HMDNetworkInfo& netInfo, + const OVR::HMDInfo& hmdInfo, + Profile* profile, + Service::NetClient* client) : + pProfile(profile), + pHmdDesc(0), + pWindow(0), + pClient(client), + NetId(netInfo.NetId), + NetInfo(netInfo), + OurHMDInfo(hmdInfo), + pLastError(NULL), + EnabledHmdCaps(0), + EnabledServiceHmdCaps(0), + SharedStateReader(), + TheSensorStateReader(), + TheLatencyTestStateReader(), + LatencyTestActive(false), + //LatencyTestDrawColor(), + LatencyTest2Active(false), + //LatencyTest2DrawColor(), + TimeManager(true), + RenderState(), + pRenderer(), + pHSWDisplay(), + LastFrameTimeSeconds(0.), + LastGetFrameTimeSeconds(0.), + //LastGetStringValue(), + RenderingConfigured(false), + BeginFrameCalled(false), + BeginFrameThreadId(), + RenderAPIThreadChecker(), + BeginFrameTimingCalled(false) +{ + sharedInit(profile); + hmdStateList.PushBack(this); +} + + +HMDState::HMDState(const OVR::HMDInfo& hmdInfo, Profile* profile) : + pProfile(profile), + pHmdDesc(0), + pWindow(0), + pClient(0), + NetId(InvalidVirtualHmdId), + NetInfo(), + OurHMDInfo(hmdInfo), + pLastError(NULL), + EnabledHmdCaps(0), + EnabledServiceHmdCaps(0), + SharedStateReader(), + TheSensorStateReader(), + TheLatencyTestStateReader(), + LatencyTestActive(false), + //LatencyTestDrawColor(), + LatencyTest2Active(false), + //LatencyTest2DrawColor(), + TimeManager(true), + RenderState(), + pRenderer(), + pHSWDisplay(), + LastFrameTimeSeconds(0.), + LastGetFrameTimeSeconds(0.), + //LastGetStringValue(), + RenderingConfigured(false), + BeginFrameCalled(false), + BeginFrameThreadId(), + RenderAPIThreadChecker(), + BeginFrameTimingCalled(false) +{ + sharedInit(profile); + hmdStateList.PushBack(this); +} + +HMDState::~HMDState() +{ + hmdStateList.Remove(this); + + if (pClient) + { + pClient->Hmd_Release(NetId); + pClient = 0; + } + + ConfigureRendering(0,0,0,0); + + if (pHmdDesc) + { + OVR_FREE(pHmdDesc); + pHmdDesc = NULL; + } +} + +void HMDState::sharedInit(Profile* profile) +{ + // TBD: We should probably be looking up the default profile for the given + // device type + user if profile == 0. + pLastError = 0; + + RenderState.OurHMDInfo = OurHMDInfo; + + UpdateRenderProfile(profile); + + OVR_ASSERT(!pHmdDesc); + pHmdDesc = (ovrHmdDesc*)OVR_ALLOC(sizeof(ovrHmdDesc)); + *pHmdDesc = RenderState.GetDesc(); + pHmdDesc->Handle = this; + + RenderState.ClearColor[0] = 0.0f; + RenderState.ClearColor[1] = 0.0f; + RenderState.ClearColor[2] = 0.0f; + RenderState.ClearColor[3] = 0.0f; + + RenderState.EnabledHmdCaps = 0; + + TimeManager.Init(RenderState.RenderInfo); + + /* + LatencyTestDrawColor[0] = 0; + LatencyTestDrawColor[1] = 0; + LatencyTestDrawColor[2] = 0; + */ + + RenderingConfigured = false; + BeginFrameCalled = false; + BeginFrameThreadId = 0; + BeginFrameTimingCalled = false; + + // Construct the HSWDisplay. We will later reconstruct it with a specific ovrRenderAPI type if the application starts using SDK-based rendering. + if(!pHSWDisplay) + { + pHSWDisplay = *OVR::CAPI::HSWDisplay::Factory(ovrRenderAPI_None, pHmdDesc, RenderState); + pHSWDisplay->Enable(pProfile->GetBoolValue("HSW", true)); + } +} + +static Vector3f GetNeckModelFromProfile(Profile* profile) +{ + OVR_ASSERT(profile); + + float neckeye[2] = { OVR_DEFAULT_NECK_TO_EYE_HORIZONTAL, OVR_DEFAULT_NECK_TO_EYE_VERTICAL }; + profile->GetFloatValues(OVR_KEY_NECK_TO_EYE_DISTANCE, neckeye, 2); + + // Make sure these are vaguely sensible values. + //OVR_ASSERT((neckeye[0] > 0.05f) && (neckeye[0] < 0.5f)); + //OVR_ASSERT((neckeye[1] > 0.05f) && (neckeye[1] < 0.5f)); + + // Named for clarity + float NeckToEyeHorizontal = neckeye[0]; + float NeckToEyeVertical = neckeye[1]; + + // Store the neck model + return Vector3f(0.0, NeckToEyeVertical, -NeckToEyeHorizontal); +} + +static float GetCenterPupilDepthFromRenderInfo(HmdRenderInfo* hmdRenderInfo) +{ + OVR_ASSERT(hmdRenderInfo); + + // Find the distance from the center of the screen to the "center eye" + // This center eye is used by systems like rendering & audio to represent the player, + // and they will handle the offsets needed from there to each actual eye. + + // HACK HACK HACK + // We know for DK1 the screen->lens surface distance is roughly 0.049f, and that the faceplate->lens is 0.02357f. + // We're going to assume(!!!!) that all HMDs have the same screen->faceplate distance. + // Crystal Cove was measured to be roughly 0.025 screen->faceplate which agrees with this assumption. + // TODO: do this properly! Update: Measured this at 0.02733 with a CC prototype, CES era (PT7), on 2/19/14 -Steve + float screenCenterToMidplate = 0.02733f; + float centerEyeRelief = hmdRenderInfo->GetEyeCenter().ReliefInMeters; + float CenterPupilDepth = screenCenterToMidplate + hmdRenderInfo->LensSurfaceToMidplateInMeters + centerEyeRelief; + + return CenterPupilDepth; +} + +void HMDState::UpdateRenderProfile(Profile* profile) +{ + // Apply the given profile to generate a render context + RenderState.RenderInfo = GenerateHmdRenderInfoFromHmdInfo(RenderState.OurHMDInfo, profile); + RenderState.Distortion[0] = CalculateDistortionRenderDesc(StereoEye_Left, RenderState.RenderInfo, 0); + RenderState.Distortion[1] = CalculateDistortionRenderDesc(StereoEye_Right, RenderState.RenderInfo, 0); + + if (pClient) + { + // Center pupil depth + float centerPupilDepth = GetCenterPupilDepthFromRenderInfo(&RenderState.RenderInfo); + pClient->SetNumberValue(GetNetId(), "CenterPupilDepth", centerPupilDepth); + + // Neck model + Vector3f neckModel = GetNeckModelFromProfile(profile); + double neckModelArray[3] = { + neckModel.x, + neckModel.y, + neckModel.z + }; + pClient->SetNumberValues(GetNetId(), "NeckModelVector3f", neckModelArray, 3); + + double camerastate[7]; + if (profile->GetDoubleValues(OVR_KEY_CAMERA_POSITION, camerastate, 7) == 0) + { + //there is no value, so we load the default + for (int i = 0; i < 7; i++) camerastate[i] = 0; + camerastate[3] = 1;//no offset. by default, give the quaternion w component value 1 + } + else + + TheSensorStateReader.setCenteredFromWorld(OVR::Posed::FromArray(camerastate)); + } + + +} + +HMDState* HMDState::CreateHMDState(NetClient* client, const HMDNetworkInfo& netInfo) +{ + // HMDState works through a handle to service HMD.... + HMDInfo hinfo; + if (!client->Hmd_GetHmdInfo(netInfo.NetId, &hinfo)) + { + OVR_DEBUG_LOG(("[HMDState] Unable to get HMD info")); + return NULL; + } + +#ifdef OVR_OS_WIN32 + OVR_DEBUG_LOG(("Setting up display shim")); + + // Initialize the display shim before reporting the display to the user code + // so that this will happen before the D3D display object is created. + Win32::DisplayShim::GetInstance().Update(&hinfo.ShimInfo); +#endif + + Ptr pDefaultProfile = *ProfileManager::GetInstance()->GetDefaultUserProfile(&hinfo); + OVR_DEBUG_LOG(("Using profile %s", pDefaultProfile->GetValue(OVR_KEY_USER))); + + HMDState* hmds = new HMDState(netInfo, hinfo, pDefaultProfile, client); + + if (!hmds->SharedStateReader.Open(netInfo.SharedMemoryName.ToCStr())) + { + delete hmds; + return NULL; + } + + hmds->TheSensorStateReader.SetUpdater(hmds->SharedStateReader.Get()); + hmds->TheLatencyTestStateReader.SetUpdater(hmds->SharedStateReader.Get()); + + return hmds; +} + +HMDState* HMDState::CreateHMDState(ovrHmdType hmdType) +{ + HmdTypeEnum t = HmdType_None; + if (hmdType == ovrHmd_DK1) + t = HmdType_DK1; + else if (hmdType == ovrHmd_DK2) + t = HmdType_DK2; + + // FIXME: This does not actually grab the right user.. + Ptr pDefaultProfile = *ProfileManager::GetInstance()->GetDefaultProfile(t); + + return new HMDState(CreateDebugHMDInfo(t), pDefaultProfile); +} + + +const OVR::List& HMDState::GetHMDStateList() +{ + return hmdStateList; +} + + +//------------------------------------------------------------------------------------- +// *** Sensor + +bool HMDState::ConfigureTracking(unsigned supportedCaps, unsigned requiredCaps) +{ + return pClient ? pClient->Hmd_ConfigureTracking(NetId, supportedCaps, requiredCaps) : true; +} + +void HMDState::ResetTracking() +{ + if (pClient) pClient->Hmd_ResetTracking(NetId); +} + +// Re-center the orientation. +void HMDState::RecenterPose() +{ + TheSensorStateReader.RecenterPose(); +} + +// Returns prediction for time. +ovrTrackingState HMDState::PredictedTrackingState(double absTime) +{ + Tracking::TrackingState ss; + TheSensorStateReader.GetSensorStateAtTime(absTime, ss); + + // Zero out the status flags + if (!pClient || !pClient->IsConnected(false, false)) + { + ss.StatusFlags = 0; + } + + return ss; +} + +void HMDState::SetEnabledHmdCaps(unsigned hmdCaps) +{ + if (OurHMDInfo.HmdType < HmdType_DK2) + { + // disable low persistence and pentile. + hmdCaps &= ~ovrHmdCap_LowPersistence; + hmdCaps &= ~ovrHmdCap_DirectPentile; + + // disable dynamic prediction using the internal latency tester + hmdCaps &= ~ovrHmdCap_DynamicPrediction; + } + + if (OurHMDInfo.HmdType >= HmdType_DK2) + { + if ((EnabledHmdCaps ^ hmdCaps) & ovrHmdCap_DynamicPrediction) + { + // DynamicPrediction change + TimeManager.ResetFrameTiming(TimeManager.GetFrameTiming().FrameIndex, + (hmdCaps & ovrHmdCap_DynamicPrediction) ? true : false, + RenderingConfigured); + } + } + + // Pentile unsupported on everything right now. + hmdCaps &= ~ovrHmdCap_DirectPentile; + + if ((EnabledHmdCaps ^ hmdCaps) & ovrHmdCap_NoVSync) + { + TimeManager.SetVsync((hmdCaps & ovrHmdCap_NoVSync) ? false : true); + } + + if ((EnabledHmdCaps ^ hmdCaps) & ovrHmdCap_NoMirrorToWindow) + { +#ifdef OVR_OS_WIN32 + Win32::DisplayShim::GetInstance().UseMirroring = (hmdCaps & ovrHmdCap_NoMirrorToWindow) ? + false : true; + if (pWindow) + { // Force window repaint so that stale mirrored image doesn't persist. + ::InvalidateRect((HWND)pWindow, 0, true); + } +#endif + } + + // TBD: Should this include be only the rendering flags? Otherwise, bits that failed + // modification in Hmd_SetEnabledCaps may mis-match... + EnabledHmdCaps = hmdCaps & ovrHmdCap_Writable_Mask; + RenderState.EnabledHmdCaps = EnabledHmdCaps; + + + // If any of the modifiable service caps changed, call on the service. + unsigned prevServiceCaps = EnabledServiceHmdCaps & ovrHmdCap_Writable_Mask; + unsigned newServiceCaps = hmdCaps & ovrHmdCap_Writable_Mask & ovrHmdCap_Service_Mask; + + if (prevServiceCaps ^ newServiceCaps) + { + EnabledServiceHmdCaps = pClient ? pClient->Hmd_SetEnabledCaps(NetId, newServiceCaps) + : newServiceCaps; + } +} + + +unsigned HMDState::SetEnabledHmdCaps() +{ + unsigned serviceCaps = pClient ? pClient->Hmd_GetEnabledCaps(NetId) : + EnabledServiceHmdCaps; + + return serviceCaps & ((~ovrHmdCap_Service_Mask) | EnabledHmdCaps); +} + + +//------------------------------------------------------------------------------------- +// ***** Property Access + +// FIXME: Remove the EGetBoolValue stuff and do it with a "Server:" prefix, so we do not +// need to keep a white-list of keys. This is also way cool because it allows us to add +// new settings keys from outside CAPI that can modify internal server data. + +bool HMDState::getBoolValue(const char* propertyName, bool defaultVal) +{ + if (NetSessionCommon::IsServiceProperty(NetSessionCommon::EGetBoolValue, propertyName)) + { + return NetClient::GetInstance()->GetBoolValue(GetNetId(), propertyName, defaultVal); + } + else if (pProfile) + { + return pProfile->GetBoolValue(propertyName, defaultVal); + } + return defaultVal; +} + +bool HMDState::setBoolValue(const char* propertyName, bool value) +{ + if (NetSessionCommon::IsServiceProperty(NetSessionCommon::ESetBoolValue, propertyName)) + { + return NetClient::GetInstance()->SetBoolValue(GetNetId(), propertyName, value); + } + + return false; +} + +int HMDState::getIntValue(const char* propertyName, int defaultVal) +{ + if (NetSessionCommon::IsServiceProperty(NetSessionCommon::EGetIntValue, propertyName)) + { + return NetClient::GetInstance()->GetIntValue(GetNetId(), propertyName, defaultVal); + } + else if (pProfile) + { + return pProfile->GetIntValue(propertyName, defaultVal); + } + return defaultVal; +} + +bool HMDState::setIntValue(const char* propertyName, int value) +{ + if (NetSessionCommon::IsServiceProperty(NetSessionCommon::ESetIntValue, propertyName)) + { + return NetClient::GetInstance()->SetIntValue(GetNetId(), propertyName, value); + } + + return false; +} + +float HMDState::getFloatValue(const char* propertyName, float defaultVal) +{ + if (OVR_strcmp(propertyName, "LensSeparation") == 0) + { + return OurHMDInfo.LensSeparationInMeters; + } + else if (OVR_strcmp(propertyName, "VsyncToNextVsync") == 0) + { + return OurHMDInfo.Shutter.VsyncToNextVsync; + } + else if (OVR_strcmp(propertyName, "PixelPersistence") == 0) + { + return OurHMDInfo.Shutter.PixelPersistence; + } + else if (NetSessionCommon::IsServiceProperty(NetSessionCommon::EGetNumberValue, propertyName)) + { + return (float)NetClient::GetInstance()->GetNumberValue(GetNetId(), propertyName, defaultVal); + } + else if (pProfile) + { + return pProfile->GetFloatValue(propertyName, defaultVal); + } + + return defaultVal; +} + +bool HMDState::setFloatValue(const char* propertyName, float value) +{ + if (NetSessionCommon::IsServiceProperty(NetSessionCommon::ESetNumberValue, propertyName)) + { + return NetClient::GetInstance()->SetNumberValue(GetNetId(), propertyName, value); + } + + return false; +} + +static unsigned CopyFloatArrayWithLimit(float dest[], unsigned destSize, + float source[], unsigned sourceSize) +{ + unsigned count = Alg::Min(destSize, sourceSize); + for (unsigned i = 0; i < count; i++) + dest[i] = source[i]; + return count; +} + +unsigned HMDState::getFloatArray(const char* propertyName, float values[], unsigned arraySize) +{ + if (arraySize) + { + if (OVR_strcmp(propertyName, "ScreenSize") == 0) + { + float data[2] = { OurHMDInfo.ScreenSizeInMeters.w, OurHMDInfo.ScreenSizeInMeters.h }; + + return CopyFloatArrayWithLimit(values, arraySize, data, 2); + } + else if (OVR_strcmp(propertyName, "DistortionClearColor") == 0) + { + return CopyFloatArrayWithLimit(values, arraySize, RenderState.ClearColor, 4); + } + else if (OVR_strcmp(propertyName, "DK2Latency") == 0) + { + if (OurHMDInfo.HmdType != HmdType_DK2) + { + return 0; + } + + union { + struct X { + float latencyRender, latencyTimewarp, latencyPostPresent; + } x; + float data[3]; + } m; + + static_assert(sizeof(m.x)==sizeof(m.data), "sizeof(struct X) failure"); + + TimeManager.GetLatencyTimings(m.x.latencyRender, m.x.latencyTimewarp, m.x.latencyPostPresent); + + return CopyFloatArrayWithLimit(values, arraySize, m.data, 3); + } + else if (NetSessionCommon::IsServiceProperty(NetSessionCommon::EGetNumberValues, propertyName)) + { + // Convert floats to doubles + double* da = new double[arraySize]; + for (int i = 0; i < (int)arraySize; ++i) + { + da[i] = values[i]; + } + + int count = NetClient::GetInstance()->GetNumberValues(GetNetId(), propertyName, da, (int)arraySize); + + for (int i = 0; i < count; ++i) + { + values[i] = (float)da[i]; + } + + delete[] da; + + return count; + } + else if (pProfile) + { + // TBD: Not quite right. Should update profile interface, so that + // we can return 0 in all conditions if property doesn't exist. + + return pProfile->GetFloatValues(propertyName, values, arraySize); + } + } + + return 0; +} + +bool HMDState::setFloatArray(const char* propertyName, float values[], unsigned arraySize) +{ + if (!arraySize) + { + return false; + } + + if (OVR_strcmp(propertyName, "DistortionClearColor") == 0) + { + CopyFloatArrayWithLimit(RenderState.ClearColor, 4, values, arraySize); + return true; + } + + if (NetSessionCommon::IsServiceProperty(NetSessionCommon::ESetNumberValues, propertyName)) + { + double* da = new double[arraySize]; + for (int i = 0; i < (int)arraySize; ++i) + { + da[i] = values[i]; + } + + bool result = NetClient::GetInstance()->SetNumberValues(GetNetId(), propertyName, da, arraySize); + + delete[] da; + + return result; + } + + return false; +} + +const char* HMDState::getString(const char* propertyName, const char* defaultVal) +{ + if (NetSessionCommon::IsServiceProperty(NetSessionCommon::EGetStringValue, propertyName)) + { + return NetClient::GetInstance()->GetStringValue(GetNetId(), propertyName, defaultVal); + } + + if (pProfile) + { + LastGetStringValue[0] = 0; + if (pProfile->GetValue(propertyName, LastGetStringValue, sizeof(LastGetStringValue))) + { + return LastGetStringValue; + } + } + + return defaultVal; +} + +bool HMDState::setString(const char* propertyName, const char* value) +{ + if (NetSessionCommon::IsServiceProperty(NetSessionCommon::ESetStringValue, propertyName)) + { + return NetClient::GetInstance()->SetStringValue(GetNetId(), propertyName, value); + } + + return false; +} + + +//------------------------------------------------------------------------------------- +// *** Latency Test + +bool HMDState::ProcessLatencyTest(unsigned char rgbColorOut[3]) +{ + return NetClient::GetInstance()->LatencyUtil_ProcessInputs(Timer::GetSeconds(), rgbColorOut); +} + +//------------------------------------------------------------------------------------- +// *** Rendering + +bool HMDState::ConfigureRendering(ovrEyeRenderDesc eyeRenderDescOut[2], + const ovrFovPort eyeFovIn[2], + const ovrRenderAPIConfig* apiConfig, + unsigned distortionCaps) +{ + ThreadChecker::Scope checkScope(&RenderAPIThreadChecker, "ovrHmd_ConfigureRendering"); + + // null -> shut down. + if (!apiConfig) + { + if (pHSWDisplay) + { + pHSWDisplay->Shutdown(); + pHSWDisplay.Clear(); + } + + if (pRenderer) + pRenderer.Clear(); + RenderingConfigured = false; + return true; + } + + if (pRenderer && + (apiConfig->Header.API != pRenderer->GetRenderAPI())) + { + // Shutdown old renderer. + if (pHSWDisplay) + { + pHSWDisplay->Shutdown(); + pHSWDisplay.Clear(); + } + + if (pRenderer) + pRenderer.Clear(); + } + + distortionCaps = distortionCaps & pHmdDesc->DistortionCaps; + + // Step 1: do basic setup configuration + RenderState.EnabledHmdCaps = EnabledHmdCaps; // This is a copy... Any cleaner way? + RenderState.DistortionCaps = distortionCaps; + RenderState.EyeRenderDesc[0] = RenderState.CalcRenderDesc(ovrEye_Left, eyeFovIn[0]); + RenderState.EyeRenderDesc[1] = RenderState.CalcRenderDesc(ovrEye_Right, eyeFovIn[1]); + eyeRenderDescOut[0] = RenderState.EyeRenderDesc[0]; + eyeRenderDescOut[1] = RenderState.EyeRenderDesc[1]; + + TimeManager.ResetFrameTiming(0, + (EnabledHmdCaps & ovrHmdCap_DynamicPrediction) ? true : false, + true); + + LastFrameTimeSeconds = 0.0f; + + // Set RenderingConfigured early to avoid ASSERTs in renderer initialization. + RenderingConfigured = true; + + if (!pRenderer) + { + pRenderer = *DistortionRenderer::APICreateRegistry + [apiConfig->Header.API](pHmdDesc, TimeManager, RenderState); + } + + if (!pRenderer || + !pRenderer->Initialize(apiConfig)) + { + RenderingConfigured = false; + return false; + } + + // Setup the Health and Safety Warning display system. + if(pHSWDisplay && (pHSWDisplay->GetRenderAPIType() != apiConfig->Header.API)) // If we need to reconstruct the HSWDisplay for a different graphics API type, delete the existing display. + { + pHSWDisplay->Shutdown(); + pHSWDisplay.Clear(); + } + + if(!pHSWDisplay) // Use * below because that for of operator= causes it to inherit the refcount the factory gave the object. + { + pHSWDisplay = *OVR::CAPI::HSWDisplay::Factory(apiConfig->Header.API, pHmdDesc, RenderState); + pHSWDisplay->Enable(pProfile->GetBoolValue("HSW", true)); + } + + if (pHSWDisplay) + pHSWDisplay->Initialize(apiConfig); // This is potentially re-initializing it with a new config. + + return true; +} + + +void HMDState::SubmitEyeTextures(const ovrPosef renderPose[2], + const ovrTexture eyeTexture[2]) +{ + RenderState.EyeRenderPoses[0] = renderPose[0]; + RenderState.EyeRenderPoses[1] = renderPose[1]; + + if (pRenderer) + { + pRenderer->SubmitEye(0, &eyeTexture[0]); + pRenderer->SubmitEye(1, &eyeTexture[1]); + } +} + + +// I appreciate this is not an idea place for this function, but it didn't seem to be +// being linked properly when in OVR_CAPI.cpp. +// Please relocate if you know of a better place +ovrBool ovrHmd_CreateDistortionMeshInternal( ovrHmdStruct * hmd, + ovrEyeType eyeType, ovrFovPort fov, + unsigned int distortionCaps, + ovrDistortionMesh *meshData, + float overrideEyeReliefIfNonZero ) +{ + if (!meshData) + return 0; + HMDState* hmds = (HMDState*)hmd; + + // Not used now, but Chromatic flag or others could possibly be checked for in the future. + OVR_UNUSED1(distortionCaps); + +#if defined (OVR_CC_MSVC) + static_assert(sizeof(DistortionMeshVertexData) == sizeof(ovrDistortionVertex), "DistortionMeshVertexData size mismatch"); +#endif + + // *** Calculate a part of "StereoParams" needed for mesh generation + + // Note that mesh distortion generation is invariant of RenderTarget UVs, allowing + // render target size and location to be changed after the fact dynamically. + // eyeToSourceUV is computed here for convenience, so that users don't need + // to call ovrHmd_GetRenderScaleAndOffset unless changing RT dynamically. + + const HmdRenderInfo& hmdri = hmds->RenderState.RenderInfo; + StereoEye stereoEye = (eyeType == ovrEye_Left) ? StereoEye_Left : StereoEye_Right; + + DistortionRenderDesc& distortion = hmds->RenderState.Distortion[eyeType]; + if (overrideEyeReliefIfNonZero) + { + distortion.Lens = GenerateLensConfigFromEyeRelief(overrideEyeReliefIfNonZero,hmdri); + } + + // Find the mapping from TanAngle space to target NDC space. + ScaleAndOffset2D eyeToSourceNDC = CreateNDCScaleAndOffsetFromFov(fov); + + int triangleCount = 0; + int vertexCount = 0; + + DistortionMeshCreate((DistortionMeshVertexData**)&meshData->pVertexData, + (uint16_t**)&meshData->pIndexData, + &vertexCount, &triangleCount, + (stereoEye == StereoEye_Right), + hmdri, distortion, eyeToSourceNDC); + + if (meshData->pVertexData) + { + // Convert to index + meshData->IndexCount = triangleCount * 3; + meshData->VertexCount = vertexCount; + return 1; + } + + return 0; +} + + + +}} // namespace OVR::CAPI diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/CAPI/CAPI_HMDState.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/CAPI/CAPI_HMDState.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,304 @@ +/************************************************************************************ + +Filename : CAPI_HMDState.h +Content : State associated with a single HMD +Created : January 24, 2014 +Authors : Michael Antonov + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#ifndef OVR_CAPI_HMDState_h +#define OVR_CAPI_HMDState_h + +#include "../Kernel/OVR_Math.h" +#include "../Kernel/OVR_List.h" +#include "../Kernel/OVR_Log.h" +#include "../OVR_CAPI.h" + +#include "CAPI_FrameTimeManager.h" +#include "CAPI_LatencyStatistics.h" +#include "CAPI_HMDRenderState.h" +#include "CAPI_DistortionRenderer.h" +#include "CAPI_HSWDisplay.h" + +#include "../Service/Service_NetClient.h" +#include "../Net/OVR_NetworkTypes.h" +#include "../Util/Util_LatencyTest2Reader.h" + +struct ovrHmdStruct { }; + +namespace OVR { namespace CAPI { + + +using namespace OVR::Util::Render; +using namespace OVR::Service; +using namespace OVR::Net; + + +//------------------------------------------------------------------------------------- +// ***** ThreadChecker + +// This helper class is used to verify that the API is used according to supported +// thread safety constraints (is not re-entrant for this and related functions). +class ThreadChecker +{ +public: + +#ifndef OVR_BUILD_DEBUG + + // In release build, thread checks are disabled. + ThreadChecker() { } + void Begin(const char* functionName) { OVR_UNUSED1(functionName); } + void End() { } + + // Add thread-re-entrancy check for function scope + struct Scope + { + Scope(ThreadChecker*, const char *) { } + ~Scope() { } + }; + + +#else // OVR_BUILD_DEBUG + ThreadChecker() : pFunctionName(0), FirstThread(0) + { } + + void Begin(const char* functionName) + { + if (!pFunctionName) + { + pFunctionName = functionName; + FirstThread = GetCurrentThreadId(); + } + else + { + // pFunctionName may be not null here if function is called internally on the same thread. + OVR_ASSERT_LOG((FirstThread == GetCurrentThreadId()), + ("%s (threadId=%p) called at the same times as %s (threadId=%p)\n", + functionName, GetCurrentThreadId(), pFunctionName, FirstThread) ); + } + } + void End() + { + pFunctionName = 0; + FirstThread = 0; + } + + // Add thread-reentrancy check for function scope. + struct Scope + { + Scope(ThreadChecker* threadChecker, const char *functionName) : pChecker(threadChecker) + { pChecker->Begin(functionName); } + ~Scope() + { pChecker->End(); } + private: + ThreadChecker* pChecker; + }; + +private: + // If not 0, contains the name of the function that first entered the scope. + const char * pFunctionName; + ThreadId FirstThread; + +#endif // OVR_BUILD_DEBUG +}; + + +//------------------------------------------------------------------------------------- +// ***** HMDState + +// Describes a single HMD. +class HMDState : public ListNode, + public ovrHmdStruct, public NewOverrideBase +{ + void operator=(const HMDState&) { } // Quiet warning. + +protected: + HMDState(const OVR::Service::HMDNetworkInfo& netInfo, + const OVR::HMDInfo& hmdInfo, + Profile* profile, + Service::NetClient* client); + HMDState(const HMDInfo& src, Profile* profile); + +public: + virtual ~HMDState(); + + static HMDState* CreateHMDState(Service::NetClient* client, const HMDNetworkInfo& netInfo); + static HMDState* CreateHMDState(ovrHmdType hmdType); // Used for debug mode + static const OVR::List& GetHMDStateList(); + + // *** Sensor Setup + + bool ConfigureTracking(unsigned supportedCaps, unsigned requiredCaps); + void ResetTracking(); + void RecenterPose(); + ovrTrackingState PredictedTrackingState(double absTime); + + // Changes HMD Caps. + // Capability bits that are not directly or logically tied to one system (such as sensor) + // are grouped here. ovrHmdCap_VSync, for example, affects rendering and timing. + void SetEnabledHmdCaps(unsigned caps); + unsigned SetEnabledHmdCaps(); + + bool ProcessLatencyTest(unsigned char rgbColorOut[3]); + + // *** Rendering Setup + bool ConfigureRendering(ovrEyeRenderDesc eyeRenderDescOut[2], + const ovrFovPort eyeFovIn[2], + const ovrRenderAPIConfig* apiConfig, + unsigned distortionCaps); + + void UpdateRenderProfile(Profile* profile); + + + void SubmitEyeTextures(const ovrPosef renderPose[2], + const ovrTexture eyeTexture[2]); + + + void sharedInit ( Profile *profile ); + + void applyProfileToSensorFusion(); + + // INlines so that they can be easily compiled out. + // Does debug ASSERT checks for functions that require BeginFrame. + // Also verifies that we are on the right thread. + void checkBeginFrameScope(const char* functionName) + { + OVR_UNUSED1(functionName); // for Release build. + OVR_ASSERT_LOG(BeginFrameCalled == true, + ("%s called outside ovrHmd_BeginFrame.", functionName)); + OVR_DEBUG_LOG_COND(BeginFrameThreadId != OVR::GetCurrentThreadId(), + ("%s called on a different thread then ovrHmd_BeginFrame.", functionName)); + } + + void checkRenderingConfigured(const char* functionName) + { + OVR_UNUSED1(functionName); // for Release build. + OVR_ASSERT_LOG(RenderingConfigured == true, + ("%s called without ovrHmd_ConfigureRendering.", functionName)); + } + + void checkBeginFrameTimingScope(const char* functionName) + { + OVR_UNUSED1(functionName); // for Release build. + OVR_ASSERT_LOG(BeginFrameTimingCalled == true, + ("%s called outside ovrHmd_BeginFrameTiming.", functionName)); + } + + // Get properties by name. + bool getBoolValue(const char* propertyName, bool defaultVal); + bool setBoolValue(const char* propertyName, bool value); + int getIntValue(const char* propertyName, int defaultVal); + bool setIntValue(const char* propertyName, int value); + float getFloatValue(const char* propertyName, float defaultVal); + bool setFloatValue(const char* propertyName, float value); + unsigned getFloatArray(const char* propertyName, float values[], unsigned arraySize); + bool setFloatArray(const char* propertyName, float values[], unsigned arraySize); + const char* getString(const char* propertyName, const char* defaultVal); + bool setString(const char* propertyName, const char* value); + + VirtualHmdId GetNetId() { return NetId; } + +public: + Ptr pProfile; + // Descriptor that gets allocated and returned to the user as ovrHmd. + ovrHmdDesc* pHmdDesc; + // Window handle passed in AttachWindow. + void* pWindow; + + // Network + Service::NetClient* pClient; + VirtualHmdId NetId; + HMDNetworkInfo NetInfo; + + // HMDInfo shouldn't change, as its string pointers are passed out. + HMDInfo OurHMDInfo; + + const char* pLastError; + + // Caps enabled for the HMD. + unsigned EnabledHmdCaps; + + // Caps actually sent to the Sensor Service + unsigned EnabledServiceHmdCaps; + + // These are the flags actually applied to the Sensor device, + // used to track whether SetDisplayReport calls are necessary. + //unsigned HmdCapsAppliedToSensor; + + // *** Sensor + Tracking::CombinedSharedStateReader SharedStateReader; + Tracking::SensorStateReader TheSensorStateReader; + Util::RecordStateReader TheLatencyTestStateReader; + + bool LatencyTestActive; + unsigned char LatencyTestDrawColor[3]; + + bool LatencyTest2Active; + unsigned char LatencyTest2DrawColor[3]; + + // Rendering part + FrameTimeManager TimeManager; + LagStatsCalculator LagStats; + LatencyStatisticsCSV LagStatsCSV; + HMDRenderState RenderState; + Ptr pRenderer; + + // Health and Safety Warning display. + Ptr pHSWDisplay; + + // Last timing value reported by BeginFrame. + double LastFrameTimeSeconds; + // Last timing value reported by GetFrameTime. These are separate since the intended + // use is from different threads. TBD: Move to FrameTimeManager? Make atomic? + double LastGetFrameTimeSeconds; + + // Last cached value returned by ovrHmd_GetString/ovrHmd_GetStringArray. + char LastGetStringValue[256]; + + // Debug flag set after ovrHmd_ConfigureRendering succeeds. + bool RenderingConfigured; + // Set after BeginFrame succeeds, and its corresponding thread id for debug checks. + bool BeginFrameCalled; + ThreadId BeginFrameThreadId; + // Graphics functions are not re-entrant from other threads. + ThreadChecker RenderAPIThreadChecker; + // + bool BeginFrameTimingCalled; +}; + + + + +//I appreciate this isn't an idea place for this function prototype, but needed +//to be seen by OVR_CAPI.cpp and the various SDK renderers of CAPI, +//and have everything defined. Please move to a better place if you know of one. +ovrBool ovrHmd_CreateDistortionMeshInternal( ovrHmdStruct * hmd, + ovrEyeType eyeType, ovrFovPort fov, + unsigned int distortionCaps, + ovrDistortionMesh *meshData, + float overrideEyeReliefIfNonZero=0 ); + + + + +}} // namespace OVR::CAPI + +#endif // OVR_CAPI_HMDState_h diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/CAPI/CAPI_HSWDisplay.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/CAPI/CAPI_HSWDisplay.cpp Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,482 @@ +/************************************************************************************ + +Filename : CAPI_HSWDisplay.cpp +Content : Implements Health and Safety Warning system. +Created : July 3, 2014 +Authors : Paul Pedriana + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#include "CAPI_HSWDisplay.h" +#include "CAPI_HMDState.h" +#include "../Kernel/OVR_Log.h" +#include "../Kernel/OVR_String.h" +#include "Textures/healthAndSafety.tga.h" // TGA file as a C array declaration. +#include + +//------------------------------------------------------------------------------------- +// ***** HSWDISPLAY_DEBUGGING +// +// Defined as 0 or 1. Enables debugging features of this module. + +#if !defined(HSWDISPLAY_DEBUGGING) + #if defined(AUTHOR_PPEDRIANA) + #define HSWDISPLAY_DEBUGGING 1 + #else + #define HSWDISPLAY_DEBUGGING 0 + #endif +#endif + +#if HSWDISPLAY_DEBUGGING + OVR_DISABLE_ALL_MSVC_WARNINGS() + #include + #include + OVR_RESTORE_ALL_MSVC_WARNINGS() +#endif + +OVR_DISABLE_MSVC_WARNING(4996) // "This function or variable may be unsafe..." + + +//------------------------------------------------------------------------------------- +// ***** HSWDISPLAY_DEFAULT_ENABLED +// +// Defined as 0 or 1. 1 is default. If 0 then by default HSWDisplay is disabled. +// Developers can set it to 0 to disable HSW display. +// +#if !defined(HSWDISPLAY_DEFAULT_ENABLED) + #define HSWDISPLAY_DEFAULT_ENABLED 1 +#endif + + + +//------------------------------------------------------------------------------------- +// ***** Experimental C API functions +// + +extern "C" +{ + OVR_EXPORT void ovrhmd_EnableHSWDisplaySDKRender(ovrHmd hmd, ovrBool enabled) + { + OVR::CAPI::HMDState* pHMDState = (OVR::CAPI::HMDState*)hmd->Handle; + + if (pHMDState) + { + OVR::CAPI::HSWDisplay* pHSWDisplay = pHMDState->pHSWDisplay; + + if(pHSWDisplay) + pHSWDisplay->EnableRender((enabled == 0) ? false : true); + } + } +} + + + + +//------------------------------------------------------------------------------------- +// ***** HSWDisplay implementation +// + +namespace OVR { namespace CAPI { + + +static const time_t HSWDisplayTimeNever = (time_t)0; // Constant which denotes the time of "never", as in the display has never been shown yet. + +#define HSWDISPLAY_POLL_INTERVAL 0.400 // Seconds between polling for whether the display should be shown. +#define OVR_KEY_HSWDISPLAYLASTDISPLAYEDTIME "HASWLastDisplayedTime" + + +#if defined(OVR_BUILD_DEBUG) + #define HSWDISPLAY_FIRST_DISMISSAL_TIME 4 // Earliest time in seconds until the user can dismiss the display. + #define HSWDISPLAY_REGULAR_DISMISSAL_TIME 2 +#else + #define HSWDISPLAY_FIRST_DISMISSAL_TIME 15 + #define HSWDISPLAY_REGULAR_DISMISSAL_TIME 6 +#endif + + +HSWDisplay::HSWDisplay(ovrRenderAPIType renderAPIType, ovrHmd hmd, const HMDRenderState& hmdRenderState) + : Enabled(HSWDISPLAY_DEFAULT_ENABLED ? true : false), + Displayed(false), + SDKRendered(false), + DismissRequested(false), + RenderEnabled(true), + UnloadGraphicsRequested(false), + StartTime(0.0), + DismissibleTime(0.0), + LastPollTime(0.0), + HMD(hmd), + HMDMounted(false), + HMDNewlyMounted(false), + RenderAPIType(renderAPIType), + RenderState(hmdRenderState), + LastProfileName(), + LastHSWTime(0) +{ +} + + +HSWDisplay::~HSWDisplay() +{ + // To consider: assert that we are already shut down. + HSWDisplay::Shutdown(); +} + + +void HSWDisplay::Enable(bool enable) +{ + Enabled = enable; + + if(!enable && Displayed) // If it's visible but should not be... + Dismiss(); +} + + +void HSWDisplay::EnableRender(bool enable) +{ + RenderEnabled = enable; +} + + +void HSWDisplay::Display() +{ + HSWDISPLAY_LOG(("[HSWDisplay] Display()")); + + DisplayInternal(); + + HMDNewlyMounted = false; + Displayed = true; + SDKRendered = RenderEnabled; + StartTime = ovr_GetTimeInSeconds(); + + const time_t lastDisplayedTime = HSWDisplay::GetCurrentProfileLastHSWTime(); + DismissibleTime = StartTime + ((lastDisplayedTime == HSWDisplayTimeNever) ? HSWDISPLAY_FIRST_DISMISSAL_TIME : HSWDISPLAY_REGULAR_DISMISSAL_TIME); + + SetCurrentProfileLastHSWTime(time(NULL)); +} + + +bool HSWDisplay::IsDisplayViewable() const +{ + // This function is called IsDisplayViewable, but currently it refers only to whether the + // HMD is mounted on the user's head. + + return HMDMounted; +} + + +bool HSWDisplay::Dismiss() +{ + #if HSWDISPLAY_DEBUGGING && defined(OVR_OS_WIN32) + if(GetKeyState(VK_SCROLL) & 0x0001) // If the scroll lock key is toggled on... + return false; // Make it so that the display doesn't dismiss, so we can debug this. + #endif + + // If dismissal is not requested yet, mark it as such. + bool newlyRequested = false; + + if(!DismissRequested) + { + DismissRequested = true; + newlyRequested = true; + } + + // If displayed and time has elapsed, do the dismissal. + OVR_ASSERT(DismissibleTime <= (ovr_GetTimeInSeconds() + HSWDISPLAY_FIRST_DISMISSAL_TIME)); // Make sure the dismissal time is sane. + if (Displayed && (ovr_GetTimeInSeconds() >= DismissibleTime)) + { + DismissInternal(); + Displayed = false; + DismissRequested = false; + SDKRendered = false; + return true; + } + + if(newlyRequested) + { HSWDISPLAY_LOG(("[HSWDisplay] Dismiss(): Not permitted yet. Queued for timeout in %.1f seconds.", DismissibleTime - ovr_GetTimeInSeconds())); } + + return false; // Cannot dismiss yet. +} + + +bool HSWDisplay::TickState(ovrHSWDisplayState *hswDisplayState, bool graphicsContext) +{ + bool newlyDisplayed = false; + const double currentTime = ovr_GetTimeInSeconds(); + + // See if we need to be currently displayed. By design we automatically display but don't automatically dismiss. + if (Displayed) + { + if (DismissRequested) // If dismiss was previously requested, see if it can be executed. + Dismiss(); + + if (Displayed) // If not already dismissed above... + { + // We currently have the debug behavior that we permit dismiss very soon after launch. + #if defined(OVR_BUILD_DEBUG) + if(currentTime >= (StartTime + 2)) + { + DismissibleTime = StartTime; + //Dismiss(); + } + #endif + } + + if (Displayed) // If not already dismissed above... + { + const ovrTrackingState ts = ((OVR::CAPI::HMDState*)HMD->Handle)->PredictedTrackingState(currentTime); + + if (ts.StatusFlags & ovrStatus_OrientationTracked) // If the Accelerometer data is valid... + { + const OVR::Vector3f v(ts.HeadPose.LinearAcceleration.x, ts.HeadPose.LinearAcceleration.y, ts.HeadPose.LinearAcceleration.z); + + const float minTapMagnitude = 350.0f; // Empirically determined by some testing. + + if (v.LengthSq() > minTapMagnitude) + Dismiss(); // This will do nothing if the display is not present. + } + } + } + else if (Enabled && (currentTime >= (LastPollTime + HSWDISPLAY_POLL_INTERVAL))) + { + LastPollTime = currentTime; + + // We need to display if any of the following are true: + // - The application is just started in Event Mode while the HMD is mounted (warning display would be viewable) and this app was not spawned from a launcher. + // - The current user has never seen the display yet while the HMD is mounted (warning display would be viewable). + // - The HMD is newly mounted (or the warning display is otherwise newly viewable). + // - The warning display hasn't shown in 24 hours (need to verify this as a requirement). + // Event Mode refers to when the app is being run in a public demo event such as a trade show. + + OVR::CAPI::HMDState* pHMDState = (OVR::CAPI::HMDState*)HMD->Handle; + + if(pHMDState) + { + const time_t lastDisplayedTime = HSWDisplay::GetCurrentProfileLastHSWTime(); + + // We currently unilaterally set HMDMounted to true because we don't yet have the ability to detect this. To do: Implement this when possible. + const bool previouslyMounted = HMDMounted; + HMDMounted = true; + HMDNewlyMounted = (!previouslyMounted && HMDMounted); // We set this back to false in the Display function or if the HMD is unmounted before then. + + if((lastDisplayedTime == HSWDisplayTimeNever) || HMDNewlyMounted) + { + if(IsDisplayViewable()) // If the HMD is mounted and otherwise being viewed by the user... + { + Display(); + newlyDisplayed = true; + } + } + } + } + else if(graphicsContext && UnloadGraphicsRequested) + { + UnloadGraphics(); + UnloadGraphicsRequested = false; + } + + if(hswDisplayState) + GetState(hswDisplayState); + + return newlyDisplayed; +} + + +void HSWDisplay::GetState(ovrHSWDisplayState *hswDisplayState) const +{ + // Return the state to the caller. + OVR_ASSERT(hswDisplayState != NULL); + if(hswDisplayState) + { + hswDisplayState->Displayed = Displayed; + hswDisplayState->StartTime = StartTime; + hswDisplayState->DismissibleTime = DismissibleTime; + } +} + + +void HSWDisplay::Render(ovrEyeType eye, const ovrTexture* eyeTexture) +{ + SDKRendered = true; + RenderInternal(eye, eyeTexture); +} + +// Persist the HSW settings on the server, since it needs to be synchronized across all applications. +// Note that the profile manager singleton cannot be used for this task because it overwrites the global +// settings for which the rift config tool is supposed to be authoritative. That also would step on the +// settings generated by other rift apps. The server settings, however, are synchronized for all apps +// and so are appropriate for this task. +static String getHSWTimeKey(const char* userName) +{ + String keyName = "server:"; + keyName += OVR_KEY_HSWDISPLAYLASTDISPLAYEDTIME; + keyName += ":"; + if (userName) + { + keyName += userName; + } + return keyName; +} + +// Returns HSWDisplayTimeNever (0) if there is no profile or this is the first time we are seeing this profile. +time_t HSWDisplay::GetCurrentProfileLastHSWTime() const +{ + // We store the timeout value in HMDState's pProfile. + HMDState* pHMDState = (HMDState*)HMD->Handle; + + if (pHMDState) + { + const char* profileName = pHMDState->pProfile ? pHMDState->pProfile->GetValue(OVR_KEY_USER) : NULL; + + if (profileName) + { + if (LastProfileName == profileName) + { + return LastHSWTime; + } + + LastProfileName = profileName; + String timeKey = getHSWTimeKey(profileName); + int lastTime = pHMDState->getIntValue(timeKey.ToCStr(), (int)HSWDisplayTimeNever); + + LastHSWTime = lastTime; + return lastTime; + } + } + + return HSWDisplayTimeNever; +} + +void HSWDisplay::SetCurrentProfileLastHSWTime(time_t t) +{ + // The timeout value is stored in HMDState's pProfile. + HMDState* pHMDState = (HMDState*)HMD->Handle; + + if (pHMDState) + { + const char* profileName = pHMDState->pProfile ? pHMDState->pProfile->GetValue(OVR_KEY_USER) : NULL; + + if (profileName) + { + LastProfileName = profileName; + LastHSWTime = (int)t; + + String timeKey = getHSWTimeKey(profileName); + pHMDState->setIntValue(timeKey.ToCStr(), (int)t); + } + } +} + + +// Generates an appropriate stereo ortho projection matrix. +void HSWDisplay::GetOrthoProjection(const HMDRenderState& RenderState, Matrix4f OrthoProjection[2]) +{ + Matrix4f perspectiveProjection[2]; + perspectiveProjection[0] = ovrMatrix4f_Projection(RenderState.EyeRenderDesc[0].Fov, 0.01f, 10000.f, true); + perspectiveProjection[1] = ovrMatrix4f_Projection(RenderState.EyeRenderDesc[1].Fov, 0.01f, 10000.f, true); + + const float orthoDistance = HSWDISPLAY_DISTANCE; // This is meters from the camera (viewer) that we place the ortho plane. + const Vector2f orthoScale0 = Vector2f(1.f) / Vector2f(RenderState.EyeRenderDesc[0].PixelsPerTanAngleAtCenter); + const Vector2f orthoScale1 = Vector2f(1.f) / Vector2f(RenderState.EyeRenderDesc[1].PixelsPerTanAngleAtCenter); + + OrthoProjection[0] = ovrMatrix4f_OrthoSubProjection(perspectiveProjection[0], orthoScale0, orthoDistance, RenderState.EyeRenderDesc[0].HmdToEyeViewOffset.x); + OrthoProjection[1] = ovrMatrix4f_OrthoSubProjection(perspectiveProjection[1], orthoScale1, orthoDistance, RenderState.EyeRenderDesc[1].HmdToEyeViewOffset.x); +} + + +const uint8_t* HSWDisplay::GetDefaultTexture(size_t& TextureSize) +{ + TextureSize = sizeof(healthAndSafety_tga); + return healthAndSafety_tga; +} + + + +}} // namespace OVR::CAPI + + + + +//------------------------------------------------------------------------------------- +// ***** HSWDisplay factory +// + +#if defined (OVR_OS_WIN32) + #define OVR_D3D_VERSION 9 + #include "D3D9/CAPI_D3D9_HSWDisplay.h" + #undef OVR_D3D_VERSION + + #define OVR_D3D_VERSION 10 + #include "D3D1X/CAPI_D3D10_HSWDisplay.h" + #undef OVR_D3D_VERSION + + #define OVR_D3D_VERSION 11 + #include "D3D1X/CAPI_D3D11_HSWDisplay.h" + #undef OVR_D3D_VERSION +#endif + +#include "GL/CAPI_GL_HSWDisplay.h" + + +OVR::CAPI::HSWDisplay* OVR::CAPI::HSWDisplay::Factory(ovrRenderAPIType apiType, ovrHmd hmd, const OVR::CAPI::HMDRenderState& renderState) +{ + OVR::CAPI::HSWDisplay* pHSWDisplay = NULL; + + switch (apiType) + { + case ovrRenderAPI_None: + pHSWDisplay = new OVR::CAPI::HSWDisplay(apiType, hmd, renderState); + break; + + case ovrRenderAPI_OpenGL: + pHSWDisplay = new OVR::CAPI::GL::HSWDisplay(apiType, hmd, renderState); + break; + + #if defined(OVR_OS_WIN32) + case ovrRenderAPI_D3D9: + pHSWDisplay = new OVR::CAPI::D3D9::HSWDisplay(apiType, hmd, renderState); + break; + + case ovrRenderAPI_D3D10: + pHSWDisplay = new OVR::CAPI::D3D10::HSWDisplay(apiType, hmd, renderState); + break; + + case ovrRenderAPI_D3D11: + pHSWDisplay = new OVR::CAPI::D3D11::HSWDisplay(apiType, hmd, renderState); + break; + #else + case ovrRenderAPI_D3D9: + case ovrRenderAPI_D3D10: + case ovrRenderAPI_D3D11: // Fall through + #endif + + // Handle unsupported cases. + case ovrRenderAPI_Android_GLES: + case ovrRenderAPI_Count: // This is not actually a type. + default: + break; + } + + return pHSWDisplay; +} + + + + + diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/CAPI/CAPI_HSWDisplay.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/CAPI/CAPI_HSWDisplay.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,249 @@ +/************************************************************************************ + +Filename : CAPI_HSWDisplay.h +Content : Implements Health and Safety Warning system. +Created : July 3, 2014 +Authors : Paul Pedriana + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#ifndef OVR_CAPI_HSWDisplay_h +#define OVR_CAPI_HSWDisplay_h + +#include "../OVR_CAPI.h" +#include "CAPI_HMDRenderState.h" +#include + + + +//------------------------------------------------------------------------------------- +// ***** HSWDISPLAY_LOG +// +// Debug log wrapper. + +#if !defined(HSWDISPLAY_LOG_ENABLED) + #ifdef OVR_BUILD_DEBUG + #define HSWDISPLAY_LOG_ENABLED 1 + #else + #define HSWDISPLAY_LOG_ENABLED 0 + #endif +#endif + +#if HSWDISPLAY_LOG_ENABLED + #define HSWDISPLAY_LOG(...) OVR_DEBUG_LOG(__VA_ARGS__) +#else + #define HSWDISPLAY_LOG(...) +#endif + + +//------------------------------------------------------------------------------------- +// ***** HSWDISPLAY_DISTANCE +// +// Floating point value in the range of ~0.75 to ~3.0 which controls the distance +// (in meters) of the display from the viewer. + +#ifndef HSWDISPLAY_DISTANCE + #define HSWDISPLAY_DISTANCE 1.5f +#endif + + +//------------------------------------------------------------------------------------- +// ***** HSWDISPLAY_SCALE +// +// Floating point value in the range of ~0.1 to ~2.0 which controls the size scale of the +// SDK-rendered HSW display. The value is an arbitrary relative value, though this may +// change in future SDK versions. + +#ifndef HSWDISPLAY_SCALE + #define HSWDISPLAY_SCALE 0.92f +#endif + + + + +//------------------------------------------------------------------------------------- +// ***** Experimental C API functions +// +// These are currently not formally supported and may be promoted to the formal C API +// or may be removed in the future. + +extern "C" +{ + // Normally if an application uses SDK-based distortion rendering + // (ovrHmd_BeginFrame / ovrHmd_EndFrame) then the SDK also takes care of + // drawing the health and safety warning. If an application is using + // SDK-based rendering but wants to draw the warning display itself, + // it call this function with enabled set to false. + OVR_EXPORT void ovrhmd_EnableHSWDisplaySDKRender(ovrHmd hmd, ovrBool enabled); +} + + +namespace OVR { namespace CAPI { + + +//------------------------------------------------------------------------------------- +// ***** CAPI::HSWDisplay +// +// Note: This will be renamed to HSWDisplay in the future. +// +// Implements the logic for the Health and Safety (HAS) warning display. Primarily this +// is two things: providing information about whether the warning needs to be currently +// displayed, and implementing the display itself. +// +// An HSWDisplay is associated 1:1 with an HMD. There can be at most one HSWDisplay +// being displayed on an HMD at a time. If a warning needs to be displayed while an +// existing one is present, it replaces the existing one. +// +// Notes +// Warnings are displayed per HMD (head mounted display). +// The app can have multiple HMDs. +// There can be multiple users of a given HMD over time, with each identified by a different user profile. +// There can be multiple apps using HMDs. +// +// Shows upon first entering a VR application (or VR mode in an application) when in Event Mode (e.g. trade show). +// Shows upon each wearing of the HMD. +// If the user profile is switched while display is active, the display must restart. +// Doesn't show in app when app was started by a launcher app. +// +// First display ever (per profile): 15 seconds until the display can be dismissed. +// Subsequent displays: 6 seconds until the display can be dismissed. Per profile. +// Dismissing occurs via HMD tap, designated keypress, gaze detection on OK button for N seconds, +// and possibly via an input gesture in the future. +// +// If the warning fades out upon completion, the fade out should begin after the full display time has elapsed, +// but it needs to avoid interfering (e.g. obscuring) with the application. This likely means the application +// would need to put in a couple seconds delay to allow the fade to complete. +// Ideally we'd handle the case of a user switching HMDs and not needing to see the warning again. + +class HSWDisplay : public RefCountBase +{ +public: + HSWDisplay(ovrRenderAPIType api, ovrHmd hmd, const HMDRenderState& renderState); + + virtual ~HSWDisplay(); + + // Must be called after construction and before use. + virtual bool Initialize(const ovrRenderAPIConfig*) + { return true; } + + // Must be called before destruction. + virtual void Shutdown() {} + + // Enables or disables the HSW display system. It may be disabled only for development uses. + // It is enabled by default. + void Enable(bool enable); + + // Enables or disables our internal rendering when Render is called. If set to false then the + // application is expected to implement drawing of the display when Displayed is true. + // It is enabled by default. + void EnableRender(bool enable); + + // Triggers a display of the HSW display for the associated HMD. Restarts the display if + // the warning is already being displayed. + void Display(); + + // This function should be called per HMD every frame in order to give this class processing time. + // Writes the new state to newHSWDisplayState if it's non-NULL. + // The graphicsContext argument indicates if the Tick is occurring within a graphics context and + // thus if graphics operations are allowed during the TickState call. + // Returns true if the new state results in a required warning display (ovrHSWDisplayState::Displayed became true). + bool TickState(ovrHSWDisplayState *newHSWDisplayState = NULL, bool graphicsContext = false); + + // Gets the current state of the HSW display. + // Corresponds to ovrhmd_GetHSWDisplayState. + void GetState(ovrHSWDisplayState *hasWarningState) const; + + // Removes the HSW display display if the minimum dismissal time has occurred. + // Returns true if the warning display could be dissmissed or was not displayed at the time of the call. + // Corresponds to ovrhmd_DismissHSWDisplay. + bool Dismiss(); + + // Returns true if the HMD appears to be currently mounted and in a state that a + // warning display would be viewable. + bool IsDisplayViewable() const; + + // Draws the warning to the eye texture(s). This must be done at the end of a + // frame but prior to executing the distortion rendering of the eye textures. + virtual void Render(ovrEyeType, const ovrTexture*); + + // Resets the current profile's HAS settings (e.g. to act as if the user has never seen the HSW display before). + void ResetProfileData(); + + // Returns the ovrRenderAPIType. This is essentially the same as RTTI, as it's indicating what subclass + // is being used for this. + ovrRenderAPIType GetRenderAPIType() const // e.g. ovrRenderAPI_D3D11 + { return RenderAPIType; } + + // Returns the required HSW display text for the current profile's locale. + // Useful for implementing custom warning displays. Returns the required strlen + // of the text, and thus success is indicated by a return value < strCapacity. + // size_t GetText(char *str, size_t strCapacity); + + // Creates and constructs an instance of an HSWDisplay subclass based on the API type. + static HSWDisplay* Factory(ovrRenderAPIType apiType, ovrHmd hmd, const HMDRenderState& renderState); + +private: + OVR_NON_COPYABLE(HSWDisplay) + +protected: + virtual void DisplayInternal() {} + virtual void DismissInternal() {} + virtual void RenderInternal(ovrEyeType, const ovrTexture*) {} + virtual void UnloadGraphics() {} + virtual void LoadGraphics() {} + + // Profile functionality + time_t GetCurrentProfileLastHSWTime() const; + void SetCurrentProfileLastHSWTime(time_t t); + + // Generates an appropriate stereo ortho projection matrix. + static void GetOrthoProjection(const HMDRenderState& RenderState, Matrix4f OrthoProjection[2]); + + // Returns the default HSW display texture data. + static const uint8_t* GetDefaultTexture(size_t& TextureSize); + +protected: + bool Enabled; // If true then the HSW display system is enabled. True by default. + bool Displayed; // If true then the warning is currently visible and the following variables have meaning. Else there is no warning being displayed for this application on the given HMD. + bool SDKRendered; // If true then the display is being rendered by the SDK as opposed to the application. + bool DismissRequested; // If true then the warning has been requested to be hidden. + bool RenderEnabled; // If true then we handle rendering when Render is called. Else we skip it and assume the application is otherwise handling it itself. + bool UnloadGraphicsRequested; // If true then an unload of graphics was requested. This acts as a message from the main thread to the drawing thread so that the unload happens in the expected thread. + double StartTime; // Absolute time when the warning was first displayed. See ovr_GetTimeInSeconds(). + double DismissibleTime; // Absolute time when the warning can be dismissed. + double LastPollTime; // Used to prevent us from polling the required display state every frame but rather more like every 200 milliseconds. + const ovrHmd HMD; // The HMDState this HSWDisplay instance corresponds to. + mutable bool HMDMounted; // True if the HMD was most recently found to be mounted. We need this in order to maintain HMDNewlyMounted. + mutable bool HMDNewlyMounted; // True if HMDMounted has transitioned from false to true. We need this in order to tell if the HMD was recently mounted so we can display the HSW display. + const ovrRenderAPIType RenderAPIType; // e.g. ovrRenderAPI_D3D11 + const HMDRenderState& RenderState; // Information about the rendering setup. + + // Settings cache + mutable String LastProfileName; + mutable int LastHSWTime; + +}; // class HSWDisplay + + + +}} // namespace OVR::CAPI + + +#endif // OVR_CAPI_HSWDisplay_h diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/CAPI/CAPI_LatencyStatistics.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/CAPI/CAPI_LatencyStatistics.cpp Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,316 @@ +/************************************************************************************ + +Filename : CAPI_LatencyStatistics.cpp +Content : Record latency statistics during rendering +Created : Sept 23, 2014 +Authors : Chris Taylor, Kevin Jenkins + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#include "CAPI_LatencyStatistics.h" + +#include "../Kernel/OVR_Log.h" +#include "../Kernel/OVR_Threads.h" +#include "../Util/Util_SystemInfo.h" + +namespace OVR { namespace CAPI { + +//----------------------------------------------------------------------------- +// ***** LatencyStatisticsObserver + +LatencyStatisticsCSV::LatencyStatisticsCSV() +{ +} + +LatencyStatisticsCSV::~LatencyStatisticsCSV() +{ + Stop(); +} + +bool LatencyStatisticsCSV::Start(String fileName, String userData1) +{ + if (_File.IsValid()) + { + if (fileName == FileName) + { + UserData1 = userData1; + return true; + } + else + { + Stop(); + } + } + + OVR::String basePath = OVR::GetBaseOVRPath(true); + OVR::String path = basePath; + path.AppendString("\\"); + path.AppendString(fileName); + OS = OVR::Util::OSAsString(); + OSVersion = OVR::Util::OSVersionAsString(); +#if defined (OVR_OS_WIN64) || defined (OVR_OS_WIN32) + ProcessInfo = OVR::Util::GetProcessInfo(); + DisplayDriverVersion = OVR::Util::GetDisplayDriverVersion(); + CameraDriverVersion = OVR::Util::GetCameraDriverVersion(); + OVR::Array< OVR::String > gpus; + OVR::Util::GetGraphicsCardList(gpus); + StringBuffer sb; + size_t gpuIdx; + for (gpuIdx = 0; gpuIdx < gpus.GetSize(); gpuIdx++) + { + sb.AppendString(gpus[gpuIdx]); + if (gpuIdx + 1 < gpus.GetSize()) + sb.AppendString("; "); + } + GPUVersion = sb; +#endif + Guid = OVR::Util::GetGuidString(); + + if (!_File.Open(path, OVR::File::Open_Write, OVR::File::Mode_Write)) + { + _File.Create(path, OVR::File::Mode_Write); + WriteHeaderV1(); + } + else + { + _File.Seek(0, FileConstants::Seek_End); + } + + if (_File.IsValid()) + { + UserData1 = userData1; + FileName = fileName; + _Observer.SetHandler(LatencyStatisticsSlot::FromMember(this)); + + return true; + } + + return false; +} +bool LatencyStatisticsCSV::Stop() +{ + if (_File.IsValid()) + { + _File.Flush(); + _File.Close(); + _Observer.ReleaseAll(); + + Guid.Clear(); + FileName.Clear(); + return true; + } + return false; +} +void LatencyStatisticsCSV::WriteHeaderV1() +{ + if (_File.IsValid()) + { + // Write header if creating the file + const char *str = "GUID,OS,OSVersion,Process,DisplayDriver,CameraDriver,GPU,Time,Interval,FPS,EndFrameExecutionTime,LatencyRender,LatencyTimewarp,LatencyPostPresent,LatencyVisionProc,LatencyVisionFrame,UserData1\n"; + _File.Write((const uint8_t *) str, (int)OVR_strlen(str)); + } +} + +void LatencyStatisticsCSV::WriteResultsV1(LatencyStatisticsResults *results) +{ + if (_File.IsValid()) + { + char str[512]; + OVR_sprintf(str, sizeof(str), + "%s,%s,%s,%s,%s,%s,%s,%f,%f,%f,%f,%f,%f,%f,%f,%f,%s\n", + Guid.ToCStr(), + OS.ToCStr(), + OSVersion.ToCStr(), + ProcessInfo.ToCStr(), + DisplayDriverVersion.ToCStr(), + CameraDriverVersion.ToCStr(), + GPUVersion.ToCStr(), + ovr_GetTimeInSeconds(), + results->IntervalSeconds, + results->FPS, + results->EndFrameExecutionTime, + results->LatencyRender, + results->LatencyTimewarp, + results->LatencyPostPresent, + results->LatencyVisionProc, + results->LatencyVisionFrame, + UserData1.ToCStr()); + str[sizeof(str)-1] = 0; + _File.Write((const uint8_t *)str, (int)OVR_strlen(str)); + } +} +void LatencyStatisticsCSV::OnResults(LatencyStatisticsResults *results) +{ + WriteResultsV1(results); +} +//------------------------------------------------------------------------------------- +// ***** LatencyStatisticsCalculator + +LagStatsCalculator::LagStatsCalculator() +{ + resetPerfStats(); +} + +void LagStatsCalculator::resetPerfStats(double resetTime) +{ + EndFrameStartTime = 0.; + EndFrameEndTime = 0.; + + LastCameraFrameCounter = ~(uint32_t)0; + + EpochBegin = resetTime; // Set epoch start to now + + FrameCount = 0; + //EndFrameSum = 0.; + + //VisionProcSum = 0.; + //VisionLagSum = 0.; + VisionFrames = 0; + + //for (int i = 0; i < 3; ++i) + //{ + // LatencyData[i] = 0.f; + // LatencySum[i] = 0.; + //} + + latencyStatisticsData.EndFrameExecutionTime = 0; + latencyStatisticsData.LatencyRender = 0; + latencyStatisticsData.LatencyTimewarp = 0; + latencyStatisticsData.LatencyPostPresent = 0; + latencyStatisticsData.LatencyVisionProc = 0; + latencyStatisticsData.LatencyVisionFrame = 0; +} + +void LagStatsCalculator::GetLatestResults(LatencyStatisticsResults* results) +{ + *results = Results.GetState(); +} +void LagStatsCalculator::AddResultsObserver(ObserverScope *calculateResultsObserver) +{ + Lock::Locker locker(&calculateResultsLock); + calculateResultsObserver->GetPtr()->Observe(calculateResultsSubject); +} +void LagStatsCalculator::InstrumentEndFrameStart(double timestamp) +{ + EndFrameStartTime = timestamp; +} + +void LagStatsCalculator::InstrumentLatencyTimings(FrameTimeManager& ftm) +{ + //latencies[0] = (float)RenderLatencySeconds; + //latencies[1] = (float)TimewarpLatencySeconds; + //latencies[2] = (float)FrameDeltas.GetMedianTimeDelta(); + + // Note: This assumes that it is called right before InstrumentEndFrameEnd() + float latencyRender, latencyTimewarp, latencyPostPresent; + ftm.GetLatencyTimings(latencyRender, latencyTimewarp, latencyPostPresent); + latencyStatisticsData.LatencyRender += latencyRender; + latencyStatisticsData.LatencyTimewarp += latencyTimewarp; + latencyStatisticsData.LatencyPostPresent += latencyPostPresent; +} + +void LagStatsCalculator::InstrumentEndFrameEnd(double timestamp) +{ + EndFrameEndTime = timestamp; + + calculateResults(); +} + +void LagStatsCalculator::InstrumentEyePose(const ovrTrackingState& state) +{ + // If the camera frame counter has rolled, + if (LastCameraFrameCounter != state.LastCameraFrameCounter) + { + // Accumulate eye pose data + if (state.StatusFlags != 0) + { + latencyStatisticsData.LatencyVisionProc += state.LastVisionProcessingTime; + latencyStatisticsData.LatencyVisionFrame += state.LastVisionFrameLatency; + } + ++VisionFrames; + + LastCameraFrameCounter = state.LastCameraFrameCounter; + } +} + +// Note: Currently assumes this is being called from OnEndFrameEnd() above. +void LagStatsCalculator::calculateResults() +{ + // Calculate time in the current epoch so far + double intervalDuration = EndFrameEndTime - EpochBegin; + + // If stats should be reset due to inactivity, + if (intervalDuration >= OVR_LAG_STATS_RESET_LIMIT) + { + resetPerfStats(EndFrameEndTime); + return; + } + + // Calculate EndFrame() duration + double endFrameDuration = EndFrameEndTime - EndFrameStartTime; + + // Incorporate EndFrame() duration into the running sum + latencyStatisticsData.EndFrameExecutionTime += endFrameDuration; + + //for (int i = 0; i < 3; ++i) + //{ + // LatencySum[i] += LatencyData[i]; + //} + + // Increment frame counter + ++FrameCount; + + // If enough time has passed, + if (intervalDuration >= OVR_LAG_STATS_EPOCH) + { + LatencyStatisticsResults results; + + float invFrameCount = 1.0f / (float) FrameCount; + + // EndFrame() instrumentation + results.IntervalSeconds = intervalDuration; + results.FPS = FrameCount / intervalDuration; + results.EndFrameExecutionTime = latencyStatisticsData.EndFrameExecutionTime * invFrameCount; + + // Latency data + results.LatencyRender = latencyStatisticsData.LatencyRender * invFrameCount; + results.LatencyTimewarp = latencyStatisticsData.LatencyTimewarp * invFrameCount; + results.LatencyPostPresent = latencyStatisticsData.LatencyPostPresent * invFrameCount; + + double invVisionFrameCount = 1. / VisionFrames; + + // Eye pose instrumentation + results.LatencyVisionProc = latencyStatisticsData.LatencyVisionProc * invVisionFrameCount; + results.LatencyVisionFrame = latencyStatisticsData.LatencyVisionFrame * invVisionFrameCount; + + Results.SetState(results); + + { + Lock::Locker locker(&calculateResultsLock); + calculateResultsSubject.GetPtr()->Call(&results); + } + + // Reset for next frame + resetPerfStats(); + } +} + + +}} // namespace OVR::CAPI diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/CAPI/CAPI_LatencyStatistics.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/CAPI/CAPI_LatencyStatistics.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,178 @@ +/************************************************************************************ + +Filename : CAPI_LatencyStatistics.h +Content : Record latency statistics during rendering +Created : Sept 23, 2014 +Authors : Chris Taylor, Kevin Jenkins + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#ifndef OVR_CAPI_LatencyStatistics_h +#define OVR_CAPI_LatencyStatistics_h + +#include "../OVR_CAPI.h" +#include "../Kernel/OVR_Timer.h" +#include "../Kernel/OVR_Lockless.h" +#include "../Kernel/OVR_SysFile.h" +#include "CAPI_FrameTimeManager.h" + +namespace OVR { namespace CAPI { + + +// Define epoch period for lag statistics +#define OVR_LAG_STATS_EPOCH 1.0 /* seconds */ +// Define seconds without frames before resetting stats +#define OVR_LAG_STATS_RESET_LIMIT 2.0 /* seconds */ + + +//------------------------------------------------------------------------------------- +// ***** LatencyStatisticsResults + +// Results from statistics collection +struct LatencyStatisticsResults +{ + // Number of seconds of data represented by these statistics. + double IntervalSeconds; + + // Frames per second during the epoch. + double FPS; + + // Measures average time for EndFrame() call over each of the frames. + double EndFrameExecutionTime; + + // Measures the time between first scanline and first pose request before app starts rendering eyes. + float LatencyRender; + + // Measures the time between first scanline and distortion/timewarp rendering. + float LatencyTimewarp; + + // Time between Present() call and photon emission from first scanline of screen + float LatencyPostPresent; + + // Measures the time from receiving the camera frame until vision CPU processing completes. + double LatencyVisionProc; + + // Measures the time from exposure until the pose is available for the frame, including processing time. + double LatencyVisionFrame; +}; + +//----------------------------------------------------------------------------- +typedef Delegate1 LatencyStatisticsSlot; + +// ***** LatencyStatisticsObserver +class LatencyStatisticsCSV +{ +public: + LatencyStatisticsCSV(); + ~LatencyStatisticsCSV(); + bool Start(String fileName, String userData1); + bool Stop(); + void OnResults(LatencyStatisticsResults *results); + + // Internal + void WriteHeaderV1(); + void WriteResultsV1(LatencyStatisticsResults *results); + ObserverScope* GetObserver() { return &_Observer; } + +protected: + ObserverScope _Observer; + String Guid, UserData1; + String FileName; + OVR::SysFile _File; + String OS, OSVersion, ProcessInfo, DisplayDriverVersion, CameraDriverVersion, GPUVersion; +}; + +//----------------------------------------------------------------------------- +// ***** LatencyStatisticsCalculator + +// Calculator for latency statistics +class LagStatsCalculator +{ + // Statistics instrumentation inputs: + + // Timestamp when the EndFrame() call started executing + double EndFrameStartTime; + // Timestamp when the EndFrame() call finished executing + double EndFrameEndTime; + + // Latency statistics for the epoch + LatencyStatisticsResults latencyStatisticsData; + + // Last latency data + // float LatencyData[3]; // render, timewarp, median post-present + + // Last vision processing frame counter number + uint32_t LastCameraFrameCounter; + + // Running statistics: + + void resetPerfStats(double resetTime = 0.); + + // Start of the current statistics epoch + double EpochBegin; + // Count of frames in this stats epoch, measured at EndFrame() + int FrameCount; + // Sum of end frame durations for this stats epoch + //double EndFrameSum; + + // Sum of latencies + // double LatencySum[3]; + + // Sum of vision processing times + //double VisionProcSum; + // Sum of vision latency times + //double VisionLagSum; + // Count of vision frames + int VisionFrames; + + // Statistics results: + + LocklessUpdater Results; + + void calculateResults(); + + OVR::ObserverScope calculateResultsSubject; + OVR::Lock calculateResultsLock; + +public: + LagStatsCalculator(); + + void GetLatestResults(LatencyStatisticsResults* results); + void AddResultsObserver(ObserverScope *calculateResultsObserver); + +public: + // Internal instrumentation interface: + + // EndFrame() instrumentation + void InstrumentEndFrameStart(double timestamp); + void InstrumentEndFrameEnd(double timestamp); + + // DK2 latency tester instrumentation + // Note: This assumes that it is called right before InstrumentEndFrameEnd() + void InstrumentLatencyTimings(FrameTimeManager& ftm); + + // Eye pose instrumentation + void InstrumentEyePose(const ovrTrackingState& state); +}; + + +}} // namespace OVR::CAPI + +#endif // OVR_CAPI_LatencyStatistics_h diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/CAPI/GL/CAPI_GLE.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/CAPI/GL/CAPI_GLE.cpp Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,7884 @@ +/************************************************************************************ + +Filename : Render_GLE.cpp +Content : OpenGL Extensions support. Implements a stripped down glew-like + interface with some additional functionality. +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#include "CAPI_GLE.h" +#include "../../Kernel/OVR_Log.h" +#include + + +#if defined(_WIN32) + #if !defined(WINAPI) + #ifndef WIN32_LEAN_AND_MEAN + #define WIN32_LEAN_AND_MEAN 1 + #endif + #include + #endif + + #pragma comment(lib, "opengl32.lib") +#elif defined(__APPLE__) + #include + #include + #include + #include +#endif + + + +//namespace OVR +//{ + // OVRTypeof + // Acts the same as the C++11 decltype expression, though with reduced requirements. + #if !defined(OVRTypeof) + #if defined(_MSC_VER) + #define OVRTypeof(x) decltype(x) // VS2010+ unilaterally supports decltype + #else + #define OVRTypeof(x) __typeof__(x) // Other compilers support decltype, but usually not unless C++11 support is present and explicitly enabled. + #endif + #endif + + + // GLELoadProc + // Macro which implements dynamically looking up and assigning an OpenGL function. + // + // Example usage: + // GLELoadProc(glCopyTexSubImage3D, glCopyTexSubImage3D); + // Expands to: + // gleCopyTexSubImage3D = (OVRTypeof(gleCopyTexSubImage3D)) GLEGetProcAddress("glCopyTexSubImage3D"); + + #define GLELoadProc(var, name) var = (OVRTypeof(var))GLEGetProcAddress(#name) + + + // Disable some #defines, as we need to call these functions directly. + #if defined(GLE_HOOKING_ENABLED) + #if defined(_WIN32) + #undef wglGetProcAddress + extern "C" { GLAPI PROC GLAPIENTRY wglGetProcAddress(LPCSTR lpszProc); } + #endif + + #undef glGetString + extern "C" { GLAPI const GLubyte * GLAPIENTRY glGetString(GLenum name); } + #endif + + + // Generic OpenGL GetProcAddress function interface. Maps to platform-specific functionality + // internally. On Windows this is equivalent to wglGetProcAddress as opposed to global GetProcAddress. + void* OVR::GLEGetProcAddress(const char* name) + { + #if defined(_WIN32) + return wglGetProcAddress(name); + + #elif defined(__APPLE__) + // Requires the OS 10.3 SDK or later. + static void* dlImage = NULL; + void* addr = nullptr; + + if(!dlImage) + dlImage = dlopen("/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL", RTLD_LAZY); + + if(dlImage) + addr = dlsym(dlImage, name); + + return addr; + + #elif defined(__ANDROID__) + return eglGetProcAddress(name); + + #else + // This was glXGetProcAddressARB in GLX versions prior to v1.4, but that was ten years ago. + return (void*)glXGetProcAddress((const GLubyte*)name); + #endif + } + + + + // Current context functionality + static OVR::GLEContext* GLECurrentContext = NULL; + + OVR::GLEContext* OVR::GLEContext::GetCurrentContext() + { + return GLECurrentContext; + } + + void OVR::GLEContext::SetCurrentContext(OVR::GLEContext* p) + { + GLECurrentContext = p; + } + + + + OVR::GLEContext::GLEContext() + : MajorVersion(0) + , MinorVersion(0) + , WholeVersion(0) + , IsGLES(false) + , IsCoreProfile(false) + , EnableHookGetError(true) + , PlatformMajorVersion(0) + , PlatformMinorVersion(0) + , PlatformWholeVersion(0) + { + // The following sequence is not thread-safe. Two threads could set the context to this at the same time. + if(GetCurrentContext() == NULL) + SetCurrentContext(this); + } + + + OVR::GLEContext::~GLEContext() + { + // Currently empty + } + + + void OVR::GLEContext::Init() + { + PlatformInit(); + + if(!IsInitialized()) + { + InitVersion(); + InitExtensionLoad(); + InitExtensionSupport(); + } + } + + + bool OVR::GLEContext::IsInitialized() const + { + return (MajorVersion != 0); + } + + + void OVR::GLEContext::Shutdown() + { + // This memset is valid only if this class has no virtual functions (similar to concept of POD). + // We cannot assert this because restrictions prevent us from using C++11 type traits here. + memset(this, 0, sizeof(GLEContext)); + } + + + void OVR::GLEContext::PlatformInit() + { + if(!IsPlatformInitialized()) + { + InitPlatformExtensionLoad(); + InitPlatformExtensionSupport(); + InitPlatformVersion(); + } + } + + + bool OVR::GLEContext::IsPlatformInitialized() const + { + return (PlatformMajorVersion != 0); + } + + + void OVR::GLEContext::InitVersion() + { + const char* version = (const char*)glGetString(GL_VERSION); + int fields = 0, major = 0, minor = 0; + bool isGLES = false; + + OVR_ASSERT(version); + if (version) + { + OVR_DEBUG_LOG(("GL_VERSION: %s", (const char*)version)); + + // Skip all leading non-digits before reading %d. + // Example GL_VERSION strings: + // "1.5 ATI-1.4.18" + // "OpenGL ES-CM 3.2" + OVR_DISABLE_MSVC_WARNING(4996) // "scanf may be unsafe" + fields = sscanf(version, isdigit(*version) ? "%d.%d" : "%*[^0-9]%d.%d", &major, &minor); + isGLES = (strstr(version, "OpenGL ES") != NULL); + OVR_RESTORE_MSVC_WARNING() + } + else + { + LogText("Warning: GL_VERSION was NULL\n"); + } + + // If two fields were not found, + if (fields != 2) + { + static_assert(sizeof(major) == sizeof(GLint), "type mis-match"); + + glGetIntegerv(GL_MAJOR_VERSION, &major); + glGetIntegerv(GL_MINOR_VERSION, &minor); + } + + // Write version data + MajorVersion = major; + MinorVersion = minor; + WholeVersion = (major * 100) + minor; + + GLint profileMask = 0; + if(WholeVersion >= 302) + { + // Older NVidia drivers have a bug with this on at least Windows. + // https://www.opengl.org/discussion_boards/showthread.php/171380-NVIDIA-drivers-not-returning-the-right-profile-mas + // A workaround could be to check for the GL_ARB_compatibility extension, which indicates if OpenGL is in compatibility mode, + // and if not then we are in core profile mode. On Apple another solution would be to use NSOpeNGLPixelFormat + // NSOpenGLView::pixelFormat to get the core profile attribute. + glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &profileMask); + } + IsCoreProfile = (profileMask == GL_CONTEXT_CORE_PROFILE_BIT); // There's also GL_CONTEXT_COMPATIBILITY_PROFILE_BIT + IsGLES = isGLES; + } + + + void OVR::GLEContext::InitExtensionLoad() + { + // GL_VERSION_1_1 + // We don't load these but rather link to them directly. + + // GL_VERSION_1_2 + GLELoadProc(glCopyTexSubImage3D_Impl, glCopyTexSubImage3D); // This expands to a get proc address call (e.g. wglGetProcAddress on Windows). + GLELoadProc(glDrawRangeElements_Impl, glDrawRangeElements); + GLELoadProc(glTexImage3D_Impl, glTexImage3D); + GLELoadProc(glTexSubImage3D_Impl, glTexSubImage3D); + + // GL_VERSION_1_3 + GLELoadProc(glActiveTexture_Impl, glActiveTexture); + GLELoadProc(glClientActiveTexture_Impl, glClientActiveTexture); + GLELoadProc(glCompressedTexImage1D_Impl, glCompressedTexImage1D); + GLELoadProc(glCompressedTexImage2D_Impl, glCompressedTexImage2D); + GLELoadProc(glCompressedTexImage3D_Impl, glCompressedTexImage3D); + GLELoadProc(glCompressedTexSubImage1D_Impl, glCompressedTexSubImage1D); + GLELoadProc(glCompressedTexSubImage2D_Impl, glCompressedTexSubImage2D); + GLELoadProc(glCompressedTexSubImage3D_Impl, glCompressedTexSubImage3D); + GLELoadProc(glGetCompressedTexImage_Impl, glGetCompressedTexImage); + GLELoadProc(glLoadTransposeMatrixd_Impl, glLoadTransposeMatrixd); + GLELoadProc(glLoadTransposeMatrixf_Impl, glLoadTransposeMatrixf); + GLELoadProc(glMultTransposeMatrixd_Impl, glMultTransposeMatrixd); + GLELoadProc(glMultTransposeMatrixf_Impl, glMultTransposeMatrixf); + GLELoadProc(glMultiTexCoord1d_Impl, glMultiTexCoord1d); + GLELoadProc(glMultiTexCoord1dv_Impl, glMultiTexCoord1dv); + GLELoadProc(glMultiTexCoord1f_Impl, glMultiTexCoord1f); + GLELoadProc(glMultiTexCoord1fv_Impl, glMultiTexCoord1fv); + GLELoadProc(glMultiTexCoord1i_Impl, glMultiTexCoord1i); + GLELoadProc(glMultiTexCoord1iv_Impl, glMultiTexCoord1iv); + GLELoadProc(glMultiTexCoord1s_Impl, glMultiTexCoord1s); + GLELoadProc(glMultiTexCoord1sv_Impl, glMultiTexCoord1sv); + GLELoadProc(glMultiTexCoord2d_Impl, glMultiTexCoord2d); + GLELoadProc(glMultiTexCoord2dv_Impl, glMultiTexCoord2dv); + GLELoadProc(glMultiTexCoord2f_Impl, glMultiTexCoord2f); + GLELoadProc(glMultiTexCoord2fv_Impl, glMultiTexCoord2fv); + GLELoadProc(glMultiTexCoord2i_Impl, glMultiTexCoord2i); + GLELoadProc(glMultiTexCoord2iv_Impl, glMultiTexCoord2iv); + GLELoadProc(glMultiTexCoord2s_Impl, glMultiTexCoord2s); + GLELoadProc(glMultiTexCoord2sv_Impl, glMultiTexCoord2sv); + GLELoadProc(glMultiTexCoord3d_Impl, glMultiTexCoord3d); + GLELoadProc(glMultiTexCoord3dv_Impl, glMultiTexCoord3dv); + GLELoadProc(glMultiTexCoord3f_Impl, glMultiTexCoord3f); + GLELoadProc(glMultiTexCoord3fv_Impl, glMultiTexCoord3fv); + GLELoadProc(glMultiTexCoord3i_Impl, glMultiTexCoord3i); + GLELoadProc(glMultiTexCoord3iv_Impl, glMultiTexCoord3iv); + GLELoadProc(glMultiTexCoord3s_Impl, glMultiTexCoord3s); + GLELoadProc(glMultiTexCoord3sv_Impl, glMultiTexCoord3sv); + GLELoadProc(glMultiTexCoord4d_Impl, glMultiTexCoord4d); + GLELoadProc(glMultiTexCoord4dv_Impl, glMultiTexCoord4dv); + GLELoadProc(glMultiTexCoord4f_Impl, glMultiTexCoord4f); + GLELoadProc(glMultiTexCoord4fv_Impl, glMultiTexCoord4fv); + GLELoadProc(glMultiTexCoord4i_Impl, glMultiTexCoord4i); + GLELoadProc(glMultiTexCoord4iv_Impl, glMultiTexCoord4iv); + GLELoadProc(glMultiTexCoord4s_Impl, glMultiTexCoord4s); + GLELoadProc(glMultiTexCoord4sv_Impl, glMultiTexCoord4sv); + GLELoadProc(glSampleCoverage_Impl, glSampleCoverage); + + // GL_VERSION_1_4 + GLELoadProc(glBlendColor_Impl, glBlendColor); + GLELoadProc(glBlendEquation_Impl, glBlendEquation); + GLELoadProc(glBlendFuncSeparate_Impl, glBlendFuncSeparate); + GLELoadProc(glFogCoordPointer_Impl, glFogCoordPointer); + GLELoadProc(glFogCoordd_Impl, glFogCoordd); + GLELoadProc(glFogCoorddv_Impl, glFogCoorddv); + GLELoadProc(glFogCoordf_Impl, glFogCoordf); + GLELoadProc(glFogCoordfv_Impl, glFogCoordfv); + GLELoadProc(glMultiDrawArrays_Impl, glMultiDrawArrays); + GLELoadProc(glMultiDrawElements_Impl, glMultiDrawElements); + GLELoadProc(glPointParameterf_Impl, glPointParameterf); + GLELoadProc(glPointParameterfv_Impl, glPointParameterfv); + GLELoadProc(glPointParameteri_Impl, glPointParameteri); + GLELoadProc(glPointParameteriv_Impl, glPointParameteriv); + GLELoadProc(glSecondaryColor3b_Impl, glSecondaryColor3b); + GLELoadProc(glSecondaryColor3bv_Impl, glSecondaryColor3bv); + GLELoadProc(glSecondaryColor3d_Impl, glSecondaryColor3d); + GLELoadProc(glSecondaryColor3dv_Impl, glSecondaryColor3dv); + GLELoadProc(glSecondaryColor3f_Impl, glSecondaryColor3f); + GLELoadProc(glSecondaryColor3fv_Impl, glSecondaryColor3fv); + GLELoadProc(glSecondaryColor3i_Impl, glSecondaryColor3i); + GLELoadProc(glSecondaryColor3iv_Impl, glSecondaryColor3iv); + GLELoadProc(glSecondaryColor3s_Impl, glSecondaryColor3s); + GLELoadProc(glSecondaryColor3sv_Impl, glSecondaryColor3sv); + GLELoadProc(glSecondaryColor3ub_Impl, glSecondaryColor3ub); + GLELoadProc(glSecondaryColor3ubv_Impl, glSecondaryColor3ubv); + GLELoadProc(glSecondaryColor3ui_Impl, glSecondaryColor3ui); + GLELoadProc(glSecondaryColor3uiv_Impl, glSecondaryColor3uiv); + GLELoadProc(glSecondaryColor3us_Impl, glSecondaryColor3us); + GLELoadProc(glSecondaryColor3usv_Impl, glSecondaryColor3usv); + GLELoadProc(glSecondaryColorPointer_Impl, glSecondaryColorPointer); + GLELoadProc(glWindowPos2d_Impl, glWindowPos2d); + GLELoadProc(glWindowPos2dv_Impl, glWindowPos2dv); + GLELoadProc(glWindowPos2f_Impl, glWindowPos2f); + GLELoadProc(glWindowPos2fv_Impl, glWindowPos2fv); + GLELoadProc(glWindowPos2i_Impl, glWindowPos2i); + GLELoadProc(glWindowPos2iv_Impl, glWindowPos2iv); + GLELoadProc(glWindowPos2s_Impl, glWindowPos2s); + GLELoadProc(glWindowPos2sv_Impl, glWindowPos2sv); + GLELoadProc(glWindowPos3d_Impl, glWindowPos3d); + GLELoadProc(glWindowPos3dv_Impl, glWindowPos3dv); + GLELoadProc(glWindowPos3f_Impl, glWindowPos3f); + GLELoadProc(glWindowPos3fv_Impl, glWindowPos3fv); + GLELoadProc(glWindowPos3i_Impl, glWindowPos3i); + GLELoadProc(glWindowPos3iv_Impl, glWindowPos3iv); + GLELoadProc(glWindowPos3s_Impl, glWindowPos3s); + GLELoadProc(glWindowPos3sv_Impl, glWindowPos3sv); + + // GL_VERSION_1_5 + GLELoadProc(glBeginQuery_Impl, glBeginQuery); + GLELoadProc(glBindBuffer_Impl, glBindBuffer); + GLELoadProc(glBufferData_Impl, glBufferData); + GLELoadProc(glBufferSubData_Impl, glBufferSubData); + GLELoadProc(glDeleteBuffers_Impl, glDeleteBuffers); + GLELoadProc(glDeleteQueries_Impl, glDeleteQueries); + GLELoadProc(glEndQuery_Impl, glEndQuery); + GLELoadProc(glGenBuffers_Impl, glGenBuffers); + GLELoadProc(glGenQueries_Impl, glGenQueries); + GLELoadProc(glGetBufferParameteriv_Impl, glGetBufferParameteriv); + GLELoadProc(glGetBufferPointerv_Impl, glGetBufferPointerv); + GLELoadProc(glGetBufferSubData_Impl, glGetBufferSubData); + GLELoadProc(glGetQueryObjectiv_Impl, glGetQueryObjectiv); + GLELoadProc(glGetQueryObjectuiv_Impl, glGetQueryObjectuiv); + GLELoadProc(glGetQueryiv_Impl, glGetQueryiv); + GLELoadProc(glIsBuffer_Impl, glIsBuffer); + GLELoadProc(glIsQuery_Impl, glIsQuery); + GLELoadProc(glMapBuffer_Impl, glMapBuffer); + GLELoadProc(glUnmapBuffer_Impl, glUnmapBuffer); + + // GL_VERSION_2_0 + GLELoadProc(glAttachShader_Impl, glAttachShader); + GLELoadProc(glBindAttribLocation_Impl, glBindAttribLocation); + GLELoadProc(glBlendEquationSeparate_Impl, glBlendEquationSeparate); + GLELoadProc(glCompileShader_Impl, glCompileShader); + GLELoadProc(glCreateProgram_Impl, glCreateProgram); + GLELoadProc(glCreateShader_Impl, glCreateShader); + GLELoadProc(glDeleteProgram_Impl, glDeleteProgram); + GLELoadProc(glDeleteShader_Impl, glDeleteShader); + GLELoadProc(glDetachShader_Impl, glDetachShader); + GLELoadProc(glDisableVertexAttribArray_Impl, glDisableVertexAttribArray); + GLELoadProc(glDrawBuffers_Impl, glDrawBuffers); + GLELoadProc(glEnableVertexAttribArray_Impl, glEnableVertexAttribArray); + GLELoadProc(glGetActiveAttrib_Impl, glGetActiveAttrib); + GLELoadProc(glGetActiveUniform_Impl, glGetActiveUniform); + GLELoadProc(glGetAttachedShaders_Impl, glGetAttachedShaders); + GLELoadProc(glGetAttribLocation_Impl, glGetAttribLocation); + GLELoadProc(glGetProgramInfoLog_Impl, glGetProgramInfoLog); + GLELoadProc(glGetProgramiv_Impl, glGetProgramiv); + GLELoadProc(glGetShaderInfoLog_Impl, glGetShaderInfoLog); + GLELoadProc(glGetShaderSource_Impl, glGetShaderSource); + GLELoadProc(glGetShaderiv_Impl, glGetShaderiv); + GLELoadProc(glGetUniformLocation_Impl, glGetUniformLocation); + GLELoadProc(glGetUniformfv_Impl, glGetUniformfv); + GLELoadProc(glGetUniformiv_Impl, glGetUniformiv); + GLELoadProc(glGetVertexAttribPointerv_Impl, glGetVertexAttribPointerv); + GLELoadProc(glGetVertexAttribdv_Impl, glGetVertexAttribdv); + GLELoadProc(glGetVertexAttribfv_Impl, glGetVertexAttribfv); + GLELoadProc(glGetVertexAttribiv_Impl, glGetVertexAttribiv); + GLELoadProc(glIsProgram_Impl, glIsProgram); + GLELoadProc(glIsShader_Impl, glIsShader); + GLELoadProc(glLinkProgram_Impl, glLinkProgram); + GLELoadProc(glShaderSource_Impl, glShaderSource); + GLELoadProc(glStencilFuncSeparate_Impl, glStencilFuncSeparate); + GLELoadProc(glStencilMaskSeparate_Impl, glStencilMaskSeparate); + GLELoadProc(glStencilOpSeparate_Impl, glStencilOpSeparate); + GLELoadProc(glUniform1f_Impl, glUniform1f); + GLELoadProc(glUniform1fv_Impl, glUniform1fv); + GLELoadProc(glUniform1i_Impl, glUniform1i); + GLELoadProc(glUniform1iv_Impl, glUniform1iv); + GLELoadProc(glUniform2f_Impl, glUniform2f); + GLELoadProc(glUniform2fv_Impl, glUniform2fv); + GLELoadProc(glUniform2i_Impl, glUniform2i); + GLELoadProc(glUniform2iv_Impl, glUniform2iv); + GLELoadProc(glUniform3f_Impl, glUniform3f); + GLELoadProc(glUniform3fv_Impl, glUniform3fv); + GLELoadProc(glUniform3i_Impl, glUniform3i); + GLELoadProc(glUniform3iv_Impl, glUniform3iv); + GLELoadProc(glUniform4f_Impl, glUniform4f); + GLELoadProc(glUniform4fv_Impl, glUniform4fv); + GLELoadProc(glUniform4i_Impl, glUniform4i); + GLELoadProc(glUniform4iv_Impl, glUniform4iv); + GLELoadProc(glUniformMatrix2fv_Impl, glUniformMatrix2fv); + GLELoadProc(glUniformMatrix3fv_Impl, glUniformMatrix3fv); + GLELoadProc(glUniformMatrix4fv_Impl, glUniformMatrix4fv); + GLELoadProc(glUseProgram_Impl, glUseProgram); + GLELoadProc(glValidateProgram_Impl, glValidateProgram); + GLELoadProc(glVertexAttrib1d_Impl, glVertexAttrib1d); + GLELoadProc(glVertexAttrib1dv_Impl, glVertexAttrib1dv); + GLELoadProc(glVertexAttrib1f_Impl, glVertexAttrib1f); + GLELoadProc(glVertexAttrib1fv_Impl, glVertexAttrib1fv); + GLELoadProc(glVertexAttrib1s_Impl, glVertexAttrib1s); + GLELoadProc(glVertexAttrib1sv_Impl, glVertexAttrib1sv); + GLELoadProc(glVertexAttrib2d_Impl, glVertexAttrib2d); + GLELoadProc(glVertexAttrib2dv_Impl, glVertexAttrib2dv); + GLELoadProc(glVertexAttrib2f_Impl, glVertexAttrib2f); + GLELoadProc(glVertexAttrib2fv_Impl, glVertexAttrib2fv); + GLELoadProc(glVertexAttrib2s_Impl, glVertexAttrib2s); + GLELoadProc(glVertexAttrib2sv_Impl, glVertexAttrib2sv); + GLELoadProc(glVertexAttrib3d_Impl, glVertexAttrib3d); + GLELoadProc(glVertexAttrib3dv_Impl, glVertexAttrib3dv); + GLELoadProc(glVertexAttrib3f_Impl, glVertexAttrib3f); + GLELoadProc(glVertexAttrib3fv_Impl, glVertexAttrib3fv); + GLELoadProc(glVertexAttrib3s_Impl, glVertexAttrib3s); + GLELoadProc(glVertexAttrib3sv_Impl, glVertexAttrib3sv); + GLELoadProc(glVertexAttrib4Nbv_Impl, glVertexAttrib4Nbv); + GLELoadProc(glVertexAttrib4Niv_Impl, glVertexAttrib4Niv); + GLELoadProc(glVertexAttrib4Nsv_Impl, glVertexAttrib4Nsv); + GLELoadProc(glVertexAttrib4Nub_Impl, glVertexAttrib4Nub); + GLELoadProc(glVertexAttrib4Nubv_Impl, glVertexAttrib4Nubv); + GLELoadProc(glVertexAttrib4Nuiv_Impl, glVertexAttrib4Nuiv); + GLELoadProc(glVertexAttrib4Nusv_Impl, glVertexAttrib4Nusv); + GLELoadProc(glVertexAttrib4bv_Impl, glVertexAttrib4bv); + GLELoadProc(glVertexAttrib4d_Impl, glVertexAttrib4d); + GLELoadProc(glVertexAttrib4dv_Impl, glVertexAttrib4dv); + GLELoadProc(glVertexAttrib4f_Impl, glVertexAttrib4f); + GLELoadProc(glVertexAttrib4fv_Impl, glVertexAttrib4fv); + GLELoadProc(glVertexAttrib4iv_Impl, glVertexAttrib4iv); + GLELoadProc(glVertexAttrib4s_Impl, glVertexAttrib4s); + GLELoadProc(glVertexAttrib4sv_Impl, glVertexAttrib4sv); + GLELoadProc(glVertexAttrib4ubv_Impl, glVertexAttrib4ubv); + GLELoadProc(glVertexAttrib4uiv_Impl, glVertexAttrib4uiv); + GLELoadProc(glVertexAttrib4usv_Impl, glVertexAttrib4usv); + GLELoadProc(glVertexAttribPointer_Impl, glVertexAttribPointer); + + // GL_VERSION_2_1 + GLELoadProc(glUniformMatrix2x3fv_Impl, glUniformMatrix2x3fv); + GLELoadProc(glUniformMatrix2x4fv_Impl, glUniformMatrix2x4fv); + GLELoadProc(glUniformMatrix3x2fv_Impl, glUniformMatrix3x2fv); + GLELoadProc(glUniformMatrix3x4fv_Impl, glUniformMatrix3x4fv); + GLELoadProc(glUniformMatrix4x2fv_Impl, glUniformMatrix4x2fv); + GLELoadProc(glUniformMatrix4x3fv_Impl, glUniformMatrix4x3fv); + + // GL_VERSION_3_0 + GLELoadProc(glBeginConditionalRender_Impl, glBeginConditionalRender); + GLELoadProc(glBeginTransformFeedback_Impl, glBeginTransformFeedback); + GLELoadProc(glBindFragDataLocation_Impl, glBindFragDataLocation); + GLELoadProc(glClampColor_Impl, glClampColor); + GLELoadProc(glClearBufferfi_Impl, glClearBufferfi); + GLELoadProc(glClearBufferfv_Impl, glClearBufferfv); + GLELoadProc(glClearBufferiv_Impl, glClearBufferiv); + GLELoadProc(glClearBufferuiv_Impl, glClearBufferuiv); + GLELoadProc(glColorMaski_Impl, glColorMaski); + GLELoadProc(glDisablei_Impl, glDisablei); + GLELoadProc(glEnablei_Impl, glEnablei); + GLELoadProc(glEndConditionalRender_Impl, glEndConditionalRender); + GLELoadProc(glEndTransformFeedback_Impl, glEndTransformFeedback); + GLELoadProc(glBindBufferRange_Impl, glBindBufferRange); + GLELoadProc(glBindBufferBase_Impl, glBindBufferBase); + GLELoadProc(glGetBooleani_v_Impl, glGetBooleani_v); + GLELoadProc(glGetIntegeri_v_Impl, glGetIntegeri_v); + GLELoadProc(glGetFragDataLocation_Impl, glGetFragDataLocation); + GLELoadProc(glGetStringi_Impl, glGetStringi); + GLELoadProc(glGetTexParameterIiv_Impl, glGetTexParameterIiv); + GLELoadProc(glGetTexParameterIuiv_Impl, glGetTexParameterIuiv); + GLELoadProc(glGetTransformFeedbackVarying_Impl, glGetTransformFeedbackVarying); + GLELoadProc(glGetUniformuiv_Impl, glGetUniformuiv); + GLELoadProc(glGetVertexAttribIiv_Impl, glGetVertexAttribIiv); + GLELoadProc(glGetVertexAttribIuiv_Impl, glGetVertexAttribIuiv); + GLELoadProc(glIsEnabledi_Impl, glIsEnabledi); + GLELoadProc(glTexParameterIiv_Impl, glTexParameterIiv); + GLELoadProc(glTexParameterIuiv_Impl, glTexParameterIuiv); + GLELoadProc(glTransformFeedbackVaryings_Impl, glTransformFeedbackVaryings); + GLELoadProc(glUniform1ui_Impl, glUniform1ui); + GLELoadProc(glUniform1uiv_Impl, glUniform1uiv); + GLELoadProc(glUniform2ui_Impl, glUniform2ui); + GLELoadProc(glUniform2uiv_Impl, glUniform2uiv); + GLELoadProc(glUniform3ui_Impl, glUniform3ui); + GLELoadProc(glUniform3uiv_Impl, glUniform3uiv); + GLELoadProc(glUniform4ui_Impl, glUniform4ui); + GLELoadProc(glUniform4uiv_Impl, glUniform4uiv); + GLELoadProc(glVertexAttribI1i_Impl, glVertexAttribI1i); + GLELoadProc(glVertexAttribI1iv_Impl, glVertexAttribI1iv); + GLELoadProc(glVertexAttribI1ui_Impl, glVertexAttribI1ui); + GLELoadProc(glVertexAttribI1uiv_Impl, glVertexAttribI1uiv); + GLELoadProc(glVertexAttribI2i_Impl, glVertexAttribI2i); + GLELoadProc(glVertexAttribI2iv_Impl, glVertexAttribI2iv); + GLELoadProc(glVertexAttribI2ui_Impl, glVertexAttribI2ui); + GLELoadProc(glVertexAttribI2uiv_Impl, glVertexAttribI2uiv); + GLELoadProc(glVertexAttribI3i_Impl, glVertexAttribI3i); + GLELoadProc(glVertexAttribI3iv_Impl, glVertexAttribI3iv); + GLELoadProc(glVertexAttribI3ui_Impl, glVertexAttribI3ui); + GLELoadProc(glVertexAttribI3uiv_Impl, glVertexAttribI3uiv); + GLELoadProc(glVertexAttribI4bv_Impl, glVertexAttribI4bv); + GLELoadProc(glVertexAttribI4i_Impl, glVertexAttribI4i); + GLELoadProc(glVertexAttribI4iv_Impl, glVertexAttribI4iv); + GLELoadProc(glVertexAttribI4sv_Impl, glVertexAttribI4sv); + GLELoadProc(glVertexAttribI4ubv_Impl, glVertexAttribI4ubv); + GLELoadProc(glVertexAttribI4ui_Impl, glVertexAttribI4ui); + GLELoadProc(glVertexAttribI4uiv_Impl, glVertexAttribI4uiv); + GLELoadProc(glVertexAttribI4usv_Impl, glVertexAttribI4usv); + GLELoadProc(glVertexAttribIPointer_Impl, glVertexAttribIPointer); + + // GL_VERSION_3_1 + GLELoadProc(glDrawArraysInstanced_Impl, glDrawArraysInstanced); + GLELoadProc(glDrawElementsInstanced_Impl, glDrawElementsInstanced); + GLELoadProc(glPrimitiveRestartIndex_Impl, glPrimitiveRestartIndex); + GLELoadProc(glTexBuffer_Impl, glTexBuffer); + + // GL_VERSION_3_2 + GLELoadProc(glFramebufferTexture_Impl, glFramebufferTexture); + GLELoadProc(glGetBufferParameteri64v_Impl, glGetBufferParameteri64v); + GLELoadProc(glGetInteger64i_v_Impl, glGetInteger64i_v); + + // GL_VERSION_3_3 + GLELoadProc(glVertexAttribDivisor_Impl, glVertexAttribDivisor); + + // GL_VERSION_4_0 + GLELoadProc(glBlendEquationSeparatei_Impl, glBlendEquationSeparatei); + GLELoadProc(glBlendEquationi_Impl, glBlendEquationi); + GLELoadProc(glBlendFuncSeparatei_Impl, glBlendFuncSeparatei); + GLELoadProc(glBlendFunci_Impl, glBlendFunci); + GLELoadProc(glMinSampleShading_Impl, glMinSampleShading); + + // GL_AMD_debug_output + GLELoadProc(glDebugMessageCallbackAMD_Impl, glDebugMessageCallbackAMD); + GLELoadProc(glDebugMessageEnableAMD_Impl, glDebugMessageEnableAMD); + GLELoadProc(glDebugMessageInsertAMD_Impl, glDebugMessageInsertAMD); + GLELoadProc(glGetDebugMessageLogAMD_Impl, glGetDebugMessageLogAMD); + + #if defined(GLE_CGL_ENABLED) + // GL_APPLE_element_array + GLELoadProc(glDrawElementArrayAPPLE_Impl, glDrawElementArrayAPPLE); + GLELoadProc(glDrawRangeElementArrayAPPLE_Impl, glDrawRangeElementArrayAPPLE); + GLELoadProc(glElementPointerAPPLE_Impl, glElementPointerAPPLE); + GLELoadProc(glMultiDrawElementArrayAPPLE_Impl, glMultiDrawElementArrayAPPLE); + GLELoadProc(glMultiDrawRangeElementArrayAPPLE_Impl, glMultiDrawRangeElementArrayAPPLE); + + // GL_APPLE_fence + GLELoadProc(glDeleteFencesAPPLE_Impl, glDeleteFencesAPPLE); + GLELoadProc(glFinishFenceAPPLE_Impl, glFinishFenceAPPLE); + GLELoadProc(glFinishObjectAPPLE_Impl, glFinishObjectAPPLE); + GLELoadProc(glGenFencesAPPLE_Impl, glGenFencesAPPLE); + GLELoadProc(glIsFenceAPPLE_Impl, glIsFenceAPPLE); + GLELoadProc(glSetFenceAPPLE_Impl, glSetFenceAPPLE); + GLELoadProc(glTestFenceAPPLE_Impl, glTestFenceAPPLE); + GLELoadProc(glTestObjectAPPLE_Impl, glTestObjectAPPLE); + + // GL_APPLE_flush_buffer_range + GLELoadProc(glBufferParameteriAPPLE_Impl, glMultiDrawRangeElementArrayAPPLE); + GLELoadProc(glFlushMappedBufferRangeAPPLE_Impl, glFlushMappedBufferRangeAPPLE); + + // GL_APPLE_object_purgeable + GLELoadProc(glGetObjectParameterivAPPLE_Impl, glGetObjectParameterivAPPLE); + GLELoadProc(glObjectPurgeableAPPLE_Impl, glObjectPurgeableAPPLE); + GLELoadProc(glObjectUnpurgeableAPPLE_Impl, glObjectUnpurgeableAPPLE); + + // GL_APPLE_texture_range + GLELoadProc(glGetTexParameterPointervAPPLE_Impl, glGetTexParameterPointervAPPLE); + GLELoadProc(glTextureRangeAPPLE_Impl, glTextureRangeAPPLE); + + // GL_APPLE_vertex_array_object + GLELoadProc(glBindVertexArrayAPPLE_Impl, glBindVertexArrayAPPLE); + GLELoadProc(glDeleteVertexArraysAPPLE_Impl, glDeleteVertexArraysAPPLE); + GLELoadProc(glGenVertexArraysAPPLE_Impl, glGenVertexArraysAPPLE); + GLELoadProc(glIsVertexArrayAPPLE_Impl, glIsVertexArrayAPPLE); + + // GL_APPLE_vertex_array_range + GLELoadProc(glFlushVertexArrayRangeAPPLE_Impl, glFlushVertexArrayRangeAPPLE); + GLELoadProc(glVertexArrayParameteriAPPLE_Impl, glVertexArrayParameteriAPPLE); + GLELoadProc(glVertexArrayRangeAPPLE_Impl, glVertexArrayRangeAPPLE); + + // GL_APPLE_vertex_program_evaluators + GLELoadProc(glDisableVertexAttribAPPLE_Impl, glDisableVertexAttribAPPLE); + GLELoadProc(glEnableVertexAttribAPPLE_Impl, glEnableVertexAttribAPPLE); + GLELoadProc(glIsVertexAttribEnabledAPPLE_Impl, glIsVertexAttribEnabledAPPLE); + GLELoadProc(glMapVertexAttrib1dAPPLE_Impl, glMapVertexAttrib1dAPPLE); + GLELoadProc(glMapVertexAttrib1fAPPLE_Impl, glMapVertexAttrib1fAPPLE); + GLELoadProc(glMapVertexAttrib2dAPPLE_Impl, glMapVertexAttrib2dAPPLE); + GLELoadProc(glMapVertexAttrib2fAPPLE_Impl, glMapVertexAttrib2fAPPLE); + + #endif // GLE_CGL_ENABLED + + // GL_ARB_debug_output + GLELoadProc(glDebugMessageCallbackARB_Impl, glDebugMessageCallbackARB); + GLELoadProc(glDebugMessageControlARB_Impl, glDebugMessageControlARB); + GLELoadProc(glDebugMessageInsertARB_Impl, glDebugMessageInsertARB); + GLELoadProc(glGetDebugMessageLogARB_Impl, glGetDebugMessageLogARB); + + // GL_ARB_ES2_compatibility + GLELoadProc(glClearDepthf_Impl, glClearDepthf); + GLELoadProc(glDepthRangef_Impl, glDepthRangef); + GLELoadProc(glGetShaderPrecisionFormat_Impl, glGetShaderPrecisionFormat); + GLELoadProc(glReleaseShaderCompiler_Impl, glReleaseShaderCompiler); + GLELoadProc(glShaderBinary_Impl, glShaderBinary); + + // GL_ARB_framebuffer_object + GLELoadProc(glBindFramebuffer_Impl, glBindFramebuffer); + GLELoadProc(glBindRenderbuffer_Impl, glBindRenderbuffer); + GLELoadProc(glBlitFramebuffer_Impl, glBlitFramebuffer); + GLELoadProc(glCheckFramebufferStatus_Impl, glCheckFramebufferStatus); + GLELoadProc(glDeleteFramebuffers_Impl, glDeleteFramebuffers); + GLELoadProc(glDeleteRenderbuffers_Impl, glDeleteRenderbuffers); + GLELoadProc(glFramebufferRenderbuffer_Impl, glFramebufferRenderbuffer); + GLELoadProc(glFramebufferTexture1D_Impl, glFramebufferTexture1D); + GLELoadProc(glFramebufferTexture2D_Impl, glFramebufferTexture2D); + GLELoadProc(glFramebufferTexture3D_Impl, glFramebufferTexture3D); + GLELoadProc(glFramebufferTextureLayer_Impl, glFramebufferTextureLayer); + GLELoadProc(glGenFramebuffers_Impl, glGenFramebuffers); + GLELoadProc(glGenRenderbuffers_Impl, glGenRenderbuffers); + GLELoadProc(glGenerateMipmap_Impl, glGenerateMipmap); + GLELoadProc(glGetFramebufferAttachmentParameteriv_Impl, glGetFramebufferAttachmentParameteriv); + GLELoadProc(glGetRenderbufferParameteriv_Impl, glGetRenderbufferParameteriv); + GLELoadProc(glIsFramebuffer_Impl, glIsFramebuffer); + GLELoadProc(glIsRenderbuffer_Impl, glIsRenderbuffer); + GLELoadProc(glRenderbufferStorage_Impl, glRenderbufferStorage); + GLELoadProc(glRenderbufferStorageMultisample_Impl, glRenderbufferStorageMultisample); + + if(!glBindFramebuffer_Impl) // This will rarely if ever be the case in practice with modern computers and drivers. + { + // See if we can map GL_EXT_framebuffer_object to GL_ARB_framebuffer_object. The former is basically a subset of the latter, but we use only that subset. + GLELoadProc(glBindFramebuffer_Impl, glBindFramebufferEXT); + GLELoadProc(glBindRenderbuffer_Impl, glBindRenderbufferEXT); + //GLELoadProc(glBlitFramebuffer_Impl, glBlitFramebufferEXT (nonexistent)); + GLELoadProc(glCheckFramebufferStatus_Impl, glCheckFramebufferStatusEXT); + GLELoadProc(glDeleteFramebuffers_Impl, glDeleteFramebuffersEXT); + GLELoadProc(glDeleteRenderbuffers_Impl, glDeleteRenderbuffersEXT); + GLELoadProc(glFramebufferRenderbuffer_Impl, glFramebufferRenderbufferEXT); + GLELoadProc(glFramebufferTexture1D_Impl, glFramebufferTexture1DEXT); + GLELoadProc(glFramebufferTexture2D_Impl, glFramebufferTexture2DEXT); + GLELoadProc(glFramebufferTexture3D_Impl, glFramebufferTexture3DEXT); + //GLELoadProc(glFramebufferTextureLayer_Impl, glFramebufferTextureLayerEXT (nonexistent)); + GLELoadProc(glGenFramebuffers_Impl, glGenFramebuffersEXT); + GLELoadProc(glGenRenderbuffers_Impl, glGenRenderbuffersEXT); + GLELoadProc(glGenerateMipmap_Impl, glGenerateMipmapEXT); + GLELoadProc(glGetFramebufferAttachmentParameteriv_Impl, glGetFramebufferAttachmentParameterivEXT); + GLELoadProc(glGetRenderbufferParameteriv_Impl, glGetRenderbufferParameterivEXT); + GLELoadProc(glIsFramebuffer_Impl, glIsFramebufferEXT); + GLELoadProc(glIsRenderbuffer_Impl, glIsRenderbufferEXT); + GLELoadProc(glRenderbufferStorage_Impl, glRenderbufferStorageEXT); + //GLELoadProc(glRenderbufferStorageMultisample_Impl, glRenderbufferStorageMultisampleEXT (nonexistent)); + } + + // GL_ARB_texture_multisample + GLELoadProc(glGetMultisamplefv_Impl, glGetMultisamplefv); + GLELoadProc(glSampleMaski_Impl, glSampleMaski); + GLELoadProc(glTexImage2DMultisample_Impl, glTexImage2DMultisample); + GLELoadProc(glTexImage3DMultisample_Impl, glTexImage3DMultisample); + + // GL_ARB_timer_query + GLELoadProc(glGetQueryObjecti64v_Impl, glGetQueryObjecti64v); + GLELoadProc(glGetQueryObjectui64v_Impl, glGetQueryObjectui64v); + GLELoadProc(glQueryCounter_Impl, glQueryCounter); + + // GL_ARB_vertex_array_object + GLELoadProc(glBindVertexArray_Impl, glBindVertexArray); + GLELoadProc(glDeleteVertexArrays_Impl, glDeleteVertexArrays); + GLELoadProc(glGenVertexArrays_Impl, glGenVertexArrays); + GLELoadProc(glIsVertexArray_Impl, glIsVertexArray); + + #if defined(GLE_CGL_ENABLED) // Apple OpenGL... + if(WholeVersion < 302) // It turns out that Apple OpenGL versions prior to 3.2 have glBindVertexArray, etc. but they silently fail by default. So always use the APPLE version. + { + glBindVertexArray_Impl = glBindVertexArrayAPPLE_Impl; + glDeleteVertexArrays_Impl = glDeleteVertexArraysAPPLE_Impl; + glGenVertexArrays_Impl = (OVRTypeof(glGenVertexArrays_Impl)) glGenVertexArraysAPPLE_Impl; // There is a const cast of the arrays argument here due to a slight difference in the Apple behavior. For our purposes it should be OK. + glIsVertexArray_Impl = glIsVertexArrayAPPLE_Impl; + + if(glBindVertexArray_Impl) + gle_ARB_vertex_array_object = true; // We are routing the APPLE version through our version, with the assumption that we use the ARB version the same as we would use the APPLE version. + } + #endif + + // GL_EXT_draw_buffers2 + GLELoadProc(glColorMaskIndexedEXT_Impl, glColorMaskIndexedEXT); + GLELoadProc(glDisableIndexedEXT_Impl, glDisableIndexedEXT); + GLELoadProc(glEnableIndexedEXT_Impl, glEnableIndexedEXT); + GLELoadProc(glGetBooleanIndexedvEXT_Impl, glGetBooleanIndexedvEXT); + GLELoadProc(glGetIntegerIndexedvEXT_Impl, glGetIntegerIndexedvEXT); + GLELoadProc(glIsEnabledIndexedEXT_Impl, glIsEnabledIndexedEXT); + + // GL_KHR_debug + GLELoadProc(glDebugMessageCallback_Impl, glDebugMessageCallback); + GLELoadProc(glDebugMessageControl_Impl, glDebugMessageControl); + GLELoadProc(glDebugMessageInsert_Impl, glDebugMessageInsert); + GLELoadProc(glGetDebugMessageLog_Impl, glGetDebugMessageLog); + GLELoadProc(glGetObjectLabel_Impl, glGetObjectLabel); + GLELoadProc(glGetObjectPtrLabel_Impl, glGetObjectPtrLabel); + GLELoadProc(glObjectLabel_Impl, glObjectLabel); + GLELoadProc(glObjectPtrLabel_Impl, glObjectPtrLabel); + GLELoadProc(glPopDebugGroup_Impl, glPopDebugGroup); + GLELoadProc(glPushDebugGroup_Impl, glPushDebugGroup); + + // GL_WIN_swap_hint + GLELoadProc(glAddSwapHintRectWIN_Impl, glAddSwapHintRectWIN); + } + + + + OVR_DISABLE_MSVC_WARNING(4510 4512 4610) // default constructor could not be generated, + struct ValueStringPair + { + bool& IsPresent; + const char* ExtensionName; + }; + + + // Helper function for InitExtensionSupport. + static void CheckExtensions(ValueStringPair* pValueStringPairArray, size_t arrayCount, const char* extensions) + { + // We search the extesion list string for each of the individual extensions we are interested in. + // We do this by walking over the string and comparing each entry in turn to our array of entries of interest. + // Example string (with patholigical extra spaces): " ext1 ext2 ext3 " + + char extension[64]; + const char* p = extensions; // p points to the beginning of the current word + const char* pEnd; // pEnd points to one-past the last character of the current word. It is where the trailing '\0' of the string would be. + + while(*p) + { + while(*p == ' ') // Find the next word begin. + ++p; + + pEnd = p; + + while((*pEnd != '\0') && (*pEnd != ' ')) // Find the next word end. + ++pEnd; + + if(((pEnd - p) > 0) && ((size_t)(pEnd - p) < OVR_ARRAY_COUNT(extension))) + { + memcpy(extension, p, pEnd - p); // To consider: Revise this code to directly read from p/pEnd instead of doing a memcpy. + extension[pEnd - p] = '\0'; + + for(size_t i = 0; i < arrayCount; i++) // For each extension we are interested in... + { + ValueStringPair& vsp = pValueStringPairArray[i]; + + if(strcmp(extension, vsp.ExtensionName) == 0) // case-sensitive compare + pValueStringPairArray[i].IsPresent = true; + } + } + + p = pEnd; + } + } + + + void OVR::GLEContext::InitExtensionSupport() + { + // It may be better in the long run to use a member STL map. + // It would make this loading code cleaner, though it would make lookups slower. + + ValueStringPair vspArray[] = + { + { gle_AMD_debug_output, "GL_AMD_debug_output" }, + #if defined(GLE_CGL_ENABLED) + { gle_APPLE_aux_depth_stencil, "GL_APPLE_aux_depth_stencil" }, + { gle_APPLE_client_storage, "GL_APPLE_client_storage" }, + { gle_APPLE_element_array, "GL_APPLE_element_array" }, + { gle_APPLE_fence, "GL_APPLE_fence" }, + { gle_APPLE_float_pixels, "GL_APPLE_float_pixels" }, + { gle_APPLE_flush_buffer_range, "GL_APPLE_flush_buffer_range" }, + { gle_APPLE_object_purgeable, "GL_APPLE_object_purgeable" }, + { gle_APPLE_pixel_buffer, "GL_APPLE_pixel_buffer" }, + { gle_APPLE_rgb_422, "GL_APPLE_rgb_422" }, + { gle_APPLE_row_bytes, "GL_APPLE_row_bytes" }, + { gle_APPLE_specular_vector, "GL_APPLE_specular_vector" }, + { gle_APPLE_texture_range, "GL_APPLE_texture_range" }, + { gle_APPLE_transform_hint, "GL_APPLE_transform_hint" }, + { gle_APPLE_vertex_array_object, "GL_APPLE_vertex_array_object" }, + { gle_APPLE_vertex_array_range, "GL_APPLE_vertex_array_range" }, + { gle_APPLE_vertex_program_evaluators, "GL_APPLE_vertex_program_evaluators" }, + { gle_APPLE_ycbcr_422, "GL_APPLE_ycbcr_422" }, + #endif + { gle_ARB_debug_output, "GL_ARB_debug_output" }, + { gle_ARB_depth_buffer_float, "GL_ARB_depth_buffer_float" }, + { gle_ARB_ES2_compatibility, "GL_ARB_ES2_compatibility" }, + { gle_ARB_framebuffer_object, "GL_ARB_framebuffer_object" }, + { gle_ARB_framebuffer_object, "GL_EXT_framebuffer_object" }, // We map glBindFramebuffer, etc. to glBindFramebufferEXT, etc. if necessary + { gle_ARB_framebuffer_sRGB, "GL_ARB_framebuffer_sRGB" }, + { gle_ARB_texture_multisample, "GL_ARB_texture_multisample" }, + { gle_ARB_texture_non_power_of_two, "GL_ARB_texture_non_power_of_two" }, + { gle_ARB_texture_rectangle, "GL_ARB_texture_rectangle" }, + { gle_ARB_texture_rectangle, "GL_EXT_texture_rectangle" }, // We also check for GL_EXT_texture_rectangle and GL_NV_texture_rectangle. + { gle_ARB_texture_rectangle, "GL_NV_texture_rectangle" }, + { gle_ARB_timer_query, "GL_ARB_timer_query" }, + { gle_ARB_vertex_array_object, "GL_ARB_vertex_array_object" }, + { gle_EXT_draw_buffers2, "GL_EXT_draw_buffers2" }, + { gle_EXT_texture_compression_s3tc, "GL_EXT_texture_compression_s3tc" }, + { gle_EXT_texture_filter_anisotropic, "GL_EXT_texture_filter_anisotropic" }, + { gle_KHR_debug, "GL_KHR_debug" }, + { gle_WIN_swap_hint, "GL_WIN_swap_hint" } + // Windows WGL, Unix GLX, and Apple CGL extensions are handled below, as they require different calls from glGetString(GL_EXTENSIONS). + }; + + // We cannot use glGetString(GL_EXTENSIONS) when an OpenGL core profile is active, + // as it's deprecated in favor of using OpenGL 3+ glGetStringi. + const char* extensions = (MajorVersion < 3) ? (const char*)glGetString(GL_EXTENSIONS) : ""; + + if (extensions && *extensions) // If we have a space-delimited extension string to search for individual extensions... + { + OVR_DEBUG_LOG(("GL_EXTENSIONS: %s", (const char*)extensions)); + CheckExtensions(vspArray, OVR_ARRAY_COUNT(vspArray), extensions); // Call our shared helper function for this. + } + else + { + if(MajorVersion >= 3) // If glGetIntegerv(GL_NUM_EXTENSIONS, ...) is supported... + { + // In this case we need to match an array of individual extensions against an array of + // externsions provided by glGetStringi. This is an O(n^2) operation, but at least we + // are doing this only once on startup. There are a few tricks we can employ to speed + // up the logic below, but they may not be worth much. + + GLint extensionCount = 0; + glGetIntegerv(GL_NUM_EXTENSIONS, &extensionCount); + GLenum err = glGetError(); + + if(err == 0) + { + #ifdef OVR_BUILD_DEBUG + OVR::StringBuffer extensionsStr; + #endif + + for(GLint e = 0; e != extensionCount; ++e) // For each extension supported... + { + const char* extension = (const char*)glGetStringi(GL_EXTENSIONS, (GLuint)e); + + if(extension) // glGetStringi returns NULL upon error. + { + #ifdef OVR_BUILD_DEBUG + extensionsStr.AppendFormat(" %s", extension); + #endif + + for(size_t i = 0; i < OVR_ARRAY_COUNT(vspArray); i++) // For each extension we are interested in... + { + ValueStringPair& vsp = vspArray[i]; + + if(strcmp(extension, vsp.ExtensionName) == 0) // case-sensitive compare + vspArray[i].IsPresent = true; + } + } + else + break; + } + + OVR_DEBUG_LOG(("GL_EXTENSIONS: %s", extensionsStr.ToCStr())); + } + } + // Else we have a problem: no means to read the extensions was successful. + } + + #if defined(GLE_CGL_ENABLED) + // The following are built into Apple OpenGL 3.2+ (declared in ) and not identified as extensions. + // On other platforms (e.g. Windows) these are identified as extensions and are detected above. + if(WholeVersion >= 302) + { + gle_ARB_depth_buffer_float = true; + gle_ARB_framebuffer_object = true; + gle_ARB_framebuffer_sRGB = true; + gle_ARB_texture_multisample = true; + gle_ARB_texture_non_power_of_two = true; + gle_ARB_texture_rectangle = true; + gle_ARB_vertex_array_object = true; + } + #endif + + } // GLEContext::InitExtensionSupport() + + + void OVR::GLEContext::InitPlatformVersion() + { + #if defined(GLE_GLX_ENABLED) + const char* pGLXVersion = glXGetClientString(glXGetCurrentDisplay(), GLX_VERSION); // To do: Use a better mechanism to get the desired display. + sscanf(pGLXVersion, "%d.%d", &PlatformMajorVersion, &PlatformMinorVersion); + + #elif defined(GLE_EGL_ENABLED) + const char* pEGLVersion = eglQueryString(eglGetDisplay(EGL_DEFAULT_DISPLAY), EGL_VERSION); + sscanf(pEGLVersion, "%d.%d", &PlatformMajorVersion, &PlatformMinorVersion); + + #else + PlatformMajorVersion = 1; + PlatformMinorVersion = 0; + PlatformWholeVersion = 100; + #endif + } + + + void OVR::GLEContext::InitPlatformExtensionLoad() + { + #if defined(GLE_WGL_ENABLED) + // WGL + // We don't load these as function pointers but rather statically link to them. + // These need to be loaded via LoadLibrary instead of wglLoadLibrary. + + #if 0 + HINSTANCE hOpenGL = LoadLibraryW(L"Opengl32.dll"); + if(hOpenGL) + { + wglCopyContext_Impl = (OVRTypeof(wglCopyContext_Impl)) GetProcAddress(hOpenGL, "wglCopyContext"); + wglCreateContext_Impl = (OVRTypeof(wglCreateContext_Impl)) GetProcAddress(hOpenGL, "wglCreateContext"); + wglCreateLayerContext_Impl = (OVRTypeof(wglCreateLayerContext_Impl)) GetProcAddress(hOpenGL, "wglCreateLayerContext"); + wglDeleteContext_Impl = (OVRTypeof(wglDeleteContext_Impl)) GetProcAddress(hOpenGL, "wglDeleteContext"); + wglGetCurrentContext_Impl = (OVRTypeof(wglGetCurrentContext_Impl)) GetProcAddress(hOpenGL, "wglGetCurrentContext"); + wglGetCurrentDC_Impl = (OVRTypeof(wglGetCurrentDC_Impl)) GetProcAddress(hOpenGL, "wglGetCurrentDC"); + wglGetProcAddress_Impl = (OVRTypeof(wglGetProcAddress_Impl)) GetProcAddress(hOpenGL, "wglGetProcAddress"); + wglMakeCurrent_Impl = (OVRTypeof(wglMakeCurrent_Impl)) GetProcAddress(hOpenGL, "wglMakeCurrent"); + wglShareLists_Impl = (OVRTypeof(wglShareLists_Impl)) GetProcAddress(hOpenGL, "wglShareLists"); + wglUseFontBitmapsA_Impl = (OVRTypeof(wglUseFontBitmapsA_Impl)) GetProcAddress(hOpenGL, "wglUseFontBitmapsA"); + wglUseFontBitmapsW_Impl = (OVRTypeof(wglUseFontBitmapsW_Impl)) GetProcAddress(hOpenGL, "wglUseFontBitmapsW"); + wglUseFontOutlinesA_Impl = (OVRTypeof(wglUseFontOutlinesA_Impl)) GetProcAddress(hOpenGL, "wglUseFontOutlinesA"); + wglUseFontOutlinesW_Impl = (OVRTypeof(wglUseFontOutlinesW_Impl)) GetProcAddress(hOpenGL, "wglUseFontOutlinesW"); + wglDescribeLayerPlane_Impl = (OVRTypeof(wglDescribeLayerPlane_Impl)) GetProcAddress(hOpenGL, "wglDescribeLayerPlane"); + wglSetLayerPaletteEntries_Impl = (OVRTypeof(wglSetLayerPaletteEntries_Impl)) GetProcAddress(hOpenGL, "wglSetLayerPaletteEntries"); + wglGetLayerPaletteEntries_Impl = (OVRTypeof(wglGetLayerPaletteEntries_Impl)) GetProcAddress(hOpenGL, "wglGetLayerPaletteEntries"); + wglRealizeLayerPalette_Impl = (OVRTypeof(wglRealizeLayerPalette_Impl)) GetProcAddress(hOpenGL, "wglRealizeLayerPalette"); + wglSwapLayerBuffers_Impl = (OVRTypeof(wglSwapLayerBuffers_Impl)) GetProcAddress(hOpenGL, "wglSwapLayerBuffers"); + wglSwapMultipleBuffers_Impl = (OVRTypeof(wglSwapMultipleBuffers_Impl)) GetProcAddress(hOpenGL, "wglSwapMultipleBuffers"); + FreeLibrary(hOpenGL); + } + #endif + + // WGL_ARB_buffer_region + GLELoadProc(wglCreateBufferRegionARB_Impl, wglCreateBufferRegionARB); + GLELoadProc(wglDeleteBufferRegionARB_Impl, wglDeleteBufferRegionARB); + GLELoadProc(wglSaveBufferRegionARB_Impl, wglSaveBufferRegionARB); + GLELoadProc(wglRestoreBufferRegionARB_Impl, wglRestoreBufferRegionARB); + + // WGL_ARB_extensions_string + GLELoadProc(wglGetExtensionsStringARB_Impl, wglGetExtensionsStringARB); + + // WGL_ARB_pixel_format + GLELoadProc(wglGetPixelFormatAttribivARB_Impl, wglGetPixelFormatAttribivARB); + GLELoadProc(wglGetPixelFormatAttribfvARB_Impl, wglGetPixelFormatAttribfvARB); + GLELoadProc(wglChoosePixelFormatARB_Impl, wglChoosePixelFormatARB); + + // WGL_ARB_make_current_read + GLELoadProc(wglMakeContextCurrentARB_Impl, wglMakeContextCurrentARB); + GLELoadProc(wglGetCurrentReadDCARB_Impl, wglGetCurrentReadDCARB); + + // WGL_ARB_pbuffer + GLELoadProc(wglCreatePbufferARB_Impl, wglCreatePbufferARB); + GLELoadProc(wglGetPbufferDCARB_Impl, wglGetPbufferDCARB); + GLELoadProc(wglReleasePbufferDCARB_Impl, wglReleasePbufferDCARB); + GLELoadProc(wglDestroyPbufferARB_Impl, wglDestroyPbufferARB); + GLELoadProc(wglQueryPbufferARB_Impl, wglQueryPbufferARB); + + // WGL_ARB_render_texture + GLELoadProc(wglBindTexImageARB_Impl, wglBindTexImageARB); + GLELoadProc(wglReleaseTexImageARB_Impl, wglReleaseTexImageARB); + GLELoadProc(wglSetPbufferAttribARB_Impl, wglSetPbufferAttribARB); + + // WGL_NV_present_video + GLELoadProc(wglEnumerateVideoDevicesNV_Impl, wglEnumerateVideoDevicesNV); + GLELoadProc(wglBindVideoDeviceNV_Impl, wglBindVideoDeviceNV); + GLELoadProc(wglQueryCurrentContextNV_Impl, wglQueryCurrentContextNV); + + // WGL_ARB_create_context + GLELoadProc(wglCreateContextAttribsARB_Impl, wglCreateContextAttribsARB); + + // WGL_EXT_extensions_string + GLELoadProc(wglGetExtensionsStringEXT_Impl, wglGetExtensionsStringEXT); + + // WGL_EXT_swap_control + GLELoadProc(wglGetSwapIntervalEXT_Impl, wglGetSwapIntervalEXT); + GLELoadProc(wglSwapIntervalEXT_Impl, wglSwapIntervalEXT); + + // WGL_OML_sync_control + GLELoadProc(wglGetSyncValuesOML_Impl, wglGetSyncValuesOML); + GLELoadProc(wglGetMscRateOML_Impl, wglGetMscRateOML); + GLELoadProc(wglSwapBuffersMscOML_Impl, wglSwapBuffersMscOML); + GLELoadProc(wglSwapLayerBuffersMscOML_Impl, wglSwapLayerBuffersMscOML); + GLELoadProc(wglWaitForMscOML_Impl, wglWaitForMscOML); + GLELoadProc(wglWaitForSbcOML_Impl, wglWaitForSbcOML); + + // WGL_NV_video_output + GLELoadProc(wglGetVideoDeviceNV_Impl, wglGetVideoDeviceNV); + GLELoadProc(wglReleaseVideoDeviceNV_Impl, wglReleaseVideoDeviceNV); + GLELoadProc(wglBindVideoImageNV_Impl, wglBindVideoImageNV); + GLELoadProc(wglReleaseVideoImageNV_Impl, wglReleaseVideoImageNV); + GLELoadProc(wglSendPbufferToVideoNV_Impl, wglSendPbufferToVideoNV); + GLELoadProc(wglGetVideoInfoNV_Impl, wglGetVideoInfoNV); + + // WGL_NV_swap_group + GLELoadProc(wglJoinSwapGroupNV_Impl, wglJoinSwapGroupNV); + GLELoadProc(wglBindSwapBarrierNV_Impl, wglBindSwapBarrierNV); + GLELoadProc(wglQuerySwapGroupNV_Impl, wglQuerySwapGroupNV); + GLELoadProc(wglQueryMaxSwapGroupsNV_Impl, wglQueryMaxSwapGroupsNV); + GLELoadProc(wglQueryFrameCountNV_Impl, wglQueryFrameCountNV); + GLELoadProc(wglResetFrameCountNV_Impl, wglResetFrameCountNV); + + // WGL_NV_video_capture + GLELoadProc(wglBindVideoCaptureDeviceNV_Impl, wglBindVideoCaptureDeviceNV); + GLELoadProc(wglEnumerateVideoCaptureDevicesNV_Impl, wglEnumerateVideoCaptureDevicesNV); + GLELoadProc(wglLockVideoCaptureDeviceNV_Impl, wglLockVideoCaptureDeviceNV); + GLELoadProc(wglQueryVideoCaptureDeviceNV_Impl, wglQueryVideoCaptureDeviceNV); + GLELoadProc(wglReleaseVideoCaptureDeviceNV_Impl, wglReleaseVideoCaptureDeviceNV); + + // WGL_NV_copy_image + GLELoadProc(wglCopyImageSubDataNV_Impl, wglCopyImageSubDataNV); + + // WGL_NV_DX_interop + GLELoadProc(wglDXCloseDeviceNV_Impl, wglDXCloseDeviceNV); + GLELoadProc(wglDXLockObjectsNV_Impl, wglDXLockObjectsNV); + GLELoadProc(wglDXObjectAccessNV_Impl, wglDXObjectAccessNV); + GLELoadProc(wglDXOpenDeviceNV_Impl, wglDXOpenDeviceNV); + GLELoadProc(wglDXRegisterObjectNV_Impl, wglDXRegisterObjectNV); + GLELoadProc(wglDXSetResourceShareHandleNV_Impl, wglDXSetResourceShareHandleNV); + GLELoadProc(wglDXUnlockObjectsNV_Impl, wglDXUnlockObjectsNV); + GLELoadProc(wglDXUnregisterObjectNV_Impl, wglDXUnregisterObjectNV); + + #elif defined(GLE_GLX_ENABLED) + // GLX_VERSION_1_1 + // We don't create any pointers_Impl, because we assume these functions are always present. + + // GLX_VERSION_1_2 + GLELoadProc(glXGetCurrentDisplay_Impl, glXGetCurrentDisplay); + + // GLX_VERSION_1_3 + GLELoadProc(glXChooseFBConfig_Impl, glXChooseFBConfig); + GLELoadProc(glXCreateNewContext_Impl, glXCreateNewContext); + GLELoadProc(glXCreatePbuffer_Impl, glXCreatePbuffer); + GLELoadProc(glXCreatePixmap_Impl, glXCreatePixmap); + GLELoadProc(glXCreateWindow_Impl, glXCreateWindow); + GLELoadProc(glXDestroyPbuffer_Impl, glXDestroyPbuffer); + GLELoadProc(glXDestroyPixmap_Impl, glXDestroyPixmap); + GLELoadProc(glXDestroyWindow_Impl, glXDestroyWindow); + GLELoadProc(glXGetCurrentReadDrawable_Impl, glXGetCurrentReadDrawable); + GLELoadProc(glXGetFBConfigAttrib_Impl, glXGetFBConfigAttrib); + GLELoadProc(glXGetFBConfigs_Impl, glXGetFBConfigs); + GLELoadProc(glXGetSelectedEvent_Impl, glXGetSelectedEvent); + GLELoadProc(glXGetVisualFromFBConfig_Impl, glXGetVisualFromFBConfig); + GLELoadProc(glXMakeContextCurrent_Impl, glXMakeContextCurrent); + GLELoadProc(glXQueryContext_Impl, glXQueryContext); + GLELoadProc(glXQueryDrawable_Impl, glXQueryDrawable); + GLELoadProc(glXSelectEvent_Impl, glXSelectEvent); + + // GLX_VERSION_1_4 + // Nothing to declare + + // GLX_ARB_create_context + GLELoadProc(glXCreateContextAttribsARB_Impl, glXCreateContextAttribsARB); + + // GLX_EXT_swap_control + GLELoadProc(glXSwapIntervalEXT_Impl, glXSwapIntervalEXT); + + // GLX_OML_sync_control + GLELoadProc(glXGetMscRateOML_Impl, glXGetMscRateOML); + GLELoadProc(glXGetSyncValuesOML_Impl, glXGetSyncValuesOML); + GLELoadProc(glXGetSyncValuesOML_Impl, glXSwapBuffersMscOML); + GLELoadProc(glXSwapBuffersMscOML_Impl, glXSwapBuffersMscOML); + GLELoadProc(glXWaitForSbcOML_Impl, glXWaitForSbcOML); + + // GLX_MESA_swap_control + GLELoadProc(glXGetSwapIntervalMESA_Impl, glXGetSwapIntervalMESA); + GLELoadProc(glXSwapIntervalMESA_Impl, glXSwapIntervalMESA); + #endif + } + + + void OVR::GLEContext::InitPlatformExtensionSupport() + { + #if defined(GLE_WGL_ENABLED) + // We need to use wglGetExtensionsStringARB or wglGetExtensionsStringEXT as opposed to above with glGetString(GL_EXTENSIONS). + ValueStringPair vspWGLArray[] = + { + { gle_WGL_ARB_buffer_region, "WGL_ARB_buffer_region" } + ,{ gle_WGL_ARB_create_context, "WGL_ARB_create_context" } + ,{ gle_WGL_ARB_create_context_profile, "WGL_ARB_create_context_profile" } + ,{ gle_WGL_ARB_create_context_robustness, "WGL_ARB_create_context_robustness" } + ,{ gle_WGL_ARB_extensions_string, "WGL_ARB_extensions_string" } + ,{ gle_WGL_ARB_framebuffer_sRGB, "WGL_ARB_framebuffer_sRGB" } + ,{ gle_WGL_ARB_framebuffer_sRGB, "WGL_EXT_framebuffer_sRGB" } // We map the EXT to the ARB. + ,{ gle_WGL_ARB_make_current_read, "WGL_ARB_make_current_read" } + ,{ gle_WGL_ARB_pbuffer, "WGL_ARB_pbuffer" } + ,{ gle_WGL_ARB_pixel_format, "WGL_ARB_pixel_format" } + ,{ gle_WGL_ARB_pixel_format_float, "WGL_ARB_pixel_format_float" } + ,{ gle_WGL_ARB_render_texture, "WGL_ARB_render_texture" } + ,{ gle_WGL_ATI_render_texture_rectangle, "WGL_ATI_render_texture_rectangle" } + ,{ gle_WGL_EXT_extensions_string, "WGL_EXT_extensions_string" } + ,{ gle_WGL_EXT_swap_control, "WGL_EXT_swap_control" } + ,{ gle_WGL_NV_copy_image, "WGL_NV_copy_image" } + ,{ gle_WGL_NV_DX_interop, "WGL_NV_DX_interop" } + ,{ gle_WGL_NV_DX_interop2, "WGL_NV_DX_interop2" } + ,{ gle_WGL_NV_present_video, "WGL_NV_present_video" } + ,{ gle_WGL_NV_render_texture_rectangle, "WGL_NV_render_texture_rectangle" } + ,{ gle_WGL_NV_swap_group, "WGL_NV_swap_group" } + ,{ gle_WGL_NV_video_capture, "WGL_NV_video_capture" } + ,{ gle_WGL_NV_video_output, "WGL_NV_video_output" } + ,{ gle_WGL_OML_sync_control, "WGL_OML_sync_control" } + }; + + const char* extensions = NULL; + + if(wglGetExtensionsStringARB_Impl) + extensions = wglGetExtensionsStringARB_Impl(wglGetCurrentDC()); // To do: Use a better mechanism to get the desired HDC. + else if(wglGetExtensionsStringEXT_Impl) + extensions = wglGetExtensionsStringEXT_Impl(); + + if (extensions && *extensions) + { + OVR_DEBUG_LOG(("WGL_EXTENSIONS: %s", (const char*)extensions)); + CheckExtensions(vspWGLArray, OVR_ARRAY_COUNT(vspWGLArray), extensions); + } + + #elif defined(GLE_GLX_ENABLED) + ValueStringPair vspGLXArray[] = + { + { gle_GLX_ARB_create_context, "GLX_ARB_create_context" } + ,{ gle_GLX_ARB_create_context_profile, "GLX_ARB_create_context_profile" } + ,{ gle_GLX_ARB_create_context_robustness, "GLX_ARB_create_context_robustness" } + ,{ gle_GLX_EXT_swap_control, "GLX_EXT_swap_control" } + ,{ gle_GLX_OML_sync_control, "GLX_OML_sync_control" } + ,{ gle_MESA_swap_control, "GLX_MESA_swap_control" } + }; + + const char* extensions = glXGetClientString(glXGetCurrentDisplay(), GLX_EXTENSIONS); // To do: Use a better mechanism to get the desired display. + + if (extensions && *extensions) + { + OVR_DEBUG_LOG(("GLX_EXTENSIONS: %s", (const char*)extensions)); + CheckExtensions(vspGLXArray, OVR_ARRAY_COUNT(vspGLXArray), extensions); + } + #endif + } + + + #if defined(GLE_HOOKING_ENABLED) + + #undef glGetError + extern "C" { GLAPI GLenum GLAPIENTRY glGetError(); } + + // Disabled until such time as it might be useful to enable for debug purposes. + //void OVR::GLEContext::PreHook(const char* functionName) + //{ + // if(EnableHookGetError) + // { + // int err = glGetError(); + // + // for(int i = 0; (i < 6) && (err != GL_NO_ERROR); i++) // 6 is an arbitrary cap to prevent infinite looping which would occur if the current GL context is invalid. + // { + // OVR_DEBUG_LOG(("GL Error prior to hook: %d (%#x) from %s", err, err, functionName ? functionName : "OpenGL")); OVR_UNUSED(functionName); + // err = glGetError(); + // } + // } + //} + + void OVR::GLEContext::PostHook(const char* functionName) + { + if(EnableHookGetError) + { + // OpenGL Standard regarding error state: To allow for distributed implementations, there may be several error flags. If any single error flag has recorded an error, the value of that flag + // is returned and that flag is reset to GL_NO_ERROR when glGetError is called. If more than one flag has recorded an error, glGetError returns and + // clears an arbitrary error flag value. Thus, glGetError should always be called in a loop, until it returns GL_NO_ERROR, if all error flags are to be reset. + int err = glGetError(); + + for(int i = 0; (i < 6) && (err != GL_NO_ERROR); i++) // 6 is an arbitrary cap to prevent infinite looping which would occur if the current GL context is invalid. + { + OVR_DEBUG_LOG(("GL Error: %d (%#x) from %s", err, err, functionName ? functionName : "OpenGL")); OVR_UNUSED(functionName); + err = glGetError(); + } + } + } + + + // OpenGL 1.1 link-based functions + #undef glAccum // Undefine the macro from our header so that we can directly call the real version of this function. + extern "C" { GLAPI void GLAPIENTRY glAccum(GLenum op, GLfloat value); } + void OVR::GLEContext::glAccum_Hook(GLenum op, GLfloat value) + { + glAccum(op, value); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glAlphaFunc + extern "C" { GLAPI void GLAPIENTRY glAlphaFunc(GLenum func, GLclampf ref); } + void OVR::GLEContext::glAlphaFunc_Hook(GLenum func, GLclampf ref) + { + glAlphaFunc(func, ref); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glAreTexturesResident + extern "C" { GLAPI GLboolean GLAPIENTRY glAreTexturesResident(GLsizei n, const GLuint *textures, GLboolean *residences); } + GLboolean OVR::GLEContext::glAreTexturesResident_Hook(GLsizei n, const GLuint *textures, GLboolean *residences) + { + GLboolean b = glAreTexturesResident(n, textures, residences); + PostHook(GLE_CURRENT_FUNCTION); + return b; + } + + #undef glArrayElement + extern "C" { GLAPI void GLAPIENTRY glArrayElement(GLint i); } + void OVR::GLEContext::glArrayElement_Hook(GLint i) + { + glArrayElement(i); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glBegin + extern "C" { GLAPI void GLAPIENTRY glBegin(GLenum mode); } + void OVR::GLEContext::glBegin_Hook(GLenum mode) + { + glBegin(mode); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glBindTexture + extern "C" { GLAPI void GLAPIENTRY glBindTexture(GLenum target, GLuint texture); } + void OVR::GLEContext::glBindTexture_Hook(GLenum target, GLuint texture) + { + glBindTexture(target, texture); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glBitmap + extern "C" { GLAPI void GLAPIENTRY glBitmap(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap); } + void OVR::GLEContext::glBitmap_Hook(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap) + { + glBitmap(width, height, xorig, yorig, xmove, ymove, bitmap); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glBlendFunc + extern "C" { GLAPI void GLAPIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor); } + void OVR::GLEContext::glBlendFunc_Hook(GLenum sfactor, GLenum dfactor) + { + glBlendFunc(sfactor, dfactor); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glCallList + extern "C" { GLAPI void GLAPIENTRY glCallList(GLuint list); } + void OVR::GLEContext::glCallList_Hook(GLuint list) + { + glCallList(list); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glCallLists + extern "C" { GLAPI void GLAPIENTRY glCallLists(GLsizei n, GLenum type, const void *lists); } + void OVR::GLEContext::glCallLists_Hook(GLsizei n, GLenum type, const void *lists) + { + glCallLists(n, type, lists); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glClear + extern "C" { GLAPI void GLAPIENTRY glClear(GLbitfield mask); } + void OVR::GLEContext::glClear_Hook(GLbitfield mask) + { + glClear(mask); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glClearAccum + extern "C" { GLAPI void GLAPIENTRY glClearAccum(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); } + void OVR::GLEContext::glClearAccum_Hook(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) + { + glClearAccum(red, green, blue, alpha); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glClearColor + extern "C" { GLAPI void GLAPIENTRY glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); } + void OVR::GLEContext::glClearColor_Hook(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) + { + glClearColor(red, green, blue, alpha); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glClearDepth + extern "C" { GLAPI void GLAPIENTRY glClearDepth(GLclampd depth); } + void OVR::GLEContext::glClearDepth_Hook(GLclampd depth) + { + glClearDepth(depth); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glClearIndex + extern "C" { GLAPI void GLAPIENTRY glClearIndex(GLfloat c); } + void OVR::GLEContext::glClearIndex_Hook(GLfloat c) + { + glClearIndex(c); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glClearStencil + extern "C" { GLAPI void GLAPIENTRY glClearStencil(GLint s); } + void OVR::GLEContext::glClearStencil_Hook(GLint s) + { + glClearStencil(s); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glClipPlane + extern "C" { GLAPI void GLAPIENTRY glClipPlane(GLenum plane, const GLdouble *equation); } + void OVR::GLEContext::glClipPlane_Hook(GLenum plane, const GLdouble *equation) + { + glClipPlane(plane, equation); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glColor3b + extern "C" { GLAPI void GLAPIENTRY glColor3b(GLbyte red, GLbyte green, GLbyte blue); } + void OVR::GLEContext::glColor3b_Hook(GLbyte red, GLbyte green, GLbyte blue) + { + glColor3b(red, green, blue); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glColor3bv + extern "C" { GLAPI void GLAPIENTRY glColor3bv(const GLbyte *v); } + void OVR::GLEContext::glColor3bv_Hook(const GLbyte *v) + { + glColor3bv(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glColor3d + extern "C" { GLAPI void GLAPIENTRY glColor3d(GLdouble red, GLdouble green, GLdouble blue); } + void OVR::GLEContext::glColor3d_Hook(GLdouble red, GLdouble green, GLdouble blue) + { + glColor3d(red, green, blue); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glColor3dv + extern "C" { GLAPI void GLAPIENTRY glColor3dv(const GLdouble *v); } + void OVR::GLEContext::glColor3dv_Hook(const GLdouble *v) + { + glColor3dv(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glColor3f + extern "C" { GLAPI void GLAPIENTRY glColor3f(GLfloat red, GLfloat green, GLfloat blue); } + void OVR::GLEContext::glColor3f_Hook(GLfloat red, GLfloat green, GLfloat blue) + { + glColor3f(red, green, blue); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glColor3fv + extern "C" { GLAPI void GLAPIENTRY glColor3fv(const GLfloat *v); } + void OVR::GLEContext::glColor3fv_Hook(const GLfloat *v) + { + glColor3fv(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glColor3i + extern "C" { GLAPI void GLAPIENTRY glColor3i(GLint red, GLint green, GLint blue); } + void OVR::GLEContext::glColor3i_Hook(GLint red, GLint green, GLint blue) + { + glColor3i(red, green, blue); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glColor3iv + extern "C" { GLAPI void GLAPIENTRY glColor3iv(const GLint *v); } + void OVR::GLEContext::glColor3iv_Hook(const GLint *v) + { + glColor3iv(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glColor3s + extern "C" { GLAPI void GLAPIENTRY glColor3s(GLshort red, GLshort green, GLshort blue); } + void OVR::GLEContext::glColor3s_Hook(GLshort red, GLshort green, GLshort blue) + { + glColor3s(red, green, blue); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glColor3sv + extern "C" { GLAPI void GLAPIENTRY glColor3sv(const GLshort *v); } + void OVR::GLEContext::glColor3sv_Hook(const GLshort *v) + { + glColor3sv(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glColor3ub + extern "C" { GLAPI void GLAPIENTRY glColor3ub(GLubyte red, GLubyte green, GLubyte blue); } + void OVR::GLEContext::glColor3ub_Hook(GLubyte red, GLubyte green, GLubyte blue) + { + glColor3ub(red, green, blue); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glColor3ubv + extern "C" { GLAPI void GLAPIENTRY glColor3ubv(const GLubyte *v); } + void OVR::GLEContext::glColor3ubv_Hook(const GLubyte *v) + { + glColor3ubv(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glColor3ui + extern "C" { GLAPI void GLAPIENTRY glColor3ui(GLuint red, GLuint green, GLuint blue); } + void OVR::GLEContext::glColor3ui_Hook(GLuint red, GLuint green, GLuint blue) + { + glColor3ui(red, green, blue); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glColor3uiv + extern "C" { GLAPI void GLAPIENTRY glColor3uiv(const GLuint *v); } + void OVR::GLEContext::glColor3uiv_Hook(const GLuint *v) + { + glColor3uiv(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glColor3us + extern "C" { GLAPI void GLAPIENTRY glColor3us(GLushort red, GLushort green, GLushort blue); } + void OVR::GLEContext::glColor3us_Hook(GLushort red, GLushort green, GLushort blue) + { + glColor3us(red, green, blue); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glColor3usv + extern "C" { GLAPI void GLAPIENTRY glColor3usv(const GLushort *v); } + void OVR::GLEContext::glColor3usv_Hook(const GLushort *v) + { + glColor3usv(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glColor4b + extern "C" { GLAPI void GLAPIENTRY glColor4b(GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha); } + void OVR::GLEContext::glColor4b_Hook(GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha) + { + glColor4b(red, green, blue, alpha); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glColor4bv + extern "C" { GLAPI void GLAPIENTRY glColor4bv(const GLbyte *v); } + void OVR::GLEContext::glColor4bv_Hook(const GLbyte *v) + { + glColor4bv(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glColor4d + extern "C" { GLAPI void GLAPIENTRY glColor4d(GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha); } + void OVR::GLEContext::glColor4d_Hook(GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha) + { + glColor4d(red, green, blue, alpha); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glColor4dv + extern "C" { GLAPI void GLAPIENTRY glColor4dv(const GLdouble *v); } + void OVR::GLEContext::glColor4dv_Hook(const GLdouble *v) + { + glColor4dv(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glColor4f + extern "C" { GLAPI void GLAPIENTRY glColor4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); } + void OVR::GLEContext::glColor4f_Hook(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) + { + glColor4f(red, green, blue, alpha); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glColor4fv + extern "C" { GLAPI void GLAPIENTRY glColor4fv(const GLfloat *v); } + void OVR::GLEContext::glColor4fv_Hook(const GLfloat *v) + { + glColor4fv(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glColor4i + extern "C" { GLAPI void GLAPIENTRY glColor4i(GLint red, GLint green, GLint blue, GLint alpha); } + void OVR::GLEContext::glColor4i_Hook(GLint red, GLint green, GLint blue, GLint alpha) + { + glColor4i(red, green, blue, alpha); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glColor4iv + extern "C" { GLAPI void GLAPIENTRY glColor4iv(const GLint *v); } + void OVR::GLEContext::glColor4iv_Hook(const GLint *v) + { + glColor4iv(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glColor4s + extern "C" { GLAPI void GLAPIENTRY glColor4s(GLshort red, GLshort green, GLshort blue, GLshort alpha); } + void OVR::GLEContext::glColor4s_Hook(GLshort red, GLshort green, GLshort blue, GLshort alpha) + { + glColor4s(red, green, blue, alpha); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glColor4sv + extern "C" { GLAPI void GLAPIENTRY glColor4sv(const GLshort *v); } + void OVR::GLEContext::glColor4sv_Hook(const GLshort *v) + { + glColor4sv(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glColor4ub + extern "C" { GLAPI void GLAPIENTRY glColor4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha); } + void OVR::GLEContext::glColor4ub_Hook(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha) + { + glColor4ub(red, green, blue, alpha); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glColor4ubv + extern "C" { GLAPI void GLAPIENTRY glColor4ubv(const GLubyte *v); } + void OVR::GLEContext::glColor4ubv_Hook(const GLubyte *v) + { + glColor4ubv(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glColor4ui + extern "C" { GLAPI void GLAPIENTRY glColor4ui(GLuint red, GLuint green, GLuint blue, GLuint alpha); } + void OVR::GLEContext::glColor4ui_Hook(GLuint red, GLuint green, GLuint blue, GLuint alpha) + { + glColor4ui(red, green, blue, alpha); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glColor4uiv + extern "C" { GLAPI void GLAPIENTRY glColor4uiv(const GLuint *v); } + void OVR::GLEContext::glColor4uiv_Hook(const GLuint *v) + { + glColor4uiv(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glColor4us + extern "C" { GLAPI void GLAPIENTRY glColor4us(GLushort red, GLushort green, GLushort blue, GLushort alpha); } + void OVR::GLEContext::glColor4us_Hook(GLushort red, GLushort green, GLushort blue, GLushort alpha) + { + glColor4us(red, green, blue, alpha); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glColor4usv + extern "C" { GLAPI void GLAPIENTRY glColor4usv(const GLushort *v); } + void OVR::GLEContext::glColor4usv_Hook(const GLushort *v) + { + glColor4usv(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glColorMask + extern "C" { GLAPI void GLAPIENTRY glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); } + void OVR::GLEContext::glColorMask_Hook(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) + { + glColorMask(red, green, blue, alpha); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glColorMaterial + extern "C" { GLAPI void GLAPIENTRY glColorMaterial(GLenum face, GLenum mode); } + void OVR::GLEContext::glColorMaterial_Hook(GLenum face, GLenum mode) + { + glColorMaterial(face, mode); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glColorPointer + extern "C" { GLAPI void GLAPIENTRY glColorPointer(GLint size, GLenum type, GLsizei stride, const void *pointer); } + void OVR::GLEContext::glColorPointer_Hook(GLint size, GLenum type, GLsizei stride, const void *pointer) + { + glColorPointer(size, type, stride, pointer); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glCopyPixels + extern "C" { GLAPI void GLAPIENTRY glCopyPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type); } + void OVR::GLEContext::glCopyPixels_Hook(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type) + { + glCopyPixels(x, y, width, height, type); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glCopyTexImage1D + extern "C" { GLAPI void GLAPIENTRY glCopyTexImage1D(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLint border); } + void OVR::GLEContext::glCopyTexImage1D_Hook(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLint border) + { + glCopyTexImage1D(target, level, internalFormat, x, y, width, border); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glCopyTexImage2D + extern "C" { GLAPI void GLAPIENTRY glCopyTexImage2D(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); } + void OVR::GLEContext::glCopyTexImage2D_Hook(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) + { + glCopyTexImage2D(target, level, internalFormat, x, y, width, height, border); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glCopyTexSubImage1D + extern "C" { GLAPI void GLAPIENTRY glCopyTexSubImage1D(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); } + void OVR::GLEContext::glCopyTexSubImage1D_Hook(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width) + { + glCopyTexSubImage1D(target, level, xoffset, x, y, width); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glCopyTexSubImage2D + extern "C" { GLAPI void GLAPIENTRY glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); } + void OVR::GLEContext::glCopyTexSubImage2D_Hook(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) + { + glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glCullFace + extern "C" { GLAPI void GLAPIENTRY glCullFace(GLenum mode); } + void OVR::GLEContext::glCullFace_Hook(GLenum mode) + { + glCullFace(mode); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glDeleteLists + extern "C" { GLAPI void GLAPIENTRY glDeleteLists(GLuint list, GLsizei range); } + void OVR::GLEContext::glDeleteLists_Hook(GLuint list, GLsizei range) + { + glDeleteLists(list, range); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glDeleteTextures + extern "C" { GLAPI void GLAPIENTRY glDeleteTextures(GLsizei n, const GLuint *textures); } + void OVR::GLEContext::glDeleteTextures_Hook(GLsizei n, const GLuint *textures) + { + glDeleteTextures(n, textures); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glDepthFunc + extern "C" { GLAPI void GLAPIENTRY glDepthFunc(GLenum func); } + void OVR::GLEContext::glDepthFunc_Hook(GLenum func) + { + glDepthFunc(func); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glDepthMask + extern "C" { GLAPI void GLAPIENTRY glDepthMask(GLboolean flag); } + void OVR::GLEContext::glDepthMask_Hook(GLboolean flag) + { + glDepthMask(flag); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glDepthRange + extern "C" { GLAPI void GLAPIENTRY glDepthRange(GLclampd zNear, GLclampd zFar); } + void OVR::GLEContext::glDepthRange_Hook(GLclampd zNear, GLclampd zFar) + { + glDepthRange(zNear, zFar); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glDisable + extern "C" { GLAPI void GLAPIENTRY glDisable(GLenum cap); } + void OVR::GLEContext::glDisable_Hook(GLenum cap) + { + glDisable(cap); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glDisableClientState + extern "C" { GLAPI void GLAPIENTRY glDisableClientState(GLenum array); } + void OVR::GLEContext::glDisableClientState_Hook(GLenum array) + { + glDisableClientState(array); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glDrawArrays + extern "C" { GLAPI void GLAPIENTRY glDrawArrays(GLenum mode, GLint first, GLsizei count); } + void OVR::GLEContext::glDrawArrays_Hook(GLenum mode, GLint first, GLsizei count) + { + glDrawArrays(mode, first, count); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glDrawBuffer + extern "C" { GLAPI void GLAPIENTRY glDrawBuffer(GLenum mode); } + void OVR::GLEContext::glDrawBuffer_Hook(GLenum mode) + { + glDrawBuffer(mode); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glDrawElements + extern "C" { GLAPI void GLAPIENTRY glDrawElements(GLenum mode, GLsizei count, GLenum type, const void *indices); } + void OVR::GLEContext::glDrawElements_Hook(GLenum mode, GLsizei count, GLenum type, const void *indices) + { + glDrawElements(mode, count, type, indices); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glDrawPixels + extern "C" { GLAPI void GLAPIENTRY glDrawPixels(GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); } + void OVR::GLEContext::glDrawPixels_Hook(GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels) + { + glDrawPixels(width, height, format, type, pixels); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glEdgeFlag + extern "C" { GLAPI void GLAPIENTRY glEdgeFlag(GLboolean flag); } + void OVR::GLEContext::glEdgeFlag_Hook(GLboolean flag) + { + glEdgeFlag(flag); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glEdgeFlagPointer + extern "C" { GLAPI void GLAPIENTRY glEdgeFlagPointer(GLsizei stride, const void *pointer); } + void OVR::GLEContext::glEdgeFlagPointer_Hook(GLsizei stride, const void *pointer) + { + glEdgeFlagPointer(stride, pointer); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glEdgeFlagv + extern "C" { GLAPI void GLAPIENTRY glEdgeFlagv(const GLboolean *flag); } + void OVR::GLEContext::glEdgeFlagv_Hook(const GLboolean *flag) + { + glEdgeFlagv(flag); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glEnable + extern "C" { GLAPI void GLAPIENTRY glEnable(GLenum cap); } + namespace OVR { + void GLEContext::glEnable_Hook(GLenum cap) + { + glEnable(cap); + PostHook(GLE_CURRENT_FUNCTION); + } + } + + #undef glEnableClientState + extern "C" { GLAPI void GLAPIENTRY glEnableClientState(GLenum array); } + void OVR::GLEContext::glEnableClientState_Hook(GLenum array) + { + glEnableClientState(array); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glEnd + extern "C" { GLAPI void GLAPIENTRY glEnd(); } + void OVR::GLEContext::glEnd_Hook() + { + glEnd(); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glEndList + extern "C" { GLAPI void GLAPIENTRY glEndList(); } + void OVR::GLEContext::glEndList_Hook() + { + glEndList(); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glEvalCoord1d + extern "C" { GLAPI void GLAPIENTRY glEvalCoord1d(GLdouble u); } + void OVR::GLEContext::glEvalCoord1d_Hook(GLdouble u) + { + glEvalCoord1d(u); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glEvalCoord1dv + extern "C" { GLAPI void GLAPIENTRY glEvalCoord1dv(const GLdouble *u); } + void OVR::GLEContext::glEvalCoord1dv_Hook(const GLdouble *u) + { + glEvalCoord1dv(u); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glEvalCoord1f + extern "C" { GLAPI void GLAPIENTRY glEvalCoord1f(GLfloat u); } + void OVR::GLEContext::glEvalCoord1f_Hook(GLfloat u) + { + glEvalCoord1f(u); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glEvalCoord1fv + extern "C" { GLAPI void GLAPIENTRY glEvalCoord1fv(const GLfloat *u); } + void OVR::GLEContext::glEvalCoord1fv_Hook(const GLfloat *u) + { + glEvalCoord1fv(u); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glEvalCoord2d + extern "C" { GLAPI void GLAPIENTRY glEvalCoord2d(GLdouble u, GLdouble v); } + void OVR::GLEContext::glEvalCoord2d_Hook(GLdouble u, GLdouble v) + { + glEvalCoord2d(u, v); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glEvalCoord2dv + extern "C" { GLAPI void GLAPIENTRY glEvalCoord2dv(const GLdouble *u); } + void OVR::GLEContext::glEvalCoord2dv_Hook(const GLdouble *u) + { + glEvalCoord2dv(u); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glEvalCoord2f + extern "C" { GLAPI void GLAPIENTRY glEvalCoord2f(GLfloat u, GLfloat v); } + void OVR::GLEContext::glEvalCoord2f_Hook(GLfloat u, GLfloat v) + { + glEvalCoord2f(u, v); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glEvalCoord2fv + extern "C" { GLAPI void GLAPIENTRY glEvalCoord2fv(const GLfloat *u); } + void OVR::GLEContext::glEvalCoord2fv_Hook(const GLfloat *u) + { + glEvalCoord2fv(u); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glEvalMesh1 + extern "C" { GLAPI void GLAPIENTRY glEvalMesh1(GLenum mode, GLint i1, GLint i2); } + void OVR::GLEContext::glEvalMesh1_Hook(GLenum mode, GLint i1, GLint i2) + { + glEvalMesh1(mode, i1, i2); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glEvalMesh2 + extern "C" { GLAPI void GLAPIENTRY glEvalMesh2(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2); } + void OVR::GLEContext::glEvalMesh2_Hook(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2) + { + glEvalMesh2(mode, i1, i2, j1, j2); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glEvalPoint1 + extern "C" { GLAPI void GLAPIENTRY glEvalPoint1(GLint i); } + void OVR::GLEContext::glEvalPoint1_Hook(GLint i) + { + glEvalPoint1(i); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glEvalPoint2 + extern "C" { GLAPI void GLAPIENTRY glEvalPoint2(GLint i, GLint j); } + void OVR::GLEContext::glEvalPoint2_Hook(GLint i, GLint j) + { + glEvalPoint2(i, j); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glFeedbackBuffer + extern "C" { GLAPI void GLAPIENTRY glFeedbackBuffer(GLsizei size, GLenum type, GLfloat *buffer); } + void OVR::GLEContext::glFeedbackBuffer_Hook(GLsizei size, GLenum type, GLfloat *buffer) + { + glFeedbackBuffer(size, type, buffer); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glFinish + extern "C" { GLAPI void GLAPIENTRY glFinish(); } + void OVR::GLEContext::glFinish_Hook() + { + glFinish(); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glFlush + extern "C" { GLAPI void GLAPIENTRY glFlush(); } + void OVR::GLEContext::glFlush_Hook() + { + glFlush(); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glFogf + extern "C" { GLAPI void GLAPIENTRY glFogf(GLenum pname, GLfloat param); } + void OVR::GLEContext::glFogf_Hook(GLenum pname, GLfloat param) + { + glFogf(pname, param); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glFogfv + extern "C" { GLAPI void GLAPIENTRY glFogfv(GLenum pname, const GLfloat *params); } + void OVR::GLEContext::glFogfv_Hook(GLenum pname, const GLfloat *params) + { + glFogfv(pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glFogi + extern "C" { GLAPI void GLAPIENTRY glFogi(GLenum pname, GLint param); } + void OVR::GLEContext::glFogi_Hook(GLenum pname, GLint param) + { + glFogi(pname, param); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glFogiv + extern "C" { GLAPI void GLAPIENTRY glFogiv(GLenum pname, const GLint *params); } + void OVR::GLEContext::glFogiv_Hook(GLenum pname, const GLint *params) + { + glFogiv(pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glFrontFace + extern "C" { GLAPI void GLAPIENTRY glFrontFace(GLenum mode); } + void OVR::GLEContext::glFrontFace_Hook(GLenum mode) + { + glFrontFace(mode); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glFrustum + extern "C" { GLAPI void GLAPIENTRY glFrustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); } + void OVR::GLEContext::glFrustum_Hook(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar) + { + glFrustum(left, right, bottom, top, zNear, zFar); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glGenLists + extern "C" { GLAPI GLuint GLAPIENTRY glGenLists(GLsizei range); } + GLuint OVR::GLEContext::glGenLists_Hook(GLsizei range) + { + GLuint u = glGenLists(range); + PostHook(GLE_CURRENT_FUNCTION); + return u; + } + + #undef glGenTextures + extern "C" { GLAPI void GLAPIENTRY glGenTextures(GLsizei n, GLuint *textures); } + void OVR::GLEContext::glGenTextures_Hook(GLsizei n, GLuint *textures) + { + glGenTextures(n, textures); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glGetBooleanv + extern "C" { GLAPI void GLAPIENTRY glGetBooleanv(GLenum pname, GLboolean *params); } + void OVR::GLEContext::glGetBooleanv_Hook(GLenum pname, GLboolean *params) + { + glGetBooleanv(pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glGetClipPlane + extern "C" { GLAPI void GLAPIENTRY glGetClipPlane(GLenum plane, GLdouble *equation); } + void OVR::GLEContext::glGetClipPlane_Hook(GLenum plane, GLdouble *equation) + { + glGetClipPlane(plane, equation); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glGetDoublev + extern "C" { GLAPI void GLAPIENTRY glGetDoublev(GLenum pname, GLdouble *params); } + void OVR::GLEContext::glGetDoublev_Hook(GLenum pname, GLdouble *params) + { + glGetDoublev(pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + //#undef glGetError Not needed because we happen to do this above already. + //extern "C" { GLAPI GLenum GLAPIENTRY glGetError(); } + GLenum OVR::GLEContext::glGetError_Hook() + { + GLenum e = glGetError(); + PostHook(GLE_CURRENT_FUNCTION); + return e; + } + + #undef glGetFloatv + extern "C" { GLAPI void GLAPIENTRY glGetFloatv(GLenum pname, GLfloat *params); } + void OVR::GLEContext::glGetFloatv_Hook(GLenum pname, GLfloat *params) + { + glGetFloatv(pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glGetIntegerv + extern "C" { GLAPI void GLAPIENTRY glGetIntegerv(GLenum pname, GLint *params); } + void OVR::GLEContext::glGetIntegerv_Hook(GLenum pname, GLint *params) + { + glGetIntegerv(pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glGetLightfv + extern "C" { GLAPI void GLAPIENTRY glGetLightfv(GLenum light, GLenum pname, GLfloat *params); } + void OVR::GLEContext::glGetLightfv_Hook(GLenum light, GLenum pname, GLfloat *params) + { + glGetLightfv(light, pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glGetLightiv + extern "C" { GLAPI void GLAPIENTRY glGetLightiv(GLenum light, GLenum pname, GLint *params); } + void OVR::GLEContext::glGetLightiv_Hook(GLenum light, GLenum pname, GLint *params) + { + glGetLightiv(light, pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glGetMapdv + extern "C" { GLAPI void GLAPIENTRY glGetMapdv(GLenum target, GLenum query, GLdouble *v); } + void OVR::GLEContext::glGetMapdv_Hook(GLenum target, GLenum query, GLdouble *v) + { + glGetMapdv(target, query, v); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glGetMapfv + extern "C" { GLAPI void GLAPIENTRY glGetMapfv(GLenum target, GLenum query, GLfloat *v); } + void OVR::GLEContext::glGetMapfv_Hook(GLenum target, GLenum query, GLfloat *v) + { + glGetMapfv(target, query, v); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glGetMapiv + extern "C" { GLAPI void GLAPIENTRY glGetMapiv(GLenum target, GLenum query, GLint *v); } + void OVR::GLEContext::glGetMapiv_Hook(GLenum target, GLenum query, GLint *v) + { + glGetMapiv(target, query, v); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glGetMaterialfv + extern "C" { GLAPI void GLAPIENTRY glGetMaterialfv(GLenum face, GLenum pname, GLfloat *params); } + void OVR::GLEContext::glGetMaterialfv_Hook(GLenum face, GLenum pname, GLfloat *params) + { + glGetMaterialfv(face, pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glGetMaterialiv + extern "C" { GLAPI void GLAPIENTRY glGetMaterialiv(GLenum face, GLenum pname, GLint *params); } + void OVR::GLEContext::glGetMaterialiv_Hook(GLenum face, GLenum pname, GLint *params) + { + glGetMaterialiv(face, pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glGetPixelMapfv + extern "C" { GLAPI void GLAPIENTRY glGetPixelMapfv(GLenum map, GLfloat *values); } + void OVR::GLEContext::glGetPixelMapfv_Hook(GLenum map, GLfloat *values) + { + glGetPixelMapfv(map, values); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glGetPixelMapuiv + extern "C" { GLAPI void GLAPIENTRY glGetPixelMapuiv(GLenum map, GLuint *values); } + void OVR::GLEContext::glGetPixelMapuiv_Hook(GLenum map, GLuint *values) + { + glGetPixelMapuiv(map, values); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glGetPixelMapusv + extern "C" { GLAPI void GLAPIENTRY glGetPixelMapusv(GLenum map, GLushort *values); } + void OVR::GLEContext::glGetPixelMapusv_Hook(GLenum map, GLushort *values) + { + glGetPixelMapusv(map, values); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glGetPointerv + extern "C" { GLAPI void GLAPIENTRY glGetPointerv(GLenum pname, void* *params); } + void OVR::GLEContext::glGetPointerv_Hook(GLenum pname, void* *params) + { + glGetPointerv(pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glGetPolygonStipple + extern "C" { GLAPI void GLAPIENTRY glGetPolygonStipple(GLubyte *mask); } + void OVR::GLEContext::glGetPolygonStipple_Hook(GLubyte *mask) + { + glGetPolygonStipple(mask); + PostHook(GLE_CURRENT_FUNCTION); + } + + // #undef glGetString // This was already disabled above. + // extern "C" { GLAPI const GLubyte * GLAPIENTRY glGetString(GLenum name); } + const GLubyte * OVR::GLEContext::glGetString_Hook(GLenum name) + { + const GLubyte * p = glGetString(name); + PostHook(GLE_CURRENT_FUNCTION); + return p; + } + + #undef glGetTexEnvfv + extern "C" { GLAPI void GLAPIENTRY glGetTexEnvfv(GLenum target, GLenum pname, GLfloat *params); } + void OVR::GLEContext::glGetTexEnvfv_Hook(GLenum target, GLenum pname, GLfloat *params) + { + glGetTexEnvfv(target, pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glGetTexEnviv + extern "C" { GLAPI void GLAPIENTRY glGetTexEnviv(GLenum target, GLenum pname, GLint *params); } + void OVR::GLEContext::glGetTexEnviv_Hook(GLenum target, GLenum pname, GLint *params) + { + glGetTexEnviv(target, pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glGetTexGendv + extern "C" { GLAPI void GLAPIENTRY glGetTexGendv(GLenum coord, GLenum pname, GLdouble *params); } + void OVR::GLEContext::glGetTexGendv_Hook(GLenum coord, GLenum pname, GLdouble *params) + { + glGetTexGendv(coord, pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glGetTexGenfv + extern "C" { GLAPI void GLAPIENTRY glGetTexGenfv(GLenum coord, GLenum pname, GLfloat *params); } + void OVR::GLEContext::glGetTexGenfv_Hook(GLenum coord, GLenum pname, GLfloat *params) + { + glGetTexGenfv(coord, pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glGetTexGeniv + extern "C" { GLAPI void GLAPIENTRY glGetTexGeniv(GLenum coord, GLenum pname, GLint *params); } + void OVR::GLEContext::glGetTexGeniv_Hook(GLenum coord, GLenum pname, GLint *params) + { + glGetTexGeniv(coord, pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glGetTexImage + extern "C" { GLAPI void GLAPIENTRY glGetTexImage(GLenum target, GLint level, GLenum format, GLenum type, void *pixels); } + void OVR::GLEContext::glGetTexImage_Hook(GLenum target, GLint level, GLenum format, GLenum type, void *pixels) + { + glGetTexImage(target, level, format, type, pixels); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glGetTexLevelParameterfv + extern "C" { GLAPI void GLAPIENTRY glGetTexLevelParameterfv(GLenum target, GLint level, GLenum pname, GLfloat *params); } + void OVR::GLEContext::glGetTexLevelParameterfv_Hook(GLenum target, GLint level, GLenum pname, GLfloat *params) + { + glGetTexLevelParameterfv(target, level, pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glGetTexLevelParameteriv + extern "C" { GLAPI void GLAPIENTRY glGetTexLevelParameteriv(GLenum target, GLint level, GLenum pname, GLint *params); } + void OVR::GLEContext::glGetTexLevelParameteriv_Hook(GLenum target, GLint level, GLenum pname, GLint *params) + { + glGetTexLevelParameteriv(target, level, pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glGetTexParameterfv + extern "C" { GLAPI void GLAPIENTRY glGetTexParameterfv(GLenum target, GLenum pname, GLfloat *params); } + void OVR::GLEContext::glGetTexParameterfv_Hook(GLenum target, GLenum pname, GLfloat *params) + { + glGetTexParameterfv(target, pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glGetTexParameteriv + extern "C" { GLAPI void GLAPIENTRY glGetTexParameteriv(GLenum target, GLenum pname, GLint *params); } + void OVR::GLEContext::glGetTexParameteriv_Hook(GLenum target, GLenum pname, GLint *params) + { + glGetTexParameteriv(target, pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glHint + extern "C" { GLAPI void GLAPIENTRY glHint(GLenum target, GLenum mode); } + void OVR::GLEContext::glHint_Hook(GLenum target, GLenum mode) + { + glHint(target, mode); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glIndexMask + extern "C" { GLAPI void GLAPIENTRY glIndexMask(GLuint mask); } + void OVR::GLEContext::glIndexMask_Hook(GLuint mask) + { + glIndexMask(mask); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glIndexPointer + extern "C" { GLAPI void GLAPIENTRY glIndexPointer(GLenum type, GLsizei stride, const void *pointer); } + void OVR::GLEContext::glIndexPointer_Hook(GLenum type, GLsizei stride, const void *pointer) + { + glIndexPointer(type, stride, pointer); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glIndexd + extern "C" { GLAPI void GLAPIENTRY glIndexd(GLdouble c); } + void OVR::GLEContext::glIndexd_Hook(GLdouble c) + { + glIndexd(c); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glIndexdv + extern "C" { GLAPI void GLAPIENTRY glIndexdv(const GLdouble *c); } + void OVR::GLEContext::glIndexdv_Hook(const GLdouble *c) + { + glIndexdv(c); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glIndexf + extern "C" { GLAPI void GLAPIENTRY glIndexf(GLfloat c); } + void OVR::GLEContext::glIndexf_Hook(GLfloat c) + { + glIndexf(c); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glIndexfv + extern "C" { GLAPI void GLAPIENTRY glIndexfv(const GLfloat *c); } + void OVR::GLEContext::glIndexfv_Hook(const GLfloat *c) + { + glIndexfv(c); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glIndexi + extern "C" { GLAPI void GLAPIENTRY glIndexi(GLint c); } + void OVR::GLEContext::glIndexi_Hook(GLint c) + { + glIndexi(c); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glIndexiv + extern "C" { GLAPI void GLAPIENTRY glIndexiv(const GLint *c); } + void OVR::GLEContext::glIndexiv_Hook(const GLint *c) + { + glIndexiv(c); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glIndexs + extern "C" { GLAPI void GLAPIENTRY glIndexs(GLshort c); } + void OVR::GLEContext::glIndexs_Hook(GLshort c) + { + glIndexs(c); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glIndexsv + extern "C" { GLAPI void GLAPIENTRY glIndexsv(const GLshort *c); } + void OVR::GLEContext::glIndexsv_Hook(const GLshort *c) + { + glIndexsv(c); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glIndexub + extern "C" { GLAPI void GLAPIENTRY glIndexub(GLubyte c); } + void OVR::GLEContext::glIndexub_Hook(GLubyte c) + { + glIndexub(c); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glIndexubv + extern "C" { GLAPI void GLAPIENTRY glIndexubv(const GLubyte *c); } + void OVR::GLEContext::glIndexubv_Hook(const GLubyte *c) + { + glIndexubv(c); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glInitNames + extern "C" { GLAPI void GLAPIENTRY glInitNames(); } + void OVR::GLEContext::glInitNames_Hook() + { + glInitNames(); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glInterleavedArrays + extern "C" { GLAPI void GLAPIENTRY glInterleavedArrays(GLenum format, GLsizei stride, const void *pointer); } + void OVR::GLEContext::glInterleavedArrays_Hook(GLenum format, GLsizei stride, const void *pointer) + { + glInterleavedArrays(format, stride, pointer); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glIsEnabled + extern "C" { GLAPI GLboolean GLAPIENTRY glIsEnabled(GLenum cap); } + GLboolean OVR::GLEContext::glIsEnabled_Hook(GLenum cap) + { + GLboolean b = glIsEnabled(cap); + PostHook(GLE_CURRENT_FUNCTION); + return b; + } + + #undef glIsList + extern "C" { GLAPI GLboolean GLAPIENTRY glIsList(GLuint list); } + GLboolean OVR::GLEContext::glIsList_Hook(GLuint list) + { + GLboolean b = glIsList(list); + PostHook(GLE_CURRENT_FUNCTION); + return b; + } + + #undef glIsTexture + extern "C" { GLAPI GLboolean GLAPIENTRY glIsTexture(GLuint texture); } + GLboolean OVR::GLEContext::glIsTexture_Hook(GLuint texture) + { + GLboolean b = glIsTexture(texture); + PostHook(GLE_CURRENT_FUNCTION); + return b; + } + + #undef glLightModelf + extern "C" { GLAPI void GLAPIENTRY glLightModelf(GLenum pname, GLfloat param); } + void OVR::GLEContext::glLightModelf_Hook(GLenum pname, GLfloat param) + { + glLightModelf(pname, param); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glLightModelfv + extern "C" { GLAPI void GLAPIENTRY glLightModelfv(GLenum pname, const GLfloat *params); } + void OVR::GLEContext::glLightModelfv_Hook(GLenum pname, const GLfloat *params) + { + glLightModelfv(pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glLightModeli + extern "C" { GLAPI void GLAPIENTRY glLightModeli(GLenum pname, GLint param); } + void OVR::GLEContext::glLightModeli_Hook(GLenum pname, GLint param) + { + glLightModeli(pname, param); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glLightModeliv + extern "C" { GLAPI void GLAPIENTRY glLightModeliv(GLenum pname, const GLint *params); } + void OVR::GLEContext::glLightModeliv_Hook(GLenum pname, const GLint *params) + { + glLightModeliv(pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glLightf + extern "C" { GLAPI void GLAPIENTRY glLightf(GLenum light, GLenum pname, GLfloat param); } + void OVR::GLEContext::glLightf_Hook(GLenum light, GLenum pname, GLfloat param) + { + glLightf(light, pname, param); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glLightfv + extern "C" { GLAPI void GLAPIENTRY glLightfv(GLenum light, GLenum pname, const GLfloat *params); } + void OVR::GLEContext::glLightfv_Hook(GLenum light, GLenum pname, const GLfloat *params) + { + glLightfv(light, pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glLighti + extern "C" { GLAPI void GLAPIENTRY glLighti(GLenum light, GLenum pname, GLint param); } + void OVR::GLEContext::glLighti_Hook(GLenum light, GLenum pname, GLint param) + { + glLighti(light, pname, param); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glLightiv + extern "C" { GLAPI void GLAPIENTRY glLightiv(GLenum light, GLenum pname, const GLint *params); } + void OVR::GLEContext::glLightiv_Hook(GLenum light, GLenum pname, const GLint *params) + { + glLightiv(light, pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glLineStipple + extern "C" { GLAPI void GLAPIENTRY glLineStipple(GLint factor, GLushort pattern); } + void OVR::GLEContext::glLineStipple_Hook(GLint factor, GLushort pattern) + { + glLineStipple(factor, pattern); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glLineWidth + extern "C" { GLAPI void GLAPIENTRY glLineWidth(GLfloat width); } + void OVR::GLEContext::glLineWidth_Hook(GLfloat width) + { + glLineWidth(width); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glListBase + extern "C" { GLAPI void GLAPIENTRY glListBase(GLuint base); } + void OVR::GLEContext::glListBase_Hook(GLuint base) + { + glListBase(base); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glLoadIdentity + extern "C" { GLAPI void GLAPIENTRY glLoadIdentity(); } + void OVR::GLEContext::glLoadIdentity_Hook() + { + glLoadIdentity(); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glLoadMatrixd + extern "C" { GLAPI void GLAPIENTRY glLoadMatrixd(const GLdouble *m); } + void OVR::GLEContext::glLoadMatrixd_Hook(const GLdouble *m) + { + glLoadMatrixd(m); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glLoadMatrixf + extern "C" { GLAPI void GLAPIENTRY glLoadMatrixf(const GLfloat *m); } + void OVR::GLEContext::glLoadMatrixf_Hook(const GLfloat *m) + { + glLoadMatrixf(m); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glLoadName + extern "C" { GLAPI void GLAPIENTRY glLoadName(GLuint name); } + void OVR::GLEContext::glLoadName_Hook(GLuint name) + { + glLoadName(name); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glLogicOp + extern "C" { GLAPI void GLAPIENTRY glLogicOp(GLenum opcode); } + void OVR::GLEContext::glLogicOp_Hook(GLenum opcode) + { + glLogicOp(opcode); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glMap1d + extern "C" { GLAPI void GLAPIENTRY glMap1d(GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); } + void OVR::GLEContext::glMap1d_Hook(GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points) + { + glMap1d(target, u1, u2, stride, order, points); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glMap1f + extern "C" { GLAPI void GLAPIENTRY glMap1f(GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); } + void OVR::GLEContext::glMap1f_Hook(GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points) + { + glMap1f(target, u1, u2, stride, order, points); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glMap2d + extern "C" { GLAPI void GLAPIENTRY glMap2d(GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); } + void OVR::GLEContext::glMap2d_Hook(GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points) + { + glMap2d(target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glMap2f + extern "C" { GLAPI void GLAPIENTRY glMap2f(GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); } + void OVR::GLEContext::glMap2f_Hook(GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points) + { + glMap2f(target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glMapGrid1d + extern "C" { GLAPI void GLAPIENTRY glMapGrid1d(GLint un, GLdouble u1, GLdouble u2); } + void OVR::GLEContext::glMapGrid1d_Hook(GLint un, GLdouble u1, GLdouble u2) + { + glMapGrid1d(un, u1, u2); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glMapGrid1f + extern "C" { GLAPI void GLAPIENTRY glMapGrid1f(GLint un, GLfloat u1, GLfloat u2); } + void OVR::GLEContext::glMapGrid1f_Hook(GLint un, GLfloat u1, GLfloat u2) + { + glMapGrid1f(un, u1, u2); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glMapGrid2d + extern "C" { GLAPI void GLAPIENTRY glMapGrid2d(GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2); } + void OVR::GLEContext::glMapGrid2d_Hook(GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2) + { + glMapGrid2d(un, u1, u2, vn, v1, v2); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glMapGrid2f + extern "C" { GLAPI void GLAPIENTRY glMapGrid2f(GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2); } + void OVR::GLEContext::glMapGrid2f_Hook(GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2) + { + glMapGrid2f(un, u1, u2, vn, v1, v2); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glMaterialf + extern "C" { GLAPI void GLAPIENTRY glMaterialf(GLenum face, GLenum pname, GLfloat param); } + void OVR::GLEContext::glMaterialf_Hook(GLenum face, GLenum pname, GLfloat param) + { + glMaterialf(face, pname, param); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glMaterialfv + extern "C" { GLAPI void GLAPIENTRY glMaterialfv(GLenum face, GLenum pname, const GLfloat *params); } + void OVR::GLEContext::glMaterialfv_Hook(GLenum face, GLenum pname, const GLfloat *params) + { + glMaterialfv(face, pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glMateriali + extern "C" { GLAPI void GLAPIENTRY glMateriali(GLenum face, GLenum pname, GLint param); } + void OVR::GLEContext::glMateriali_Hook(GLenum face, GLenum pname, GLint param) + { + glMateriali(face, pname, param); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glMaterialiv + extern "C" { GLAPI void GLAPIENTRY glMaterialiv(GLenum face, GLenum pname, const GLint *params); } + void OVR::GLEContext::glMaterialiv_Hook(GLenum face, GLenum pname, const GLint *params) + { + glMaterialiv(face, pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glMatrixMode + extern "C" { GLAPI void GLAPIENTRY glMatrixMode(GLenum mode); } + void OVR::GLEContext::glMatrixMode_Hook(GLenum mode) + { + glMatrixMode(mode); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glMultMatrixd + extern "C" { GLAPI void GLAPIENTRY glMultMatrixd(const GLdouble *m); } + void OVR::GLEContext::glMultMatrixd_Hook(const GLdouble *m) + { + glMultMatrixd(m); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glMultMatrixf + extern "C" { GLAPI void GLAPIENTRY glMultMatrixf(const GLfloat *m); } + void OVR::GLEContext::glMultMatrixf_Hook(const GLfloat *m) + { + glMultMatrixf(m); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glNewList + extern "C" { GLAPI void GLAPIENTRY glNewList(GLuint list, GLenum mode); } + void OVR::GLEContext::glNewList_Hook(GLuint list, GLenum mode) + { + glNewList(list, mode); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glNormal3b + extern "C" { GLAPI void GLAPIENTRY glNormal3b(GLbyte nx, GLbyte ny, GLbyte nz); } + void OVR::GLEContext::glNormal3b_Hook(GLbyte nx, GLbyte ny, GLbyte nz) + { + glNormal3b(nx, ny, nz); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glNormal3bv + extern "C" { GLAPI void GLAPIENTRY glNormal3bv(const GLbyte *v); } + void OVR::GLEContext::glNormal3bv_Hook(const GLbyte *v) + { + glNormal3bv(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glNormal3d + extern "C" { GLAPI void GLAPIENTRY glNormal3d(GLdouble nx, GLdouble ny, GLdouble nz); } + void OVR::GLEContext::glNormal3d_Hook(GLdouble nx, GLdouble ny, GLdouble nz) + { + glNormal3d(nx, ny, nz); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glNormal3dv + extern "C" { GLAPI void GLAPIENTRY glNormal3dv(const GLdouble *v); } + void OVR::GLEContext::glNormal3dv_Hook(const GLdouble *v) + { + glNormal3dv(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glNormal3f + extern "C" { GLAPI void GLAPIENTRY glNormal3f(GLfloat nx, GLfloat ny, GLfloat nz); } + void OVR::GLEContext::glNormal3f_Hook(GLfloat nx, GLfloat ny, GLfloat nz) + { + glNormal3f(nx, ny, nz); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glNormal3fv + extern "C" { GLAPI void GLAPIENTRY glNormal3fv(const GLfloat *v); } + void OVR::GLEContext::glNormal3fv_Hook(const GLfloat *v) + { + glNormal3fv(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glNormal3i + extern "C" { GLAPI void GLAPIENTRY glNormal3i(GLint nx, GLint ny, GLint nz); } + void OVR::GLEContext::glNormal3i_Hook(GLint nx, GLint ny, GLint nz) + { + glNormal3i(nx, ny, nz); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glNormal3iv + extern "C" { GLAPI void GLAPIENTRY glNormal3iv(const GLint *v); } + void OVR::GLEContext::glNormal3iv_Hook(const GLint *v) + { + glNormal3iv(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glNormal3s + extern "C" { GLAPI void GLAPIENTRY glNormal3s(GLshort nx, GLshort ny, GLshort nz); } + void OVR::GLEContext::glNormal3s_Hook(GLshort nx, GLshort ny, GLshort nz) + { + glNormal3s(nx, ny, nz); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glNormal3sv + extern "C" { GLAPI void GLAPIENTRY glNormal3sv(const GLshort *v); } + void OVR::GLEContext::glNormal3sv_Hook(const GLshort *v) + { + glNormal3sv(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glNormalPointer + extern "C" { GLAPI void GLAPIENTRY glNormalPointer(GLenum type, GLsizei stride, const void *pointer); } + void OVR::GLEContext::glNormalPointer_Hook(GLenum type, GLsizei stride, const void *pointer) + { + glNormalPointer(type, stride, pointer); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glOrtho + extern "C" { GLAPI void GLAPIENTRY glOrtho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); } + void OVR::GLEContext::glOrtho_Hook(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar) + { + glOrtho(left, right, bottom, top, zNear, zFar); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glPassThrough + extern "C" { GLAPI void GLAPIENTRY glPassThrough(GLfloat token); } + void OVR::GLEContext::glPassThrough_Hook(GLfloat token) + { + glPassThrough(token); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glPixelMapfv + extern "C" { GLAPI void GLAPIENTRY glPixelMapfv(GLenum map, GLsizei mapsize, const GLfloat *values); } + void OVR::GLEContext::glPixelMapfv_Hook(GLenum map, GLsizei mapsize, const GLfloat *values) + { + glPixelMapfv(map, mapsize, values); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glPixelMapuiv + extern "C" { GLAPI void GLAPIENTRY glPixelMapuiv(GLenum map, GLsizei mapsize, const GLuint *values); } + void OVR::GLEContext::glPixelMapuiv_Hook(GLenum map, GLsizei mapsize, const GLuint *values) + { + glPixelMapuiv(map, mapsize, values); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glPixelMapusv + extern "C" { GLAPI void GLAPIENTRY glPixelMapusv(GLenum map, GLsizei mapsize, const GLushort *values); } + void OVR::GLEContext::glPixelMapusv_Hook(GLenum map, GLsizei mapsize, const GLushort *values) + { + glPixelMapusv(map, mapsize, values); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glPixelStoref + extern "C" { GLAPI void GLAPIENTRY glPixelStoref(GLenum pname, GLfloat param); } + void OVR::GLEContext::glPixelStoref_Hook(GLenum pname, GLfloat param) + { + glPixelStoref(pname, param); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glPixelStorei + extern "C" { GLAPI void GLAPIENTRY glPixelStorei(GLenum pname, GLint param); } + void OVR::GLEContext::glPixelStorei_Hook(GLenum pname, GLint param) + { + glPixelStorei(pname, param); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glPixelTransferf + extern "C" { GLAPI void GLAPIENTRY glPixelTransferf(GLenum pname, GLfloat param); } + void OVR::GLEContext::glPixelTransferf_Hook(GLenum pname, GLfloat param) + { + glPixelTransferf(pname, param); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glPixelTransferi + extern "C" { GLAPI void GLAPIENTRY glPixelTransferi(GLenum pname, GLint param); } + void OVR::GLEContext::glPixelTransferi_Hook(GLenum pname, GLint param) + { + glPixelTransferi(pname, param); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glPixelZoom + extern "C" { GLAPI void GLAPIENTRY glPixelZoom(GLfloat xfactor, GLfloat yfactor); } + void OVR::GLEContext::glPixelZoom_Hook(GLfloat xfactor, GLfloat yfactor) + { + glPixelZoom(xfactor, yfactor); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glPointSize + extern "C" { GLAPI void GLAPIENTRY glPointSize(GLfloat size); } + void OVR::GLEContext::glPointSize_Hook(GLfloat size) + { + glPointSize(size); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glPolygonMode + extern "C" { GLAPI void GLAPIENTRY glPolygonMode(GLenum face, GLenum mode); } + void OVR::GLEContext::glPolygonMode_Hook(GLenum face, GLenum mode) + { + glPolygonMode(face, mode); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glPolygonOffset + extern "C" { GLAPI void GLAPIENTRY glPolygonOffset(GLfloat factor, GLfloat units); } + void OVR::GLEContext::glPolygonOffset_Hook(GLfloat factor, GLfloat units) + { + glPolygonOffset(factor, units); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glPolygonStipple + extern "C" { GLAPI void GLAPIENTRY glPolygonStipple(const GLubyte *mask); } + void OVR::GLEContext::glPolygonStipple_Hook(const GLubyte *mask) + { + glPolygonStipple(mask); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glPopAttrib + extern "C" { GLAPI void GLAPIENTRY glPopAttrib(); } + void OVR::GLEContext::glPopAttrib_Hook() + { + glPopAttrib(); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glPopClientAttrib + extern "C" { GLAPI void GLAPIENTRY glPopClientAttrib(); } + void OVR::GLEContext::glPopClientAttrib_Hook() + { + glPopClientAttrib(); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glPopMatrix + extern "C" { GLAPI void GLAPIENTRY glPopMatrix(); } + void OVR::GLEContext::glPopMatrix_Hook() + { + glPopMatrix(); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glPopName + extern "C" { GLAPI void GLAPIENTRY glPopName(); } + void OVR::GLEContext::glPopName_Hook() + { + glPopName(); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glPrioritizeTextures + extern "C" { GLAPI void GLAPIENTRY glPrioritizeTextures(GLsizei n, const GLuint *textures, const GLclampf *priorities); } + void OVR::GLEContext::glPrioritizeTextures_Hook(GLsizei n, const GLuint *textures, const GLclampf *priorities) + { + glPrioritizeTextures(n, textures, priorities); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glPushAttrib + extern "C" { GLAPI void GLAPIENTRY glPushAttrib(GLbitfield mask); } + void OVR::GLEContext::glPushAttrib_Hook(GLbitfield mask) + { + glPushAttrib(mask); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glPushClientAttrib + extern "C" { GLAPI void GLAPIENTRY glPushClientAttrib(GLbitfield mask); } + void OVR::GLEContext::glPushClientAttrib_Hook(GLbitfield mask) + { + glPushClientAttrib(mask); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glPushMatrix + extern "C" { GLAPI void GLAPIENTRY glPushMatrix(); } + void OVR::GLEContext::glPushMatrix_Hook() + { + glPushMatrix(); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glPushName + extern "C" { GLAPI void GLAPIENTRY glPushName(GLuint name); } + void OVR::GLEContext::glPushName_Hook(GLuint name) + { + glPushName(name); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glRasterPos2d + extern "C" { GLAPI void GLAPIENTRY glRasterPos2d(GLdouble x, GLdouble y); } + void OVR::GLEContext::glRasterPos2d_Hook(GLdouble x, GLdouble y) + { + glRasterPos2d(x, y); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glRasterPos2dv + extern "C" { GLAPI void GLAPIENTRY glRasterPos2dv(const GLdouble *v); } + void OVR::GLEContext::glRasterPos2dv_Hook(const GLdouble *v) + { + glRasterPos2dv(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glRasterPos2f + extern "C" { GLAPI void GLAPIENTRY glRasterPos2f(GLfloat x, GLfloat y); } + void OVR::GLEContext::glRasterPos2f_Hook(GLfloat x, GLfloat y) + { + glRasterPos2f(x, y); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glRasterPos2fv + extern "C" { GLAPI void GLAPIENTRY glRasterPos2fv(const GLfloat *v); } + void OVR::GLEContext::glRasterPos2fv_Hook(const GLfloat *v) + { + glRasterPos2fv(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glRasterPos2i + extern "C" { GLAPI void GLAPIENTRY glRasterPos2i(GLint x, GLint y); } + void OVR::GLEContext::glRasterPos2i_Hook(GLint x, GLint y) + { + glRasterPos2i(x, y); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glRasterPos2iv + extern "C" { GLAPI void GLAPIENTRY glRasterPos2iv(const GLint *v); } + void OVR::GLEContext::glRasterPos2iv_Hook(const GLint *v) + { + glRasterPos2iv(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glRasterPos2s + extern "C" { GLAPI void GLAPIENTRY glRasterPos2s(GLshort x, GLshort y); } + void OVR::GLEContext::glRasterPos2s_Hook(GLshort x, GLshort y) + { + glRasterPos2s(x, y); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glRasterPos2sv + extern "C" { GLAPI void GLAPIENTRY glRasterPos2sv(const GLshort *v); } + void OVR::GLEContext::glRasterPos2sv_Hook(const GLshort *v) + { + glRasterPos2sv(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glRasterPos3d + extern "C" { GLAPI void GLAPIENTRY glRasterPos3d(GLdouble x, GLdouble y, GLdouble z); } + void OVR::GLEContext::glRasterPos3d_Hook(GLdouble x, GLdouble y, GLdouble z) + { + glRasterPos3d(x, y, z); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glRasterPos3dv + extern "C" { GLAPI void GLAPIENTRY glRasterPos3dv(const GLdouble *v); } + void OVR::GLEContext::glRasterPos3dv_Hook(const GLdouble *v) + { + glRasterPos3dv(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glRasterPos3f + extern "C" { GLAPI void GLAPIENTRY glRasterPos3f(GLfloat x, GLfloat y, GLfloat z); } + void OVR::GLEContext::glRasterPos3f_Hook(GLfloat x, GLfloat y, GLfloat z) + { + glRasterPos3f(x, y, z); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glRasterPos3fv + extern "C" { GLAPI void GLAPIENTRY glRasterPos3fv(const GLfloat *v); } + void OVR::GLEContext::glRasterPos3fv_Hook(const GLfloat *v) + { + glRasterPos3fv(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glRasterPos3i + extern "C" { GLAPI void GLAPIENTRY glRasterPos3i(GLint x, GLint y, GLint z); } + void OVR::GLEContext::glRasterPos3i_Hook(GLint x, GLint y, GLint z) + { + glRasterPos3i(x, y, z); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glRasterPos3iv + extern "C" { GLAPI void GLAPIENTRY glRasterPos3iv(const GLint *v); } + void OVR::GLEContext::glRasterPos3iv_Hook(const GLint *v) + { + glRasterPos3iv(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glRasterPos3s + extern "C" { GLAPI void GLAPIENTRY glRasterPos3s(GLshort x, GLshort y, GLshort z); } + void OVR::GLEContext::glRasterPos3s_Hook(GLshort x, GLshort y, GLshort z) + { + glRasterPos3s(x, y, z); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glRasterPos3sv + extern "C" { GLAPI void GLAPIENTRY glRasterPos3sv(const GLshort *v); } + void OVR::GLEContext::glRasterPos3sv_Hook(const GLshort *v) + { + glRasterPos3sv(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glRasterPos4d + extern "C" { GLAPI void GLAPIENTRY glRasterPos4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w); } + void OVR::GLEContext::glRasterPos4d_Hook(GLdouble x, GLdouble y, GLdouble z, GLdouble w) + { + glRasterPos4d(x, y, z, w); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glRasterPos4dv + extern "C" { GLAPI void GLAPIENTRY glRasterPos4dv(const GLdouble *v); } + void OVR::GLEContext::glRasterPos4dv_Hook(const GLdouble *v) + { + glRasterPos4dv(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glRasterPos4f + extern "C" { GLAPI void GLAPIENTRY glRasterPos4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w); } + void OVR::GLEContext::glRasterPos4f_Hook(GLfloat x, GLfloat y, GLfloat z, GLfloat w) + { + glRasterPos4f(x, y, z, w); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glRasterPos4fv + extern "C" { GLAPI void GLAPIENTRY glRasterPos4fv(const GLfloat *v); } + void OVR::GLEContext::glRasterPos4fv_Hook(const GLfloat *v) + { + glRasterPos4fv(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glRasterPos4i + extern "C" { GLAPI void GLAPIENTRY glRasterPos4i(GLint x, GLint y, GLint z, GLint w); } + void OVR::GLEContext::glRasterPos4i_Hook(GLint x, GLint y, GLint z, GLint w) + { + glRasterPos4i(x, y, z, w); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glRasterPos4iv + extern "C" { GLAPI void GLAPIENTRY glRasterPos4iv(const GLint *v); } + void OVR::GLEContext::glRasterPos4iv_Hook(const GLint *v) + { + glRasterPos4iv(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glRasterPos4s + extern "C" { GLAPI void GLAPIENTRY glRasterPos4s(GLshort x, GLshort y, GLshort z, GLshort w); } + void OVR::GLEContext::glRasterPos4s_Hook(GLshort x, GLshort y, GLshort z, GLshort w) + { + glRasterPos4s(x, y, z, w); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glRasterPos4sv + extern "C" { GLAPI void GLAPIENTRY glRasterPos4sv(const GLshort *v); } + void OVR::GLEContext::glRasterPos4sv_Hook(const GLshort *v) + { + glRasterPos4sv(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glReadBuffer + extern "C" { GLAPI void GLAPIENTRY glReadBuffer(GLenum mode); } + void OVR::GLEContext::glReadBuffer_Hook(GLenum mode) + { + glReadBuffer(mode); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glReadPixels + extern "C" { GLAPI void GLAPIENTRY glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels); } + void OVR::GLEContext::glReadPixels_Hook(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels) + { + glReadPixels(x, y, width, height, format, type, pixels); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glRectd + extern "C" { GLAPI void GLAPIENTRY glRectd(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2); } + void OVR::GLEContext::glRectd_Hook(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2) + { + glRectd(x1, y1, x2, y2); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glRectdv + extern "C" { GLAPI void GLAPIENTRY glRectdv(const GLdouble *v1, const GLdouble *v2); } + void OVR::GLEContext::glRectdv_Hook(const GLdouble *v1, const GLdouble *v2) + { + glRectdv(v1, v2); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glRectf + extern "C" { GLAPI void GLAPIENTRY glRectf(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2); } + void OVR::GLEContext::glRectf_Hook(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2) + { + glRectf(x1, y1, x2, y2); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glRectfv + extern "C" { GLAPI void GLAPIENTRY glRectfv(const GLfloat *v1, const GLfloat *v2); } + void OVR::GLEContext::glRectfv_Hook(const GLfloat *v1, const GLfloat *v2) + { + glRectfv(v1, v2); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glRecti + extern "C" { GLAPI void GLAPIENTRY glRecti(GLint x1, GLint y1, GLint x2, GLint y2); } + void OVR::GLEContext::glRecti_Hook(GLint x1, GLint y1, GLint x2, GLint y2) + { + glRecti(x1, y1, x2, y2); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glRectiv + extern "C" { GLAPI void GLAPIENTRY glRectiv(const GLint *v1, const GLint *v2); } + void OVR::GLEContext::glRectiv_Hook(const GLint *v1, const GLint *v2) + { + glRectiv(v1, v2); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glRects + extern "C" { GLAPI void GLAPIENTRY glRects(GLshort x1, GLshort y1, GLshort x2, GLshort y2); } + void OVR::GLEContext::glRects_Hook(GLshort x1, GLshort y1, GLshort x2, GLshort y2) + { + glRects(x1, y1, x2, y2); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glRectsv + extern "C" { GLAPI void GLAPIENTRY glRectsv(const GLshort *v1, const GLshort *v2); } + void OVR::GLEContext::glRectsv_Hook(const GLshort *v1, const GLshort *v2) + { + glRectsv(v1, v2); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glRenderMode + extern "C" { GLAPI GLint GLAPIENTRY glRenderMode(GLenum mode); } + GLint OVR::GLEContext::glRenderMode_Hook(GLenum mode) + { + GLint i = glRenderMode(mode); + PostHook(GLE_CURRENT_FUNCTION); + return i; + } + + #undef glRotated + extern "C" { GLAPI void GLAPIENTRY glRotated(GLdouble angle, GLdouble x, GLdouble y, GLdouble z); } + void OVR::GLEContext::glRotated_Hook(GLdouble angle, GLdouble x, GLdouble y, GLdouble z) + { + glRotated(angle, x, y, z); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glRotatef + extern "C" { GLAPI void GLAPIENTRY glRotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z); } + void OVR::GLEContext::glRotatef_Hook(GLfloat angle, GLfloat x, GLfloat y, GLfloat z) + { + glRotatef(angle, x, y, z); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glScaled + extern "C" { GLAPI void GLAPIENTRY glScaled(GLdouble x, GLdouble y, GLdouble z); } + void OVR::GLEContext::glScaled_Hook(GLdouble x, GLdouble y, GLdouble z) + { + glScaled(x, y, z); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glScalef + extern "C" { GLAPI void GLAPIENTRY glScalef(GLfloat x, GLfloat y, GLfloat z); } + void OVR::GLEContext::glScalef_Hook(GLfloat x, GLfloat y, GLfloat z) + { + glScalef(x, y, z); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glScissor + extern "C" { GLAPI void GLAPIENTRY glScissor(GLint x, GLint y, GLsizei width, GLsizei height); } + void OVR::GLEContext::glScissor_Hook(GLint x, GLint y, GLsizei width, GLsizei height) + { + glScissor(x, y, width, height); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glSelectBuffer + extern "C" { GLAPI void GLAPIENTRY glSelectBuffer(GLsizei size, GLuint *buffer); } + void OVR::GLEContext::glSelectBuffer_Hook(GLsizei size, GLuint *buffer) + { + glSelectBuffer(size, buffer); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glShadeModel + extern "C" { GLAPI void GLAPIENTRY glShadeModel(GLenum mode); } + void OVR::GLEContext::glShadeModel_Hook(GLenum mode) + { + glShadeModel(mode); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glStencilFunc + extern "C" { GLAPI void GLAPIENTRY glStencilFunc(GLenum func, GLint ref, GLuint mask); } + void OVR::GLEContext::glStencilFunc_Hook(GLenum func, GLint ref, GLuint mask) + { + glStencilFunc(func, ref, mask); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glStencilMask + extern "C" { GLAPI void GLAPIENTRY glStencilMask(GLuint mask); } + void OVR::GLEContext::glStencilMask_Hook(GLuint mask) + { + glStencilMask(mask); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glStencilOp + extern "C" { GLAPI void GLAPIENTRY glStencilOp(GLenum fail, GLenum zfail, GLenum zpass); } + void OVR::GLEContext::glStencilOp_Hook(GLenum fail, GLenum zfail, GLenum zpass) + { + glStencilOp(fail, zfail, zpass); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glTexCoord1d + extern "C" { GLAPI void GLAPIENTRY glTexCoord1d(GLdouble s); } + void OVR::GLEContext::glTexCoord1d_Hook(GLdouble s) + { + glTexCoord1d(s); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glTexCoord1dv + extern "C" { GLAPI void GLAPIENTRY glTexCoord1dv(const GLdouble *v); } + void OVR::GLEContext::glTexCoord1dv_Hook(const GLdouble *v) + { + glTexCoord1dv(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glTexCoord1f + extern "C" { GLAPI void GLAPIENTRY glTexCoord1f(GLfloat s); } + void OVR::GLEContext::glTexCoord1f_Hook(GLfloat s) + { + glTexCoord1f(s); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glTexCoord1fv + extern "C" { GLAPI void GLAPIENTRY glTexCoord1fv(const GLfloat *v); } + void OVR::GLEContext::glTexCoord1fv_Hook(const GLfloat *v) + { + glTexCoord1fv(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glTexCoord1i + extern "C" { GLAPI void GLAPIENTRY glTexCoord1i(GLint s); } + void OVR::GLEContext::glTexCoord1i_Hook(GLint s) + { + glTexCoord1i(s); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glTexCoord1iv + extern "C" { GLAPI void GLAPIENTRY glTexCoord1iv(const GLint *v); } + void OVR::GLEContext::glTexCoord1iv_Hook(const GLint *v) + { + glTexCoord1iv(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glTexCoord1s + extern "C" { GLAPI void GLAPIENTRY glTexCoord1s(GLshort s); } + void OVR::GLEContext::glTexCoord1s_Hook(GLshort s) + { + glTexCoord1s(s); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glTexCoord1sv + extern "C" { GLAPI void GLAPIENTRY glTexCoord1sv(const GLshort *v); } + void OVR::GLEContext::glTexCoord1sv_Hook(const GLshort *v) + { + glTexCoord1sv(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glTexCoord2d + extern "C" { GLAPI void GLAPIENTRY glTexCoord2d(GLdouble s, GLdouble t); } + void OVR::GLEContext::glTexCoord2d_Hook(GLdouble s, GLdouble t) + { + glTexCoord2d(s, t); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glTexCoord2dv + extern "C" { GLAPI void GLAPIENTRY glTexCoord2dv(const GLdouble *v); } + void OVR::GLEContext::glTexCoord2dv_Hook(const GLdouble *v) + { + glTexCoord2dv(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glTexCoord2f + extern "C" { GLAPI void GLAPIENTRY glTexCoord2f(GLfloat s, GLfloat t); } + void OVR::GLEContext::glTexCoord2f_Hook(GLfloat s, GLfloat t) + { + glTexCoord2f(s, t); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glTexCoord2fv + extern "C" { GLAPI void GLAPIENTRY glTexCoord2fv(const GLfloat *v); } + void OVR::GLEContext::glTexCoord2fv_Hook(const GLfloat *v) + { + glTexCoord2fv(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glTexCoord2i + extern "C" { GLAPI void GLAPIENTRY glTexCoord2i(GLint s, GLint t); } + void OVR::GLEContext::glTexCoord2i_Hook(GLint s, GLint t) + { + glTexCoord2i(s, t); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glTexCoord2iv + extern "C" { GLAPI void GLAPIENTRY glTexCoord2iv(const GLint *v); } + void OVR::GLEContext::glTexCoord2iv_Hook(const GLint *v) + { + glTexCoord2iv(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glTexCoord2s + extern "C" { GLAPI void GLAPIENTRY glTexCoord2s(GLshort s, GLshort t); } + void OVR::GLEContext::glTexCoord2s_Hook(GLshort s, GLshort t) + { + glTexCoord2s(s, t); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glTexCoord2sv + extern "C" { GLAPI void GLAPIENTRY glTexCoord2sv(const GLshort *v); } + void OVR::GLEContext::glTexCoord2sv_Hook(const GLshort *v) + { + glTexCoord2sv(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glTexCoord3d + extern "C" { GLAPI void GLAPIENTRY glTexCoord3d(GLdouble s, GLdouble t, GLdouble r); } + void OVR::GLEContext::glTexCoord3d_Hook(GLdouble s, GLdouble t, GLdouble r) + { + glTexCoord3d(s, t, r); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glTexCoord3dv + extern "C" { GLAPI void GLAPIENTRY glTexCoord3dv(const GLdouble *v); } + void OVR::GLEContext::glTexCoord3dv_Hook(const GLdouble *v) + { + glTexCoord3dv(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glTexCoord3f + extern "C" { GLAPI void GLAPIENTRY glTexCoord3f(GLfloat s, GLfloat t, GLfloat r); } + void OVR::GLEContext::glTexCoord3f_Hook(GLfloat s, GLfloat t, GLfloat r) + { + glTexCoord3f(s, t, r); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glTexCoord3fv + extern "C" { GLAPI void GLAPIENTRY glTexCoord3fv(const GLfloat *v); } + void OVR::GLEContext::glTexCoord3fv_Hook(const GLfloat *v) + { + glTexCoord3fv(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glTexCoord3i + extern "C" { GLAPI void GLAPIENTRY glTexCoord3i(GLint s, GLint t, GLint r); } + void OVR::GLEContext::glTexCoord3i_Hook(GLint s, GLint t, GLint r) + { + glTexCoord3i(s, t, r); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glTexCoord3iv + extern "C" { GLAPI void GLAPIENTRY glTexCoord3iv(const GLint *v); } + void OVR::GLEContext::glTexCoord3iv_Hook(const GLint *v) + { + glTexCoord3iv(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glTexCoord3s + extern "C" { GLAPI void GLAPIENTRY glTexCoord3s(GLshort s, GLshort t, GLshort r); } + void OVR::GLEContext::glTexCoord3s_Hook(GLshort s, GLshort t, GLshort r) + { + glTexCoord3s(s, t, r); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glTexCoord3sv + extern "C" { GLAPI void GLAPIENTRY glTexCoord3sv(const GLshort *v); } + void OVR::GLEContext::glTexCoord3sv_Hook(const GLshort *v) + { + glTexCoord3sv(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glTexCoord4d + extern "C" { GLAPI void GLAPIENTRY glTexCoord4d(GLdouble s, GLdouble t, GLdouble r, GLdouble q); } + void OVR::GLEContext::glTexCoord4d_Hook(GLdouble s, GLdouble t, GLdouble r, GLdouble q) + { + glTexCoord4d(s, t, r, q); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glTexCoord4dv + extern "C" { GLAPI void GLAPIENTRY glTexCoord4dv(const GLdouble *v); } + void OVR::GLEContext::glTexCoord4dv_Hook(const GLdouble *v) + { + glTexCoord4dv(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glTexCoord4f + extern "C" { GLAPI void GLAPIENTRY glTexCoord4f(GLfloat s, GLfloat t, GLfloat r, GLfloat q); } + void OVR::GLEContext::glTexCoord4f_Hook(GLfloat s, GLfloat t, GLfloat r, GLfloat q) + { + glTexCoord4f(s, t, r, q); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glTexCoord4fv + extern "C" { GLAPI void GLAPIENTRY glTexCoord4fv(const GLfloat *v); } + void OVR::GLEContext::glTexCoord4fv_Hook(const GLfloat *v) + { + glTexCoord4fv(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glTexCoord4i + extern "C" { GLAPI void GLAPIENTRY glTexCoord4i(GLint s, GLint t, GLint r, GLint q); } + void OVR::GLEContext::glTexCoord4i_Hook(GLint s, GLint t, GLint r, GLint q) + { + glTexCoord4i(s, t, r, q); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glTexCoord4iv + extern "C" { GLAPI void GLAPIENTRY glTexCoord4iv(const GLint *v); } + void OVR::GLEContext::glTexCoord4iv_Hook(const GLint *v) + { + glTexCoord4iv(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glTexCoord4s + extern "C" { GLAPI void GLAPIENTRY glTexCoord4s(GLshort s, GLshort t, GLshort r, GLshort q); } + void OVR::GLEContext::glTexCoord4s_Hook(GLshort s, GLshort t, GLshort r, GLshort q) + { + glTexCoord4s(s, t, r, q); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glTexCoord4sv + extern "C" { GLAPI void GLAPIENTRY glTexCoord4sv(const GLshort *v); } + void OVR::GLEContext::glTexCoord4sv_Hook(const GLshort *v) + { + glTexCoord4sv(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glTexCoordPointer + extern "C" { GLAPI void GLAPIENTRY glTexCoordPointer(GLint size, GLenum type, GLsizei stride, const void *pointer); } + void OVR::GLEContext::glTexCoordPointer_Hook(GLint size, GLenum type, GLsizei stride, const void *pointer) + { + glTexCoordPointer(size, type, stride, pointer); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glTexEnvf + extern "C" { GLAPI void GLAPIENTRY glTexEnvf(GLenum target, GLenum pname, GLfloat param); } + void OVR::GLEContext::glTexEnvf_Hook(GLenum target, GLenum pname, GLfloat param) + { + glTexEnvf(target, pname, param); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glTexEnvfv + extern "C" { GLAPI void GLAPIENTRY glTexEnvfv(GLenum target, GLenum pname, const GLfloat *params); } + void OVR::GLEContext::glTexEnvfv_Hook(GLenum target, GLenum pname, const GLfloat *params) + { + glTexEnvfv(target, pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glTexEnvi + extern "C" { GLAPI void GLAPIENTRY glTexEnvi(GLenum target, GLenum pname, GLint param); } + void OVR::GLEContext::glTexEnvi_Hook(GLenum target, GLenum pname, GLint param) + { + glTexEnvi(target, pname, param); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glTexEnviv + extern "C" { GLAPI void GLAPIENTRY glTexEnviv(GLenum target, GLenum pname, const GLint *params); } + void OVR::GLEContext::glTexEnviv_Hook(GLenum target, GLenum pname, const GLint *params) + { + glTexEnviv(target, pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glTexGend + extern "C" { GLAPI void GLAPIENTRY glTexGend(GLenum coord, GLenum pname, GLdouble param); } + void OVR::GLEContext::glTexGend_Hook(GLenum coord, GLenum pname, GLdouble param) + { + glTexGend(coord, pname, param); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glTexGendv + extern "C" { GLAPI void GLAPIENTRY glTexGendv(GLenum coord, GLenum pname, const GLdouble *params); } + void OVR::GLEContext::glTexGendv_Hook(GLenum coord, GLenum pname, const GLdouble *params) + { + glTexGendv(coord, pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glTexGenf + extern "C" { GLAPI void GLAPIENTRY glTexGenf(GLenum coord, GLenum pname, GLfloat param); } + void OVR::GLEContext::glTexGenf_Hook(GLenum coord, GLenum pname, GLfloat param) + { + glTexGenf(coord, pname, param); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glTexGenfv + extern "C" { GLAPI void GLAPIENTRY glTexGenfv(GLenum coord, GLenum pname, const GLfloat *params); } + void OVR::GLEContext::glTexGenfv_Hook(GLenum coord, GLenum pname, const GLfloat *params) + { + glTexGenfv(coord, pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glTexGeni + extern "C" { GLAPI void GLAPIENTRY glTexGeni(GLenum coord, GLenum pname, GLint param); } + void OVR::GLEContext::glTexGeni_Hook(GLenum coord, GLenum pname, GLint param) + { + glTexGeni(coord, pname, param); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glTexGeniv + extern "C" { GLAPI void GLAPIENTRY glTexGeniv(GLenum coord, GLenum pname, const GLint *params); } + void OVR::GLEContext::glTexGeniv_Hook(GLenum coord, GLenum pname, const GLint *params) + { + glTexGeniv(coord, pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glTexImage1D + extern "C" { GLAPI void GLAPIENTRY glTexImage1D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); } + void OVR::GLEContext::glTexImage1D_Hook(GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels) + { + glTexImage1D(target, level, internalformat, width, border, format, type, pixels); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glTexImage2D + extern "C" { GLAPI void GLAPIENTRY glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); } + void OVR::GLEContext::glTexImage2D_Hook(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels) + { + glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glTexParameterf + extern "C" { GLAPI void GLAPIENTRY glTexParameterf(GLenum target, GLenum pname, GLfloat param); } + void OVR::GLEContext::glTexParameterf_Hook(GLenum target, GLenum pname, GLfloat param) + { + glTexParameterf(target, pname, param); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glTexParameterfv + extern "C" { GLAPI void GLAPIENTRY glTexParameterfv(GLenum target, GLenum pname, const GLfloat *params); } + void OVR::GLEContext::glTexParameterfv_Hook(GLenum target, GLenum pname, const GLfloat *params) + { + glTexParameterfv(target, pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glTexParameteri + extern "C" { GLAPI void GLAPIENTRY glTexParameteri(GLenum target, GLenum pname, GLint param); } + void OVR::GLEContext::glTexParameteri_Hook(GLenum target, GLenum pname, GLint param) + { + glTexParameteri(target, pname, param); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glTexParameteriv + extern "C" { GLAPI void GLAPIENTRY glTexParameteriv(GLenum target, GLenum pname, const GLint *params); } + void OVR::GLEContext::glTexParameteriv_Hook(GLenum target, GLenum pname, const GLint *params) + { + glTexParameteriv(target, pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glTexSubImage1D + extern "C" { GLAPI void GLAPIENTRY glTexSubImage1D(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); } + void OVR::GLEContext::glTexSubImage1D_Hook(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels) + { + glTexSubImage1D(target, level, xoffset, width, format, type, pixels); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glTexSubImage2D + extern "C" { GLAPI void GLAPIENTRY glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); } + void OVR::GLEContext::glTexSubImage2D_Hook(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels) + { + glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glTranslated + extern "C" { GLAPI void GLAPIENTRY glTranslated(GLdouble x, GLdouble y, GLdouble z); } + void OVR::GLEContext::glTranslated_Hook(GLdouble x, GLdouble y, GLdouble z) + { + glTranslated(x, y, z); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glTranslatef + extern "C" { GLAPI void GLAPIENTRY glTranslatef(GLfloat x, GLfloat y, GLfloat z); } + void OVR::GLEContext::glTranslatef_Hook(GLfloat x, GLfloat y, GLfloat z) + { + glTranslatef(x, y, z); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glVertex2d + extern "C" { GLAPI void GLAPIENTRY glVertex2d(GLdouble x, GLdouble y); } + void OVR::GLEContext::glVertex2d_Hook(GLdouble x, GLdouble y) + { + glVertex2d(x, y); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glVertex2dv + extern "C" { GLAPI void GLAPIENTRY glVertex2dv(const GLdouble *v); } + void OVR::GLEContext::glVertex2dv_Hook(const GLdouble *v) + { + glVertex2dv(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glVertex2f + extern "C" { GLAPI void GLAPIENTRY glVertex2f(GLfloat x, GLfloat y); } + void OVR::GLEContext::glVertex2f_Hook(GLfloat x, GLfloat y) + { + glVertex2f(x, y); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glVertex2fv + extern "C" { GLAPI void GLAPIENTRY glVertex2fv(const GLfloat *v); } + void OVR::GLEContext::glVertex2fv_Hook(const GLfloat *v) + { + glVertex2fv(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glVertex2i + extern "C" { GLAPI void GLAPIENTRY glVertex2i(GLint x, GLint y); } + void OVR::GLEContext::glVertex2i_Hook(GLint x, GLint y) + { + glVertex2i(x, y); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glVertex2iv + extern "C" { GLAPI void GLAPIENTRY glVertex2iv(const GLint *v); } + void OVR::GLEContext::glVertex2iv_Hook(const GLint *v) + { + glVertex2iv(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glVertex2s + extern "C" { GLAPI void GLAPIENTRY glVertex2s(GLshort x, GLshort y); } + void OVR::GLEContext::glVertex2s_Hook(GLshort x, GLshort y) + { + glVertex2s(x, y); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glVertex2sv + extern "C" { GLAPI void GLAPIENTRY glVertex2sv(const GLshort *v); } + void OVR::GLEContext::glVertex2sv_Hook(const GLshort *v) + { + glVertex2sv(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glVertex3d + extern "C" { GLAPI void GLAPIENTRY glVertex3d(GLdouble x, GLdouble y, GLdouble z); } + void OVR::GLEContext::glVertex3d_Hook(GLdouble x, GLdouble y, GLdouble z) + { + glVertex3d(x, y, z); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glVertex3dv + extern "C" { GLAPI void GLAPIENTRY glVertex3dv(const GLdouble *v); } + void OVR::GLEContext::glVertex3dv_Hook(const GLdouble *v) + { + glVertex3dv(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glVertex3f + extern "C" { GLAPI void GLAPIENTRY glVertex3f(GLfloat x, GLfloat y, GLfloat z); } + void OVR::GLEContext::glVertex3f_Hook(GLfloat x, GLfloat y, GLfloat z) + { + glVertex3f(x, y, z); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glVertex3fv + extern "C" { GLAPI void GLAPIENTRY glVertex3fv(const GLfloat *v); } + void OVR::GLEContext::glVertex3fv_Hook(const GLfloat *v) + { + glVertex3fv(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glVertex3i + extern "C" { GLAPI void GLAPIENTRY glVertex3i(GLint x, GLint y, GLint z); } + void OVR::GLEContext::glVertex3i_Hook(GLint x, GLint y, GLint z) + { + glVertex3i(x, y, z); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glVertex3iv + extern "C" { GLAPI void GLAPIENTRY glVertex3iv(const GLint *v); } + void OVR::GLEContext::glVertex3iv_Hook(const GLint *v) + { + glVertex3iv(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glVertex3s + extern "C" { GLAPI void GLAPIENTRY glVertex3s(GLshort x, GLshort y, GLshort z); } + void OVR::GLEContext::glVertex3s_Hook(GLshort x, GLshort y, GLshort z) + { + glVertex3s(x, y, z); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glVertex3sv + extern "C" { GLAPI void GLAPIENTRY glVertex3sv(const GLshort *v); } + void OVR::GLEContext::glVertex3sv_Hook(const GLshort *v) + { + glVertex3sv(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glVertex4d + extern "C" { GLAPI void GLAPIENTRY glVertex4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w); } + void OVR::GLEContext::glVertex4d_Hook(GLdouble x, GLdouble y, GLdouble z, GLdouble w) + { + glVertex4d(x, y, z, w); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glVertex4dv + extern "C" { GLAPI void GLAPIENTRY glVertex4dv(const GLdouble *v); } + void OVR::GLEContext::glVertex4dv_Hook(const GLdouble *v) + { + glVertex4dv(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glVertex4f + extern "C" { GLAPI void GLAPIENTRY glVertex4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w); } + void OVR::GLEContext::glVertex4f_Hook(GLfloat x, GLfloat y, GLfloat z, GLfloat w) + { + glVertex4f(x, y, z, w); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glVertex4fv + extern "C" { GLAPI void GLAPIENTRY glVertex4fv(const GLfloat *v); } + void OVR::GLEContext::glVertex4fv_Hook(const GLfloat *v) + { + glVertex4fv(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glVertex4i + extern "C" { GLAPI void GLAPIENTRY glVertex4i(GLint x, GLint y, GLint z, GLint w); } + void OVR::GLEContext::glVertex4i_Hook(GLint x, GLint y, GLint z, GLint w) + { + glVertex4i(x, y, z, w); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glVertex4iv + extern "C" { GLAPI void GLAPIENTRY glVertex4iv(const GLint *v); } + void OVR::GLEContext::glVertex4iv_Hook(const GLint *v) + { + glVertex4iv(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glVertex4s + extern "C" { GLAPI void GLAPIENTRY glVertex4s(GLshort x, GLshort y, GLshort z, GLshort w); } + void OVR::GLEContext::glVertex4s_Hook(GLshort x, GLshort y, GLshort z, GLshort w) + { + glVertex4s(x, y, z, w); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glVertex4sv + extern "C" { GLAPI void GLAPIENTRY glVertex4sv(const GLshort *v); } + void OVR::GLEContext::glVertex4sv_Hook(const GLshort *v) + { + glVertex4sv(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glVertexPointer + extern "C" { GLAPI void GLAPIENTRY glVertexPointer(GLint size, GLenum type, GLsizei stride, const void *pointer); } + void OVR::GLEContext::glVertexPointer_Hook(GLint size, GLenum type, GLsizei stride, const void *pointer) + { + glVertexPointer(size, type, stride, pointer); + PostHook(GLE_CURRENT_FUNCTION); + } + + #undef glViewport + extern "C" { GLAPI void GLAPIENTRY glViewport(GLint x, GLint y, GLsizei width, GLsizei height); } + void OVR::GLEContext::glViewport_Hook(GLint x, GLint y, GLsizei width, GLsizei height) + { + glViewport(x, y, width, height); + PostHook(GLE_CURRENT_FUNCTION); + } + + + + // Pointer-based functions + void OVR::GLEContext::glBlendColor_Hook(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) + { + if(glBlendColor_Impl) + glBlendColor_Impl(red, green, blue, alpha); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glBlendEquation_Hook(GLenum mode) + { + if(glBlendEquation_Impl) + glBlendEquation_Impl(mode); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glDrawRangeElements_Hook(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices) + { + if(glDrawRangeElements_Impl) + glDrawRangeElements_Impl(mode, start, end, count, type, indices); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glTexImage3D_Hook(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels) + { + if(glTexImage3D_Impl) + glTexImage3D_Impl(target, level, internalformat, width, height, depth, border, format, type, pixels); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glTexSubImage3D_Hook(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels) + { + if(glTexSubImage3D_Impl) + glTexSubImage3D_Impl(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels); + PostHook(GLE_CURRENT_FUNCTION); + } + + + void OVR::GLEContext::glCopyTexSubImage3D_Hook(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height) + { + if(glCopyTexSubImage3D_Impl) + glCopyTexSubImage3D_Impl(target, level, xoffset, yoffset, zoffset, x, y, width, height); + PostHook(GLE_CURRENT_FUNCTION); + } + + // GL_VERSION_1_2 deprecated functions + /* Not currently supported + void OVR::GLEContext::glColorTable_Hook(GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table) + { + if(glColorTable_Impl) + glColorTable_Impl(target, internalformat, width, format, type, table); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glColorTableParameterfv_Hook(GLenum target, GLenum pname, const GLfloat *params) + { + if(glColorTableParameterfv_Impl) + glColorTableParameterfv_Impl(target, pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glColorTableParameteriv_Hook(GLenum target, GLenum pname, const GLint *params) + { + if(glColorTableParameteriv_Impl) + glColorTableParameteriv_Impl(target, pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glCopyColorTable_Hook(GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width) + { + if(glCopyColorTable_Impl) + glCopyColorTable_Impl(target, internalformat, x, y, width); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glGetColorTable_Hook(GLenum target, GLenum format, GLenum type, GLvoid *table) + { + if(glGetColorTable_Impl) + glGetColorTable_Impl(target, format, type, table); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glGetColorTableParameterfv_Hook(GLenum target, GLenum pname, GLfloat *params) + { + if(glGetColorTableParameterfv_Impl) + glGetColorTableParameterfv_Impl(target, pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glGetColorTableParameteriv_Hook(GLenum target, GLenum pname, GLint *params) + { + if(glGetColorTableParameteriv_Impl) + glGetColorTableParameteriv_Impl(target, pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glColorSubTable_Hook(GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data) + { + if(glColorSubTable_Impl) + glColorSubTable_Impl(target, start, count, format, type, data); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glCopyColorSubTable_Hook(GLenum target, GLsizei start, GLint x, GLint y, GLsizei width) + { + if(glCopyColorSubTable_Impl) + glCopyColorSubTable_Impl(target, start, x, y, width); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glConvolutionFilter1D_Hook(GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image) + { + if(glConvolutionFilter1D_Impl) + glConvolutionFilter1D_Impl(target, internalformat, width, format, type, image); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glConvolutionFilter2D_Hook(GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image) + { + if(glConvolutionFilter2D_Impl) + glConvolutionFilter2D_Impl(target, internalformat, width, height, format, type, image); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glConvolutionParameterf_Hook(GLenum target, GLenum pname, GLfloat params) + { + if(glConvolutionParameterf_Impl) + glConvolutionParameterf_Impl(target, pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glConvolutionParameterfv_Hook(GLenum target, GLenum pname, const GLfloat *params) + { + if(glConvolutionParameterfv_Impl) + glConvolutionParameterfv_Impl(target, pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glConvolutionParameteri_Hook(GLenum target, GLenum pname, GLint params) + { + if(glConvolutionParameteri_Impl) + glConvolutionParameteri_Impl(target, pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glConvolutionParameteriv_Hook(GLenum target, GLenum pname, const GLint *params) + { + if(glConvolutionParameteriv_Impl) + glConvolutionParameteriv_Impl(target, pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glCopyConvolutionFilter1D_Hook(GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width) + { + if(glCopyConvolutionFilter1D_Impl) + glCopyConvolutionFilter1D_Impl(target, internalformat, x, y, width); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glCopyConvolutionFilter2D_Hook(GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height) + { + if(glCopyConvolutionFilter2D_Impl) + glCopyConvolutionFilter2D_Impl(target, internalformat, x, y, width, height); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glGetConvolutionFilter_Hook(GLenum target, GLenum format, GLenum type, GLvoid *image) + { + if(glGetConvolutionFilter_Impl) + glGetConvolutionFilter_Impl(target, format, type, image); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glGetConvolutionParameterfv_Hook(GLenum target, GLenum pname, GLfloat *params) + { + if(glGetConvolutionParameterfv_Impl) + glGetConvolutionParameterfv_Impl(target, pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glGetConvolutionParameteriv_Hook(GLenum target, GLenum pname, GLint *params) + { + if(glGetConvolutionParameteriv_Impl) + glGetConvolutionParameteriv_Impl(target, pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glGetSeparableFilter_Hook(GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span) + { + if(glGetSeparableFilter_Impl) + glGetSeparableFilter_Impl(target, format, type, row, column, span); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glSeparableFilter2D_Hook(GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column) + { + if(glSeparableFilter2D_Impl) + glSeparableFilter2D_Impl(target, internalformat, width, height, format, type, row, column); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glGetHistogram_Hook(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values) + { + if(glGetHistogram_Impl) + glGetHistogram_Impl(target, reset, format, type, values); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glGetHistogramParameterfv_Hook(GLenum target, GLenum pname, GLfloat *params) + { + if(glGetHistogramParameterfv_Impl) + glGetHistogramParameterfv_Impl(target, pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glGetHistogramParameteriv_Hook(GLenum target, GLenum pname, GLint *params) + { + if(glGetHistogramParameteriv_Impl) + glGetHistogramParameteriv_Impl(target, pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glGetMinmax_Hook(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values) + { + if(glGetMinmax_Impl) + glGetMinmax_Impl(target, reset, format, type, values); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glGetMinmaxParameterfv_Hook(GLenum target, GLenum pname, GLfloat *params) + { + if(glGetMinmaxParameterfv_Impl) + glGetMinmaxParameterfv_Impl(target, pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glGetMinmaxParameteriv_Hook(GLenum target, GLenum pname, GLint *params) + { + if(glGetMinmaxParameteriv_Impl) + glGetMinmaxParameteriv_Impl(target, pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glHistogram_Hook(GLenum target, GLsizei width, GLenum internalformat, GLboolean sink) + { + if(glHistogram_Impl) + glHistogram_Impl(target, width, internalformat, sink); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glMinmax_Hook(GLenum target, GLenum internalformat, GLboolean sink) + { + if(glMinmax_Impl) + glMinmax_Impl(target, internalformat, sink); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glResetHistogram_Hook(GLenum target) + { + if(glResetHistogram_Impl) + glResetHistogram_Impl(target); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glResetMinmax_Hook(GLenum target) + { + if(glResetMinmax_Impl) + glResetMinmax_Impl(target); + PostHook(GLE_CURRENT_FUNCTION); + } + */ + + // GL_VERSION_1_3 + void OVR::GLEContext::glActiveTexture_Hook(GLenum texture) + { + if(glActiveTexture_Impl) + glActiveTexture_Impl(texture); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glSampleCoverage_Hook(GLclampf value, GLboolean invert) + { + if(glSampleCoverage_Impl) + glSampleCoverage_Impl(value, invert); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glCompressedTexImage3D_Hook(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data) + { + if(glCompressedTexImage3D_Impl) + glCompressedTexImage3D_Impl(target, level, internalformat, width, height, depth, border, imageSize, data); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glCompressedTexImage2D_Hook(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data) + { + if(glCompressedTexImage2D_Impl) + glCompressedTexImage2D_Impl(target, level, internalformat, width, height, border, imageSize, data); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glCompressedTexImage1D_Hook(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data) + { + if(glCompressedTexImage1D_Impl) + glCompressedTexImage1D_Impl(target, level, internalformat, width, border, imageSize, data); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glCompressedTexSubImage3D_Hook(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data) + { + if(glCompressedTexSubImage3D_Impl) + glCompressedTexSubImage3D_Impl(target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glCompressedTexSubImage2D_Hook(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data) + { + if(glCompressedTexSubImage2D_Impl) + glCompressedTexSubImage2D_Impl(target, level, xoffset, yoffset, width, height, format, imageSize, data); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glCompressedTexSubImage1D_Hook(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data) + { + if(glCompressedTexSubImage1D_Impl) + glCompressedTexSubImage1D_Impl(target, level, xoffset, width, format, imageSize, data); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glGetCompressedTexImage_Hook(GLenum target, GLint level, GLvoid *img) + { + if(glGetCompressedTexImage_Impl) + glGetCompressedTexImage_Impl(target, level, img); + PostHook(GLE_CURRENT_FUNCTION); + } + + + // GL_VERSION_1_3 deprecated functions + void OVR::GLEContext::glClientActiveTexture_Hook(GLenum texture) + { + if(glClientActiveTexture_Impl) + glClientActiveTexture_Impl(texture); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glMultiTexCoord1d_Hook(GLenum target, GLdouble s) + { + if(glMultiTexCoord1d_Impl) + glMultiTexCoord1d_Impl(target, s); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glMultiTexCoord1dv_Hook(GLenum target, const GLdouble *v) + { + if(glMultiTexCoord1dv_Impl) + glMultiTexCoord1dv_Impl(target, v); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glMultiTexCoord1f_Hook(GLenum target, GLfloat s) + { + if(glMultiTexCoord1f_Impl) + glMultiTexCoord1f_Impl(target, s); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glMultiTexCoord1fv_Hook(GLenum target, const GLfloat *v) + { + if(glMultiTexCoord1fv_Impl) + glMultiTexCoord1fv_Impl(target, v); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glMultiTexCoord1i_Hook(GLenum target, GLint s) + { + if(glMultiTexCoord1i_Impl) + glMultiTexCoord1i_Impl(target, s); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glMultiTexCoord1iv_Hook(GLenum target, const GLint *v) + { + if(glMultiTexCoord1iv_Impl) + glMultiTexCoord1iv_Impl(target, v); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glMultiTexCoord1s_Hook(GLenum target, GLshort s) + { + if(glMultiTexCoord1s_Impl) + glMultiTexCoord1s_Impl(target, s); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glMultiTexCoord1sv_Hook(GLenum target, const GLshort *v) + { + if(glMultiTexCoord1sv_Impl) + glMultiTexCoord1sv_Impl(target, v); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glMultiTexCoord2d_Hook(GLenum target, GLdouble s, GLdouble t) + { + if(glMultiTexCoord2d_Impl) + glMultiTexCoord2d_Impl(target, s, t); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glMultiTexCoord2dv_Hook(GLenum target, const GLdouble *v) + { + if(glMultiTexCoord2dv_Impl) + glMultiTexCoord2dv_Impl(target, v); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glMultiTexCoord2f_Hook(GLenum target, GLfloat s, GLfloat t) + { + if(glMultiTexCoord2f_Impl) + glMultiTexCoord2f_Impl(target, s, t); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glMultiTexCoord2fv_Hook(GLenum target, const GLfloat *v) + { + if(glMultiTexCoord2fv_Impl) + glMultiTexCoord2fv_Impl(target, v); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glMultiTexCoord2i_Hook(GLenum target, GLint s, GLint t) + { + if(glMultiTexCoord2i_Impl) + glMultiTexCoord2i_Impl(target, s, t); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glMultiTexCoord2iv_Hook(GLenum target, const GLint *v) + { + if(glMultiTexCoord2iv_Impl) + glMultiTexCoord2iv_Impl(target, v); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glMultiTexCoord2s_Hook(GLenum target, GLshort s, GLshort t) + { + if(glMultiTexCoord2s_Impl) + glMultiTexCoord2s_Impl(target, s, t); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glMultiTexCoord2sv_Hook(GLenum target, const GLshort *v) + { + if(glMultiTexCoord2sv_Impl) + glMultiTexCoord2sv_Impl(target, v); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glMultiTexCoord3d_Hook(GLenum target, GLdouble s, GLdouble t, GLdouble r) + { + if(glMultiTexCoord3d_Impl) + glMultiTexCoord3d_Impl(target, s, t, r); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glMultiTexCoord3dv_Hook(GLenum target, const GLdouble *v) + { + if(glMultiTexCoord3dv_Impl) + glMultiTexCoord3dv_Impl(target, v); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glMultiTexCoord3f_Hook(GLenum target, GLfloat s, GLfloat t, GLfloat r) + { + if(glMultiTexCoord3f_Impl) + glMultiTexCoord3f_Impl(target, s, t, r); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glMultiTexCoord3fv_Hook(GLenum target, const GLfloat *v) + { + if(glMultiTexCoord3fv_Impl) + glMultiTexCoord3fv_Impl(target, v); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glMultiTexCoord3i_Hook(GLenum target, GLint s, GLint t, GLint r) + { + if(glMultiTexCoord3i_Impl) + glMultiTexCoord3i_Impl(target, s, t, r); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glMultiTexCoord3iv_Hook(GLenum target, const GLint *v) + { + if(glMultiTexCoord3iv_Impl) + glMultiTexCoord3iv_Impl(target, v); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glMultiTexCoord3s_Hook(GLenum target, GLshort s, GLshort t, GLshort r) + { + if(glMultiTexCoord3s_Impl) + glMultiTexCoord3s_Impl(target, s, t, r); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glMultiTexCoord3sv_Hook(GLenum target, const GLshort *v) + { + if(glMultiTexCoord3sv_Impl) + glMultiTexCoord3sv_Impl(target, v); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glMultiTexCoord4d_Hook(GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q) + { + if(glMultiTexCoord4d_Impl) + glMultiTexCoord4d_Impl(target, s, t, r, q); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glMultiTexCoord4dv_Hook(GLenum target, const GLdouble *v) + { + if(glMultiTexCoord4dv_Impl) + glMultiTexCoord4dv_Impl(target, v); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glMultiTexCoord4f_Hook(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q) + { + if(glMultiTexCoord4f_Impl) + glMultiTexCoord4f_Impl(target, s, t, r, q); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glMultiTexCoord4fv_Hook(GLenum target, const GLfloat *v) + { + if(glMultiTexCoord4fv_Impl) + glMultiTexCoord4fv_Impl(target, v); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glMultiTexCoord4i_Hook(GLenum target, GLint s, GLint t, GLint r, GLint q) + { + if(glMultiTexCoord4i_Impl) + glMultiTexCoord4i_Impl(target, s, t, r, q); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glMultiTexCoord4iv_Hook(GLenum target, const GLint *v) + { + if(glMultiTexCoord4iv_Impl) + glMultiTexCoord4iv_Impl(target, v); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glMultiTexCoord4s_Hook(GLenum target, GLshort s, GLshort t, GLshort r, GLshort q) + { + if(glMultiTexCoord4s_Impl) + glMultiTexCoord4s_Impl(target, s, t, r, q); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glMultiTexCoord4sv_Hook(GLenum target, const GLshort *v) + { + if(glMultiTexCoord4sv_Impl) + glMultiTexCoord4sv_Impl(target, v); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glLoadTransposeMatrixf_Hook(const GLfloat *m) + { + if(glLoadTransposeMatrixf_Impl) + glLoadTransposeMatrixf_Impl(m); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glLoadTransposeMatrixd_Hook(const GLdouble *m) + { + if(glLoadTransposeMatrixd_Impl) + glLoadTransposeMatrixd_Impl(m); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glMultTransposeMatrixf_Hook(const GLfloat *m) + { + if(glMultTransposeMatrixf_Impl) + glMultTransposeMatrixf_Impl(m); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glMultTransposeMatrixd_Hook(const GLdouble *m) + { + if(glMultTransposeMatrixd_Impl) + glMultTransposeMatrixd_Impl(m); + PostHook(GLE_CURRENT_FUNCTION); + } + + + // GL_VERSION_1_4 + void OVR::GLEContext::glBlendFuncSeparate_Hook(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha) + { + if(glBlendFuncSeparate_Impl) + glBlendFuncSeparate_Impl(sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glMultiDrawArrays_Hook(GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount) + { + if(glMultiDrawArrays_Impl) + glMultiDrawArrays_Impl(mode, first, count, primcount); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glMultiDrawElements_Hook(GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount) + { + if(glMultiDrawElements_Impl) + glMultiDrawElements_Impl(mode, count, type, indices, primcount); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glPointParameterf_Hook(GLenum pname, GLfloat param) + { + if(glPointParameterf_Impl) + glPointParameterf_Impl(pname, param); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glPointParameterfv_Hook(GLenum pname, const GLfloat *params) + { + if(glPointParameterfv_Impl) + glPointParameterfv_Impl(pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glPointParameteri_Hook(GLenum pname, GLint param) + { + if(glPointParameteri_Impl) + glPointParameteri_Impl(pname, param); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glPointParameteriv_Hook(GLenum pname, const GLint *params) + { + if(glPointParameteriv_Impl) + glPointParameteriv_Impl(pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + + // GL_VERSION_1_4 deprecated functions + void OVR::GLEContext::glFogCoordf_Hook(GLfloat coord) + { + if(glFogCoordf_Impl) + glFogCoordf_Impl(coord); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glFogCoordfv_Hook(const GLfloat *coord) + { + if(glFogCoordfv_Impl) + glFogCoordfv_Impl(coord); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glFogCoordd_Hook(GLdouble coord) + { + if(glFogCoordd_Impl) + glFogCoordd_Impl(coord); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glFogCoorddv_Hook(const GLdouble *coord) + { + if(glFogCoorddv_Impl) + glFogCoorddv_Impl(coord); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glFogCoordPointer_Hook(GLenum type, GLsizei stride, const GLvoid *pointer) + { + if(glFogCoordPointer_Impl) + glFogCoordPointer_Impl(type, stride, pointer); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glSecondaryColor3b_Hook(GLbyte red, GLbyte green, GLbyte blue) + { + if(glSecondaryColor3b_Impl) + glSecondaryColor3b_Impl(red, green, blue); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glSecondaryColor3bv_Hook(const GLbyte *v) + { + if(glSecondaryColor3bv_Impl) + glSecondaryColor3bv_Impl(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glSecondaryColor3d_Hook(GLdouble red, GLdouble green, GLdouble blue) + { + if(glSecondaryColor3d_Impl) + glSecondaryColor3d_Impl(red, green, blue); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glSecondaryColor3dv_Hook(const GLdouble *v) + { + if(glSecondaryColor3dv_Impl) + glSecondaryColor3dv_Impl(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glSecondaryColor3f_Hook(GLfloat red, GLfloat green, GLfloat blue) + { + if(glSecondaryColor3f_Impl) + glSecondaryColor3f_Impl(red, green, blue); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glSecondaryColor3fv_Hook(const GLfloat *v) + { + if(glSecondaryColor3fv_Impl) + glSecondaryColor3fv_Impl(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glSecondaryColor3i_Hook(GLint red, GLint green, GLint blue) + { + if(glSecondaryColor3i_Impl) + glSecondaryColor3i_Impl(red, green, blue); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glSecondaryColor3iv_Hook(const GLint *v) + { + if(glSecondaryColor3iv_Impl) + glSecondaryColor3iv_Impl(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glSecondaryColor3s_Hook(GLshort red, GLshort green, GLshort blue) + { + if(glSecondaryColor3s_Impl) + glSecondaryColor3s_Impl(red, green, blue); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glSecondaryColor3sv_Hook(const GLshort *v) + { + if(glSecondaryColor3sv_Impl) + glSecondaryColor3sv_Impl(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glSecondaryColor3ub_Hook(GLubyte red, GLubyte green, GLubyte blue) + { + if(glSecondaryColor3ub_Impl) + glSecondaryColor3ub_Impl(red, green, blue); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glSecondaryColor3ubv_Hook(const GLubyte *v) + { + if(glSecondaryColor3ubv_Impl) + glSecondaryColor3ubv_Impl(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glSecondaryColor3ui_Hook(GLuint red, GLuint green, GLuint blue) + { + if(glSecondaryColor3ui_Impl) + glSecondaryColor3ui_Impl(red, green, blue); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glSecondaryColor3uiv_Hook(const GLuint *v) + { + if(glSecondaryColor3uiv_Impl) + glSecondaryColor3uiv_Impl(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glSecondaryColor3us_Hook(GLushort red, GLushort green, GLushort blue) + { + if(glSecondaryColor3us_Impl) + glSecondaryColor3us_Impl(red, green, blue); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glSecondaryColor3usv_Hook(const GLushort *v) + { + if(glSecondaryColor3usv_Impl) + glSecondaryColor3usv_Impl(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glSecondaryColorPointer_Hook(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) + { + if(glSecondaryColorPointer_Impl) + glSecondaryColorPointer_Impl(size, type, stride, pointer); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glWindowPos2d_Hook(GLdouble x, GLdouble y) + { + if(glWindowPos2d_Impl) + glWindowPos2d_Impl(x, y); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glWindowPos2dv_Hook(const GLdouble *v) + { + if(glWindowPos2dv_Impl) + glWindowPos2dv_Impl(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glWindowPos2f_Hook(GLfloat x, GLfloat y) + { + if(glWindowPos2f_Impl) + glWindowPos2f_Impl(x, y); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glWindowPos2fv_Hook(const GLfloat *v) + { + if(glWindowPos2fv_Impl) + glWindowPos2fv_Impl(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glWindowPos2i_Hook(GLint x, GLint y) + { + if(glWindowPos2i_Impl) + glWindowPos2i_Impl(x, y); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glWindowPos2iv_Hook(const GLint *v) + { + if(glWindowPos2iv_Impl) + glWindowPos2iv_Impl(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glWindowPos2s_Hook(GLshort x, GLshort y) + { + if(glWindowPos2s_Impl) + glWindowPos2s_Impl(x, y); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glWindowPos2sv_Hook(const GLshort *v) + { + if(glWindowPos2sv_Impl) + glWindowPos2sv_Impl(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glWindowPos3d_Hook(GLdouble x, GLdouble y, GLdouble z) + { + if(glWindowPos3d_Impl) + glWindowPos3d_Impl(x, y, z); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glWindowPos3dv_Hook(const GLdouble *v) + { + if(glWindowPos3dv_Impl) + glWindowPos3dv_Impl(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glWindowPos3f_Hook(GLfloat x, GLfloat y, GLfloat z) + { + if(glWindowPos3f_Impl) + glWindowPos3f_Impl(x, y, z); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glWindowPos3fv_Hook(const GLfloat *v) + { + if(glWindowPos3fv_Impl) + glWindowPos3fv_Impl(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glWindowPos3i_Hook(GLint x, GLint y, GLint z) + { + if(glWindowPos3i_Impl) + glWindowPos3i_Impl(x, y, z); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glWindowPos3iv_Hook(const GLint *v) + { + if(glWindowPos3iv_Impl) + glWindowPos3iv_Impl(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glWindowPos3s_Hook(GLshort x, GLshort y, GLshort z) + { + if(glWindowPos3s_Impl) + glWindowPos3s_Impl(x, y, z); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glWindowPos3sv_Hook(const GLshort *v) + { + if(glWindowPos3sv_Impl) + glWindowPos3sv_Impl(v); + PostHook(GLE_CURRENT_FUNCTION); + } + + + // GL_VERSION_1_5 + void OVR::GLEContext::glGenQueries_Hook(GLsizei n, GLuint *ids) + { + if(glGenQueries_Impl) + glGenQueries_Impl(n, ids); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glDeleteQueries_Hook(GLsizei n, const GLuint *ids) + { + if(glDeleteQueries_Impl) + glDeleteQueries_Impl(n, ids); + PostHook(GLE_CURRENT_FUNCTION); + } + + GLboolean OVR::GLEContext::glIsQuery_Hook(GLuint id) + { + GLboolean b = GL_FALSE; + if(glIsQuery_Impl) + b = glIsQuery_Impl(id); + PostHook(GLE_CURRENT_FUNCTION); + return b; + } + + void OVR::GLEContext::glBeginQuery_Hook(GLenum target, GLuint id) + { + if(glBeginQuery_Impl) + glBeginQuery_Impl(target, id); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glEndQuery_Hook(GLenum target) + { + if(glEndQuery_Impl) + glEndQuery_Impl(target); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glGetQueryiv_Hook(GLenum target, GLenum pname, GLint *params) + { + if(glGetQueryiv_Impl) + glGetQueryiv_Impl(target, pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glGetQueryObjectiv_Hook(GLuint id, GLenum pname, GLint *params) + { + if(glGetQueryObjectiv_Impl) + glGetQueryObjectiv_Impl(id, pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glGetQueryObjectuiv_Hook(GLuint id, GLenum pname, GLuint *params) + { + if(glGetQueryObjectuiv_Impl) + glGetQueryObjectuiv_Impl(id, pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glBindBuffer_Hook(GLenum target, GLuint buffer) + { + if(glBindBuffer_Impl) + glBindBuffer_Impl(target, buffer); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glDeleteBuffers_Hook(GLsizei n, const GLuint *buffers) + { + if(glDeleteBuffers_Impl) + glDeleteBuffers_Impl(n, buffers); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glGenBuffers_Hook(GLsizei n, GLuint *buffers) + { + if(glGenBuffers_Impl) + glGenBuffers_Impl(n, buffers); + PostHook(GLE_CURRENT_FUNCTION); + } + + GLboolean OVR::GLEContext::glIsBuffer_Hook(GLuint buffer) + { + GLboolean b = GL_FALSE; + if(glIsBuffer_Impl) + b = glIsBuffer_Impl(buffer); + PostHook(GLE_CURRENT_FUNCTION); + return b; + } + + void OVR::GLEContext::glBufferData_Hook(GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage) + { + if(glBufferData_Impl) + glBufferData_Impl(target, size, data, usage); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glBufferSubData_Hook(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data) + { + if(glBufferSubData_Impl) + glBufferSubData_Impl(target, offset, size, data); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glGetBufferSubData_Hook(GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data) + { + if(glGetBufferSubData_Impl) + glGetBufferSubData_Impl(target, offset, size, data); + PostHook(GLE_CURRENT_FUNCTION); + } + + GLvoid* OVR::GLEContext::glMapBuffer_Hook(GLenum target, GLenum access) + { + GLvoid* p = NULL; + if(glMapBuffer_Impl) + p = glMapBuffer_Impl(target, access); + PostHook(GLE_CURRENT_FUNCTION); + return p; + } + + GLboolean OVR::GLEContext::glUnmapBuffer_Hook(GLenum target) + { + GLboolean b = GL_FALSE; + if(glUnmapBuffer_Impl) + b = glUnmapBuffer_Impl(target); + PostHook(GLE_CURRENT_FUNCTION); + return b; + } + + void OVR::GLEContext::glGetBufferParameteriv_Hook(GLenum target, GLenum pname, GLint *params) + { + if(glGetBufferParameteriv_Impl) + glGetBufferParameteriv_Impl(target, pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glGetBufferPointerv_Hook(GLenum target, GLenum pname, GLvoid* *params) + { + if(glGetBufferPointerv_Impl) + glGetBufferPointerv_Impl(target, pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + + // GL_VERSION_2_0 + void OVR::GLEContext::glBlendEquationSeparate_Hook(GLenum modeRGB, GLenum modeAlpha) + { + if(glBlendEquationSeparate_Impl) + glBlendEquationSeparate_Impl(modeRGB, modeAlpha); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glDrawBuffers_Hook(GLsizei n, const GLenum *bufs) + { + if(glDrawBuffers_Impl) + glDrawBuffers_Impl(n, bufs); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glStencilOpSeparate_Hook(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass) + { + if(glStencilOpSeparate_Impl) + glStencilOpSeparate_Impl(face, sfail, dpfail, dppass); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glStencilFuncSeparate_Hook(GLenum face, GLenum func, GLint ref, GLuint mask) + { + if(glStencilFuncSeparate_Impl) + glStencilFuncSeparate_Impl(face, func, ref, mask); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glStencilMaskSeparate_Hook(GLenum face, GLuint mask) + { + if(glStencilMaskSeparate_Impl) + glStencilMaskSeparate_Impl(face, mask); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glAttachShader_Hook(GLuint program, GLuint shader) + { + if(glAttachShader_Impl) + glAttachShader_Impl(program, shader); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glBindAttribLocation_Hook(GLuint program, GLuint index, const GLchar *name) + { + if(glBindAttribLocation_Impl) + glBindAttribLocation_Impl(program, index, name); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glCompileShader_Hook(GLuint shader) + { + if(glCompileShader_Impl) + glCompileShader_Impl(shader); + PostHook(GLE_CURRENT_FUNCTION); + } + + GLuint OVR::GLEContext::glCreateProgram_Hook() + { + GLuint u = 0; + if(glCreateProgram_Impl) + u = glCreateProgram_Impl(); + PostHook(GLE_CURRENT_FUNCTION); + return u; + } + + GLuint OVR::GLEContext::glCreateShader_Hook(GLenum type) + { + GLuint u = 0; + if(glCreateShader_Impl) + u = glCreateShader_Impl(type); + PostHook(GLE_CURRENT_FUNCTION); + return u; + } + + void OVR::GLEContext::glDeleteProgram_Hook(GLuint program) + { + if(glDeleteProgram_Impl) + glDeleteProgram_Impl(program); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glDeleteShader_Hook(GLuint shader) + { + if(glDeleteShader_Impl) + glDeleteShader_Impl(shader); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glDetachShader_Hook(GLuint program, GLuint shader) + { + if(glDetachShader_Impl) + glDetachShader_Impl(program, shader); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glDisableVertexAttribArray_Hook(GLuint index) + { + if(glDisableVertexAttribArray_Impl) + glDisableVertexAttribArray_Impl(index); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glEnableVertexAttribArray_Hook(GLuint index) + { + if(glEnableVertexAttribArray_Impl) + glEnableVertexAttribArray_Impl(index); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glGetActiveAttrib_Hook(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name) + { + if(glGetActiveAttrib_Impl) + glGetActiveAttrib_Impl(program, index, bufSize, length, size, type, name); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glGetActiveUniform_Hook(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name) + { + if(glGetActiveUniform_Impl) + glGetActiveUniform_Impl(program, index, bufSize, length, size, type, name); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glGetAttachedShaders_Hook(GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj) + { + if(glGetAttachedShaders_Impl) + glGetAttachedShaders_Impl(program, maxCount, count, obj); + PostHook(GLE_CURRENT_FUNCTION); + } + + GLint OVR::GLEContext::glGetAttribLocation_Hook(GLuint program, const GLchar *name) + { + GLint i = 0; + if(glGetAttribLocation_Impl) + i = glGetAttribLocation_Impl(program, name); + PostHook(GLE_CURRENT_FUNCTION); + return i; + } + + void OVR::GLEContext::glGetProgramiv_Hook(GLuint program, GLenum pname, GLint *params) + { + if(glGetProgramiv_Impl) + glGetProgramiv_Impl(program, pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glGetProgramInfoLog_Hook(GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog) + { + if(glGetProgramInfoLog_Impl) + glGetProgramInfoLog_Impl(program, bufSize, length, infoLog); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glGetShaderiv_Hook(GLuint shader, GLenum pname, GLint *params) + { + if(glGetShaderiv_Impl) + glGetShaderiv_Impl(shader, pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glGetShaderInfoLog_Hook(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog) + { + if(glGetShaderInfoLog_Impl) + glGetShaderInfoLog_Impl(shader, bufSize, length, infoLog); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glGetShaderSource_Hook(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source) + { + if(glGetShaderSource_Impl) + glGetShaderSource_Impl(shader, bufSize, length, source); + PostHook(GLE_CURRENT_FUNCTION); + } + + GLint OVR::GLEContext::glGetUniformLocation_Hook(GLuint program, const GLchar *name) + { + GLint i = 0; + if(glGetUniformLocation_Impl) + i = glGetUniformLocation_Impl(program, name); + PostHook(GLE_CURRENT_FUNCTION); + return i; + } + + void OVR::GLEContext::glGetUniformfv_Hook(GLuint program, GLint location, GLfloat *params) + { + if(glGetUniformfv_Impl) + glGetUniformfv_Impl(program, location, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glGetUniformiv_Hook(GLuint program, GLint location, GLint *params) + { + if(glGetUniformiv_Impl) + glGetUniformiv_Impl(program, location, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glGetVertexAttribdv_Hook(GLuint index, GLenum pname, GLdouble *params) + { + if(glGetVertexAttribdv_Impl) + glGetVertexAttribdv_Impl(index, pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glGetVertexAttribfv_Hook(GLuint index, GLenum pname, GLfloat *params) + { + if(glGetVertexAttribfv_Impl) + glGetVertexAttribfv_Impl(index, pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glGetVertexAttribiv_Hook(GLuint index, GLenum pname, GLint *params) + { + if(glGetVertexAttribiv_Impl) + glGetVertexAttribiv_Impl(index, pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glGetVertexAttribPointerv_Hook(GLuint index, GLenum pname, GLvoid* *pointer) + { + if(glGetVertexAttribPointerv_Impl) + glGetVertexAttribPointerv_Impl(index, pname, pointer); + PostHook(GLE_CURRENT_FUNCTION); + } + + GLboolean OVR::GLEContext::glIsProgram_Hook(GLuint program) + { + GLboolean b = GL_FALSE; + if(glIsProgram_Impl) + b = glIsProgram_Impl(program); + PostHook(GLE_CURRENT_FUNCTION); + return b; + } + + GLboolean OVR::GLEContext::glIsShader_Hook(GLuint shader) + { + GLboolean b = GL_FALSE; + if(glIsShader_Impl) + b = glIsShader_Impl(shader); + PostHook(GLE_CURRENT_FUNCTION); + return b; + } + + void OVR::GLEContext::glLinkProgram_Hook(GLuint program) + { + if(glLinkProgram_Impl) + glLinkProgram_Impl(program); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glShaderSource_Hook(GLuint shader, GLsizei count, const GLchar* *string, const GLint *length) + { + if(glShaderSource_Impl) + glShaderSource_Impl(shader, count, string, length); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glUseProgram_Hook(GLuint program) + { + if(glUseProgram_Impl) + glUseProgram_Impl(program); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glUniform1f_Hook(GLint location, GLfloat v0) + { + if(glUniform1f_Impl) + glUniform1f_Impl(location, v0); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glUniform2f_Hook(GLint location, GLfloat v0, GLfloat v1) + { + if(glUniform2f_Impl) + glUniform2f_Impl(location, v0, v1); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glUniform3f_Hook(GLint location, GLfloat v0, GLfloat v1, GLfloat v2) + { + if(glUniform3f_Impl) + glUniform3f_Impl(location, v0, v1, v2); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glUniform4f_Hook(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3) + { + if(glUniform4f_Impl) + glUniform4f_Impl(location, v0, v1, v2, v3); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glUniform1i_Hook(GLint location, GLint v0) + { + if(glUniform1i_Impl) + glUniform1i_Impl(location, v0); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glUniform2i_Hook(GLint location, GLint v0, GLint v1) + { + if(glUniform2i_Impl) + glUniform2i_Impl(location, v0, v1); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glUniform3i_Hook(GLint location, GLint v0, GLint v1, GLint v2) + { + if(glUniform3i_Impl) + glUniform3i_Impl(location, v0, v1, v2); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glUniform4i_Hook(GLint location, GLint v0, GLint v1, GLint v2, GLint v3) + { + if(glUniform4i_Impl) + glUniform4i_Impl(location, v0, v1, v2, v3); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glUniform1fv_Hook(GLint location, GLsizei count, const GLfloat *value) + { + if(glUniform1fv_Impl) + glUniform1fv_Impl(location, count, value); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glUniform2fv_Hook(GLint location, GLsizei count, const GLfloat *value) + { + if(glUniform2fv_Impl) + glUniform2fv_Impl(location, count, value); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glUniform3fv_Hook(GLint location, GLsizei count, const GLfloat *value) + { + if(glUniform3fv_Impl) + glUniform3fv_Impl(location, count, value); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glUniform4fv_Hook(GLint location, GLsizei count, const GLfloat *value) + { + if(glUniform4fv_Impl) + glUniform4fv_Impl(location, count, value); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glUniform1iv_Hook(GLint location, GLsizei count, const GLint *value) + { + if(glUniform1iv_Impl) + glUniform1iv_Impl(location, count, value); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glUniform2iv_Hook(GLint location, GLsizei count, const GLint *value) + { + if(glUniform2iv_Impl) + glUniform2iv_Impl(location, count, value); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glUniform3iv_Hook(GLint location, GLsizei count, const GLint *value) + { + if(glUniform3iv_Impl) + glUniform3iv_Impl(location, count, value); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glUniform4iv_Hook(GLint location, GLsizei count, const GLint *value) + { + if(glUniform4iv_Impl) + glUniform4iv_Impl(location, count, value); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glUniformMatrix2fv_Hook(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) + { + if(glUniformMatrix2fv_Impl) + glUniformMatrix2fv_Impl(location, count, transpose, value); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glUniformMatrix3fv_Hook(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) + { + if(glUniformMatrix3fv_Impl) + glUniformMatrix3fv_Impl(location, count, transpose, value); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glUniformMatrix4fv_Hook(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) + { + if(glUniformMatrix4fv_Impl) + glUniformMatrix4fv_Impl(location, count, transpose, value); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glValidateProgram_Hook(GLuint program) + { + if(glValidateProgram_Impl) + glValidateProgram_Impl(program); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glVertexAttrib1d_Hook(GLuint index, GLdouble x) + { + if(glVertexAttrib1d_Impl) + glVertexAttrib1d_Impl(index, x); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glVertexAttrib1dv_Hook(GLuint index, const GLdouble *v) + { + if(glVertexAttrib1dv_Impl) + glVertexAttrib1dv_Impl(index, v); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glVertexAttrib1f_Hook(GLuint index, GLfloat x) + { + if(glVertexAttrib1f_Impl) + glVertexAttrib1f_Impl(index, x); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glVertexAttrib1fv_Hook(GLuint index, const GLfloat *v) + { + if(glVertexAttrib1fv_Impl) + glVertexAttrib1fv_Impl(index, v); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glVertexAttrib1s_Hook(GLuint index, GLshort x) + { + if(glVertexAttrib1s_Impl) + glVertexAttrib1s_Impl(index, x); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glVertexAttrib1sv_Hook(GLuint index, const GLshort *v) + { + if(glVertexAttrib1sv_Impl) + glVertexAttrib1sv_Impl(index, v); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glVertexAttrib2d_Hook(GLuint index, GLdouble x, GLdouble y) + { + if(glVertexAttrib2d_Impl) + glVertexAttrib2d_Impl(index, x, y); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glVertexAttrib2dv_Hook(GLuint index, const GLdouble *v) + { + if(glVertexAttrib2dv_Impl) + glVertexAttrib2dv_Impl(index, v); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glVertexAttrib2f_Hook(GLuint index, GLfloat x, GLfloat y) + { + if(glVertexAttrib2f_Impl) + glVertexAttrib2f_Impl(index, x, y); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glVertexAttrib2fv_Hook(GLuint index, const GLfloat *v) + { + if(glVertexAttrib2fv_Impl) + glVertexAttrib2fv_Impl(index, v); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glVertexAttrib2s_Hook(GLuint index, GLshort x, GLshort y) + { + if(glVertexAttrib2s_Impl) + glVertexAttrib2s_Impl(index, x, y); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glVertexAttrib2sv_Hook(GLuint index, const GLshort *v) + { + if(glVertexAttrib2sv_Impl) + glVertexAttrib2sv_Impl(index, v); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glVertexAttrib3d_Hook(GLuint index, GLdouble x, GLdouble y, GLdouble z) + { + if(glVertexAttrib3d_Impl) + glVertexAttrib3d_Impl(index, x, y, z); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glVertexAttrib3dv_Hook(GLuint index, const GLdouble *v) + { + if(glVertexAttrib3dv_Impl) + glVertexAttrib3dv_Impl(index, v); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glVertexAttrib3f_Hook(GLuint index, GLfloat x, GLfloat y, GLfloat z) + { + if(glVertexAttrib3f_Impl) + glVertexAttrib3f_Impl(index, x, y, z); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glVertexAttrib3fv_Hook(GLuint index, const GLfloat *v) + { + if(glVertexAttrib3fv_Impl) + glVertexAttrib3fv_Impl(index, v); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glVertexAttrib3s_Hook(GLuint index, GLshort x, GLshort y, GLshort z) + { + if(glVertexAttrib3s_Impl) + glVertexAttrib3s_Impl(index, x, y, z); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glVertexAttrib3sv_Hook(GLuint index, const GLshort *v) + { + if(glVertexAttrib3sv_Impl) + glVertexAttrib3sv_Impl(index, v); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glVertexAttrib4Nbv_Hook(GLuint index, const GLbyte *v) + { + if(glVertexAttrib4Nbv_Impl) + glVertexAttrib4Nbv_Impl(index, v); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glVertexAttrib4Niv_Hook(GLuint index, const GLint *v) + { + if(glVertexAttrib4Niv_Impl) + glVertexAttrib4Niv_Impl(index, v); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glVertexAttrib4Nsv_Hook(GLuint index, const GLshort *v) + { + if(glVertexAttrib4Nsv_Impl) + glVertexAttrib4Nsv_Impl(index, v); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glVertexAttrib4Nub_Hook(GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w) + { + if(glVertexAttrib4Nub_Impl) + glVertexAttrib4Nub_Impl(index, x, y, z, w); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glVertexAttrib4Nubv_Hook(GLuint index, const GLubyte *v) + { + if(glVertexAttrib4Nubv_Impl) + glVertexAttrib4Nubv_Impl(index, v); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glVertexAttrib4Nuiv_Hook(GLuint index, const GLuint *v) + { + if(glVertexAttrib4Nuiv_Impl) + glVertexAttrib4Nuiv_Impl(index, v); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glVertexAttrib4Nusv_Hook(GLuint index, const GLushort *v) + { + if(glVertexAttrib4Nusv_Impl) + glVertexAttrib4Nusv_Impl(index, v); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glVertexAttrib4bv_Hook(GLuint index, const GLbyte *v) + { + if(glVertexAttrib4bv_Impl) + glVertexAttrib4bv_Impl(index, v); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glVertexAttrib4d_Hook(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w) + { + if(glVertexAttrib4d_Impl) + glVertexAttrib4d_Impl(index, x, y, z, w); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glVertexAttrib4dv_Hook(GLuint index, const GLdouble *v) + { + if(glVertexAttrib4dv_Impl) + glVertexAttrib4dv_Impl(index, v); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glVertexAttrib4f_Hook(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) + { + if(glVertexAttrib4f_Impl) + glVertexAttrib4f_Impl(index, x, y, z, w); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glVertexAttrib4fv_Hook(GLuint index, const GLfloat *v) + { + if(glVertexAttrib4fv_Impl) + glVertexAttrib4fv_Impl(index, v); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glVertexAttrib4iv_Hook(GLuint index, const GLint *v) + { + if(glVertexAttrib4iv_Impl) + glVertexAttrib4iv_Impl(index, v); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glVertexAttrib4s_Hook(GLuint index, GLshort x, GLshort y, GLshort z, GLshort w) + { + if(glVertexAttrib4s_Impl) + glVertexAttrib4s_Impl(index, x, y, z, w); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glVertexAttrib4sv_Hook(GLuint index, const GLshort *v) + { + if(glVertexAttrib4sv_Impl) + glVertexAttrib4sv_Impl(index, v); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glVertexAttrib4ubv_Hook(GLuint index, const GLubyte *v) + { + if(glVertexAttrib4ubv_Impl) + glVertexAttrib4ubv_Impl(index, v); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glVertexAttrib4uiv_Hook(GLuint index, const GLuint *v) + { + if(glVertexAttrib4uiv_Impl) + glVertexAttrib4uiv_Impl(index, v); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glVertexAttrib4usv_Hook(GLuint index, const GLushort *v) + { + if(glVertexAttrib4usv_Impl) + glVertexAttrib4usv_Impl(index, v); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glVertexAttribPointer_Hook(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer) + { + if(glVertexAttribPointer_Impl) + glVertexAttribPointer_Impl(index, size, type, normalized, stride, pointer); + PostHook(GLE_CURRENT_FUNCTION); + } + + + // GL_VERSION_2_1 + void OVR::GLEContext::glUniformMatrix2x3fv_Hook(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) + { + if(glUniformMatrix2x3fv_Impl) + glUniformMatrix2x3fv_Impl(location, count, transpose, value); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glUniformMatrix3x2fv_Hook(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) + { + if(glUniformMatrix3x2fv_Impl) + glUniformMatrix3x2fv_Impl(location, count, transpose, value); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glUniformMatrix2x4fv_Hook(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) + { + if(glUniformMatrix2x4fv_Impl) + glUniformMatrix2x4fv_Impl(location, count, transpose, value); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glUniformMatrix4x2fv_Hook(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) + { + if(glUniformMatrix4x2fv_Impl) + glUniformMatrix4x2fv_Impl(location, count, transpose, value); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glUniformMatrix3x4fv_Hook(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) + { + if(glUniformMatrix3x4fv_Impl) + glUniformMatrix3x4fv_Impl(location, count, transpose, value); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glUniformMatrix4x3fv_Hook(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) + { + if(glUniformMatrix4x3fv_Impl) + glUniformMatrix4x3fv_Impl(location, count, transpose, value); + PostHook(GLE_CURRENT_FUNCTION); + } + + + // GL_VERSION_3_0 + void OVR::GLEContext::glColorMaski_Hook(GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a) + { + if(glColorMaski_Impl) + glColorMaski_Impl(index, r, g, b, a); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glGetBooleani_v_Hook(GLenum target, GLuint index, GLboolean *data) + { + if(glGetBooleani_v_Impl) + glGetBooleani_v_Impl(target, index, data); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glGetIntegeri_v_Hook(GLenum target, GLuint index, GLint *data) + { + if(glGetIntegeri_v_Impl) + glGetIntegeri_v_Impl(target, index, data); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glEnablei_Hook(GLenum target, GLuint index) + { + if(glEnablei_Impl) + glEnablei_Impl(target, index); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glDisablei_Hook(GLenum target, GLuint index) + { + if(glDisablei_Impl) + glDisablei_Impl(target, index); + PostHook(GLE_CURRENT_FUNCTION); + } + + GLboolean OVR::GLEContext::glIsEnabledi_Hook(GLenum target, GLuint index) + { + GLboolean b = GL_FALSE; + if(glIsEnabledi_Impl) + b = glIsEnabledi_Impl(target, index); + PostHook(GLE_CURRENT_FUNCTION); + return b; + } + + void OVR::GLEContext::glBeginTransformFeedback_Hook(GLenum primitiveMode) + { + if(glBeginTransformFeedback_Impl) + glBeginTransformFeedback_Impl(primitiveMode); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glEndTransformFeedback_Hook() + { + if(glEndTransformFeedback_Impl) + glEndTransformFeedback_Impl(); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glBindBufferRange_Hook(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size) + { + if(glBindBufferRange_Impl) + glBindBufferRange_Impl(target, index, buffer, offset, size); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glBindBufferBase_Hook(GLenum target, GLuint index, GLuint buffer) + { + if(glBindBufferBase_Impl) + glBindBufferBase_Impl(target, index, buffer); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glTransformFeedbackVaryings_Hook(GLuint program, GLsizei count, const GLchar* *varyings, GLenum bufferMode) + { + if(glTransformFeedbackVaryings_Impl) + glTransformFeedbackVaryings_Impl(program, count, varyings, bufferMode); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glGetTransformFeedbackVarying_Hook(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name) + { + if(glGetTransformFeedbackVarying_Impl) + glGetTransformFeedbackVarying_Impl(program, index, bufSize, length, size, type, name); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glClampColor_Hook(GLenum target, GLenum clamp) + { + if(glClampColor_Impl) + glClampColor_Impl(target, clamp); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glBeginConditionalRender_Hook(GLuint id, GLenum mode) + { + if(glBeginConditionalRender_Impl) + glBeginConditionalRender_Impl(id, mode); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glEndConditionalRender_Hook() + { + if(glEndConditionalRender_Impl) + glEndConditionalRender_Impl(); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glVertexAttribIPointer_Hook(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) + { + if(glVertexAttribIPointer_Impl) + glVertexAttribIPointer_Impl(index, size, type, stride, pointer); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glGetVertexAttribIiv_Hook(GLuint index, GLenum pname, GLint *params) + { + if(glGetVertexAttribIiv_Impl) + glGetVertexAttribIiv_Impl(index, pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glGetVertexAttribIuiv_Hook(GLuint index, GLenum pname, GLuint *params) + { + if(glGetVertexAttribIuiv_Impl) + glGetVertexAttribIuiv_Impl(index, pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glVertexAttribI1i_Hook(GLuint index, GLint x) + { + if(glVertexAttribI1i_Impl) + glVertexAttribI1i_Impl(index, x); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glVertexAttribI2i_Hook(GLuint index, GLint x, GLint y) + { + if(glVertexAttribI2i_Impl) + glVertexAttribI2i_Impl(index, x, y); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glVertexAttribI3i_Hook(GLuint index, GLint x, GLint y, GLint z) + { + if(glVertexAttribI3i_Impl) + glVertexAttribI3i_Impl(index, x, y, z); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glVertexAttribI4i_Hook(GLuint index, GLint x, GLint y, GLint z, GLint w) + { + if(glVertexAttribI4i_Impl) + glVertexAttribI4i_Impl(index, x, y, z, w); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glVertexAttribI1ui_Hook(GLuint index, GLuint x) + { + if(glVertexAttribI1ui_Impl) + glVertexAttribI1ui_Impl(index, x); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glVertexAttribI2ui_Hook(GLuint index, GLuint x, GLuint y) + { + if(glVertexAttribI2ui_Impl) + glVertexAttribI2ui_Impl(index, x, y); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glVertexAttribI3ui_Hook(GLuint index, GLuint x, GLuint y, GLuint z) + { + if(glVertexAttribI3ui_Impl) + glVertexAttribI3ui_Impl(index, x, y, z); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glVertexAttribI4ui_Hook(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w) + { + if(glVertexAttribI4ui_Impl) + glVertexAttribI4ui_Impl(index, x, y, z, w); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glVertexAttribI1iv_Hook(GLuint index, const GLint *v) + { + if(glVertexAttribI1iv_Impl) + glVertexAttribI1iv_Impl(index, v); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glVertexAttribI2iv_Hook(GLuint index, const GLint *v) + { + if(glVertexAttribI2iv_Impl) + glVertexAttribI2iv_Impl(index, v); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glVertexAttribI3iv_Hook(GLuint index, const GLint *v) + { + if(glVertexAttribI3iv_Impl) + glVertexAttribI3iv_Impl(index, v); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glVertexAttribI4iv_Hook(GLuint index, const GLint *v) + { + if(glVertexAttribI4iv_Impl) + glVertexAttribI4iv_Impl(index, v); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glVertexAttribI1uiv_Hook(GLuint index, const GLuint *v) + { + if(glVertexAttribI1uiv_Impl) + glVertexAttribI1uiv_Impl(index, v); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glVertexAttribI2uiv_Hook(GLuint index, const GLuint *v) + { + if(glVertexAttribI2uiv_Impl) + glVertexAttribI2uiv_Impl(index, v); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glVertexAttribI3uiv_Hook(GLuint index, const GLuint *v) + { + if(glVertexAttribI3uiv_Impl) + glVertexAttribI3uiv_Impl(index, v); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glVertexAttribI4uiv_Hook(GLuint index, const GLuint *v) + { + if(glVertexAttribI4uiv_Impl) + glVertexAttribI4uiv_Impl(index, v); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glVertexAttribI4bv_Hook(GLuint index, const GLbyte *v) + { + if(glVertexAttribI4bv_Impl) + glVertexAttribI4bv_Impl(index, v); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glVertexAttribI4sv_Hook(GLuint index, const GLshort *v) + { + if(glVertexAttribI4sv_Impl) + glVertexAttribI4sv_Impl(index, v); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glVertexAttribI4ubv_Hook(GLuint index, const GLubyte *v) + { + if(glVertexAttribI4ubv_Impl) + glVertexAttribI4ubv_Impl(index, v); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glVertexAttribI4usv_Hook(GLuint index, const GLushort *v) + { + if(glVertexAttribI4usv_Impl) + glVertexAttribI4usv_Impl(index, v); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glGetUniformuiv_Hook(GLuint program, GLint location, GLuint *params) + { + if(glGetUniformuiv_Impl) + glGetUniformuiv_Impl(program, location, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glBindFragDataLocation_Hook(GLuint program, GLuint color, const GLchar *name) + { + if(glBindFragDataLocation_Impl) + glBindFragDataLocation_Impl(program, color, name); + PostHook(GLE_CURRENT_FUNCTION); + } + + GLint OVR::GLEContext::glGetFragDataLocation_Hook(GLuint program, const GLchar *name) + { + GLint i = 0; + if(glGetFragDataLocation_Impl) + i = glGetFragDataLocation_Impl(program, name); + PostHook(GLE_CURRENT_FUNCTION); + return i; + } + + void OVR::GLEContext::glUniform1ui_Hook(GLint location, GLuint v0) + { + if(glUniform1ui_Impl) + glUniform1ui_Impl(location, v0); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glUniform2ui_Hook(GLint location, GLuint v0, GLuint v1) + { + if(glUniform2ui_Impl) + glUniform2ui_Impl(location, v0, v1); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glUniform3ui_Hook(GLint location, GLuint v0, GLuint v1, GLuint v2) + { + if(glUniform3ui_Impl) + glUniform3ui_Impl(location, v0, v1, v2); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glUniform4ui_Hook(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3) + { + if(glUniform4ui_Impl) + glUniform4ui_Impl(location, v0, v1, v2, v3); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glUniform1uiv_Hook(GLint location, GLsizei count, const GLuint *value) + { + if(glUniform1uiv_Impl) + glUniform1uiv_Impl(location, count, value); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glUniform2uiv_Hook(GLint location, GLsizei count, const GLuint *value) + { + if(glUniform2uiv_Impl) + glUniform2uiv_Impl(location, count, value); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glUniform3uiv_Hook(GLint location, GLsizei count, const GLuint *value) + { + if(glUniform3uiv_Impl) + glUniform3uiv_Impl(location, count, value); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glUniform4uiv_Hook(GLint location, GLsizei count, const GLuint *value) + { + if(glUniform4uiv_Impl) + glUniform4uiv_Impl(location, count, value); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glTexParameterIiv_Hook(GLenum target, GLenum pname, const GLint *params) + { + if(glTexParameterIiv_Impl) + glTexParameterIiv_Impl(target, pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glTexParameterIuiv_Hook(GLenum target, GLenum pname, const GLuint *params) + { + if(glTexParameterIuiv_Impl) + glTexParameterIuiv_Impl(target, pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glGetTexParameterIiv_Hook(GLenum target, GLenum pname, GLint *params) + { + if(glGetTexParameterIiv_Impl) + glGetTexParameterIiv_Impl(target, pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glGetTexParameterIuiv_Hook(GLenum target, GLenum pname, GLuint *params) + { + if(glGetTexParameterIuiv_Impl) + glGetTexParameterIuiv_Impl(target, pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glClearBufferiv_Hook(GLenum buffer, GLint drawbuffer, const GLint *value) + { + if(glClearBufferiv_Impl) + glClearBufferiv_Impl(buffer, drawbuffer, value); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glClearBufferuiv_Hook(GLenum buffer, GLint drawbuffer, const GLuint *value) + { + if(glClearBufferuiv_Impl) + glClearBufferuiv_Impl(buffer, drawbuffer, value); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glClearBufferfv_Hook(GLenum buffer, GLint drawbuffer, const GLfloat *value) + { + if(glClearBufferfv_Impl) + glClearBufferfv_Impl(buffer, drawbuffer, value); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glClearBufferfi_Hook(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil) + { + if(glClearBufferfi_Impl) + glClearBufferfi_Impl(buffer, drawbuffer, depth, stencil); + PostHook(GLE_CURRENT_FUNCTION); + } + + const GLubyte* OVR::GLEContext::glGetStringi_Hook(GLenum name, GLuint index) + { + const GLubyte* p = NULL; + if(glGetStringi_Impl) + p = glGetStringi_Impl(name, index); + PostHook(GLE_CURRENT_FUNCTION); + return p; + } + + + // GL_VERSION_3_1 + void OVR::GLEContext::glDrawArraysInstanced_Hook(GLenum mode, GLint first, GLsizei count, GLsizei primcount) + { + if(glDrawArraysInstanced_Impl) + glDrawArraysInstanced_Impl(mode, first, count, primcount); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glDrawElementsInstanced_Hook(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount) + { + if(glDrawElementsInstanced_Impl) + glDrawElementsInstanced_Impl(mode, count, type, indices, primcount); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glTexBuffer_Hook(GLenum target, GLenum internalformat, GLuint buffer) + { + if(glTexBuffer_Impl) + glTexBuffer_Impl(target, internalformat, buffer); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glPrimitiveRestartIndex_Hook(GLuint index) + { + if(glPrimitiveRestartIndex_Impl) + glPrimitiveRestartIndex_Impl(index); + PostHook(GLE_CURRENT_FUNCTION); + } + + + // GL_VERSION_3_2 + void OVR::GLEContext::glGetInteger64i_v_Hook(GLenum target, GLuint index, GLint64 *data) + { + if(glGetInteger64i_v_Impl) + glGetInteger64i_v_Impl(target, index, data); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glGetBufferParameteri64v_Hook(GLenum target, GLenum pname, GLint64 *params) + { + if(glGetBufferParameteri64v_Impl) + glGetBufferParameteri64v_Impl(target, pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glFramebufferTexture_Hook(GLenum target, GLenum attachment, GLuint texture, GLint level) + { + if(glFramebufferTexture_Impl) + glFramebufferTexture_Impl(target, attachment, texture, level); + PostHook(GLE_CURRENT_FUNCTION); + } + + + // GL_VERSION_3_3 + void OVR::GLEContext::glVertexAttribDivisor_Hook(GLuint index, GLuint divisor) + { + if(glVertexAttribDivisor_Impl) + glVertexAttribDivisor_Impl(index, divisor); + PostHook(GLE_CURRENT_FUNCTION); + } + + + // GL_VERSION_4_0 + void OVR::GLEContext::glMinSampleShading_Hook(GLclampf value) + { + if(glMinSampleShading_Impl) + glMinSampleShading_Impl(value); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glBlendEquationi_Hook(GLuint buf, GLenum mode) + { + if(glBlendEquationi_Impl) + glBlendEquationi_Impl(buf, mode); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glBlendEquationSeparatei_Hook(GLuint buf, GLenum modeRGB, GLenum modeAlpha) + { + if(glBlendEquationSeparatei_Impl) + glBlendEquationSeparatei_Impl(buf, modeRGB, modeAlpha); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glBlendFunci_Hook(GLuint buf, GLenum src, GLenum dst) + { + if(glBlendFunci_Impl) + glBlendFunci_Impl(buf, src, dst); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glBlendFuncSeparatei_Hook(GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) + { + if(glBlendFuncSeparatei_Impl) + glBlendFuncSeparatei_Impl(buf, srcRGB, dstRGB, srcAlpha, dstAlpha); + PostHook(GLE_CURRENT_FUNCTION); + } + + + // GL_AMD_debug_output + void OVR::GLEContext::glDebugMessageEnableAMD_Hook(GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled) + { + if(glDebugMessageEnableAMD_Impl) + glDebugMessageEnableAMD_Impl(category, severity, count, ids, enabled); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glDebugMessageInsertAMD_Hook(GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf) + { + if(glDebugMessageInsertAMD_Impl) + glDebugMessageInsertAMD_Impl(category, severity, id, length, buf); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glDebugMessageCallbackAMD_Hook(GLDEBUGPROCAMD callback, GLvoid *userParam) + { + if(glDebugMessageCallbackAMD_Impl) + glDebugMessageCallbackAMD_Impl(callback, userParam); + PostHook(GLE_CURRENT_FUNCTION); + } + + GLuint OVR::GLEContext::glGetDebugMessageLogAMD_Hook(GLuint count, GLsizei bufsize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message) + { + GLuint u = 0; + if(glGetDebugMessageLogAMD_Impl) + u = glGetDebugMessageLogAMD_Impl(count, bufsize, categories, severities, ids, lengths, message); + PostHook(GLE_CURRENT_FUNCTION); + return u; + } + + + #if defined(GLE_CGL_ENABLED) + // GL_APPLE_element_array + void OVR::GLEContext::glElementPointerAPPLE_Hook(GLenum type, const GLvoid *pointer) + { + if(glElementPointerAPPLE_Impl) + glElementPointerAPPLE_Impl(type, pointer); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glDrawElementArrayAPPLE_Hook(GLenum mode, GLint first, GLsizei count) + { + if(glDrawElementArrayAPPLE_Impl) + glDrawElementArrayAPPLE_Impl(mode, first, count); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glDrawRangeElementArrayAPPLE_Hook(GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count) + { + if(glDrawRangeElementArrayAPPLE_Impl) + glDrawRangeElementArrayAPPLE_Impl(mode, start, end, first, count); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glMultiDrawElementArrayAPPLE_Hook(GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount) + { + if(glMultiDrawElementArrayAPPLE_Impl) + glMultiDrawElementArrayAPPLE_Impl(mode, first, count, primcount); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glMultiDrawRangeElementArrayAPPLE_Hook(GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount) + { + if(glMultiDrawRangeElementArrayAPPLE_Impl) + glMultiDrawRangeElementArrayAPPLE_Impl(mode, start, end, first, count, primcount); + PostHook(GLE_CURRENT_FUNCTION); + } + + + // GL_APPLE_fence + void OVR::GLEContext::glGenFencesAPPLE_Hook(GLsizei n, GLuint *fences) + { + if(glGenFencesAPPLE_Impl) + glGenFencesAPPLE_Impl(n, fences); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glDeleteFencesAPPLE_Hook(GLsizei n, const GLuint *fences) + { + if(glDeleteFencesAPPLE_Impl) + glDeleteFencesAPPLE_Impl(n, fences); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glSetFenceAPPLE_Hook(GLuint fence) + { + if(glSetFenceAPPLE_Impl) + glSetFenceAPPLE_Impl(fence); + PostHook(GLE_CURRENT_FUNCTION); + } + + GLboolean OVR::GLEContext::glIsFenceAPPLE_Hook(GLuint fence) + { + GLboolean b = GL_FALSE; + if(glIsFenceAPPLE_Impl) + b = glIsFenceAPPLE_Impl(fence); + PostHook(GLE_CURRENT_FUNCTION); + return b; + } + + GLboolean OVR::GLEContext::glTestFenceAPPLE_Hook(GLuint fence) + { + GLboolean b = GL_FALSE; + if(glTestFenceAPPLE_Impl) + b = glTestFenceAPPLE_Impl(fence); + PostHook(GLE_CURRENT_FUNCTION); + return b; + } + + void OVR::GLEContext::glFinishFenceAPPLE_Hook(GLuint fence) + { + if(glFinishFenceAPPLE_Impl) + glFinishFenceAPPLE_Impl(fence); + PostHook(GLE_CURRENT_FUNCTION); + } + + GLboolean OVR::GLEContext::glTestObjectAPPLE_Hook(GLenum object, GLuint name) + { + GLboolean b = GL_FALSE; + if(glTestObjectAPPLE_Impl) + b = glTestObjectAPPLE_Impl(object, name); + PostHook(GLE_CURRENT_FUNCTION); + return b; + } + + void OVR::GLEContext::glFinishObjectAPPLE_Hook(GLenum object, GLint name) + { + if(glFinishObjectAPPLE_Impl) + glFinishObjectAPPLE_Impl(object, name); + PostHook(GLE_CURRENT_FUNCTION); + } + + + // GL_APPLE_flush_buffer_range + void OVR::GLEContext::glBufferParameteriAPPLE_Hook(GLenum target, GLenum pname, GLint param) + { + if(glBufferParameteriAPPLE_Impl) + glBufferParameteriAPPLE_Impl(target, pname, param); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glFlushMappedBufferRangeAPPLE_Hook(GLenum target, GLintptr offset, GLsizeiptr size) + { + if(glFlushMappedBufferRangeAPPLE_Impl) + glFlushMappedBufferRangeAPPLE_Impl(target, offset, size); + PostHook(GLE_CURRENT_FUNCTION); + } + + + // GL_APPLE_object_purgeable + GLenum OVR::GLEContext::glObjectPurgeableAPPLE_Hook(GLenum objectType, GLuint name, GLenum option) + { + GLenum e = 0; + if(glObjectPurgeableAPPLE_Impl) + e = glObjectPurgeableAPPLE_Impl(objectType, name, option); + PostHook(GLE_CURRENT_FUNCTION); + return e; + } + + GLenum OVR::GLEContext::glObjectUnpurgeableAPPLE_Hook(GLenum objectType, GLuint name, GLenum option) + { + GLenum e = 0; + if(glObjectUnpurgeableAPPLE_Impl) + e =glObjectUnpurgeableAPPLE_Impl(objectType, name, option); + PostHook(GLE_CURRENT_FUNCTION); + return e; + } + + void OVR::GLEContext::glGetObjectParameterivAPPLE_Hook(GLenum objectType, GLuint name, GLenum pname, GLint *params) + { + if(glGetObjectParameterivAPPLE_Impl) + glGetObjectParameterivAPPLE_Impl(objectType, name, pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + + // GL_APPLE_texture_range + void OVR::GLEContext::glTextureRangeAPPLE_Hook(GLenum target, GLsizei length, const GLvoid *pointer) + { + if(glTextureRangeAPPLE_Impl) + glTextureRangeAPPLE_Impl(target, length, pointer); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glGetTexParameterPointervAPPLE_Hook(GLenum target, GLenum pname, GLvoid **params) + { + if(glGetTexParameterPointervAPPLE_Impl) + glGetTexParameterPointervAPPLE_Impl(target, pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + + // GL_APPLE_vertex_array_object + void OVR::GLEContext::glBindVertexArrayAPPLE_Hook(GLuint array) + { + if(glBindVertexArrayAPPLE_Impl) + glBindVertexArrayAPPLE_Impl(array); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glDeleteVertexArraysAPPLE_Hook(GLsizei n, const GLuint *arrays) + { + if(glDeleteVertexArraysAPPLE_Impl) + glDeleteVertexArraysAPPLE_Impl(n, arrays); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glGenVertexArraysAPPLE_Hook(GLsizei n, GLuint *arrays) + { + if(glGenVertexArraysAPPLE_Impl) + glGenVertexArraysAPPLE_Impl(n, arrays); + PostHook(GLE_CURRENT_FUNCTION); + } + + GLboolean OVR::GLEContext::glIsVertexArrayAPPLE_Hook(GLuint array) + { + GLboolean b = GL_FALSE; + if(glIsVertexArrayAPPLE_Impl) + b = glIsVertexArrayAPPLE_Impl(array); + PostHook(GLE_CURRENT_FUNCTION); + return b; + } + + + // GL_APPLE_vertex_array_range + void OVR::GLEContext::glVertexArrayRangeAPPLE_Hook(GLsizei length, GLvoid *pointer) + { + if(glVertexArrayRangeAPPLE_Impl) + glVertexArrayRangeAPPLE_Impl(length, pointer); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glFlushVertexArrayRangeAPPLE_Hook(GLsizei length, GLvoid *pointer) + { + if(glFlushVertexArrayRangeAPPLE_Impl) + glFlushVertexArrayRangeAPPLE_Impl(length, pointer); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glVertexArrayParameteriAPPLE_Hook(GLenum pname, GLint param) + { + if(glVertexArrayParameteriAPPLE_Impl) + glVertexArrayParameteriAPPLE_Impl(pname, param); + PostHook(GLE_CURRENT_FUNCTION); + } + + + // GL_APPLE_vertex_program_evaluators + void OVR::GLEContext::glEnableVertexAttribAPPLE_Hook(GLuint index, GLenum pname) + { + if(glEnableVertexAttribAPPLE_Impl) + glEnableVertexAttribAPPLE_Impl(index, pname); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glDisableVertexAttribAPPLE_Hook(GLuint index, GLenum pname) + { + if(glDisableVertexAttribAPPLE_Impl) + glDisableVertexAttribAPPLE_Impl(index, pname); + PostHook(GLE_CURRENT_FUNCTION); + } + + GLboolean OVR::GLEContext::glIsVertexAttribEnabledAPPLE_Hook(GLuint index, GLenum pname) + { + GLboolean b = GL_FALSE; + if(glIsVertexAttribEnabledAPPLE_Impl) + b = glIsVertexAttribEnabledAPPLE_Impl(index, pname); + PostHook(GLE_CURRENT_FUNCTION); + return b; + } + + void OVR::GLEContext::glMapVertexAttrib1dAPPLE_Hook(GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points) + { + if(glMapVertexAttrib1dAPPLE_Impl) + glMapVertexAttrib1dAPPLE_Impl(index, size, u1, u2, stride, order, points); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glMapVertexAttrib1fAPPLE_Hook(GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points) + { + if(glMapVertexAttrib1fAPPLE_Impl) + glMapVertexAttrib1fAPPLE_Impl(index, size, u1, u2, stride, order, points); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glMapVertexAttrib2dAPPLE_Hook(GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points) + { + if(glMapVertexAttrib2dAPPLE_Impl) + glMapVertexAttrib2dAPPLE_Impl(index, size, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glMapVertexAttrib2fAPPLE_Hook(GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points) + { + if(glMapVertexAttrib2fAPPLE_Impl) + glMapVertexAttrib2fAPPLE_Impl(index, size, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points); + PostHook(GLE_CURRENT_FUNCTION); + } + #endif // GLE_CGL_ENABLED + + + // GL_ARB_debug_output + void OVR::GLEContext::glDebugMessageControlARB_Hook(GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled) + { + if(glDebugMessageControlARB_Impl) + glDebugMessageControlARB_Impl(source, type, severity, count, ids, enabled); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glDebugMessageInsertARB_Hook(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf) + { + if(glDebugMessageInsertARB_Impl) + glDebugMessageInsertARB_Impl(source, type, id, severity, length, buf); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glDebugMessageCallbackARB_Hook(GLDEBUGPROCARB callback, const GLvoid *userParam) + { + if(glDebugMessageCallbackARB_Impl) + glDebugMessageCallbackARB_Impl(callback, userParam); + PostHook(GLE_CURRENT_FUNCTION); + } + + GLuint OVR::GLEContext::glGetDebugMessageLogARB_Hook(GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog) + { + GLuint u = 0; + if(glGetDebugMessageLogARB_Impl) + u = glGetDebugMessageLogARB_Impl(count, bufsize, sources, types, ids, severities, lengths, messageLog); + PostHook(GLE_CURRENT_FUNCTION); + return u; + } + + + // GL_ARB_ES2_compatibility + void OVR::GLEContext::glReleaseShaderCompiler_Hook() + { + if(glReleaseShaderCompiler_Impl) + glReleaseShaderCompiler_Impl(); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glShaderBinary_Hook(GLsizei count, const GLuint *shaders, GLenum binaryformat, const GLvoid *binary, GLsizei length) + { + if(glShaderBinary_Impl) + glShaderBinary_Impl(count, shaders, binaryformat, binary, length); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glGetShaderPrecisionFormat_Hook(GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision) + { + if(glGetShaderPrecisionFormat_Impl) + glGetShaderPrecisionFormat_Impl(shadertype, precisiontype, range, precision); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glDepthRangef_Hook(GLclampf n, GLclampf f) + { + if(glDepthRangef_Impl) + glDepthRangef_Impl(n, f); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glClearDepthf_Hook(GLclampf d) + { + if(glClearDepthf_Impl) + glClearDepthf_Impl(d); + PostHook(GLE_CURRENT_FUNCTION); + } + + + // GL_ARB_framebuffer_object + GLboolean OVR::GLEContext::glIsRenderbuffer_Hook(GLuint renderbuffer) + { + GLboolean b = GL_FALSE; + if(glIsRenderbuffer_Impl) + b = glIsRenderbuffer_Impl(renderbuffer); + PostHook(GLE_CURRENT_FUNCTION); + return b; + } + + void OVR::GLEContext::glBindRenderbuffer_Hook(GLenum target, GLuint renderbuffer) + { + if(glBindRenderbuffer_Impl) + glBindRenderbuffer_Impl(target, renderbuffer); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glDeleteRenderbuffers_Hook(GLsizei n, const GLuint *renderbuffers) + { + if(glDeleteRenderbuffers_Impl) + glDeleteRenderbuffers_Impl(n, renderbuffers); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glGenRenderbuffers_Hook(GLsizei n, GLuint *renderbuffers) + { + if(glGenRenderbuffers_Impl) + glGenRenderbuffers_Impl(n, renderbuffers); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glRenderbufferStorage_Hook(GLenum target, GLenum internalformat, GLsizei width, GLsizei height) + { + if(glRenderbufferStorage_Impl) + glRenderbufferStorage_Impl(target, internalformat, width, height); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glGetRenderbufferParameteriv_Hook(GLenum target, GLenum pname, GLint *params) + { + if(glGetRenderbufferParameteriv_Impl) + glGetRenderbufferParameteriv_Impl(target, pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + GLboolean OVR::GLEContext::glIsFramebuffer_Hook(GLuint framebuffer) + { + GLboolean b = GL_FALSE; + if(glIsFramebuffer_Impl) + b = glIsFramebuffer_Impl(framebuffer); + PostHook(GLE_CURRENT_FUNCTION); + return b; + } + + void OVR::GLEContext::glBindFramebuffer_Hook(GLenum target, GLuint framebuffer) + { + if(glBindFramebuffer_Impl) + glBindFramebuffer_Impl(target, framebuffer); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glDeleteFramebuffers_Hook(GLsizei n, const GLuint *framebuffers) + { + if(glDeleteFramebuffers_Impl) + glDeleteFramebuffers_Impl(n, framebuffers); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glGenFramebuffers_Hook(GLsizei n, GLuint *framebuffers) + { + if(glGenFramebuffers_Impl) + glGenFramebuffers_Impl(n, framebuffers); + PostHook(GLE_CURRENT_FUNCTION); + } + + GLenum OVR::GLEContext::glCheckFramebufferStatus_Hook(GLenum target) + { + GLenum e = 0; + if(glCheckFramebufferStatus_Impl) + e = glCheckFramebufferStatus_Impl(target); + PostHook(GLE_CURRENT_FUNCTION); + return e; + } + + void OVR::GLEContext::glFramebufferTexture1D_Hook(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) + { + if(glFramebufferTexture1D_Impl) + glFramebufferTexture1D_Impl(target, attachment, textarget, texture, level); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glFramebufferTexture2D_Hook(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) + { + if(glFramebufferTexture2D_Impl) + glFramebufferTexture2D_Impl(target, attachment, textarget, texture, level); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glFramebufferTexture3D_Hook(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset) + { + if(glFramebufferTexture3D_Impl) + glFramebufferTexture3D_Impl(target, attachment, textarget, texture, level, zoffset); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glFramebufferRenderbuffer_Hook(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) + { + if(glFramebufferRenderbuffer_Impl) + glFramebufferRenderbuffer_Impl(target, attachment, renderbuffertarget, renderbuffer); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glGetFramebufferAttachmentParameteriv_Hook(GLenum target, GLenum attachment, GLenum pname, GLint *params) + { + if(glGetFramebufferAttachmentParameteriv_Impl) + glGetFramebufferAttachmentParameteriv_Impl(target, attachment, pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glGenerateMipmap_Hook(GLenum target) + { + if(glGenerateMipmap_Impl) + glGenerateMipmap_Impl(target); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glBlitFramebuffer_Hook(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) + { + if(glBlitFramebuffer_Impl) + glBlitFramebuffer_Impl(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glRenderbufferStorageMultisample_Hook(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) + { + if(glRenderbufferStorageMultisample_Impl) + glRenderbufferStorageMultisample_Impl(target, samples, internalformat, width, height); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glFramebufferTextureLayer_Hook(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer) + { + if(glFramebufferTextureLayer_Impl) + glFramebufferTextureLayer_Impl(target, attachment, texture, level, layer); + PostHook(GLE_CURRENT_FUNCTION); + } + + + // GL_ARB_texture_multisample + void OVR::GLEContext::glTexImage2DMultisample_Hook(GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations) + { + if(glTexImage2DMultisample_Impl) + glTexImage2DMultisample_Impl(target, samples, internalformat, width, height, fixedsamplelocations); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glTexImage3DMultisample_Hook(GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations) + { + if(glTexImage3DMultisample_Impl) + glTexImage3DMultisample_Impl(target, samples, internalformat, width, height, depth, fixedsamplelocations); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glGetMultisamplefv_Hook(GLenum pname, GLuint index, GLfloat *val) + { + if(glGetMultisamplefv_Impl) + glGetMultisamplefv_Impl(pname, index, val); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glSampleMaski_Hook(GLuint index, GLbitfield mask) + { + if(glSampleMaski_Impl) + glSampleMaski_Impl(index, mask); + PostHook(GLE_CURRENT_FUNCTION); + } + + + // GL_ARB_timer_query + void OVR::GLEContext::glQueryCounter_Hook(GLuint id, GLenum target) + { + if(glQueryCounter_Impl) + glQueryCounter_Impl(id, target); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glGetQueryObjecti64v_Hook(GLuint id, GLenum pname, GLint64 *params) + { + if(glGetQueryObjecti64v_Impl) + glGetQueryObjecti64v_Impl(id, pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glGetQueryObjectui64v_Hook(GLuint id, GLenum pname, GLuint64 *params) + { + if(glGetQueryObjectui64v_Impl) + glGetQueryObjectui64v_Impl(id, pname, params); + PostHook(GLE_CURRENT_FUNCTION); + } + + + // GL_ARB_vertex_array_object + void OVR::GLEContext::glBindVertexArray_Hook(GLuint array) + { + if(glBindVertexArray_Impl) + glBindVertexArray_Impl(array); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glDeleteVertexArrays_Hook(GLsizei n, const GLuint *arrays) + { + if(glDeleteVertexArrays_Impl) + glDeleteVertexArrays_Impl(n, arrays); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glGenVertexArrays_Hook(GLsizei n, GLuint *arrays) + { + if(glGenVertexArrays_Impl) + glGenVertexArrays_Impl(n, arrays); + PostHook(GLE_CURRENT_FUNCTION); + } + + GLboolean OVR::GLEContext::glIsVertexArray_Hook(GLuint array) + { + GLboolean b = GL_FALSE; + if(glIsVertexArray_Impl) + b = glIsVertexArray_Impl(array); + PostHook(GLE_CURRENT_FUNCTION); + return b; + } + + + // GL_EXT_draw_buffers2 + void OVR::GLEContext::glColorMaskIndexedEXT_Hook(GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a) + { + if(glColorMaskIndexedEXT_Impl) + glColorMaskIndexedEXT_Impl(index, r, g, b, a); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glGetBooleanIndexedvEXT_Hook(GLenum target, GLuint index, GLboolean *data) + { + if(glGetBooleanIndexedvEXT_Impl) + glGetBooleanIndexedvEXT_Impl(target, index, data); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glGetIntegerIndexedvEXT_Hook(GLenum target, GLuint index, GLint *data) + { + if(glGetIntegerIndexedvEXT_Impl) + glGetIntegerIndexedvEXT_Impl(target, index, data); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glEnableIndexedEXT_Hook(GLenum target, GLuint index) + { + if(glEnableIndexedEXT_Impl) + glEnableIndexedEXT_Impl(target, index); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glDisableIndexedEXT_Hook(GLenum target, GLuint index) + { + if(glDisableIndexedEXT_Impl) + glDisableIndexedEXT_Impl(target, index); + PostHook(GLE_CURRENT_FUNCTION); + } + + GLboolean OVR::GLEContext::glIsEnabledIndexedEXT_Hook(GLenum target, GLuint index) + { + GLboolean b = GL_FALSE; + if(glIsEnabledIndexedEXT_Impl) + b = glIsEnabledIndexedEXT_Impl(target, index); + PostHook(GLE_CURRENT_FUNCTION); + return b; + } + + + // GL_KHR_debug + void OVR::GLEContext::glDebugMessageControl_Hook(GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint* ids, GLboolean enabled) + { + if(glDebugMessageControl_Impl) + glDebugMessageControl_Impl(source, type, severity, count, ids, enabled); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glDebugMessageInsert_Hook(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const char* buf) + { + if(glDebugMessageInsert_Impl) + glDebugMessageInsert_Impl(source, type, id, severity, length, buf); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glDebugMessageCallback_Hook(GLDEBUGPROC callback, const void* userParam) + { + if(glDebugMessageCallback_Impl) + glDebugMessageCallback_Impl(callback, userParam); + PostHook(GLE_CURRENT_FUNCTION); + } + + GLuint OVR::GLEContext::glGetDebugMessageLog_Hook(GLuint count, GLsizei bufSize, GLenum* sources, GLenum* types, GLuint* ids, GLenum* severities, GLsizei* lengths, char* messageLog) + { + GLuint u = 0; + if(glGetDebugMessageLog_Impl) + u = glGetDebugMessageLog_Impl(count, bufSize, sources, types, ids, severities, lengths, messageLog); + PostHook(GLE_CURRENT_FUNCTION); + return u; + } + + void OVR::GLEContext::glPushDebugGroup_Hook(GLenum source, GLuint id, GLsizei length, const char * message) + { + if(glPushDebugGroup_Impl) + glPushDebugGroup_Impl(source, id, length, message); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glPopDebugGroup_Hook() + { + if(glPopDebugGroup_Impl) + glPopDebugGroup_Impl(); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glObjectLabel_Hook(GLenum identifier, GLuint name, GLsizei length, const char *label) + { + if(glObjectLabel_Impl) + glObjectLabel_Impl(identifier, name, length, label); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glGetObjectLabel_Hook(GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, char *label) + { + if(glGetObjectLabel_Impl) + glGetObjectLabel_Impl(identifier, name, bufSize, length, label); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glObjectPtrLabel_Hook(void* ptr, GLsizei length, const char *label) + { + if(glObjectPtrLabel_Impl) + glObjectPtrLabel_Impl(ptr, length, label); + PostHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glGetObjectPtrLabel_Hook(void* ptr, GLsizei bufSize, GLsizei *length, char *label) + { + if(glGetObjectPtrLabel_Impl) + glGetObjectPtrLabel_Impl(ptr, bufSize, length, label); + PostHook(GLE_CURRENT_FUNCTION); + } + + + // GL_WIN_swap_hint + void OVR::GLEContext::glAddSwapHintRectWIN_Hook(GLint x, GLint y, GLsizei width, GLsizei height) + { + if(glAddSwapHintRectWIN_Impl) + glAddSwapHintRectWIN_Impl(x, y, width, height); + PostHook(GLE_CURRENT_FUNCTION); + } + + + #if defined(GLE_WGL_ENABLED) + // WGL + void OVR::GLEContext::PostWGLHook(const char* /*function*/) + { + // Empty for now. WGL functions don't have a function like glGetError(). + } + + /* We currently don't hook these + #undef wglCopyContext + extern "C" { GLAPI BOOL GLAPIENTRY wglCopyContext(HGLRC hglrcSrc, HGLRC hglrcDst, UINT mask); } + BOOL OVR::GLEContext::wglCopyContext_Hook(HGLRC hglrcSrc, HGLRC hglrcDst, UINT mask) + { + BOOL b = wglCopyContext(hglrcSrc, hglrcDst, mask); + PostWGLHook(GLE_CURRENT_FUNCTION); + return b; + } + + #undef wglCreateContext + extern "C" { GLAPI HGLRC GLAPIENTRY wglCreateContext(HDC hdc); } + HGLRC OVR::GLEContext::wglCreateContext_Hook(HDC hdc) + { + HGLRC h = wglCreateContext(hdc); + PostWGLHook(GLE_CURRENT_FUNCTION); + return h; + } + + #undef wglCreateLayerContext + extern "C" { GLAPI HGLRC GLAPIENTRY wglCreateLayerContext(HDC hdc, int iLayerPlane); } + HGLRC OVR::GLEContext::wglCreateLayerContext_Hook(HDC hdc, int iLayerPlane) + { + HGLRC h = wglCreateLayerContext(hdc, iLayerPlane); + PostWGLHook(GLE_CURRENT_FUNCTION); + return h; + } + + #undef wglDeleteContext + extern "C" { GLAPI BOOL GLAPIENTRY wglDeleteContext(HGLRC hglrc); } + BOOL OVR::GLEContext::wglDeleteContext_Hook(HGLRC hglrc) + { + BOOL b = wglDeleteContext(hglrc); + PostWGLHook(GLE_CURRENT_FUNCTION); + return b; + } + + #undef wglGetCurrentContext + extern "C" { GLAPI HGLRC GLAPIENTRY wglGetCurrentContext(); } + HGLRC OVR::GLEContext::wglGetCurrentContext_Hook() + { + HGLRC h = wglGetCurrentContext(); + PostWGLHook(GLE_CURRENT_FUNCTION); + return h; + } + + #undef wglGetCurrentDC + extern "C" { GLAPI HDC GLAPIENTRY wglGetCurrentDC(); } + HDC OVR::GLEContext::wglGetCurrentDC_Hook() + { + HDC h = wglGetCurrentDC(); + PostWGLHook(GLE_CURRENT_FUNCTION); + return h; + } + + //#undef wglGetProcAddress Not needed because we happen to do it above already. + //extern "C" { GLAPI PROC GLAPIENTRY wglGetProcAddress(LPCSTR lpszProc); } + PROC OVR::GLEContext::wglGetProcAddress_Hook(LPCSTR lpszProc) + { + PROC p = wglGetProcAddress(lpszProc); + PostWGLHook(GLE_CURRENT_FUNCTION); + return p; + } + + #undef wglMakeCurrent + extern "C" { GLAPI BOOL GLAPIENTRY wglMakeCurrent(HDC hdc, HGLRC hglrc); } + BOOL OVR::GLEContext::wglMakeCurrent_Hook(HDC hdc, HGLRC hglrc) + { + BOOL b = wglMakeCurrent(hdc, hglrc); + PostWGLHook(GLE_CURRENT_FUNCTION); + return b; + } + + #undef wglShareLists + extern "C" { GLAPI BOOL GLAPIENTRY wglShareLists(HGLRC hglrc1, HGLRC hglrc2); } + BOOL OVR::GLEContext::wglShareLists_Hook(HGLRC hglrc1, HGLRC hglrc2) + { + BOOL b = wglShareLists(hglrc1, hglrc2); + PostWGLHook(GLE_CURRENT_FUNCTION); + return b; + } + + #undef wglUseFontBitmapsA + extern "C" { GLAPI BOOL GLAPIENTRY wglUseFontBitmapsA(HDC hdc, DWORD first, DWORD count, DWORD listBase); } + BOOL OVR::GLEContext::wglUseFontBitmapsA_Hook(HDC hdc, DWORD first, DWORD count, DWORD listBase) + { + BOOL b = wglUseFontBitmapsA(hdc, first, count, listBase); + PostWGLHook(GLE_CURRENT_FUNCTION); + return b; + } + + #undef wglUseFontBitmapsW + extern "C" { GLAPI BOOL GLAPIENTRY wglUseFontBitmapsW(HDC hdc, DWORD first, DWORD count, DWORD listBase); } + BOOL OVR::GLEContext::wglUseFontBitmapsW_Hook(HDC hdc, DWORD first, DWORD count, DWORD listBase) + { + BOOL b = wglUseFontBitmapsW(hdc, first, count, listBase); + PostWGLHook(GLE_CURRENT_FUNCTION); + return b; + } + + #undef wglUseFontOutlinesA + extern "C" { GLAPI BOOL GLAPIENTRY wglUseFontOutlinesA(HDC hdc, DWORD first, DWORD count, DWORD listBase, FLOAT deviation, FLOAT extrusion, int format, LPGLYPHMETRICSFLOAT lpgmf); } + BOOL OVR::GLEContext::wglUseFontOutlinesA_Hook(HDC hdc, DWORD first, DWORD count, DWORD listBase, FLOAT deviation, FLOAT extrusion, int format, LPGLYPHMETRICSFLOAT lpgmf) + { + BOOL b = wglUseFontOutlinesA(hdc, first, count, listBase, deviation, extrusion, format, lpgmf); + PostWGLHook(GLE_CURRENT_FUNCTION); + return b; + } + + #undef wglUseFontOutlinesW + extern "C" { GLAPI BOOL GLAPIENTRY wglUseFontOutlinesW(HDC hdc, DWORD first, DWORD count, DWORD listBase, FLOAT deviation, FLOAT extrusion, int format, LPGLYPHMETRICSFLOAT lpgmf); } + BOOL OVR::GLEContext::wglUseFontOutlinesW_Hook(HDC hdc, DWORD first, DWORD count, DWORD listBase, FLOAT deviation, FLOAT extrusion, int format, LPGLYPHMETRICSFLOAT lpgmf) + { + BOOL b = wglUseFontOutlinesW(hdc, first, count, listBase, deviation, extrusion, format, lpgmf); + PostWGLHook(GLE_CURRENT_FUNCTION); + return b; + } + + #undef wglDescribeLayerPlane + extern "C" { GLAPI BOOL GLAPIENTRY wglDescribeLayerPlane(HDC hdc, int iPixelFormat, int iLayerPlane, UINT nBytes, LPLAYERPLANEDESCRIPTOR plpd); } + BOOL OVR::GLEContext::wglDescribeLayerPlane_Hook(HDC hdc, int iPixelFormat, int iLayerPlane, UINT nBytes, LPLAYERPLANEDESCRIPTOR plpd) + { + BOOL b = wglDescribeLayerPlane(hdc, iPixelFormat, iLayerPlane, nBytes, plpd); + PostWGLHook(GLE_CURRENT_FUNCTION); + return b; + } + + #undef wglSetLayerPaletteEntries + extern "C" { GLAPI int GLAPIENTRY wglSetLayerPaletteEntries(HDC hdc, int iLayerPlane, int iStart, int cEntries, const COLORREF *pcr); } + int OVR::GLEContext::wglSetLayerPaletteEntries_Hook(HDC hdc, int iLayerPlane, int iStart, int cEntries, const COLORREF *pcr) + { + int i = wglSetLayerPaletteEntries(hdc, iLayerPlane, iStart, cEntries, pcr); + PostWGLHook(GLE_CURRENT_FUNCTION); + return i; + } + + #undef wglGetLayerPaletteEntries + extern "C" { GLAPI int GLAPIENTRY wglGetLayerPaletteEntries(HDC hdc, int iLayerPlane, int iStart, int cEntries, COLORREF *pcr); } + int OVR::GLEContext::wglGetLayerPaletteEntries_Hook(HDC hdc, int iLayerPlane, int iStart, int cEntries, COLORREF *pcr) + { + int i = wglGetLayerPaletteEntries(hdc, iLayerPlane, iStart, cEntries, pcr); + PostWGLHook(GLE_CURRENT_FUNCTION); + return i; + } + + #undef wglRealizeLayerPalette + extern "C" { GLAPI BOOL GLAPIENTRY wglRealizeLayerPalette(HDC hdc, int iLayerPlane, BOOL bRealize); } + BOOL OVR::GLEContext::wglRealizeLayerPalette_Hook(HDC hdc, int iLayerPlane, BOOL bRealize) + { + BOOL b = wglRealizeLayerPalette(hdc, iLayerPlane, bRealize); + PostWGLHook(GLE_CURRENT_FUNCTION); + return b; + } + + #undef wglSwapLayerBuffers + extern "C" { GLAPI BOOL GLAPIENTRY wglSwapLayerBuffers(HDC hdc, UINT fuPlanes); } + BOOL OVR::GLEContext::wglSwapLayerBuffers_Hook(HDC hdc, UINT fuPlanes) + { + BOOL b = wglSwapLayerBuffers(hdc, fuPlanes); + PostWGLHook(GLE_CURRENT_FUNCTION); + return b; + } + + #undef wglSwapMultipleBuffers + extern "C" { GLAPI DWORD GLAPIENTRY wglSwapMultipleBuffers(UINT i, CONST WGLSWAP* p); } + DWORD OVR::GLEContext::wglSwapMultipleBuffers_Hook(UINT i, CONST WGLSWAP* p) + { + DWORD dw = wglSwapMultipleBuffers(i, p); + PostWGLHook(GLE_CURRENT_FUNCTION); + return dw; + } + */ + + // The rest of the functions are pointer-based. + + // WGL_ARB_buffer_region + HANDLE OVR::GLEContext::wglCreateBufferRegionARB_Hook(HDC hDC, int iLayerPlane, UINT uType) + { + HANDLE h = NULL; + if(wglCreateBufferRegionARB_Impl) + h = wglCreateBufferRegionARB_Impl(hDC, iLayerPlane, uType); + PostWGLHook(GLE_CURRENT_FUNCTION); + return h; + } + + VOID OVR::GLEContext::wglDeleteBufferRegionARB_Hook(HANDLE hRegion) + { + if(wglDeleteBufferRegionARB_Impl) + wglDeleteBufferRegionARB_Impl(hRegion); + PostWGLHook(GLE_CURRENT_FUNCTION); + } + + BOOL OVR::GLEContext::wglSaveBufferRegionARB_Hook(HANDLE hRegion, int x, int y, int width, int height) + { + BOOL b = FALSE; + if(wglSaveBufferRegionARB_Impl) + b = wglSaveBufferRegionARB_Impl(hRegion, x, y, width, height); + PostWGLHook(GLE_CURRENT_FUNCTION); + return b; + } + + BOOL OVR::GLEContext::wglRestoreBufferRegionARB_Hook(HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc) + { + BOOL b = FALSE; + if(wglRestoreBufferRegionARB_Impl) + b = wglRestoreBufferRegionARB_Impl(hRegion, x, y, width, height, xSrc, ySrc); + PostWGLHook(GLE_CURRENT_FUNCTION); + return b; + } + + // WGL_ARB_extensions_string + const char * OVR::GLEContext::wglGetExtensionsStringARB_Hook(HDC hdc) + { + const char * p = NULL; + if(wglGetExtensionsStringARB_Impl) + p = wglGetExtensionsStringARB_Impl(hdc); + PostWGLHook(GLE_CURRENT_FUNCTION); + return p; + } + + // WGL_ARB_pixel_format + BOOL OVR::GLEContext::wglGetPixelFormatAttribivARB_Hook(HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues) + { + BOOL b = FALSE; + if(wglGetPixelFormatAttribivARB_Impl) + b = wglGetPixelFormatAttribivARB_Impl(hdc, iPixelFormat, iLayerPlane, nAttributes, piAttributes, piValues); + PostWGLHook(GLE_CURRENT_FUNCTION); + return b; + } + + BOOL OVR::GLEContext::wglGetPixelFormatAttribfvARB_Hook(HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues) + { + BOOL b = FALSE; + if(wglGetPixelFormatAttribfvARB_Impl) + b = wglGetPixelFormatAttribfvARB_Impl(hdc, iPixelFormat, iLayerPlane, nAttributes, piAttributes, pfValues); + PostWGLHook(GLE_CURRENT_FUNCTION); + return b; + } + + BOOL OVR::GLEContext::wglChoosePixelFormatARB_Hook(HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats) + { + BOOL b = FALSE; + if(wglChoosePixelFormatARB_Impl) + b = wglChoosePixelFormatARB_Impl(hdc, piAttribIList, pfAttribFList, nMaxFormats, piFormats, nNumFormats); + PostWGLHook(GLE_CURRENT_FUNCTION); + return b; + } + + // WGL_ARB_make_current_read + BOOL OVR::GLEContext::wglMakeContextCurrentARB_Hook(HDC hDrawDC, HDC hReadDC, HGLRC hglrc) + { + BOOL b = FALSE; + if(wglMakeContextCurrentARB_Impl) + b = wglMakeContextCurrentARB_Impl(hDrawDC, hReadDC, hglrc); + PostWGLHook(GLE_CURRENT_FUNCTION); + return b; + } + + HDC OVR::GLEContext::wglGetCurrentReadDCARB_Hook() + { + HDC h = NULL; + if(wglGetCurrentReadDCARB_Impl) + h = wglGetCurrentReadDCARB_Impl(); + PostWGLHook(GLE_CURRENT_FUNCTION); + return h; + } + + // WGL_ARB_pbuffer + HPBUFFERARB OVR::GLEContext::wglCreatePbufferARB_Hook(HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList) + { + HPBUFFERARB h = NULL; + if(wglCreatePbufferARB_Impl) + h = wglCreatePbufferARB_Impl(hDC, iPixelFormat, iWidth, iHeight, piAttribList); + PostWGLHook(GLE_CURRENT_FUNCTION); + return h; + } + + HDC OVR::GLEContext::wglGetPbufferDCARB_Hook(HPBUFFERARB hPbuffer) + { + HDC h = NULL; + if(wglGetPbufferDCARB_Impl) + h = wglGetPbufferDCARB_Impl(hPbuffer); + PostWGLHook(GLE_CURRENT_FUNCTION); + return h; + } + + int OVR::GLEContext::wglReleasePbufferDCARB_Hook(HPBUFFERARB hPbuffer, HDC hDC) + { + int i = 0; + if(wglReleasePbufferDCARB_Impl) + i = wglReleasePbufferDCARB_Impl(hPbuffer, hDC); + PostWGLHook(GLE_CURRENT_FUNCTION); + return i; + } + + BOOL OVR::GLEContext::wglDestroyPbufferARB_Hook(HPBUFFERARB hPbuffer) + { + BOOL b = FALSE; + if(wglDestroyPbufferARB_Impl) + b = wglDestroyPbufferARB_Impl(hPbuffer); + PostWGLHook(GLE_CURRENT_FUNCTION); + return b; + } + + BOOL OVR::GLEContext::wglQueryPbufferARB_Hook(HPBUFFERARB hPbuffer, int iAttribute, int *piValue) + { + BOOL b = FALSE; + if(wglQueryPbufferARB_Impl) + b = wglQueryPbufferARB_Impl(hPbuffer, iAttribute, piValue); + PostWGLHook(GLE_CURRENT_FUNCTION); + return b; + } + + // WGL_ARB_render_texture + BOOL OVR::GLEContext::wglBindTexImageARB_Hook(HPBUFFERARB hPbuffer, int iBuffer) + { + BOOL b = FALSE; + if(wglBindTexImageARB_Impl) + b = wglBindTexImageARB_Impl(hPbuffer, iBuffer); + PostWGLHook(GLE_CURRENT_FUNCTION); + return b; + } + + BOOL OVR::GLEContext::wglReleaseTexImageARB_Hook(HPBUFFERARB hPbuffer, int iBuffer) + { + BOOL b = FALSE; + if(wglReleaseTexImageARB_Impl) + b = wglReleaseTexImageARB_Impl(hPbuffer, iBuffer); + PostWGLHook(GLE_CURRENT_FUNCTION); + return b; + } + + BOOL OVR::GLEContext::wglSetPbufferAttribARB_Hook(HPBUFFERARB hPbuffer, const int *piAttribList) + { + BOOL b = FALSE; + if(wglSetPbufferAttribARB_Impl) + b = wglSetPbufferAttribARB_Impl(hPbuffer, piAttribList); + PostWGLHook(GLE_CURRENT_FUNCTION); + return b; + } + + // WGL_NV_present_video + int OVR::GLEContext::wglEnumerateVideoDevicesNV_Hook(HDC hDC, HVIDEOOUTPUTDEVICENV *phDeviceList) + { + int i = 0; + if(wglEnumerateVideoDevicesNV_Impl) + i = wglEnumerateVideoDevicesNV_Impl(hDC, phDeviceList); + PostWGLHook(GLE_CURRENT_FUNCTION); + return i; + } + + BOOL OVR::GLEContext::wglBindVideoDeviceNV_Hook(HDC hDC, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int *piAttribList) + { + BOOL b = FALSE; + if(wglBindVideoDeviceNV_Impl) + b = wglBindVideoDeviceNV_Impl(hDC, uVideoSlot, hVideoDevice, piAttribList); + PostWGLHook(GLE_CURRENT_FUNCTION); + return b; + } + + BOOL OVR::GLEContext::wglQueryCurrentContextNV_Hook(int iAttribute, int *piValue) + { + BOOL b = FALSE; + if(wglQueryCurrentContextNV_Impl) + b = wglQueryCurrentContextNV_Impl(iAttribute, piValue); + PostWGLHook(GLE_CURRENT_FUNCTION); + return b; + } + + // WGL_ARB_create_context + HGLRC OVR::GLEContext::wglCreateContextAttribsARB_Hook(HDC hDC, HGLRC hShareContext, const int *attribList) + { + HGLRC h = NULL; + if(wglCreateContextAttribsARB_Impl) + h = wglCreateContextAttribsARB_Impl(hDC, hShareContext, attribList); + PostWGLHook(GLE_CURRENT_FUNCTION); + return h; + } + + // WGL_EXT_extensions_string + const char * OVR::GLEContext::wglGetExtensionsStringEXT_Hook() + { + const char * p = NULL; + if(wglGetExtensionsStringEXT_Impl) + p = wglGetExtensionsStringEXT_Impl(); + PostWGLHook(GLE_CURRENT_FUNCTION); + return p; + } + + // WGL_EXT_swap_control + BOOL OVR::GLEContext::wglSwapIntervalEXT_Hook(int interval) + { + BOOL b = FALSE; + if(wglSwapIntervalEXT_Impl) + b = wglSwapIntervalEXT_Impl(interval); + PostWGLHook(GLE_CURRENT_FUNCTION); + return b; + } + + int OVR::GLEContext::wglGetSwapIntervalEXT_Hook() + { + int i = 0; + if(wglGetSwapIntervalEXT_Impl) + i = wglGetSwapIntervalEXT_Impl(); + PostWGLHook(GLE_CURRENT_FUNCTION); + return i; + } + + // WGL_OML_sync_control + BOOL OVR::GLEContext::wglGetSyncValuesOML_Hook(HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc) + { + BOOL b = FALSE; + if(wglGetSyncValuesOML_Impl) + b = wglGetSyncValuesOML_Impl(hdc, ust, msc, sbc); + PostWGLHook(GLE_CURRENT_FUNCTION); + return b; + } + + BOOL OVR::GLEContext::wglGetMscRateOML_Hook(HDC hdc, INT32 *numerator, INT32 *denominator) + { + BOOL b = FALSE; + if(wglGetMscRateOML_Impl) + b = wglGetMscRateOML_Impl(hdc, numerator, denominator); + PostWGLHook(GLE_CURRENT_FUNCTION); + return b; + } + + INT64 OVR::GLEContext::wglSwapBuffersMscOML_Hook(HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder) + { + INT64 i = 0; + if(wglSwapBuffersMscOML_Impl) + i = wglSwapBuffersMscOML_Impl(hdc, target_msc, divisor, remainder); + PostWGLHook(GLE_CURRENT_FUNCTION); + return i; + } + + INT64 OVR::GLEContext::wglSwapLayerBuffersMscOML_Hook(HDC hdc, int fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder) + { + INT64 i = 0; + if(wglSwapLayerBuffersMscOML_Impl) + i = wglSwapLayerBuffersMscOML_Impl(hdc, fuPlanes, target_msc, divisor, remainder); + PostWGLHook(GLE_CURRENT_FUNCTION); + return i; + } + + BOOL OVR::GLEContext::wglWaitForMscOML_Hook(HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc) + { + BOOL b = FALSE; + if(wglWaitForMscOML_Impl) + b = wglWaitForMscOML_Impl(hdc, target_msc, divisor, remainder, ust, msc, sbc); + PostWGLHook(GLE_CURRENT_FUNCTION); + return b; + } + + BOOL OVR::GLEContext::wglWaitForSbcOML_Hook(HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc) + { + BOOL b = FALSE; + if(wglWaitForSbcOML_Impl) + b = wglWaitForSbcOML_Impl(hdc, target_sbc, ust, msc, sbc); + PostWGLHook(GLE_CURRENT_FUNCTION); + return b; + } + + // WGL_NV_video_output + BOOL OVR::GLEContext::wglGetVideoDeviceNV_Hook(HDC hDC, int numDevices, HPVIDEODEV *hVideoDevice) + { + BOOL b = FALSE; + if(wglGetVideoDeviceNV_Impl) + b = wglGetVideoDeviceNV_Impl(hDC, numDevices, hVideoDevice); + PostWGLHook(GLE_CURRENT_FUNCTION); + return b; + } + + BOOL OVR::GLEContext::wglReleaseVideoDeviceNV_Hook(HPVIDEODEV hVideoDevice) + { + BOOL b = FALSE; + if(wglReleaseVideoDeviceNV_Impl) + b = wglReleaseVideoDeviceNV_Impl(hVideoDevice); + PostWGLHook(GLE_CURRENT_FUNCTION); + return b; + } + + BOOL OVR::GLEContext::wglBindVideoImageNV_Hook(HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer) + { + BOOL b = FALSE; + if(wglBindVideoImageNV_Impl) + b = wglBindVideoImageNV_Impl(hVideoDevice, hPbuffer, iVideoBuffer); + PostWGLHook(GLE_CURRENT_FUNCTION); + return b; + } + + BOOL OVR::GLEContext::wglReleaseVideoImageNV_Hook(HPBUFFERARB hPbuffer, int iVideoBuffer) + { + BOOL b = FALSE; + if(wglReleaseVideoImageNV_Impl) + b = wglReleaseVideoImageNV_Impl(hPbuffer, iVideoBuffer); + PostWGLHook(GLE_CURRENT_FUNCTION); + return b; + } + + BOOL OVR::GLEContext::wglSendPbufferToVideoNV_Hook(HPBUFFERARB hPbuffer, int iBufferType, unsigned long *pulCounterPbuffer, BOOL bBlock) + { + BOOL b = FALSE; + if(wglSendPbufferToVideoNV_Impl) + b = wglSendPbufferToVideoNV_Impl(hPbuffer, iBufferType, pulCounterPbuffer, bBlock); + PostWGLHook(GLE_CURRENT_FUNCTION); + return b; + } + + BOOL OVR::GLEContext::wglGetVideoInfoNV_Hook(HPVIDEODEV hpVideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo) + { + BOOL b = FALSE; + if(wglGetVideoInfoNV_Impl) + b = wglGetVideoInfoNV_Impl(hpVideoDevice, pulCounterOutputPbuffer, pulCounterOutputVideo); + PostWGLHook(GLE_CURRENT_FUNCTION); + return b; + } + + // WGL_NV_swap_group + BOOL OVR::GLEContext::wglJoinSwapGroupNV_Hook(HDC hDC, GLuint group) + { + BOOL b = FALSE; + if(wglJoinSwapGroupNV_Impl) + b = wglJoinSwapGroupNV_Impl(hDC, group); + PostWGLHook(GLE_CURRENT_FUNCTION); + return b; + } + + BOOL OVR::GLEContext::wglBindSwapBarrierNV_Hook(GLuint group, GLuint barrier) + { + BOOL b = FALSE; + if(wglBindSwapBarrierNV_Impl) + b = wglBindSwapBarrierNV_Impl(group, barrier); + PostWGLHook(GLE_CURRENT_FUNCTION); + return b; + } + + BOOL OVR::GLEContext::wglQuerySwapGroupNV_Hook(HDC hDC, GLuint *group, GLuint *barrier) + { + BOOL b = FALSE; + if(wglQuerySwapGroupNV_Impl) + b = wglQuerySwapGroupNV_Impl(hDC, group, barrier); + PostWGLHook(GLE_CURRENT_FUNCTION); + return b; + } + + BOOL OVR::GLEContext::wglQueryMaxSwapGroupsNV_Hook(HDC hDC, GLuint *maxGroups, GLuint *maxBarriers) + { + BOOL b = FALSE; + if(wglQueryMaxSwapGroupsNV_Impl) + b = wglQueryMaxSwapGroupsNV_Impl(hDC, maxGroups, maxBarriers); + PostWGLHook(GLE_CURRENT_FUNCTION); + return b; + } + + BOOL OVR::GLEContext::wglQueryFrameCountNV_Hook(HDC hDC, GLuint *count) + { + BOOL b = FALSE; + if(wglQueryFrameCountNV_Impl) + b = wglQueryFrameCountNV_Impl(hDC, count); + PostWGLHook(GLE_CURRENT_FUNCTION); + return b; + } + + BOOL OVR::GLEContext::wglResetFrameCountNV_Hook(HDC hDC) + { + BOOL b = FALSE; + if(wglResetFrameCountNV_Impl) + b = wglResetFrameCountNV_Impl(hDC); + PostHook(GLE_CURRENT_FUNCTION); + return b; + } + + // WGL_NV_video_capture + BOOL OVR::GLEContext::wglBindVideoCaptureDeviceNV_Hook(UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice) + { + BOOL b = FALSE; + if(wglBindVideoCaptureDeviceNV_Impl) + b = wglBindVideoCaptureDeviceNV_Impl(uVideoSlot, hDevice); + PostWGLHook(GLE_CURRENT_FUNCTION); + return b; + } + + UINT OVR::GLEContext::wglEnumerateVideoCaptureDevicesNV_Hook(HDC hDc, HVIDEOINPUTDEVICENV *phDeviceList) + { + UINT u = 0; + if(wglEnumerateVideoCaptureDevicesNV_Impl) + u = wglEnumerateVideoCaptureDevicesNV_Impl(hDc, phDeviceList); + PostWGLHook(GLE_CURRENT_FUNCTION); + return u; + } + + BOOL OVR::GLEContext::wglLockVideoCaptureDeviceNV_Hook(HDC hDc, HVIDEOINPUTDEVICENV hDevice) + { + BOOL b = FALSE; + if(wglLockVideoCaptureDeviceNV_Impl) + b = wglLockVideoCaptureDeviceNV_Impl(hDc, hDevice); + PostWGLHook(GLE_CURRENT_FUNCTION); + return b; + } + + BOOL OVR::GLEContext::wglQueryVideoCaptureDeviceNV_Hook(HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int *piValue) + { + BOOL b = FALSE; + if(wglQueryVideoCaptureDeviceNV_Impl) + b = wglQueryVideoCaptureDeviceNV_Impl(hDc, hDevice, iAttribute, piValue); + PostWGLHook(GLE_CURRENT_FUNCTION); + return b; + } + + BOOL OVR::GLEContext::wglReleaseVideoCaptureDeviceNV_Hook(HDC hDc, HVIDEOINPUTDEVICENV hDevice) + { + BOOL b = FALSE; + if(wglReleaseVideoCaptureDeviceNV_Impl) + b = wglReleaseVideoCaptureDeviceNV_Impl(hDc, hDevice); + PostWGLHook(GLE_CURRENT_FUNCTION); + return b; + } + + // WGL_NV_copy_image + BOOL OVR::GLEContext::wglCopyImageSubDataNV_Hook(HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, + GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth) + { + BOOL b = FALSE; + if(wglCopyImageSubDataNV_Impl) + b = wglCopyImageSubDataNV_Impl(hSrcRC, srcName, srcTarget, srcLevel, srcX, srcY, srcZ, hDstRC, dstName, dstTarget, dstLevel, dstX, dstY, dstZ, width, height, depth); + PostWGLHook(GLE_CURRENT_FUNCTION); + return b; + } + + // WGL_NV_DX_interop + BOOL OVR::GLEContext::wglDXSetResourceShareHandleNV_Hook(void *dxObject, HANDLE shareHandle) + { + BOOL b = FALSE; + if(wglDXSetResourceShareHandleNV_Impl) + b = wglDXSetResourceShareHandleNV_Impl(dxObject, shareHandle); + PostWGLHook(GLE_CURRENT_FUNCTION); + return b; + } + + HANDLE OVR::GLEContext::wglDXOpenDeviceNV_Hook(void *dxDevice) + { + HANDLE h = NULL; + if(wglDXOpenDeviceNV_Impl) + h = wglDXOpenDeviceNV_Impl(dxDevice); + PostWGLHook(GLE_CURRENT_FUNCTION); + return h; + } + + BOOL OVR::GLEContext::wglDXCloseDeviceNV_Hook(HANDLE hDevice) + { + BOOL b = FALSE; + if(wglDXCloseDeviceNV_Impl) + b = wglDXCloseDeviceNV_Impl(hDevice); + PostWGLHook(GLE_CURRENT_FUNCTION); + return b; + } + + HANDLE OVR::GLEContext::wglDXRegisterObjectNV_Hook(HANDLE hDevice, void *dxObject, GLuint name, GLenum type, GLenum access) + { + HANDLE h = NULL; + if(wglDXRegisterObjectNV_Impl) + h = wglDXRegisterObjectNV_Impl(hDevice, dxObject, name, type, access); + PostWGLHook(GLE_CURRENT_FUNCTION); + return h; + } + + BOOL OVR::GLEContext::wglDXUnregisterObjectNV_Hook(HANDLE hDevice, HANDLE hObject) + { + BOOL b = FALSE; + if(wglDXUnregisterObjectNV_Impl) + b = wglDXUnregisterObjectNV_Impl(hDevice, hObject); + PostWGLHook(GLE_CURRENT_FUNCTION); + return b; + } + + BOOL OVR::GLEContext::wglDXObjectAccessNV_Hook(HANDLE hObject, GLenum access) + { + BOOL b = FALSE; + if(wglDXObjectAccessNV_Impl) + b = wglDXObjectAccessNV_Impl(hObject, access); + PostWGLHook(GLE_CURRENT_FUNCTION); + return b; + } + + BOOL OVR::GLEContext::wglDXLockObjectsNV_Hook(HANDLE hDevice, GLint count, HANDLE *hObjects) + { + BOOL b = FALSE; + if(wglDXLockObjectsNV_Impl) + b = wglDXLockObjectsNV_Impl(hDevice, count, hObjects); + PostWGLHook(GLE_CURRENT_FUNCTION); + return b; + } + + BOOL OVR::GLEContext::wglDXUnlockObjectsNV_Hook(HANDLE hDevice, GLint count, HANDLE *hObjects) + { + BOOL b = FALSE; + if(wglDXUnlockObjectsNV_Impl) + b = wglDXUnlockObjectsNV_Impl(hDevice, count, hObjects); + PostWGLHook(GLE_CURRENT_FUNCTION); + return b; + } + + #endif // defined(GLE_WGL_ENABLED) + + #if defined(GLE_GLX_ENABLED) + void OVR::GLEContext::PostGLXHook(const char* /*function*/) + { + // Empty for now. GLX functions don't have a function like glGetError(). + } + + // GLX_VERSION_1_0 + // GLX_VERSION_1_1 + // We don't currently implement hooking of these. + + // GLX_VERSION_1_2 + ::Display* OVR::GLEContext::glXGetCurrentDisplay_Hook(void) + { + ::Display* p = NULL; + if(glXGetCurrentDisplay_Impl) + p = glXGetCurrentDisplay_Impl(); + PostGLXHook(GLE_CURRENT_FUNCTION); + return p; + } + + // GLX_VERSION_1_3 + GLXFBConfig* OVR::GLEContext::glXChooseFBConfig_Hook(Display *dpy, int screen, const int *attrib_list, int *nelements) + { + GLXFBConfig* p = NULL; + if(glXChooseFBConfig_Impl) + p = glXChooseFBConfig_Impl(dpy, screen, attrib_list, nelements); + PostGLXHook(GLE_CURRENT_FUNCTION); + return p; + } + + GLXContext OVR::GLEContext::glXCreateNewContext_Hook(Display *dpy, GLXFBConfig config, int render_type, GLXContext share_list, Bool direct) + { + GLXContext c = 0; + if(glXCreateNewContext_Impl) + c = glXCreateNewContext_Impl(dpy, config, render_type, share_list, direct); + PostGLXHook(GLE_CURRENT_FUNCTION); + return c; + } + + GLXPbuffer OVR::GLEContext::glXCreatePbuffer_Hook(Display *dpy, GLXFBConfig config, const int *attrib_list) + { + GLXPbuffer b = 0; + if(glXCreatePbuffer_Impl) + b = glXCreatePbuffer_Impl(dpy, config, attrib_list); + PostGLXHook(GLE_CURRENT_FUNCTION); + return b; + } + + GLXPixmap OVR::GLEContext::glXCreatePixmap_Hook(Display *dpy, GLXFBConfig config, Pixmap pixmap, const int *attrib_list) + { + GLXPixmap m = 0; + if(glXCreatePixmap_Impl) + m = glXCreatePixmap_Impl(dpy, config, pixmap, attrib_list); + PostGLXHook(GLE_CURRENT_FUNCTION); + return m; + } + + GLXWindow OVR::GLEContext::glXCreateWindow_Hook(Display *dpy, GLXFBConfig config, Window win, const int *attrib_list) + { + GLXWindow w = 0; + if(glXCreateWindow_Impl) + w = glXCreateWindow_Impl(dpy, config, win, attrib_list); + PostGLXHook(GLE_CURRENT_FUNCTION); + return w; + } + + void OVR::GLEContext::glXDestroyPbuffer_Hook(Display *dpy, GLXPbuffer pbuf) + { + if(glXDestroyPbuffer_Impl) + glXDestroyPbuffer_Impl(dpy, pbuf); + PostGLXHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glXDestroyPixmap_Hook(Display *dpy, GLXPixmap pixmap) + { + if(glXDestroyPixmap_Impl) + glXDestroyPixmap_Impl(dpy, pixmap); + PostGLXHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glXDestroyWindow_Hook(Display *dpy, GLXWindow win) + { + if(glXDestroyWindow_Impl) + glXDestroyWindow_Impl(dpy, win); + PostGLXHook(GLE_CURRENT_FUNCTION); + } + + GLXDrawable OVR::GLEContext::glXGetCurrentReadDrawable_Hook(void) + { + GLXDrawable d; + if(glXGetCurrentReadDrawable_Impl) + d = glXGetCurrentReadDrawable_Impl(); + PostGLXHook(GLE_CURRENT_FUNCTION); + return d; + } + + int OVR::GLEContext::glXGetFBConfigAttrib_Hook(Display *dpy, GLXFBConfig config, int attribute, int *value) + { + int i = -1; + if(glXGetFBConfigAttrib_Impl) + i = glXGetFBConfigAttrib_Impl(dpy, config, attribute, value); + PostGLXHook(GLE_CURRENT_FUNCTION); + return i; + } + + GLXFBConfig* OVR::GLEContext::glXGetFBConfigs_Hook(Display *dpy, int screen, int *nelements) + { + GLXFBConfig* p = NULL; + if(glXGetFBConfigs_Impl) + p = glXGetFBConfigs_Impl(dpy, screen, nelements); + PostGLXHook(GLE_CURRENT_FUNCTION); + return p; + } + + void OVR::GLEContext::glXGetSelectedEvent_Hook(Display *dpy, GLXDrawable draw, unsigned long *event_mask) + { + if(glXGetSelectedEvent_Impl) + glXGetSelectedEvent_Impl(dpy, draw, event_mask); + PostGLXHook(GLE_CURRENT_FUNCTION); + } + + XVisualInfo* OVR::GLEContext::glXGetVisualFromFBConfig_Hook(Display *dpy, GLXFBConfig config) + { + XVisualInfo* p = NULL; + if(glXGetVisualFromFBConfig_Impl) + p = glXGetVisualFromFBConfig_Impl(dpy, config); + PostGLXHook(GLE_CURRENT_FUNCTION); + return p; + } + + Bool OVR::GLEContext::glXMakeContextCurrent_Hook(Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx) + { + Bool b = False; + if(glXMakeContextCurrent_Impl) + b = glXMakeContextCurrent_Impl(dpy, draw, read, ctx); + PostGLXHook(GLE_CURRENT_FUNCTION); + return b; + } + + int OVR::GLEContext::glXQueryContext_Hook(Display *dpy, GLXContext ctx, int attribute, int *value) + { + int i = GLX_BAD_ATTRIBUTE; + if(glXQueryContext_Impl) + i = glXQueryContext_Impl(dpy, ctx, attribute, value); + PostGLXHook(GLE_CURRENT_FUNCTION); + return i; + } + + void OVR::GLEContext::glXQueryDrawable_Hook(Display *dpy, GLXDrawable draw, int attribute, unsigned int *value) + { + if(glXQueryDrawable_Impl) + glXQueryDrawable_Impl(dpy, draw, attribute, value); + PostGLXHook(GLE_CURRENT_FUNCTION); + } + + void OVR::GLEContext::glXSelectEvent_Hook(Display *dpy, GLXDrawable draw, unsigned long event_mask) + { + if(glXSelectEvent_Impl) + glXSelectEvent_Impl(dpy, draw, event_mask); + PostGLXHook(GLE_CURRENT_FUNCTION); + } + + // GLX_VERSION_1_4 + // We don't do hooking of this. + + // GLX_ARB_create_context + GLXContext OVR::GLEContext::glXCreateContextAttribsARB_Hook(Display* dpy, GLXFBConfig config, GLXContext share_context, Bool direct, const int *attrib_list) + { + GLXContext c = 0; + if(glXCreateContextAttribsARB_Impl) + c = glXCreateContextAttribsARB_Impl(dpy, config, share_context, direct, attrib_list); + PostGLXHook(GLE_CURRENT_FUNCTION); + return c; + } + + // GLX_EXT_swap_control + void OVR::GLEContext::glXSwapIntervalEXT_Hook(Display* dpy, GLXDrawable drawable, int interval) + { + if(glXSwapIntervalEXT_Impl) + glXSwapIntervalEXT_Impl(dpy, drawable, interval); + PostGLXHook(GLE_CURRENT_FUNCTION); + } + + // GLX_OML_sync_control + Bool OVR::GLEContext::glXGetMscRateOML_Hook(Display* dpy, GLXDrawable drawable, int32_t* numerator, int32_t* denominator) + { + Bool b = False; + if(glXGetMscRateOML_Impl) + b = glXGetMscRateOML_Impl(dpy, drawable, numerator, denominator); + PostGLXHook(GLE_CURRENT_FUNCTION); + return b; + } + + Bool OVR::GLEContext::glXGetSyncValuesOML_Hook(Display* dpy, GLXDrawable drawable, int64_t* ust, int64_t* msc, int64_t* sbc) + { + Bool b = False; + if(glXGetSyncValuesOML_Impl) + b = glXGetSyncValuesOML_Impl(dpy, drawable, ust, msc, sbc); + PostGLXHook(GLE_CURRENT_FUNCTION); + return b; + } + + int64_t OVR::GLEContext::glXSwapBuffersMscOML_Hook(Display* dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder) + { + int64_t i = 0; + if(glXSwapBuffersMscOML_Impl) + i = glXSwapBuffersMscOML_Impl(dpy, drawable, target_msc, divisor, remainder); + PostGLXHook(GLE_CURRENT_FUNCTION); + return i; + } + + Bool OVR::GLEContext::glXWaitForMscOML_Hook(Display* dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder, int64_t* ust, int64_t* msc, int64_t* sbc) + { + Bool b = False; + if(glXWaitForMscOML_Impl) + b = glXWaitForMscOML_Impl(dpy, drawable, target_msc, divisor, remainder, ust, msc, sbc); + PostGLXHook(GLE_CURRENT_FUNCTION); + return b; + } + + Bool OVR::GLEContext::glXWaitForSbcOML_Hook(Display* dpy, GLXDrawable drawable, int64_t target_sbc, int64_t* ust, int64_t* msc, int64_t* sbc) + { + Bool b = False; + if(glXWaitForSbcOML_Impl) + b = glXWaitForSbcOML_Impl(dpy, drawable, target_sbc, ust, msc, sbc); + PostGLXHook(GLE_CURRENT_FUNCTION); + return b; + } + + // GLX_MESA_swap_control + int OVR::GLEContext::glXGetSwapIntervalMESA_Hook() + { + int i = 0; + if(glXGetSwapIntervalMESA_Impl) + i = glXGetSwapIntervalMESA_Impl(); + PostGLXHook(GLE_CURRENT_FUNCTION); + return i; + } + + + int OVR::GLEContext::glXSwapIntervalMESA_Hook(unsigned int interval) + { + int i = 0; + if(glXSwapIntervalMESA_Impl) + i = glXSwapIntervalMESA_Impl(interval); + PostGLXHook(GLE_CURRENT_FUNCTION); + return i; + } + + #endif // defined(GLE_GLX_ENABLED) + + #endif // GLE_HOOKING_ENABLED + +//} // namespace OVR + + + diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/CAPI/GL/CAPI_GLE.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/CAPI/GL/CAPI_GLE.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,2003 @@ +/************************************************************************************ + +Filename : CAPI_GLE.h +Content : OpenGL extensions support. Implements a stripped down glew-like + interface with some additional functionality. +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +// This file provides functionality similar to a reduced version of GLEW, plus some +// additional functionality that's useful to us, such as function hooking. + +#ifndef INC_OVR_CAPI_GLE_h +#define INC_OVR_CAPI_GLE_h + + +#include "../../Kernel/OVR_Types.h" +#include "CAPI_GLE_GL.h" + + +/////////////////////////////////////////////////////////////////////////////// +// How to use this functionality +// +// - You #include this header instead of gl.h, glext.h, wglext.h (Windows), gl3.h (Apple), gl3ext.h (Apple), glx.h (Unix), and glxext.h (Unix). +// Currently you still would #include for the base wgl functions on Windows and OpenGL.h or NSOpenGL for the +// base Apple cgl functions. +// +// - You call OpenGL functions just like you would if you were directly using OpenGL +// headers and declarations. The difference is that this module automatically loads +// extensions on init and so you should never need to use GetProcAddress, wglGetProcAddress, etc. +// +// - OpenGL 1.1 functions can be called unilaterally without checking if they are present, +// as it's assumed they are always present. +// +// - In order to use an OpenGL 1.2 or later function you can check the GLEContext::WholeVersion +// variable to tell what version of OpenGL is present and active. Example usage: +// if(GLEContext::GetCurrentContext()->WholeVersion >= 302) // If OpenGL 3.2 or later... +// +// - In order to use an OpenGL extension, you can check the GLE_ helper macro that exists for each +// extension. For example, in order to check of the KHR_debug is present you could do this: +// if(GLE_KHR_debug) ... +// You cannot check for the presence of extensions by testing the function pointer, because +// when hooking is enabled then we aren't using function pointers and thus all functions will +// look like they are present. +// +// - You can test if the OpenGL implementation is OpenGL ES by checking the GLEContext IsGLES +// member variable. For example: if(GLEContext::GetCurrentContext()->IsGLES) ... +// +// - You can test if the OpenGL implementation is a core profile ES by checking the GLEContext IsCoreProfile +// member variable. For example: if(GLEContext::GetCurrentContext()->IsCoreProfile) ... +// +/////////////////////////////////////////////////////////////////////////////// + + +/////////////////////////////////////////////////////////////////////////////// +// How to add support for additional functions to this module. +// +// For an example of how to do this, search the source files for all cases of KHR_Debug and just copy +// the things that it does but for your new extension. +// +// 1) Add the appropriate extension declaration to CAPI_GLE_GL.h, preferably by +// copying it from the standard header file it normally comes from. If it's +// platform-specific (e.g. a Windows wgl function) then make sure it's declared +// within the given platform section. Note that there are potentially #defines, typedefs, +// function typedefs, and function #defines. There is always a GLE_ macro declared which +// lets the user know at runtime whether the extension is present. +// e.g. #ifndef GL_KHR_debug +// #define GL_KHR_debug 1 +// #define GL_CONTEXT_FLAG_DEBUG_BIT 0x00000002 etc. +// typedef void (GLAPIENTRY * PFNGLPOPDEBUGGROUPPROC) (); +// #define glPopDebugGroup GLEGetCurrentFunction(glPopDebugGroup) +// #define GLE_KHR_debug GLEGetCurrentVariable(gl_KHR_debug) +// #endif etc. +// +// 2) Add a hook function for in the hook section of the GLEContext class in this header, +// ideally in the same order it's declared in the CAPI_GLE_GL.h so it's easily readable. +// e.g. void glDebugMessageControl_Hook(GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint* ids, GLboolean enabled); etc. +// +// 3) Add a declaration for each interface function to the GLEContext class in this header. +// e.g. PFNGLDEBUGMESSAGECALLBACKPROC glDebugMessageCallback_Impl; etc. +// +// 4) Add code to GLEContext::InitExtensionLoad to load the function pointer. +// e.g. GLELoadProc(glDebugMessageCallback_Impl, glDebugMessageCallback); etc. +// +// 5) Add code to GLEContext::InitExtensionSupport to detect the extension support. +// e.g. { gl_KHR_debug, "GL_KHR_debug" }, etc. +// +// 6) Implement the GLEContext hook function(s) you declared. +// e.g. void OVR::GLEContext::glDebugMessageControl_Hook(GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint* ids, GLboolean enabled) +// { +// if(glDebugMessageControl_Impl) +// glDebugMessageControl_Impl(source, type, severity, count, ids, enabled); +// PostHook(); +// } +// +// Note that if the extension is a WGL-, GLX-, or CGL-specific extension, they are handled like above +// but are in their own section below the section for regular OpenGL extensions. +// +// In some cases the given interface may already be present by currently commented out, +// in which case you can simply un-comment it to enable it. +/////////////////////////////////////////////////////////////////////////////// + + +namespace OVR +{ + // Generic OpenGL GetProcAddress function interface. Maps to platform-specific functionality + // internally. On Windows this is equivalent to wglGetProcAddress as opposed to global GetProcAddress. + void* GLEGetProcAddress(const char* name); + + + // GLEContext + // + // Manages a collection of OpenGL extension interfaces. + // If the application has multiple OpenGL unrelated contexts then you will want to create a + // different instance of this class for each one you intend to use it with. + // + // Example usage: + // GLEContext gGLEContext; + // + // GLEContext::SetCurrentContext(&gGLEContext); + // gGLEContext.PlatformInit(); // Initializes WGL/GLX/etc. platform-specific OpenGL functionality + // + // if(GLE_WGL_ARB_create_context) // If wglCreateContextAttribsARB is available... + // { + // int attribList[] = { WGL_CONTEXT_MAJOR_VERSION_ARB, 3, WGL_CONTEXT_MINOR_VERSION_ARB, 2, WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_DEBUG_BIT_ARB, None }; + // HGLRC h = wglCreateContextAttribsARB(hDC, 0, attribList); + // [...] + // } + // + // gGLEContext.Init(); // Must be called after an OpenGL context has been created. + // + // if(GLE_WHOLE_VERSION() >= 302) // If OpenGL 3.2 or later + // { + // glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, someTexture, 0); // This is an OpenGL 3.2 function. + // [...] + // } + // + // if(GLE_GL_ARB_texture_multisample) // If the GL_ARB_texture_multisample extension is available... + // { + // glEnable(GL_SAMPLE_MASK); + // glSampleMaski(0, 0x1); + // [...] + // } + // + // [...] + // + // gGLEContext.Shutdown(); + // + GLE_CLASS_EXPORT class GLEContext + { + public: + GLEContext(); + ~GLEContext(); + + // Initializes platform-specific functionality (e.g. Windows WGL, Unix GLX, Android EGL, Apple CGL). + // You would typically call this before creating an OpenGL context and using platform-specific functions. + void PlatformInit(); + bool IsPlatformInitialized() const; + + // Loads all the extensions from the current OpenGL context. This must be called after an OpenGL context + // has been created and made current. + void Init(); + bool IsInitialized() const; + + // Clears all the extensions initialized by PlatformInit and Init. + void Shutdown(); + + void SetEnableHookGetError(bool enabled) + { EnableHookGetError = enabled; } + + // Returns the default instance of this class. + static GLEContext* GetCurrentContext(); + + // Sets the default instance of this class. This should be called after enabling a new OpenGL context. + // This sets the current GLEContext; it does not set the underlying OpenGL context itself. + static void SetCurrentContext(GLEContext*); + + public: + // OpenGL version information + int MajorVersion; // Best guess at major version + int MinorVersion; // Best guess at minor version + int WholeVersion; // Equals ((MajorVersion * 100) + MinorVersion). Example usage: if(glv.WholeVersion >= 302) // If OpenGL v3.02+ ... + bool IsGLES; // Open GL ES? + bool IsCoreProfile; // Is the current OpenGL context a core profile context? Its trueness may be a false positive but will never be a false negative. + bool EnableHookGetError; // If enabled then hook functions call glGetError after making the call. + + int PlatformMajorVersion; // GLX/WGL/EGL/CGL version. Not the same as OpenGL version. + int PlatformMinorVersion; + int PlatformWholeVersion; + + void InitVersion(); // Initializes the version information (e.g. MajorVersion). Called by the public Init function. + void InitExtensionLoad(); // Loads the function addresses into the function pointers. + void InitExtensionSupport(); // Loads the boolean extension support booleans. + + void InitPlatformVersion(); + void InitPlatformExtensionLoad(); + void InitPlatformExtensionSupport(); + + public: + // GL_VERSION_1_1 + // Not normally included because all OpenGL 1.1 functionality is always present. But if we have + // hooking enabled then we implement our own version of each function. + #if defined(GLE_HOOKING_ENABLED) + //void PreHook(const char* functionName); // Called at the beginning of a hook function. + void PostHook(const char* functionName); // Called at the end of a hook function. + + void glAccum_Hook(GLenum op, GLfloat value); + void glAlphaFunc_Hook(GLenum func, GLclampf ref); + GLboolean glAreTexturesResident_Hook(GLsizei n, const GLuint *textures, GLboolean *residences); + void glArrayElement_Hook(GLint i); + void glBegin_Hook(GLenum mode); + void glBindTexture_Hook(GLenum target, GLuint texture); + void glBitmap_Hook(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap); + void glBlendFunc_Hook(GLenum sfactor, GLenum dfactor); + void glCallList_Hook(GLuint list); + void glCallLists_Hook(GLsizei n, GLenum type, const void *lists); + void glClear_Hook(GLbitfield mask); + void glClearAccum_Hook(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); + void glClearColor_Hook(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); + void glClearDepth_Hook(GLclampd depth); + void glClearIndex_Hook(GLfloat c); + void glClearStencil_Hook(GLint s); + void glClipPlane_Hook(GLenum plane, const GLdouble *equation); + void glColor3b_Hook(GLbyte red, GLbyte green, GLbyte blue); + void glColor3bv_Hook(const GLbyte *v); + void glColor3d_Hook(GLdouble red, GLdouble green, GLdouble blue); + void glColor3dv_Hook(const GLdouble *v); + void glColor3f_Hook(GLfloat red, GLfloat green, GLfloat blue); + void glColor3fv_Hook(const GLfloat *v); + void glColor3i_Hook(GLint red, GLint green, GLint blue); + void glColor3iv_Hook(const GLint *v); + void glColor3s_Hook(GLshort red, GLshort green, GLshort blue); + void glColor3sv_Hook(const GLshort *v); + void glColor3ub_Hook(GLubyte red, GLubyte green, GLubyte blue); + void glColor3ubv_Hook(const GLubyte *v); + void glColor3ui_Hook(GLuint red, GLuint green, GLuint blue); + void glColor3uiv_Hook(const GLuint *v); + void glColor3us_Hook(GLushort red, GLushort green, GLushort blue); + void glColor3usv_Hook(const GLushort *v); + void glColor4b_Hook(GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha); + void glColor4bv_Hook(const GLbyte *v); + void glColor4d_Hook(GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha); + void glColor4dv_Hook(const GLdouble *v); + void glColor4f_Hook(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); + void glColor4fv_Hook(const GLfloat *v); + void glColor4i_Hook(GLint red, GLint green, GLint blue, GLint alpha); + void glColor4iv_Hook(const GLint *v); + void glColor4s_Hook(GLshort red, GLshort green, GLshort blue, GLshort alpha); + void glColor4sv_Hook(const GLshort *v); + void glColor4ub_Hook(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha); + void glColor4ubv_Hook(const GLubyte *v); + void glColor4ui_Hook(GLuint red, GLuint green, GLuint blue, GLuint alpha); + void glColor4uiv_Hook(const GLuint *v); + void glColor4us_Hook(GLushort red, GLushort green, GLushort blue, GLushort alpha); + void glColor4usv_Hook(const GLushort *v); + void glColorMask_Hook(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); + void glColorMaterial_Hook(GLenum face, GLenum mode); + void glColorPointer_Hook(GLint size, GLenum type, GLsizei stride, const void *pointer); + void glCopyPixels_Hook(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type); + void glCopyTexImage1D_Hook(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLint border); + void glCopyTexImage2D_Hook(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); + void glCopyTexSubImage1D_Hook(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); + void glCopyTexSubImage2D_Hook(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); + void glCullFace_Hook(GLenum mode); + void glDeleteLists_Hook(GLuint list, GLsizei range); + void glDeleteTextures_Hook(GLsizei n, const GLuint *textures); + void glDepthFunc_Hook(GLenum func); + void glDepthMask_Hook(GLboolean flag); + void glDepthRange_Hook(GLclampd zNear, GLclampd zFar); + void glDisable_Hook(GLenum cap); + void glDisableClientState_Hook(GLenum array); + void glDrawArrays_Hook(GLenum mode, GLint first, GLsizei count); + void glDrawBuffer_Hook(GLenum mode); + void glDrawElements_Hook(GLenum mode, GLsizei count, GLenum type, const void *indices); + void glDrawPixels_Hook(GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); + void glEdgeFlag_Hook(GLboolean flag); + void glEdgeFlagPointer_Hook(GLsizei stride, const void *pointer); + void glEdgeFlagv_Hook(const GLboolean *flag); + void glEnable_Hook(GLenum cap); + void glEnableClientState_Hook(GLenum array); + void glEnd_Hook(void); + void glEndList_Hook(void); + void glEvalCoord1d_Hook(GLdouble u); + void glEvalCoord1dv_Hook(const GLdouble *u); + void glEvalCoord1f_Hook(GLfloat u); + void glEvalCoord1fv_Hook(const GLfloat *u); + void glEvalCoord2d_Hook(GLdouble u, GLdouble v); + void glEvalCoord2dv_Hook(const GLdouble *u); + void glEvalCoord2f_Hook(GLfloat u, GLfloat v); + void glEvalCoord2fv_Hook(const GLfloat *u); + void glEvalMesh1_Hook(GLenum mode, GLint i1, GLint i2); + void glEvalMesh2_Hook(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2); + void glEvalPoint1_Hook(GLint i); + void glEvalPoint2_Hook(GLint i, GLint j); + void glFeedbackBuffer_Hook(GLsizei size, GLenum type, GLfloat *buffer); + void glFinish_Hook(void); + void glFlush_Hook(void); + void glFogf_Hook(GLenum pname, GLfloat param); + void glFogfv_Hook(GLenum pname, const GLfloat *params); + void glFogi_Hook(GLenum pname, GLint param); + void glFogiv_Hook(GLenum pname, const GLint *params); + void glFrontFace_Hook(GLenum mode); + void glFrustum_Hook(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); + GLuint glGenLists_Hook(GLsizei range); + void glGenTextures_Hook(GLsizei n, GLuint *textures); + void glGetBooleanv_Hook(GLenum pname, GLboolean *params); + void glGetClipPlane_Hook(GLenum plane, GLdouble *equation); + void glGetDoublev_Hook(GLenum pname, GLdouble *params); + GLenum glGetError_Hook(void); + void glGetFloatv_Hook(GLenum pname, GLfloat *params); + void glGetIntegerv_Hook(GLenum pname, GLint *params); + void glGetLightfv_Hook(GLenum light, GLenum pname, GLfloat *params); + void glGetLightiv_Hook(GLenum light, GLenum pname, GLint *params); + void glGetMapdv_Hook(GLenum target, GLenum query, GLdouble *v); + void glGetMapfv_Hook(GLenum target, GLenum query, GLfloat *v); + void glGetMapiv_Hook(GLenum target, GLenum query, GLint *v); + void glGetMaterialfv_Hook(GLenum face, GLenum pname, GLfloat *params); + void glGetMaterialiv_Hook(GLenum face, GLenum pname, GLint *params); + void glGetPixelMapfv_Hook(GLenum map, GLfloat *values); + void glGetPixelMapuiv_Hook(GLenum map, GLuint *values); + void glGetPixelMapusv_Hook(GLenum map, GLushort *values); + void glGetPointerv_Hook(GLenum pname, void* *params); + void glGetPolygonStipple_Hook(GLubyte *mask); + const GLubyte * glGetString_Hook(GLenum name); + void glGetTexEnvfv_Hook(GLenum target, GLenum pname, GLfloat *params); + void glGetTexEnviv_Hook(GLenum target, GLenum pname, GLint *params); + void glGetTexGendv_Hook(GLenum coord, GLenum pname, GLdouble *params); + void glGetTexGenfv_Hook(GLenum coord, GLenum pname, GLfloat *params); + void glGetTexGeniv_Hook(GLenum coord, GLenum pname, GLint *params); + void glGetTexImage_Hook(GLenum target, GLint level, GLenum format, GLenum type, void *pixels); + void glGetTexLevelParameterfv_Hook(GLenum target, GLint level, GLenum pname, GLfloat *params); + void glGetTexLevelParameteriv_Hook(GLenum target, GLint level, GLenum pname, GLint *params); + void glGetTexParameterfv_Hook(GLenum target, GLenum pname, GLfloat *params); + void glGetTexParameteriv_Hook(GLenum target, GLenum pname, GLint *params); + void glHint_Hook(GLenum target, GLenum mode); + void glIndexMask_Hook(GLuint mask); + void glIndexPointer_Hook(GLenum type, GLsizei stride, const void *pointer); + void glIndexd_Hook(GLdouble c); + void glIndexdv_Hook(const GLdouble *c); + void glIndexf_Hook(GLfloat c); + void glIndexfv_Hook(const GLfloat *c); + void glIndexi_Hook(GLint c); + void glIndexiv_Hook(const GLint *c); + void glIndexs_Hook(GLshort c); + void glIndexsv_Hook(const GLshort *c); + void glIndexub_Hook(GLubyte c); + void glIndexubv_Hook(const GLubyte *c); + void glInitNames_Hook(void); + void glInterleavedArrays_Hook(GLenum format, GLsizei stride, const void *pointer); + GLboolean glIsEnabled_Hook(GLenum cap); + GLboolean glIsList_Hook(GLuint list); + GLboolean glIsTexture_Hook(GLuint texture); + void glLightModelf_Hook(GLenum pname, GLfloat param); + void glLightModelfv_Hook(GLenum pname, const GLfloat *params); + void glLightModeli_Hook(GLenum pname, GLint param); + void glLightModeliv_Hook(GLenum pname, const GLint *params); + void glLightf_Hook(GLenum light, GLenum pname, GLfloat param); + void glLightfv_Hook(GLenum light, GLenum pname, const GLfloat *params); + void glLighti_Hook(GLenum light, GLenum pname, GLint param); + void glLightiv_Hook(GLenum light, GLenum pname, const GLint *params); + void glLineStipple_Hook(GLint factor, GLushort pattern); + void glLineWidth_Hook(GLfloat width); + void glListBase_Hook(GLuint base); + void glLoadIdentity_Hook(void); + void glLoadMatrixd_Hook(const GLdouble *m); + void glLoadMatrixf_Hook(const GLfloat *m); + void glLoadName_Hook(GLuint name); + void glLogicOp_Hook(GLenum opcode); + void glMap1d_Hook(GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); + void glMap1f_Hook(GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); + void glMap2d_Hook(GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); + void glMap2f_Hook(GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); + void glMapGrid1d_Hook(GLint un, GLdouble u1, GLdouble u2); + void glMapGrid1f_Hook(GLint un, GLfloat u1, GLfloat u2); + void glMapGrid2d_Hook(GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2); + void glMapGrid2f_Hook(GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2); + void glMaterialf_Hook(GLenum face, GLenum pname, GLfloat param); + void glMaterialfv_Hook(GLenum face, GLenum pname, const GLfloat *params); + void glMateriali_Hook(GLenum face, GLenum pname, GLint param); + void glMaterialiv_Hook(GLenum face, GLenum pname, const GLint *params); + void glMatrixMode_Hook(GLenum mode); + void glMultMatrixd_Hook(const GLdouble *m); + void glMultMatrixf_Hook(const GLfloat *m); + void glNewList_Hook(GLuint list, GLenum mode); + void glNormal3b_Hook(GLbyte nx, GLbyte ny, GLbyte nz); + void glNormal3bv_Hook(const GLbyte *v); + void glNormal3d_Hook(GLdouble nx, GLdouble ny, GLdouble nz); + void glNormal3dv_Hook(const GLdouble *v); + void glNormal3f_Hook(GLfloat nx, GLfloat ny, GLfloat nz); + void glNormal3fv_Hook(const GLfloat *v); + void glNormal3i_Hook(GLint nx, GLint ny, GLint nz); + void glNormal3iv_Hook(const GLint *v); + void glNormal3s_Hook(GLshort nx, GLshort ny, GLshort nz); + void glNormal3sv_Hook(const GLshort *v); + void glNormalPointer_Hook(GLenum type, GLsizei stride, const void *pointer); + void glOrtho_Hook(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); + void glPassThrough_Hook(GLfloat token); + void glPixelMapfv_Hook(GLenum map, GLsizei mapsize, const GLfloat *values); + void glPixelMapuiv_Hook(GLenum map, GLsizei mapsize, const GLuint *values); + void glPixelMapusv_Hook(GLenum map, GLsizei mapsize, const GLushort *values); + void glPixelStoref_Hook(GLenum pname, GLfloat param); + void glPixelStorei_Hook(GLenum pname, GLint param); + void glPixelTransferf_Hook(GLenum pname, GLfloat param); + void glPixelTransferi_Hook(GLenum pname, GLint param); + void glPixelZoom_Hook(GLfloat xfactor, GLfloat yfactor); + void glPointSize_Hook(GLfloat size); + void glPolygonMode_Hook(GLenum face, GLenum mode); + void glPolygonOffset_Hook(GLfloat factor, GLfloat units); + void glPolygonStipple_Hook(const GLubyte *mask); + void glPopAttrib_Hook(void); + void glPopClientAttrib_Hook(void); + void glPopMatrix_Hook(void); + void glPopName_Hook(void); + void glPrioritizeTextures_Hook(GLsizei n, const GLuint *textures, const GLclampf *priorities); + void glPushAttrib_Hook(GLbitfield mask); + void glPushClientAttrib_Hook(GLbitfield mask); + void glPushMatrix_Hook(void); + void glPushName_Hook(GLuint name); + void glRasterPos2d_Hook(GLdouble x, GLdouble y); + void glRasterPos2dv_Hook(const GLdouble *v); + void glRasterPos2f_Hook(GLfloat x, GLfloat y); + void glRasterPos2fv_Hook(const GLfloat *v); + void glRasterPos2i_Hook(GLint x, GLint y); + void glRasterPos2iv_Hook(const GLint *v); + void glRasterPos2s_Hook(GLshort x, GLshort y); + void glRasterPos2sv_Hook(const GLshort *v); + void glRasterPos3d_Hook(GLdouble x, GLdouble y, GLdouble z); + void glRasterPos3dv_Hook(const GLdouble *v); + void glRasterPos3f_Hook(GLfloat x, GLfloat y, GLfloat z); + void glRasterPos3fv_Hook(const GLfloat *v); + void glRasterPos3i_Hook(GLint x, GLint y, GLint z); + void glRasterPos3iv_Hook(const GLint *v); + void glRasterPos3s_Hook(GLshort x, GLshort y, GLshort z); + void glRasterPos3sv_Hook(const GLshort *v); + void glRasterPos4d_Hook(GLdouble x, GLdouble y, GLdouble z, GLdouble w); + void glRasterPos4dv_Hook(const GLdouble *v); + void glRasterPos4f_Hook(GLfloat x, GLfloat y, GLfloat z, GLfloat w); + void glRasterPos4fv_Hook(const GLfloat *v); + void glRasterPos4i_Hook(GLint x, GLint y, GLint z, GLint w); + void glRasterPos4iv_Hook(const GLint *v); + void glRasterPos4s_Hook(GLshort x, GLshort y, GLshort z, GLshort w); + void glRasterPos4sv_Hook(const GLshort *v); + void glReadBuffer_Hook(GLenum mode); + void glReadPixels_Hook(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels); + void glRectd_Hook(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2); + void glRectdv_Hook(const GLdouble *v1, const GLdouble *v2); + void glRectf_Hook(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2); + void glRectfv_Hook(const GLfloat *v1, const GLfloat *v2); + void glRecti_Hook(GLint x1, GLint y1, GLint x2, GLint y2); + void glRectiv_Hook(const GLint *v1, const GLint *v2); + void glRects_Hook(GLshort x1, GLshort y1, GLshort x2, GLshort y2); + void glRectsv_Hook(const GLshort *v1, const GLshort *v2); + GLint glRenderMode_Hook(GLenum mode); + void glRotated_Hook(GLdouble angle, GLdouble x, GLdouble y, GLdouble z); + void glRotatef_Hook(GLfloat angle, GLfloat x, GLfloat y, GLfloat z); + void glScaled_Hook(GLdouble x, GLdouble y, GLdouble z); + void glScalef_Hook(GLfloat x, GLfloat y, GLfloat z); + void glScissor_Hook(GLint x, GLint y, GLsizei width, GLsizei height); + void glSelectBuffer_Hook(GLsizei size, GLuint *buffer); + void glShadeModel_Hook(GLenum mode); + void glStencilFunc_Hook(GLenum func, GLint ref, GLuint mask); + void glStencilMask_Hook(GLuint mask); + void glStencilOp_Hook(GLenum fail, GLenum zfail, GLenum zpass); + void glTexCoord1d_Hook(GLdouble s); + void glTexCoord1dv_Hook(const GLdouble *v); + void glTexCoord1f_Hook(GLfloat s); + void glTexCoord1fv_Hook(const GLfloat *v); + void glTexCoord1i_Hook(GLint s); + void glTexCoord1iv_Hook(const GLint *v); + void glTexCoord1s_Hook(GLshort s); + void glTexCoord1sv_Hook(const GLshort *v); + void glTexCoord2d_Hook(GLdouble s, GLdouble t); + void glTexCoord2dv_Hook(const GLdouble *v); + void glTexCoord2f_Hook(GLfloat s, GLfloat t); + void glTexCoord2fv_Hook(const GLfloat *v); + void glTexCoord2i_Hook(GLint s, GLint t); + void glTexCoord2iv_Hook(const GLint *v); + void glTexCoord2s_Hook(GLshort s, GLshort t); + void glTexCoord2sv_Hook(const GLshort *v); + void glTexCoord3d_Hook(GLdouble s, GLdouble t, GLdouble r); + void glTexCoord3dv_Hook(const GLdouble *v); + void glTexCoord3f_Hook(GLfloat s, GLfloat t, GLfloat r); + void glTexCoord3fv_Hook(const GLfloat *v); + void glTexCoord3i_Hook(GLint s, GLint t, GLint r); + void glTexCoord3iv_Hook(const GLint *v); + void glTexCoord3s_Hook(GLshort s, GLshort t, GLshort r); + void glTexCoord3sv_Hook(const GLshort *v); + void glTexCoord4d_Hook(GLdouble s, GLdouble t, GLdouble r, GLdouble q); + void glTexCoord4dv_Hook(const GLdouble *v); + void glTexCoord4f_Hook(GLfloat s, GLfloat t, GLfloat r, GLfloat q); + void glTexCoord4fv_Hook(const GLfloat *v); + void glTexCoord4i_Hook(GLint s, GLint t, GLint r, GLint q); + void glTexCoord4iv_Hook(const GLint *v); + void glTexCoord4s_Hook(GLshort s, GLshort t, GLshort r, GLshort q); + void glTexCoord4sv_Hook(const GLshort *v); + void glTexCoordPointer_Hook(GLint size, GLenum type, GLsizei stride, const void *pointer); + void glTexEnvf_Hook(GLenum target, GLenum pname, GLfloat param); + void glTexEnvfv_Hook(GLenum target, GLenum pname, const GLfloat *params); + void glTexEnvi_Hook(GLenum target, GLenum pname, GLint param); + void glTexEnviv_Hook(GLenum target, GLenum pname, const GLint *params); + void glTexGend_Hook(GLenum coord, GLenum pname, GLdouble param); + void glTexGendv_Hook(GLenum coord, GLenum pname, const GLdouble *params); + void glTexGenf_Hook(GLenum coord, GLenum pname, GLfloat param); + void glTexGenfv_Hook(GLenum coord, GLenum pname, const GLfloat *params); + void glTexGeni_Hook(GLenum coord, GLenum pname, GLint param); + void glTexGeniv_Hook(GLenum coord, GLenum pname, const GLint *params); + void glTexImage1D_Hook(GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); + void glTexImage2D_Hook(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); + void glTexParameterf_Hook(GLenum target, GLenum pname, GLfloat param); + void glTexParameterfv_Hook(GLenum target, GLenum pname, const GLfloat *params); + void glTexParameteri_Hook(GLenum target, GLenum pname, GLint param); + void glTexParameteriv_Hook(GLenum target, GLenum pname, const GLint *params); + void glTexSubImage1D_Hook(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); + void glTexSubImage2D_Hook(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); + void glTranslated_Hook(GLdouble x, GLdouble y, GLdouble z); + void glTranslatef_Hook(GLfloat x, GLfloat y, GLfloat z); + void glVertex2d_Hook(GLdouble x, GLdouble y); + void glVertex2dv_Hook(const GLdouble *v); + void glVertex2f_Hook(GLfloat x, GLfloat y); + void glVertex2fv_Hook(const GLfloat *v); + void glVertex2i_Hook(GLint x, GLint y); + void glVertex2iv_Hook(const GLint *v); + void glVertex2s_Hook(GLshort x, GLshort y); + void glVertex2sv_Hook(const GLshort *v); + void glVertex3d_Hook(GLdouble x, GLdouble y, GLdouble z); + void glVertex3dv_Hook(const GLdouble *v); + void glVertex3f_Hook(GLfloat x, GLfloat y, GLfloat z); + void glVertex3fv_Hook(const GLfloat *v); + void glVertex3i_Hook(GLint x, GLint y, GLint z); + void glVertex3iv_Hook(const GLint *v); + void glVertex3s_Hook(GLshort x, GLshort y, GLshort z); + void glVertex3sv_Hook(const GLshort *v); + void glVertex4d_Hook(GLdouble x, GLdouble y, GLdouble z, GLdouble w); + void glVertex4dv_Hook(const GLdouble *v); + void glVertex4f_Hook(GLfloat x, GLfloat y, GLfloat z, GLfloat w); + void glVertex4fv_Hook(const GLfloat *v); + void glVertex4i_Hook(GLint x, GLint y, GLint z, GLint w); + void glVertex4iv_Hook(const GLint *v); + void glVertex4s_Hook(GLshort x, GLshort y, GLshort z, GLshort w); + void glVertex4sv_Hook(const GLshort *v); + void glVertexPointer_Hook(GLint size, GLenum type, GLsizei stride, const void *pointer); + void glViewport_Hook(GLint x, GLint y, GLsizei width, GLsizei height); + + // GL_VERSION_1_2 + void glBlendColor_Hook(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); + void glBlendEquation_Hook(GLenum mode); + void glDrawRangeElements_Hook(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); + void glTexImage3D_Hook(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); + void glTexSubImage3D_Hook(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); + void glCopyTexSubImage3D_Hook(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); + + // GL_VERSION_1_2 deprecated functions + /* Not currently supported + void glColorTable_Hook(GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); + void glColorTableParameterfv_Hook(GLenum target, GLenum pname, const GLfloat *params); + void glColorTableParameteriv_Hook(GLenum target, GLenum pname, const GLint *params); + void glCopyColorTable_Hook(GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); + void glGetColorTable_Hook(GLenum target, GLenum format, GLenum type, GLvoid *table); + void glGetColorTableParameterfv_Hook(GLenum target, GLenum pname, GLfloat *params); + void glGetColorTableParameteriv_Hook(GLenum target, GLenum pname, GLint *params); + void glColorSubTable_Hook(GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); + void glCopyColorSubTable_Hook(GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); + void glConvolutionFilter1D_Hook(GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); + void glConvolutionFilter2D_Hook(GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); + void glConvolutionParameterf_Hook(GLenum target, GLenum pname, GLfloat params); + void glConvolutionParameterfv_Hook(GLenum target, GLenum pname, const GLfloat *params); + void glConvolutionParameteri_Hook(GLenum target, GLenum pname, GLint params); + void glConvolutionParameteriv_Hook(GLenum target, GLenum pname, const GLint *params); + void glCopyConvolutionFilter1D_Hook(GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); + void glCopyConvolutionFilter2D_Hook(GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); + void glGetConvolutionFilter_Hook(GLenum target, GLenum format, GLenum type, GLvoid *image); + void glGetConvolutionParameterfv_Hook(GLenum target, GLenum pname, GLfloat *params); + void glGetConvolutionParameteriv_Hook(GLenum target, GLenum pname, GLint *params); + void glGetSeparableFilter_Hook(GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); + void glSeparableFilter2D_Hook(GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); + void glGetHistogram_Hook(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); + void glGetHistogramParameterfv_Hook(GLenum target, GLenum pname, GLfloat *params); + void glGetHistogramParameteriv_Hook(GLenum target, GLenum pname, GLint *params); + void glGetMinmax_Hook(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); + void glGetMinmaxParameterfv_Hook(GLenum target, GLenum pname, GLfloat *params); + void glGetMinmaxParameteriv_Hook(GLenum target, GLenum pname, GLint *params); + void glHistogram_Hook(GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); + void glMinmax_Hook(GLenum target, GLenum internalformat, GLboolean sink); + void glResetHistogram_Hook(GLenum target); + void glResetMinmax_Hook(GLenum target); + */ + + // GL_VERSION_1_3 + void glActiveTexture_Hook(GLenum texture); + void glSampleCoverage_Hook(GLclampf value, GLboolean invert); + void glCompressedTexImage3D_Hook(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); + void glCompressedTexImage2D_Hook(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); + void glCompressedTexImage1D_Hook(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); + void glCompressedTexSubImage3D_Hook(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); + void glCompressedTexSubImage2D_Hook(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); + void glCompressedTexSubImage1D_Hook(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); + void glGetCompressedTexImage_Hook(GLenum target, GLint level, GLvoid *img); + + // GL_VERSION_1_3 deprecated functions + void glClientActiveTexture_Hook(GLenum texture); + void glMultiTexCoord1d_Hook(GLenum target, GLdouble s); + void glMultiTexCoord1dv_Hook(GLenum target, const GLdouble *v); + void glMultiTexCoord1f_Hook(GLenum target, GLfloat s); + void glMultiTexCoord1fv_Hook(GLenum target, const GLfloat *v); + void glMultiTexCoord1i_Hook(GLenum target, GLint s); + void glMultiTexCoord1iv_Hook(GLenum target, const GLint *v); + void glMultiTexCoord1s_Hook(GLenum target, GLshort s); + void glMultiTexCoord1sv_Hook(GLenum target, const GLshort *v); + void glMultiTexCoord2d_Hook(GLenum target, GLdouble s, GLdouble t); + void glMultiTexCoord2dv_Hook(GLenum target, const GLdouble *v); + void glMultiTexCoord2f_Hook(GLenum target, GLfloat s, GLfloat t); + void glMultiTexCoord2fv_Hook(GLenum target, const GLfloat *v); + void glMultiTexCoord2i_Hook(GLenum target, GLint s, GLint t); + void glMultiTexCoord2iv_Hook(GLenum target, const GLint *v); + void glMultiTexCoord2s_Hook(GLenum target, GLshort s, GLshort t); + void glMultiTexCoord2sv_Hook(GLenum target, const GLshort *v); + void glMultiTexCoord3d_Hook(GLenum target, GLdouble s, GLdouble t, GLdouble r); + void glMultiTexCoord3dv_Hook(GLenum target, const GLdouble *v); + void glMultiTexCoord3f_Hook(GLenum target, GLfloat s, GLfloat t, GLfloat r); + void glMultiTexCoord3fv_Hook(GLenum target, const GLfloat *v); + void glMultiTexCoord3i_Hook(GLenum target, GLint s, GLint t, GLint r); + void glMultiTexCoord3iv_Hook(GLenum target, const GLint *v); + void glMultiTexCoord3s_Hook(GLenum target, GLshort s, GLshort t, GLshort r); + void glMultiTexCoord3sv_Hook(GLenum target, const GLshort *v); + void glMultiTexCoord4d_Hook(GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); + void glMultiTexCoord4dv_Hook(GLenum target, const GLdouble *v); + void glMultiTexCoord4f_Hook(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); + void glMultiTexCoord4fv_Hook(GLenum target, const GLfloat *v); + void glMultiTexCoord4i_Hook(GLenum target, GLint s, GLint t, GLint r, GLint q); + void glMultiTexCoord4iv_Hook(GLenum target, const GLint *v); + void glMultiTexCoord4s_Hook(GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); + void glMultiTexCoord4sv_Hook(GLenum target, const GLshort *v); + void glLoadTransposeMatrixf_Hook(const GLfloat *m); + void glLoadTransposeMatrixd_Hook(const GLdouble *m); + void glMultTransposeMatrixf_Hook(const GLfloat *m); + void glMultTransposeMatrixd_Hook(const GLdouble *m); + + // GL_VERSION_1_4 + void glBlendFuncSeparate_Hook(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); + void glMultiDrawArrays_Hook(GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); + void glMultiDrawElements_Hook(GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); + void glPointParameterf_Hook(GLenum pname, GLfloat param); + void glPointParameterfv_Hook(GLenum pname, const GLfloat *params); + void glPointParameteri_Hook(GLenum pname, GLint param); + void glPointParameteriv_Hook(GLenum pname, const GLint *params); + + // GL_VERSION_1_4 deprecated functions + void glFogCoordf_Hook(GLfloat coord); + void glFogCoordfv_Hook(const GLfloat *coord); + void glFogCoordd_Hook(GLdouble coord); + void glFogCoorddv_Hook(const GLdouble *coord); + void glFogCoordPointer_Hook(GLenum type, GLsizei stride, const GLvoid *pointer); + void glSecondaryColor3b_Hook(GLbyte red, GLbyte green, GLbyte blue); + void glSecondaryColor3bv_Hook(const GLbyte *v); + void glSecondaryColor3d_Hook(GLdouble red, GLdouble green, GLdouble blue); + void glSecondaryColor3dv_Hook(const GLdouble *v); + void glSecondaryColor3f_Hook(GLfloat red, GLfloat green, GLfloat blue); + void glSecondaryColor3fv_Hook(const GLfloat *v); + void glSecondaryColor3i_Hook(GLint red, GLint green, GLint blue); + void glSecondaryColor3iv_Hook(const GLint *v); + void glSecondaryColor3s_Hook(GLshort red, GLshort green, GLshort blue); + void glSecondaryColor3sv_Hook(const GLshort *v); + void glSecondaryColor3ub_Hook(GLubyte red, GLubyte green, GLubyte blue); + void glSecondaryColor3ubv_Hook(const GLubyte *v); + void glSecondaryColor3ui_Hook(GLuint red, GLuint green, GLuint blue); + void glSecondaryColor3uiv_Hook(const GLuint *v); + void glSecondaryColor3us_Hook(GLushort red, GLushort green, GLushort blue); + void glSecondaryColor3usv_Hook(const GLushort *v); + void glSecondaryColorPointer_Hook(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); + void glWindowPos2d_Hook(GLdouble x, GLdouble y); + void glWindowPos2dv_Hook(const GLdouble *v); + void glWindowPos2f_Hook(GLfloat x, GLfloat y); + void glWindowPos2fv_Hook(const GLfloat *v); + void glWindowPos2i_Hook(GLint x, GLint y); + void glWindowPos2iv_Hook(const GLint *v); + void glWindowPos2s_Hook(GLshort x, GLshort y); + void glWindowPos2sv_Hook(const GLshort *v); + void glWindowPos3d_Hook(GLdouble x, GLdouble y, GLdouble z); + void glWindowPos3dv_Hook(const GLdouble *v); + void glWindowPos3f_Hook(GLfloat x, GLfloat y, GLfloat z); + void glWindowPos3fv_Hook(const GLfloat *v); + void glWindowPos3i_Hook(GLint x, GLint y, GLint z); + void glWindowPos3iv_Hook(const GLint *v); + void glWindowPos3s_Hook(GLshort x, GLshort y, GLshort z); + void glWindowPos3sv_Hook(const GLshort *v); + + // GL_VERSION_1_5 + void glGenQueries_Hook(GLsizei n, GLuint *ids); + void glDeleteQueries_Hook(GLsizei n, const GLuint *ids); + GLboolean glIsQuery_Hook(GLuint id); + void glBeginQuery_Hook(GLenum target, GLuint id); + void glEndQuery_Hook(GLenum target); + void glGetQueryiv_Hook(GLenum target, GLenum pname, GLint *params); + void glGetQueryObjectiv_Hook(GLuint id, GLenum pname, GLint *params); + void glGetQueryObjectuiv_Hook(GLuint id, GLenum pname, GLuint *params); + void glBindBuffer_Hook(GLenum target, GLuint buffer); + void glDeleteBuffers_Hook(GLsizei n, const GLuint *buffers); + void glGenBuffers_Hook(GLsizei n, GLuint *buffers); + GLboolean glIsBuffer_Hook(GLuint buffer); + void glBufferData_Hook(GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); + void glBufferSubData_Hook(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data); + void glGetBufferSubData_Hook(GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data); + GLvoid* glMapBuffer_Hook(GLenum target, GLenum access); + GLboolean glUnmapBuffer_Hook(GLenum target); + void glGetBufferParameteriv_Hook(GLenum target, GLenum pname, GLint *params); + void glGetBufferPointerv_Hook(GLenum target, GLenum pname, GLvoid* *params); + + // GL_VERSION_2_0 + void glBlendEquationSeparate_Hook(GLenum modeRGB, GLenum modeAlpha); + void glDrawBuffers_Hook(GLsizei n, const GLenum *bufs); + void glStencilOpSeparate_Hook(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); + void glStencilFuncSeparate_Hook(GLenum face, GLenum func, GLint ref, GLuint mask); + void glStencilMaskSeparate_Hook(GLenum face, GLuint mask); + void glAttachShader_Hook(GLuint program, GLuint shader); + void glBindAttribLocation_Hook(GLuint program, GLuint index, const GLchar *name); + void glCompileShader_Hook(GLuint shader); + GLuint glCreateProgram_Hook(void); + GLuint glCreateShader_Hook(GLenum type); + void glDeleteProgram_Hook(GLuint program); + void glDeleteShader_Hook(GLuint shader); + void glDetachShader_Hook(GLuint program, GLuint shader); + void glDisableVertexAttribArray_Hook(GLuint index); + void glEnableVertexAttribArray_Hook(GLuint index); + void glGetActiveAttrib_Hook(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); + void glGetActiveUniform_Hook(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); + void glGetAttachedShaders_Hook(GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj); + GLint glGetAttribLocation_Hook(GLuint program, const GLchar *name); + void glGetProgramiv_Hook(GLuint program, GLenum pname, GLint *params); + void glGetProgramInfoLog_Hook(GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); + void glGetShaderiv_Hook(GLuint shader, GLenum pname, GLint *params); + void glGetShaderInfoLog_Hook(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); + void glGetShaderSource_Hook(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); + GLint glGetUniformLocation_Hook(GLuint program, const GLchar *name); + void glGetUniformfv_Hook(GLuint program, GLint location, GLfloat *params); + void glGetUniformiv_Hook(GLuint program, GLint location, GLint *params); + void glGetVertexAttribdv_Hook(GLuint index, GLenum pname, GLdouble *params); + void glGetVertexAttribfv_Hook(GLuint index, GLenum pname, GLfloat *params); + void glGetVertexAttribiv_Hook(GLuint index, GLenum pname, GLint *params); + void glGetVertexAttribPointerv_Hook(GLuint index, GLenum pname, GLvoid* *pointer); + GLboolean glIsProgram_Hook(GLuint program); + GLboolean glIsShader_Hook(GLuint shader); + void glLinkProgram_Hook(GLuint program); + void glShaderSource_Hook(GLuint shader, GLsizei count, const GLchar* *string, const GLint *length); + void glUseProgram_Hook(GLuint program); + void glUniform1f_Hook(GLint location, GLfloat v0); + void glUniform2f_Hook(GLint location, GLfloat v0, GLfloat v1); + void glUniform3f_Hook(GLint location, GLfloat v0, GLfloat v1, GLfloat v2); + void glUniform4f_Hook(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); + void glUniform1i_Hook(GLint location, GLint v0); + void glUniform2i_Hook(GLint location, GLint v0, GLint v1); + void glUniform3i_Hook(GLint location, GLint v0, GLint v1, GLint v2); + void glUniform4i_Hook(GLint location, GLint v0, GLint v1, GLint v2, GLint v3); + void glUniform1fv_Hook(GLint location, GLsizei count, const GLfloat *value); + void glUniform2fv_Hook(GLint location, GLsizei count, const GLfloat *value); + void glUniform3fv_Hook(GLint location, GLsizei count, const GLfloat *value); + void glUniform4fv_Hook(GLint location, GLsizei count, const GLfloat *value); + void glUniform1iv_Hook(GLint location, GLsizei count, const GLint *value); + void glUniform2iv_Hook(GLint location, GLsizei count, const GLint *value); + void glUniform3iv_Hook(GLint location, GLsizei count, const GLint *value); + void glUniform4iv_Hook(GLint location, GLsizei count, const GLint *value); + void glUniformMatrix2fv_Hook(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + void glUniformMatrix3fv_Hook(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + void glUniformMatrix4fv_Hook(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + void glValidateProgram_Hook(GLuint program); + void glVertexAttrib1d_Hook(GLuint index, GLdouble x); + void glVertexAttrib1dv_Hook(GLuint index, const GLdouble *v); + void glVertexAttrib1f_Hook(GLuint index, GLfloat x); + void glVertexAttrib1fv_Hook(GLuint index, const GLfloat *v); + void glVertexAttrib1s_Hook(GLuint index, GLshort x); + void glVertexAttrib1sv_Hook(GLuint index, const GLshort *v); + void glVertexAttrib2d_Hook(GLuint index, GLdouble x, GLdouble y); + void glVertexAttrib2dv_Hook(GLuint index, const GLdouble *v); + void glVertexAttrib2f_Hook(GLuint index, GLfloat x, GLfloat y); + void glVertexAttrib2fv_Hook(GLuint index, const GLfloat *v); + void glVertexAttrib2s_Hook(GLuint index, GLshort x, GLshort y); + void glVertexAttrib2sv_Hook(GLuint index, const GLshort *v); + void glVertexAttrib3d_Hook(GLuint index, GLdouble x, GLdouble y, GLdouble z); + void glVertexAttrib3dv_Hook(GLuint index, const GLdouble *v); + void glVertexAttrib3f_Hook(GLuint index, GLfloat x, GLfloat y, GLfloat z); + void glVertexAttrib3fv_Hook(GLuint index, const GLfloat *v); + void glVertexAttrib3s_Hook(GLuint index, GLshort x, GLshort y, GLshort z); + void glVertexAttrib3sv_Hook(GLuint index, const GLshort *v); + void glVertexAttrib4Nbv_Hook(GLuint index, const GLbyte *v); + void glVertexAttrib4Niv_Hook(GLuint index, const GLint *v); + void glVertexAttrib4Nsv_Hook(GLuint index, const GLshort *v); + void glVertexAttrib4Nub_Hook(GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); + void glVertexAttrib4Nubv_Hook(GLuint index, const GLubyte *v); + void glVertexAttrib4Nuiv_Hook(GLuint index, const GLuint *v); + void glVertexAttrib4Nusv_Hook(GLuint index, const GLushort *v); + void glVertexAttrib4bv_Hook(GLuint index, const GLbyte *v); + void glVertexAttrib4d_Hook(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); + void glVertexAttrib4dv_Hook(GLuint index, const GLdouble *v); + void glVertexAttrib4f_Hook(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); + void glVertexAttrib4fv_Hook(GLuint index, const GLfloat *v); + void glVertexAttrib4iv_Hook(GLuint index, const GLint *v); + void glVertexAttrib4s_Hook(GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); + void glVertexAttrib4sv_Hook(GLuint index, const GLshort *v); + void glVertexAttrib4ubv_Hook(GLuint index, const GLubyte *v); + void glVertexAttrib4uiv_Hook(GLuint index, const GLuint *v); + void glVertexAttrib4usv_Hook(GLuint index, const GLushort *v); + void glVertexAttribPointer_Hook(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); + + // GL_VERSION_2_1 + void glUniformMatrix2x3fv_Hook(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + void glUniformMatrix3x2fv_Hook(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + void glUniformMatrix2x4fv_Hook(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + void glUniformMatrix4x2fv_Hook(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + void glUniformMatrix3x4fv_Hook(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + void glUniformMatrix4x3fv_Hook(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + + // GL_VERSION_3_0 + void glColorMaski_Hook(GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); + void glGetBooleani_v_Hook(GLenum target, GLuint index, GLboolean *data); + void glGetIntegeri_v_Hook(GLenum target, GLuint index, GLint *data); + void glEnablei_Hook(GLenum target, GLuint index); + void glDisablei_Hook(GLenum target, GLuint index); + GLboolean glIsEnabledi_Hook(GLenum target, GLuint index); + void glBeginTransformFeedback_Hook(GLenum primitiveMode); + void glEndTransformFeedback_Hook(void); + void glBindBufferRange_Hook(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); + void glBindBufferBase_Hook(GLenum target, GLuint index, GLuint buffer); + void glTransformFeedbackVaryings_Hook(GLuint program, GLsizei count, const GLchar* *varyings, GLenum bufferMode); + void glGetTransformFeedbackVarying_Hook(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); + void glClampColor_Hook(GLenum target, GLenum clamp); + void glBeginConditionalRender_Hook(GLuint id, GLenum mode); + void glEndConditionalRender_Hook(void); + void glVertexAttribIPointer_Hook(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); + void glGetVertexAttribIiv_Hook(GLuint index, GLenum pname, GLint *params); + void glGetVertexAttribIuiv_Hook(GLuint index, GLenum pname, GLuint *params); + void glVertexAttribI1i_Hook(GLuint index, GLint x); + void glVertexAttribI2i_Hook(GLuint index, GLint x, GLint y); + void glVertexAttribI3i_Hook(GLuint index, GLint x, GLint y, GLint z); + void glVertexAttribI4i_Hook(GLuint index, GLint x, GLint y, GLint z, GLint w); + void glVertexAttribI1ui_Hook(GLuint index, GLuint x); + void glVertexAttribI2ui_Hook(GLuint index, GLuint x, GLuint y); + void glVertexAttribI3ui_Hook(GLuint index, GLuint x, GLuint y, GLuint z); + void glVertexAttribI4ui_Hook(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); + void glVertexAttribI1iv_Hook(GLuint index, const GLint *v); + void glVertexAttribI2iv_Hook(GLuint index, const GLint *v); + void glVertexAttribI3iv_Hook(GLuint index, const GLint *v); + void glVertexAttribI4iv_Hook(GLuint index, const GLint *v); + void glVertexAttribI1uiv_Hook(GLuint index, const GLuint *v); + void glVertexAttribI2uiv_Hook(GLuint index, const GLuint *v); + void glVertexAttribI3uiv_Hook(GLuint index, const GLuint *v); + void glVertexAttribI4uiv_Hook(GLuint index, const GLuint *v); + void glVertexAttribI4bv_Hook(GLuint index, const GLbyte *v); + void glVertexAttribI4sv_Hook(GLuint index, const GLshort *v); + void glVertexAttribI4ubv_Hook(GLuint index, const GLubyte *v); + void glVertexAttribI4usv_Hook(GLuint index, const GLushort *v); + void glGetUniformuiv_Hook(GLuint program, GLint location, GLuint *params); + void glBindFragDataLocation_Hook(GLuint program, GLuint color, const GLchar *name); + GLint glGetFragDataLocation_Hook(GLuint program, const GLchar *name); + void glUniform1ui_Hook(GLint location, GLuint v0); + void glUniform2ui_Hook(GLint location, GLuint v0, GLuint v1); + void glUniform3ui_Hook(GLint location, GLuint v0, GLuint v1, GLuint v2); + void glUniform4ui_Hook(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); + void glUniform1uiv_Hook(GLint location, GLsizei count, const GLuint *value); + void glUniform2uiv_Hook(GLint location, GLsizei count, const GLuint *value); + void glUniform3uiv_Hook(GLint location, GLsizei count, const GLuint *value); + void glUniform4uiv_Hook(GLint location, GLsizei count, const GLuint *value); + void glTexParameterIiv_Hook(GLenum target, GLenum pname, const GLint *params); + void glTexParameterIuiv_Hook(GLenum target, GLenum pname, const GLuint *params); + void glGetTexParameterIiv_Hook(GLenum target, GLenum pname, GLint *params); + void glGetTexParameterIuiv_Hook(GLenum target, GLenum pname, GLuint *params); + void glClearBufferiv_Hook(GLenum buffer, GLint drawbuffer, const GLint *value); + void glClearBufferuiv_Hook(GLenum buffer, GLint drawbuffer, const GLuint *value); + void glClearBufferfv_Hook(GLenum buffer, GLint drawbuffer, const GLfloat *value); + void glClearBufferfi_Hook(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); + const GLubyte* glGetStringi_Hook(GLenum name, GLuint index); + + // GL_VERSION_3_1 + void glDrawArraysInstanced_Hook(GLenum mode, GLint first, GLsizei count, GLsizei primcount); + void glDrawElementsInstanced_Hook(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); + void glTexBuffer_Hook(GLenum target, GLenum internalformat, GLuint buffer); + void glPrimitiveRestartIndex_Hook(GLuint index); + + // GL_VERSION_3_2 + void glGetInteger64i_v_Hook(GLenum target, GLuint index, GLint64 *data); + void glGetBufferParameteri64v_Hook(GLenum target, GLenum pname, GLint64 *params); + void glFramebufferTexture_Hook(GLenum target, GLenum attachment, GLuint texture, GLint level); + + // GL_VERSION_3_3 + void glVertexAttribDivisor_Hook(GLuint index, GLuint divisor); + + // GL_VERSION_4_0 + void glMinSampleShading_Hook(GLclampf value); + void glBlendEquationi_Hook(GLuint buf, GLenum mode); + void glBlendEquationSeparatei_Hook(GLuint buf, GLenum modeRGB, GLenum modeAlpha); + void glBlendFunci_Hook(GLuint buf, GLenum src, GLenum dst); + void glBlendFuncSeparatei_Hook(GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); + + // GL_AMD_debug_output + void glDebugMessageEnableAMD_Hook(GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); + void glDebugMessageInsertAMD_Hook(GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf); + void glDebugMessageCallbackAMD_Hook(GLDEBUGPROCAMD callback, GLvoid *userParam); + GLuint glGetDebugMessageLogAMD_Hook(GLuint count, GLsizei bufsize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message); + + #if defined(GLE_CGL_ENABLED) + // GL_APPLE_element_array + void glElementPointerAPPLE_Hook(GLenum type, const GLvoid *pointer); + void glDrawElementArrayAPPLE_Hook(GLenum mode, GLint first, GLsizei count); + void glDrawRangeElementArrayAPPLE_Hook(GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); + void glMultiDrawElementArrayAPPLE_Hook(GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); + void glMultiDrawRangeElementArrayAPPLE_Hook(GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); + + // GL_APPLE_fence + void glGenFencesAPPLE_Hook(GLsizei n, GLuint *fences); + void glDeleteFencesAPPLE_Hook(GLsizei n, const GLuint *fences); + void glSetFenceAPPLE_Hook(GLuint fence); + GLboolean glIsFenceAPPLE_Hook(GLuint fence); + GLboolean glTestFenceAPPLE_Hook(GLuint fence); + void glFinishFenceAPPLE_Hook(GLuint fence); + GLboolean glTestObjectAPPLE_Hook(GLenum object, GLuint name); + void glFinishObjectAPPLE_Hook(GLenum object, GLint name); + + // GL_APPLE_flush_buffer_range + void glBufferParameteriAPPLE_Hook(GLenum target, GLenum pname, GLint param); + void glFlushMappedBufferRangeAPPLE_Hook(GLenum target, GLintptr offset, GLsizeiptr size); + + // GL_APPLE_object_purgeable + GLenum glObjectPurgeableAPPLE_Hook(GLenum objectType, GLuint name, GLenum option); + GLenum glObjectUnpurgeableAPPLE_Hook(GLenum objectType, GLuint name, GLenum option); + void glGetObjectParameterivAPPLE_Hook(GLenum objectType, GLuint name, GLenum pname, GLint *params); + + // GL_APPLE_texture_range + void glTextureRangeAPPLE_Hook(GLenum target, GLsizei length, const GLvoid *pointer); + void glGetTexParameterPointervAPPLE_Hook(GLenum target, GLenum pname, GLvoid **params); + + // GL_APPLE_vertex_array_object + void glBindVertexArrayAPPLE_Hook(GLuint array); + void glDeleteVertexArraysAPPLE_Hook(GLsizei n, const GLuint *arrays); + void glGenVertexArraysAPPLE_Hook(GLsizei n, GLuint *arrays); + GLboolean glIsVertexArrayAPPLE_Hook(GLuint array); + + // GL_APPLE_vertex_array_range + void glVertexArrayRangeAPPLE_Hook(GLsizei length, GLvoid *pointer); + void glFlushVertexArrayRangeAPPLE_Hook(GLsizei length, GLvoid *pointer); + void glVertexArrayParameteriAPPLE_Hook(GLenum pname, GLint param); + + // GL_APPLE_vertex_program_evaluators + void glEnableVertexAttribAPPLE_Hook(GLuint index, GLenum pname); + void glDisableVertexAttribAPPLE_Hook(GLuint index, GLenum pname); + GLboolean glIsVertexAttribEnabledAPPLE_Hook(GLuint index, GLenum pname); + void glMapVertexAttrib1dAPPLE_Hook(GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); + void glMapVertexAttrib1fAPPLE_Hook(GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); + void glMapVertexAttrib2dAPPLE_Hook(GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); + void glMapVertexAttrib2fAPPLE_Hook(GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); + #endif // GLE_CGL_ENABLED + + // GL_ARB_debug_output + void glDebugMessageControlARB_Hook(GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); + void glDebugMessageInsertARB_Hook(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); + void glDebugMessageCallbackARB_Hook(GLDEBUGPROCARB callback, const GLvoid *userParam); + GLuint glGetDebugMessageLogARB_Hook(GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); + + // GL_ARB_ES2_compatibility + void glReleaseShaderCompiler_Hook(); + void glShaderBinary_Hook(GLsizei count, const GLuint *shaders, GLenum binaryformat, const GLvoid *binary, GLsizei length); + void glGetShaderPrecisionFormat_Hook(GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); + void glDepthRangef_Hook(GLclampf n, GLclampf f); + void glClearDepthf_Hook(GLclampf d); + + // GL_ARB_framebuffer_object + GLboolean glIsRenderbuffer_Hook(GLuint renderbuffer); + void glBindRenderbuffer_Hook(GLenum target, GLuint renderbuffer); + void glDeleteRenderbuffers_Hook(GLsizei n, const GLuint *renderbuffers); + void glGenRenderbuffers_Hook(GLsizei n, GLuint *renderbuffers); + void glRenderbufferStorage_Hook(GLenum target, GLenum internalformat, GLsizei width, GLsizei height); + void glGetRenderbufferParameteriv_Hook(GLenum target, GLenum pname, GLint *params); + GLboolean glIsFramebuffer_Hook(GLuint framebuffer); + void glBindFramebuffer_Hook(GLenum target, GLuint framebuffer); + void glDeleteFramebuffers_Hook(GLsizei n, const GLuint *framebuffers); + void glGenFramebuffers_Hook(GLsizei n, GLuint *framebuffers); + GLenum glCheckFramebufferStatus_Hook(GLenum target); + void glFramebufferTexture1D_Hook(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); + void glFramebufferTexture2D_Hook(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); + void glFramebufferTexture3D_Hook(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); + void glFramebufferRenderbuffer_Hook(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); + void glGetFramebufferAttachmentParameteriv_Hook(GLenum target, GLenum attachment, GLenum pname, GLint *params); + void glGenerateMipmap_Hook(GLenum target); + void glBlitFramebuffer_Hook(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); + void glRenderbufferStorageMultisample_Hook(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); + void glFramebufferTextureLayer_Hook(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); + + // GL_ARB_texture_multisample + void glTexImage2DMultisample_Hook(GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); + void glTexImage3DMultisample_Hook(GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); + void glGetMultisamplefv_Hook(GLenum pname, GLuint index, GLfloat *val); + void glSampleMaski_Hook(GLuint index, GLbitfield mask); + + // GL_ARB_timer_query + void glQueryCounter_Hook(GLuint id, GLenum target); + void glGetQueryObjecti64v_Hook(GLuint id, GLenum pname, GLint64 *params); + void glGetQueryObjectui64v_Hook(GLuint id, GLenum pname, GLuint64 *params); + + // GL_ARB_vertex_array_object + void glBindVertexArray_Hook(GLuint array); + void glDeleteVertexArrays_Hook(GLsizei n, const GLuint *arrays); + void glGenVertexArrays_Hook(GLsizei n, GLuint *arrays); + GLboolean glIsVertexArray_Hook(GLuint array); + + // GL_EXT_draw_buffers2 + void glColorMaskIndexedEXT_Hook(GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); + void glGetBooleanIndexedvEXT_Hook(GLenum target, GLuint index, GLboolean *data); + void glGetIntegerIndexedvEXT_Hook(GLenum target, GLuint index, GLint *data); + void glEnableIndexedEXT_Hook(GLenum target, GLuint index); + void glDisableIndexedEXT_Hook(GLenum target, GLuint index); + GLboolean glIsEnabledIndexedEXT_Hook(GLenum target, GLuint index); + + // GL_KHR_debug + void glDebugMessageControl_Hook(GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint* ids, GLboolean enabled); + void glDebugMessageInsert_Hook(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const char* buf); + void glDebugMessageCallback_Hook(GLDEBUGPROC callback, const void* userParam); + GLuint glGetDebugMessageLog_Hook(GLuint count, GLsizei bufSize, GLenum* sources, GLenum* types, GLuint* ids, GLenum* severities, GLsizei* lengths, char* messageLog); + void glPushDebugGroup_Hook(GLenum source, GLuint id, GLsizei length, const char * message); + void glPopDebugGroup_Hook(void); + void glObjectLabel_Hook(GLenum identifier, GLuint name, GLsizei length, const char *label); + void glGetObjectLabel_Hook(GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, char *label); + void glObjectPtrLabel_Hook(void* ptr, GLsizei length, const char *label); + void glGetObjectPtrLabel_Hook(void* ptr, GLsizei bufSize, GLsizei *length, char *label); + + // GL_WIN_swap_hint + void glAddSwapHintRectWIN_Hook(GLint x, GLint y, GLsizei width, GLsizei height); + + #if defined(GLE_WGL_ENABLED) + void PostWGLHook(const char* functionName); + + // WGL + /* Hooking of these is currently disabled. + BOOL wglCopyContext_Hook(HGLRC, HGLRC, UINT); + HGLRC wglCreateContext_Hook(HDC); + HGLRC wglCreateLayerContext_Hook(HDC, int); + BOOL wglDeleteContext_Hook(HGLRC); + HGLRC wglGetCurrentContext_Hook(VOID); + HDC wglGetCurrentDC_Hook(VOID); + PROC wglGetProcAddress_Hook(LPCSTR); + BOOL wglMakeCurrent_Hook(HDC, HGLRC); + BOOL wglShareLists_Hook(HGLRC, HGLRC); + BOOL wglUseFontBitmapsA_Hook(HDC, DWORD, DWORD, DWORD); + BOOL wglUseFontBitmapsW_Hook(HDC, DWORD, DWORD, DWORD); + BOOL wglUseFontOutlinesA_Hook(HDC, DWORD, DWORD, DWORD, FLOAT, FLOAT, int, LPGLYPHMETRICSFLOAT); + BOOL wglUseFontOutlinesW_Hook(HDC, DWORD, DWORD, DWORD, FLOAT, FLOAT, int, LPGLYPHMETRICSFLOAT); + BOOL wglDescribeLayerPlane_Hook(HDC, int, int, UINT, LPLAYERPLANEDESCRIPTOR); + int wglSetLayerPaletteEntries_Hook(HDC, int, int, int, CONST COLORREF *); + int wglGetLayerPaletteEntries_Hook(HDC, int, int, int, COLORREF *); + BOOL wglRealizeLayerPalette_Hook(HDC, int, BOOL); + BOOL wglSwapLayerBuffers_Hook(HDC, UINT); + DWORD wglSwapMultipleBuffers_Hook(UINT, CONST WGLSWAP *); + */ + + // WGL_ARB_buffer_region + HANDLE wglCreateBufferRegionARB_Hook (HDC hDC, int iLayerPlane, UINT uType); + VOID wglDeleteBufferRegionARB_Hook (HANDLE hRegion); + BOOL wglSaveBufferRegionARB_Hook (HANDLE hRegion, int x, int y, int width, int height); + BOOL wglRestoreBufferRegionARB_Hook (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc); + + // WGL_ARB_extensions_string + const char * wglGetExtensionsStringARB_Hook (HDC hdc); + + // WGL_ARB_pixel_format + BOOL wglGetPixelFormatAttribivARB_Hook (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues); + BOOL wglGetPixelFormatAttribfvARB_Hook (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues); + BOOL wglChoosePixelFormatARB_Hook (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); + + // WGL_ARB_make_current_read + BOOL wglMakeContextCurrentARB_Hook (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); + HDC wglGetCurrentReadDCARB_Hook (void); + + // WGL_ARB_pbuffer + HPBUFFERARB wglCreatePbufferARB_Hook (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); + HDC wglGetPbufferDCARB_Hook (HPBUFFERARB hPbuffer); + int wglReleasePbufferDCARB_Hook (HPBUFFERARB hPbuffer, HDC hDC); + BOOL wglDestroyPbufferARB_Hook (HPBUFFERARB hPbuffer); + BOOL wglQueryPbufferARB_Hook (HPBUFFERARB hPbuffer, int iAttribute, int *piValue); + + // WGL_ARB_render_texture + BOOL wglBindTexImageARB_Hook (HPBUFFERARB hPbuffer, int iBuffer); + BOOL wglReleaseTexImageARB_Hook (HPBUFFERARB hPbuffer, int iBuffer); + BOOL wglSetPbufferAttribARB_Hook (HPBUFFERARB hPbuffer, const int *piAttribList); + + // WGL_NV_present_video + int wglEnumerateVideoDevicesNV_Hook (HDC hDC, HVIDEOOUTPUTDEVICENV *phDeviceList); + BOOL wglBindVideoDeviceNV_Hook (HDC hDC, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int *piAttribList); + BOOL wglQueryCurrentContextNV_Hook (int iAttribute, int *piValue); + + // WGL_ARB_create_context + HGLRC wglCreateContextAttribsARB_Hook (HDC hDC, HGLRC hShareContext, const int *attribList); + + // WGL_EXT_extensions_string + const char * wglGetExtensionsStringEXT_Hook (); + + // WGL_EXT_swap_control + BOOL wglSwapIntervalEXT_Hook(int interval); + int wglGetSwapIntervalEXT_Hook(); + + // WGL_OML_sync_control + BOOL wglGetSyncValuesOML_Hook (HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc); + BOOL wglGetMscRateOML_Hook (HDC hdc, INT32 *numerator, INT32 *denominator); + INT64 wglSwapBuffersMscOML_Hook (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder); + INT64 wglSwapLayerBuffersMscOML_Hook (HDC hdc, int fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder); + BOOL wglWaitForMscOML_Hook (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc); + BOOL wglWaitForSbcOML_Hook (HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc); + + // WGL_NV_video_output + BOOL wglGetVideoDeviceNV_Hook (HDC hDC, int numDevices, HPVIDEODEV *hVideoDevice); + BOOL wglReleaseVideoDeviceNV_Hook (HPVIDEODEV hVideoDevice); + BOOL wglBindVideoImageNV_Hook (HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer); + BOOL wglReleaseVideoImageNV_Hook (HPBUFFERARB hPbuffer, int iVideoBuffer); + BOOL wglSendPbufferToVideoNV_Hook (HPBUFFERARB hPbuffer, int iBufferType, unsigned long *pulCounterPbuffer, BOOL bBlock); + BOOL wglGetVideoInfoNV_Hook (HPVIDEODEV hpVideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo); + + // WGL_NV_swap_group + BOOL wglJoinSwapGroupNV_Hook (HDC hDC, GLuint group); + BOOL wglBindSwapBarrierNV_Hook (GLuint group, GLuint barrier); + BOOL wglQuerySwapGroupNV_Hook (HDC hDC, GLuint *group, GLuint *barrier); + BOOL wglQueryMaxSwapGroupsNV_Hook (HDC hDC, GLuint *maxGroups, GLuint *maxBarriers); + BOOL wglQueryFrameCountNV_Hook (HDC hDC, GLuint *count); + BOOL wglResetFrameCountNV_Hook (HDC hDC); + + // WGL_NV_video_capture + BOOL wglBindVideoCaptureDeviceNV_Hook (UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice); + UINT wglEnumerateVideoCaptureDevicesNV_Hook (HDC hDc, HVIDEOINPUTDEVICENV *phDeviceList); + BOOL wglLockVideoCaptureDeviceNV_Hook (HDC hDc, HVIDEOINPUTDEVICENV hDevice); + BOOL wglQueryVideoCaptureDeviceNV_Hook (HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int *piValue); + BOOL wglReleaseVideoCaptureDeviceNV_Hook (HDC hDc, HVIDEOINPUTDEVICENV hDevice); + + // WGL_NV_copy_image + BOOL wglCopyImageSubDataNV_Hook (HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); + + // WGL_NV_DX_interop + BOOL wglDXSetResourceShareHandleNV_Hook(void *dxObject, HANDLE shareHandle); + HANDLE wglDXOpenDeviceNV_Hook(void *dxDevice); + BOOL wglDXCloseDeviceNV_Hook(HANDLE hDevice); + HANDLE wglDXRegisterObjectNV_Hook(HANDLE hDevice, void *dxObject, GLuint name, GLenum type, GLenum access); + BOOL wglDXUnregisterObjectNV_Hook(HANDLE hDevice, HANDLE hObject); + BOOL wglDXObjectAccessNV_Hook(HANDLE hObject, GLenum access); + BOOL wglDXLockObjectsNV_Hook(HANDLE hDevice, GLint count, HANDLE *hObjects); + BOOL wglDXUnlockObjectsNV_Hook(HANDLE hDevice, GLint count, HANDLE *hObjects); + #endif // GLE_WGL_ENABLED + + #if defined(GLE_GLX_ENABLED) + void PostGLXHook(const char* functionName); + + // GLX_VERSION_1_0 + // GLX_VERSION_1_1 + // We don't currently do hooking of these. + + // GLX_VERSION_1_2 + ::Display* glXGetCurrentDisplay_Hook(void); + + // GLX_VERSION_1_3 + GLXFBConfig* glXChooseFBConfig_Hook(::Display *dpy, int screen, const int *attrib_list, int *nelements); + GLXContext glXCreateNewContext_Hook(::Display *dpy, GLXFBConfig config, int render_type, GLXContext share_list, Bool direct); + GLXPbuffer glXCreatePbuffer_Hook(::Display *dpy, GLXFBConfig config, const int *attrib_list); + GLXPixmap glXCreatePixmap_Hook(::Display *dpy, GLXFBConfig config, Pixmap pixmap, const int *attrib_list); + GLXWindow glXCreateWindow_Hook(::Display *dpy, GLXFBConfig config, Window win, const int *attrib_list); + void glXDestroyPbuffer_Hook(::Display *dpy, GLXPbuffer pbuf); + void glXDestroyPixmap_Hook(::Display *dpy, GLXPixmap pixmap); + void glXDestroyWindow_Hook(::Display *dpy, GLXWindow win); + GLXDrawable glXGetCurrentReadDrawable_Hook(void); + int glXGetFBConfigAttrib_Hook(::Display *dpy, GLXFBConfig config, int attribute, int *value); + GLXFBConfig* glXGetFBConfigs_Hook(::Display *dpy, int screen, int *nelements); + void glXGetSelectedEvent_Hook(::Display *dpy, GLXDrawable draw, unsigned long *event_mask); + XVisualInfo* glXGetVisualFromFBConfig_Hook(::Display *dpy, GLXFBConfig config); + Bool glXMakeContextCurrent_Hook(::Display *display, GLXDrawable draw, GLXDrawable read, GLXContext ctx); + int glXQueryContext_Hook(::Display *dpy, GLXContext ctx, int attribute, int *value); + void glXQueryDrawable_Hook(::Display *dpy, GLXDrawable draw, int attribute, unsigned int *value); + void glXSelectEvent_Hook(::Display *dpy, GLXDrawable draw, unsigned long event_mask); + + // GLX_VERSION_1_4 + // We don't do hooking of this. + + // GLX_ARB_create_context + GLXContext glXCreateContextAttribsARB_Hook(Display* dpy, GLXFBConfig config, GLXContext share_context, Bool direct, const int *attrib_list); + + // GLX_EXT_swap_control + void glXSwapIntervalEXT_Hook(::Display* dpy, GLXDrawable drawable, int interval); + + // GLX_OML_sync_control + Bool glXGetMscRateOML_Hook(::Display* dpy, GLXDrawable drawable, int32_t* numerator, int32_t* denominator); + Bool glXGetSyncValuesOML_Hook(::Display* dpy, GLXDrawable drawable, int64_t* ust, int64_t* msc, int64_t* sbc); + int64_t glXSwapBuffersMscOML_Hook(::Display* dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder); + Bool glXWaitForMscOML_Hook(::Display* dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder, int64_t* ust, int64_t* msc, int64_t* sbc); + Bool glXWaitForSbcOML_Hook(::Display* dpy, GLXDrawable drawable, int64_t target_sbc, int64_t* ust, int64_t* msc, int64_t* sbc); + + // GLX_MESA_swap_control + int glXGetSwapIntervalMESA_Hook(); + int glXSwapIntervalMESA_Hook(unsigned int interval); + + #endif // GLE_GLX_ENABLED + + #endif // #if defined(GLE_HOOKING_ENABLED) + + // GL_VERSION_1_1 + // These are not represented by function pointers. + + // GL_VERSION_1_2 + PFNGLCOPYTEXSUBIMAGE3DPROC glCopyTexSubImage3D_Impl; + PFNGLDRAWRANGEELEMENTSPROC glDrawRangeElements_Impl; + PFNGLTEXIMAGE3DPROC glTexImage3D_Impl; + PFNGLTEXSUBIMAGE3DPROC glTexSubImage3D_Impl; + + // GL_VERSION_1_2 deprecated functions + /* Not currently supported + PFNGLCOLORTABLEPROC glColorTable_Impl; + PFNGLCOLORTABLEPARAMETERFVPROC glColorTableParameterfv_Impl; + PFNGLCOLORTABLEPARAMETERIVPROC glColorTableParameteriv_Impl; + PFNGLCOPYCOLORTABLEPROC glCopyColorTable_Impl; + PFNGLGETCOLORTABLEPROC glGetColorTable_Impl; + PFNGLGETCOLORTABLEPARAMETERFVPROC glGetColorTableParameterfv_Impl; + PFNGLGETCOLORTABLEPARAMETERIVPROC glGetColorTableParameteriv_Impl; + PFNGLCOLORSUBTABLEPROC glColorSubTable_Impl; + PFNGLCOPYCOLORSUBTABLEPROC glCopyColorSubTable_Impl; + PFNGLCONVOLUTIONFILTER1DPROC glConvolutionFilter1D_Impl; + PFNGLCONVOLUTIONFILTER2DPROC glConvolutionFilter2D_Impl; + PFNGLCONVOLUTIONPARAMETERFPROC glConvolutionParameterf_Impl; + PFNGLCONVOLUTIONPARAMETERFVPROC glConvolutionParameterfv_Impl; + PFNGLCONVOLUTIONPARAMETERIPROC glConvolutionParameteri_Impl; + PFNGLCONVOLUTIONPARAMETERIVPROC glConvolutionParameteriv_Impl; + PFNGLCOPYCONVOLUTIONFILTER1DPROC glCopyConvolutionFilter1D_Impl; + PFNGLCOPYCONVOLUTIONFILTER2DPROC glCopyConvolutionFilter2D_Impl; + PFNGLGETCONVOLUTIONFILTERPROC glGetConvolutionFilter_Impl; + PFNGLGETCONVOLUTIONPARAMETERFVPROC glGetConvolutionParameterfv_Impl; + PFNGLGETCONVOLUTIONPARAMETERIVPROC glGetConvolutionParameteriv_Impl; + PFNGLGETSEPARABLEFILTERPROC glGetSeparableFilter_Impl; + PFNGLSEPARABLEFILTER2DPROC glSeparableFilter2D_Impl; + PFNGLGETHISTOGRAMPROC glGetHistogram_Impl; + PFNGLGETHISTOGRAMPARAMETERFVPROC glGetHistogramParameterfv_Impl; + PFNGLGETHISTOGRAMPARAMETERIVPROC glGetHistogramParameteriv_Impl; + PFNGLGETMINMAXPROC glGetMinmax_Impl; + PFNGLGETMINMAXPARAMETERFVPROC glGetMinmaxParameterfv_Impl; + PFNGLGETMINMAXPARAMETERIVPROC glGetMinmaxParameteriv_Impl; + PFNGLHISTOGRAMPROC glHistogram_Impl; + PFNGLMINMAXPROC glMinmax_Impl; + PFNGLRESETHISTOGRAMPROC glResetHistogram_Impl; + PFNGLRESETMINMAXPROC glResetMinmax_Impl; + */ + + // GL_VERSION_1_3 + PFNGLACTIVETEXTUREPROC glActiveTexture_Impl; + PFNGLCLIENTACTIVETEXTUREPROC glClientActiveTexture_Impl; + PFNGLCOMPRESSEDTEXIMAGE1DPROC glCompressedTexImage1D_Impl; + PFNGLCOMPRESSEDTEXIMAGE2DPROC glCompressedTexImage2D_Impl; + PFNGLCOMPRESSEDTEXIMAGE3DPROC glCompressedTexImage3D_Impl; + PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC glCompressedTexSubImage1D_Impl; + PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC glCompressedTexSubImage2D_Impl; + PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC glCompressedTexSubImage3D_Impl; + PFNGLGETCOMPRESSEDTEXIMAGEPROC glGetCompressedTexImage_Impl; + PFNGLLOADTRANSPOSEMATRIXDPROC glLoadTransposeMatrixd_Impl; + PFNGLLOADTRANSPOSEMATRIXFPROC glLoadTransposeMatrixf_Impl; + PFNGLMULTTRANSPOSEMATRIXDPROC glMultTransposeMatrixd_Impl; + PFNGLMULTTRANSPOSEMATRIXFPROC glMultTransposeMatrixf_Impl; + PFNGLMULTITEXCOORD1DPROC glMultiTexCoord1d_Impl; + PFNGLMULTITEXCOORD1DVPROC glMultiTexCoord1dv_Impl; + PFNGLMULTITEXCOORD1FPROC glMultiTexCoord1f_Impl; + PFNGLMULTITEXCOORD1FVPROC glMultiTexCoord1fv_Impl; + PFNGLMULTITEXCOORD1IPROC glMultiTexCoord1i_Impl; + PFNGLMULTITEXCOORD1IVPROC glMultiTexCoord1iv_Impl; + PFNGLMULTITEXCOORD1SPROC glMultiTexCoord1s_Impl; + PFNGLMULTITEXCOORD1SVPROC glMultiTexCoord1sv_Impl; + PFNGLMULTITEXCOORD2DPROC glMultiTexCoord2d_Impl; + PFNGLMULTITEXCOORD2DVPROC glMultiTexCoord2dv_Impl; + PFNGLMULTITEXCOORD2FPROC glMultiTexCoord2f_Impl; + PFNGLMULTITEXCOORD2FVPROC glMultiTexCoord2fv_Impl; + PFNGLMULTITEXCOORD2IPROC glMultiTexCoord2i_Impl; + PFNGLMULTITEXCOORD2IVPROC glMultiTexCoord2iv_Impl; + PFNGLMULTITEXCOORD2SPROC glMultiTexCoord2s_Impl; + PFNGLMULTITEXCOORD2SVPROC glMultiTexCoord2sv_Impl; + PFNGLMULTITEXCOORD3DPROC glMultiTexCoord3d_Impl; + PFNGLMULTITEXCOORD3DVPROC glMultiTexCoord3dv_Impl; + PFNGLMULTITEXCOORD3FPROC glMultiTexCoord3f_Impl; + PFNGLMULTITEXCOORD3FVPROC glMultiTexCoord3fv_Impl; + PFNGLMULTITEXCOORD3IPROC glMultiTexCoord3i_Impl; + PFNGLMULTITEXCOORD3IVPROC glMultiTexCoord3iv_Impl; + PFNGLMULTITEXCOORD3SPROC glMultiTexCoord3s_Impl; + PFNGLMULTITEXCOORD3SVPROC glMultiTexCoord3sv_Impl; + PFNGLMULTITEXCOORD4DPROC glMultiTexCoord4d_Impl; + PFNGLMULTITEXCOORD4DVPROC glMultiTexCoord4dv_Impl; + PFNGLMULTITEXCOORD4FPROC glMultiTexCoord4f_Impl; + PFNGLMULTITEXCOORD4FVPROC glMultiTexCoord4fv_Impl; + PFNGLMULTITEXCOORD4IPROC glMultiTexCoord4i_Impl; + PFNGLMULTITEXCOORD4IVPROC glMultiTexCoord4iv_Impl; + PFNGLMULTITEXCOORD4SPROC glMultiTexCoord4s_Impl; + PFNGLMULTITEXCOORD4SVPROC glMultiTexCoord4sv_Impl; + PFNGLSAMPLECOVERAGEPROC glSampleCoverage_Impl; + + // GL_VERSION_1_4 + PFNGLBLENDCOLORPROC glBlendColor_Impl; + PFNGLBLENDEQUATIONPROC glBlendEquation_Impl; + PFNGLBLENDFUNCSEPARATEPROC glBlendFuncSeparate_Impl; + PFNGLFOGCOORDPOINTERPROC glFogCoordPointer_Impl; + PFNGLFOGCOORDDPROC glFogCoordd_Impl; + PFNGLFOGCOORDDVPROC glFogCoorddv_Impl; + PFNGLFOGCOORDFPROC glFogCoordf_Impl; + PFNGLFOGCOORDFVPROC glFogCoordfv_Impl; + PFNGLMULTIDRAWARRAYSPROC glMultiDrawArrays_Impl; + PFNGLMULTIDRAWELEMENTSPROC glMultiDrawElements_Impl; + PFNGLPOINTPARAMETERFPROC glPointParameterf_Impl; + PFNGLPOINTPARAMETERFVPROC glPointParameterfv_Impl; + PFNGLPOINTPARAMETERIPROC glPointParameteri_Impl; + PFNGLPOINTPARAMETERIVPROC glPointParameteriv_Impl; + PFNGLSECONDARYCOLOR3BPROC glSecondaryColor3b_Impl; + PFNGLSECONDARYCOLOR3BVPROC glSecondaryColor3bv_Impl; + PFNGLSECONDARYCOLOR3DPROC glSecondaryColor3d_Impl; + PFNGLSECONDARYCOLOR3DVPROC glSecondaryColor3dv_Impl; + PFNGLSECONDARYCOLOR3FPROC glSecondaryColor3f_Impl; + PFNGLSECONDARYCOLOR3FVPROC glSecondaryColor3fv_Impl; + PFNGLSECONDARYCOLOR3IPROC glSecondaryColor3i_Impl; + PFNGLSECONDARYCOLOR3IVPROC glSecondaryColor3iv_Impl; + PFNGLSECONDARYCOLOR3SPROC glSecondaryColor3s_Impl; + PFNGLSECONDARYCOLOR3SVPROC glSecondaryColor3sv_Impl; + PFNGLSECONDARYCOLOR3UBPROC glSecondaryColor3ub_Impl; + PFNGLSECONDARYCOLOR3UBVPROC glSecondaryColor3ubv_Impl; + PFNGLSECONDARYCOLOR3UIPROC glSecondaryColor3ui_Impl; + PFNGLSECONDARYCOLOR3UIVPROC glSecondaryColor3uiv_Impl; + PFNGLSECONDARYCOLOR3USPROC glSecondaryColor3us_Impl; + PFNGLSECONDARYCOLOR3USVPROC glSecondaryColor3usv_Impl; + PFNGLSECONDARYCOLORPOINTERPROC glSecondaryColorPointer_Impl; + PFNGLWINDOWPOS2DPROC glWindowPos2d_Impl; + PFNGLWINDOWPOS2DVPROC glWindowPos2dv_Impl; + PFNGLWINDOWPOS2FPROC glWindowPos2f_Impl; + PFNGLWINDOWPOS2FVPROC glWindowPos2fv_Impl; + PFNGLWINDOWPOS2IPROC glWindowPos2i_Impl; + PFNGLWINDOWPOS2IVPROC glWindowPos2iv_Impl; + PFNGLWINDOWPOS2SPROC glWindowPos2s_Impl; + PFNGLWINDOWPOS2SVPROC glWindowPos2sv_Impl; + PFNGLWINDOWPOS3DPROC glWindowPos3d_Impl; + PFNGLWINDOWPOS3DVPROC glWindowPos3dv_Impl; + PFNGLWINDOWPOS3FPROC glWindowPos3f_Impl; + PFNGLWINDOWPOS3FVPROC glWindowPos3fv_Impl; + PFNGLWINDOWPOS3IPROC glWindowPos3i_Impl; + PFNGLWINDOWPOS3IVPROC glWindowPos3iv_Impl; + PFNGLWINDOWPOS3SPROC glWindowPos3s_Impl; + PFNGLWINDOWPOS3SVPROC glWindowPos3sv_Impl; + + // GL_VERSION_1_5 + PFNGLBEGINQUERYPROC glBeginQuery_Impl; + PFNGLBINDBUFFERPROC glBindBuffer_Impl; + PFNGLBUFFERDATAPROC glBufferData_Impl; + PFNGLBUFFERSUBDATAPROC glBufferSubData_Impl; + PFNGLDELETEBUFFERSPROC glDeleteBuffers_Impl; + PFNGLDELETEQUERIESPROC glDeleteQueries_Impl; + PFNGLENDQUERYPROC glEndQuery_Impl; + PFNGLGENBUFFERSPROC glGenBuffers_Impl; + PFNGLGENQUERIESPROC glGenQueries_Impl; + PFNGLGETBUFFERPARAMETERIVPROC glGetBufferParameteriv_Impl; + PFNGLGETBUFFERPOINTERVPROC glGetBufferPointerv_Impl; + PFNGLGETBUFFERSUBDATAPROC glGetBufferSubData_Impl; + PFNGLGETQUERYOBJECTIVPROC glGetQueryObjectiv_Impl; + PFNGLGETQUERYOBJECTUIVPROC glGetQueryObjectuiv_Impl; + PFNGLGETQUERYIVPROC glGetQueryiv_Impl; + PFNGLISBUFFERPROC glIsBuffer_Impl; + PFNGLISQUERYPROC glIsQuery_Impl; + PFNGLMAPBUFFERPROC glMapBuffer_Impl; + PFNGLUNMAPBUFFERPROC glUnmapBuffer_Impl; + + // GL_VERSION_2_0 + PFNGLATTACHSHADERPROC glAttachShader_Impl; + PFNGLBINDATTRIBLOCATIONPROC glBindAttribLocation_Impl; + PFNGLBLENDEQUATIONSEPARATEPROC glBlendEquationSeparate_Impl; + PFNGLCOMPILESHADERPROC glCompileShader_Impl; + PFNGLCREATEPROGRAMPROC glCreateProgram_Impl; + PFNGLCREATESHADERPROC glCreateShader_Impl; + PFNGLDELETEPROGRAMPROC glDeleteProgram_Impl; + PFNGLDELETESHADERPROC glDeleteShader_Impl; + PFNGLDETACHSHADERPROC glDetachShader_Impl; + PFNGLDISABLEVERTEXATTRIBARRAYPROC glDisableVertexAttribArray_Impl; + PFNGLDRAWBUFFERSPROC glDrawBuffers_Impl; + PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray_Impl; + PFNGLGETACTIVEATTRIBPROC glGetActiveAttrib_Impl; + PFNGLGETACTIVEUNIFORMPROC glGetActiveUniform_Impl; + PFNGLGETATTACHEDSHADERSPROC glGetAttachedShaders_Impl; + PFNGLGETATTRIBLOCATIONPROC glGetAttribLocation_Impl; + PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog_Impl; + PFNGLGETPROGRAMIVPROC glGetProgramiv_Impl; + PFNGLGETSHADERINFOLOGPROC glGetShaderInfoLog_Impl; + PFNGLGETSHADERSOURCEPROC glGetShaderSource_Impl; + PFNGLGETSHADERIVPROC glGetShaderiv_Impl; + PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation_Impl; + PFNGLGETUNIFORMFVPROC glGetUniformfv_Impl; + PFNGLGETUNIFORMIVPROC glGetUniformiv_Impl; + PFNGLGETVERTEXATTRIBPOINTERVPROC glGetVertexAttribPointerv_Impl; + PFNGLGETVERTEXATTRIBDVPROC glGetVertexAttribdv_Impl; + PFNGLGETVERTEXATTRIBFVPROC glGetVertexAttribfv_Impl; + PFNGLGETVERTEXATTRIBIVPROC glGetVertexAttribiv_Impl; + PFNGLISPROGRAMPROC glIsProgram_Impl; + PFNGLISSHADERPROC glIsShader_Impl; + PFNGLLINKPROGRAMPROC glLinkProgram_Impl; + PFNGLSHADERSOURCEPROC glShaderSource_Impl; + PFNGLSTENCILFUNCSEPARATEPROC glStencilFuncSeparate_Impl; + PFNGLSTENCILMASKSEPARATEPROC glStencilMaskSeparate_Impl; + PFNGLSTENCILOPSEPARATEPROC glStencilOpSeparate_Impl; + PFNGLUNIFORM1FPROC glUniform1f_Impl; + PFNGLUNIFORM1FVPROC glUniform1fv_Impl; + PFNGLUNIFORM1IPROC glUniform1i_Impl; + PFNGLUNIFORM1IVPROC glUniform1iv_Impl; + PFNGLUNIFORM2FPROC glUniform2f_Impl; + PFNGLUNIFORM2FVPROC glUniform2fv_Impl; + PFNGLUNIFORM2IPROC glUniform2i_Impl; + PFNGLUNIFORM2IVPROC glUniform2iv_Impl; + PFNGLUNIFORM3FPROC glUniform3f_Impl; + PFNGLUNIFORM3FVPROC glUniform3fv_Impl; + PFNGLUNIFORM3IPROC glUniform3i_Impl; + PFNGLUNIFORM3IVPROC glUniform3iv_Impl; + PFNGLUNIFORM4FPROC glUniform4f_Impl; + PFNGLUNIFORM4FVPROC glUniform4fv_Impl; + PFNGLUNIFORM4IPROC glUniform4i_Impl; + PFNGLUNIFORM4IVPROC glUniform4iv_Impl; + PFNGLUNIFORMMATRIX2FVPROC glUniformMatrix2fv_Impl; + PFNGLUNIFORMMATRIX3FVPROC glUniformMatrix3fv_Impl; + PFNGLUNIFORMMATRIX4FVPROC glUniformMatrix4fv_Impl; + PFNGLUSEPROGRAMPROC glUseProgram_Impl; + PFNGLVALIDATEPROGRAMPROC glValidateProgram_Impl; + PFNGLVERTEXATTRIB1DPROC glVertexAttrib1d_Impl; + PFNGLVERTEXATTRIB1DVPROC glVertexAttrib1dv_Impl; + PFNGLVERTEXATTRIB1FPROC glVertexAttrib1f_Impl; + PFNGLVERTEXATTRIB1FVPROC glVertexAttrib1fv_Impl; + PFNGLVERTEXATTRIB1SPROC glVertexAttrib1s_Impl; + PFNGLVERTEXATTRIB1SVPROC glVertexAttrib1sv_Impl; + PFNGLVERTEXATTRIB2DPROC glVertexAttrib2d_Impl; + PFNGLVERTEXATTRIB2DVPROC glVertexAttrib2dv_Impl; + PFNGLVERTEXATTRIB2FPROC glVertexAttrib2f_Impl; + PFNGLVERTEXATTRIB2FVPROC glVertexAttrib2fv_Impl; + PFNGLVERTEXATTRIB2SPROC glVertexAttrib2s_Impl; + PFNGLVERTEXATTRIB2SVPROC glVertexAttrib2sv_Impl; + PFNGLVERTEXATTRIB3DPROC glVertexAttrib3d_Impl; + PFNGLVERTEXATTRIB3DVPROC glVertexAttrib3dv_Impl; + PFNGLVERTEXATTRIB3FPROC glVertexAttrib3f_Impl; + PFNGLVERTEXATTRIB3FVPROC glVertexAttrib3fv_Impl; + PFNGLVERTEXATTRIB3SPROC glVertexAttrib3s_Impl; + PFNGLVERTEXATTRIB3SVPROC glVertexAttrib3sv_Impl; + PFNGLVERTEXATTRIB4NBVPROC glVertexAttrib4Nbv_Impl; + PFNGLVERTEXATTRIB4NIVPROC glVertexAttrib4Niv_Impl; + PFNGLVERTEXATTRIB4NSVPROC glVertexAttrib4Nsv_Impl; + PFNGLVERTEXATTRIB4NUBPROC glVertexAttrib4Nub_Impl; + PFNGLVERTEXATTRIB4NUBVPROC glVertexAttrib4Nubv_Impl; + PFNGLVERTEXATTRIB4NUIVPROC glVertexAttrib4Nuiv_Impl; + PFNGLVERTEXATTRIB4NUSVPROC glVertexAttrib4Nusv_Impl; + PFNGLVERTEXATTRIB4BVPROC glVertexAttrib4bv_Impl; + PFNGLVERTEXATTRIB4DPROC glVertexAttrib4d_Impl; + PFNGLVERTEXATTRIB4DVPROC glVertexAttrib4dv_Impl; + PFNGLVERTEXATTRIB4FPROC glVertexAttrib4f_Impl; + PFNGLVERTEXATTRIB4FVPROC glVertexAttrib4fv_Impl; + PFNGLVERTEXATTRIB4IVPROC glVertexAttrib4iv_Impl; + PFNGLVERTEXATTRIB4SPROC glVertexAttrib4s_Impl; + PFNGLVERTEXATTRIB4SVPROC glVertexAttrib4sv_Impl; + PFNGLVERTEXATTRIB4UBVPROC glVertexAttrib4ubv_Impl; + PFNGLVERTEXATTRIB4UIVPROC glVertexAttrib4uiv_Impl; + PFNGLVERTEXATTRIB4USVPROC glVertexAttrib4usv_Impl; + PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer_Impl; + + // GL_VERSION_2_1 + PFNGLUNIFORMMATRIX2X3FVPROC glUniformMatrix2x3fv_Impl; + PFNGLUNIFORMMATRIX2X4FVPROC glUniformMatrix2x4fv_Impl; + PFNGLUNIFORMMATRIX3X2FVPROC glUniformMatrix3x2fv_Impl; + PFNGLUNIFORMMATRIX3X4FVPROC glUniformMatrix3x4fv_Impl; + PFNGLUNIFORMMATRIX4X2FVPROC glUniformMatrix4x2fv_Impl; + PFNGLUNIFORMMATRIX4X3FVPROC glUniformMatrix4x3fv_Impl; + + // GL_VERSION_3_0 + PFNGLBEGINCONDITIONALRENDERPROC glBeginConditionalRender_Impl; + PFNGLBEGINTRANSFORMFEEDBACKPROC glBeginTransformFeedback_Impl; + PFNGLBINDFRAGDATALOCATIONPROC glBindFragDataLocation_Impl; + PFNGLCLAMPCOLORPROC glClampColor_Impl; + PFNGLCLEARBUFFERFIPROC glClearBufferfi_Impl; + PFNGLCLEARBUFFERFVPROC glClearBufferfv_Impl; + PFNGLCLEARBUFFERIVPROC glClearBufferiv_Impl; + PFNGLCLEARBUFFERUIVPROC glClearBufferuiv_Impl; + PFNGLCOLORMASKIPROC glColorMaski_Impl; + PFNGLDISABLEIPROC glDisablei_Impl; + PFNGLENABLEIPROC glEnablei_Impl; + PFNGLENDCONDITIONALRENDERPROC glEndConditionalRender_Impl; + PFNGLENDTRANSFORMFEEDBACKPROC glEndTransformFeedback_Impl; + PFNGLBINDBUFFERRANGEPROC glBindBufferRange_Impl; + PFNGLBINDBUFFERBASEPROC glBindBufferBase_Impl; + PFNGLGETBOOLEANI_VPROC glGetBooleani_v_Impl; + PFNGLGETINTEGERI_VPROC glGetIntegeri_v_Impl; + PFNGLGETFRAGDATALOCATIONPROC glGetFragDataLocation_Impl; + PFNGLGETSTRINGIPROC glGetStringi_Impl; + PFNGLGETTEXPARAMETERIIVPROC glGetTexParameterIiv_Impl; + PFNGLGETTEXPARAMETERIUIVPROC glGetTexParameterIuiv_Impl; + PFNGLGETTRANSFORMFEEDBACKVARYINGPROC glGetTransformFeedbackVarying_Impl; + PFNGLGETUNIFORMUIVPROC glGetUniformuiv_Impl; + PFNGLGETVERTEXATTRIBIIVPROC glGetVertexAttribIiv_Impl; + PFNGLGETVERTEXATTRIBIUIVPROC glGetVertexAttribIuiv_Impl; + PFNGLISENABLEDIPROC glIsEnabledi_Impl; + PFNGLTEXPARAMETERIIVPROC glTexParameterIiv_Impl; + PFNGLTEXPARAMETERIUIVPROC glTexParameterIuiv_Impl; + PFNGLTRANSFORMFEEDBACKVARYINGSPROC glTransformFeedbackVaryings_Impl; + PFNGLUNIFORM1UIPROC glUniform1ui_Impl; + PFNGLUNIFORM1UIVPROC glUniform1uiv_Impl; + PFNGLUNIFORM2UIPROC glUniform2ui_Impl; + PFNGLUNIFORM2UIVPROC glUniform2uiv_Impl; + PFNGLUNIFORM3UIPROC glUniform3ui_Impl; + PFNGLUNIFORM3UIVPROC glUniform3uiv_Impl; + PFNGLUNIFORM4UIPROC glUniform4ui_Impl; + PFNGLUNIFORM4UIVPROC glUniform4uiv_Impl; + PFNGLVERTEXATTRIBI1IPROC glVertexAttribI1i_Impl; + PFNGLVERTEXATTRIBI1IVPROC glVertexAttribI1iv_Impl; + PFNGLVERTEXATTRIBI1UIPROC glVertexAttribI1ui_Impl; + PFNGLVERTEXATTRIBI1UIVPROC glVertexAttribI1uiv_Impl; + PFNGLVERTEXATTRIBI2IPROC glVertexAttribI2i_Impl; + PFNGLVERTEXATTRIBI2IVPROC glVertexAttribI2iv_Impl; + PFNGLVERTEXATTRIBI2UIPROC glVertexAttribI2ui_Impl; + PFNGLVERTEXATTRIBI2UIVPROC glVertexAttribI2uiv_Impl; + PFNGLVERTEXATTRIBI3IPROC glVertexAttribI3i_Impl; + PFNGLVERTEXATTRIBI3IVPROC glVertexAttribI3iv_Impl; + PFNGLVERTEXATTRIBI3UIPROC glVertexAttribI3ui_Impl; + PFNGLVERTEXATTRIBI3UIVPROC glVertexAttribI3uiv_Impl; + PFNGLVERTEXATTRIBI4BVPROC glVertexAttribI4bv_Impl; + PFNGLVERTEXATTRIBI4IPROC glVertexAttribI4i_Impl; + PFNGLVERTEXATTRIBI4IVPROC glVertexAttribI4iv_Impl; + PFNGLVERTEXATTRIBI4SVPROC glVertexAttribI4sv_Impl; + PFNGLVERTEXATTRIBI4UBVPROC glVertexAttribI4ubv_Impl; + PFNGLVERTEXATTRIBI4UIPROC glVertexAttribI4ui_Impl; + PFNGLVERTEXATTRIBI4UIVPROC glVertexAttribI4uiv_Impl; + PFNGLVERTEXATTRIBI4USVPROC glVertexAttribI4usv_Impl; + PFNGLVERTEXATTRIBIPOINTERPROC glVertexAttribIPointer_Impl; + + // GL_VERSION_3_1 + PFNGLDRAWARRAYSINSTANCEDPROC glDrawArraysInstanced_Impl; + PFNGLDRAWELEMENTSINSTANCEDPROC glDrawElementsInstanced_Impl; + PFNGLPRIMITIVERESTARTINDEXPROC glPrimitiveRestartIndex_Impl; + PFNGLTEXBUFFERPROC glTexBuffer_Impl; + + // GL_VERSION_3_2 + PFNGLFRAMEBUFFERTEXTUREPROC glFramebufferTexture_Impl; + PFNGLGETBUFFERPARAMETERI64VPROC glGetBufferParameteri64v_Impl; + PFNGLGETINTEGER64I_VPROC glGetInteger64i_v_Impl; + + // GL_VERSION_3_3 + PFNGLVERTEXATTRIBDIVISORPROC glVertexAttribDivisor_Impl; + + // GL_VERSION_4_0 + PFNGLBLENDEQUATIONSEPARATEIPROC glBlendEquationSeparatei_Impl; + PFNGLBLENDEQUATIONIPROC glBlendEquationi_Impl; + PFNGLBLENDFUNCSEPARATEIPROC glBlendFuncSeparatei_Impl; + PFNGLBLENDFUNCIPROC glBlendFunci_Impl; + PFNGLMINSAMPLESHADINGPROC glMinSampleShading_Impl; + + // GL_AMD_debug_output + PFNGLDEBUGMESSAGECALLBACKAMDPROC glDebugMessageCallbackAMD_Impl; + PFNGLDEBUGMESSAGEENABLEAMDPROC glDebugMessageEnableAMD_Impl; + PFNGLDEBUGMESSAGEINSERTAMDPROC glDebugMessageInsertAMD_Impl; + PFNGLGETDEBUGMESSAGELOGAMDPROC glGetDebugMessageLogAMD_Impl; + + #if defined(GLE_CGL_ENABLED) + // GL_APPLE_aux_depth_stencil + // (no functions) + + // GL_APPLE_client_storage + // (no functions) + + // GL_APPLE_element_array + PFNGLDRAWELEMENTARRAYAPPLEPROC glDrawElementArrayAPPLE_Impl; + PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC glDrawRangeElementArrayAPPLE_Impl; + PFNGLELEMENTPOINTERAPPLEPROC glElementPointerAPPLE_Impl; + PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC glMultiDrawElementArrayAPPLE_Impl; + PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC glMultiDrawRangeElementArrayAPPLE_Impl; + + // GL_APPLE_fence + PFNGLDELETEFENCESAPPLEPROC glDeleteFencesAPPLE_Impl; + PFNGLFINISHFENCEAPPLEPROC glFinishFenceAPPLE_Impl; + PFNGLFINISHOBJECTAPPLEPROC glFinishObjectAPPLE_Impl; + PFNGLGENFENCESAPPLEPROC glGenFencesAPPLE_Impl; + PFNGLISFENCEAPPLEPROC glIsFenceAPPLE_Impl; + PFNGLSETFENCEAPPLEPROC glSetFenceAPPLE_Impl; + PFNGLTESTFENCEAPPLEPROC glTestFenceAPPLE_Impl; + PFNGLTESTOBJECTAPPLEPROC glTestObjectAPPLE_Impl; + + // GL_APPLE_float_pixels + // (no functions) + + // GL_APPLE_flush_buffer_range + PFNGLBUFFERPARAMETERIAPPLEPROC glBufferParameteriAPPLE_Impl; + PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC glFlushMappedBufferRangeAPPLE_Impl; + + // GL_APPLE_object_purgeable + PFNGLGETOBJECTPARAMETERIVAPPLEPROC glGetObjectParameterivAPPLE_Impl; + PFNGLOBJECTPURGEABLEAPPLEPROC glObjectPurgeableAPPLE_Impl; + PFNGLOBJECTUNPURGEABLEAPPLEPROC glObjectUnpurgeableAPPLE_Impl; + + // GL_APPLE_pixel_buffer + // (no functions) + + // GL_APPLE_rgb_422 + // (no functions) + + // GL_APPLE_row_bytes + // (no functions) + + // GL_APPLE_specular_vector + // (no functions) + + // GL_APPLE_texture_range + PFNGLGETTEXPARAMETERPOINTERVAPPLEPROC glGetTexParameterPointervAPPLE_Impl; + PFNGLTEXTURERANGEAPPLEPROC glTextureRangeAPPLE_Impl; + + // GL_APPLE_transform_hint + // (no functions) + + // GL_APPLE_vertex_array_object + PFNGLBINDVERTEXARRAYAPPLEPROC glBindVertexArrayAPPLE_Impl; + PFNGLDELETEVERTEXARRAYSAPPLEPROC glDeleteVertexArraysAPPLE_Impl; + PFNGLGENVERTEXARRAYSAPPLEPROC glGenVertexArraysAPPLE_Impl; + PFNGLISVERTEXARRAYAPPLEPROC glIsVertexArrayAPPLE_Impl; + + // GL_APPLE_vertex_array_range + PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC glFlushVertexArrayRangeAPPLE_Impl; + PFNGLVERTEXARRAYPARAMETERIAPPLEPROC glVertexArrayParameteriAPPLE_Impl; + PFNGLVERTEXARRAYRANGEAPPLEPROC glVertexArrayRangeAPPLE_Impl; + + // GL_APPLE_vertex_program_evaluators + PFNGLDISABLEVERTEXATTRIBAPPLEPROC glDisableVertexAttribAPPLE_Impl; + PFNGLENABLEVERTEXATTRIBAPPLEPROC glEnableVertexAttribAPPLE_Impl; + PFNGLISVERTEXATTRIBENABLEDAPPLEPROC glIsVertexAttribEnabledAPPLE_Impl; + PFNGLMAPVERTEXATTRIB1DAPPLEPROC glMapVertexAttrib1dAPPLE_Impl; + PFNGLMAPVERTEXATTRIB1FAPPLEPROC glMapVertexAttrib1fAPPLE_Impl; + PFNGLMAPVERTEXATTRIB2DAPPLEPROC glMapVertexAttrib2dAPPLE_Impl; + PFNGLMAPVERTEXATTRIB2FAPPLEPROC glMapVertexAttrib2fAPPLE_Impl; + #endif // GLE_CGL_ENABLED + + // GL_ARB_debug_output + PFNGLDEBUGMESSAGECALLBACKARBPROC glDebugMessageCallbackARB_Impl; + PFNGLDEBUGMESSAGECONTROLARBPROC glDebugMessageControlARB_Impl; + PFNGLDEBUGMESSAGEINSERTARBPROC glDebugMessageInsertARB_Impl; + PFNGLGETDEBUGMESSAGELOGARBPROC glGetDebugMessageLogARB_Impl; + + // GL_ARB_ES2_compatibility + PFNGLCLEARDEPTHFPROC glClearDepthf_Impl; + PFNGLDEPTHRANGEFPROC glDepthRangef_Impl; + PFNGLGETSHADERPRECISIONFORMATPROC glGetShaderPrecisionFormat_Impl; + PFNGLRELEASESHADERCOMPILERPROC glReleaseShaderCompiler_Impl; + PFNGLSHADERBINARYPROC glShaderBinary_Impl; + + // GL_ARB_framebuffer_object + PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer_Impl; + PFNGLBINDRENDERBUFFERPROC glBindRenderbuffer_Impl; + PFNGLBLITFRAMEBUFFERPROC glBlitFramebuffer_Impl; + PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus_Impl; + PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers_Impl; + PFNGLDELETERENDERBUFFERSPROC glDeleteRenderbuffers_Impl; + PFNGLFRAMEBUFFERRENDERBUFFERPROC glFramebufferRenderbuffer_Impl; + PFNGLFRAMEBUFFERTEXTURE1DPROC glFramebufferTexture1D_Impl; + PFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D_Impl; + PFNGLFRAMEBUFFERTEXTURE3DPROC glFramebufferTexture3D_Impl; + PFNGLFRAMEBUFFERTEXTURELAYERPROC glFramebufferTextureLayer_Impl; + PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers_Impl; + PFNGLGENRENDERBUFFERSPROC glGenRenderbuffers_Impl; + PFNGLGENERATEMIPMAPPROC glGenerateMipmap_Impl; + PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC glGetFramebufferAttachmentParameteriv_Impl; + PFNGLGETRENDERBUFFERPARAMETERIVPROC glGetRenderbufferParameteriv_Impl; + PFNGLISFRAMEBUFFERPROC glIsFramebuffer_Impl; + PFNGLISRENDERBUFFERPROC glIsRenderbuffer_Impl; + PFNGLRENDERBUFFERSTORAGEPROC glRenderbufferStorage_Impl; + PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC glRenderbufferStorageMultisample_Impl; + + // GL_ARB_framebuffer_sRGB + // (no functions) + + // GL_ARB_texture_multisample + PFNGLGETMULTISAMPLEFVPROC glGetMultisamplefv_Impl; + PFNGLSAMPLEMASKIPROC glSampleMaski_Impl; + PFNGLTEXIMAGE2DMULTISAMPLEPROC glTexImage2DMultisample_Impl; + PFNGLTEXIMAGE3DMULTISAMPLEPROC glTexImage3DMultisample_Impl; + + // GL_ARB_texture_non_power_of_two + // (no functions) + + // GL_ARB_texture_rectangle + // (no functions) + + // GL_ARB_timer_query + PFNGLGETQUERYOBJECTI64VPROC glGetQueryObjecti64v_Impl; + PFNGLGETQUERYOBJECTUI64VPROC glGetQueryObjectui64v_Impl; + PFNGLQUERYCOUNTERPROC glQueryCounter_Impl; + + // GL_ARB_vertex_array_object + PFNGLBINDVERTEXARRAYPROC glBindVertexArray_Impl; + PFNGLDELETEVERTEXARRAYSPROC glDeleteVertexArrays_Impl; + PFNGLGENVERTEXARRAYSPROC glGenVertexArrays_Impl; + PFNGLISVERTEXARRAYPROC glIsVertexArray_Impl; + + // GL_EXT_draw_buffers2 + PFNGLCOLORMASKINDEXEDEXTPROC glColorMaskIndexedEXT_Impl; + PFNGLDISABLEINDEXEDEXTPROC glDisableIndexedEXT_Impl; + PFNGLENABLEINDEXEDEXTPROC glEnableIndexedEXT_Impl; + PFNGLGETBOOLEANINDEXEDVEXTPROC glGetBooleanIndexedvEXT_Impl; + PFNGLGETINTEGERINDEXEDVEXTPROC glGetIntegerIndexedvEXT_Impl; + PFNGLISENABLEDINDEXEDEXTPROC glIsEnabledIndexedEXT_Impl; + + // GL_EXT_texture_filter_anisotropic + // (no functions) + + // GL_KHR_debug + PFNGLDEBUGMESSAGECALLBACKPROC glDebugMessageCallback_Impl; + PFNGLDEBUGMESSAGECONTROLPROC glDebugMessageControl_Impl; + PFNGLDEBUGMESSAGEINSERTPROC glDebugMessageInsert_Impl; + PFNGLGETDEBUGMESSAGELOGPROC glGetDebugMessageLog_Impl; + PFNGLGETOBJECTLABELPROC glGetObjectLabel_Impl; + PFNGLGETOBJECTPTRLABELPROC glGetObjectPtrLabel_Impl; + PFNGLOBJECTLABELPROC glObjectLabel_Impl; + PFNGLOBJECTPTRLABELPROC glObjectPtrLabel_Impl; + PFNGLPOPDEBUGGROUPPROC glPopDebugGroup_Impl; + PFNGLPUSHDEBUGGROUPPROC glPushDebugGroup_Impl; + + // GL_KHR_robust_buffer_access_behavior + + // GL_WIN_swap_hint + PFNGLADDSWAPHINTRECTWINPROC glAddSwapHintRectWIN_Impl; + + #if defined(GLE_WGL_ENABLED) + // WGL + // We don't declare pointers for these because we statically link to the implementations, same as with the OpenGL 1.1 functions. + // BOOL wglCopyContext_Hook(HGLRC, HGLRC, UINT); + // HGLRC wglCreateContext_Hook(HDC); + // HGLRC wglCreateLayerContext_Hook(HDC, int); + // BOOL wglDeleteContext_Hook(HGLRC); + // HGLRC wglGetCurrentContext_Hook(VOID); + // HDC wglGetCurrentDC_Hook(VOID); + // PROC wglGetProcAddress_Hook(LPCSTR); + // BOOL wglMakeCurrent_Hook(HDC, HGLRC); + // BOOL wglShareLists_Hook(HGLRC, HGLRC); + // BOOL wglUseFontBitmapsA_Hook(HDC, DWORD, DWORD, DWORD); + // BOOL wglUseFontBitmapsW_Hook(HDC, DWORD, DWORD, DWORD); + // BOOL wglUseFontOutlinesA_Hook(HDC, DWORD, DWORD, DWORD, FLOAT, FLOAT, int, LPGLYPHMETRICSFLOAT); + // BOOL wglUseFontOutlinesW_Hook(HDC, DWORD, DWORD, DWORD, FLOAT, FLOAT, int, LPGLYPHMETRICSFLOAT); + // BOOL wglDescribeLayerPlane_Hook(HDC, int, int, UINT, LPLAYERPLANEDESCRIPTOR); + // int wglSetLayerPaletteEntries_Hook(HDC, int, int, int, CONST COLORREF *); + // int wglGetLayerPaletteEntries_Hook(HDC, int, int, int, COLORREF *); + // BOOL wglRealizeLayerPalette_Hook(HDC, int, BOOL); + // BOOL wglSwapLayerBuffers_Hook(HDC, UINT); + // DWORD wglSwapMultipleBuffers_Hook(UINT, CONST WGLSWAP *); + + #if 0 + PFNWGLCOPYCONTEXTPROC wglCopyContext_Impl; + PFNWGLCREATECONTEXTPROC wglCreateContext_Impl; + PFNWGLCREATELAYERCONTEXTPROC wglCreateLayerContext_Impl; + PFNWGLDELETECONTEXTPROC wglDeleteContext_Impl; + PFNWGLGETCURRENTCONTEXTPROC wglGetCurrentContext_Impl; + PFNWGLGETCURRENTDCPROC wglGetCurrentDC_Impl; + PFNWGLGETPROCADDRESSPROC wglGetProcAddress_Impl; + PFNWGLMAKECURRENTPROC wglMakeCurrent_Impl; + PFNWGLSHARELISTSPROC wglShareLists_Impl; + PFNWGLUSEFONTBITMAPSAPROC wglUseFontBitmapsA_Impl; + PFNWGLUSEFONTBITMAPSWPROC wglUseFontBitmapsW_Impl; + PFNWGLUSEFONTOUTLINESAPROC wglUseFontOutlinesA_Impl; + PFNWGLUSEFONTOUTLINESWPROC wglUseFontOutlinesW_Impl; + PFNWGLDESCRIBELAYERPLANEPROC wglDescribeLayerPlane_Impl; + PFNWGLSETLAYERPALETTEENTRIESPROC wglSetLayerPaletteEntries_Impl; + PFNWGLGETLAYERPALETTEENTRIESPROC wglGetLayerPaletteEntries_Impl; + PFNWGLREALIZELAYERPALETTEPROC wglRealizeLayerPalette_Impl; + PFNWGLSWAPLAYERBUFFERSPROC wglSwapLayerBuffers_Impl; + PFNWGLSWAPMULTIPLEBUFFERSPROC wglSwapMultipleBuffers_Impl; + #endif + + // WGL_ARB_buffer_region + PFNWGLCREATEBUFFERREGIONARBPROC wglCreateBufferRegionARB_Impl; + PFNWGLDELETEBUFFERREGIONARBPROC wglDeleteBufferRegionARB_Impl; + PFNWGLSAVEBUFFERREGIONARBPROC wglSaveBufferRegionARB_Impl; + PFNWGLRESTOREBUFFERREGIONARBPROC wglRestoreBufferRegionARB_Impl; + + // WGL_ARB_extensions_string + PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB_Impl; + + // WGL_ARB_pixel_format + PFNWGLGETPIXELFORMATATTRIBIVARBPROC wglGetPixelFormatAttribivARB_Impl; + PFNWGLGETPIXELFORMATATTRIBFVARBPROC wglGetPixelFormatAttribfvARB_Impl; + PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormatARB_Impl; + + // WGL_ARB_make_current_read + PFNWGLMAKECONTEXTCURRENTARBPROC wglMakeContextCurrentARB_Impl; + PFNWGLGETCURRENTREADDCARBPROC wglGetCurrentReadDCARB_Impl; + + // WGL_ARB_pbuffer + PFNWGLCREATEPBUFFERARBPROC wglCreatePbufferARB_Impl; + PFNWGLGETPBUFFERDCARBPROC wglGetPbufferDCARB_Impl; + PFNWGLRELEASEPBUFFERDCARBPROC wglReleasePbufferDCARB_Impl; + PFNWGLDESTROYPBUFFERARBPROC wglDestroyPbufferARB_Impl; + PFNWGLQUERYPBUFFERARBPROC wglQueryPbufferARB_Impl; + + // WGL_ARB_render_texture + PFNWGLBINDTEXIMAGEARBPROC wglBindTexImageARB_Impl; + PFNWGLRELEASETEXIMAGEARBPROC wglReleaseTexImageARB_Impl; + PFNWGLSETPBUFFERATTRIBARBPROC wglSetPbufferAttribARB_Impl; + + // WGL_ARB_pixel_format_float + // (no functions) + + // WGL_ARB_framebuffer_sRGB + // (no functions) + + // WGL_NV_present_video + PFNWGLENUMERATEVIDEODEVICESNVPROC wglEnumerateVideoDevicesNV_Impl; + PFNWGLBINDVIDEODEVICENVPROC wglBindVideoDeviceNV_Impl; + PFNWGLQUERYCURRENTCONTEXTNVPROC wglQueryCurrentContextNV_Impl; + + // WGL_ARB_create_context + PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB_Impl; + + // WGL_ARB_create_context_profile + // (no functions) + + // WGL_ARB_create_context_robustness + // (no functions) + + // WGL_EXT_extensions_string + PFNWGLGETEXTENSIONSSTRINGEXTPROC wglGetExtensionsStringEXT_Impl; + + // WGL_EXT_swap_control + PFNWGLGETSWAPINTERVALEXTPROC wglGetSwapIntervalEXT_Impl; + PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT_Impl; + + // WGL_OML_sync_control + PFNWGLGETSYNCVALUESOMLPROC wglGetSyncValuesOML_Impl; + PFNWGLGETMSCRATEOMLPROC wglGetMscRateOML_Impl; + PFNWGLSWAPBUFFERSMSCOMLPROC wglSwapBuffersMscOML_Impl; + PFNWGLSWAPLAYERBUFFERSMSCOMLPROC wglSwapLayerBuffersMscOML_Impl; + PFNWGLWAITFORMSCOMLPROC wglWaitForMscOML_Impl; + PFNWGLWAITFORSBCOMLPROC wglWaitForSbcOML_Impl; + + // WGL_NV_video_output + PFNWGLGETVIDEODEVICENVPROC wglGetVideoDeviceNV_Impl; + PFNWGLRELEASEVIDEODEVICENVPROC wglReleaseVideoDeviceNV_Impl; + PFNWGLBINDVIDEOIMAGENVPROC wglBindVideoImageNV_Impl; + PFNWGLRELEASEVIDEOIMAGENVPROC wglReleaseVideoImageNV_Impl; + PFNWGLSENDPBUFFERTOVIDEONVPROC wglSendPbufferToVideoNV_Impl; + PFNWGLGETVIDEOINFONVPROC wglGetVideoInfoNV_Impl; + + // WGL_NV_swap_group + PFNWGLJOINSWAPGROUPNVPROC wglJoinSwapGroupNV_Impl; + PFNWGLBINDSWAPBARRIERNVPROC wglBindSwapBarrierNV_Impl; + PFNWGLQUERYSWAPGROUPNVPROC wglQuerySwapGroupNV_Impl; + PFNWGLQUERYMAXSWAPGROUPSNVPROC wglQueryMaxSwapGroupsNV_Impl; + PFNWGLQUERYFRAMECOUNTNVPROC wglQueryFrameCountNV_Impl; + PFNWGLRESETFRAMECOUNTNVPROC wglResetFrameCountNV_Impl; + + // WGL_NV_video_capture + PFNWGLBINDVIDEOCAPTUREDEVICENVPROC wglBindVideoCaptureDeviceNV_Impl; + PFNWGLENUMERATEVIDEOCAPTUREDEVICESNVPROC wglEnumerateVideoCaptureDevicesNV_Impl; + PFNWGLLOCKVIDEOCAPTUREDEVICENVPROC wglLockVideoCaptureDeviceNV_Impl; + PFNWGLQUERYVIDEOCAPTUREDEVICENVPROC wglQueryVideoCaptureDeviceNV_Impl; + PFNWGLRELEASEVIDEOCAPTUREDEVICENVPROC wglReleaseVideoCaptureDeviceNV_Impl; + + // WGL_NV_copy_image + PFNWGLCOPYIMAGESUBDATANVPROC wglCopyImageSubDataNV_Impl; + + // WGL_NV_DX_interop + PFNWGLDXCLOSEDEVICENVPROC wglDXCloseDeviceNV_Impl; + PFNWGLDXLOCKOBJECTSNVPROC wglDXLockObjectsNV_Impl; + PFNWGLDXOBJECTACCESSNVPROC wglDXObjectAccessNV_Impl; + PFNWGLDXOPENDEVICENVPROC wglDXOpenDeviceNV_Impl; + PFNWGLDXREGISTEROBJECTNVPROC wglDXRegisterObjectNV_Impl; + PFNWGLDXSETRESOURCESHAREHANDLENVPROC wglDXSetResourceShareHandleNV_Impl; + PFNWGLDXUNLOCKOBJECTSNVPROC wglDXUnlockObjectsNV_Impl; + PFNWGLDXUNREGISTEROBJECTNVPROC wglDXUnregisterObjectNV_Impl; + + #endif // GLE_WGL_ENABLED + + #if defined(GLE_GLX_ENABLED) + // GLX_VERSION_1_1 + // We don't create any pointers, because we assume these functions are always present. + + // GLX_VERSION_1_2 + PFNGLXGETCURRENTDISPLAYPROC glXGetCurrentDisplay_Impl; + + // GLX_VERSION_1_3 + PFNGLXCHOOSEFBCONFIGPROC glXChooseFBConfig_Impl; + PFNGLXCREATENEWCONTEXTPROC glXCreateNewContext_Impl; + PFNGLXCREATEPBUFFERPROC glXCreatePbuffer_Impl; + PFNGLXCREATEPIXMAPPROC glXCreatePixmap_Impl; + PFNGLXCREATEWINDOWPROC glXCreateWindow_Impl; + PFNGLXDESTROYPBUFFERPROC glXDestroyPbuffer_Impl; + PFNGLXDESTROYPIXMAPPROC glXDestroyPixmap_Impl; + PFNGLXDESTROYWINDOWPROC glXDestroyWindow_Impl; + PFNGLXGETCURRENTREADDRAWABLEPROC glXGetCurrentReadDrawable_Impl; + PFNGLXGETFBCONFIGATTRIBPROC glXGetFBConfigAttrib_Impl; + PFNGLXGETFBCONFIGSPROC glXGetFBConfigs_Impl; + PFNGLXGETSELECTEDEVENTPROC glXGetSelectedEvent_Impl; + PFNGLXGETVISUALFROMFBCONFIGPROC glXGetVisualFromFBConfig_Impl; + PFNGLXMAKECONTEXTCURRENTPROC glXMakeContextCurrent_Impl; + PFNGLXQUERYCONTEXTPROC glXQueryContext_Impl; + PFNGLXQUERYDRAWABLEPROC glXQueryDrawable_Impl; + PFNGLXSELECTEVENTPROC glXSelectEvent_Impl; + + // GLX_VERSION_1_4 + // Nothing to declare + + // GLX_ARB_create_context + PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribsARB_Impl; + + // GLX_EXT_swap_control + PFNGLXSWAPINTERVALEXTPROC glXSwapIntervalEXT_Impl; + + // GLX_OML_sync_control + PFNGLXGETMSCRATEOMLPROC glXGetMscRateOML_Impl; + PFNGLXGETSYNCVALUESOMLPROC glXGetSyncValuesOML_Impl; + PFNGLXSWAPBUFFERSMSCOMLPROC glXSwapBuffersMscOML_Impl; + PFNGLXWAITFORMSCOMLPROC glXWaitForMscOML_Impl; + PFNGLXWAITFORSBCOMLPROC glXWaitForSbcOML_Impl; + + // GLX_MESA_swap_control + PFNGLXGETSWAPINTERVALMESAPROC glXGetSwapIntervalMESA_Impl; + PFNGLXSWAPINTERVALMESAPROC glXSwapIntervalMESA_Impl; + + #endif // GLE_GLX_ENABLED + + + // Boolean extension support indicators. Each of these identifies the + // presence or absence of the given extension. A better solution here + // might be to use an STL map. + bool gle_AMD_debug_output; + //bool gle_AMD_performance_monitor; + bool gle_APPLE_aux_depth_stencil; + bool gle_APPLE_client_storage; + bool gle_APPLE_element_array; + bool gle_APPLE_fence; + bool gle_APPLE_float_pixels; + bool gle_APPLE_flush_buffer_range; + bool gle_APPLE_object_purgeable; + bool gle_APPLE_pixel_buffer; + bool gle_APPLE_rgb_422; + bool gle_APPLE_row_bytes; + bool gle_APPLE_specular_vector; + bool gle_APPLE_texture_range; + bool gle_APPLE_transform_hint; + bool gle_APPLE_vertex_array_object; + bool gle_APPLE_vertex_array_range; + bool gle_APPLE_vertex_program_evaluators; + bool gle_APPLE_ycbcr_422; + bool gle_ARB_debug_output; + bool gle_ARB_depth_buffer_float; + //bool gle_ARB_direct_state_access; + bool gle_ARB_ES2_compatibility; + bool gle_ARB_framebuffer_object; + bool gle_ARB_framebuffer_sRGB; + bool gle_ARB_texture_multisample; + bool gle_ARB_texture_non_power_of_two; + bool gle_ARB_texture_rectangle; + bool gle_ARB_timer_query; + bool gle_ARB_vertex_array_object; + //bool gle_ARB_vertex_attrib_binding; + bool gle_EXT_draw_buffers2; + bool gle_EXT_texture_compression_s3tc; + bool gle_EXT_texture_filter_anisotropic; + //bool gle_KHR_context_flush_control; + bool gle_KHR_debug; + //bool gle_KHR_robust_buffer_access_behavior; + //bool gle_KHR_robustness; + bool gle_WIN_swap_hint; + + #if defined(GLE_WGL_ENABLED) + bool gle_WGL_ARB_buffer_region; + bool gle_WGL_ARB_create_context; + bool gle_WGL_ARB_create_context_profile; + bool gle_WGL_ARB_create_context_robustness; + bool gle_WGL_ARB_extensions_string; + bool gle_WGL_ARB_framebuffer_sRGB; + bool gle_WGL_ARB_make_current_read; + bool gle_WGL_ARB_pbuffer; + bool gle_WGL_ARB_pixel_format; + bool gle_WGL_ARB_pixel_format_float; + bool gle_WGL_ARB_render_texture; + bool gle_WGL_ATI_render_texture_rectangle; + bool gle_WGL_EXT_extensions_string; + bool gle_WGL_EXT_swap_control; + bool gle_WGL_NV_copy_image; + bool gle_WGL_NV_DX_interop; + bool gle_WGL_NV_DX_interop2; + bool gle_WGL_NV_present_video; + bool gle_WGL_NV_render_texture_rectangle; + bool gle_WGL_NV_swap_group; + bool gle_WGL_NV_video_capture; + bool gle_WGL_NV_video_output; + bool gle_WGL_OML_sync_control; + #elif defined(GLE_GLX_ENABLED) + bool gle_GLX_ARB_create_context; + bool gle_GLX_ARB_create_context_profile; + bool gle_GLX_ARB_create_context_robustness; + bool gle_GLX_EXT_swap_control; + bool gle_GLX_OML_sync_control; + bool gle_MESA_swap_control; + #endif + + }; // class GLEContext + + +} // namespace OVR + + +#endif // Header include guard diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/CAPI/GL/CAPI_GLE_GL.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/CAPI/GL/CAPI_GLE_GL.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,4761 @@ +/************************************************************************************ + +Filename : CAPI_GLE_GL.h +Content : GL extensions declarations. +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + + +#ifndef INC_OVR_CAPI_GLE_GL_h +#define INC_OVR_CAPI_GLE_GL_h + + +#include + + +// Windows headers +// Windows-specific OpenGL 1.1 interfaces. Long ago this was . +// OpenGL 1.1 interface. +// OpenGL 1.2+ compatibility profile and extension interfaces. Not provided by Microsoft. +// Windows-specific extension interfaces. Not provided by Microsoft. +// OpenGL core profile and ARB extension interfaces. Doesn't include interfaces found only in the compatibility profile. Overlaps with gl.h and glext.h. +// +// Mac headers +// OpenGL 1.1 interface. +// OpenGL 1.2+ compatibility profile and extension interfaces. +// Includes only interfaces supported in a core OpenGL 3.1 implementations plus a few related extensions. +// Includes extensions supported in a core OpenGL 3.1 implementation. +// Apple-specific OpenGL interfaces. +// Apple-specific OpenGL interfaces. +// +// Linux headers +// OpenGL 1.1 interface. +// OpenGL 1.2+ compatibility profile and extension interfaces. +// X Windows-specific OpenGL interfaces. +// X Windows 1.3+ API and GLX extension interfaces. +// OpenGL core profile and ARB extension interfaces. Doesn't include interfaces found only in the compatibility profile. Overlaps with gl.h and glext.h. + +#if defined(__gl_h_) || defined(__GL_H__) || defined(__X_GL_H) + #error gl.h should be included after this, not before. +#endif +#if defined(__gl2_h_) + #error gl2.h should be included after this, not before. +#endif +#if defined(__gltypes_h_) + #error gltypes.h should be included after this, not before. +#endif +#if defined(__glext_h_) || defined(__GLEXT_H_) + #error glext.h should be included after this, not before. +#endif + +// Prevent other GL versions from being included in the future. +// We do not disable Microsoft's wingdi.h and redeclare its functions. That's a big header that includes many other things. +// We do not currently disable Apple's OpenGL/OpenGL.h, though we could if we replicated its declarations in this header file. +#define __gl_h_ // Disable future #includes of Apple's +#define __GL_H__ // Disable future #includes of Microsoft's +#define __X_GL_H // etc. +#define __gl2_h_ +#define __gltypes_h_ +#define __glext_h_ +#define __GLEXT_H_ + + +// GLE platform identification +#if defined(_WIN32) + #define GLE_WGL_ENABLED 1 // WGL interface +#elif defined(__ANDROID__) + #define GLE_EGL_ENABLED 1 // EGL interface +#elif defined(__IPHONE__) + #define GLE_EAGL_ENABLED 1 // EAGL interface +#elif defined(__APPLE__) + #define GLE_CGL_ENABLED 1 // CGL interface +#else + #define GLE_GLX_ENABLED 1 // GLX interface +#endif + + +// GLAPI / GLAPIENTRY +// +// GLAPI is a wrapper for Microsoft __declspec(dllimport). +// GLAPIENTRY is the calling convention (__stdcall under Microsoft). +// +#if defined(GLE_WGL_ENABLED) + #if !defined(WINAPI) + #ifndef WIN32_LEAN_AND_MEAN + #define WIN32_LEAN_AND_MEAN 1 + #endif + #include + #undef WIN32_LEAN_AND_MEAN + #endif + + #ifndef WINGDIAPI // Normally defined via windows.h + #define WINGDIAPI __declspec(dllimport) + #define GLE_WINGDIAPI_DEFINED // We define this so that we can know to undefine WINGDIAPI at the end of this file. + #endif + + #if !defined(GLAPI) + #if defined(__MINGW32__) || defined(__CYGWIN__) + #define GLAPI extern + #else + #define GLAPI WINGDIAPI + #endif + #endif + #if !defined(GLAPIENTRY) + #define GLAPIENTRY __stdcall + #endif +#else + #include + + #define GLAPI extern + #define GLAPIENTRY /* empty */ +#endif + + +// GLE_CLASS_EXPORT +// Possibly maps to Microsoft __declspec(dllexport) or nothing on other platforms. +#define GLE_CLASS_EXPORT // Currently defined to nothing. Could be defined to a dll export type. + + + +// GLE_HOOKING_ENABLED +// When enabled, we intercept all OpenGL calls and do any useful internal processing before or after the call. +// An example use case for this is to intercept OpenGL errors on platforms that don't support the OpenGL +// debug functionality (e.g. KHR_Debug). +#if !defined(GLE_WGL_ENABLED) && !defined(GLE_GLX_ENABLED) && defined(OVR_BUILD_DEBUG) // Windows and Unix don't need it because they have OpenGL debug extension support (e.g. KHR_Debug). + #define GLE_HOOKING_ENABLED 1 +#endif + +// When using hooking, we map all OpenGL function usage to our member functions that end with _Hook. +// These member hook functions will internally call the actual OpenGL functions after doing some internal processing. +#if defined(GLE_HOOKING_ENABLED) + #define GLEGetCurrentFunction(x) GLEContext::GetCurrentContext()->x##_Hook + #define GLEGetCurrentVariable(x) GLEContext::GetCurrentContext()->x +#else + #define GLEGetCurrentFunction(x) GLEContext::GetCurrentContext()->x##_Impl + #define GLEGetCurrentVariable(x) GLEContext::GetCurrentContext()->x +#endif + +// GLE_CURRENT_FUNCTION +// Used by hooking in debug builds. +#if defined(OVR_BUILD_DEBUG) + #define GLE_CURRENT_FUNCTION __FUNCTION__ +#else + #define GLE_CURRENT_FUNCTION NULL +#endif + + +// GLE_WHOLE_VERSION +// Returns the major+minor version of the current GLEContext. +// Example usage: +// if(GLE_WHOLE_VERSION() >= 302) // If OpenGL 3.2 or later... +// ... +#define GLE_WHOLE_VERSION() GLEContext::GetCurrentContext()->WholeVersion() + + + +#ifdef __cplusplus +extern "C" { +#endif + + +// OpenGL 1.1 declarations are present in all versions of gl.h, including Microsoft's. +// You don't need to dynamically link to these functions on any platform and can just assume +// they are present. A number of these functions have been deprecated by OpenGL v3+, and +// if an OpenGL v3+ core profile is enabled then usage of the deprecated functions is an error. + +#ifndef GL_VERSION_1_1 + #define GL_VERSION_1_1 1 + + typedef unsigned int GLenum; + typedef unsigned int GLbitfield; + typedef unsigned int GLuint; + typedef int GLint; + typedef int GLsizei; + typedef unsigned char GLboolean; + typedef signed char GLbyte; + typedef short GLshort; + typedef unsigned char GLubyte; + typedef unsigned short GLushort; + typedef unsigned long GLulong; + typedef float GLfloat; + typedef float GLclampf; + typedef double GLdouble; + typedef double GLclampd; + typedef void GLvoid; + typedef int64_t GLint64EXT; + typedef uint64_t GLuint64EXT; + typedef GLint64EXT GLint64; + typedef GLuint64EXT GLuint64; + typedef struct __GLsync *GLsync; + typedef char GLchar; + + #define GL_ZERO 0 + #define GL_FALSE 0 + #define GL_LOGIC_OP 0x0BF1 + #define GL_NONE 0 + #define GL_TEXTURE_COMPONENTS 0x1003 + #define GL_NO_ERROR 0 + #define GL_POINTS 0x0000 + #define GL_CURRENT_BIT 0x00000001 + #define GL_TRUE 1 + #define GL_ONE 1 + #define GL_CLIENT_PIXEL_STORE_BIT 0x00000001 + #define GL_LINES 0x0001 + #define GL_LINE_LOOP 0x0002 + #define GL_POINT_BIT 0x00000002 + #define GL_CLIENT_VERTEX_ARRAY_BIT 0x00000002 + #define GL_LINE_STRIP 0x0003 + #define GL_LINE_BIT 0x00000004 + #define GL_TRIANGLES 0x0004 + #define GL_TRIANGLE_STRIP 0x0005 + #define GL_TRIANGLE_FAN 0x0006 + #define GL_QUADS 0x0007 + #define GL_QUAD_STRIP 0x0008 + #define GL_POLYGON_BIT 0x00000008 + #define GL_POLYGON 0x0009 + #define GL_POLYGON_STIPPLE_BIT 0x00000010 + #define GL_PIXEL_MODE_BIT 0x00000020 + #define GL_LIGHTING_BIT 0x00000040 + #define GL_FOG_BIT 0x00000080 + #define GL_DEPTH_BUFFER_BIT 0x00000100 + #define GL_ACCUM 0x0100 + #define GL_LOAD 0x0101 + #define GL_RETURN 0x0102 + #define GL_MULT 0x0103 + #define GL_ADD 0x0104 + #define GL_NEVER 0x0200 + #define GL_ACCUM_BUFFER_BIT 0x00000200 + #define GL_LESS 0x0201 + #define GL_EQUAL 0x0202 + #define GL_LEQUAL 0x0203 + #define GL_GREATER 0x0204 + #define GL_NOTEQUAL 0x0205 + #define GL_GEQUAL 0x0206 + #define GL_ALWAYS 0x0207 + #define GL_SRC_COLOR 0x0300 + #define GL_ONE_MINUS_SRC_COLOR 0x0301 + #define GL_SRC_ALPHA 0x0302 + #define GL_ONE_MINUS_SRC_ALPHA 0x0303 + #define GL_DST_ALPHA 0x0304 + #define GL_ONE_MINUS_DST_ALPHA 0x0305 + #define GL_DST_COLOR 0x0306 + #define GL_ONE_MINUS_DST_COLOR 0x0307 + #define GL_SRC_ALPHA_SATURATE 0x0308 + #define GL_STENCIL_BUFFER_BIT 0x00000400 + #define GL_FRONT_LEFT 0x0400 + #define GL_FRONT_RIGHT 0x0401 + #define GL_BACK_LEFT 0x0402 + #define GL_BACK_RIGHT 0x0403 + #define GL_FRONT 0x0404 + #define GL_BACK 0x0405 + #define GL_LEFT 0x0406 + #define GL_RIGHT 0x0407 + #define GL_FRONT_AND_BACK 0x0408 + #define GL_AUX0 0x0409 + #define GL_AUX1 0x040A + #define GL_AUX2 0x040B + #define GL_AUX3 0x040C + #define GL_INVALID_ENUM 0x0500 + #define GL_INVALID_VALUE 0x0501 + #define GL_INVALID_OPERATION 0x0502 + #define GL_STACK_OVERFLOW 0x0503 + #define GL_STACK_UNDERFLOW 0x0504 + #define GL_OUT_OF_MEMORY 0x0505 + #define GL_2D 0x0600 + #define GL_3D 0x0601 + #define GL_3D_COLOR 0x0602 + #define GL_3D_COLOR_TEXTURE 0x0603 + #define GL_4D_COLOR_TEXTURE 0x0604 + #define GL_PASS_THROUGH_TOKEN 0x0700 + #define GL_POINT_TOKEN 0x0701 + #define GL_LINE_TOKEN 0x0702 + #define GL_POLYGON_TOKEN 0x0703 + #define GL_BITMAP_TOKEN 0x0704 + #define GL_DRAW_PIXEL_TOKEN 0x0705 + #define GL_COPY_PIXEL_TOKEN 0x0706 + #define GL_LINE_RESET_TOKEN 0x0707 + #define GL_EXP 0x0800 + #define GL_VIEWPORT_BIT 0x00000800 + #define GL_EXP2 0x0801 + #define GL_CW 0x0900 + #define GL_CCW 0x0901 + #define GL_COEFF 0x0A00 + #define GL_ORDER 0x0A01 + #define GL_DOMAIN 0x0A02 + #define GL_CURRENT_COLOR 0x0B00 + #define GL_CURRENT_INDEX 0x0B01 + #define GL_CURRENT_NORMAL 0x0B02 + #define GL_CURRENT_TEXTURE_COORDS 0x0B03 + #define GL_CURRENT_RASTER_COLOR 0x0B04 + #define GL_CURRENT_RASTER_INDEX 0x0B05 + #define GL_CURRENT_RASTER_TEXTURE_COORDS 0x0B06 + #define GL_CURRENT_RASTER_POSITION 0x0B07 + #define GL_CURRENT_RASTER_POSITION_VALID 0x0B08 + #define GL_CURRENT_RASTER_DISTANCE 0x0B09 + #define GL_POINT_SMOOTH 0x0B10 + #define GL_POINT_SIZE 0x0B11 + #define GL_POINT_SIZE_RANGE 0x0B12 + #define GL_POINT_SIZE_GRANULARITY 0x0B13 + #define GL_LINE_SMOOTH 0x0B20 + #define GL_LINE_WIDTH 0x0B21 + #define GL_LINE_WIDTH_RANGE 0x0B22 + #define GL_LINE_WIDTH_GRANULARITY 0x0B23 + #define GL_LINE_STIPPLE 0x0B24 + #define GL_LINE_STIPPLE_PATTERN 0x0B25 + #define GL_LINE_STIPPLE_REPEAT 0x0B26 + #define GL_LIST_MODE 0x0B30 + #define GL_MAX_LIST_NESTING 0x0B31 + #define GL_LIST_BASE 0x0B32 + #define GL_LIST_INDEX 0x0B33 + #define GL_POLYGON_MODE 0x0B40 + #define GL_POLYGON_SMOOTH 0x0B41 + #define GL_POLYGON_STIPPLE 0x0B42 + #define GL_EDGE_FLAG 0x0B43 + #define GL_CULL_FACE 0x0B44 + #define GL_CULL_FACE_MODE 0x0B45 + #define GL_FRONT_FACE 0x0B46 + #define GL_LIGHTING 0x0B50 + #define GL_LIGHT_MODEL_LOCAL_VIEWER 0x0B51 + #define GL_LIGHT_MODEL_TWO_SIDE 0x0B52 + #define GL_LIGHT_MODEL_AMBIENT 0x0B53 + #define GL_SHADE_MODEL 0x0B54 + #define GL_COLOR_MATERIAL_FACE 0x0B55 + #define GL_COLOR_MATERIAL_PARAMETER 0x0B56 + #define GL_COLOR_MATERIAL 0x0B57 + #define GL_FOG 0x0B60 + #define GL_FOG_INDEX 0x0B61 + #define GL_FOG_DENSITY 0x0B62 + #define GL_FOG_START 0x0B63 + #define GL_FOG_END 0x0B64 + #define GL_FOG_MODE 0x0B65 + #define GL_FOG_COLOR 0x0B66 + #define GL_DEPTH_RANGE 0x0B70 + #define GL_DEPTH_TEST 0x0B71 + #define GL_DEPTH_WRITEMASK 0x0B72 + #define GL_DEPTH_CLEAR_VALUE 0x0B73 + #define GL_DEPTH_FUNC 0x0B74 + #define GL_ACCUM_CLEAR_VALUE 0x0B80 + #define GL_STENCIL_TEST 0x0B90 + #define GL_STENCIL_CLEAR_VALUE 0x0B91 + #define GL_STENCIL_FUNC 0x0B92 + #define GL_STENCIL_VALUE_MASK 0x0B93 + #define GL_STENCIL_FAIL 0x0B94 + #define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 + #define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 + #define GL_STENCIL_REF 0x0B97 + #define GL_STENCIL_WRITEMASK 0x0B98 + #define GL_MATRIX_MODE 0x0BA0 + #define GL_NORMALIZE 0x0BA1 + #define GL_VIEWPORT 0x0BA2 + #define GL_MODELVIEW_STACK_DEPTH 0x0BA3 + #define GL_PROJECTION_STACK_DEPTH 0x0BA4 + #define GL_TEXTURE_STACK_DEPTH 0x0BA5 + #define GL_MODELVIEW_MATRIX 0x0BA6 + #define GL_PROJECTION_MATRIX 0x0BA7 + #define GL_TEXTURE_MATRIX 0x0BA8 + #define GL_ATTRIB_STACK_DEPTH 0x0BB0 + #define GL_CLIENT_ATTRIB_STACK_DEPTH 0x0BB1 + #define GL_ALPHA_TEST 0x0BC0 + #define GL_ALPHA_TEST_FUNC 0x0BC1 + #define GL_ALPHA_TEST_REF 0x0BC2 + #define GL_DITHER 0x0BD0 + #define GL_BLEND_DST 0x0BE0 + #define GL_BLEND_SRC 0x0BE1 + #define GL_BLEND 0x0BE2 + #define GL_LOGIC_OP_MODE 0x0BF0 + #define GL_INDEX_LOGIC_OP 0x0BF1 + #define GL_COLOR_LOGIC_OP 0x0BF2 + #define GL_AUX_BUFFERS 0x0C00 + #define GL_DRAW_BUFFER 0x0C01 + #define GL_READ_BUFFER 0x0C02 + #define GL_SCISSOR_BOX 0x0C10 + #define GL_SCISSOR_TEST 0x0C11 + #define GL_INDEX_CLEAR_VALUE 0x0C20 + #define GL_INDEX_WRITEMASK 0x0C21 + #define GL_COLOR_CLEAR_VALUE 0x0C22 + #define GL_COLOR_WRITEMASK 0x0C23 + #define GL_INDEX_MODE 0x0C30 + #define GL_RGBA_MODE 0x0C31 + #define GL_DOUBLEBUFFER 0x0C32 + #define GL_STEREO 0x0C33 + #define GL_RENDER_MODE 0x0C40 + #define GL_PERSPECTIVE_CORRECTION_HINT 0x0C50 + #define GL_POINT_SMOOTH_HINT 0x0C51 + #define GL_LINE_SMOOTH_HINT 0x0C52 + #define GL_POLYGON_SMOOTH_HINT 0x0C53 + #define GL_FOG_HINT 0x0C54 + #define GL_TEXTURE_GEN_S 0x0C60 + #define GL_TEXTURE_GEN_T 0x0C61 + #define GL_TEXTURE_GEN_R 0x0C62 + #define GL_TEXTURE_GEN_Q 0x0C63 + #define GL_PIXEL_MAP_I_TO_I 0x0C70 + #define GL_PIXEL_MAP_S_TO_S 0x0C71 + #define GL_PIXEL_MAP_I_TO_R 0x0C72 + #define GL_PIXEL_MAP_I_TO_G 0x0C73 + #define GL_PIXEL_MAP_I_TO_B 0x0C74 + #define GL_PIXEL_MAP_I_TO_A 0x0C75 + #define GL_PIXEL_MAP_R_TO_R 0x0C76 + #define GL_PIXEL_MAP_G_TO_G 0x0C77 + #define GL_PIXEL_MAP_B_TO_B 0x0C78 + #define GL_PIXEL_MAP_A_TO_A 0x0C79 + #define GL_PIXEL_MAP_I_TO_I_SIZE 0x0CB0 + #define GL_PIXEL_MAP_S_TO_S_SIZE 0x0CB1 + #define GL_PIXEL_MAP_I_TO_R_SIZE 0x0CB2 + #define GL_PIXEL_MAP_I_TO_G_SIZE 0x0CB3 + #define GL_PIXEL_MAP_I_TO_B_SIZE 0x0CB4 + #define GL_PIXEL_MAP_I_TO_A_SIZE 0x0CB5 + #define GL_PIXEL_MAP_R_TO_R_SIZE 0x0CB6 + #define GL_PIXEL_MAP_G_TO_G_SIZE 0x0CB7 + #define GL_PIXEL_MAP_B_TO_B_SIZE 0x0CB8 + #define GL_PIXEL_MAP_A_TO_A_SIZE 0x0CB9 + #define GL_UNPACK_SWAP_BYTES 0x0CF0 + #define GL_UNPACK_LSB_FIRST 0x0CF1 + #define GL_UNPACK_ROW_LENGTH 0x0CF2 + #define GL_UNPACK_SKIP_ROWS 0x0CF3 + #define GL_UNPACK_SKIP_PIXELS 0x0CF4 + #define GL_UNPACK_ALIGNMENT 0x0CF5 + #define GL_PACK_SWAP_BYTES 0x0D00 + #define GL_PACK_LSB_FIRST 0x0D01 + #define GL_PACK_ROW_LENGTH 0x0D02 + #define GL_PACK_SKIP_ROWS 0x0D03 + #define GL_PACK_SKIP_PIXELS 0x0D04 + #define GL_PACK_ALIGNMENT 0x0D05 + #define GL_MAP_COLOR 0x0D10 + #define GL_MAP_STENCIL 0x0D11 + #define GL_INDEX_SHIFT 0x0D12 + #define GL_INDEX_OFFSET 0x0D13 + #define GL_RED_SCALE 0x0D14 + #define GL_RED_BIAS 0x0D15 + #define GL_ZOOM_X 0x0D16 + #define GL_ZOOM_Y 0x0D17 + #define GL_GREEN_SCALE 0x0D18 + #define GL_GREEN_BIAS 0x0D19 + #define GL_BLUE_SCALE 0x0D1A + #define GL_BLUE_BIAS 0x0D1B + #define GL_ALPHA_SCALE 0x0D1C + #define GL_ALPHA_BIAS 0x0D1D + #define GL_DEPTH_SCALE 0x0D1E + #define GL_DEPTH_BIAS 0x0D1F + #define GL_MAX_EVAL_ORDER 0x0D30 + #define GL_MAX_LIGHTS 0x0D31 + #define GL_MAX_CLIP_PLANES 0x0D32 + #define GL_MAX_TEXTURE_SIZE 0x0D33 + #define GL_MAX_PIXEL_MAP_TABLE 0x0D34 + #define GL_MAX_ATTRIB_STACK_DEPTH 0x0D35 + #define GL_MAX_MODELVIEW_STACK_DEPTH 0x0D36 + #define GL_MAX_NAME_STACK_DEPTH 0x0D37 + #define GL_MAX_PROJECTION_STACK_DEPTH 0x0D38 + #define GL_MAX_TEXTURE_STACK_DEPTH 0x0D39 + #define GL_MAX_VIEWPORT_DIMS 0x0D3A + #define GL_MAX_CLIENT_ATTRIB_STACK_DEPTH 0x0D3B + #define GL_SUBPIXEL_BITS 0x0D50 + #define GL_INDEX_BITS 0x0D51 + #define GL_RED_BITS 0x0D52 + #define GL_GREEN_BITS 0x0D53 + #define GL_BLUE_BITS 0x0D54 + #define GL_ALPHA_BITS 0x0D55 + #define GL_DEPTH_BITS 0x0D56 + #define GL_STENCIL_BITS 0x0D57 + #define GL_ACCUM_RED_BITS 0x0D58 + #define GL_ACCUM_GREEN_BITS 0x0D59 + #define GL_ACCUM_BLUE_BITS 0x0D5A + #define GL_ACCUM_ALPHA_BITS 0x0D5B + #define GL_NAME_STACK_DEPTH 0x0D70 + #define GL_AUTO_NORMAL 0x0D80 + #define GL_MAP1_COLOR_4 0x0D90 + #define GL_MAP1_INDEX 0x0D91 + #define GL_MAP1_NORMAL 0x0D92 + #define GL_MAP1_TEXTURE_COORD_1 0x0D93 + #define GL_MAP1_TEXTURE_COORD_2 0x0D94 + #define GL_MAP1_TEXTURE_COORD_3 0x0D95 + #define GL_MAP1_TEXTURE_COORD_4 0x0D96 + #define GL_MAP1_VERTEX_3 0x0D97 + #define GL_MAP1_VERTEX_4 0x0D98 + #define GL_MAP2_COLOR_4 0x0DB0 + #define GL_MAP2_INDEX 0x0DB1 + #define GL_MAP2_NORMAL 0x0DB2 + #define GL_MAP2_TEXTURE_COORD_1 0x0DB3 + #define GL_MAP2_TEXTURE_COORD_2 0x0DB4 + #define GL_MAP2_TEXTURE_COORD_3 0x0DB5 + #define GL_MAP2_TEXTURE_COORD_4 0x0DB6 + #define GL_MAP2_VERTEX_3 0x0DB7 + #define GL_MAP2_VERTEX_4 0x0DB8 + #define GL_MAP1_GRID_DOMAIN 0x0DD0 + #define GL_MAP1_GRID_SEGMENTS 0x0DD1 + #define GL_MAP2_GRID_DOMAIN 0x0DD2 + #define GL_MAP2_GRID_SEGMENTS 0x0DD3 + #define GL_TEXTURE_1D 0x0DE0 + #define GL_TEXTURE_2D 0x0DE1 + #define GL_FEEDBACK_BUFFER_POINTER 0x0DF0 + #define GL_FEEDBACK_BUFFER_SIZE 0x0DF1 + #define GL_FEEDBACK_BUFFER_TYPE 0x0DF2 + #define GL_SELECTION_BUFFER_POINTER 0x0DF3 + #define GL_SELECTION_BUFFER_SIZE 0x0DF4 + #define GL_TEXTURE_WIDTH 0x1000 + #define GL_TRANSFORM_BIT 0x00001000 + #define GL_TEXTURE_HEIGHT 0x1001 + #define GL_TEXTURE_INTERNAL_FORMAT 0x1003 + #define GL_TEXTURE_BORDER_COLOR 0x1004 + #define GL_TEXTURE_BORDER 0x1005 + #define GL_DONT_CARE 0x1100 + #define GL_FASTEST 0x1101 + #define GL_NICEST 0x1102 + #define GL_AMBIENT 0x1200 + #define GL_DIFFUSE 0x1201 + #define GL_SPECULAR 0x1202 + #define GL_POSITION 0x1203 + #define GL_SPOT_DIRECTION 0x1204 + #define GL_SPOT_EXPONENT 0x1205 + #define GL_SPOT_CUTOFF 0x1206 + #define GL_CONSTANT_ATTENUATION 0x1207 + #define GL_LINEAR_ATTENUATION 0x1208 + #define GL_QUADRATIC_ATTENUATION 0x1209 + #define GL_COMPILE 0x1300 + #define GL_COMPILE_AND_EXECUTE 0x1301 + #define GL_BYTE 0x1400 + #define GL_UNSIGNED_BYTE 0x1401 + #define GL_SHORT 0x1402 + #define GL_UNSIGNED_SHORT 0x1403 + #define GL_INT 0x1404 + #define GL_UNSIGNED_INT 0x1405 + #define GL_FLOAT 0x1406 + #define GL_2_BYTES 0x1407 + #define GL_3_BYTES 0x1408 + #define GL_4_BYTES 0x1409 + #define GL_DOUBLE 0x140A + #define GL_CLEAR 0x1500 + #define GL_AND 0x1501 + #define GL_AND_REVERSE 0x1502 + #define GL_COPY 0x1503 + #define GL_AND_INVERTED 0x1504 + #define GL_NOOP 0x1505 + #define GL_XOR 0x1506 + #define GL_OR 0x1507 + #define GL_NOR 0x1508 + #define GL_EQUIV 0x1509 + #define GL_INVERT 0x150A + #define GL_OR_REVERSE 0x150B + #define GL_COPY_INVERTED 0x150C + #define GL_OR_INVERTED 0x150D + #define GL_NAND 0x150E + #define GL_SET 0x150F + #define GL_EMISSION 0x1600 + #define GL_SHININESS 0x1601 + #define GL_AMBIENT_AND_DIFFUSE 0x1602 + #define GL_COLOR_INDEXES 0x1603 + #define GL_MODELVIEW 0x1700 + #define GL_PROJECTION 0x1701 + #define GL_TEXTURE 0x1702 + #define GL_COLOR 0x1800 + #define GL_DEPTH 0x1801 + #define GL_STENCIL 0x1802 + #define GL_COLOR_INDEX 0x1900 + #define GL_STENCIL_INDEX 0x1901 + #define GL_DEPTH_COMPONENT 0x1902 + #define GL_RED 0x1903 + #define GL_GREEN 0x1904 + #define GL_BLUE 0x1905 + #define GL_ALPHA 0x1906 + #define GL_RGB 0x1907 + #define GL_RGBA 0x1908 + #define GL_LUMINANCE 0x1909 + #define GL_LUMINANCE_ALPHA 0x190A + #define GL_BITMAP 0x1A00 + #define GL_POINT 0x1B00 + #define GL_LINE 0x1B01 + #define GL_FILL 0x1B02 + #define GL_RENDER 0x1C00 + #define GL_FEEDBACK 0x1C01 + #define GL_SELECT 0x1C02 + #define GL_FLAT 0x1D00 + #define GL_SMOOTH 0x1D01 + #define GL_KEEP 0x1E00 + #define GL_REPLACE 0x1E01 + #define GL_INCR 0x1E02 + #define GL_DECR 0x1E03 + #define GL_VENDOR 0x1F00 + #define GL_RENDERER 0x1F01 + #define GL_VERSION 0x1F02 + #define GL_EXTENSIONS 0x1F03 + #define GL_S 0x2000 + #define GL_ENABLE_BIT 0x00002000 + #define GL_T 0x2001 + #define GL_R 0x2002 + #define GL_Q 0x2003 + #define GL_MODULATE 0x2100 + #define GL_DECAL 0x2101 + #define GL_TEXTURE_ENV_MODE 0x2200 + #define GL_TEXTURE_ENV_COLOR 0x2201 + #define GL_TEXTURE_ENV 0x2300 + #define GL_EYE_LINEAR 0x2400 + #define GL_OBJECT_LINEAR 0x2401 + #define GL_SPHERE_MAP 0x2402 + #define GL_TEXTURE_GEN_MODE 0x2500 + #define GL_OBJECT_PLANE 0x2501 + #define GL_EYE_PLANE 0x2502 + #define GL_NEAREST 0x2600 + #define GL_LINEAR 0x2601 + #define GL_NEAREST_MIPMAP_NEAREST 0x2700 + #define GL_LINEAR_MIPMAP_NEAREST 0x2701 + #define GL_NEAREST_MIPMAP_LINEAR 0x2702 + #define GL_LINEAR_MIPMAP_LINEAR 0x2703 + #define GL_TEXTURE_MAG_FILTER 0x2800 + #define GL_TEXTURE_MIN_FILTER 0x2801 + #define GL_TEXTURE_WRAP_S 0x2802 + #define GL_TEXTURE_WRAP_T 0x2803 + #define GL_CLAMP 0x2900 + #define GL_REPEAT 0x2901 + #define GL_POLYGON_OFFSET_UNITS 0x2A00 + #define GL_POLYGON_OFFSET_POINT 0x2A01 + #define GL_POLYGON_OFFSET_LINE 0x2A02 + #define GL_R3_G3_B2 0x2A10 + #define GL_V2F 0x2A20 + #define GL_V3F 0x2A21 + #define GL_C4UB_V2F 0x2A22 + #define GL_C4UB_V3F 0x2A23 + #define GL_C3F_V3F 0x2A24 + #define GL_N3F_V3F 0x2A25 + #define GL_C4F_N3F_V3F 0x2A26 + #define GL_T2F_V3F 0x2A27 + #define GL_T4F_V4F 0x2A28 + #define GL_T2F_C4UB_V3F 0x2A29 + #define GL_T2F_C3F_V3F 0x2A2A + #define GL_T2F_N3F_V3F 0x2A2B + #define GL_T2F_C4F_N3F_V3F 0x2A2C + #define GL_T4F_C4F_N3F_V4F 0x2A2D + #define GL_CLIP_PLANE0 0x3000 + #define GL_CLIP_PLANE1 0x3001 + #define GL_CLIP_PLANE2 0x3002 + #define GL_CLIP_PLANE3 0x3003 + #define GL_CLIP_PLANE4 0x3004 + #define GL_CLIP_PLANE5 0x3005 + #define GL_LIGHT0 0x4000 + #define GL_COLOR_BUFFER_BIT 0x00004000 + #define GL_LIGHT1 0x4001 + #define GL_LIGHT2 0x4002 + #define GL_LIGHT3 0x4003 + #define GL_LIGHT4 0x4004 + #define GL_LIGHT5 0x4005 + #define GL_LIGHT6 0x4006 + #define GL_LIGHT7 0x4007 + #define GL_HINT_BIT 0x00008000 + #define GL_POLYGON_OFFSET_FILL 0x8037 + #define GL_POLYGON_OFFSET_FACTOR 0x8038 + #define GL_ALPHA4 0x803B + #define GL_ALPHA8 0x803C + #define GL_ALPHA12 0x803D + #define GL_ALPHA16 0x803E + #define GL_LUMINANCE4 0x803F + #define GL_LUMINANCE8 0x8040 + #define GL_LUMINANCE12 0x8041 + #define GL_LUMINANCE16 0x8042 + #define GL_LUMINANCE4_ALPHA4 0x8043 + #define GL_LUMINANCE6_ALPHA2 0x8044 + #define GL_LUMINANCE8_ALPHA8 0x8045 + #define GL_LUMINANCE12_ALPHA4 0x8046 + #define GL_LUMINANCE12_ALPHA12 0x8047 + #define GL_LUMINANCE16_ALPHA16 0x8048 + #define GL_INTENSITY 0x8049 + #define GL_INTENSITY4 0x804A + #define GL_INTENSITY8 0x804B + #define GL_INTENSITY12 0x804C + #define GL_INTENSITY16 0x804D + #define GL_RGB4 0x804F + #define GL_RGB5 0x8050 + #define GL_RGB8 0x8051 + #define GL_RGB10 0x8052 + #define GL_RGB12 0x8053 + #define GL_RGB16 0x8054 + #define GL_RGBA2 0x8055 + #define GL_RGBA4 0x8056 + #define GL_RGB5_A1 0x8057 + #define GL_RGBA8 0x8058 + #define GL_RGB10_A2 0x8059 + #define GL_RGBA12 0x805A + #define GL_RGBA16 0x805B + #define GL_TEXTURE_RED_SIZE 0x805C + #define GL_TEXTURE_GREEN_SIZE 0x805D + #define GL_TEXTURE_BLUE_SIZE 0x805E + #define GL_TEXTURE_ALPHA_SIZE 0x805F + #define GL_TEXTURE_LUMINANCE_SIZE 0x8060 + #define GL_TEXTURE_INTENSITY_SIZE 0x8061 + #define GL_PROXY_TEXTURE_1D 0x8063 + #define GL_PROXY_TEXTURE_2D 0x8064 + #define GL_TEXTURE_PRIORITY 0x8066 + #define GL_TEXTURE_RESIDENT 0x8067 + #define GL_TEXTURE_BINDING_1D 0x8068 + #define GL_TEXTURE_BINDING_2D 0x8069 + #define GL_VERTEX_ARRAY 0x8074 + #define GL_NORMAL_ARRAY 0x8075 + #define GL_COLOR_ARRAY 0x8076 + #define GL_INDEX_ARRAY 0x8077 + #define GL_TEXTURE_COORD_ARRAY 0x8078 + #define GL_EDGE_FLAG_ARRAY 0x8079 + #define GL_VERTEX_ARRAY_SIZE 0x807A + #define GL_VERTEX_ARRAY_TYPE 0x807B + #define GL_VERTEX_ARRAY_STRIDE 0x807C + #define GL_NORMAL_ARRAY_TYPE 0x807E + #define GL_NORMAL_ARRAY_STRIDE 0x807F + #define GL_COLOR_ARRAY_SIZE 0x8081 + #define GL_COLOR_ARRAY_TYPE 0x8082 + #define GL_COLOR_ARRAY_STRIDE 0x8083 + #define GL_INDEX_ARRAY_TYPE 0x8085 + #define GL_INDEX_ARRAY_STRIDE 0x8086 + #define GL_TEXTURE_COORD_ARRAY_SIZE 0x8088 + #define GL_TEXTURE_COORD_ARRAY_TYPE 0x8089 + #define GL_TEXTURE_COORD_ARRAY_STRIDE 0x808A + #define GL_EDGE_FLAG_ARRAY_STRIDE 0x808C + #define GL_VERTEX_ARRAY_POINTER 0x808E + #define GL_NORMAL_ARRAY_POINTER 0x808F + #define GL_COLOR_ARRAY_POINTER 0x8090 + #define GL_INDEX_ARRAY_POINTER 0x8091 + #define GL_TEXTURE_COORD_ARRAY_POINTER 0x8092 + #define GL_EDGE_FLAG_ARRAY_POINTER 0x8093 + #define GL_COLOR_INDEX1_EXT 0x80E2 + #define GL_COLOR_INDEX2_EXT 0x80E3 + #define GL_COLOR_INDEX4_EXT 0x80E4 + #define GL_COLOR_INDEX8_EXT 0x80E5 + #define GL_COLOR_INDEX12_EXT 0x80E6 + #define GL_COLOR_INDEX16_EXT 0x80E7 + #define GL_EVAL_BIT 0x00010000 + #define GL_LIST_BIT 0x00020000 + #define GL_TEXTURE_BIT 0x00040000 + #define GL_SCISSOR_BIT 0x00080000 + #define GL_ALL_ATTRIB_BITS 0x000fffff + #define GL_CLIENT_ALL_ATTRIB_BITS 0xffffffff + + #if defined(GLE_HOOKING_ENABLED) + // In this case we map these functions to internal versions instead of the standard versions. + #define glAccum(...) GLEGetCurrentFunction(glAccum)(__VA_ARGS__) + #define glAlphaFunc(...) GLEGetCurrentFunction(glAlphaFunc)(__VA_ARGS__) + #define glAreTexturesResident(...) GLEGetCurrentFunction(glAreTexturesResident)(__VA_ARGS__) + #define glArrayElement(...) GLEGetCurrentFunction(glArrayElement)(__VA_ARGS__) + #define glBegin(...) GLEGetCurrentFunction(glBegin)(__VA_ARGS__) + #define glBindTexture(...) GLEGetCurrentFunction(glBindTexture)(__VA_ARGS__) + #define glBitmap(...) GLEGetCurrentFunction(glBitmap)(__VA_ARGS__) + #define glBlendFunc(...) GLEGetCurrentFunction(glBlendFunc)(__VA_ARGS__) + #define glCallList(...) GLEGetCurrentFunction(glCallList)(__VA_ARGS__) + #define glCallLists(...) GLEGetCurrentFunction(glCallLists)(__VA_ARGS__) + #define glClear(...) GLEGetCurrentFunction(glClear)(__VA_ARGS__) + #define glClearAccum(...) GLEGetCurrentFunction(glClearAccum)(__VA_ARGS__) + #define glClearColor(...) GLEGetCurrentFunction(glClearColor)(__VA_ARGS__) + #define glClearDepth(...) GLEGetCurrentFunction(glClearDepth)(__VA_ARGS__) + #define glClearIndex(...) GLEGetCurrentFunction(glClearIndex)(__VA_ARGS__) + #define glClearStencil(...) GLEGetCurrentFunction(glClearStencil)(__VA_ARGS__) + #define glClipPlane(...) GLEGetCurrentFunction(glClipPlane)(__VA_ARGS__) + #define glColor3b(...) GLEGetCurrentFunction(glColor3b)(__VA_ARGS__) + #define glColor3bv(...) GLEGetCurrentFunction(glColor3bv)(__VA_ARGS__) + #define glColor3d(...) GLEGetCurrentFunction(glColor3d)(__VA_ARGS__) + #define glColor3dv(...) GLEGetCurrentFunction(glColor3dv)(__VA_ARGS__) + #define glColor3f(...) GLEGetCurrentFunction(glColor3f)(__VA_ARGS__) + #define glColor3fv(...) GLEGetCurrentFunction(glColor3fv)(__VA_ARGS__) + #define glColor3i(...) GLEGetCurrentFunction(glColor3i)(__VA_ARGS__) + #define glColor3iv(...) GLEGetCurrentFunction(glColor3iv)(__VA_ARGS__) + #define glColor3s(...) GLEGetCurrentFunction(glColor3s)(__VA_ARGS__) + #define glColor3sv(...) GLEGetCurrentFunction(glColor3sv)(__VA_ARGS__) + #define glColor3ub(...) GLEGetCurrentFunction(glColor3ub)(__VA_ARGS__) + #define glColor3ubv(...) GLEGetCurrentFunction(glColor3ubv)(__VA_ARGS__) + #define glColor3ui(...) GLEGetCurrentFunction(glColor3ui)(__VA_ARGS__) + #define glColor3uiv(...) GLEGetCurrentFunction(glColor3uiv)(__VA_ARGS__) + #define glColor3us(...) GLEGetCurrentFunction(glColor3us)(__VA_ARGS__) + #define glColor3usv(...) GLEGetCurrentFunction(glColor3usv)(__VA_ARGS__) + #define glColor4b(...) GLEGetCurrentFunction(glColor4b)(__VA_ARGS__) + #define glColor4bv(...) GLEGetCurrentFunction(glColor4bv)(__VA_ARGS__) + #define glColor4d(...) GLEGetCurrentFunction(glColor4d)(__VA_ARGS__) + #define glColor4dv(...) GLEGetCurrentFunction(glColor4dv)(__VA_ARGS__) + #define glColor4f(...) GLEGetCurrentFunction(glColor4f)(__VA_ARGS__) + #define glColor4fv(...) GLEGetCurrentFunction(glColor4fv)(__VA_ARGS__) + #define glColor4i(...) GLEGetCurrentFunction(glColor4i)(__VA_ARGS__) + #define glColor4iv(...) GLEGetCurrentFunction(glColor4iv)(__VA_ARGS__) + #define glColor4s(...) GLEGetCurrentFunction(glColor4s)(__VA_ARGS__) + #define glColor4sv(...) GLEGetCurrentFunction(glColor4sv)(__VA_ARGS__) + #define glColor4ub(...) GLEGetCurrentFunction(glColor4ub)(__VA_ARGS__) + #define glColor4ubv(...) GLEGetCurrentFunction(glColor4ubv)(__VA_ARGS__) + #define glColor4ui(...) GLEGetCurrentFunction(glColor4ui)(__VA_ARGS__) + #define glColor4uiv(...) GLEGetCurrentFunction(glColor4uiv)(__VA_ARGS__) + #define glColor4us(...) GLEGetCurrentFunction(glColor4us)(__VA_ARGS__) + #define glColor4usv(...) GLEGetCurrentFunction(glColor4usv)(__VA_ARGS__) + #define glColorMask(...) GLEGetCurrentFunction(glColorMask)(__VA_ARGS__) + #define glColorMaterial(...) GLEGetCurrentFunction(glColorMaterial)(__VA_ARGS__) + #define glColorPointer(...) GLEGetCurrentFunction(glColorPointer)(__VA_ARGS__) + #define glCopyPixels(...) GLEGetCurrentFunction(glCopyPixels)(__VA_ARGS__) + #define glCopyTexImage1D(...) GLEGetCurrentFunction(glCopyTexImage1D)(__VA_ARGS__) + #define glCopyTexImage2D(...) GLEGetCurrentFunction(glCopyTexImage2D)(__VA_ARGS__) + #define glCopyTexSubImage1D(...) GLEGetCurrentFunction(glCopyTexSubImage1D)(__VA_ARGS__) + #define glCopyTexSubImage2D(...) GLEGetCurrentFunction(glCopyTexSubImage2D)(__VA_ARGS__) + #define glCullFace(...) GLEGetCurrentFunction(glCullFace)(__VA_ARGS__) + #define glDeleteLists(...) GLEGetCurrentFunction(glDeleteLists)(__VA_ARGS__) + #define glDeleteTextures(...) GLEGetCurrentFunction(glDeleteTextures)(__VA_ARGS__) + #define glDepthFunc(...) GLEGetCurrentFunction(glDepthFunc)(__VA_ARGS__) + #define glDepthMask(...) GLEGetCurrentFunction(glDepthMask)(__VA_ARGS__) + #define glDepthRange(...) GLEGetCurrentFunction(glDepthRange)(__VA_ARGS__) + #define glDisable(...) GLEGetCurrentFunction(glDisable)(__VA_ARGS__) + #define glDisableClientState(...) GLEGetCurrentFunction(glDisableClientState)(__VA_ARGS__) + #define glDrawArrays(...) GLEGetCurrentFunction(glDrawArrays)(__VA_ARGS__) + #define glDrawBuffer(...) GLEGetCurrentFunction(glDrawBuffer)(__VA_ARGS__) + #define glDrawElements(...) GLEGetCurrentFunction(glDrawElements)(__VA_ARGS__) + #define glDrawPixels(...) GLEGetCurrentFunction(glDrawPixels)(__VA_ARGS__) + #define glEdgeFlag(...) GLEGetCurrentFunction(glEdgeFlag)(__VA_ARGS__) + #define glEdgeFlagPointer(...) GLEGetCurrentFunction(glEdgeFlagPointer)(__VA_ARGS__) + #define glEdgeFlagv(...) GLEGetCurrentFunction(glEdgeFlagv)(__VA_ARGS__) + #define glEnable(...) GLEGetCurrentFunction(glEnable)(__VA_ARGS__) + #define glEnableClientState(...) GLEGetCurrentFunction(glEnableClientState)(__VA_ARGS__) + #define glEnd() GLEGetCurrentFunction(glEnd)() + #define glEndList() GLEGetCurrentFunction(glEndList)(_) + #define glEvalCoord1d(...) GLEGetCurrentFunction(glEvalCoord1d)(__VA_ARGS__) + #define glEvalCoord1dv(...) GLEGetCurrentFunction(glEvalCoord1dv)(__VA_ARGS__) + #define glEvalCoord1f(...) GLEGetCurrentFunction(glEvalCoord1f)(__VA_ARGS__) + #define glEvalCoord1fv(...) GLEGetCurrentFunction(glEvalCoord1fv)(__VA_ARGS__) + #define glEvalCoord2d(...) GLEGetCurrentFunction(glEvalCoord2d)(__VA_ARGS__) + #define glEvalCoord2dv(...) GLEGetCurrentFunction(glEvalCoord2dv)(__VA_ARGS__) + #define glEvalCoord2f(...) GLEGetCurrentFunction(glEvalCoord2f)(__VA_ARGS__) + #define glEvalCoord2fv(...) GLEGetCurrentFunction(glEvalCoord2fv)(__VA_ARGS__) + #define glEvalMesh1(...) GLEGetCurrentFunction(glEvalMesh1)(__VA_ARGS__) + #define glEvalMesh2(...) GLEGetCurrentFunction(glEvalMesh2)(__VA_ARGS__) + #define glEvalPoint1(...) GLEGetCurrentFunction(glEvalPoint1)(__VA_ARGS__) + #define glEvalPoint2(...) GLEGetCurrentFunction(glEvalPoint2)(__VA_ARGS__) + #define glFeedbackBuffer(...) GLEGetCurrentFunction(glFeedbackBuffer)(__VA_ARGS__) + #define glFinish() GLEGetCurrentFunction(glFinish)() + #define glFlush() GLEGetCurrentFunction(glFlush)() + #define glFogf(...) GLEGetCurrentFunction(glFogf)(__VA_ARGS__) + #define glFogfv(...) GLEGetCurrentFunction(glFogfv)(__VA_ARGS__) + #define glFogi(...) GLEGetCurrentFunction(glFogi)(__VA_ARGS__) + #define glFogiv(...) GLEGetCurrentFunction(glFogiv)(__VA_ARGS__) + #define glFrontFace(...) GLEGetCurrentFunction(glFrontFace)(__VA_ARGS__) + #define glFrustum(...) GLEGetCurrentFunction(glFrustum)(__VA_ARGS__) + #define glGenLists(...) GLEGetCurrentFunction(glGenLists)(__VA_ARGS__) + #define glGenTextures(...) GLEGetCurrentFunction(glGenTextures)(__VA_ARGS__) + #define glGetBooleanv(...) GLEGetCurrentFunction(glGetBooleanv)(__VA_ARGS__) + #define glGetClipPlane(...) GLEGetCurrentFunction(glGetClipPlane)(__VA_ARGS__) + #define glGetDoublev(...) GLEGetCurrentFunction(glGetDoublev)(__VA_ARGS__) + #define glGetError() GLEGetCurrentFunction(glGetError)() + #define glGetFloatv(...) GLEGetCurrentFunction(glGetFloatv)(__VA_ARGS__) + #define glGetIntegerv(...) GLEGetCurrentFunction(glGetIntegerv)(__VA_ARGS__) + #define glGetLightfv(...) GLEGetCurrentFunction(glGetLightfv)(__VA_ARGS__) + #define glGetLightiv(...) GLEGetCurrentFunction(glGetLightiv)(__VA_ARGS__) + #define glGetMapdv(...) GLEGetCurrentFunction(glGetMapdv)(__VA_ARGS__) + #define glGetMapfv(...) GLEGetCurrentFunction(glGetMapfv)(__VA_ARGS__) + #define glGetMapiv(...) GLEGetCurrentFunction(glGetMapiv)(__VA_ARGS__) + #define glGetMaterialfv(...) GLEGetCurrentFunction(glGetMaterialfv)(__VA_ARGS__) + #define glGetMaterialiv(...) GLEGetCurrentFunction(glGetMaterialiv)(__VA_ARGS__) + #define glGetPixelMapfv(...) GLEGetCurrentFunction(glGetPixelMapfv)(__VA_ARGS__) + #define glGetPixelMapuiv(...) GLEGetCurrentFunction(glGetPixelMapuiv)(__VA_ARGS__) + #define glGetPixelMapusv(...) GLEGetCurrentFunction(glGetPixelMapusv)(__VA_ARGS__) + #define glGetPointerv(...) GLEGetCurrentFunction(glGetPointerv)(__VA_ARGS__) + #define glGetPolygonStipple(...) GLEGetCurrentFunction(glGetPolygonStipple)(__VA_ARGS__) + #define glGetString(...) GLEGetCurrentFunction(glGetString)(__VA_ARGS__) + #define glGetTexEnvfv(...) GLEGetCurrentFunction(glGetTexEnvfv)(__VA_ARGS__) + #define glGetTexEnviv(...) GLEGetCurrentFunction(glGetTexEnviv)(__VA_ARGS__) + #define glGetTexGendv(...) GLEGetCurrentFunction(glGetTexGendv)(__VA_ARGS__) + #define glGetTexGenfv(...) GLEGetCurrentFunction(glGetTexGenfv)(__VA_ARGS__) + #define glGetTexGeniv(...) GLEGetCurrentFunction(glGetTexGeniv)(__VA_ARGS__) + #define glGetTexImage(...) GLEGetCurrentFunction(glGetTexImage)(__VA_ARGS__) + #define glGetTexLevelParameterfv(...) GLEGetCurrentFunction(glGetTexLevelParameterfv)(__VA_ARGS__) + #define glGetTexLevelParameteriv(...) GLEGetCurrentFunction(glGetTexLevelParameteriv)(__VA_ARGS__) + #define glGetTexParameterfv(...) GLEGetCurrentFunction(glGetTexParameterfv)(__VA_ARGS__) + #define glGetTexParameteriv(...) GLEGetCurrentFunction(glGetTexParameteriv)(__VA_ARGS__) + #define glHint(...) GLEGetCurrentFunction(glHint)(__VA_ARGS__) + #define glIndexMask(...) GLEGetCurrentFunction(glIndexMask)(__VA_ARGS__) + #define glIndexPointer(...) GLEGetCurrentFunction(glIndexPointer)(__VA_ARGS__) + #define glIndexd(...) GLEGetCurrentFunction(glIndexd)(__VA_ARGS__) + #define glIndexdv(...) GLEGetCurrentFunction(glIndexdv)(__VA_ARGS__) + #define glIndexf(...) GLEGetCurrentFunction(glIndexf)(__VA_ARGS__) + #define glIndexfv(...) GLEGetCurrentFunction(glIndexfv)(__VA_ARGS__) + #define glIndexi(...) GLEGetCurrentFunction(glIndexi)(__VA_ARGS__) + #define glIndexiv(...) GLEGetCurrentFunction(glIndexiv)(__VA_ARGS__) + #define glIndexs(...) GLEGetCurrentFunction(glIndexs)(__VA_ARGS__) + #define glIndexsv(...) GLEGetCurrentFunction(glIndexsv)(__VA_ARGS__) + #define glIndexub(...) GLEGetCurrentFunction(glIndexub)(__VA_ARGS__) + #define glIndexubv(...) GLEGetCurrentFunction(glIndexubv)(__VA_ARGS__) + #define glInitNames() GLEGetCurrentFunction(glInitNames)() + #define glInterleavedArrays(...) GLEGetCurrentFunction(glInterleavedArrays)(__VA_ARGS__) + #define glIsEnabled(...) GLEGetCurrentFunction(glIsEnabled)(__VA_ARGS__) + #define glIsList(...) GLEGetCurrentFunction(glIsList)(__VA_ARGS__) + #define glIsTexture(...) GLEGetCurrentFunction(glIsTexture)(__VA_ARGS__) + #define glLightModelf(...) GLEGetCurrentFunction(glLightModelf)(__VA_ARGS__) + #define glLightModelfv(...) GLEGetCurrentFunction(glLightModelfv)(__VA_ARGS__) + #define glLightModeli(...) GLEGetCurrentFunction(glLightModeli)(__VA_ARGS__) + #define glLightModeliv(...) GLEGetCurrentFunction(glLightModeliv)(__VA_ARGS__) + #define glLightf(...) GLEGetCurrentFunction(glLightf)(__VA_ARGS__) + #define glLightfv(...) GLEGetCurrentFunction(glLightfv)(__VA_ARGS__) + #define glLighti(...) GLEGetCurrentFunction(glLighti)(__VA_ARGS__) + #define glLightiv(...) GLEGetCurrentFunction(glLightiv)(__VA_ARGS__) + #define glLineStipple(...) GLEGetCurrentFunction(glLineStipple)(__VA_ARGS__) + #define glLineWidth(...) GLEGetCurrentFunction(glLineWidth)(__VA_ARGS__) + #define glListBase(...) GLEGetCurrentFunction(glListBase)(__VA_ARGS__) + #define glLoadIdentity() GLEGetCurrentFunction(glLoadIdentity)() + #define glLoadMatrixd(...) GLEGetCurrentFunction(glLoadMatrixd)(__VA_ARGS__) + #define glLoadMatrixf(...) GLEGetCurrentFunction(glLoadMatrixf)(__VA_ARGS__) + #define glLoadName(...) GLEGetCurrentFunction(glLoadName)(__VA_ARGS__) + #define glLogicOp(...) GLEGetCurrentFunction(glLogicOp)(__VA_ARGS__) + #define glMap1d(...) GLEGetCurrentFunction(glMap1d)(__VA_ARGS__) + #define glMap1f(...) GLEGetCurrentFunction(glMap1f)(__VA_ARGS__) + #define glMap2d(...) GLEGetCurrentFunction(glMap2d)(__VA_ARGS__) + #define glMap2f(...) GLEGetCurrentFunction(glMap2f)(__VA_ARGS__) + #define glMapGrid1d(...) GLEGetCurrentFunction(glMapGrid1d)(__VA_ARGS__) + #define glMapGrid1f(...) GLEGetCurrentFunction(glMapGrid1f)(__VA_ARGS__) + #define glMapGrid2d(...) GLEGetCurrentFunction(glMapGrid2d)(__VA_ARGS__) + #define glMapGrid2f(...) GLEGetCurrentFunction(glMapGrid2f)(__VA_ARGS__) + #define glMaterialf(...) GLEGetCurrentFunction(glMaterialf)(__VA_ARGS__) + #define glMaterialfv(...) GLEGetCurrentFunction(glMaterialfv)(__VA_ARGS__) + #define glMateriali(...) GLEGetCurrentFunction(glMateriali)(__VA_ARGS__) + #define glMaterialiv(...) GLEGetCurrentFunction(glMaterialiv)(__VA_ARGS__) + #define glMatrixMode(...) GLEGetCurrentFunction(glMatrixMode)(__VA_ARGS__) + #define glMultMatrixd(...) GLEGetCurrentFunction(glMultMatrixd)(__VA_ARGS__) + #define glMultMatrixf(...) GLEGetCurrentFunction(glMultMatrixf)(__VA_ARGS__) + #define glNewList(...) GLEGetCurrentFunction(glNewList)(__VA_ARGS__) + #define glNormal3b(...) GLEGetCurrentFunction(glNormal3b)(__VA_ARGS__) + #define glNormal3bv(...) GLEGetCurrentFunction(glNormal3bv)(__VA_ARGS__) + #define glNormal3d(...) GLEGetCurrentFunction(glNormal3d)(__VA_ARGS__) + #define glNormal3dv(...) GLEGetCurrentFunction(glNormal3dv)(__VA_ARGS__) + #define glNormal3f(...) GLEGetCurrentFunction(glNormal3f)(__VA_ARGS__) + #define glNormal3fv(...) GLEGetCurrentFunction(glNormal3fv)(__VA_ARGS__) + #define glNormal3i(...) GLEGetCurrentFunction(glNormal3i)(__VA_ARGS__) + #define glNormal3iv(...) GLEGetCurrentFunction(glNormal3iv)(__VA_ARGS__) + #define glNormal3s(...) GLEGetCurrentFunction(glNormal3s)(__VA_ARGS__) + #define glNormal3sv(...) GLEGetCurrentFunction(glNormal3sv)(__VA_ARGS__) + #define glNormalPointer(...) GLEGetCurrentFunction(glNormalPointer)(__VA_ARGS__) + #define glOrtho(...) GLEGetCurrentFunction(glOrtho)(__VA_ARGS__) + #define glPassThrough(...) GLEGetCurrentFunction(glPassThrough)(__VA_ARGS__) + #define glPixelMapfv(...) GLEGetCurrentFunction(glPixelMapfv)(__VA_ARGS__) + #define glPixelMapuiv(...) GLEGetCurrentFunction(glPixelMapuiv)(__VA_ARGS__) + #define glPixelMapusv(...) GLEGetCurrentFunction(glPixelMapusv)(__VA_ARGS__) + #define glPixelStoref(...) GLEGetCurrentFunction(glPixelStoref)(__VA_ARGS__) + #define glPixelStorei(...) GLEGetCurrentFunction(glPixelStorei)(__VA_ARGS__) + #define glPixelTransferf(...) GLEGetCurrentFunction(glPixelTransferf)(__VA_ARGS__) + #define glPixelTransferi(...) GLEGetCurrentFunction(glPixelTransferi)(__VA_ARGS__) + #define glPixelZoom(...) GLEGetCurrentFunction(glPixelZoom)(__VA_ARGS__) + #define glPointSize(...) GLEGetCurrentFunction(glPointSize)(__VA_ARGS__) + #define glPolygonMode(...) GLEGetCurrentFunction(glPolygonMode)(__VA_ARGS__) + #define glPolygonOffset(...) GLEGetCurrentFunction(glPolygonOffset)(__VA_ARGS__) + #define glPolygonStipple(...) GLEGetCurrentFunction(glPolygonStipple)(__VA_ARGS__) + #define glPopAttrib() GLEGetCurrentFunction(glPopAttrib)() + #define glPopClientAttrib() GLEGetCurrentFunction(glPopClientAttrib)() + #define glPopMatrix() GLEGetCurrentFunction(glPopMatrix)() + #define glPopName() GLEGetCurrentFunction(glPopName)() + #define glPrioritizeTextures(...) GLEGetCurrentFunction(glPrioritizeTextures)(__VA_ARGS__) + #define glPushAttrib(...) GLEGetCurrentFunction(glPushAttrib)(__VA_ARGS__) + #define glPushClientAttrib(...) GLEGetCurrentFunction(glPushClientAttrib)(__VA_ARGS__) + #define glPushMatrix() GLEGetCurrentFunction(glPushMatrix)() + #define glPushName(...) GLEGetCurrentFunction(glPushName)(__VA_ARGS__) + #define glRasterPos2d(...) GLEGetCurrentFunction(glRasterPos2d)(__VA_ARGS__) + #define glRasterPos2dv(...) GLEGetCurrentFunction(glRasterPos2dv)(__VA_ARGS__) + #define glRasterPos2f(...) GLEGetCurrentFunction(glRasterPos2f)(__VA_ARGS__) + #define glRasterPos2fv(...) GLEGetCurrentFunction(glRasterPos2fv)(__VA_ARGS__) + #define glRasterPos2i(...) GLEGetCurrentFunction(glRasterPos2i)(__VA_ARGS__) + #define glRasterPos2iv(...) GLEGetCurrentFunction(glRasterPos2iv)(__VA_ARGS__) + #define glRasterPos2s(...) GLEGetCurrentFunction(glRasterPos2s)(__VA_ARGS__) + #define glRasterPos2sv(...) GLEGetCurrentFunction(glRasterPos2sv)(__VA_ARGS__) + #define glRasterPos3d(...) GLEGetCurrentFunction(glRasterPos3d)(__VA_ARGS__) + #define glRasterPos3dv(...) GLEGetCurrentFunction(glRasterPos3dv)(__VA_ARGS__) + #define glRasterPos3f(...) GLEGetCurrentFunction(glRasterPos3f)(__VA_ARGS__) + #define glRasterPos3fv(...) GLEGetCurrentFunction(glRasterPos3fv)(__VA_ARGS__) + #define glRasterPos3i(...) GLEGetCurrentFunction(glRasterPos3i)(__VA_ARGS__) + #define glRasterPos3iv(...) GLEGetCurrentFunction(glRasterPos3iv)(__VA_ARGS__) + #define glRasterPos3s(...) GLEGetCurrentFunction(glRasterPos3s)(__VA_ARGS__) + #define glRasterPos3sv(...) GLEGetCurrentFunction(glRasterPos3sv)(__VA_ARGS__) + #define glRasterPos4d(...) GLEGetCurrentFunction(glRasterPos4d)(__VA_ARGS__) + #define glRasterPos4dv(...) GLEGetCurrentFunction(glRasterPos4dv)(__VA_ARGS__) + #define glRasterPos4f(...) GLEGetCurrentFunction(glRasterPos4f)(__VA_ARGS__) + #define glRasterPos4fv(...) GLEGetCurrentFunction(glRasterPos4fv)(__VA_ARGS__) + #define glRasterPos4i(...) GLEGetCurrentFunction(glRasterPos4i)(__VA_ARGS__) + #define glRasterPos4iv(...) GLEGetCurrentFunction(glRasterPos4iv)(__VA_ARGS__) + #define glRasterPos4s(...) GLEGetCurrentFunction(glRasterPos4s)(__VA_ARGS__) + #define glRasterPos4sv(...) GLEGetCurrentFunction(glRasterPos4sv)(__VA_ARGS__) + #define glReadBuffer(...) GLEGetCurrentFunction(glReadBuffer)(__VA_ARGS__) + #define glReadPixels(...) GLEGetCurrentFunction(glReadPixels)(__VA_ARGS__) + #define glRectd(...) GLEGetCurrentFunction(glRectd)(__VA_ARGS__) + #define glRectdv(...) GLEGetCurrentFunction(glRectdv)(__VA_ARGS__) + #define glRectf(...) GLEGetCurrentFunction(glRectf)(__VA_ARGS__) + #define glRectfv(...) GLEGetCurrentFunction(glRectfv)(__VA_ARGS__) + #define glRecti(...) GLEGetCurrentFunction(glRecti)(__VA_ARGS__) + #define glRectiv(...) GLEGetCurrentFunction(glRectiv)(__VA_ARGS__) + #define glRects(...) GLEGetCurrentFunction(glRects)(__VA_ARGS__) + #define glRectsv(...) GLEGetCurrentFunction(glRectsv)(__VA_ARGS__) + #define glRenderMode(...) GLEGetCurrentFunction(glRenderMode)(__VA_ARGS__) + #define glRotated(...) GLEGetCurrentFunction(glRotated)(__VA_ARGS__) + #define glRotatef(...) GLEGetCurrentFunction(glRotatef)(__VA_ARGS__) + #define glScaled(...) GLEGetCurrentFunction(glScaled)(__VA_ARGS__) + #define glScalef(...) GLEGetCurrentFunction(glScalef)(__VA_ARGS__) + #define glScissor(...) GLEGetCurrentFunction(glScissor)(__VA_ARGS__) + #define glSelectBuffer(...) GLEGetCurrentFunction(glSelectBuffer)(__VA_ARGS__) + #define glShadeModel(...) GLEGetCurrentFunction(glShadeModel)(__VA_ARGS__) + #define glStencilFunc(...) GLEGetCurrentFunction(glStencilFunc)(__VA_ARGS__) + #define glStencilMask(...) GLEGetCurrentFunction(glStencilMask)(__VA_ARGS__) + #define glStencilOp(...) GLEGetCurrentFunction(glStencilOp)(__VA_ARGS__) + #define glTexCoord1d(...) GLEGetCurrentFunction(glTexCoord1d)(__VA_ARGS__) + #define glTexCoord1dv(...) GLEGetCurrentFunction(glTexCoord1dv)(__VA_ARGS__) + #define glTexCoord1f(...) GLEGetCurrentFunction(glTexCoord1f)(__VA_ARGS__) + #define glTexCoord1fv(...) GLEGetCurrentFunction(glTexCoord1fv)(__VA_ARGS__) + #define glTexCoord1i(...) GLEGetCurrentFunction(glTexCoord1i)(__VA_ARGS__) + #define glTexCoord1iv(...) GLEGetCurrentFunction(glTexCoord1iv)(__VA_ARGS__) + #define glTexCoord1s(...) GLEGetCurrentFunction(glTexCoord1s)(__VA_ARGS__) + #define glTexCoord1sv(...) GLEGetCurrentFunction(glTexCoord1sv)(__VA_ARGS__) + #define glTexCoord2d(...) GLEGetCurrentFunction(glTexCoord2d)(__VA_ARGS__) + #define glTexCoord2dv(...) GLEGetCurrentFunction(glTexCoord2dv)(__VA_ARGS__) + #define glTexCoord2f(...) GLEGetCurrentFunction(glTexCoord2f)(__VA_ARGS__) + #define glTexCoord2fv(...) GLEGetCurrentFunction(glTexCoord2fv)(__VA_ARGS__) + #define glTexCoord2i(...) GLEGetCurrentFunction(glTexCoord2i)(__VA_ARGS__) + #define glTexCoord2iv(...) GLEGetCurrentFunction(glTexCoord2iv)(__VA_ARGS__) + #define glTexCoord2s(...) GLEGetCurrentFunction(glTexCoord2s)(__VA_ARGS__) + #define glTexCoord2sv(...) GLEGetCurrentFunction(glTexCoord2sv)(__VA_ARGS__) + #define glTexCoord3d(...) GLEGetCurrentFunction(glTexCoord3d)(__VA_ARGS__) + #define glTexCoord3dv(...) GLEGetCurrentFunction(glTexCoord3dv)(__VA_ARGS__) + #define glTexCoord3f(...) GLEGetCurrentFunction(glTexCoord3f)(__VA_ARGS__) + #define glTexCoord3fv(...) GLEGetCurrentFunction(glTexCoord3fv)(__VA_ARGS__) + #define glTexCoord3i(...) GLEGetCurrentFunction(glTexCoord3i)(__VA_ARGS__) + #define glTexCoord3iv(...) GLEGetCurrentFunction(glTexCoord3iv)(__VA_ARGS__) + #define glTexCoord3s(...) GLEGetCurrentFunction(glTexCoord3s)(__VA_ARGS__) + #define glTexCoord3sv(...) GLEGetCurrentFunction(glTexCoord3sv)(__VA_ARGS__) + #define glTexCoord4d(...) GLEGetCurrentFunction(glTexCoord4d)(__VA_ARGS__) + #define glTexCoord4dv(...) GLEGetCurrentFunction(glTexCoord4dv)(__VA_ARGS__) + #define glTexCoord4f(...) GLEGetCurrentFunction(glTexCoord4f)(__VA_ARGS__) + #define glTexCoord4fv(...) GLEGetCurrentFunction(glTexCoord4fv)(__VA_ARGS__) + #define glTexCoord4i(...) GLEGetCurrentFunction(glTexCoord4i)(__VA_ARGS__) + #define glTexCoord4iv(...) GLEGetCurrentFunction(glTexCoord4iv)(__VA_ARGS__) + #define glTexCoord4s(...) GLEGetCurrentFunction(glTexCoord4s)(__VA_ARGS__) + #define glTexCoord4sv(...) GLEGetCurrentFunction(glTexCoord4sv)(__VA_ARGS__) + #define glTexCoordPointer(...) GLEGetCurrentFunction(glTexCoordPointer)(__VA_ARGS__) + #define glTexEnvf(...) GLEGetCurrentFunction(glTexEnvf)(__VA_ARGS__) + #define glTexEnvfv(...) GLEGetCurrentFunction(glTexEnvfv)(__VA_ARGS__) + #define glTexEnvi(...) GLEGetCurrentFunction(glTexEnvi)(__VA_ARGS__) + #define glTexEnviv(...) GLEGetCurrentFunction(glTexEnviv)(__VA_ARGS__) + #define glTexGend(...) GLEGetCurrentFunction(glTexGend)(__VA_ARGS__) + #define glTexGendv(...) GLEGetCurrentFunction(glTexGendv)(__VA_ARGS__) + #define glTexGenf(...) GLEGetCurrentFunction(glTexGenf)(__VA_ARGS__) + #define glTexGenfv(...) GLEGetCurrentFunction(glTexGenfv)(__VA_ARGS__) + #define glTexGeni(...) GLEGetCurrentFunction(glTexGeni)(__VA_ARGS__) + #define glTexGeniv(...) GLEGetCurrentFunction(glTexGeniv)(__VA_ARGS__) + #define glTexImage1D(...) GLEGetCurrentFunction(glTexImage1D)(__VA_ARGS__) + #define glTexImage2D(...) GLEGetCurrentFunction(glTexImage2D)(__VA_ARGS__) + #define glTexParameterf(...) GLEGetCurrentFunction(glTexParameterf)(__VA_ARGS__) + #define glTexParameterfv(...) GLEGetCurrentFunction(glTexParameterfv)(__VA_ARGS__) + #define glTexParameteri(...) GLEGetCurrentFunction(glTexParameteri)(__VA_ARGS__) + #define glTexParameteriv(...) GLEGetCurrentFunction(glTexParameteriv)(__VA_ARGS__) + #define glTexSubImage1D(...) GLEGetCurrentFunction(glTexSubImage1D)(__VA_ARGS__) + #define glTexSubImage2D(...) GLEGetCurrentFunction(glTexSubImage2D)(__VA_ARGS__) + #define glTranslated(...) GLEGetCurrentFunction(glTranslated)(__VA_ARGS__) + #define glTranslatef(...) GLEGetCurrentFunction(glTranslatef)(__VA_ARGS__) + #define glVertex2d(...) GLEGetCurrentFunction(glVertex2d)(__VA_ARGS__) + #define glVertex2dv(...) GLEGetCurrentFunction(glVertex2dv)(__VA_ARGS__) + #define glVertex2f(...) GLEGetCurrentFunction(glVertex2f)(__VA_ARGS__) + #define glVertex2fv(...) GLEGetCurrentFunction(glVertex2fv)(__VA_ARGS__) + #define glVertex2i(...) GLEGetCurrentFunction(glVertex2i)(__VA_ARGS__) + #define glVertex2iv(...) GLEGetCurrentFunction(glVertex2iv)(__VA_ARGS__) + #define glVertex2s(...) GLEGetCurrentFunction(glVertex2s)(__VA_ARGS__) + #define glVertex2sv(...) GLEGetCurrentFunction(glVertex2sv)(__VA_ARGS__) + #define glVertex3d(...) GLEGetCurrentFunction(glVertex3d)(__VA_ARGS__) + #define glVertex3dv(...) GLEGetCurrentFunction(glVertex3dv)(__VA_ARGS__) + #define glVertex3f(...) GLEGetCurrentFunction(glVertex3f)(__VA_ARGS__) + #define glVertex3fv(...) GLEGetCurrentFunction(glVertex3fv)(__VA_ARGS__) + #define glVertex3i(...) GLEGetCurrentFunction(glVertex3i)(__VA_ARGS__) + #define glVertex3iv(...) GLEGetCurrentFunction(glVertex3iv)(__VA_ARGS__) + #define glVertex3s(...) GLEGetCurrentFunction(glVertex3s)(__VA_ARGS__) + #define glVertex3sv(...) GLEGetCurrentFunction(glVertex3sv)(__VA_ARGS__) + #define glVertex4d(...) GLEGetCurrentFunction(glVertex4d)(__VA_ARGS__) + #define glVertex4dv(...) GLEGetCurrentFunction(glVertex4dv)(__VA_ARGS__) + #define glVertex4f(...) GLEGetCurrentFunction(glVertex4f)(__VA_ARGS__) + #define glVertex4fv(...) GLEGetCurrentFunction(glVertex4fv)(__VA_ARGS__) + #define glVertex4i(...) GLEGetCurrentFunction(glVertex4i)(__VA_ARGS__) + #define glVertex4iv(...) GLEGetCurrentFunction(glVertex4iv)(__VA_ARGS__) + #define glVertex4s(...) GLEGetCurrentFunction(glVertex4s)(__VA_ARGS__) + #define glVertex4sv(...) GLEGetCurrentFunction(glVertex4sv)(__VA_ARGS__) + #define glVertexPointer(...) GLEGetCurrentFunction(glVertexPointer)(__VA_ARGS__) + #define glViewport(...) GLEGetCurrentFunction(glViewport)(__VA_ARGS__) + #else + // There is no need to typedef OpenGL 1.1 function types because they are present in all + // OpenGL implementations and don't need to be treated dynamically like extensions. + GLAPI void GLAPIENTRY glAccum (GLenum op, GLfloat value); + GLAPI void GLAPIENTRY glAlphaFunc (GLenum func, GLclampf ref); + GLAPI GLboolean GLAPIENTRY glAreTexturesResident (GLsizei n, const GLuint *textures, GLboolean *residences); + GLAPI void GLAPIENTRY glArrayElement (GLint i); + GLAPI void GLAPIENTRY glBegin (GLenum mode); + GLAPI void GLAPIENTRY glBindTexture (GLenum target, GLuint texture); + GLAPI void GLAPIENTRY glBitmap (GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap); + GLAPI void GLAPIENTRY glBlendFunc (GLenum sfactor, GLenum dfactor); + GLAPI void GLAPIENTRY glCallList (GLuint list); + GLAPI void GLAPIENTRY glCallLists (GLsizei n, GLenum type, const void *lists); + GLAPI void GLAPIENTRY glClear (GLbitfield mask); + GLAPI void GLAPIENTRY glClearAccum (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); + GLAPI void GLAPIENTRY glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); + GLAPI void GLAPIENTRY glClearDepth (GLclampd depth); + GLAPI void GLAPIENTRY glClearIndex (GLfloat c); + GLAPI void GLAPIENTRY glClearStencil (GLint s); + GLAPI void GLAPIENTRY glClipPlane (GLenum plane, const GLdouble *equation); + GLAPI void GLAPIENTRY glColor3b (GLbyte red, GLbyte green, GLbyte blue); + GLAPI void GLAPIENTRY glColor3bv (const GLbyte *v); + GLAPI void GLAPIENTRY glColor3d (GLdouble red, GLdouble green, GLdouble blue); + GLAPI void GLAPIENTRY glColor3dv (const GLdouble *v); + GLAPI void GLAPIENTRY glColor3f (GLfloat red, GLfloat green, GLfloat blue); + GLAPI void GLAPIENTRY glColor3fv (const GLfloat *v); + GLAPI void GLAPIENTRY glColor3i (GLint red, GLint green, GLint blue); + GLAPI void GLAPIENTRY glColor3iv (const GLint *v); + GLAPI void GLAPIENTRY glColor3s (GLshort red, GLshort green, GLshort blue); + GLAPI void GLAPIENTRY glColor3sv (const GLshort *v); + GLAPI void GLAPIENTRY glColor3ub (GLubyte red, GLubyte green, GLubyte blue); + GLAPI void GLAPIENTRY glColor3ubv (const GLubyte *v); + GLAPI void GLAPIENTRY glColor3ui (GLuint red, GLuint green, GLuint blue); + GLAPI void GLAPIENTRY glColor3uiv (const GLuint *v); + GLAPI void GLAPIENTRY glColor3us (GLushort red, GLushort green, GLushort blue); + GLAPI void GLAPIENTRY glColor3usv (const GLushort *v); + GLAPI void GLAPIENTRY glColor4b (GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha); + GLAPI void GLAPIENTRY glColor4bv (const GLbyte *v); + GLAPI void GLAPIENTRY glColor4d (GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha); + GLAPI void GLAPIENTRY glColor4dv (const GLdouble *v); + GLAPI void GLAPIENTRY glColor4f (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); + GLAPI void GLAPIENTRY glColor4fv (const GLfloat *v); + GLAPI void GLAPIENTRY glColor4i (GLint red, GLint green, GLint blue, GLint alpha); + GLAPI void GLAPIENTRY glColor4iv (const GLint *v); + GLAPI void GLAPIENTRY glColor4s (GLshort red, GLshort green, GLshort blue, GLshort alpha); + GLAPI void GLAPIENTRY glColor4sv (const GLshort *v); + GLAPI void GLAPIENTRY glColor4ub (GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha); + GLAPI void GLAPIENTRY glColor4ubv (const GLubyte *v); + GLAPI void GLAPIENTRY glColor4ui (GLuint red, GLuint green, GLuint blue, GLuint alpha); + GLAPI void GLAPIENTRY glColor4uiv (const GLuint *v); + GLAPI void GLAPIENTRY glColor4us (GLushort red, GLushort green, GLushort blue, GLushort alpha); + GLAPI void GLAPIENTRY glColor4usv (const GLushort *v); + GLAPI void GLAPIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); + GLAPI void GLAPIENTRY glColorMaterial (GLenum face, GLenum mode); + GLAPI void GLAPIENTRY glColorPointer (GLint size, GLenum type, GLsizei stride, const void *pointer); + GLAPI void GLAPIENTRY glCopyPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum type); + GLAPI void GLAPIENTRY glCopyTexImage1D (GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLint border); + GLAPI void GLAPIENTRY glCopyTexImage2D (GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); + GLAPI void GLAPIENTRY glCopyTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); + GLAPI void GLAPIENTRY glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); + GLAPI void GLAPIENTRY glCullFace (GLenum mode); + GLAPI void GLAPIENTRY glDeleteLists (GLuint list, GLsizei range); + GLAPI void GLAPIENTRY glDeleteTextures (GLsizei n, const GLuint *textures); + GLAPI void GLAPIENTRY glDepthFunc (GLenum func); + GLAPI void GLAPIENTRY glDepthMask (GLboolean flag); + GLAPI void GLAPIENTRY glDepthRange (GLclampd zNear, GLclampd zFar); + GLAPI void GLAPIENTRY glDisable (GLenum cap); + GLAPI void GLAPIENTRY glDisableClientState (GLenum array); + GLAPI void GLAPIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count); + GLAPI void GLAPIENTRY glDrawBuffer (GLenum mode); + GLAPI void GLAPIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const void *indices); + GLAPI void GLAPIENTRY glDrawPixels (GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); + GLAPI void GLAPIENTRY glEdgeFlag (GLboolean flag); + GLAPI void GLAPIENTRY glEdgeFlagPointer (GLsizei stride, const void *pointer); + GLAPI void GLAPIENTRY glEdgeFlagv (const GLboolean *flag); + GLAPI void GLAPIENTRY glEnable (GLenum cap); + GLAPI void GLAPIENTRY glEnableClientState (GLenum array); + GLAPI void GLAPIENTRY glEnd (void); + GLAPI void GLAPIENTRY glEndList (void); + GLAPI void GLAPIENTRY glEvalCoord1d (GLdouble u); + GLAPI void GLAPIENTRY glEvalCoord1dv (const GLdouble *u); + GLAPI void GLAPIENTRY glEvalCoord1f (GLfloat u); + GLAPI void GLAPIENTRY glEvalCoord1fv (const GLfloat *u); + GLAPI void GLAPIENTRY glEvalCoord2d (GLdouble u, GLdouble v); + GLAPI void GLAPIENTRY glEvalCoord2dv (const GLdouble *u); + GLAPI void GLAPIENTRY glEvalCoord2f (GLfloat u, GLfloat v); + GLAPI void GLAPIENTRY glEvalCoord2fv (const GLfloat *u); + GLAPI void GLAPIENTRY glEvalMesh1 (GLenum mode, GLint i1, GLint i2); + GLAPI void GLAPIENTRY glEvalMesh2 (GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2); + GLAPI void GLAPIENTRY glEvalPoint1 (GLint i); + GLAPI void GLAPIENTRY glEvalPoint2 (GLint i, GLint j); + GLAPI void GLAPIENTRY glFeedbackBuffer (GLsizei size, GLenum type, GLfloat *buffer); + GLAPI void GLAPIENTRY glFinish (void); + GLAPI void GLAPIENTRY glFlush (void); + GLAPI void GLAPIENTRY glFogf (GLenum pname, GLfloat param); + GLAPI void GLAPIENTRY glFogfv (GLenum pname, const GLfloat *params); + GLAPI void GLAPIENTRY glFogi (GLenum pname, GLint param); + GLAPI void GLAPIENTRY glFogiv (GLenum pname, const GLint *params); + GLAPI void GLAPIENTRY glFrontFace (GLenum mode); + GLAPI void GLAPIENTRY glFrustum (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); + GLAPI GLuint GLAPIENTRY glGenLists (GLsizei range); + GLAPI void GLAPIENTRY glGenTextures (GLsizei n, GLuint *textures); + GLAPI void GLAPIENTRY glGetBooleanv (GLenum pname, GLboolean *params); + GLAPI void GLAPIENTRY glGetClipPlane (GLenum plane, GLdouble *equation); + GLAPI void GLAPIENTRY glGetDoublev (GLenum pname, GLdouble *params); + GLAPI GLenum GLAPIENTRY glGetError (void); + GLAPI void GLAPIENTRY glGetFloatv (GLenum pname, GLfloat *params); + GLAPI void GLAPIENTRY glGetIntegerv (GLenum pname, GLint *params); + GLAPI void GLAPIENTRY glGetLightfv (GLenum light, GLenum pname, GLfloat *params); + GLAPI void GLAPIENTRY glGetLightiv (GLenum light, GLenum pname, GLint *params); + GLAPI void GLAPIENTRY glGetMapdv (GLenum target, GLenum query, GLdouble *v); + GLAPI void GLAPIENTRY glGetMapfv (GLenum target, GLenum query, GLfloat *v); + GLAPI void GLAPIENTRY glGetMapiv (GLenum target, GLenum query, GLint *v); + GLAPI void GLAPIENTRY glGetMaterialfv (GLenum face, GLenum pname, GLfloat *params); + GLAPI void GLAPIENTRY glGetMaterialiv (GLenum face, GLenum pname, GLint *params); + GLAPI void GLAPIENTRY glGetPixelMapfv (GLenum map, GLfloat *values); + GLAPI void GLAPIENTRY glGetPixelMapuiv (GLenum map, GLuint *values); + GLAPI void GLAPIENTRY glGetPixelMapusv (GLenum map, GLushort *values); + GLAPI void GLAPIENTRY glGetPointerv (GLenum pname, void* *params); + GLAPI void GLAPIENTRY glGetPolygonStipple (GLubyte *mask); + GLAPI const GLubyte * GLAPIENTRY glGetString (GLenum name); + GLAPI void GLAPIENTRY glGetTexEnvfv (GLenum target, GLenum pname, GLfloat *params); + GLAPI void GLAPIENTRY glGetTexEnviv (GLenum target, GLenum pname, GLint *params); + GLAPI void GLAPIENTRY glGetTexGendv (GLenum coord, GLenum pname, GLdouble *params); + GLAPI void GLAPIENTRY glGetTexGenfv (GLenum coord, GLenum pname, GLfloat *params); + GLAPI void GLAPIENTRY glGetTexGeniv (GLenum coord, GLenum pname, GLint *params); + GLAPI void GLAPIENTRY glGetTexImage (GLenum target, GLint level, GLenum format, GLenum type, void *pixels); + GLAPI void GLAPIENTRY glGetTexLevelParameterfv (GLenum target, GLint level, GLenum pname, GLfloat *params); + GLAPI void GLAPIENTRY glGetTexLevelParameteriv (GLenum target, GLint level, GLenum pname, GLint *params); + GLAPI void GLAPIENTRY glGetTexParameterfv (GLenum target, GLenum pname, GLfloat *params); + GLAPI void GLAPIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint *params); + GLAPI void GLAPIENTRY glHint (GLenum target, GLenum mode); + GLAPI void GLAPIENTRY glIndexMask (GLuint mask); + GLAPI void GLAPIENTRY glIndexPointer (GLenum type, GLsizei stride, const void *pointer); + GLAPI void GLAPIENTRY glIndexd (GLdouble c); + GLAPI void GLAPIENTRY glIndexdv (const GLdouble *c); + GLAPI void GLAPIENTRY glIndexf (GLfloat c); + GLAPI void GLAPIENTRY glIndexfv (const GLfloat *c); + GLAPI void GLAPIENTRY glIndexi (GLint c); + GLAPI void GLAPIENTRY glIndexiv (const GLint *c); + GLAPI void GLAPIENTRY glIndexs (GLshort c); + GLAPI void GLAPIENTRY glIndexsv (const GLshort *c); + GLAPI void GLAPIENTRY glIndexub (GLubyte c); + GLAPI void GLAPIENTRY glIndexubv (const GLubyte *c); + GLAPI void GLAPIENTRY glInitNames (void); + GLAPI void GLAPIENTRY glInterleavedArrays (GLenum format, GLsizei stride, const void *pointer); + GLAPI GLboolean GLAPIENTRY glIsEnabled (GLenum cap); + GLAPI GLboolean GLAPIENTRY glIsList (GLuint list); + GLAPI GLboolean GLAPIENTRY glIsTexture (GLuint texture); + GLAPI void GLAPIENTRY glLightModelf (GLenum pname, GLfloat param); + GLAPI void GLAPIENTRY glLightModelfv (GLenum pname, const GLfloat *params); + GLAPI void GLAPIENTRY glLightModeli (GLenum pname, GLint param); + GLAPI void GLAPIENTRY glLightModeliv (GLenum pname, const GLint *params); + GLAPI void GLAPIENTRY glLightf (GLenum light, GLenum pname, GLfloat param); + GLAPI void GLAPIENTRY glLightfv (GLenum light, GLenum pname, const GLfloat *params); + GLAPI void GLAPIENTRY glLighti (GLenum light, GLenum pname, GLint param); + GLAPI void GLAPIENTRY glLightiv (GLenum light, GLenum pname, const GLint *params); + GLAPI void GLAPIENTRY glLineStipple (GLint factor, GLushort pattern); + GLAPI void GLAPIENTRY glLineWidth (GLfloat width); + GLAPI void GLAPIENTRY glListBase (GLuint base); + GLAPI void GLAPIENTRY glLoadIdentity (void); + GLAPI void GLAPIENTRY glLoadMatrixd (const GLdouble *m); + GLAPI void GLAPIENTRY glLoadMatrixf (const GLfloat *m); + GLAPI void GLAPIENTRY glLoadName (GLuint name); + GLAPI void GLAPIENTRY glLogicOp (GLenum opcode); + GLAPI void GLAPIENTRY glMap1d (GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); + GLAPI void GLAPIENTRY glMap1f (GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); + GLAPI void GLAPIENTRY glMap2d (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); + GLAPI void GLAPIENTRY glMap2f (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); + GLAPI void GLAPIENTRY glMapGrid1d (GLint un, GLdouble u1, GLdouble u2); + GLAPI void GLAPIENTRY glMapGrid1f (GLint un, GLfloat u1, GLfloat u2); + GLAPI void GLAPIENTRY glMapGrid2d (GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2); + GLAPI void GLAPIENTRY glMapGrid2f (GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2); + GLAPI void GLAPIENTRY glMaterialf (GLenum face, GLenum pname, GLfloat param); + GLAPI void GLAPIENTRY glMaterialfv (GLenum face, GLenum pname, const GLfloat *params); + GLAPI void GLAPIENTRY glMateriali (GLenum face, GLenum pname, GLint param); + GLAPI void GLAPIENTRY glMaterialiv (GLenum face, GLenum pname, const GLint *params); + GLAPI void GLAPIENTRY glMatrixMode (GLenum mode); + GLAPI void GLAPIENTRY glMultMatrixd (const GLdouble *m); + GLAPI void GLAPIENTRY glMultMatrixf (const GLfloat *m); + GLAPI void GLAPIENTRY glNewList (GLuint list, GLenum mode); + GLAPI void GLAPIENTRY glNormal3b (GLbyte nx, GLbyte ny, GLbyte nz); + GLAPI void GLAPIENTRY glNormal3bv (const GLbyte *v); + GLAPI void GLAPIENTRY glNormal3d (GLdouble nx, GLdouble ny, GLdouble nz); + GLAPI void GLAPIENTRY glNormal3dv (const GLdouble *v); + GLAPI void GLAPIENTRY glNormal3f (GLfloat nx, GLfloat ny, GLfloat nz); + GLAPI void GLAPIENTRY glNormal3fv (const GLfloat *v); + GLAPI void GLAPIENTRY glNormal3i (GLint nx, GLint ny, GLint nz); + GLAPI void GLAPIENTRY glNormal3iv (const GLint *v); + GLAPI void GLAPIENTRY glNormal3s (GLshort nx, GLshort ny, GLshort nz); + GLAPI void GLAPIENTRY glNormal3sv (const GLshort *v); + GLAPI void GLAPIENTRY glNormalPointer (GLenum type, GLsizei stride, const void *pointer); + GLAPI void GLAPIENTRY glOrtho (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); + GLAPI void GLAPIENTRY glPassThrough (GLfloat token); + GLAPI void GLAPIENTRY glPixelMapfv (GLenum map, GLsizei mapsize, const GLfloat *values); + GLAPI void GLAPIENTRY glPixelMapuiv (GLenum map, GLsizei mapsize, const GLuint *values); + GLAPI void GLAPIENTRY glPixelMapusv (GLenum map, GLsizei mapsize, const GLushort *values); + GLAPI void GLAPIENTRY glPixelStoref (GLenum pname, GLfloat param); + GLAPI void GLAPIENTRY glPixelStorei (GLenum pname, GLint param); + GLAPI void GLAPIENTRY glPixelTransferf (GLenum pname, GLfloat param); + GLAPI void GLAPIENTRY glPixelTransferi (GLenum pname, GLint param); + GLAPI void GLAPIENTRY glPixelZoom (GLfloat xfactor, GLfloat yfactor); + GLAPI void GLAPIENTRY glPointSize (GLfloat size); + GLAPI void GLAPIENTRY glPolygonMode (GLenum face, GLenum mode); + GLAPI void GLAPIENTRY glPolygonOffset (GLfloat factor, GLfloat units); + GLAPI void GLAPIENTRY glPolygonStipple (const GLubyte *mask); + GLAPI void GLAPIENTRY glPopAttrib (void); + GLAPI void GLAPIENTRY glPopClientAttrib (void); + GLAPI void GLAPIENTRY glPopMatrix (void); + GLAPI void GLAPIENTRY glPopName (void); + GLAPI void GLAPIENTRY glPrioritizeTextures (GLsizei n, const GLuint *textures, const GLclampf *priorities); + GLAPI void GLAPIENTRY glPushAttrib (GLbitfield mask); + GLAPI void GLAPIENTRY glPushClientAttrib (GLbitfield mask); + GLAPI void GLAPIENTRY glPushMatrix (void); + GLAPI void GLAPIENTRY glPushName (GLuint name); + GLAPI void GLAPIENTRY glRasterPos2d (GLdouble x, GLdouble y); + GLAPI void GLAPIENTRY glRasterPos2dv (const GLdouble *v); + GLAPI void GLAPIENTRY glRasterPos2f (GLfloat x, GLfloat y); + GLAPI void GLAPIENTRY glRasterPos2fv (const GLfloat *v); + GLAPI void GLAPIENTRY glRasterPos2i (GLint x, GLint y); + GLAPI void GLAPIENTRY glRasterPos2iv (const GLint *v); + GLAPI void GLAPIENTRY glRasterPos2s (GLshort x, GLshort y); + GLAPI void GLAPIENTRY glRasterPos2sv (const GLshort *v); + GLAPI void GLAPIENTRY glRasterPos3d (GLdouble x, GLdouble y, GLdouble z); + GLAPI void GLAPIENTRY glRasterPos3dv (const GLdouble *v); + GLAPI void GLAPIENTRY glRasterPos3f (GLfloat x, GLfloat y, GLfloat z); + GLAPI void GLAPIENTRY glRasterPos3fv (const GLfloat *v); + GLAPI void GLAPIENTRY glRasterPos3i (GLint x, GLint y, GLint z); + GLAPI void GLAPIENTRY glRasterPos3iv (const GLint *v); + GLAPI void GLAPIENTRY glRasterPos3s (GLshort x, GLshort y, GLshort z); + GLAPI void GLAPIENTRY glRasterPos3sv (const GLshort *v); + GLAPI void GLAPIENTRY glRasterPos4d (GLdouble x, GLdouble y, GLdouble z, GLdouble w); + GLAPI void GLAPIENTRY glRasterPos4dv (const GLdouble *v); + GLAPI void GLAPIENTRY glRasterPos4f (GLfloat x, GLfloat y, GLfloat z, GLfloat w); + GLAPI void GLAPIENTRY glRasterPos4fv (const GLfloat *v); + GLAPI void GLAPIENTRY glRasterPos4i (GLint x, GLint y, GLint z, GLint w); + GLAPI void GLAPIENTRY glRasterPos4iv (const GLint *v); + GLAPI void GLAPIENTRY glRasterPos4s (GLshort x, GLshort y, GLshort z, GLshort w); + GLAPI void GLAPIENTRY glRasterPos4sv (const GLshort *v); + GLAPI void GLAPIENTRY glReadBuffer (GLenum mode); + GLAPI void GLAPIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels); + GLAPI void GLAPIENTRY glRectd (GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2); + GLAPI void GLAPIENTRY glRectdv (const GLdouble *v1, const GLdouble *v2); + GLAPI void GLAPIENTRY glRectf (GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2); + GLAPI void GLAPIENTRY glRectfv (const GLfloat *v1, const GLfloat *v2); + GLAPI void GLAPIENTRY glRecti (GLint x1, GLint y1, GLint x2, GLint y2); + GLAPI void GLAPIENTRY glRectiv (const GLint *v1, const GLint *v2); + GLAPI void GLAPIENTRY glRects (GLshort x1, GLshort y1, GLshort x2, GLshort y2); + GLAPI void GLAPIENTRY glRectsv (const GLshort *v1, const GLshort *v2); + GLAPI GLint GLAPIENTRY glRenderMode (GLenum mode); + GLAPI void GLAPIENTRY glRotated (GLdouble angle, GLdouble x, GLdouble y, GLdouble z); + GLAPI void GLAPIENTRY glRotatef (GLfloat angle, GLfloat x, GLfloat y, GLfloat z); + GLAPI void GLAPIENTRY glScaled (GLdouble x, GLdouble y, GLdouble z); + GLAPI void GLAPIENTRY glScalef (GLfloat x, GLfloat y, GLfloat z); + GLAPI void GLAPIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height); + GLAPI void GLAPIENTRY glSelectBuffer (GLsizei size, GLuint *buffer); + GLAPI void GLAPIENTRY glShadeModel (GLenum mode); + GLAPI void GLAPIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask); + GLAPI void GLAPIENTRY glStencilMask (GLuint mask); + GLAPI void GLAPIENTRY glStencilOp (GLenum fail, GLenum zfail, GLenum zpass); + GLAPI void GLAPIENTRY glTexCoord1d (GLdouble s); + GLAPI void GLAPIENTRY glTexCoord1dv (const GLdouble *v); + GLAPI void GLAPIENTRY glTexCoord1f (GLfloat s); + GLAPI void GLAPIENTRY glTexCoord1fv (const GLfloat *v); + GLAPI void GLAPIENTRY glTexCoord1i (GLint s); + GLAPI void GLAPIENTRY glTexCoord1iv (const GLint *v); + GLAPI void GLAPIENTRY glTexCoord1s (GLshort s); + GLAPI void GLAPIENTRY glTexCoord1sv (const GLshort *v); + GLAPI void GLAPIENTRY glTexCoord2d (GLdouble s, GLdouble t); + GLAPI void GLAPIENTRY glTexCoord2dv (const GLdouble *v); + GLAPI void GLAPIENTRY glTexCoord2f (GLfloat s, GLfloat t); + GLAPI void GLAPIENTRY glTexCoord2fv (const GLfloat *v); + GLAPI void GLAPIENTRY glTexCoord2i (GLint s, GLint t); + GLAPI void GLAPIENTRY glTexCoord2iv (const GLint *v); + GLAPI void GLAPIENTRY glTexCoord2s (GLshort s, GLshort t); + GLAPI void GLAPIENTRY glTexCoord2sv (const GLshort *v); + GLAPI void GLAPIENTRY glTexCoord3d (GLdouble s, GLdouble t, GLdouble r); + GLAPI void GLAPIENTRY glTexCoord3dv (const GLdouble *v); + GLAPI void GLAPIENTRY glTexCoord3f (GLfloat s, GLfloat t, GLfloat r); + GLAPI void GLAPIENTRY glTexCoord3fv (const GLfloat *v); + GLAPI void GLAPIENTRY glTexCoord3i (GLint s, GLint t, GLint r); + GLAPI void GLAPIENTRY glTexCoord3iv (const GLint *v); + GLAPI void GLAPIENTRY glTexCoord3s (GLshort s, GLshort t, GLshort r); + GLAPI void GLAPIENTRY glTexCoord3sv (const GLshort *v); + GLAPI void GLAPIENTRY glTexCoord4d (GLdouble s, GLdouble t, GLdouble r, GLdouble q); + GLAPI void GLAPIENTRY glTexCoord4dv (const GLdouble *v); + GLAPI void GLAPIENTRY glTexCoord4f (GLfloat s, GLfloat t, GLfloat r, GLfloat q); + GLAPI void GLAPIENTRY glTexCoord4fv (const GLfloat *v); + GLAPI void GLAPIENTRY glTexCoord4i (GLint s, GLint t, GLint r, GLint q); + GLAPI void GLAPIENTRY glTexCoord4iv (const GLint *v); + GLAPI void GLAPIENTRY glTexCoord4s (GLshort s, GLshort t, GLshort r, GLshort q); + GLAPI void GLAPIENTRY glTexCoord4sv (const GLshort *v); + GLAPI void GLAPIENTRY glTexCoordPointer (GLint size, GLenum type, GLsizei stride, const void *pointer); + GLAPI void GLAPIENTRY glTexEnvf (GLenum target, GLenum pname, GLfloat param); + GLAPI void GLAPIENTRY glTexEnvfv (GLenum target, GLenum pname, const GLfloat *params); + GLAPI void GLAPIENTRY glTexEnvi (GLenum target, GLenum pname, GLint param); + GLAPI void GLAPIENTRY glTexEnviv (GLenum target, GLenum pname, const GLint *params); + GLAPI void GLAPIENTRY glTexGend (GLenum coord, GLenum pname, GLdouble param); + GLAPI void GLAPIENTRY glTexGendv (GLenum coord, GLenum pname, const GLdouble *params); + GLAPI void GLAPIENTRY glTexGenf (GLenum coord, GLenum pname, GLfloat param); + GLAPI void GLAPIENTRY glTexGenfv (GLenum coord, GLenum pname, const GLfloat *params); + GLAPI void GLAPIENTRY glTexGeni (GLenum coord, GLenum pname, GLint param); + GLAPI void GLAPIENTRY glTexGeniv (GLenum coord, GLenum pname, const GLint *params); + GLAPI void GLAPIENTRY glTexImage1D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); + GLAPI void GLAPIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); + GLAPI void GLAPIENTRY glTexParameterf (GLenum target, GLenum pname, GLfloat param); + GLAPI void GLAPIENTRY glTexParameterfv (GLenum target, GLenum pname, const GLfloat *params); + GLAPI void GLAPIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param); + GLAPI void GLAPIENTRY glTexParameteriv (GLenum target, GLenum pname, const GLint *params); + GLAPI void GLAPIENTRY glTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); + GLAPI void GLAPIENTRY glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); + GLAPI void GLAPIENTRY glTranslated (GLdouble x, GLdouble y, GLdouble z); + GLAPI void GLAPIENTRY glTranslatef (GLfloat x, GLfloat y, GLfloat z); + GLAPI void GLAPIENTRY glVertex2d (GLdouble x, GLdouble y); + GLAPI void GLAPIENTRY glVertex2dv (const GLdouble *v); + GLAPI void GLAPIENTRY glVertex2f (GLfloat x, GLfloat y); + GLAPI void GLAPIENTRY glVertex2fv (const GLfloat *v); + GLAPI void GLAPIENTRY glVertex2i (GLint x, GLint y); + GLAPI void GLAPIENTRY glVertex2iv (const GLint *v); + GLAPI void GLAPIENTRY glVertex2s (GLshort x, GLshort y); + GLAPI void GLAPIENTRY glVertex2sv (const GLshort *v); + GLAPI void GLAPIENTRY glVertex3d (GLdouble x, GLdouble y, GLdouble z); + GLAPI void GLAPIENTRY glVertex3dv (const GLdouble *v); + GLAPI void GLAPIENTRY glVertex3f (GLfloat x, GLfloat y, GLfloat z); + GLAPI void GLAPIENTRY glVertex3fv (const GLfloat *v); + GLAPI void GLAPIENTRY glVertex3i (GLint x, GLint y, GLint z); + GLAPI void GLAPIENTRY glVertex3iv (const GLint *v); + GLAPI void GLAPIENTRY glVertex3s (GLshort x, GLshort y, GLshort z); + GLAPI void GLAPIENTRY glVertex3sv (const GLshort *v); + GLAPI void GLAPIENTRY glVertex4d (GLdouble x, GLdouble y, GLdouble z, GLdouble w); + GLAPI void GLAPIENTRY glVertex4dv (const GLdouble *v); + GLAPI void GLAPIENTRY glVertex4f (GLfloat x, GLfloat y, GLfloat z, GLfloat w); + GLAPI void GLAPIENTRY glVertex4fv (const GLfloat *v); + GLAPI void GLAPIENTRY glVertex4i (GLint x, GLint y, GLint z, GLint w); + GLAPI void GLAPIENTRY glVertex4iv (const GLint *v); + GLAPI void GLAPIENTRY glVertex4s (GLshort x, GLshort y, GLshort z, GLshort w); + GLAPI void GLAPIENTRY glVertex4sv (const GLshort *v); + GLAPI void GLAPIENTRY glVertexPointer (GLint size, GLenum type, GLsizei stride, const void *pointer); + GLAPI void GLAPIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height); + + #endif // GLE_HOOKING_ENABLED + +#endif // GL_VERSION_1_1 + + + + +// OpenGL 1.2+ functions are not declared in Microsoft's gl.h + +#ifndef GL_VERSION_1_2 + #define GL_VERSION_1_2 1 + + #define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 + #define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 + #define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 + #define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 + #define GL_UNSIGNED_BYTE_3_3_2 0x8032 + #define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 + #define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 + #define GL_UNSIGNED_INT_8_8_8_8 0x8035 + #define GL_UNSIGNED_INT_10_10_10_2 0x8036 + #define GL_RESCALE_NORMAL 0x803A + #define GL_TEXTURE_BINDING_3D 0x806A + #define GL_PACK_SKIP_IMAGES 0x806B + #define GL_PACK_IMAGE_HEIGHT 0x806C + #define GL_UNPACK_SKIP_IMAGES 0x806D + #define GL_UNPACK_IMAGE_HEIGHT 0x806E + #define GL_TEXTURE_3D 0x806F + #define GL_PROXY_TEXTURE_3D 0x8070 + #define GL_TEXTURE_DEPTH 0x8071 + #define GL_TEXTURE_WRAP_R 0x8072 + #define GL_MAX_3D_TEXTURE_SIZE 0x8073 + #define GL_BGR 0x80E0 + #define GL_BGRA 0x80E1 + #define GL_MAX_ELEMENTS_VERTICES 0x80E8 + #define GL_MAX_ELEMENTS_INDICES 0x80E9 + #define GL_CLAMP_TO_EDGE 0x812F + #define GL_TEXTURE_MIN_LOD 0x813A + #define GL_TEXTURE_MAX_LOD 0x813B + #define GL_TEXTURE_BASE_LEVEL 0x813C + #define GL_TEXTURE_MAX_LEVEL 0x813D + #define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 + #define GL_SINGLE_COLOR 0x81F9 + #define GL_SEPARATE_SPECULAR_COLOR 0x81FA + #define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 + #define GL_UNSIGNED_SHORT_5_6_5 0x8363 + #define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 + #define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 + #define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 + #define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 + #define GL_ALIASED_POINT_SIZE_RANGE 0x846D + #define GL_ALIASED_LINE_WIDTH_RANGE 0x846E + + typedef void (GLAPIENTRY * PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); + typedef void (GLAPIENTRY * PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); + typedef void (GLAPIENTRY * PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); + typedef void (GLAPIENTRY * PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); + + #define glCopyTexSubImage3D GLEGetCurrentFunction(glCopyTexSubImage3D) + #define glDrawRangeElements GLEGetCurrentFunction(glDrawRangeElements) + #define glTexImage3D GLEGetCurrentFunction(glTexImage3D) + #define glTexSubImage3D GLEGetCurrentFunction(glTexSubImage3D) + + // OpenGL 2.1 deprecated functions + /* + typedef void (GLAPIENTRY PFNGLBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); + typedef void (GLAPIENTRY PFNGLBLENDEQUATIONPROC) (GLenum mode); + typedef void (GLAPIENTRY PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); + typedef void (GLAPIENTRY PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); + typedef void (GLAPIENTRY PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); + typedef void (GLAPIENTRY PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); + typedef void (GLAPIENTRY PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); + typedef void (GLAPIENTRY PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); + typedef void (GLAPIENTRY PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); + typedef void (GLAPIENTRY PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); + typedef void (GLAPIENTRY PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); + typedef void (GLAPIENTRY PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); + typedef void (GLAPIENTRY PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); + typedef void (GLAPIENTRY PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params); + typedef void (GLAPIENTRY PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); + typedef void (GLAPIENTRY PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params); + typedef void (GLAPIENTRY PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); + typedef void (GLAPIENTRY PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); + typedef void (GLAPIENTRY PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); + typedef void (GLAPIENTRY PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); + typedef void (GLAPIENTRY PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); + typedef void (GLAPIENTRY PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); + typedef void (GLAPIENTRY PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); + typedef void (GLAPIENTRY PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); + typedef void (GLAPIENTRY PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); + typedef void (GLAPIENTRY PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); + typedef void (GLAPIENTRY PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); + typedef void (GLAPIENTRY PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); + typedef void (GLAPIENTRY PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); + typedef void (GLAPIENTRY PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); + typedef void (GLAPIENTRY PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); + typedef void (GLAPIENTRY PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink); + typedef void (GLAPIENTRY PFNGLRESETHISTOGRAMPROC) (GLenum target); + typedef void (GLAPIENTRY PFNGLRESETMINMAXPROC) (GLenum target); + */ +#endif // GL_VERSION_1_2 + + + +#ifndef GL_VERSION_1_3 + #define GL_VERSION_1_3 1 + + #define GL_MULTISAMPLE 0x809D + #define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E + #define GL_SAMPLE_ALPHA_TO_ONE 0x809F + #define GL_SAMPLE_COVERAGE 0x80A0 + #define GL_SAMPLE_BUFFERS 0x80A8 + #define GL_SAMPLES 0x80A9 + #define GL_SAMPLE_COVERAGE_VALUE 0x80AA + #define GL_SAMPLE_COVERAGE_INVERT 0x80AB + #define GL_CLAMP_TO_BORDER 0x812D + #define GL_TEXTURE0 0x84C0 + #define GL_TEXTURE1 0x84C1 + #define GL_TEXTURE2 0x84C2 + #define GL_TEXTURE3 0x84C3 + #define GL_TEXTURE4 0x84C4 + #define GL_TEXTURE5 0x84C5 + #define GL_TEXTURE6 0x84C6 + #define GL_TEXTURE7 0x84C7 + #define GL_TEXTURE8 0x84C8 + #define GL_TEXTURE9 0x84C9 + #define GL_TEXTURE10 0x84CA + #define GL_TEXTURE11 0x84CB + #define GL_TEXTURE12 0x84CC + #define GL_TEXTURE13 0x84CD + #define GL_TEXTURE14 0x84CE + #define GL_TEXTURE15 0x84CF + #define GL_TEXTURE16 0x84D0 + #define GL_TEXTURE17 0x84D1 + #define GL_TEXTURE18 0x84D2 + #define GL_TEXTURE19 0x84D3 + #define GL_TEXTURE20 0x84D4 + #define GL_TEXTURE21 0x84D5 + #define GL_TEXTURE22 0x84D6 + #define GL_TEXTURE23 0x84D7 + #define GL_TEXTURE24 0x84D8 + #define GL_TEXTURE25 0x84D9 + #define GL_TEXTURE26 0x84DA + #define GL_TEXTURE27 0x84DB + #define GL_TEXTURE28 0x84DC + #define GL_TEXTURE29 0x84DD + #define GL_TEXTURE30 0x84DE + #define GL_TEXTURE31 0x84DF + #define GL_ACTIVE_TEXTURE 0x84E0 + #define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 + #define GL_MAX_TEXTURE_UNITS 0x84E2 + #define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3 + #define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4 + #define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5 + #define GL_TRANSPOSE_COLOR_MATRIX 0x84E6 + #define GL_SUBTRACT 0x84E7 + #define GL_COMPRESSED_ALPHA 0x84E9 + #define GL_COMPRESSED_LUMINANCE 0x84EA + #define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB + #define GL_COMPRESSED_INTENSITY 0x84EC + #define GL_COMPRESSED_RGB 0x84ED + #define GL_COMPRESSED_RGBA 0x84EE + #define GL_TEXTURE_COMPRESSION_HINT 0x84EF + #define GL_NORMAL_MAP 0x8511 + #define GL_REFLECTION_MAP 0x8512 + #define GL_TEXTURE_CUBE_MAP 0x8513 + #define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 + #define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 + #define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 + #define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 + #define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 + #define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 + #define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A + #define GL_PROXY_TEXTURE_CUBE_MAP 0x851B + #define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C + #define GL_COMBINE 0x8570 + #define GL_COMBINE_RGB 0x8571 + #define GL_COMBINE_ALPHA 0x8572 + #define GL_RGB_SCALE 0x8573 + #define GL_ADD_SIGNED 0x8574 + #define GL_INTERPOLATE 0x8575 + #define GL_CONSTANT 0x8576 + #define GL_PRIMARY_COLOR 0x8577 + #define GL_PREVIOUS 0x8578 + #define GL_SOURCE0_RGB 0x8580 + #define GL_SOURCE1_RGB 0x8581 + #define GL_SOURCE2_RGB 0x8582 + #define GL_SOURCE0_ALPHA 0x8588 + #define GL_SOURCE1_ALPHA 0x8589 + #define GL_SOURCE2_ALPHA 0x858A + #define GL_OPERAND0_RGB 0x8590 + #define GL_OPERAND1_RGB 0x8591 + #define GL_OPERAND2_RGB 0x8592 + #define GL_OPERAND0_ALPHA 0x8598 + #define GL_OPERAND1_ALPHA 0x8599 + #define GL_OPERAND2_ALPHA 0x859A + #define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0 + #define GL_TEXTURE_COMPRESSED 0x86A1 + #define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 + #define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 + #define GL_DOT3_RGB 0x86AE + #define GL_DOT3_RGBA 0x86AF + #define GL_MULTISAMPLE_BIT 0x20000000 + + typedef void (GLAPIENTRY * PFNGLACTIVETEXTUREPROC) (GLenum texture); + typedef void (GLAPIENTRY * PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture); + typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data); + typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); + typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); + typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); + typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); + typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); + typedef void (GLAPIENTRY * PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint lod, void *img); + typedef void (GLAPIENTRY * PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble m[16]); + typedef void (GLAPIENTRY * PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat m[16]); + typedef void (GLAPIENTRY * PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble m[16]); + typedef void (GLAPIENTRY * PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat m[16]); + typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s); + typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v); + typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1FPROC) (GLenum target, GLfloat s); + typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1FVPROC) (GLenum target, const GLfloat *v); + typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1IPROC) (GLenum target, GLint s); + typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1IVPROC) (GLenum target, const GLint *v); + typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1SPROC) (GLenum target, GLshort s); + typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1SVPROC) (GLenum target, const GLshort *v); + typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2DPROC) (GLenum target, GLdouble s, GLdouble t); + typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2DVPROC) (GLenum target, const GLdouble *v); + typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t); + typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v); + typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2IPROC) (GLenum target, GLint s, GLint t); + typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2IVPROC) (GLenum target, const GLint *v); + typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2SPROC) (GLenum target, GLshort s, GLshort t); + typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2SVPROC) (GLenum target, const GLshort *v); + typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); + typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3DVPROC) (GLenum target, const GLdouble *v); + typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); + typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v); + typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3IPROC) (GLenum target, GLint s, GLint t, GLint r); + typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3IVPROC) (GLenum target, const GLint *v); + typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3SPROC) (GLenum target, GLshort s, GLshort t, GLshort r); + typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3SVPROC) (GLenum target, const GLshort *v); + typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); + typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4DVPROC) (GLenum target, const GLdouble *v); + typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); + typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v); + typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4IPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); + typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4IVPROC) (GLenum target, const GLint *v); + typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4SPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); + typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4SVPROC) (GLenum target, const GLshort *v); + typedef void (GLAPIENTRY * PFNGLSAMPLECOVERAGEPROC) (GLclampf value, GLboolean invert); + + #define glActiveTexture GLEGetCurrentFunction(glActiveTexture) + #define glClientActiveTexture GLEGetCurrentFunction(glClientActiveTexture) + #define glCompressedTexImage1D GLEGetCurrentFunction(glCompressedTexImage1D) + #define glCompressedTexImage2D GLEGetCurrentFunction(glCompressedTexImage2D) + #define glCompressedTexImage3D GLEGetCurrentFunction(glCompressedTexImage3D) + #define glCompressedTexSubImage1D GLEGetCurrentFunction(glCompressedTexSubImage1D) + #define glCompressedTexSubImage2D GLEGetCurrentFunction(glCompressedTexSubImage2D) + #define glCompressedTexSubImage3D GLEGetCurrentFunction(glCompressedTexSubImage3D) + #define glGetCompressedTexImage GLEGetCurrentFunction(glGetCompressedTexImage) + #define glLoadTransposeMatrixd GLEGetCurrentFunction(glLoadTransposeMatrixd) + #define glLoadTransposeMatrixf GLEGetCurrentFunction(glLoadTransposeMatrixf) + #define glMultTransposeMatrixd GLEGetCurrentFunction(glMultTransposeMatrixd) + #define glMultTransposeMatrixf GLEGetCurrentFunction(glMultTransposeMatrixf) + #define glMultiTexCoord1d GLEGetCurrentFunction(glMultiTexCoord1d) + #define glMultiTexCoord1dv GLEGetCurrentFunction(glMultiTexCoord1dv) + #define glMultiTexCoord1f GLEGetCurrentFunction(glMultiTexCoord1f) + #define glMultiTexCoord1fv GLEGetCurrentFunction(glMultiTexCoord1fv) + #define glMultiTexCoord1i GLEGetCurrentFunction(glMultiTexCoord1i) + #define glMultiTexCoord1iv GLEGetCurrentFunction(glMultiTexCoord1iv) + #define glMultiTexCoord1s GLEGetCurrentFunction(glMultiTexCoord1s) + #define glMultiTexCoord1sv GLEGetCurrentFunction(glMultiTexCoord1sv) + #define glMultiTexCoord2d GLEGetCurrentFunction(glMultiTexCoord2d) + #define glMultiTexCoord2dv GLEGetCurrentFunction(glMultiTexCoord2dv) + #define glMultiTexCoord2f GLEGetCurrentFunction(glMultiTexCoord2f) + #define glMultiTexCoord2fv GLEGetCurrentFunction(glMultiTexCoord2fv) + #define glMultiTexCoord2i GLEGetCurrentFunction(glMultiTexCoord2i) + #define glMultiTexCoord2iv GLEGetCurrentFunction(glMultiTexCoord2iv) + #define glMultiTexCoord2s GLEGetCurrentFunction(glMultiTexCoord2s) + #define glMultiTexCoord2sv GLEGetCurrentFunction(glMultiTexCoord2sv) + #define glMultiTexCoord3d GLEGetCurrentFunction(glMultiTexCoord3d) + #define glMultiTexCoord3dv GLEGetCurrentFunction(glMultiTexCoord3dv) + #define glMultiTexCoord3f GLEGetCurrentFunction(glMultiTexCoord3f) + #define glMultiTexCoord3fv GLEGetCurrentFunction(glMultiTexCoord3fv) + #define glMultiTexCoord3i GLEGetCurrentFunction(glMultiTexCoord3i) + #define glMultiTexCoord3iv GLEGetCurrentFunction(glMultiTexCoord3iv) + #define glMultiTexCoord3s GLEGetCurrentFunction(glMultiTexCoord3s) + #define glMultiTexCoord3sv GLEGetCurrentFunction(glMultiTexCoord3sv) + #define glMultiTexCoord4d GLEGetCurrentFunction(glMultiTexCoord4d) + #define glMultiTexCoord4dv GLEGetCurrentFunction(glMultiTexCoord4dv) + #define glMultiTexCoord4f GLEGetCurrentFunction(glMultiTexCoord4f) + #define glMultiTexCoord4fv GLEGetCurrentFunction(glMultiTexCoord4fv) + #define glMultiTexCoord4i GLEGetCurrentFunction(glMultiTexCoord4i) + #define glMultiTexCoord4iv GLEGetCurrentFunction(glMultiTexCoord4iv) + #define glMultiTexCoord4s GLEGetCurrentFunction(glMultiTexCoord4s) + #define glMultiTexCoord4sv GLEGetCurrentFunction(glMultiTexCoord4sv) + #define glSampleCoverage GLEGetCurrentFunction(glSampleCoverage) + +#endif // GL_VERSION_1_3 + + + +#ifndef GL_VERSION_1_4 + #define GL_VERSION_1_4 1 + + #define GL_BLEND_DST_RGB 0x80C8 + #define GL_BLEND_SRC_RGB 0x80C9 + #define GL_BLEND_DST_ALPHA 0x80CA + #define GL_BLEND_SRC_ALPHA 0x80CB + #define GL_POINT_SIZE_MIN 0x8126 + #define GL_POINT_SIZE_MAX 0x8127 + #define GL_POINT_FADE_THRESHOLD_SIZE 0x8128 + #define GL_POINT_DISTANCE_ATTENUATION 0x8129 + #define GL_GENERATE_MIPMAP 0x8191 + #define GL_GENERATE_MIPMAP_HINT 0x8192 + #define GL_DEPTH_COMPONENT16 0x81A5 + #define GL_DEPTH_COMPONENT24 0x81A6 + #define GL_DEPTH_COMPONENT32 0x81A7 + #define GL_MIRRORED_REPEAT 0x8370 + #define GL_FOG_COORDINATE_SOURCE 0x8450 + #define GL_FOG_COORDINATE 0x8451 + #define GL_FRAGMENT_DEPTH 0x8452 + #define GL_CURRENT_FOG_COORDINATE 0x8453 + #define GL_FOG_COORDINATE_ARRAY_TYPE 0x8454 + #define GL_FOG_COORDINATE_ARRAY_STRIDE 0x8455 + #define GL_FOG_COORDINATE_ARRAY_POINTER 0x8456 + #define GL_FOG_COORDINATE_ARRAY 0x8457 + #define GL_COLOR_SUM 0x8458 + #define GL_CURRENT_SECONDARY_COLOR 0x8459 + #define GL_SECONDARY_COLOR_ARRAY_SIZE 0x845A + #define GL_SECONDARY_COLOR_ARRAY_TYPE 0x845B + #define GL_SECONDARY_COLOR_ARRAY_STRIDE 0x845C + #define GL_SECONDARY_COLOR_ARRAY_POINTER 0x845D + #define GL_SECONDARY_COLOR_ARRAY 0x845E + #define GL_MAX_TEXTURE_LOD_BIAS 0x84FD + #define GL_TEXTURE_FILTER_CONTROL 0x8500 + #define GL_TEXTURE_LOD_BIAS 0x8501 + #define GL_INCR_WRAP 0x8507 + #define GL_DECR_WRAP 0x8508 + #define GL_TEXTURE_DEPTH_SIZE 0x884A + #define GL_DEPTH_TEXTURE_MODE 0x884B + #define GL_TEXTURE_COMPARE_MODE 0x884C + #define GL_TEXTURE_COMPARE_FUNC 0x884D + #define GL_COMPARE_R_TO_TEXTURE 0x884E + + typedef void (GLAPIENTRY * PFNGLBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); + typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONPROC) (GLenum mode); + typedef void (GLAPIENTRY * PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); + typedef void (GLAPIENTRY * PFNGLFOGCOORDPOINTERPROC) (GLenum type, GLsizei stride, const void *pointer); + typedef void (GLAPIENTRY * PFNGLFOGCOORDDPROC) (GLdouble coord); + typedef void (GLAPIENTRY * PFNGLFOGCOORDDVPROC) (const GLdouble *coord); + typedef void (GLAPIENTRY * PFNGLFOGCOORDFPROC) (GLfloat coord); + typedef void (GLAPIENTRY * PFNGLFOGCOORDFVPROC) (const GLfloat *coord); + typedef void (GLAPIENTRY * PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount); + typedef void (GLAPIENTRY * PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const* indices, GLsizei drawcount); + typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param); + typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params); + typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param); + typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params); + typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3BPROC) (GLbyte red, GLbyte green, GLbyte blue); + typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3BVPROC) (const GLbyte *v); + typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3DPROC) (GLdouble red, GLdouble green, GLdouble blue); + typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3DVPROC) (const GLdouble *v); + typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3FPROC) (GLfloat red, GLfloat green, GLfloat blue); + typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3FVPROC) (const GLfloat *v); + typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3IPROC) (GLint red, GLint green, GLint blue); + typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3IVPROC) (const GLint *v); + typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3SPROC) (GLshort red, GLshort green, GLshort blue); + typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3SVPROC) (const GLshort *v); + typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UBPROC) (GLubyte red, GLubyte green, GLubyte blue); + typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UBVPROC) (const GLubyte *v); + typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UIPROC) (GLuint red, GLuint green, GLuint blue); + typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UIVPROC) (const GLuint *v); + typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3USPROC) (GLushort red, GLushort green, GLushort blue); + typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3USVPROC) (const GLushort *v); + typedef void (GLAPIENTRY * PFNGLSECONDARYCOLORPOINTERPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); + typedef void (GLAPIENTRY * PFNGLWINDOWPOS2DPROC) (GLdouble x, GLdouble y); + typedef void (GLAPIENTRY * PFNGLWINDOWPOS2DVPROC) (const GLdouble *p); + typedef void (GLAPIENTRY * PFNGLWINDOWPOS2FPROC) (GLfloat x, GLfloat y); + typedef void (GLAPIENTRY * PFNGLWINDOWPOS2FVPROC) (const GLfloat *p); + typedef void (GLAPIENTRY * PFNGLWINDOWPOS2IPROC) (GLint x, GLint y); + typedef void (GLAPIENTRY * PFNGLWINDOWPOS2IVPROC) (const GLint *p); + typedef void (GLAPIENTRY * PFNGLWINDOWPOS2SPROC) (GLshort x, GLshort y); + typedef void (GLAPIENTRY * PFNGLWINDOWPOS2SVPROC) (const GLshort *p); + typedef void (GLAPIENTRY * PFNGLWINDOWPOS3DPROC) (GLdouble x, GLdouble y, GLdouble z); + typedef void (GLAPIENTRY * PFNGLWINDOWPOS3DVPROC) (const GLdouble *p); + typedef void (GLAPIENTRY * PFNGLWINDOWPOS3FPROC) (GLfloat x, GLfloat y, GLfloat z); + typedef void (GLAPIENTRY * PFNGLWINDOWPOS3FVPROC) (const GLfloat *p); + typedef void (GLAPIENTRY * PFNGLWINDOWPOS3IPROC) (GLint x, GLint y, GLint z); + typedef void (GLAPIENTRY * PFNGLWINDOWPOS3IVPROC) (const GLint *p); + typedef void (GLAPIENTRY * PFNGLWINDOWPOS3SPROC) (GLshort x, GLshort y, GLshort z); + typedef void (GLAPIENTRY * PFNGLWINDOWPOS3SVPROC) (const GLshort *p); + + #define glBlendColor GLEGetCurrentFunction(glBlendColor) + #define glBlendEquation GLEGetCurrentFunction(glBlendEquation) + #define glBlendFuncSeparate GLEGetCurrentFunction(glBlendFuncSeparate) + #define glFogCoordPointer GLEGetCurrentFunction(glFogCoordPointer) + #define glFogCoordd GLEGetCurrentFunction(glFogCoordd) + #define glFogCoorddv GLEGetCurrentFunction(glFogCoorddv) + #define glFogCoordf GLEGetCurrentFunction(glFogCoordf) + #define glFogCoordfv GLEGetCurrentFunction(glFogCoordfv) + #define glMultiDrawArrays GLEGetCurrentFunction(glMultiDrawArrays) + #define glMultiDrawElements GLEGetCurrentFunction(glMultiDrawElements) + #define glPointParameterf GLEGetCurrentFunction(glPointParameterf) + #define glPointParameterfv GLEGetCurrentFunction(glPointParameterfv) + #define glPointParameteri GLEGetCurrentFunction(glPointParameteri) + #define glPointParameteriv GLEGetCurrentFunction(glPointParameteriv) + #define glSecondaryColor3b GLEGetCurrentFunction(glSecondaryColor3b) + #define glSecondaryColor3bv GLEGetCurrentFunction(glSecondaryColor3bv) + #define glSecondaryColor3d GLEGetCurrentFunction(glSecondaryColor3d) + #define glSecondaryColor3dv GLEGetCurrentFunction(glSecondaryColor3dv) + #define glSecondaryColor3f GLEGetCurrentFunction(glSecondaryColor3f) + #define glSecondaryColor3fv GLEGetCurrentFunction(glSecondaryColor3fv) + #define glSecondaryColor3i GLEGetCurrentFunction(glSecondaryColor3i) + #define glSecondaryColor3iv GLEGetCurrentFunction(glSecondaryColor3iv) + #define glSecondaryColor3s GLEGetCurrentFunction(glSecondaryColor3s) + #define glSecondaryColor3sv GLEGetCurrentFunction(glSecondaryColor3sv) + #define glSecondaryColor3ub GLEGetCurrentFunction(glSecondaryColor3ub) + #define glSecondaryColor3ubv GLEGetCurrentFunction(glSecondaryColor3ubv) + #define glSecondaryColor3ui GLEGetCurrentFunction(glSecondaryColor3ui) + #define glSecondaryColor3uiv GLEGetCurrentFunction(glSecondaryColor3uiv) + #define glSecondaryColor3us GLEGetCurrentFunction(glSecondaryColor3us) + #define glSecondaryColor3usv GLEGetCurrentFunction(glSecondaryColor3usv) + #define glSecondaryColorPointer GLEGetCurrentFunction(glSecondaryColorPointer) + #define glWindowPos2d GLEGetCurrentFunction(glWindowPos2d) + #define glWindowPos2dv GLEGetCurrentFunction(glWindowPos2dv) + #define glWindowPos2f GLEGetCurrentFunction(glWindowPos2f) + #define glWindowPos2fv GLEGetCurrentFunction(glWindowPos2fv) + #define glWindowPos2i GLEGetCurrentFunction(glWindowPos2i) + #define glWindowPos2iv GLEGetCurrentFunction(glWindowPos2iv) + #define glWindowPos2s GLEGetCurrentFunction(glWindowPos2s) + #define glWindowPos2sv GLEGetCurrentFunction(glWindowPos2sv) + #define glWindowPos3d GLEGetCurrentFunction(glWindowPos3d) + #define glWindowPos3dv GLEGetCurrentFunction(glWindowPos3dv) + #define glWindowPos3f GLEGetCurrentFunction(glWindowPos3f) + #define glWindowPos3fv GLEGetCurrentFunction(glWindowPos3fv) + #define glWindowPos3i GLEGetCurrentFunction(glWindowPos3i) + #define glWindowPos3iv GLEGetCurrentFunction(glWindowPos3iv) + #define glWindowPos3s GLEGetCurrentFunction(glWindowPos3s) + #define glWindowPos3sv GLEGetCurrentFunction(glWindowPos3sv) + +#endif // GL_VERSION_1_4 + + + +#ifndef GL_VERSION_1_5 + #define GL_VERSION_1_5 1 + + #define GL_CURRENT_FOG_COORD GL_CURRENT_FOG_COORDINATE + #define GL_FOG_COORD GL_FOG_COORDINATE + #define GL_FOG_COORD_ARRAY GL_FOG_COORDINATE_ARRAY + #define GL_FOG_COORD_ARRAY_BUFFER_BINDING GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING + #define GL_FOG_COORD_ARRAY_POINTER GL_FOG_COORDINATE_ARRAY_POINTER + #define GL_FOG_COORD_ARRAY_STRIDE GL_FOG_COORDINATE_ARRAY_STRIDE + #define GL_FOG_COORD_ARRAY_TYPE GL_FOG_COORDINATE_ARRAY_TYPE + #define GL_FOG_COORD_SRC GL_FOG_COORDINATE_SOURCE + #define GL_SRC0_ALPHA GL_SOURCE0_ALPHA + #define GL_SRC0_RGB GL_SOURCE0_RGB + #define GL_SRC1_ALPHA GL_SOURCE1_ALPHA + #define GL_SRC1_RGB GL_SOURCE1_RGB + #define GL_SRC2_ALPHA GL_SOURCE2_ALPHA + #define GL_SRC2_RGB GL_SOURCE2_RGB + #define GL_BUFFER_SIZE 0x8764 + #define GL_BUFFER_USAGE 0x8765 + #define GL_QUERY_COUNTER_BITS 0x8864 + #define GL_CURRENT_QUERY 0x8865 + #define GL_QUERY_RESULT 0x8866 + #define GL_QUERY_RESULT_AVAILABLE 0x8867 + #define GL_ARRAY_BUFFER 0x8892 + #define GL_ELEMENT_ARRAY_BUFFER 0x8893 + #define GL_ARRAY_BUFFER_BINDING 0x8894 + #define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 + #define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896 + #define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897 + #define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898 + #define GL_INDEX_ARRAY_BUFFER_BINDING 0x8899 + #define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A + #define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B + #define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C + #define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D + #define GL_WEIGHT_ARRAY_BUFFER_BINDING 0x889E + #define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F + #define GL_READ_ONLY 0x88B8 + #define GL_WRITE_ONLY 0x88B9 + #define GL_READ_WRITE 0x88BA + #define GL_BUFFER_ACCESS 0x88BB + #define GL_BUFFER_MAPPED 0x88BC + #define GL_BUFFER_MAP_POINTER 0x88BD + #define GL_STREAM_DRAW 0x88E0 + #define GL_STREAM_READ 0x88E1 + #define GL_STREAM_COPY 0x88E2 + #define GL_STATIC_DRAW 0x88E4 + #define GL_STATIC_READ 0x88E5 + #define GL_STATIC_COPY 0x88E6 + #define GL_DYNAMIC_DRAW 0x88E8 + #define GL_DYNAMIC_READ 0x88E9 + #define GL_DYNAMIC_COPY 0x88EA + #define GL_SAMPLES_PASSED 0x8914 + + typedef ptrdiff_t GLintptr; + typedef ptrdiff_t GLsizeiptr; + + typedef void (GLAPIENTRY * PFNGLBEGINQUERYPROC) (GLenum target, GLuint id); + typedef void (GLAPIENTRY * PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); + typedef void (GLAPIENTRY * PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const void* data, GLenum usage); + typedef void (GLAPIENTRY * PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const void* data); + typedef void (GLAPIENTRY * PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint* buffers); + typedef void (GLAPIENTRY * PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint* ids); + typedef void (GLAPIENTRY * PFNGLENDQUERYPROC) (GLenum target); + typedef void (GLAPIENTRY * PFNGLGENBUFFERSPROC) (GLsizei n, GLuint* buffers); + typedef void (GLAPIENTRY * PFNGLGENQUERIESPROC) (GLsizei n, GLuint* ids); + typedef void (GLAPIENTRY * PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint* params); + typedef void (GLAPIENTRY * PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, void** params); + typedef void (GLAPIENTRY * PFNGLGETBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, void* data); + typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTIVPROC) (GLuint id, GLenum pname, GLint* params); + typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint* params); + typedef void (GLAPIENTRY * PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint* params); + typedef GLboolean (GLAPIENTRY * PFNGLISBUFFERPROC) (GLuint buffer); + typedef GLboolean (GLAPIENTRY * PFNGLISQUERYPROC) (GLuint id); + typedef void* (GLAPIENTRY * PFNGLMAPBUFFERPROC) (GLenum target, GLenum access); + typedef GLboolean (GLAPIENTRY * PFNGLUNMAPBUFFERPROC) (GLenum target); + + #define glBeginQuery GLEGetCurrentFunction(glBeginQuery) + #define glBindBuffer GLEGetCurrentFunction(glBindBuffer) + #define glBufferData GLEGetCurrentFunction(glBufferData) + #define glBufferSubData GLEGetCurrentFunction(glBufferSubData) + #define glDeleteBuffers GLEGetCurrentFunction(glDeleteBuffers) + #define glDeleteQueries GLEGetCurrentFunction(glDeleteQueries) + #define glEndQuery GLEGetCurrentFunction(glEndQuery) + #define glGenBuffers GLEGetCurrentFunction(glGenBuffers) + #define glGenQueries GLEGetCurrentFunction(glGenQueries) + #define glGetBufferParameteriv GLEGetCurrentFunction(glGetBufferParameteriv) + #define glGetBufferPointerv GLEGetCurrentFunction(glGetBufferPointerv) + #define glGetBufferSubData GLEGetCurrentFunction(glGetBufferSubData) + #define glGetQueryObjectiv GLEGetCurrentFunction(glGetQueryObjectiv) + #define glGetQueryObjectuiv GLEGetCurrentFunction(glGetQueryObjectuiv) + #define glGetQueryiv GLEGetCurrentFunction(glGetQueryiv) + #define glIsBuffer GLEGetCurrentFunction(glIsBuffer) + #define glIsQuery GLEGetCurrentFunction(glIsQuery) + #define glMapBuffer GLEGetCurrentFunction(glMapBuffer) + #define glUnmapBuffer GLEGetCurrentFunction(glUnmapBuffer) + +#endif // GL_VERSION_1_5 + + + + +#ifndef GL_VERSION_2_0 + #define GL_VERSION_2_0 1 + + #define GL_BLEND_EQUATION_RGB GL_BLEND_EQUATION + #define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 + #define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 + #define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 + #define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 + #define GL_CURRENT_VERTEX_ATTRIB 0x8626 + #define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 + #define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643 + #define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 + #define GL_STENCIL_BACK_FUNC 0x8800 + #define GL_STENCIL_BACK_FAIL 0x8801 + #define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 + #define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 + #define GL_MAX_DRAW_BUFFERS 0x8824 + #define GL_DRAW_BUFFER0 0x8825 + #define GL_DRAW_BUFFER1 0x8826 + #define GL_DRAW_BUFFER2 0x8827 + #define GL_DRAW_BUFFER3 0x8828 + #define GL_DRAW_BUFFER4 0x8829 + #define GL_DRAW_BUFFER5 0x882A + #define GL_DRAW_BUFFER6 0x882B + #define GL_DRAW_BUFFER7 0x882C + #define GL_DRAW_BUFFER8 0x882D + #define GL_DRAW_BUFFER9 0x882E + #define GL_DRAW_BUFFER10 0x882F + #define GL_DRAW_BUFFER11 0x8830 + #define GL_DRAW_BUFFER12 0x8831 + #define GL_DRAW_BUFFER13 0x8832 + #define GL_DRAW_BUFFER14 0x8833 + #define GL_DRAW_BUFFER15 0x8834 + #define GL_BLEND_EQUATION_ALPHA 0x883D + #define GL_POINT_SPRITE 0x8861 + #define GL_COORD_REPLACE 0x8862 + #define GL_MAX_VERTEX_ATTRIBS 0x8869 + #define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A + #define GL_MAX_TEXTURE_COORDS 0x8871 + #define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 + #define GL_FRAGMENT_SHADER 0x8B30 + #define GL_VERTEX_SHADER 0x8B31 + #define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 + #define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A + #define GL_MAX_VARYING_FLOATS 0x8B4B + #define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C + #define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D + #define GL_SHADER_TYPE 0x8B4F + #define GL_FLOAT_VEC2 0x8B50 + #define GL_FLOAT_VEC3 0x8B51 + #define GL_FLOAT_VEC4 0x8B52 + #define GL_INT_VEC2 0x8B53 + #define GL_INT_VEC3 0x8B54 + #define GL_INT_VEC4 0x8B55 + #define GL_BOOL 0x8B56 + #define GL_BOOL_VEC2 0x8B57 + #define GL_BOOL_VEC3 0x8B58 + #define GL_BOOL_VEC4 0x8B59 + #define GL_FLOAT_MAT2 0x8B5A + #define GL_FLOAT_MAT3 0x8B5B + #define GL_FLOAT_MAT4 0x8B5C + #define GL_SAMPLER_1D 0x8B5D + #define GL_SAMPLER_2D 0x8B5E + #define GL_SAMPLER_3D 0x8B5F + #define GL_SAMPLER_CUBE 0x8B60 + #define GL_SAMPLER_1D_SHADOW 0x8B61 + #define GL_SAMPLER_2D_SHADOW 0x8B62 + #define GL_DELETE_STATUS 0x8B80 + #define GL_COMPILE_STATUS 0x8B81 + #define GL_LINK_STATUS 0x8B82 + #define GL_VALIDATE_STATUS 0x8B83 + #define GL_INFO_LOG_LENGTH 0x8B84 + #define GL_ATTACHED_SHADERS 0x8B85 + #define GL_ACTIVE_UNIFORMS 0x8B86 + #define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 + #define GL_SHADER_SOURCE_LENGTH 0x8B88 + #define GL_ACTIVE_ATTRIBUTES 0x8B89 + #define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A + #define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B + #define GL_SHADING_LANGUAGE_VERSION 0x8B8C + #define GL_CURRENT_PROGRAM 0x8B8D + #define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0 + #define GL_LOWER_LEFT 0x8CA1 + #define GL_UPPER_LEFT 0x8CA2 + #define GL_STENCIL_BACK_REF 0x8CA3 + #define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 + #define GL_STENCIL_BACK_WRITEMASK 0x8CA5 + + typedef void (GLAPIENTRY * PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); + typedef void (GLAPIENTRY * PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar* name); + typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha); + typedef void (GLAPIENTRY * PFNGLCOMPILESHADERPROC) (GLuint shader); + typedef GLuint (GLAPIENTRY * PFNGLCREATEPROGRAMPROC) (void); + typedef GLuint (GLAPIENTRY * PFNGLCREATESHADERPROC) (GLenum type); + typedef void (GLAPIENTRY * PFNGLDELETEPROGRAMPROC) (GLuint program); + typedef void (GLAPIENTRY * PFNGLDELETESHADERPROC) (GLuint shader); + typedef void (GLAPIENTRY * PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); + typedef void (GLAPIENTRY * PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index); + typedef void (GLAPIENTRY * PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum* bufs); + typedef void (GLAPIENTRY * PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index); + typedef void (GLAPIENTRY * PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei maxLength, GLsizei* length, GLint* size, GLenum* type, GLchar* name); + typedef void (GLAPIENTRY * PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei maxLength, GLsizei* length, GLint* size, GLenum* type, GLchar* name); + typedef void (GLAPIENTRY * PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei* count, GLuint* shaders); + typedef GLint (GLAPIENTRY * PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar* name); + typedef void (GLAPIENTRY * PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei* length, GLchar* infoLog); + typedef void (GLAPIENTRY * PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint* param); + typedef void (GLAPIENTRY * PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei* length, GLchar* infoLog); + typedef void (GLAPIENTRY * PFNGLGETSHADERSOURCEPROC) (GLuint obj, GLsizei maxLength, GLsizei* length, GLchar* source); + typedef void (GLAPIENTRY * PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint* param); + typedef GLint (GLAPIENTRY * PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar* name); + typedef void (GLAPIENTRY * PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat* params); + typedef void (GLAPIENTRY * PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint* params); + typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, void** pointer); + typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBDVPROC) (GLuint index, GLenum pname, GLdouble* params); + typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat* params); + typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint* params); + typedef GLboolean (GLAPIENTRY * PFNGLISPROGRAMPROC) (GLuint program); + typedef GLboolean (GLAPIENTRY * PFNGLISSHADERPROC) (GLuint shader); + typedef void (GLAPIENTRY * PFNGLLINKPROGRAMPROC) (GLuint program); + typedef void (GLAPIENTRY * PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar *const* string, const GLint* length); + typedef void (GLAPIENTRY * PFNGLSTENCILFUNCSEPARATEPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); + typedef void (GLAPIENTRY * PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask); + typedef void (GLAPIENTRY * PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); + typedef void (GLAPIENTRY * PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); + typedef void (GLAPIENTRY * PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat* value); + typedef void (GLAPIENTRY * PFNGLUNIFORM1IPROC) (GLint location, GLint v0); + typedef void (GLAPIENTRY * PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint* value); + typedef void (GLAPIENTRY * PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); + typedef void (GLAPIENTRY * PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat* value); + typedef void (GLAPIENTRY * PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); + typedef void (GLAPIENTRY * PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint* value); + typedef void (GLAPIENTRY * PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); + typedef void (GLAPIENTRY * PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat* value); + typedef void (GLAPIENTRY * PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); + typedef void (GLAPIENTRY * PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint* value); + typedef void (GLAPIENTRY * PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); + typedef void (GLAPIENTRY * PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat* value); + typedef void (GLAPIENTRY * PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); + typedef void (GLAPIENTRY * PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint* value); + typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); + typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); + typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); + typedef void (GLAPIENTRY * PFNGLUSEPROGRAMPROC) (GLuint program); + typedef void (GLAPIENTRY * PFNGLVALIDATEPROGRAMPROC) (GLuint program); + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1DPROC) (GLuint index, GLdouble x); + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble* v); + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat* v); + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1SPROC) (GLuint index, GLshort x); + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1SVPROC) (GLuint index, const GLshort* v); + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y); + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble* v); + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat* v); + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y); + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2SVPROC) (GLuint index, const GLshort* v); + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble* v); + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat* v); + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z); + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3SVPROC) (GLuint index, const GLshort* v); + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte* v); + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NIVPROC) (GLuint index, const GLint* v); + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort* v); + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte* v); + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint* v); + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort* v); + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte* v); + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble* v); + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat* v); + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4IVPROC) (GLuint index, const GLint* v); + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4SVPROC) (GLuint index, const GLshort* v); + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte* v); + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint* v); + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort* v); + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* pointer); + + #define glAttachShader GLEGetCurrentFunction(glAttachShader) + #define glBindAttribLocation GLEGetCurrentFunction(glBindAttribLocation) + #define glBlendEquationSeparate GLEGetCurrentFunction(glBlendEquationSeparate) + #define glCompileShader GLEGetCurrentFunction(glCompileShader) + #define glCreateProgram GLEGetCurrentFunction(glCreateProgram) + #define glCreateShader GLEGetCurrentFunction(glCreateShader) + #define glDeleteProgram GLEGetCurrentFunction(glDeleteProgram) + #define glDeleteShader GLEGetCurrentFunction(glDeleteShader) + #define glDetachShader GLEGetCurrentFunction(glDetachShader) + #define glDisableVertexAttribArray GLEGetCurrentFunction(glDisableVertexAttribArray) + #define glDrawBuffers GLEGetCurrentFunction(glDrawBuffers) + #define glEnableVertexAttribArray GLEGetCurrentFunction(glEnableVertexAttribArray) + #define glGetActiveAttrib GLEGetCurrentFunction(glGetActiveAttrib) + #define glGetActiveUniform GLEGetCurrentFunction(glGetActiveUniform) + #define glGetAttachedShaders GLEGetCurrentFunction(glGetAttachedShaders) + #define glGetAttribLocation GLEGetCurrentFunction(glGetAttribLocation) + #define glGetProgramInfoLog GLEGetCurrentFunction(glGetProgramInfoLog) + #define glGetProgramiv GLEGetCurrentFunction(glGetProgramiv) + #define glGetShaderInfoLog GLEGetCurrentFunction(glGetShaderInfoLog) + #define glGetShaderSource GLEGetCurrentFunction(glGetShaderSource) + #define glGetShaderiv GLEGetCurrentFunction(glGetShaderiv) + #define glGetUniformLocation GLEGetCurrentFunction(glGetUniformLocation) + #define glGetUniformfv GLEGetCurrentFunction(glGetUniformfv) + #define glGetUniformiv GLEGetCurrentFunction(glGetUniformiv) + #define glGetVertexAttribPointerv GLEGetCurrentFunction(glGetVertexAttribPointerv) + #define glGetVertexAttribdv GLEGetCurrentFunction(glGetVertexAttribdv) + #define glGetVertexAttribfv GLEGetCurrentFunction(glGetVertexAttribfv) + #define glGetVertexAttribiv GLEGetCurrentFunction(glGetVertexAttribiv) + #define glIsProgram GLEGetCurrentFunction(glIsProgram) + #define glIsShader GLEGetCurrentFunction(glIsShader) + #define glLinkProgram GLEGetCurrentFunction(glLinkProgram) + #define glShaderSource GLEGetCurrentFunction(glShaderSource) + #define glStencilFuncSeparate GLEGetCurrentFunction(glStencilFuncSeparate) + #define glStencilMaskSeparate GLEGetCurrentFunction(glStencilMaskSeparate) + #define glStencilOpSeparate GLEGetCurrentFunction(glStencilOpSeparate) + #define glUniform1f GLEGetCurrentFunction(glUniform1f) + #define glUniform1fv GLEGetCurrentFunction(glUniform1fv) + #define glUniform1i GLEGetCurrentFunction(glUniform1i) + #define glUniform1iv GLEGetCurrentFunction(glUniform1iv) + #define glUniform2f GLEGetCurrentFunction(glUniform2f) + #define glUniform2fv GLEGetCurrentFunction(glUniform2fv) + #define glUniform2i GLEGetCurrentFunction(glUniform2i) + #define glUniform2iv GLEGetCurrentFunction(glUniform2iv) + #define glUniform3f GLEGetCurrentFunction(glUniform3f) + #define glUniform3fv GLEGetCurrentFunction(glUniform3fv) + #define glUniform3i GLEGetCurrentFunction(glUniform3i) + #define glUniform3iv GLEGetCurrentFunction(glUniform3iv) + #define glUniform4f GLEGetCurrentFunction(glUniform4f) + #define glUniform4fv GLEGetCurrentFunction(glUniform4fv) + #define glUniform4i GLEGetCurrentFunction(glUniform4i) + #define glUniform4iv GLEGetCurrentFunction(glUniform4iv) + #define glUniformMatrix2fv GLEGetCurrentFunction(glUniformMatrix2fv) + #define glUniformMatrix3fv GLEGetCurrentFunction(glUniformMatrix3fv) + #define glUniformMatrix4fv GLEGetCurrentFunction(glUniformMatrix4fv) + #define glUseProgram GLEGetCurrentFunction(glUseProgram) + #define glValidateProgram GLEGetCurrentFunction(glValidateProgram) + #define glVertexAttrib1d GLEGetCurrentFunction(glVertexAttrib1d) + #define glVertexAttrib1dv GLEGetCurrentFunction(glVertexAttrib1dv) + #define glVertexAttrib1f GLEGetCurrentFunction(glVertexAttrib1f) + #define glVertexAttrib1fv GLEGetCurrentFunction(glVertexAttrib1fv) + #define glVertexAttrib1s GLEGetCurrentFunction(glVertexAttrib1s) + #define glVertexAttrib1sv GLEGetCurrentFunction(glVertexAttrib1sv) + #define glVertexAttrib2d GLEGetCurrentFunction(glVertexAttrib2d) + #define glVertexAttrib2dv GLEGetCurrentFunction(glVertexAttrib2dv) + #define glVertexAttrib2f GLEGetCurrentFunction(glVertexAttrib2f) + #define glVertexAttrib2fv GLEGetCurrentFunction(glVertexAttrib2fv) + #define glVertexAttrib2s GLEGetCurrentFunction(glVertexAttrib2s) + #define glVertexAttrib2sv GLEGetCurrentFunction(glVertexAttrib2sv) + #define glVertexAttrib3d GLEGetCurrentFunction(glVertexAttrib3d) + #define glVertexAttrib3dv GLEGetCurrentFunction(glVertexAttrib3dv) + #define glVertexAttrib3f GLEGetCurrentFunction(glVertexAttrib3f) + #define glVertexAttrib3fv GLEGetCurrentFunction(glVertexAttrib3fv) + #define glVertexAttrib3s GLEGetCurrentFunction(glVertexAttrib3s) + #define glVertexAttrib3sv GLEGetCurrentFunction(glVertexAttrib3sv) + #define glVertexAttrib4Nbv GLEGetCurrentFunction(glVertexAttrib4Nbv) + #define glVertexAttrib4Niv GLEGetCurrentFunction(glVertexAttrib4Niv) + #define glVertexAttrib4Nsv GLEGetCurrentFunction(glVertexAttrib4Nsv) + #define glVertexAttrib4Nub GLEGetCurrentFunction(glVertexAttrib4Nub) + #define glVertexAttrib4Nubv GLEGetCurrentFunction(glVertexAttrib4Nubv) + #define glVertexAttrib4Nuiv GLEGetCurrentFunction(glVertexAttrib4Nuiv) + #define glVertexAttrib4Nusv GLEGetCurrentFunction(glVertexAttrib4Nusv) + #define glVertexAttrib4bv GLEGetCurrentFunction(glVertexAttrib4bv) + #define glVertexAttrib4d GLEGetCurrentFunction(glVertexAttrib4d) + #define glVertexAttrib4dv GLEGetCurrentFunction(glVertexAttrib4dv) + #define glVertexAttrib4f GLEGetCurrentFunction(glVertexAttrib4f) + #define glVertexAttrib4fv GLEGetCurrentFunction(glVertexAttrib4fv) + #define glVertexAttrib4iv GLEGetCurrentFunction(glVertexAttrib4iv) + #define glVertexAttrib4s GLEGetCurrentFunction(glVertexAttrib4s) + #define glVertexAttrib4sv GLEGetCurrentFunction(glVertexAttrib4sv) + #define glVertexAttrib4ubv GLEGetCurrentFunction(glVertexAttrib4ubv) + #define glVertexAttrib4uiv GLEGetCurrentFunction(glVertexAttrib4uiv) + #define glVertexAttrib4usv GLEGetCurrentFunction(glVertexAttrib4usv) + #define glVertexAttribPointer GLEGetCurrentFunction(glVertexAttribPointer) + +#endif // GL_VERSION_2_0 + + + +#ifndef GL_VERSION_2_1 + #define GL_VERSION_2_1 1 + + #define GL_CURRENT_RASTER_SECONDARY_COLOR 0x845F + #define GL_PIXEL_PACK_BUFFER 0x88EB + #define GL_PIXEL_UNPACK_BUFFER 0x88EC + #define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED + #define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF + #define GL_FLOAT_MAT2x3 0x8B65 + #define GL_FLOAT_MAT2x4 0x8B66 + #define GL_FLOAT_MAT3x2 0x8B67 + #define GL_FLOAT_MAT3x4 0x8B68 + #define GL_FLOAT_MAT4x2 0x8B69 + #define GL_FLOAT_MAT4x3 0x8B6A + #define GL_SRGB 0x8C40 + #define GL_SRGB8 0x8C41 + #define GL_SRGB_ALPHA 0x8C42 + #define GL_SRGB8_ALPHA8 0x8C43 + #define GL_SLUMINANCE_ALPHA 0x8C44 + #define GL_SLUMINANCE8_ALPHA8 0x8C45 + #define GL_SLUMINANCE 0x8C46 + #define GL_SLUMINANCE8 0x8C47 + #define GL_COMPRESSED_SRGB 0x8C48 + #define GL_COMPRESSED_SRGB_ALPHA 0x8C49 + #define GL_COMPRESSED_SLUMINANCE 0x8C4A + #define GL_COMPRESSED_SLUMINANCE_ALPHA 0x8C4B + + typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX2X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX2X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX3X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX3X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX4X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX4X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + + #define glUniformMatrix2x3fv GLEGetCurrentFunction(glUniformMatrix2x3fv) + #define glUniformMatrix2x4fv GLEGetCurrentFunction(glUniformMatrix2x4fv) + #define glUniformMatrix3x2fv GLEGetCurrentFunction(glUniformMatrix3x2fv) + #define glUniformMatrix3x4fv GLEGetCurrentFunction(glUniformMatrix3x4fv) + #define glUniformMatrix4x2fv GLEGetCurrentFunction(glUniformMatrix4x2fv) + #define glUniformMatrix4x3fv GLEGetCurrentFunction(glUniformMatrix4x3fv) + +#endif // GL_VERSION_2_1 + + + + +#ifndef GL_VERSION_3_0 + #define GL_VERSION_3_0 1 + + #define GL_CLIP_DISTANCE0 GL_CLIP_PLANE0 + #define GL_CLIP_DISTANCE1 GL_CLIP_PLANE1 + #define GL_CLIP_DISTANCE2 GL_CLIP_PLANE2 + #define GL_CLIP_DISTANCE3 GL_CLIP_PLANE3 + #define GL_CLIP_DISTANCE4 GL_CLIP_PLANE4 + #define GL_CLIP_DISTANCE5 GL_CLIP_PLANE5 + #define GL_COMPARE_REF_TO_TEXTURE GL_COMPARE_R_TO_TEXTURE_ARB + #define GL_MAX_CLIP_DISTANCES GL_MAX_CLIP_PLANES + #define GL_MAX_VARYING_COMPONENTS GL_MAX_VARYING_FLOATS + #define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x0001 + #define GL_MAJOR_VERSION 0x821B + #define GL_MINOR_VERSION 0x821C + #define GL_NUM_EXTENSIONS 0x821D + #define GL_CONTEXT_FLAGS 0x821E + #define GL_DEPTH_BUFFER 0x8223 + #define GL_STENCIL_BUFFER 0x8224 + #define GL_RGBA32F 0x8814 + #define GL_RGB32F 0x8815 + #define GL_RGBA16F 0x881A + #define GL_RGB16F 0x881B + #define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD + #define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF + #define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904 + #define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905 + #define GL_CLAMP_VERTEX_COLOR 0x891A + #define GL_CLAMP_FRAGMENT_COLOR 0x891B + #define GL_CLAMP_READ_COLOR 0x891C + #define GL_FIXED_ONLY 0x891D + #define GL_TEXTURE_RED_TYPE 0x8C10 + #define GL_TEXTURE_GREEN_TYPE 0x8C11 + #define GL_TEXTURE_BLUE_TYPE 0x8C12 + #define GL_TEXTURE_ALPHA_TYPE 0x8C13 + #define GL_TEXTURE_LUMINANCE_TYPE 0x8C14 + #define GL_TEXTURE_INTENSITY_TYPE 0x8C15 + #define GL_TEXTURE_DEPTH_TYPE 0x8C16 + #define GL_TEXTURE_1D_ARRAY 0x8C18 + #define GL_PROXY_TEXTURE_1D_ARRAY 0x8C19 + #define GL_TEXTURE_2D_ARRAY 0x8C1A + #define GL_PROXY_TEXTURE_2D_ARRAY 0x8C1B + #define GL_TEXTURE_BINDING_1D_ARRAY 0x8C1C + #define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D + #define GL_R11F_G11F_B10F 0x8C3A + #define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B + #define GL_RGB9_E5 0x8C3D + #define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E + #define GL_TEXTURE_SHARED_SIZE 0x8C3F + #define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76 + #define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F + #define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80 + #define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83 + #define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84 + #define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85 + #define GL_PRIMITIVES_GENERATED 0x8C87 + #define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88 + #define GL_RASTERIZER_DISCARD 0x8C89 + #define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A + #define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B + #define GL_INTERLEAVED_ATTRIBS 0x8C8C + #define GL_SEPARATE_ATTRIBS 0x8C8D + #define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E + #define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F + #define GL_RGBA32UI 0x8D70 + #define GL_RGB32UI 0x8D71 + #define GL_RGBA16UI 0x8D76 + #define GL_RGB16UI 0x8D77 + #define GL_RGBA8UI 0x8D7C + #define GL_RGB8UI 0x8D7D + #define GL_RGBA32I 0x8D82 + #define GL_RGB32I 0x8D83 + #define GL_RGBA16I 0x8D88 + #define GL_RGB16I 0x8D89 + #define GL_RGBA8I 0x8D8E + #define GL_RGB8I 0x8D8F + #define GL_RED_INTEGER 0x8D94 + #define GL_GREEN_INTEGER 0x8D95 + #define GL_BLUE_INTEGER 0x8D96 + #define GL_ALPHA_INTEGER 0x8D97 + #define GL_RGB_INTEGER 0x8D98 + #define GL_RGBA_INTEGER 0x8D99 + #define GL_BGR_INTEGER 0x8D9A + #define GL_BGRA_INTEGER 0x8D9B + #define GL_SAMPLER_1D_ARRAY 0x8DC0 + #define GL_SAMPLER_2D_ARRAY 0x8DC1 + #define GL_SAMPLER_1D_ARRAY_SHADOW 0x8DC3 + #define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4 + #define GL_SAMPLER_CUBE_SHADOW 0x8DC5 + #define GL_UNSIGNED_INT_VEC2 0x8DC6 + #define GL_UNSIGNED_INT_VEC3 0x8DC7 + #define GL_UNSIGNED_INT_VEC4 0x8DC8 + #define GL_INT_SAMPLER_1D 0x8DC9 + #define GL_INT_SAMPLER_2D 0x8DCA + #define GL_INT_SAMPLER_3D 0x8DCB + #define GL_INT_SAMPLER_CUBE 0x8DCC + #define GL_INT_SAMPLER_1D_ARRAY 0x8DCE + #define GL_INT_SAMPLER_2D_ARRAY 0x8DCF + #define GL_UNSIGNED_INT_SAMPLER_1D 0x8DD1 + #define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2 + #define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3 + #define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4 + #define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY 0x8DD6 + #define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7 + #define GL_QUERY_WAIT 0x8E13 + #define GL_QUERY_NO_WAIT 0x8E14 + #define GL_QUERY_BY_REGION_WAIT 0x8E15 + #define GL_QUERY_BY_REGION_NO_WAIT 0x8E16 + + typedef void (GLAPIENTRY * PFNGLBEGINCONDITIONALRENDERPROC) (GLuint id, GLenum mode); + typedef void (GLAPIENTRY * PFNGLBEGINTRANSFORMFEEDBACKPROC) (GLenum primitiveMode); + typedef void (GLAPIENTRY * PFNGLBINDFRAGDATALOCATIONPROC) (GLuint program, GLuint colorNumber, const GLchar* name); + typedef void (GLAPIENTRY * PFNGLCLAMPCOLORPROC) (GLenum target, GLenum clamp); + typedef void (GLAPIENTRY * PFNGLCLEARBUFFERFIPROC) (GLenum buffer, GLint drawBuffer, GLfloat depth, GLint stencil); + typedef void (GLAPIENTRY * PFNGLCLEARBUFFERFVPROC) (GLenum buffer, GLint drawBuffer, const GLfloat* value); + typedef void (GLAPIENTRY * PFNGLCLEARBUFFERIVPROC) (GLenum buffer, GLint drawBuffer, const GLint* value); + typedef void (GLAPIENTRY * PFNGLCLEARBUFFERUIVPROC) (GLenum buffer, GLint drawBuffer, const GLuint* value); + typedef void (GLAPIENTRY * PFNGLCOLORMASKIPROC) (GLuint buf, GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); + typedef void (GLAPIENTRY * PFNGLDISABLEIPROC) (GLenum cap, GLuint index); + typedef void (GLAPIENTRY * PFNGLENABLEIPROC) (GLenum cap, GLuint index); + typedef void (GLAPIENTRY * PFNGLENDCONDITIONALRENDERPROC) (void); + typedef void (GLAPIENTRY * PFNGLENDTRANSFORMFEEDBACKPROC) (void); + typedef void (GLAPIENTRY * PFNGLBINDBUFFERRANGEPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); + typedef void (GLAPIENTRY * PFNGLBINDBUFFERBASEPROC) (GLenum target, GLuint index, GLuint buffer); + typedef void (GLAPIENTRY * PFNGLGETBOOLEANI_VPROC) (GLenum pname, GLuint index, GLboolean* data); + typedef void (GLAPIENTRY * PFNGLGETINTEGERI_VPROC) (GLenum target, GLuint index, GLint* data); + typedef GLint (GLAPIENTRY * PFNGLGETFRAGDATALOCATIONPROC) (GLuint program, const GLchar* name); + typedef const GLubyte* (GLAPIENTRY * PFNGLGETSTRINGIPROC) (GLenum name, GLuint index); + typedef void (GLAPIENTRY * PFNGLGETTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, GLint* params); + typedef void (GLAPIENTRY * PFNGLGETTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, GLuint* params); + typedef void (GLAPIENTRY * PFNGLGETTRANSFORMFEEDBACKVARYINGPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLsizei * size, GLenum * type, GLchar * name); + typedef void (GLAPIENTRY * PFNGLGETUNIFORMUIVPROC) (GLuint program, GLint location, GLuint* params); + typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIIVPROC) (GLuint index, GLenum pname, GLint* params); + typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIUIVPROC) (GLuint index, GLenum pname, GLuint* params); + typedef GLboolean (GLAPIENTRY * PFNGLISENABLEDIPROC) (GLenum cap, GLuint index); + typedef void (GLAPIENTRY * PFNGLTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, const GLint* params); + typedef void (GLAPIENTRY * PFNGLTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, const GLuint* params); + typedef void (GLAPIENTRY * PFNGLTRANSFORMFEEDBACKVARYINGSPROC) (GLuint program, GLsizei count, const GLchar *const* varyings, GLenum bufferMode); + typedef void (GLAPIENTRY * PFNGLUNIFORM1UIPROC) (GLint location, GLuint v0); + typedef void (GLAPIENTRY * PFNGLUNIFORM1UIVPROC) (GLint location, GLsizei count, const GLuint* value); + typedef void (GLAPIENTRY * PFNGLUNIFORM2UIPROC) (GLint location, GLuint v0, GLuint v1); + typedef void (GLAPIENTRY * PFNGLUNIFORM2UIVPROC) (GLint location, GLsizei count, const GLuint* value); + typedef void (GLAPIENTRY * PFNGLUNIFORM3UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); + typedef void (GLAPIENTRY * PFNGLUNIFORM3UIVPROC) (GLint location, GLsizei count, const GLuint* value); + typedef void (GLAPIENTRY * PFNGLUNIFORM4UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); + typedef void (GLAPIENTRY * PFNGLUNIFORM4UIVPROC) (GLint location, GLsizei count, const GLuint* value); + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1IPROC) (GLuint index, GLint v0); + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1IVPROC) (GLuint index, const GLint* v0); + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1UIPROC) (GLuint index, GLuint v0); + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1UIVPROC) (GLuint index, const GLuint* v0); + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2IPROC) (GLuint index, GLint v0, GLint v1); + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2IVPROC) (GLuint index, const GLint* v0); + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2UIPROC) (GLuint index, GLuint v0, GLuint v1); + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2UIVPROC) (GLuint index, const GLuint* v0); + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3IPROC) (GLuint index, GLint v0, GLint v1, GLint v2); + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3IVPROC) (GLuint index, const GLint* v0); + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3UIPROC) (GLuint index, GLuint v0, GLuint v1, GLuint v2); + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3UIVPROC) (GLuint index, const GLuint* v0); + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4BVPROC) (GLuint index, const GLbyte* v0); + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4IPROC) (GLuint index, GLint v0, GLint v1, GLint v2, GLint v3); + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4IVPROC) (GLuint index, const GLint* v0); + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4SVPROC) (GLuint index, const GLshort* v0); + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4UBVPROC) (GLuint index, const GLubyte* v0); + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4UIPROC) (GLuint index, GLuint v0, GLuint v1, GLuint v2, GLuint v3); + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4UIVPROC) (GLuint index, const GLuint* v0); + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4USVPROC) (GLuint index, const GLushort* v0); + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBIPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void*pointer); + + #define glBeginConditionalRender GLEGetCurrentFunction(glBeginConditionalRender) + #define glBeginTransformFeedback GLEGetCurrentFunction(glBeginTransformFeedback) + #define glBindFragDataLocation GLEGetCurrentFunction(glBindFragDataLocation) + #define glClampColor GLEGetCurrentFunction(glClampColor) + #define glClearBufferfi GLEGetCurrentFunction(glClearBufferfi) + #define glClearBufferfv GLEGetCurrentFunction(glClearBufferfv) + #define glClearBufferiv GLEGetCurrentFunction(glClearBufferiv) + #define glClearBufferuiv GLEGetCurrentFunction(glClearBufferuiv) + #define glColorMaski GLEGetCurrentFunction(glColorMaski) + #define glDisablei GLEGetCurrentFunction(glDisablei) + #define glEnablei GLEGetCurrentFunction(glEnablei) + #define glEndConditionalRender GLEGetCurrentFunction(glEndConditionalRender) + #define glEndTransformFeedback GLEGetCurrentFunction(glEndTransformFeedback) + #define glGetBooleani_v GLEGetCurrentFunction(glGetBooleani_v) + #define glGetIntegeri_v GLEGetCurrentFunction(glGetIntegeri_v) + #define glGetFragDataLocation GLEGetCurrentFunction(glGetFragDataLocation) + #define glGetStringi GLEGetCurrentFunction(glGetStringi) + #define glGetTexParameterIiv GLEGetCurrentFunction(glGetTexParameterIiv) + #define glGetTexParameterIuiv GLEGetCurrentFunction(glGetTexParameterIuiv) + #define glGetTransformFeedbackVarying GLEGetCurrentFunction(glGetTransformFeedbackVarying) + #define glGetUniformuiv GLEGetCurrentFunction(glGetUniformuiv) + #define glGetVertexAttribIiv GLEGetCurrentFunction(glGetVertexAttribIiv) + #define glGetVertexAttribIuiv GLEGetCurrentFunction(glGetVertexAttribIuiv) + #define glIsEnabledi GLEGetCurrentFunction(glIsEnabledi) + #define glTexParameterIiv GLEGetCurrentFunction(glTexParameterIiv) + #define glTexParameterIuiv GLEGetCurrentFunction(glTexParameterIuiv) + #define glTransformFeedbackVaryings GLEGetCurrentFunction(glTransformFeedbackVaryings) + #define glUniform1ui GLEGetCurrentFunction(glUniform1ui) + #define glUniform1uiv GLEGetCurrentFunction(glUniform1uiv) + #define glUniform2ui GLEGetCurrentFunction(glUniform2ui) + #define glUniform2uiv GLEGetCurrentFunction(glUniform2uiv) + #define glUniform3ui GLEGetCurrentFunction(glUniform3ui) + #define glUniform3uiv GLEGetCurrentFunction(glUniform3uiv) + #define glUniform4ui GLEGetCurrentFunction(glUniform4ui) + #define glUniform4uiv GLEGetCurrentFunction(glUniform4uiv) + #define glVertexAttribI1i GLEGetCurrentFunction(glVertexAttribI1i) + #define glVertexAttribI1iv GLEGetCurrentFunction(glVertexAttribI1iv) + #define glVertexAttribI1ui GLEGetCurrentFunction(glVertexAttribI1ui) + #define glVertexAttribI1uiv GLEGetCurrentFunction(glVertexAttribI1uiv) + #define glVertexAttribI2i GLEGetCurrentFunction(glVertexAttribI2i) + #define glVertexAttribI2iv GLEGetCurrentFunction(glVertexAttribI2iv) + #define glVertexAttribI2ui GLEGetCurrentFunction(glVertexAttribI2ui) + #define glVertexAttribI2uiv GLEGetCurrentFunction(glVertexAttribI2uiv) + #define glVertexAttribI3i GLEGetCurrentFunction(glVertexAttribI3i) + #define glVertexAttribI3iv GLEGetCurrentFunction(glVertexAttribI3iv) + #define glVertexAttribI3ui GLEGetCurrentFunction(glVertexAttribI3ui) + #define glVertexAttribI3uiv GLEGetCurrentFunction(glVertexAttribI3uiv) + #define glVertexAttribI4bv GLEGetCurrentFunction(glVertexAttribI4bv) + #define glVertexAttribI4i GLEGetCurrentFunction(glVertexAttribI4i) + #define glVertexAttribI4iv GLEGetCurrentFunction(glVertexAttribI4iv) + #define glVertexAttribI4sv GLEGetCurrentFunction(glVertexAttribI4sv) + #define glVertexAttribI4ubv GLEGetCurrentFunction(glVertexAttribI4ubv) + #define glVertexAttribI4ui GLEGetCurrentFunction(glVertexAttribI4ui) + #define glVertexAttribI4uiv GLEGetCurrentFunction(glVertexAttribI4uiv) + #define glVertexAttribI4usv GLEGetCurrentFunction(glVertexAttribI4usv) + #define glVertexAttribIPointer GLEGetCurrentFunction(glVertexAttribIPointer) + +#endif // GL_VERSION_3_0 + + + + +#ifndef GL_VERSION_3_1 + #define GL_VERSION_3_1 1 + + #define GL_TEXTURE_RECTANGLE 0x84F5 + #define GL_TEXTURE_BINDING_RECTANGLE 0x84F6 + #define GL_PROXY_TEXTURE_RECTANGLE 0x84F7 + #define GL_MAX_RECTANGLE_TEXTURE_SIZE 0x84F8 + #define GL_SAMPLER_2D_RECT 0x8B63 + #define GL_SAMPLER_2D_RECT_SHADOW 0x8B64 + #define GL_TEXTURE_BUFFER 0x8C2A + #define GL_MAX_TEXTURE_BUFFER_SIZE 0x8C2B + #define GL_TEXTURE_BINDING_BUFFER 0x8C2C + #define GL_TEXTURE_BUFFER_DATA_STORE_BINDING 0x8C2D + #define GL_TEXTURE_BUFFER_FORMAT 0x8C2E + #define GL_SAMPLER_BUFFER 0x8DC2 + #define GL_INT_SAMPLER_2D_RECT 0x8DCD + #define GL_INT_SAMPLER_BUFFER 0x8DD0 + #define GL_UNSIGNED_INT_SAMPLER_2D_RECT 0x8DD5 + #define GL_UNSIGNED_INT_SAMPLER_BUFFER 0x8DD8 + #define GL_RED_SNORM 0x8F90 + #define GL_RG_SNORM 0x8F91 + #define GL_RGB_SNORM 0x8F92 + #define GL_RGBA_SNORM 0x8F93 + #define GL_R8_SNORM 0x8F94 + #define GL_RG8_SNORM 0x8F95 + #define GL_RGB8_SNORM 0x8F96 + #define GL_RGBA8_SNORM 0x8F97 + #define GL_R16_SNORM 0x8F98 + #define GL_RG16_SNORM 0x8F99 + #define GL_RGB16_SNORM 0x8F9A + #define GL_RGBA16_SNORM 0x8F9B + #define GL_SIGNED_NORMALIZED 0x8F9C + #define GL_PRIMITIVE_RESTART 0x8F9D + #define GL_PRIMITIVE_RESTART_INDEX 0x8F9E + #define GL_BUFFER_ACCESS_FLAGS 0x911F + #define GL_BUFFER_MAP_LENGTH 0x9120 + #define GL_BUFFER_MAP_OFFSET 0x9121 + + typedef void (GLAPIENTRY * PFNGLDRAWARRAYSINSTANCEDPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); + typedef void (GLAPIENTRY * PFNGLDRAWELEMENTSINSTANCEDPROC) (GLenum mode, GLsizei count, GLenum type, const void* indices, GLsizei primcount); + typedef void (GLAPIENTRY * PFNGLPRIMITIVERESTARTINDEXPROC) (GLuint buffer); + typedef void (GLAPIENTRY * PFNGLTEXBUFFERPROC) (GLenum target, GLenum internalFormat, GLuint buffer); + + #define glDrawArraysInstanced GLEGetCurrentFunction(glDrawArraysInstanced) + #define glDrawElementsInstanced GLEGetCurrentFunction(glDrawElementsInstanced) + #define glPrimitiveRestartIndex GLEGetCurrentFunction(glPrimitiveRestartIndex) + #define glTexBuffer GLEGetCurrentFunction(glTexBuffer) + +#endif // GL_VERSION_3_1 + + + +#ifndef GL_VERSION_3_2 + #define GL_VERSION_3_2 1 + + #define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001 + #define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002 + #define GL_LINES_ADJACENCY 0x000A + #define GL_LINE_STRIP_ADJACENCY 0x000B + #define GL_TRIANGLES_ADJACENCY 0x000C + #define GL_TRIANGLE_STRIP_ADJACENCY 0x000D + #define GL_PROGRAM_POINT_SIZE 0x8642 + #define GL_GEOMETRY_VERTICES_OUT 0x8916 + #define GL_GEOMETRY_INPUT_TYPE 0x8917 + #define GL_GEOMETRY_OUTPUT_TYPE 0x8918 + #define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 0x8C29 + #define GL_FRAMEBUFFER_ATTACHMENT_LAYERED 0x8DA7 + #define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS 0x8DA8 + #define GL_GEOMETRY_SHADER 0x8DD9 + #define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS 0x8DDF + #define GL_MAX_GEOMETRY_OUTPUT_VERTICES 0x8DE0 + #define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 0x8DE1 + #define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122 + #define GL_MAX_GEOMETRY_INPUT_COMPONENTS 0x9123 + #define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS 0x9124 + #define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125 + #define GL_CONTEXT_PROFILE_MASK 0x9126 + + typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTUREPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); + typedef void (GLAPIENTRY * PFNGLGETBUFFERPARAMETERI64VPROC) (GLenum target, GLenum value, GLint64 * data); + typedef void (GLAPIENTRY * PFNGLGETINTEGER64I_VPROC) (GLenum pname, GLuint index, GLint64 * data); + + #define glFramebufferTexture GLEGetCurrentFunction(glFramebufferTexture) + #define glGetBufferParameteri64v GLEGetCurrentFunction(glGetBufferParameteri64v) + #define glGetInteger64i_v GLEGetCurrentFunction(glGetInteger64i_v) + +#endif // GL_VERSION_3_2 + + + +#ifndef GL_VERSION_3_3 + #define GL_VERSION_3_3 1 + + #define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE + #define GL_RGB10_A2UI 0x906F + + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBDIVISORPROC) (GLuint index, GLuint divisor); + + #define glVertexAttribDivisor GLEGetCurrentFunction(glVertexAttribDivisor) +#endif + + + +#ifndef GL_VERSION_4_0 + #define GL_VERSION_4_0 1 + + #define GL_SAMPLE_SHADING 0x8C36 + #define GL_MIN_SAMPLE_SHADING_VALUE 0x8C37 + #define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5E + #define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5F + #define GL_MAX_PROGRAM_TEXTURE_GATHER_COMPONENTS 0x8F9F + #define GL_TEXTURE_CUBE_MAP_ARRAY 0x9009 + #define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY 0x900A + #define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY 0x900B + #define GL_SAMPLER_CUBE_MAP_ARRAY 0x900C + #define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW 0x900D + #define GL_INT_SAMPLER_CUBE_MAP_ARRAY 0x900E + #define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY 0x900F + + typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONSEPARATEIPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); + typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONIPROC) (GLuint buf, GLenum mode); + typedef void (GLAPIENTRY * PFNGLBLENDFUNCSEPARATEIPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); + typedef void (GLAPIENTRY * PFNGLBLENDFUNCIPROC) (GLuint buf, GLenum src, GLenum dst); + typedef void (GLAPIENTRY * PFNGLMINSAMPLESHADINGPROC) (GLclampf value); + + #define glBlendEquationSeparatei GLEGetCurrentFunction(glBlendEquationSeparatei) + #define glBlendEquationi GLEGetCurrentFunction(glBlendEquationi) + #define glBlendFuncSeparatei GLEGetCurrentFunction(glBlendFuncSeparatei) + #define glBlendFunci GLEGetCurrentFunction(glBlendFunci) + #define glMinSampleShading GLEGetCurrentFunction(glMinSampleShading) + +#endif // GL_VERSION_4_0 + + + + +#ifndef GL_VERSION_4_1 + #define GL_VERSION_4_1 1 + // Empty +#endif + + + +#ifndef GL_VERSION_4_2 + #define GL_VERSION_4_2 1 + + #define GL_COMPRESSED_RGBA_BPTC_UNORM 0x8E8C + #define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM 0x8E8D + #define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT 0x8E8E + #define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT 0x8E8F +#endif + + + +#ifndef GL_VERSION_4_3 + #define GL_VERSION_4_3 1 + + #define GL_NUM_SHADING_LANGUAGE_VERSIONS 0x82E9 + #define GL_VERTEX_ATTRIB_ARRAY_LONG 0x874E +#endif + + + +#ifndef GL_VERSION_4_4 + #define GL_VERSION_4_4 1 + + #define GL_PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED 0x8221 + #define GL_MAX_VERTEX_ATTRIB_STRIDE 0x82E5 + #define GL_TEXTURE_BUFFER_BINDING 0x8C2A +#endif + + + +#ifndef GL_VERSION_4_5 + #define GL_VERSION_4_5 1 + // Empty +#endif + + + +#ifndef GL_AMD_debug_output + #define GL_AMD_debug_output 1 + + #define GL_MAX_DEBUG_MESSAGE_LENGTH_AMD 0x9143 + #define GL_MAX_DEBUG_LOGGED_MESSAGES_AMD 0x9144 + #define GL_DEBUG_LOGGED_MESSAGES_AMD 0x9145 + #define GL_DEBUG_SEVERITY_HIGH_AMD 0x9146 + #define GL_DEBUG_SEVERITY_MEDIUM_AMD 0x9147 + #define GL_DEBUG_SEVERITY_LOW_AMD 0x9148 + #define GL_DEBUG_CATEGORY_API_ERROR_AMD 0x9149 + #define GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD 0x914A + #define GL_DEBUG_CATEGORY_DEPRECATION_AMD 0x914B + #define GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD 0x914C + #define GL_DEBUG_CATEGORY_PERFORMANCE_AMD 0x914D + #define GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD 0x914E + #define GL_DEBUG_CATEGORY_APPLICATION_AMD 0x914F + #define GL_DEBUG_CATEGORY_OTHER_AMD 0x9150 + + typedef void (GLAPIENTRY *GLDEBUGPROCAMD)(GLuint id, GLenum category, GLenum severity, GLsizei length, const GLchar* message, void* userParam); + + typedef void (GLAPIENTRY * PFNGLDEBUGMESSAGECALLBACKAMDPROC) (GLDEBUGPROCAMD callback, void *userParam); + typedef void (GLAPIENTRY * PFNGLDEBUGMESSAGEENABLEAMDPROC) (GLenum category, GLenum severity, GLsizei count, const GLuint* ids, GLboolean enabled); + typedef void (GLAPIENTRY * PFNGLDEBUGMESSAGEINSERTAMDPROC) (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar* buf); + typedef GLuint (GLAPIENTRY * PFNGLGETDEBUGMESSAGELOGAMDPROC) (GLuint count, GLsizei bufsize, GLenum* categories, GLuint* severities, GLuint* ids, GLsizei* lengths, GLchar* message); + + #define glDebugMessageCallbackAMD GLEGetCurrentFunction(glDebugMessageCallbackAMD) + #define glDebugMessageEnableAMD GLEGetCurrentFunction(glDebugMessageEnableAMD) + #define glDebugMessageInsertAMD GLEGetCurrentFunction(glDebugMessageInsertAMD) + #define glGetDebugMessageLogAMD GLEGetCurrentFunction(glGetDebugMessageLogAMD) + + #define GLE_AMD_debug_output GLEGetCurrentVariable(gle_AMD_debug_output) + +#endif // GL_AMD_debug_output + + + +/* Disabled until needed +#ifndef GL_AMD_performance_monitor + #define GL_AMD_performance_monitor 1 + + #define GL_COUNTER_TYPE_AMD 0x8BC0 + #define GL_COUNTER_RANGE_AMD 0x8BC1 + #define GL_UNSIGNED_INT64_AMD 0x8BC2 + #define GL_PERCENTAGE_AMD 0x8BC3 + #define GL_PERFMON_RESULT_AVAILABLE_AMD 0x8BC4 + #define GL_PERFMON_RESULT_SIZE_AMD 0x8BC5 + #define GL_PERFMON_RESULT_AMD 0x8BC6 + + typedef void (GLAPIENTRY * PFNGLBEGINPERFMONITORAMDPROC) (GLuint monitor); + typedef void (GLAPIENTRY * PFNGLDELETEPERFMONITORSAMDPROC) (GLsizei n, GLuint* monitors); + typedef void (GLAPIENTRY * PFNGLENDPERFMONITORAMDPROC) (GLuint monitor); + typedef void (GLAPIENTRY * PFNGLGENPERFMONITORSAMDPROC) (GLsizei n, GLuint* monitors); + typedef void (GLAPIENTRY * PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint* data, GLint *bytesWritten); + typedef void (GLAPIENTRY * PFNGLGETPERFMONITORCOUNTERINFOAMDPROC) (GLuint group, GLuint counter, GLenum pname, void *data); + typedef void (GLAPIENTRY * PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC) (GLuint group, GLuint counter, GLsizei bufSize, GLsizei* length, GLchar *counterString); + typedef void (GLAPIENTRY * PFNGLGETPERFMONITORCOUNTERSAMDPROC) (GLuint group, GLint* numCounters, GLint *maxActiveCounters, GLsizei countersSize, GLuint *counters); + typedef void (GLAPIENTRY * PFNGLGETPERFMONITORGROUPSTRINGAMDPROC) (GLuint group, GLsizei bufSize, GLsizei* length, GLchar *groupString); + typedef void (GLAPIENTRY * PFNGLGETPERFMONITORGROUPSAMDPROC) (GLint* numGroups, GLsizei groupsSize, GLuint *groups); + typedef void (GLAPIENTRY * PFNGLSELECTPERFMONITORCOUNTERSAMDPROC) (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint* counterList); + + #define glBeginPerfMonitorAMD GLEGetCurrentFunction(glBeginPerfMonitorAMD) + #define glDeletePerfMonitorsAMD GLEGetCurrentFunction(glDeletePerfMonitorsAMD) + #define glEndPerfMonitorAMD GLEGetCurrentFunction(glEndPerfMonitorAMD) + #define glGenPerfMonitorsAMD GLEGetCurrentFunction(glGenPerfMonitorsAMD) + #define glGetPerfMonitorCounterDataAMD GLEGetCurrentFunction(glGetPerfMonitorCounterDataAMD) + #define glGetPerfMonitorCounterInfoAMD GLEGetCurrentFunction(glGetPerfMonitorCounterInfoAMD) + #define glGetPerfMonitorCounterStringAMD GLEGetCurrentFunction(glGetPerfMonitorCounterStringAMD) + #define glGetPerfMonitorCountersAMD GLEGetCurrentFunction(glGetPerfMonitorCountersAMD) + #define glGetPerfMonitorGroupStringAMD GLEGetCurrentFunction(glGetPerfMonitorGroupStringAMD) + #define glGetPerfMonitorGroupsAMD GLEGetCurrentFunction(glGetPerfMonitorGroupsAMD) + #define glSelectPerfMonitorCountersAMD GLEGetCurrentFunction(glSelectPerfMonitorCountersAMD) + + #define GLE_AMD_performance_monitor GLEGetCurrentVariable(gle_AMD_performance_monitor) + +#endif // GL_AMD_performance_monitor +*/ + + +#if defined(GLE_CGL_ENABLED) + #ifndef GL_APPLE_aux_depth_stencil + #define GL_APPLE_aux_depth_stencil 1 + + #define GL_AUX_DEPTH_STENCIL_APPLE 0x8A14g + + #define GLE_APPLE_aux_depth_stencil GLEGetCurrentVariable(gle_APPLE_aux_depth_stencil) + #endif + + + + #ifndef GL_APPLE_client_storage + #define GL_APPLE_client_storage 1 + + #define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2 + + #define GLE_APPLE_client_storage GLEGetCurrentVariable(gle_APPLE_client_storage) + #endif + + + + #ifndef GL_APPLE_element_array + #define GL_APPLE_element_array 1 + + #define GL_ELEMENT_ARRAY_APPLE 0x8A0C + #define GL_ELEMENT_ARRAY_TYPE_APPLE 0x8A0D + #define GL_ELEMENT_ARRAY_POINTER_APPLE 0x8A0E + + typedef void (GLAPIENTRY * PFNGLDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, GLint first, GLsizei count); + typedef void (GLAPIENTRY * PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); + typedef void (GLAPIENTRY * PFNGLELEMENTPOINTERAPPLEPROC) (GLenum type, const void *pointer); + typedef void (GLAPIENTRY * PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, const GLint* first, const GLsizei *count, GLsizei primcount); + typedef void (GLAPIENTRY * PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, const GLint* first, const GLsizei *count, GLsizei primcount); + + #define glDrawElementArrayAPPLE GLEGetCurrentFunction(glDrawElementArrayAPPLE) + #define glDrawRangeElementArrayAPPLE GLEGetCurrentFunction(glDrawRangeElementArrayAPPLE) + #define glElementPointerAPPLE GLEGetCurrentFunction(glElementPointerAPPLE) + #define glMultiDrawElementArrayAPPLE GLEGetCurrentFunction(glMultiDrawElementArrayAPPLE) + #define glMultiDrawRangeElementArrayAPPLE GLEGetCurrentFunction(glMultiDrawRangeElementArrayAPPLE) + + #define GLE_APPLE_element_array GLEGetCurrentVariable(gle_APPLE_element_array) + #endif + + + + #ifndef GL_APPLE_fence + #define GL_APPLE_fence 1 + + #define GL_DRAW_PIXELS_APPLE 0x8A0A + #define GL_FENCE_APPLE 0x8A0B + + typedef void (GLAPIENTRY * PFNGLDELETEFENCESAPPLEPROC) (GLsizei n, const GLuint* fences); + typedef void (GLAPIENTRY * PFNGLFINISHFENCEAPPLEPROC) (GLuint fence); + typedef void (GLAPIENTRY * PFNGLFINISHOBJECTAPPLEPROC) (GLenum object, GLint name); + typedef void (GLAPIENTRY * PFNGLGENFENCESAPPLEPROC) (GLsizei n, GLuint* fences); + typedef GLboolean (GLAPIENTRY * PFNGLISFENCEAPPLEPROC) (GLuint fence); + typedef void (GLAPIENTRY * PFNGLSETFENCEAPPLEPROC) (GLuint fence); + typedef GLboolean (GLAPIENTRY * PFNGLTESTFENCEAPPLEPROC) (GLuint fence); + typedef GLboolean (GLAPIENTRY * PFNGLTESTOBJECTAPPLEPROC) (GLenum object, GLuint name); + + #define glDeleteFencesAPPLE GLEGetCurrentFunction(glDeleteFencesAPPLE) + #define glFinishFenceAPPLE GLEGetCurrentFunction(glFinishFenceAPPLE) + #define glFinishObjectAPPLE GLEGetCurrentFunction(glFinishObjectAPPLE) + #define glGenFencesAPPLE GLEGetCurrentFunction(glGenFencesAPPLE) + #define glIsFenceAPPLE GLEGetCurrentFunction(glIsFenceAPPLE) + #define glSetFenceAPPLE GLEGetCurrentFunction(glSetFenceAPPLE) + #define glTestFenceAPPLE GLEGetCurrentFunction(glTestFenceAPPLE) + #define glTestObjectAPPLE GLEGetCurrentFunction(glTestObjectAPPLE) + + #define GLE_APPLE_fence GLEGetCurrentVariable(gle_APPLE_fence) + + #endif + + + + #ifndef GL_APPLE_float_pixels + #define GL_APPLE_float_pixels 1 + + #define GL_HALF_APPLE 0x140B + #define GL_RGBA_FLOAT32_APPLE 0x8814 + #define GL_RGB_FLOAT32_APPLE 0x8815 + #define GL_ALPHA_FLOAT32_APPLE 0x8816 + #define GL_INTENSITY_FLOAT32_APPLE 0x8817 + #define GL_LUMINANCE_FLOAT32_APPLE 0x8818 + #define GL_LUMINANCE_ALPHA_FLOAT32_APPLE 0x8819 + #define GL_RGBA_FLOAT16_APPLE 0x881A + #define GL_RGB_FLOAT16_APPLE 0x881B + #define GL_ALPHA_FLOAT16_APPLE 0x881C + #define GL_INTENSITY_FLOAT16_APPLE 0x881D + #define GL_LUMINANCE_FLOAT16_APPLE 0x881E + #define GL_LUMINANCE_ALPHA_FLOAT16_APPLE 0x881F + #define GL_COLOR_FLOAT_APPLE 0x8A0F + + #define GLE_APPLE_float_pixels GLEGetCurrentVariable(gle_APPLE_float_pixels) + #endif + + + + #ifndef GL_APPLE_flush_buffer_range + #define GL_APPLE_flush_buffer_range 1 + + #define GL_BUFFER_SERIALIZED_MODIFY_APPLE 0x8A12 + #define GL_BUFFER_FLUSHING_UNMAP_APPLE 0x8A13 + + typedef void (GLAPIENTRY * PFNGLBUFFERPARAMETERIAPPLEPROC) (GLenum target, GLenum pname, GLint param); + typedef void (GLAPIENTRY * PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC) (GLenum target, GLintptr offset, GLsizeiptr size); + + #define glBufferParameteriAPPLE GLEGetCurrentFunction(glBufferParameteriAPPLE) + #define glFlushMappedBufferRangeAPPLE GLEGetCurrentFunction(glFlushMappedBufferRangeAPPLE) + + #define GLE_APPLE_flush_buffer_range GLEGetCurrentVariable(gle_APPLE_flush_buffer_range) + #endif + + + + #ifndef GL_APPLE_object_purgeable + #define GL_APPLE_object_purgeable 1 + + #define GL_BUFFER_OBJECT_APPLE 0x85B3 + #define GL_RELEASED_APPLE 0x8A19 + #define GL_VOLATILE_APPLE 0x8A1A + #define GL_RETAINED_APPLE 0x8A1B + #define GL_UNDEFINED_APPLE 0x8A1C + #define GL_PURGEABLE_APPLE 0x8A1D + + typedef void (GLAPIENTRY * PFNGLGETOBJECTPARAMETERIVAPPLEPROC) (GLenum objectType, GLuint name, GLenum pname, GLint* params); + typedef GLenum (GLAPIENTRY * PFNGLOBJECTPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option); + typedef GLenum (GLAPIENTRY * PFNGLOBJECTUNPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option); + + #define glGetObjectParameterivAPPLE GLEGetCurrentFunction(glGetObjectParameterivAPPLE) + #define glObjectPurgeableAPPLE GLEGetCurrentFunction(glObjectPurgeableAPPLE) + #define glObjectUnpurgeableAPPLE GLEGetCurrentFunction(glObjectUnpurgeableAPPLE) + + #define GLE_APPLE_object_purgeable GLEGetCurrentVariable(gle_APPLE_object_purgeable) + #endif + + + + #ifndef GL_APPLE_pixel_buffer + #define GL_APPLE_pixel_buffer 1 + + #define GL_MIN_PBUFFER_VIEWPORT_DIMS_APPLE 0x8A10 + + #define GLE_APPLE_pixel_buffer GLEGetCurrentVariable(gle_APPLE_pixel_buffer) + #endif + + + + #ifndef GL_APPLE_rgb_422 + #define GL_APPLE_rgb_422 1 + + #define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA + #define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB + #define GL_RGB_422_APPLE 0x8A1F + #define GL_RGB_RAW_422_APPLE 0x8A51 + + #define GLE_APPLE_rgb_422 GLEGetCurrentVariable(gle_APPLE_rgb_422) + #endif + + + + #ifndef GL_APPLE_row_bytes + #define GL_APPLE_row_bytes 1 + + #define GL_PACK_ROW_BYTES_APPLE 0x8A15 + #define GL_UNPACK_ROW_BYTES_APPLE 0x8A16 + + #define GLE_APPLE_row_bytes GLEGetCurrentVariable(gle_APPLE_row_bytes) + #endif + + + + #ifndef GL_APPLE_specular_vector + #define GL_APPLE_specular_vector 1 + + #define GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE 0x85B0 + + #define GLE_APPLE_specular_vector GLEGetCurrentVariable(gle_APPLE_specular_vector) + #endif + + + + #ifndef GL_APPLE_texture_range + #define GL_APPLE_texture_range 1 + + #define GL_TEXTURE_RANGE_LENGTH_APPLE 0x85B7 + #define GL_TEXTURE_RANGE_POINTER_APPLE 0x85B8 + #define GL_TEXTURE_STORAGE_HINT_APPLE 0x85BC + #define GL_STORAGE_PRIVATE_APPLE 0x85BD + #define GL_STORAGE_CACHED_APPLE 0x85BE + #define GL_STORAGE_SHARED_APPLE 0x85BF + + typedef void (GLAPIENTRY * PFNGLGETTEXPARAMETERPOINTERVAPPLEPROC) (GLenum target, GLenum pname, void **params); + typedef void (GLAPIENTRY * PFNGLTEXTURERANGEAPPLEPROC) (GLenum target, GLsizei length, const void *pointer); + + #define glGetTexParameterPointervAPPLE GLEGetCurrentFunction(glGetTexParameterPointervAPPLE) + #define glTextureRangeAPPLE GLEGetCurrentFunction(glTextureRangeAPPLE) + + #define GLE_APPLE_texture_range GLEGetCurrentVariable(gle_APPLE_texture_range) + #endif + + + #ifndef GL_APPLE_transform_hint + #define GL_APPLE_transform_hint 1 + + #define GL_TRANSFORM_HINT_APPLE 0x85B1 + + #define GLE_APPLE_transform_hint GLEGetCurrentVariable(gle_APPLE_transform_hint) + #endif + + + + #ifndef GL_APPLE_vertex_array_object + #define GL_APPLE_vertex_array_object 1 + + // This has been superceded by GL_ARB_vertex_array_object, though if you are using Apple + // OpenGL prior to 3.x then only this interface will be available. However, we have made + // it so that glBindVertexArray maps to glBindVertexArrayApple when only the latter is present, + // thus allowing you to write cleaner code. You can always just call glBindVertexArray instead + // of glBindVertexArrayAPPLE, etc. + #define GL_VERTEX_ARRAY_BINDING_APPLE 0x85B5 + + typedef void (GLAPIENTRY * PFNGLBINDVERTEXARRAYAPPLEPROC) (GLuint array); + typedef void (GLAPIENTRY * PFNGLDELETEVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint* arrays); + typedef void (GLAPIENTRY * PFNGLGENVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint* arrays); // It's not clear whether arrays needs to be const or not. + typedef GLboolean (GLAPIENTRY * PFNGLISVERTEXARRAYAPPLEPROC) (GLuint array); + + #define glBindVertexArrayAPPLE GLEGetCurrentFunction(glBindVertexArrayAPPLE) + #define glDeleteVertexArraysAPPLE GLEGetCurrentFunction(glDeleteVertexArraysAPPLE) + #define glGenVertexArraysAPPLE GLEGetCurrentFunction(glGenVertexArraysAPPLE) + #define glIsVertexArrayAPPLE GLEGetCurrentFunction(glIsVertexArrayAPPLE) + + #define GLE_APPLE_vertex_array_object GLEGetCurrentVariable(gle_APPLE_vertex_array_object) + #endif + + + + #ifndef GL_APPLE_vertex_array_range + #define GL_APPLE_vertex_array_range 1 + + #define GL_VERTEX_ARRAY_RANGE_APPLE 0x851D + #define GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE 0x851E + #define GL_VERTEX_ARRAY_STORAGE_HINT_APPLE 0x851F + #define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_APPLE 0x8520 + #define GL_VERTEX_ARRAY_RANGE_POINTER_APPLE 0x8521 + #define GL_STORAGE_CLIENT_APPLE 0x85B4 + #define GL_STORAGE_CACHED_APPLE 0x85BE + #define GL_STORAGE_SHARED_APPLE 0x85BF + + typedef void (GLAPIENTRY * PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, void *pointer); + typedef void (GLAPIENTRY * PFNGLVERTEXARRAYPARAMETERIAPPLEPROC) (GLenum pname, GLint param); + typedef void (GLAPIENTRY * PFNGLVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, void *pointer); + + #define glFlushVertexArrayRangeAPPLE GLEGetCurrentFunction(glFlushVertexArrayRangeAPPLE) + #define glVertexArrayParameteriAPPLE GLEGetCurrentFunction(glVertexArrayParameteriAPPLE) + #define glVertexArrayRangeAPPLE GLEGetCurrentFunction(glVertexArrayRangeAPPLE) + + #define GLE_APPLE_vertex_array_range GLEGetCurrentVariable(gle_APPLE_vertex_array_range) + #endif + + + + #ifndef GL_APPLE_vertex_program_evaluators + #define GL_APPLE_vertex_program_evaluators 1 + + #define GL_VERTEX_ATTRIB_MAP1_APPLE 0x8A00 + #define GL_VERTEX_ATTRIB_MAP2_APPLE 0x8A01 + #define GL_VERTEX_ATTRIB_MAP1_SIZE_APPLE 0x8A02 + #define GL_VERTEX_ATTRIB_MAP1_COEFF_APPLE 0x8A03 + #define GL_VERTEX_ATTRIB_MAP1_ORDER_APPLE 0x8A04 + #define GL_VERTEX_ATTRIB_MAP1_DOMAIN_APPLE 0x8A05 + #define GL_VERTEX_ATTRIB_MAP2_SIZE_APPLE 0x8A06 + #define GL_VERTEX_ATTRIB_MAP2_COEFF_APPLE 0x8A07 + #define GL_VERTEX_ATTRIB_MAP2_ORDER_APPLE 0x8A08 + #define GL_VERTEX_ATTRIB_MAP2_DOMAIN_APPLE 0x8A09 + + typedef void (GLAPIENTRY * PFNGLDISABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname); + typedef void (GLAPIENTRY * PFNGLENABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname); + typedef GLboolean (GLAPIENTRY * PFNGLISVERTEXATTRIBENABLEDAPPLEPROC) (GLuint index, GLenum pname); + typedef void (GLAPIENTRY * PFNGLMAPVERTEXATTRIB1DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble* points); + typedef void (GLAPIENTRY * PFNGLMAPVERTEXATTRIB1FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat* points); + typedef void (GLAPIENTRY * PFNGLMAPVERTEXATTRIB2DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble* points); + typedef void (GLAPIENTRY * PFNGLMAPVERTEXATTRIB2FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat* points); + + #define glDisableVertexAttribAPPLE GLEGetCurrentFunction(glDisableVertexAttribAPPLE) + #define glEnableVertexAttribAPPLE GLEGetCurrentFunction(glEnableVertexAttribAPPLE) + #define glIsVertexAttribEnabledAPPLE GLEGetCurrentFunction(glIsVertexAttribEnabledAPPLE) + #define glMapVertexAttrib1dAPPLE GLEGetCurrentFunction(glMapVertexAttrib1dAPPLE) + #define glMapVertexAttrib1fAPPLE GLEGetCurrentFunction(glMapVertexAttrib1fAPPLE) + #define glMapVertexAttrib2dAPPLE GLEGetCurrentFunction(glMapVertexAttrib2dAPPLE) + #define glMapVertexAttrib2fAPPLE GLEGetCurrentFunction(glMapVertexAttrib2fAPPLE) + + #define GLE_APPLE_vertex_program_evaluators GLEGetCurrentVariable(gle_APPLE_vertex_program_evaluators) + #endif + +#endif // GLE_CGL_ENABLED + + +#ifndef GL_ARB_debug_output + #define GL_ARB_debug_output 1 + + #define GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB 0x8242 + #define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_ARB 0x8243 + #define GL_DEBUG_CALLBACK_FUNCTION_ARB 0x8244 + #define GL_DEBUG_CALLBACK_USER_PARAM_ARB 0x8245 + #define GL_DEBUG_SOURCE_API_ARB 0x8246 + #define GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB 0x8247 + #define GL_DEBUG_SOURCE_SHADER_COMPILER_ARB 0x8248 + #define GL_DEBUG_SOURCE_THIRD_PARTY_ARB 0x8249 + #define GL_DEBUG_SOURCE_APPLICATION_ARB 0x824A + #define GL_DEBUG_SOURCE_OTHER_ARB 0x824B + #define GL_DEBUG_TYPE_ERROR_ARB 0x824C + #define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB 0x824D + #define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB 0x824E + #define GL_DEBUG_TYPE_PORTABILITY_ARB 0x824F + #define GL_DEBUG_TYPE_PERFORMANCE_ARB 0x8250 + #define GL_DEBUG_TYPE_OTHER_ARB 0x8251 + #define GL_MAX_DEBUG_MESSAGE_LENGTH_ARB 0x9143 + #define GL_MAX_DEBUG_LOGGED_MESSAGES_ARB 0x9144 + #define GL_DEBUG_LOGGED_MESSAGES_ARB 0x9145 + #define GL_DEBUG_SEVERITY_HIGH_ARB 0x9146 + #define GL_DEBUG_SEVERITY_MEDIUM_ARB 0x9147 + #define GL_DEBUG_SEVERITY_LOW_ARB 0x9148 + + typedef void (GLAPIENTRY *GLDEBUGPROCARB)(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, const void* userParam); + + typedef void (GLAPIENTRY * PFNGLDEBUGMESSAGECALLBACKARBPROC) (GLDEBUGPROCARB callback, const void *userParam); + typedef void (GLAPIENTRY * PFNGLDEBUGMESSAGECONTROLARBPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint* ids, GLboolean enabled); + typedef void (GLAPIENTRY * PFNGLDEBUGMESSAGEINSERTARBPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* buf); + typedef GLuint (GLAPIENTRY * PFNGLGETDEBUGMESSAGELOGARBPROC) (GLuint count, GLsizei bufSize, GLenum* sources, GLenum* types, GLuint* ids, GLenum* severities, GLsizei* lengths, GLchar* messageLog); + + #define glDebugMessageCallbackARB GLEGetCurrentFunction(glDebugMessageCallbackARB) + #define glDebugMessageControlARB GLEGetCurrentFunction(glDebugMessageControlARB) + #define glDebugMessageInsertARB GLEGetCurrentFunction(glDebugMessageInsertARB) + #define glGetDebugMessageLogARB GLEGetCurrentFunction(glGetDebugMessageLogARB) + + #define GLE_ARB_debug_output GLEGetCurrentVariable(gle_ARB_debug_output) + +#endif // GL_ARB_debug_output + + + +#ifndef GL_ARB_depth_buffer_float + #define GL_ARB_depth_buffer_float 1 + + // Supercededs GL_NV_depth_buffer_float + #define GL_DEPTH_COMPONENT32F 0x8CAC + #define GL_DEPTH32F_STENCIL8 0x8CAD + #define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD + + #define GLE_ARB_depth_buffer_float GLEGetCurrentVariable(gle_ARB_depth_buffer_float) +#endif + + +/* Disabled until needed +#ifndef GL_ARB_direct_state_access + #define GL_ARB_direct_state_access 1 + + #define GL_TEXTURE_TARGET 0x1006 + #define GL_QUERY_TARGET 0x82EA + #define GL_TEXTURE_BINDING 0x82EB + + typedef void (GLAPIENTRY * PFNGLBINDTEXTUREUNITPROC) (GLuint unit, GLuint texture); + typedef void (GLAPIENTRY * PFNGLBLITNAMEDFRAMEBUFFERPROC) (GLuint readFramebuffer, GLuint drawFramebuffer, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); + typedef GLenum (GLAPIENTRY * PFNGLCHECKNAMEDFRAMEBUFFERSTATUSPROC) (GLuint framebuffer, GLenum target); + typedef void (GLAPIENTRY * PFNGLCLEARNAMEDBUFFERDATAPROC) (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); + typedef void (GLAPIENTRY * PFNGLCLEARNAMEDBUFFERSUBDATAPROC) (GLuint buffer, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); + typedef void (GLAPIENTRY * PFNGLCLEARNAMEDFRAMEBUFFERFIPROC) (GLuint framebuffer, GLenum buffer, GLfloat depth, GLint stencil); + typedef void (GLAPIENTRY * PFNGLCLEARNAMEDFRAMEBUFFERFVPROC) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLfloat* value); + typedef void (GLAPIENTRY * PFNGLCLEARNAMEDFRAMEBUFFERIVPROC) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLint* value); + typedef void (GLAPIENTRY * PFNGLCLEARNAMEDFRAMEBUFFERUIVPROC) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLuint* value); + typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXTURESUBIMAGE1DPROC) (GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); + typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXTURESUBIMAGE2DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); + typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXTURESUBIMAGE3DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); + typedef void (GLAPIENTRY * PFNGLCOPYNAMEDBUFFERSUBDATAPROC) (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); + typedef void (GLAPIENTRY * PFNGLCOPYTEXTURESUBIMAGE1DPROC) (GLuint texture, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); + typedef void (GLAPIENTRY * PFNGLCOPYTEXTURESUBIMAGE2DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); + typedef void (GLAPIENTRY * PFNGLCOPYTEXTURESUBIMAGE3DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); + typedef void (GLAPIENTRY * PFNGLCREATEBUFFERSPROC) (GLsizei n, GLuint* buffers); + typedef void (GLAPIENTRY * PFNGLCREATEFRAMEBUFFERSPROC) (GLsizei n, GLuint* framebuffers); + typedef void (GLAPIENTRY * PFNGLCREATEPROGRAMPIPELINESPROC) (GLsizei n, GLuint* pipelines); + typedef void (GLAPIENTRY * PFNGLCREATEQUERIESPROC) (GLenum target, GLsizei n, GLuint* ids); + typedef void (GLAPIENTRY * PFNGLCREATERENDERBUFFERSPROC) (GLsizei n, GLuint* renderbuffers); + typedef void (GLAPIENTRY * PFNGLCREATESAMPLERSPROC) (GLsizei n, GLuint* samplers); + typedef void (GLAPIENTRY * PFNGLCREATETEXTURESPROC) (GLenum target, GLsizei n, GLuint* textures); + typedef void (GLAPIENTRY * PFNGLCREATETRANSFORMFEEDBACKSPROC) (GLsizei n, GLuint* ids); + typedef void (GLAPIENTRY * PFNGLCREATEVERTEXARRAYSPROC) (GLsizei n, GLuint* arrays); + typedef void (GLAPIENTRY * PFNGLDISABLEVERTEXARRAYATTRIBPROC) (GLuint vaobj, GLuint index); + typedef void (GLAPIENTRY * PFNGLENABLEVERTEXARRAYATTRIBPROC) (GLuint vaobj, GLuint index); + typedef void (GLAPIENTRY * PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); + typedef void (GLAPIENTRY * PFNGLGENERATETEXTUREMIPMAPPROC) (GLuint texture); + typedef void (GLAPIENTRY * PFNGLGETCOMPRESSEDTEXTUREIMAGEPROC) (GLuint texture, GLint level, GLsizei bufSize, void *pixels); + typedef void (GLAPIENTRY * PFNGLGETNAMEDBUFFERPARAMETERI64VPROC) (GLuint buffer, GLenum pname, GLint64* params); + typedef void (GLAPIENTRY * PFNGLGETNAMEDBUFFERPARAMETERIVPROC) (GLuint buffer, GLenum pname, GLint* params); + typedef void (GLAPIENTRY * PFNGLGETNAMEDBUFFERPOINTERVPROC) (GLuint buffer, GLenum pname, void** params); + typedef void (GLAPIENTRY * PFNGLGETNAMEDBUFFERSUBDATAPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, void *data); + typedef void (GLAPIENTRY * PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLuint framebuffer, GLenum attachment, GLenum pname, GLint* params); + typedef void (GLAPIENTRY * PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVPROC) (GLuint framebuffer, GLenum pname, GLint* param); + typedef void (GLAPIENTRY * PFNGLGETNAMEDRENDERBUFFERPARAMETERIVPROC) (GLuint renderbuffer, GLenum pname, GLint* params); + typedef void (GLAPIENTRY * PFNGLGETTEXTUREIMAGEPROC) (GLuint texture, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *pixels); + typedef void (GLAPIENTRY * PFNGLGETTEXTURELEVELPARAMETERFVPROC) (GLuint texture, GLint level, GLenum pname, GLfloat* params); + typedef void (GLAPIENTRY * PFNGLGETTEXTURELEVELPARAMETERIVPROC) (GLuint texture, GLint level, GLenum pname, GLint* params); + typedef void (GLAPIENTRY * PFNGLGETTEXTUREPARAMETERIIVPROC) (GLuint texture, GLenum pname, GLint* params); + typedef void (GLAPIENTRY * PFNGLGETTEXTUREPARAMETERIUIVPROC) (GLuint texture, GLenum pname, GLuint* params); + typedef void (GLAPIENTRY * PFNGLGETTEXTUREPARAMETERFVPROC) (GLuint texture, GLenum pname, GLfloat* params); + typedef void (GLAPIENTRY * PFNGLGETTEXTUREPARAMETERIVPROC) (GLuint texture, GLenum pname, GLint* params); + typedef void (GLAPIENTRY * PFNGLGETTRANSFORMFEEDBACKI64_VPROC) (GLuint xfb, GLenum pname, GLuint index, GLint64* param); + typedef void (GLAPIENTRY * PFNGLGETTRANSFORMFEEDBACKI_VPROC) (GLuint xfb, GLenum pname, GLuint index, GLint* param); + typedef void (GLAPIENTRY * PFNGLGETTRANSFORMFEEDBACKIVPROC) (GLuint xfb, GLenum pname, GLint* param); + typedef void (GLAPIENTRY * PFNGLGETVERTEXARRAYINDEXED64IVPROC) (GLuint vaobj, GLuint index, GLenum pname, GLint64* param); + typedef void (GLAPIENTRY * PFNGLGETVERTEXARRAYINDEXEDIVPROC) (GLuint vaobj, GLuint index, GLenum pname, GLint* param); + typedef void (GLAPIENTRY * PFNGLGETVERTEXARRAYIVPROC) (GLuint vaobj, GLenum pname, GLint* param); + typedef void (GLAPIENTRY * PFNGLINVALIDATENAMEDFRAMEBUFFERDATAPROC) (GLuint framebuffer, GLsizei numAttachments, const GLenum* attachments); + typedef void (GLAPIENTRY * PFNGLINVALIDATENAMEDFRAMEBUFFERSUBDATAPROC) (GLuint framebuffer, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height); + typedef void * (GLAPIENTRY * PFNGLMAPNAMEDBUFFERPROC) (GLuint buffer, GLenum access); + typedef void * (GLAPIENTRY * PFNGLMAPNAMEDBUFFERRANGEPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); + typedef void (GLAPIENTRY * PFNGLNAMEDBUFFERDATAPROC) (GLuint buffer, GLsizeiptr size, const void *data, GLenum usage); + typedef void (GLAPIENTRY * PFNGLNAMEDBUFFERSTORAGEPROC) (GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags); + typedef void (GLAPIENTRY * PFNGLNAMEDBUFFERSUBDATAPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); + typedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERDRAWBUFFERPROC) (GLuint framebuffer, GLenum mode); + typedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERDRAWBUFFERSPROC) (GLuint framebuffer, GLsizei n, const GLenum* bufs); + typedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERPARAMETERIPROC) (GLuint framebuffer, GLenum pname, GLint param); + typedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERREADBUFFERPROC) (GLuint framebuffer, GLenum mode); + typedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERRENDERBUFFERPROC) (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); + typedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERTEXTUREPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); + typedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERTEXTURELAYERPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); + typedef void (GLAPIENTRY * PFNGLNAMEDRENDERBUFFERSTORAGEPROC) (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); + typedef void (GLAPIENTRY * PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); + typedef void (GLAPIENTRY * PFNGLTEXTUREBUFFERPROC) (GLuint texture, GLenum internalformat, GLuint buffer); + typedef void (GLAPIENTRY * PFNGLTEXTUREBUFFERRANGEPROC) (GLuint texture, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); + typedef void (GLAPIENTRY * PFNGLTEXTUREPARAMETERIIVPROC) (GLuint texture, GLenum pname, const GLint* params); + typedef void (GLAPIENTRY * PFNGLTEXTUREPARAMETERIUIVPROC) (GLuint texture, GLenum pname, const GLuint* params); + typedef void (GLAPIENTRY * PFNGLTEXTUREPARAMETERFPROC) (GLuint texture, GLenum pname, GLfloat param); + typedef void (GLAPIENTRY * PFNGLTEXTUREPARAMETERFVPROC) (GLuint texture, GLenum pname, const GLfloat* param); + typedef void (GLAPIENTRY * PFNGLTEXTUREPARAMETERIPROC) (GLuint texture, GLenum pname, GLint param); + typedef void (GLAPIENTRY * PFNGLTEXTUREPARAMETERIVPROC) (GLuint texture, GLenum pname, const GLint* param); + typedef void (GLAPIENTRY * PFNGLTEXTURESTORAGE1DPROC) (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width); + typedef void (GLAPIENTRY * PFNGLTEXTURESTORAGE2DPROC) (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); + typedef void (GLAPIENTRY * PFNGLTEXTURESTORAGE2DMULTISAMPLEPROC) (GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); + typedef void (GLAPIENTRY * PFNGLTEXTURESTORAGE3DPROC) (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); + typedef void (GLAPIENTRY * PFNGLTEXTURESTORAGE3DMULTISAMPLEPROC) (GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); + typedef void (GLAPIENTRY * PFNGLTEXTURESUBIMAGE1DPROC) (GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); + typedef void (GLAPIENTRY * PFNGLTEXTURESUBIMAGE2DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); + typedef void (GLAPIENTRY * PFNGLTEXTURESUBIMAGE3DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); + typedef void (GLAPIENTRY * PFNGLTRANSFORMFEEDBACKBUFFERBASEPROC) (GLuint xfb, GLuint index, GLuint buffer); + typedef void (GLAPIENTRY * PFNGLTRANSFORMFEEDBACKBUFFERRANGEPROC) (GLuint xfb, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); + typedef GLboolean (GLAPIENTRY * PFNGLUNMAPNAMEDBUFFERPROC) (GLuint buffer); + typedef void (GLAPIENTRY * PFNGLVERTEXARRAYATTRIBBINDINGPROC) (GLuint vaobj, GLuint attribindex, GLuint bindingindex); + typedef void (GLAPIENTRY * PFNGLVERTEXARRAYATTRIBFORMATPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); + typedef void (GLAPIENTRY * PFNGLVERTEXARRAYATTRIBIFORMATPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); + typedef void (GLAPIENTRY * PFNGLVERTEXARRAYATTRIBLFORMATPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); + typedef void (GLAPIENTRY * PFNGLVERTEXARRAYBINDINGDIVISORPROC) (GLuint vaobj, GLuint bindingindex, GLuint divisor); + typedef void (GLAPIENTRY * PFNGLVERTEXARRAYELEMENTBUFFERPROC) (GLuint vaobj, GLuint buffer); + typedef void (GLAPIENTRY * PFNGLVERTEXARRAYVERTEXBUFFERPROC) (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); + typedef void (GLAPIENTRY * PFNGLVERTEXARRAYVERTEXBUFFERSPROC) (GLuint vaobj, GLuint first, GLsizei count, const GLuint* buffers, const GLintptr *offsets, const GLsizei *strides); + + #define glBindTextureUnit GLEGetCurrentFunction(glBindTextureUnit) + #define glBlitNamedFramebuffer GLEGetCurrentFunction(glBlitNamedFramebuffer) + #define glCheckNamedFramebufferStatus GLEGetCurrentFunction(glCheckNamedFramebufferStatus) + #define glClearNamedBufferData GLEGetCurrentFunction(glClearNamedBufferData) + #define glClearNamedBufferSubData GLEGetCurrentFunction(glClearNamedBufferSubData) + #define glClearNamedFramebufferfi GLEGetCurrentFunction(glClearNamedFramebufferfi) + #define glClearNamedFramebufferfv GLEGetCurrentFunction(glClearNamedFramebufferfv) + #define glClearNamedFramebufferiv GLEGetCurrentFunction(glClearNamedFramebufferiv) + #define glClearNamedFramebufferuiv GLEGetCurrentFunction(glClearNamedFramebufferuiv) + #define glCompressedTextureSubImage1D GLEGetCurrentFunction(glCompressedTextureSubImage1D) + #define glCompressedTextureSubImage2D GLEGetCurrentFunction(glCompressedTextureSubImage2D) + #define glCompressedTextureSubImage3D GLEGetCurrentFunction(glCompressedTextureSubImage3D) + #define glCopyNamedBufferSubData GLEGetCurrentFunction(glCopyNamedBufferSubData) + #define glCopyTextureSubImage1D GLEGetCurrentFunction(glCopyTextureSubImage1D) + #define glCopyTextureSubImage2D GLEGetCurrentFunction(glCopyTextureSubImage2D) + #define glCopyTextureSubImage3D GLEGetCurrentFunction(glCopyTextureSubImage3D) + #define glCreateBuffers GLEGetCurrentFunction(glCreateBuffers) + #define glCreateFramebuffers GLEGetCurrentFunction(glCreateFramebuffers) + #define glCreateProgramPipelines GLEGetCurrentFunction(glCreateProgramPipelines) + #define glCreateQueries GLEGetCurrentFunction(glCreateQueries) + #define glCreateRenderbuffers GLEGetCurrentFunction(glCreateRenderbuffers) + #define glCreateSamplers GLEGetCurrentFunction(glCreateSamplers) + #define glCreateTextures GLEGetCurrentFunction(glCreateTextures) + #define glCreateTransformFeedbacks GLEGetCurrentFunction(glCreateTransformFeedbacks) + #define glCreateVertexArrays GLEGetCurrentFunction(glCreateVertexArrays) + #define glDisableVertexArrayAttrib GLEGetCurrentFunction(glDisableVertexArrayAttrib) + #define glEnableVertexArrayAttrib GLEGetCurrentFunction(glEnableVertexArrayAttrib) + #define glFlushMappedNamedBufferRange GLEGetCurrentFunction(glFlushMappedNamedBufferRange) + #define glGenerateTextureMipmap GLEGetCurrentFunction(glGenerateTextureMipmap) + #define glGetCompressedTextureImage GLEGetCurrentFunction(glGetCompressedTextureImage) + #define glGetNamedBufferParameteri64v GLEGetCurrentFunction(glGetNamedBufferParameteri64v) + #define glGetNamedBufferParameteriv GLEGetCurrentFunction(glGetNamedBufferParameteriv) + #define glGetNamedBufferPointerv GLEGetCurrentFunction(glGetNamedBufferPointerv) + #define glGetNamedBufferSubData GLEGetCurrentFunction(glGetNamedBufferSubData) + #define glGetNamedFramebufferAttachmentParameteriv GLEGetCurrentFunction(glGetNamedFramebufferAttachmentParameteriv) + #define glGetNamedFramebufferParameteriv GLEGetCurrentFunction(glGetNamedFramebufferParameteriv) + #define glGetNamedRenderbufferParameteriv GLEGetCurrentFunction(glGetNamedRenderbufferParameteriv) + #define glGetTextureImage GLEGetCurrentFunction(glGetTextureImage) + #define glGetTextureLevelParameterfv GLEGetCurrentFunction(glGetTextureLevelParameterfv) + #define glGetTextureLevelParameteriv GLEGetCurrentFunction(glGetTextureLevelParameteriv) + #define glGetTextureParameterIiv GLEGetCurrentFunction(glGetTextureParameterIiv) + #define glGetTextureParameterIuiv GLEGetCurrentFunction(glGetTextureParameterIuiv) + #define glGetTextureParameterfv GLEGetCurrentFunction(glGetTextureParameterfv) + #define glGetTextureParameteriv GLEGetCurrentFunction(glGetTextureParameteriv) + #define glGetTransformFeedbacki64_v GLEGetCurrentFunction(glGetTransformFeedbacki64_v) + #define glGetTransformFeedbacki_v GLEGetCurrentFunction(glGetTransformFeedbacki_v) + #define glGetTransformFeedbackiv GLEGetCurrentFunction(glGetTransformFeedbackiv) + #define glGetVertexArrayIndexed64iv GLEGetCurrentFunction(glGetVertexArrayIndexed64iv) + #define glGetVertexArrayIndexediv GLEGetCurrentFunction(glGetVertexArrayIndexediv) + #define glGetVertexArrayiv GLEGetCurrentFunction(glGetVertexArrayiv) + #define glInvalidateNamedFramebufferData GLEGetCurrentFunction(glInvalidateNamedFramebufferData) + #define glInvalidateNamedFramebufferSubData GLEGetCurrentFunction(glInvalidateNamedFramebufferSubData) + #define glMapNamedBuffer GLEGetCurrentFunction(glMapNamedBuffer) + #define glMapNamedBufferRange GLEGetCurrentFunction(glMapNamedBufferRange) + #define glNamedBufferData GLEGetCurrentFunction(glNamedBufferData) + #define glNamedBufferStorage GLEGetCurrentFunction(glNamedBufferStorage) + #define glNamedBufferSubData GLEGetCurrentFunction(glNamedBufferSubData) + #define glNamedFramebufferDrawBuffer GLEGetCurrentFunction(glNamedFramebufferDrawBuffer) + #define glNamedFramebufferDrawBuffers GLEGetCurrentFunction(glNamedFramebufferDrawBuffers) + #define glNamedFramebufferParameteri GLEGetCurrentFunction(glNamedFramebufferParameteri) + #define glNamedFramebufferReadBuffer GLEGetCurrentFunction(glNamedFramebufferReadBuffer) + #define glNamedFramebufferRenderbuffer GLEGetCurrentFunction(glNamedFramebufferRenderbuffer) + #define glNamedFramebufferTexture GLEGetCurrentFunction(glNamedFramebufferTexture) + #define glNamedFramebufferTextureLayer GLEGetCurrentFunction(glNamedFramebufferTextureLayer) + #define glNamedRenderbufferStorage GLEGetCurrentFunction(glNamedRenderbufferStorage) + #define glNamedRenderbufferStorageMultisample GLEGetCurrentFunction(glNamedRenderbufferStorageMultisample) + #define glTextureBuffer GLEGetCurrentFunction(glTextureBuffer) + #define glTextureBufferRange GLEGetCurrentFunction(glTextureBufferRange) + #define glTextureParameterIiv GLEGetCurrentFunction(glTextureParameterIiv) + #define glTextureParameterIuiv GLEGetCurrentFunction(glTextureParameterIuiv) + #define glTextureParameterf GLEGetCurrentFunction(glTextureParameterf) + #define glTextureParameterfv GLEGetCurrentFunction(glTextureParameterfv) + #define glTextureParameteri GLEGetCurrentFunction(glTextureParameteri) + #define glTextureParameteriv GLEGetCurrentFunction(glTextureParameteriv) + #define glTextureStorage1D GLEGetCurrentFunction(glTextureStorage1D) + #define glTextureStorage2D GLEGetCurrentFunction(glTextureStorage2D) + #define glTextureStorage2DMultisample GLEGetCurrentFunction(glTextureStorage2DMultisample) + #define glTextureStorage3D GLEGetCurrentFunction(glTextureStorage3D) + #define glTextureStorage3DMultisample GLEGetCurrentFunction(glTextureStorage3DMultisample) + #define glTextureSubImage1D GLEGetCurrentFunction(glTextureSubImage1D) + #define glTextureSubImage2D GLEGetCurrentFunction(glTextureSubImage2D) + #define glTextureSubImage3D GLEGetCurrentFunction(glTextureSubImage3D) + #define glTransformFeedbackBufferBase GLEGetCurrentFunction(glTransformFeedbackBufferBase) + #define glTransformFeedbackBufferRange GLEGetCurrentFunction(glTransformFeedbackBufferRange) + #define glUnmapNamedBuffer GLEGetCurrentFunction(glUnmapNamedBuffer) + #define glVertexArrayAttribBinding GLEGetCurrentFunction(glVertexArrayAttribBinding) + #define glVertexArrayAttribFormat GLEGetCurrentFunction(glVertexArrayAttribFormat) + #define glVertexArrayAttribIFormat GLEGetCurrentFunction(glVertexArrayAttribIFormat) + #define glVertexArrayAttribLFormat GLEGetCurrentFunction(glVertexArrayAttribLFormat) + #define glVertexArrayBindingDivisor GLEGetCurrentFunction(glVertexArrayBindingDivisor) + #define glVertexArrayElementBuffer GLEGetCurrentFunction(glVertexArrayElementBuffer) + #define glVertexArrayVertexBuffer GLEGetCurrentFunction(glVertexArrayVertexBuffer) + #define glVertexArrayVertexBuffers GLEGetCurrentFunction(glVertexArrayVertexBuffers) + + #define GLE_ARB_direct_state_access GLEGetCurrentVariable(gle_ARB_direct_state_access) +#endif // GL_ARB_direct_state_access */ + + + +#ifndef GL_ARB_ES2_compatibility + #define GL_ARB_ES2_compatibility 1 + + // This is for OpenGL ES compatibility. + #define GL_FIXED 0x140C + #define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A + #define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B + #define GL_RGB565 0x8D62 + #define GL_LOW_FLOAT 0x8DF0 + #define GL_MEDIUM_FLOAT 0x8DF1 + #define GL_HIGH_FLOAT 0x8DF2 + #define GL_LOW_INT 0x8DF3 + #define GL_MEDIUM_INT 0x8DF4 + #define GL_HIGH_INT 0x8DF5 + #define GL_SHADER_BINARY_FORMATS 0x8DF8 + #define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 + #define GL_SHADER_COMPILER 0x8DFA + #define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB + #define GL_MAX_VARYING_VECTORS 0x8DFC + #define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD + + typedef int GLfixed; + + typedef void (GLAPIENTRY * PFNGLCLEARDEPTHFPROC) (GLclampf d); + typedef void (GLAPIENTRY * PFNGLDEPTHRANGEFPROC) (GLclampf n, GLclampf f); + typedef void (GLAPIENTRY * PFNGLGETSHADERPRECISIONFORMATPROC) (GLenum shadertype, GLenum precisiontype, GLint* range, GLint *precision); + typedef void (GLAPIENTRY * PFNGLRELEASESHADERCOMPILERPROC) (void); + typedef void (GLAPIENTRY * PFNGLSHADERBINARYPROC) (GLsizei count, const GLuint* shaders, GLenum binaryformat, const void*binary, GLsizei length); + + #define glClearDepthf GLEGetCurrentFunction(glClearDepthf) + #define glDepthRangef GLEGetCurrentFunction(glDepthRangef) + #define glGetShaderPrecisionFormat GLEGetCurrentFunction(glGetShaderPrecisionFormat) + #define glReleaseShaderCompiler GLEGetCurrentFunction(glReleaseShaderCompiler) + #define glShaderBinary GLEGetCurrentFunction(glShaderBinary) + + #define GLE_ARB_ES2_compatibility GLEGetCurrentVariable(gle_ARB_ES2_compatibility) +#endif + + + +#ifndef GL_ARB_framebuffer_object + #define GL_ARB_framebuffer_object 1 + + // GL_ARB_framebuffer_object is part of the OpenGL 4.4 core profile. + #define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 + #define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210 + #define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211 + #define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212 + #define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213 + #define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214 + #define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215 + #define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216 + #define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217 + #define GL_FRAMEBUFFER_DEFAULT 0x8218 + #define GL_FRAMEBUFFER_UNDEFINED 0x8219 + #define GL_DEPTH_STENCIL_ATTACHMENT 0x821A + #define GL_INDEX 0x8222 + #define GL_MAX_RENDERBUFFER_SIZE 0x84E8 + #define GL_DEPTH_STENCIL 0x84F9 + #define GL_UNSIGNED_INT_24_8 0x84FA + #define GL_DEPTH24_STENCIL8 0x88F0 + #define GL_TEXTURE_STENCIL_SIZE 0x88F1 + #define GL_UNSIGNED_NORMALIZED 0x8C17 + #define GL_SRGB 0x8C40 + #define GL_DRAW_FRAMEBUFFER_BINDING 0x8CA6 + #define GL_FRAMEBUFFER_BINDING 0x8CA6 + #define GL_RENDERBUFFER_BINDING 0x8CA7 + #define GL_READ_FRAMEBUFFER 0x8CA8 + #define GL_DRAW_FRAMEBUFFER 0x8CA9 + #define GL_READ_FRAMEBUFFER_BINDING 0x8CAA + #define GL_RENDERBUFFER_SAMPLES 0x8CAB + #define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 + #define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 + #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 + #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 + #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4 + #define GL_FRAMEBUFFER_COMPLETE 0x8CD5 + #define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 + #define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 + #define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB + #define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC + #define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD + #define GL_MAX_COLOR_ATTACHMENTS 0x8CDF + #define GL_COLOR_ATTACHMENT0 0x8CE0 + #define GL_COLOR_ATTACHMENT1 0x8CE1 + #define GL_COLOR_ATTACHMENT2 0x8CE2 + #define GL_COLOR_ATTACHMENT3 0x8CE3 + #define GL_COLOR_ATTACHMENT4 0x8CE4 + #define GL_COLOR_ATTACHMENT5 0x8CE5 + #define GL_COLOR_ATTACHMENT6 0x8CE6 + #define GL_COLOR_ATTACHMENT7 0x8CE7 + #define GL_COLOR_ATTACHMENT8 0x8CE8 + #define GL_COLOR_ATTACHMENT9 0x8CE9 + #define GL_COLOR_ATTACHMENT10 0x8CEA + #define GL_COLOR_ATTACHMENT11 0x8CEB + #define GL_COLOR_ATTACHMENT12 0x8CEC + #define GL_COLOR_ATTACHMENT13 0x8CED + #define GL_COLOR_ATTACHMENT14 0x8CEE + #define GL_COLOR_ATTACHMENT15 0x8CEF + #define GL_DEPTH_ATTACHMENT 0x8D00 + #define GL_STENCIL_ATTACHMENT 0x8D20 + #define GL_FRAMEBUFFER 0x8D40 + #define GL_RENDERBUFFER 0x8D41 + #define GL_RENDERBUFFER_WIDTH 0x8D42 + #define GL_RENDERBUFFER_HEIGHT 0x8D43 + #define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 + #define GL_STENCIL_INDEX1 0x8D46 + #define GL_STENCIL_INDEX4 0x8D47 + #define GL_STENCIL_INDEX8 0x8D48 + #define GL_STENCIL_INDEX16 0x8D49 + #define GL_RENDERBUFFER_RED_SIZE 0x8D50 + #define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 + #define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 + #define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 + #define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 + #define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 + #define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56 + #define GL_MAX_SAMPLES 0x8D57 + + typedef void (GLAPIENTRY * PFNGLBINDFRAMEBUFFERPROC) (GLenum target, GLuint framebuffer); + typedef void (GLAPIENTRY * PFNGLBINDRENDERBUFFERPROC) (GLenum target, GLuint renderbuffer); + typedef void (GLAPIENTRY * PFNGLBLITFRAMEBUFFERPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); + typedef GLenum (GLAPIENTRY * PFNGLCHECKFRAMEBUFFERSTATUSPROC) (GLenum target); + typedef void (GLAPIENTRY * PFNGLDELETEFRAMEBUFFERSPROC) (GLsizei n, const GLuint* framebuffers); + typedef void (GLAPIENTRY * PFNGLDELETERENDERBUFFERSPROC) (GLsizei n, const GLuint* renderbuffers); + typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERRENDERBUFFERPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); + typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE1DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); + typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE2DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); + typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE3DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint layer); + typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURELAYERPROC) (GLenum target,GLenum attachment, GLuint texture,GLint level,GLint layer); + typedef void (GLAPIENTRY * PFNGLGENFRAMEBUFFERSPROC) (GLsizei n, GLuint* framebuffers); + typedef void (GLAPIENTRY * PFNGLGENRENDERBUFFERSPROC) (GLsizei n, GLuint* renderbuffers); + typedef void (GLAPIENTRY * PFNGLGENERATEMIPMAPPROC) (GLenum target); + typedef void (GLAPIENTRY * PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLenum target, GLenum attachment, GLenum pname, GLint* params); + typedef void (GLAPIENTRY * PFNGLGETRENDERBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint* params); + typedef GLboolean (GLAPIENTRY * PFNGLISFRAMEBUFFERPROC) (GLuint framebuffer); + typedef GLboolean (GLAPIENTRY * PFNGLISRENDERBUFFERPROC) (GLuint renderbuffer); + typedef void (GLAPIENTRY * PFNGLRENDERBUFFERSTORAGEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); + typedef void (GLAPIENTRY * PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); + + #define glBindFramebuffer GLEGetCurrentFunction(glBindFramebuffer) + #define glBindRenderbuffer GLEGetCurrentFunction(glBindRenderbuffer) + #define glBlitFramebuffer GLEGetCurrentFunction(glBlitFramebuffer) + #define glCheckFramebufferStatus GLEGetCurrentFunction(glCheckFramebufferStatus) + #define glDeleteFramebuffers GLEGetCurrentFunction(glDeleteFramebuffers) + #define glDeleteRenderbuffers GLEGetCurrentFunction(glDeleteRenderbuffers) + #define glFramebufferRenderbuffer GLEGetCurrentFunction(glFramebufferRenderbuffer) + #define glFramebufferTexture1D GLEGetCurrentFunction(glFramebufferTexture1D) + #define glFramebufferTexture2D GLEGetCurrentFunction(glFramebufferTexture2D) + #define glFramebufferTexture3D GLEGetCurrentFunction(glFramebufferTexture3D) + #define glFramebufferTextureLayer GLEGetCurrentFunction(glFramebufferTextureLayer) + #define glGenFramebuffers GLEGetCurrentFunction(glGenFramebuffers) + #define glGenRenderbuffers GLEGetCurrentFunction(glGenRenderbuffers) + #define glGenerateMipmap GLEGetCurrentFunction(glGenerateMipmap) + #define glGetFramebufferAttachmentParameteriv GLEGetCurrentFunction(glGetFramebufferAttachmentParameteriv) + #define glGetRenderbufferParameteriv GLEGetCurrentFunction(glGetRenderbufferParameteriv) + #define glIsFramebuffer GLEGetCurrentFunction(glIsFramebuffer) + #define glIsRenderbuffer GLEGetCurrentFunction(glIsRenderbuffer) + #define glRenderbufferStorage GLEGetCurrentFunction(glRenderbufferStorage) + #define glRenderbufferStorageMultisample GLEGetCurrentFunction(glRenderbufferStorageMultisample) + + #define GLE_ARB_framebuffer_object GLEGetCurrentVariable(gle_ARB_framebuffer_object) + +#endif // GL_ARB_framebuffer_object + + + +#ifndef GL_ARB_framebuffer_sRGB + #define GL_ARB_framebuffer_sRGB 1 + + // GL_ARB_framebuffer_sRGB is part of the OpenGL 4.4 core profile. + #define GL_FRAMEBUFFER_SRGB 0x8DB9 + + #define GLE_ARB_framebuffer_sRGB GLEGetCurrentVariable(gle_ARB_framebuffer_sRGB) +#endif + + + +#ifndef GL_ARB_texture_multisample + #define GL_ARB_texture_multisample 1 + + #define GL_SAMPLE_POSITION 0x8E50 + #define GL_SAMPLE_MASK 0x8E51 + #define GL_SAMPLE_MASK_VALUE 0x8E52 + #define GL_MAX_SAMPLE_MASK_WORDS 0x8E59 + #define GL_TEXTURE_2D_MULTISAMPLE 0x9100 + #define GL_PROXY_TEXTURE_2D_MULTISAMPLE 0x9101 + #define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102 + #define GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9103 + #define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104 + #define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105 + #define GL_TEXTURE_SAMPLES 0x9106 + #define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107 + #define GL_SAMPLER_2D_MULTISAMPLE 0x9108 + #define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109 + #define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A + #define GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B + #define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C + #define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D + #define GL_MAX_COLOR_TEXTURE_SAMPLES 0x910E + #define GL_MAX_DEPTH_TEXTURE_SAMPLES 0x910F + #define GL_MAX_INTEGER_SAMPLES 0x9110 + + typedef void (GLAPIENTRY * PFNGLGETMULTISAMPLEFVPROC) (GLenum pname, GLuint index, GLfloat* val); + typedef void (GLAPIENTRY * PFNGLSAMPLEMASKIPROC) (GLuint index, GLbitfield mask); + typedef void (GLAPIENTRY * PFNGLTEXIMAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); + typedef void (GLAPIENTRY * PFNGLTEXIMAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); + + #define glGetMultisamplefv GLEGetCurrentFunction(glGetMultisamplefv) + #define glSampleMaski GLEGetCurrentFunction(glSampleMaski) + #define glTexImage2DMultisample GLEGetCurrentFunction(glTexImage2DMultisample) + #define glTexImage3DMultisample GLEGetCurrentFunction(glTexImage3DMultisample) + + #define GLE_ARB_texture_multisample GLEGetCurrentVariable(gle_ARB_texture_multisample) + +#endif // GL_ARB_texture_multisample + + + +#ifndef GL_ARB_texture_non_power_of_two + #define GL_ARB_texture_non_power_of_two 1 + + #define GLE_ARB_texture_non_power_of_two GLEGetCurrentVariable(gle_ARB_texture_non_power_of_two) +#endif + + + +#ifndef GL_ARB_texture_rectangle + #define GL_ARB_texture_rectangle 1 + + // texture_rectangle was added to the OpenGL 3.1 core profile and so this extension is not needed + // unless using an earlier version of OpenGL. + // There are also the GL_EXT_texture_rectangle and GL_NV_texture_rectangle extensions. Apple reports + // the preseence of GL_EXT_texture_rectangle but not GL_ARB_texture_rectangle or GL_NV_texture_rectangle. + // You should check for GL_ARB_texture_rectangle instead of these other two. + #define GL_TEXTURE_RECTANGLE_ARB 0x84F5 + #define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6 + #define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7 + #define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8 + #define GL_SAMPLER_2D_RECT_ARB 0x8B63 + #define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 + + #define GLE_ARB_texture_rectangle GLEGetCurrentVariable(gle_ARB_texture_rectangle) +#endif + + + +#ifndef GL_ARB_timer_query + #define GL_ARB_timer_query 1 + + #define GL_TIME_ELAPSED 0x88BF + #define GL_TIMESTAMP 0x8E28 + + typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTI64VPROC) (GLuint id, GLenum pname, GLint64* params); + typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTUI64VPROC) (GLuint id, GLenum pname, GLuint64* params); + typedef void (GLAPIENTRY * PFNGLQUERYCOUNTERPROC) (GLuint id, GLenum target); + + #define glGetQueryObjecti64v GLEGetCurrentFunction(glGetQueryObjecti64v) + #define glGetQueryObjectui64v GLEGetCurrentFunction(glGetQueryObjectui64v) + #define glQueryCounter GLEGetCurrentFunction(glQueryCounter) + + #define GLE_ARB_timer_query GLEGetCurrentVariable(gle_ARB_timer_query) +#endif + + + +#ifndef GL_ARB_vertex_array_object + #define GL_ARB_vertex_array_object 1 + + #define GL_VERTEX_ARRAY_BINDING 0x85B5 + + typedef void (GLAPIENTRY * PFNGLBINDVERTEXARRAYPROC) (GLuint array); + typedef void (GLAPIENTRY * PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint* arrays); + typedef void (GLAPIENTRY * PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint* arrays); + typedef GLboolean (GLAPIENTRY * PFNGLISVERTEXARRAYPROC) (GLuint array); + + #define glBindVertexArray GLEGetCurrentFunction(glBindVertexArray) + #define glDeleteVertexArrays GLEGetCurrentFunction(glDeleteVertexArrays) + #define glGenVertexArrays GLEGetCurrentFunction(glGenVertexArrays) + #define glIsVertexArray GLEGetCurrentFunction(glIsVertexArray) + + #define GLE_ARB_vertex_array_object GLEGetCurrentVariable(gle_ARB_vertex_array_object) +#endif + + + +/* Disabled until needed +#ifndef GL_ARB_vertex_attrib_binding + #define GL_ARB_vertex_attrib_binding 1 + + #define GL_VERTEX_ATTRIB_BINDING 0x82D4 + #define GL_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D5 + #define GL_VERTEX_BINDING_DIVISOR 0x82D6 + #define GL_VERTEX_BINDING_OFFSET 0x82D7 + #define GL_VERTEX_BINDING_STRIDE 0x82D8 + #define GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D9 + #define GL_MAX_VERTEX_ATTRIB_BINDINGS 0x82DA + #define GL_VERTEX_BINDING_BUFFER 0x8F4F + + typedef void (GLAPIENTRY * PFNGLBINDVERTEXBUFFERPROC) (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); + typedef void (GLAPIENTRY * PFNGLVERTEXARRAYBINDVERTEXBUFFEREXTPROC) (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); + typedef void (GLAPIENTRY * PFNGLVERTEXARRAYVERTEXATTRIBBINDINGEXTPROC) (GLuint vaobj, GLuint attribindex, GLuint bindingindex); + typedef void (GLAPIENTRY * PFNGLVERTEXARRAYVERTEXATTRIBFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); + typedef void (GLAPIENTRY * PFNGLVERTEXARRAYVERTEXATTRIBIFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); + typedef void (GLAPIENTRY * PFNGLVERTEXARRAYVERTEXATTRIBLFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); + typedef void (GLAPIENTRY * PFNGLVERTEXARRAYVERTEXBINDINGDIVISOREXTPROC) (GLuint vaobj, GLuint bindingindex, GLuint divisor); + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBBINDINGPROC) (GLuint attribindex, GLuint bindingindex); + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBIFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); + typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBLFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); + typedef void (GLAPIENTRY * PFNGLVERTEXBINDINGDIVISORPROC) (GLuint bindingindex, GLuint divisor); + + #define glBindVertexBuffer GLEGetCurrentFunction(glBindVertexBuffer) + #define glVertexArrayBindVertexBufferEXT GLEGetCurrentFunction(glVertexArrayBindVertexBufferEXT) + #define glVertexArrayVertexAttribBindingEXT GLEGetCurrentFunction(glVertexArrayVertexAttribBindingEXT) + #define glVertexArrayVertexAttribFormatEXT GLEGetCurrentFunction(glVertexArrayVertexAttribFormatEXT) + #define glVertexArrayVertexAttribIFormatEXT GLEGetCurrentFunction(glVertexArrayVertexAttribIFormatEXT) + #define glVertexArrayVertexAttribLFormatEXT GLEGetCurrentFunction(glVertexArrayVertexAttribLFormatEXT) + #define glVertexArrayVertexBindingDivisorEXT GLEGetCurrentFunction(glVertexArrayVertexBindingDivisorEXT) + #define glVertexAttribBinding GLEGetCurrentFunction(glVertexAttribBinding) + #define glVertexAttribFormat GLEGetCurrentFunction(glVertexAttribFormat) + #define glVertexAttribIFormat GLEGetCurrentFunction(glVertexAttribIFormat) + #define glVertexAttribLFormat GLEGetCurrentFunction(glVertexAttribLFormat) + #define glVertexBindingDivisor GLEGetCurrentFunction(glVertexBindingDivisor) + + #define GLE_ARB_vertex_attrib_binding GLEGetCurrentVariable(gle_ARB_vertex_attrib_binding) +#endif +*/ + + +#ifndef GL_EXT_draw_buffers2 + #define GL_EXT_draw_buffers2 1 + + typedef void (GLAPIENTRY * PFNGLCOLORMASKINDEXEDEXTPROC) (GLuint buf, GLboolean r, GLboolean g, GLboolean b, GLboolean a); + typedef void (GLAPIENTRY * PFNGLDISABLEINDEXEDEXTPROC) (GLenum target, GLuint index); + typedef void (GLAPIENTRY * PFNGLENABLEINDEXEDEXTPROC) (GLenum target, GLuint index); + typedef void (GLAPIENTRY * PFNGLGETBOOLEANINDEXEDVEXTPROC) (GLenum value, GLuint index, GLboolean* data); + typedef void (GLAPIENTRY * PFNGLGETINTEGERINDEXEDVEXTPROC) (GLenum value, GLuint index, GLint* data); + typedef GLboolean (GLAPIENTRY * PFNGLISENABLEDINDEXEDEXTPROC) (GLenum target, GLuint index); + + #define glColorMaskIndexedEXT GLEGetCurrentFunction(glColorMaskIndexedEXT) + #define glDisableIndexedEXT GLEGetCurrentFunction(glDisableIndexedEXT) + #define glEnableIndexedEXT GLEGetCurrentFunction(glEnableIndexedEXT) + #define glGetBooleanIndexedvEXT GLEGetCurrentFunction(glGetBooleanIndexedvEXT) + #define glGetIntegerIndexedvEXT GLEGetCurrentFunction(glGetIntegerIndexedvEXT) + #define glIsEnabledIndexedEXT GLEGetCurrentFunction(glIsEnabledIndexedEXT) + + #define GLE_EXT_draw_buffers2 GLEGetCurrentVariable(gle_EXT_draw_buffers2) +#endif + + + +#ifndef GL_EXT_texture_compression_s3tc + #define GL_EXT_texture_compression_s3tc 1 + + #define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 + #define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 + #define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 + #define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 + + #define GLE_EXT_texture_compression_s3tc GLEGetCurrentVariable(gle_EXT_texture_compression_s3tc) +#endif + + + +#ifndef GL_EXT_texture_filter_anisotropic + #define GL_EXT_texture_filter_anisotropic 1 + + #define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE + #define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF + + #define GLE_EXT_texture_filter_anisotropic GLEGetCurrentVariable(gle_EXT_texture_filter_anisotropic) +#endif + + + +/* Disabled until needed +#ifndef GL_KHR_context_flush_control + #define GL_KHR_context_flush_control 1 + + #define GLE_KHR_context_flush_control GLEGetCurrentVariable(gle_KHR_context_flush_control) +#endif +*/ + + + +#ifndef GL_KHR_debug + #define GL_KHR_debug 1 + + #define GL_CONTEXT_FLAG_DEBUG_BIT 0x00000002 + #define GL_STACK_OVERFLOW 0x0503 + #define GL_STACK_UNDERFLOW 0x0504 + #define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242 + #define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH 0x8243 + #define GL_DEBUG_CALLBACK_FUNCTION 0x8244 + #define GL_DEBUG_CALLBACK_USER_PARAM 0x8245 + #define GL_DEBUG_SOURCE_API 0x8246 + #define GL_DEBUG_SOURCE_WINDOW_SYSTEM 0x8247 + #define GL_DEBUG_SOURCE_SHADER_COMPILER 0x8248 + #define GL_DEBUG_SOURCE_THIRD_PARTY 0x8249 + #define GL_DEBUG_SOURCE_APPLICATION 0x824A + #define GL_DEBUG_SOURCE_OTHER 0x824B + #define GL_DEBUG_TYPE_ERROR 0x824C + #define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR 0x824D + #define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR 0x824E + #define GL_DEBUG_TYPE_PORTABILITY 0x824F + #define GL_DEBUG_TYPE_PERFORMANCE 0x8250 + #define GL_DEBUG_TYPE_OTHER 0x8251 + #define GL_DEBUG_TYPE_MARKER 0x8268 + #define GL_DEBUG_TYPE_PUSH_GROUP 0x8269 + #define GL_DEBUG_TYPE_POP_GROUP 0x826A + #define GL_DEBUG_SEVERITY_NOTIFICATION 0x826B + #define GL_MAX_DEBUG_GROUP_STACK_DEPTH 0x826C + #define GL_DEBUG_GROUP_STACK_DEPTH 0x826D + #define GL_BUFFER 0x82E0 + #define GL_SHADER 0x82E1 + #define GL_PROGRAM 0x82E2 + #define GL_QUERY 0x82E3 + #define GL_PROGRAM_PIPELINE 0x82E4 + #define GL_SAMPLER 0x82E6 + #define GL_DISPLAY_LIST 0x82E7 + #define GL_MAX_LABEL_LENGTH 0x82E8 + #define GL_MAX_DEBUG_MESSAGE_LENGTH 0x9143 + #define GL_MAX_DEBUG_LOGGED_MESSAGES 0x9144 + #define GL_DEBUG_LOGGED_MESSAGES 0x9145 + #define GL_DEBUG_SEVERITY_HIGH 0x9146 + #define GL_DEBUG_SEVERITY_MEDIUM 0x9147 + #define GL_DEBUG_SEVERITY_LOW 0x9148 + #define GL_DEBUG_OUTPUT 0x92E0 + + typedef void (GLAPIENTRY *GLDEBUGPROC)(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, const void* userParam); + + typedef void (GLAPIENTRY * PFNGLDEBUGMESSAGECALLBACKPROC) (GLDEBUGPROC callback, const void *userParam); + typedef void (GLAPIENTRY * PFNGLDEBUGMESSAGECONTROLPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint* ids, GLboolean enabled); + typedef void (GLAPIENTRY * PFNGLDEBUGMESSAGEINSERTPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* buf); + typedef GLuint (GLAPIENTRY * PFNGLGETDEBUGMESSAGELOGPROC) (GLuint count, GLsizei bufSize, GLenum* sources, GLenum* types, GLuint* ids, GLenum* severities, GLsizei* lengths, GLchar* messageLog); + typedef void (GLAPIENTRY * PFNGLGETOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei* length, GLchar *label); + typedef void (GLAPIENTRY * PFNGLGETOBJECTPTRLABELPROC) (const void *ptr, GLsizei bufSize, GLsizei* length, GLchar *label); + typedef void (GLAPIENTRY * PFNGLOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei length, const GLchar* label); + typedef void (GLAPIENTRY * PFNGLOBJECTPTRLABELPROC) (const void *ptr, GLsizei length, const GLchar* label); + typedef void (GLAPIENTRY * PFNGLPOPDEBUGGROUPPROC) (void); + typedef void (GLAPIENTRY * PFNGLPUSHDEBUGGROUPPROC) (GLenum source, GLuint id, GLsizei length, const GLchar * message); + + #define glDebugMessageCallback GLEGetCurrentFunction(glDebugMessageCallback) + #define glDebugMessageControl GLEGetCurrentFunction(glDebugMessageControl) + #define glDebugMessageInsert GLEGetCurrentFunction(glDebugMessageInsert) + #define glGetDebugMessageLog GLEGetCurrentFunction(glGetDebugMessageLog) + #define glGetObjectLabel GLEGetCurrentFunction(glGetObjectLabel) + #define glGetObjectPtrLabel GLEGetCurrentFunction(glGetObjectPtrLabel) + #define glObjectLabel GLEGetCurrentFunction(glObjectLabel) + #define glObjectPtrLabel GLEGetCurrentFunction(glObjectPtrLabel) + #define glPopDebugGroup GLEGetCurrentFunction(glPopDebugGroup) + #define glPushDebugGroup GLEGetCurrentFunction(glPushDebugGroup) + + #define GLE_KHR_debug GLEGetCurrentVariable(gle_KHR_debug) +#endif // GL_KHR_debug + + + +#ifndef GL_KHR_robust_buffer_access_behavior + #define GL_KHR_robust_buffer_access_behavior 1 + + #define GLE_KHR_robust_buffer_access_behavior GLEGetCurrentVariable(gle_KHR_robust_buffer_access_behavior) +#endif + + + +/* Disabled until needed +#ifndef GL_KHR_robustness + #define GL_KHR_robustness 1 + + #define GL_CONTEXT_LOST 0x0507 + #define GL_LOSE_CONTEXT_ON_RESET 0x8252 + #define GL_GUILTY_CONTEXT_RESET 0x8253 + #define GL_INNOCENT_CONTEXT_RESET 0x8254 + #define GL_UNKNOWN_CONTEXT_RESET 0x8255 + #define GL_RESET_NOTIFICATION_STRATEGY 0x8256 + #define GL_NO_RESET_NOTIFICATION 0x8261 + #define GL_CONTEXT_ROBUST_ACCESS 0x90F3 + + typedef void (GLAPIENTRY * PFNGLGETNUNIFORMFVPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat* params); + typedef void (GLAPIENTRY * PFNGLGETNUNIFORMIVPROC) (GLuint program, GLint location, GLsizei bufSize, GLint* params); + typedef void (GLAPIENTRY * PFNGLGETNUNIFORMUIVPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint* params); + typedef void (GLAPIENTRY * PFNGLREADNPIXELSPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); + + #define glGetnUniformfv GLEGetCurrentFunction(glGetnUniformfv) + #define glGetnUniformiv GLEGetCurrentFunction(glGetnUniformiv) + #define glGetnUniformuiv GLEGetCurrentFunction(glGetnUniformuiv) + #define glReadnPixels GLEGetCurrentFunction(glReadnPixels) + + #define GLE_KHR_robustness GLEGetCurrentVariable(gle_KHR_robustness) + +#endif // GL_KHR_robustness +*/ + + + +#ifndef GL_WIN_swap_hint + #define GL_WIN_swap_hint 1 + + typedef void (GLAPIENTRY * PFNGLADDSWAPHINTRECTWINPROC) (GLint x, GLint y, GLsizei width, GLsizei height); + + #define glAddSwapHintRectWIN GLEGetCurrentFunction(glAddSwapHintRectWIN) + + #define GLE_WIN_swap_hint GLEGetCurrentVariable(gle_WIN_swap_hint) +#endif + + + +/************************************************************************************ + Windows-specific (WGL) functionality +************************************************************************************/ + +#if defined(GLE_WGL_ENABLED) + #ifdef __wglext_h_ + #error wglext.h was included before this header. This header needs to be inlcuded instead of or at least before wglext.h + #endif + #define __wglext_h_ // Prevent wglext.h from having any future effect if it's #included. + + // Declare shared types and structs from wglext.h + DECLARE_HANDLE(HPBUFFERARB); // This type is used by a couple extensions. + + // WGL functions from + #if 0 // defined(GLE_HOOKING_ENABLED) We currently don't hook these. + #define wglCopyContext(...) GLEGetCurrentFunction(wglCopyContext)(__VA_ARGS__) + #define wglCreateContext(...) GLEGetCurrentFunction(wglCreateContext)(__VA_ARGS__) + #define wglCreateLayerContext(...) GLEGetCurrentFunction(wglCreateLayerContext)(__VA_ARGS__) + #define wglDeleteContext(...) GLEGetCurrentFunction(wglDeleteContext)(__VA_ARGS__) + #define wglGetCurrentContext(...) GLEGetCurrentFunction(wglGetCurrentContext)(__VA_ARGS__) + #define wglGetCurrentDC(...) GLEGetCurrentFunction(wglGetCurrentDC)(__VA_ARGS__) + #define wglGetProcAddress(...) GLEGetCurrentFunction(wglGetProcAddress)(__VA_ARGS__) + #define wglMakeCurrent(...) GLEGetCurrentFunction(wglMakeCurrent)(__VA_ARGS__) + #define wglShareLists(...) GLEGetCurrentFunction(wglShareLists)(__VA_ARGS__) + #define wglUseFontBitmapsA(...) GLEGetCurrentFunction(wglUseFontBitmapsA)(__VA_ARGS__) + #define wglUseFontBitmapsW(...) GLEGetCurrentFunction(wglUseFontBitmapsW)(__VA_ARGS__) + #define wglUseFontOutlinesA(...) GLEGetCurrentFunction(wglUseFontOutlinesA)(__VA_ARGS__) + #define wglUseFontOutlinesW(...) GLEGetCurrentFunction(wglUseFontOutlinesW)(__VA_ARGS__) + #define wglDescribeLayerPlane(...) GLEGetCurrentFunction(wglDescribeLayerPlane)(__VA_ARGS__) + #define wglSetLayerPaletteEntries(...) GLEGetCurrentFunction(wglSetLayerPaletteEntries)(__VA_ARGS__) + #define wglGetLayerPaletteEntries(...) GLEGetCurrentFunction(wglGetLayerPaletteEntries)(__VA_ARGS__) + #define wglRealizeLayerPalette(...) GLEGetCurrentFunction(wglRealizeLayerPalette)(__VA_ARGS__) + #define wglSwapLayerBuffers(...) GLEGetCurrentFunction(wglSwapLayerBuffers)(__VA_ARGS__) + #define wglSwapMultipleBuffers(...) GLEGetCurrentFunction(wglSwapMultipleBuffers)(__VA_ARGS__) + #else + // The following functions are directly declared in Microsoft's without associated typedefs, and are exported from Opengl32.dll. + // We can link to them directly through Opengl32.lib/dll (same as OpenGL 1.1 functions) or we can dynamically link them from OpenGL32.dll at runtime. + typedef BOOL (WINAPI * PFNWGLCOPYCONTEXTPROC)(HGLRC, HGLRC, UINT); + typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTPROC)(HDC); + typedef HGLRC (WINAPI * PFNWGLCREATELAYERCONTEXTPROC)(HDC, int); + typedef BOOL (WINAPI * PFNWGLDELETECONTEXTPROC)(HGLRC); + typedef HGLRC (WINAPI * PFNWGLGETCURRENTCONTEXTPROC)(VOID); + typedef HDC (WINAPI * PFNWGLGETCURRENTDCPROC)(VOID); + typedef PROC (WINAPI * PFNWGLGETPROCADDRESSPROC)(LPCSTR); + typedef BOOL (WINAPI * PFNWGLMAKECURRENTPROC)(HDC, HGLRC); + typedef BOOL (WINAPI * PFNWGLSHARELISTSPROC)(HGLRC, HGLRC); + typedef BOOL (WINAPI * PFNWGLUSEFONTBITMAPSAPROC)(HDC, DWORD, DWORD, DWORD); + typedef BOOL (WINAPI * PFNWGLUSEFONTBITMAPSWPROC)(HDC, DWORD, DWORD, DWORD); + typedef BOOL (WINAPI * PFNWGLUSEFONTOUTLINESAPROC)(HDC, DWORD, DWORD, DWORD, FLOAT, FLOAT, int, LPGLYPHMETRICSFLOAT); + typedef BOOL (WINAPI * PFNWGLUSEFONTOUTLINESWPROC)(HDC, DWORD, DWORD, DWORD, FLOAT, FLOAT, int, LPGLYPHMETRICSFLOAT); + typedef BOOL (WINAPI * PFNWGLDESCRIBELAYERPLANEPROC)(HDC, int, int, UINT, LPLAYERPLANEDESCRIPTOR); + typedef int (WINAPI * PFNWGLSETLAYERPALETTEENTRIESPROC)(HDC, int, int, int, CONST COLORREF *); + typedef int (WINAPI * PFNWGLGETLAYERPALETTEENTRIESPROC)(HDC, int, int, int, COLORREF *); + typedef BOOL (WINAPI * PFNWGLREALIZELAYERPALETTEPROC)(HDC, int, BOOL); + typedef BOOL (WINAPI * PFNWGLSWAPLAYERBUFFERSPROC)(HDC, UINT); + typedef DWORD (WINAPI * PFNWGLSWAPMULTIPLEBUFFERSPROC)(UINT, CONST WGLSWAP *); + + #if 0 + #define wglCopyContext GLEContext::GetCurrentContext()->wglCopyContext_Impl + #define wglCreateContext GLEContext::GetCurrentContext()->wglCreateContext_Impl + #define wglCreateLayerContext GLEContext::GetCurrentContext()->wglCreateLayerContext_Impl + #define wglDeleteContext GLEContext::GetCurrentContext()->wglDeleteContext_Impl + #define wglGetCurrentContext GLEContext::GetCurrentContext()->wglGetCurrentContext_Impl + #define wglGetCurrentDC GLEContext::GetCurrentContext()->wglGetCurrentDC_Impl + #define wglGetProcAddress GLEContext::GetCurrentContext()->wglGetProcAddress_Impl + #define wglMakeCurrent GLEContext::GetCurrentContext()->wglMakeCurrent_Impl + #define wglShareLists GLEContext::GetCurrentContext()->wglShareLists_Impl + #define wglUseFontBitmapsA GLEContext::GetCurrentContext()->wglUseFontBitmapsA_Impl + #define wglUseFontBitmapsW GLEContext::GetCurrentContext()->wglUseFontBitmapsW_Impl + #define wglUseFontOutlinesA GLEContext::GetCurrentContext()->wglUseFontOutlinesA_Impl + #define wglUseFontOutlinesW GLEContext::GetCurrentContext()->wglUseFontOutlinesW_Impl + #define wglDescribeLayerPlane GLEContext::GetCurrentContext()->wglDescribeLayerPlane_Impl + #define wglSetLayerPaletteEntries GLEContext::GetCurrentContext()->wglSetLayerPaletteEntries_Impl + #define wglGetLayerPaletteEntries GLEContext::GetCurrentContext()->wglGetLayerPaletteEntries_Impl + #define wglRealizeLayerPalette GLEContext::GetCurrentContext()->wglRealizeLayerPalette_Impl + #define wglSwapLayerBuffers GLEContext::GetCurrentContext()->wglSwapLayerBuffers_Impl + #define wglSwapMultipleBuffers GLEContext::GetCurrentContext()->wglSwapMultipleBuffers_Impl + #endif + #endif + + // Note: In order to detect the WGL extensions' availability, we need to call wglGetExtensionsStringARB or + // wglGetExtensionsStringEXT instead of glGetString(GL_EXTENSIONS). + #ifndef WGL_ARB_buffer_region + #define WGL_ARB_buffer_region 1 + + #define WGL_FRONT_COLOR_BUFFER_BIT_ARB 0x00000001 + #define WGL_BACK_COLOR_BUFFER_BIT_ARB 0x00000002 + #define WGL_DEPTH_BUFFER_BIT_ARB 0x00000004 + #define WGL_STENCIL_BUFFER_BIT_ARB 0x00000008 + + typedef HANDLE (WINAPI * PFNWGLCREATEBUFFERREGIONARBPROC) (HDC hDC, int iLayerPlane, UINT uType); + typedef VOID (WINAPI * PFNWGLDELETEBUFFERREGIONARBPROC) (HANDLE hRegion); + typedef BOOL (WINAPI * PFNWGLSAVEBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height); + typedef BOOL (WINAPI * PFNWGLRESTOREBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc); + + #define wglCreateBufferRegionARB GLEGetCurrentFunction(wglCreateBufferRegionARB) + #define wglDeleteBufferRegionARB GLEGetCurrentFunction(wglDeleteBufferRegionARB) + #define wglSaveBufferRegionARB GLEGetCurrentFunction(wglSaveBufferRegionARB) + #define wglRestoreBufferRegionARB GLEGetCurrentFunction(wglRestoreBufferRegionARB) + + #define GLE_WGL_ARB_buffer_region GLEGetCurrentVariable(gle_WGL_ARB_buffer_region) + #endif + + + #ifndef WGL_ARB_extensions_string + #define WGL_ARB_extensions_string 1 + + typedef const char * (WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC) (HDC hdc); + + #define wglGetExtensionsStringARB GLEGetCurrentFunction(wglGetExtensionsStringARB) + + #define GLE_WGL_ARB_extensions_string GLEGetCurrentVariable(gle_WGL_ARB_extensions_string) + #endif + + + #ifndef WGL_ARB_pixel_format + #define WGL_ARB_pixel_format 1 + + #define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000 + #define WGL_DRAW_TO_WINDOW_ARB 0x2001 + #define WGL_DRAW_TO_BITMAP_ARB 0x2002 + #define WGL_ACCELERATION_ARB 0x2003 + #define WGL_NEED_PALETTE_ARB 0x2004 + #define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005 + #define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006 + #define WGL_SWAP_METHOD_ARB 0x2007 + #define WGL_NUMBER_OVERLAYS_ARB 0x2008 + #define WGL_NUMBER_UNDERLAYS_ARB 0x2009 + #define WGL_TRANSPARENT_ARB 0x200A + #define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037 + #define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038 + #define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039 + #define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A + #define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B + #define WGL_SHARE_DEPTH_ARB 0x200C + #define WGL_SHARE_STENCIL_ARB 0x200D + #define WGL_SHARE_ACCUM_ARB 0x200E + #define WGL_SUPPORT_GDI_ARB 0x200F + #define WGL_SUPPORT_OPENGL_ARB 0x2010 + #define WGL_DOUBLE_BUFFER_ARB 0x2011 + #define WGL_STEREO_ARB 0x2012 + #define WGL_PIXEL_TYPE_ARB 0x2013 + #define WGL_COLOR_BITS_ARB 0x2014 + #define WGL_RED_BITS_ARB 0x2015 + #define WGL_RED_SHIFT_ARB 0x2016 + #define WGL_GREEN_BITS_ARB 0x2017 + #define WGL_GREEN_SHIFT_ARB 0x2018 + #define WGL_BLUE_BITS_ARB 0x2019 + #define WGL_BLUE_SHIFT_ARB 0x201A + #define WGL_ALPHA_BITS_ARB 0x201B + #define WGL_ALPHA_SHIFT_ARB 0x201C + #define WGL_ACCUM_BITS_ARB 0x201D + #define WGL_ACCUM_RED_BITS_ARB 0x201E + #define WGL_ACCUM_GREEN_BITS_ARB 0x201F + #define WGL_ACCUM_BLUE_BITS_ARB 0x2020 + #define WGL_ACCUM_ALPHA_BITS_ARB 0x2021 + #define WGL_DEPTH_BITS_ARB 0x2022 + #define WGL_STENCIL_BITS_ARB 0x2023 + #define WGL_AUX_BUFFERS_ARB 0x2024 + #define WGL_NO_ACCELERATION_ARB 0x2025 + #define WGL_GENERIC_ACCELERATION_ARB 0x2026 + #define WGL_FULL_ACCELERATION_ARB 0x2027 + #define WGL_SWAP_EXCHANGE_ARB 0x2028 + #define WGL_SWAP_COPY_ARB 0x2029 + #define WGL_SWAP_UNDEFINED_ARB 0x202A + #define WGL_TYPE_RGBA_ARB 0x202B + #define WGL_TYPE_COLORINDEX_ARB 0x202C + + typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues); + typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues); + typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATARBPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); + + #define wglGetPixelFormatAttribivARB GLEGetCurrentFunction(wglGetPixelFormatAttribivARB) + #define wglGetPixelFormatAttribfvARB GLEGetCurrentFunction(wglGetPixelFormatAttribfvARB) + #define wglChoosePixelFormatARB GLEGetCurrentFunction(wglChoosePixelFormatARB) + + #define GLE_WGL_ARB_pixel_format GLEGetCurrentVariable(gle_WGL_ARB_pixel_format) + #endif + + + #ifndef WGL_ARB_make_current_read + #define WGL_ARB_make_current_read 1 + + #define ERROR_INVALID_PIXEL_TYPE_ARB 0x2043 + #define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054 + + typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTARBPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); + typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCARBPROC) (void); + + #define wglMakeContextCurrentARB GLEGetCurrentFunction(wglMakeContextCurrentARB) + #define wglGetCurrentReadDCARB GLEGetCurrentFunction(wglGetCurrentReadDCARB) + + #define GLE_WGL_ARB_make_current_read GLEGetCurrentVariable(gle_WGL_ARB_make_current_read) + #endif + + + #ifndef WGL_ARB_pbuffer + #define WGL_ARB_pbuffer 1 + + #define WGL_DRAW_TO_PBUFFER_ARB 0x202D + #define WGL_MAX_PBUFFER_PIXELS_ARB 0x202E + #define WGL_MAX_PBUFFER_WIDTH_ARB 0x202F + #define WGL_MAX_PBUFFER_HEIGHT_ARB 0x2030 + #define WGL_PBUFFER_LARGEST_ARB 0x2033 + #define WGL_PBUFFER_WIDTH_ARB 0x2034 + #define WGL_PBUFFER_HEIGHT_ARB 0x2035 + + typedef HPBUFFERARB (WINAPI * PFNWGLCREATEPBUFFERARBPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); + typedef HDC (WINAPI * PFNWGLGETPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer); + typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer, HDC hDC); + typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFERARBPROC) (HPBUFFERARB hPbuffer); + typedef BOOL (WINAPI * PFNWGLQUERYPBUFFERARBPROC) (HPBUFFERARB hPbuffer, int iAttribute, int *piValue); + + #define wglCreatePbufferARB GLEGetCurrentFunction(wglCreatePbufferARB) + #define wglGetPbufferDCARB GLEGetCurrentFunction(wglGetPbufferDCARB) + #define wglReleasePbufferDCARB GLEGetCurrentFunction(wglReleasePbufferDCARB) + #define wglDestroyPbufferARB GLEGetCurrentFunction(wglDestroyPbufferARB) + #define wglQueryPbufferARB GLEGetCurrentFunction(wglQueryPbufferARB) + + #define GLE_WGL_ARB_pbuffer GLEGetCurrentVariable(gle_WGL_ARB_pbuffer) + #endif + + + #ifndef WGL_ARB_render_texture + #define WGL_ARB_render_texture 1 + + #define WGL_BIND_TO_TEXTURE_RGB_ARB 0x2070 + #define WGL_BIND_TO_TEXTURE_RGBA_ARB 0x2071 + #define WGL_TEXTURE_FORMAT_ARB 0x2072 + #define WGL_TEXTURE_TARGET_ARB 0x2073 + #define WGL_MIPMAP_TEXTURE_ARB 0x2074 + #define WGL_TEXTURE_RGB_ARB 0x2075 + #define WGL_TEXTURE_RGBA_ARB 0x2076 + #define WGL_NO_TEXTURE_ARB 0x2077 + #define WGL_TEXTURE_CUBE_MAP_ARB 0x2078 + #define WGL_TEXTURE_1D_ARB 0x2079 + #define WGL_TEXTURE_2D_ARB 0x207A + #define WGL_MIPMAP_LEVEL_ARB 0x207B + #define WGL_CUBE_MAP_FACE_ARB 0x207C + #define WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x207D + #define WGL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x207E + #define WGL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x207F + #define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x2080 + #define WGL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x2081 + #define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x2082 + #define WGL_FRONT_LEFT_ARB 0x2083 + #define WGL_FRONT_RIGHT_ARB 0x2084 + #define WGL_BACK_LEFT_ARB 0x2085 + #define WGL_BACK_RIGHT_ARB 0x2086 + #define WGL_AUX0_ARB 0x2087 + #define WGL_AUX1_ARB 0x2088 + #define WGL_AUX2_ARB 0x2089 + #define WGL_AUX3_ARB 0x208A + #define WGL_AUX4_ARB 0x208B + #define WGL_AUX5_ARB 0x208C + #define WGL_AUX6_ARB 0x208D + #define WGL_AUX7_ARB 0x208E + #define WGL_AUX8_ARB 0x208F + #define WGL_AUX9_ARB 0x2090 + + typedef BOOL (WINAPI * PFNWGLBINDTEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer); + typedef BOOL (WINAPI * PFNWGLRELEASETEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer); + typedef BOOL (WINAPI * PFNWGLSETPBUFFERATTRIBARBPROC) (HPBUFFERARB hPbuffer, const int *piAttribList); + + #define wglBindTexImageARB GLEGetCurrentFunction(wglBindTexImageARB) + #define wglReleaseTexImageARB GLEGetCurrentFunction(wglReleaseTexImageARB) + #define wglSetPbufferAttribARB GLEGetCurrentFunction(wglSetPbufferAttribARB) + + #define GLE_WGL_ARB_render_texture GLEGetCurrentVariable(gle_WGL_ARB_render_texture) + #endif + + + #ifndef WGL_ARB_pixel_format_float + #define WGL_ARB_pixel_format_float 1 + + #define WGL_TYPE_RGBA_FLOAT_ARB 0x21A0 + + #define GLE_WGL_ARB_pixel_format_float GLEGetCurrentVariable(gle_WGL_ARB_pixel_format_float) + #endif + + + #ifndef WGL_ARB_framebuffer_sRGB + #define WGL_ARB_framebuffer_sRGB 1 + + // There is also the WGL_EXT_framebuffer_sRGB extension, which is the + // same as this. So use this one instead of that for checking. + #define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20A9 + + #define GLE_WGL_ARB_framebuffer_sRGB GLEGetCurrentVariable(gle_WGL_ARB_framebuffer_sRGB) + #endif + + + #ifndef WGL_NV_present_video + #define WGL_NV_present_video 1 + + DECLARE_HANDLE(HVIDEOOUTPUTDEVICENV); + + typedef int (WINAPI * PFNWGLENUMERATEVIDEODEVICESNVPROC) (HDC hDC, HVIDEOOUTPUTDEVICENV *phDeviceList); + typedef BOOL (WINAPI * PFNWGLBINDVIDEODEVICENVPROC) (HDC hDC, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int *piAttribList); + typedef BOOL (WINAPI * PFNWGLQUERYCURRENTCONTEXTNVPROC) (int iAttribute, int *piValue); + + #define wglEnumerateVideoDevicesNV GLEGetCurrentFunction(wglEnumerateVideoDevicesNV) + #define wglBindVideoDeviceNV GLEGetCurrentFunction(wglBindVideoDeviceNV) + #define wglQueryCurrentContextNV GLEGetCurrentFunction(wglQueryCurrentContextNV) + + #define GLE_WGL_NV_present_video GLEGetCurrentVariable(gle_WGL_NV_present_video) + #endif + + + #ifndef WGL_ARB_create_context + #define WGL_ARB_create_context 1 + + #define WGL_CONTEXT_DEBUG_BIT_ARB 0x00000001 + #define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002 + #define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091 + #define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092 + #define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093 + #define WGL_CONTEXT_FLAGS_ARB 0x2094 + #define ERROR_INVALID_VERSION_ARB 0x2095 + + typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC, HGLRC hShareContext, const int *attribList); + + #define wglCreateContextAttribsARB GLEGetCurrentFunction(wglCreateContextAttribsARB) + + #define GLE_WGL_ARB_create_context GLEGetCurrentVariable(gle_WGL_ARB_create_context) + #endif + + + #ifndef WGL_ARB_create_context_profile + #define WGL_ARB_create_context_profile 1 + + #define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126 + #define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 + #define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002 + #define ERROR_INVALID_PROFILE_ARB 0x2096 + + #define GLE_WGL_ARB_create_context_profile GLEGetCurrentVariable(gle_WGL_ARB_create_context_profile) + #endif + + + #ifndef WGL_ARB_create_context_robustness + #define WGL_ARB_create_context_robustness 1 + + #define WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004 + #define WGL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 + #define WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 + #define WGL_NO_RESET_NOTIFICATION_ARB 0x8261 + + #define GLE_WGL_ARB_create_context_robustness GLEGetCurrentVariable(gle_WGL_ARB_create_context_robustness) + #endif + + + + #ifndef WGL_ATI_render_texture_rectangle + #define WGL_ATI_render_texture_rectangle 1 + + #define WGL_TEXTURE_RECTANGLE_ATI 0x21A5 + + #define GLE_WGL_ATI_render_texture_rectangle GLEGetCurrentVariable(gle_WGL_ATI_render_texture_rectangle) + #endif + + + #ifndef WGL_EXT_extensions_string + #define WGL_EXT_extensions_string 1 + + typedef const char * (WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC) (void); + + #define wglGetExtensionsStringEXT GLEGetCurrentFunction(wglGetExtensionsStringEXT) + + #define GLE_WGL_EXT_extensions_string GLEGetCurrentVariable(gle_WGL_EXT_extensions_string) + #endif + + + #ifndef WGL_NV_render_texture_rectangle + #define WGL_NV_render_texture_rectangle 1 + + #define WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV 0x20A0 + #define WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV 0x20A1 + #define WGL_TEXTURE_RECTANGLE_NV 0x20A2 + + #define GLE_WGL_NV_render_texture_rectangle GLEGetCurrentVariable(gle_WGL_NV_render_texture_rectangle) + #endif + + + #ifndef WGL_EXT_swap_control + #define WGL_EXT_swap_control 1 + + typedef int (WINAPI * PFNWGLGETSWAPINTERVALEXTPROC) (void); + typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC) (int interval); + + #define wglGetSwapIntervalEXT GLEGetCurrentFunction(wglGetSwapIntervalEXT) + #define wglSwapIntervalEXT GLEGetCurrentFunction(wglSwapIntervalEXT) + + #define GLE_WGL_EXT_swap_control GLEGetCurrentVariable(gle_WGL_EXT_swap_control) + #endif + + + #ifndef WGL_OML_sync_control + #define WGL_OML_sync_control 1 + + typedef BOOL (WINAPI * PFNWGLGETSYNCVALUESOMLPROC) (HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc); + typedef BOOL (WINAPI * PFNWGLGETMSCRATEOMLPROC) (HDC hdc, INT32 *numerator, INT32 *denominator); + typedef INT64 (WINAPI * PFNWGLSWAPBUFFERSMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder); + typedef INT64 (WINAPI * PFNWGLSWAPLAYERBUFFERSMSCOMLPROC) (HDC hdc, int fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder); + typedef BOOL (WINAPI * PFNWGLWAITFORMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc); + typedef BOOL (WINAPI * PFNWGLWAITFORSBCOMLPROC) (HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc); + + #define wglGetSyncValuesOML GLEGetCurrentFunction(wglGetSyncValuesOML) + #define wglGetMscRateOML GLEGetCurrentFunction(wglGetMscRateOML) + #define wglSwapBuffersMscOML GLEGetCurrentFunction(wglSwapBuffersMscOML) + #define wglSwapLayerBuffersMscOML GLEGetCurrentFunction(wglSwapLayerBuffersMscOML) + #define wglWaitForMscOML GLEGetCurrentFunction(wglWaitForMscOML) + #define wglWaitForSbcOML GLEGetCurrentFunction(wglWaitForSbcOML) + + #define GLE_WGL_OML_sync_control GLEGetCurrentVariable(gle_WGL_OML_sync_control) + #endif + + + #ifndef WGL_NV_video_output + #define WGL_NV_video_output 1 + + DECLARE_HANDLE(HPVIDEODEV); + + typedef BOOL (WINAPI * PFNWGLGETVIDEODEVICENVPROC) (HDC hDC, int numDevices, HPVIDEODEV *hVideoDevice); + typedef BOOL (WINAPI * PFNWGLRELEASEVIDEODEVICENVPROC) (HPVIDEODEV hVideoDevice); + typedef BOOL (WINAPI * PFNWGLBINDVIDEOIMAGENVPROC) (HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer); + typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOIMAGENVPROC) (HPBUFFERARB hPbuffer, int iVideoBuffer); + typedef BOOL (WINAPI * PFNWGLSENDPBUFFERTOVIDEONVPROC) (HPBUFFERARB hPbuffer, int iBufferType, unsigned long *pulCounterPbuffer, BOOL bBlock); + typedef BOOL (WINAPI * PFNWGLGETVIDEOINFONVPROC) (HPVIDEODEV hpVideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo); + + #define wglGetVideoDeviceNV GLEGetCurrentFunction(wglGetVideoDeviceNV) + #define wglReleaseVideoDeviceNV GLEGetCurrentFunction(wglReleaseVideoDeviceNV) + #define wglBindVideoImageNV GLEGetCurrentFunction(wglBindVideoImageNV) + #define wglReleaseVideoImageNV GLEGetCurrentFunction(wglReleaseVideoImageNV) + #define wglSendPbufferToVideoNV GLEGetCurrentFunction(wglSendPbufferToVideoNV) + #define wglGetVideoInfoNV GLEGetCurrentFunction(wglGetVideoInfoNV) + + #define GLE_WGL_NV_video_output GLEGetCurrentVariable(gle_WGL_NV_video_output) + #endif + + + #ifndef WGL_NV_swap_group + #define WGL_NV_swap_group 1 + + typedef BOOL (WINAPI * PFNWGLJOINSWAPGROUPNVPROC) (HDC hDC, GLuint group); + typedef BOOL (WINAPI * PFNWGLBINDSWAPBARRIERNVPROC) (GLuint group, GLuint barrier); + typedef BOOL (WINAPI * PFNWGLQUERYSWAPGROUPNVPROC) (HDC hDC, GLuint *group, GLuint *barrier); + typedef BOOL (WINAPI * PFNWGLQUERYMAXSWAPGROUPSNVPROC) (HDC hDC, GLuint *maxGroups, GLuint *maxBarriers); + typedef BOOL (WINAPI * PFNWGLQUERYFRAMECOUNTNVPROC) (HDC hDC, GLuint *count); + typedef BOOL (WINAPI * PFNWGLRESETFRAMECOUNTNVPROC) (HDC hDC); + + #define wglJoinSwapGroupNV GLEGetCurrentFunction(wglJoinSwapGroupNV) + #define wglBindSwapBarrierNV GLEGetCurrentFunction(wglBindSwapBarrierNV) + #define wglQuerySwapGroupNV GLEGetCurrentFunction(wglQuerySwapGroupNV) + #define wglQueryMaxSwapGroupsNV GLEGetCurrentFunction(wglQueryMaxSwapGroupsNV) + #define wglQueryFrameCountNV GLEGetCurrentFunction(wglQueryFrameCountNV) + #define wglResetFrameCountNV GLEGetCurrentFunction(wglResetFrameCountNV) + + #define GLE_WGL_NV_swap_group GLEGetCurrentVariable(gle_WGL_NV_swap_group) + #endif + + + #ifndef WGL_NV_video_capture + #define WGL_NV_video_capture 1 + + #define WGL_UNIQUE_ID_NV 0x20CE + #define WGL_NUM_VIDEO_CAPTURE_SLOTS_NV 0x20CF + + typedef struct _GPU_DEVICE { + DWORD cb; + CHAR DeviceName[32]; + CHAR DeviceString[128]; + DWORD Flags; + RECT rcVirtualScreen; + } GPU_DEVICE, *PGPU_DEVICE; + DECLARE_HANDLE(HVIDEOINPUTDEVICENV); + + typedef BOOL (WINAPI * PFNWGLBINDVIDEOCAPTUREDEVICENVPROC) (UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice); + typedef UINT (WINAPI * PFNWGLENUMERATEVIDEOCAPTUREDEVICESNVPROC) (HDC hDc, HVIDEOINPUTDEVICENV *phDeviceList); + typedef BOOL (WINAPI * PFNWGLLOCKVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice); + typedef BOOL (WINAPI * PFNWGLQUERYVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int *piValue); + typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice); + + #define wglBindVideoCaptureDeviceNV GLEGetCurrentFunction(wglBindVideoCaptureDeviceNV) + #define wglEnumerateVideoCaptureDevicesNV GLEGetCurrentFunction(wglEnumerateVideoCaptureDevicesNV) + #define wglLockVideoCaptureDeviceNV GLEGetCurrentFunction(wglLockVideoCaptureDeviceNV) + #define wglQueryVideoCaptureDeviceNV GLEGetCurrentFunction(wglQueryVideoCaptureDeviceNV) + #define wglReleaseVideoCaptureDeviceNV GLEGetCurrentFunction(wglReleaseVideoCaptureDeviceNV) + + #define GLE_WGL_NV_video_capture GLEGetCurrentVariable(gle_WGL_NV_video_capture) + #endif + + + #ifndef WGL_NV_copy_image + #define WGL_NV_copy_image 1 + + typedef BOOL (WINAPI * PFNWGLCOPYIMAGESUBDATANVPROC) (HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); + + #define wglCopyImageSubDataNV GLEGetCurrentFunction(wglCopyImageSubDataNV) + + #define GLE_WGL_NV_copy_image GLEGetCurrentVariable(gle_WGL_NV_copy_image) + #endif + + + #ifndef WGL_NV_DX_interop + #define WGL_NV_DX_interop 1 + + // Note that modern AMD drivers support this NVidia extension. + #define WGL_ACCESS_READ_ONLY_NV 0x0000 + #define WGL_ACCESS_READ_WRITE_NV 0x0001 + #define WGL_ACCESS_WRITE_DISCARD_NV 0x0002 + + typedef BOOL (WINAPI * PFNWGLDXCLOSEDEVICENVPROC) (HANDLE hDevice); + typedef BOOL (WINAPI * PFNWGLDXLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE* hObjects); + typedef BOOL (WINAPI * PFNWGLDXOBJECTACCESSNVPROC) (HANDLE hObject, GLenum access); + typedef HANDLE (WINAPI * PFNWGLDXOPENDEVICENVPROC) (void* dxDevice); + typedef HANDLE (WINAPI * PFNWGLDXREGISTEROBJECTNVPROC) (HANDLE hDevice, void* dxObject, GLuint name, GLenum type, GLenum access); + typedef BOOL (WINAPI * PFNWGLDXSETRESOURCESHAREHANDLENVPROC) (void* dxObject, HANDLE shareHandle); + typedef BOOL (WINAPI * PFNWGLDXUNLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE* hObjects); + typedef BOOL (WINAPI * PFNWGLDXUNREGISTEROBJECTNVPROC) (HANDLE hDevice, HANDLE hObject); + + #define wglDXCloseDeviceNV GLEGetCurrentFunction(wglDXCloseDeviceNV) + #define wglDXLockObjectsNV GLEGetCurrentFunction(wglDXLockObjectsNV) + #define wglDXObjectAccessNV GLEGetCurrentFunction(wglDXObjectAccessNV) + #define wglDXOpenDeviceNV GLEGetCurrentFunction(wglDXOpenDeviceNV) + #define wglDXRegisterObjectNV GLEGetCurrentFunction(wglDXRegisterObjectNV) + #define wglDXSetResourceShareHandleNV GLEGetCurrentFunction(wglDXSetResourceShareHandleNV) + #define wglDXUnlockObjectsNV GLEGetCurrentFunction(wglDXUnlockObjectsNV) + #define wglDXUnregisterObjectNV GLEGetCurrentFunction(wglDXUnregisterObjectNV) + + #define GLE_WGL_NV_DX_interop GLEGetCurrentVariable(gle_WGL_NV_DX_interop) + #endif + + + #ifndef WGL_NV_DX_interop2 + #define WGL_NV_DX_interop2 1 + + // This is an update to WGL_NV_DX_interop to support DX10/DX11. + // https://www.opengl.org/registry/specs/NV/DX_interop2.txt + #define GLE_WGL_NV_DX_interop2 GLEGetCurrentVariable(gle_WGL_NV_DX_interop2) + + #endif + +#endif // GLE_WGL_ENABLED + + + +/************************************************************************************ + Apple-specific (CGL) functionality +************************************************************************************/ + +#if defined(GLE_CGL_ENABLED) + // We don't currently disable Apple's OpenGL/OpenGL.h and replicate its declarations here. + // We might want to do that if we intended to support hooking its functions here like we do for wgl functions. + #include +#endif + + + +/************************************************************************************ + Unix-specific (GLX) functionality +************************************************************************************/ + +#if defined(GLE_GLX_ENABLED) + #ifdef __glxext_h_ + #error glxext.h was included before this header. This header needs to be inlcuded instead of or at least before glxext.h + #endif + #define __glxext_h_ + + #if defined(GLX_H) || defined(__GLX_glx_h__) || defined(__glx_h__) + #error glx.h was included before this header. This header needs to be inlcuded instead of or at least before glx.h + #endif + #define GLX_H + #define __GLX_glx_h__ + #define __glx_h__ + + #include + #include + #include + + // GLX version 1.0 functions are assumed to always be present. + #ifndef GLX_VERSION_1_0 + #define GLX_VERSION_1_0 1 + + #define GLX_USE_GL 1 + #define GLX_BUFFER_SIZE 2 + #define GLX_LEVEL 3 + #define GLX_RGBA 4 + #define GLX_DOUBLEBUFFER 5 + #define GLX_STEREO 6 + #define GLX_AUX_BUFFERS 7 + #define GLX_RED_SIZE 8 + #define GLX_GREEN_SIZE 9 + #define GLX_BLUE_SIZE 10 + #define GLX_ALPHA_SIZE 11 + #define GLX_DEPTH_SIZE 12 + #define GLX_STENCIL_SIZE 13 + #define GLX_ACCUM_RED_SIZE 14 + #define GLX_ACCUM_GREEN_SIZE 15 + #define GLX_ACCUM_BLUE_SIZE 16 + #define GLX_ACCUM_ALPHA_SIZE 17 + #define GLX_BAD_SCREEN 1 + #define GLX_BAD_ATTRIBUTE 2 + #define GLX_NO_EXTENSION 3 + #define GLX_BAD_VISUAL 4 + #define GLX_BAD_CONTEXT 5 + #define GLX_BAD_VALUE 6 + #define GLX_BAD_ENUM 7 + + typedef XID GLXDrawable; + typedef XID GLXPixmap; + typedef unsigned int GLXVideoDeviceNV; + typedef struct __GLXcontextRec *GLXContext; + + // GLE_HOOKING_ENABLED + // We don't currently support hooking the following GLX 1.0 functions like we do with the analagous windows wgl functions. + // However, we can do this if needed. We would just have something like this: + // #define glXQueryExtension(...) GLEGetCurrentFunction(glXQueryExtension)(__VA_ARGS__) + // plus a member function like: + // Bool glXQueryExtension_Hook(Display*, int*, int*); + // See wglCopyContext for an example. + + extern Bool glXQueryExtension (Display *dpy, int *errorBase, int *eventBase); + extern Bool glXQueryVersion (Display *dpy, int *major, int *minor); + extern int glXGetConfig (Display *dpy, XVisualInfo *vis, int attrib, int *value); + extern XVisualInfo* glXChooseVisual (Display *dpy, int screen, int *attribList); + extern GLXPixmap glXCreateGLXPixmap (Display *dpy, XVisualInfo *vis, Pixmap pixmap); + extern void glXDestroyGLXPixmap (Display *dpy, GLXPixmap pix); + extern GLXContext glXCreateContext (Display *dpy, XVisualInfo *vis, GLXContext shareList, Bool direct); + extern void glXDestroyContext (Display *dpy, GLXContext ctx); + extern Bool glXIsDirect (Display *dpy, GLXContext ctx); + extern void glXCopyContext (Display *dpy, GLXContext src, GLXContext dst, GLulong mask); + extern Bool glXMakeCurrent (Display *dpy, GLXDrawable drawable, GLXContext ctx); + extern GLXContext glXGetCurrentContext (void); + extern GLXDrawable glXGetCurrentDrawable (void); + extern void glXWaitGL (void); + extern void glXWaitX (void); + extern void glXSwapBuffers (Display *dpy, GLXDrawable drawable); + extern void glXUseXFont (Font font, int first, int count, int listBase); + + #endif // GLX_VERSION_1_0 + + + + #ifndef GLX_VERSION_1_1 + #define GLX_VERSION_1_1 + + #define GLX_VENDOR 0x1 + #define GLX_VERSION 0x2 + #define GLX_EXTENSIONS 0x3 + + // These function pointers are assumed to always be present. + extern const char* glXQueryExtensionsString (Display *dpy, int screen); + extern const char* glXGetClientString (Display *dpy, int name); + extern const char* glXQueryServerString (Display *dpy, int screen, int name); + #endif + + + #ifndef GLX_VERSION_1_2 + #define GLX_VERSION_1_2 1 + + typedef Display* (* PFNGLXGETCURRENTDISPLAYPROC) (void); + + #define glXGetCurrentDisplay GLEGetCurrentFunction(glXGetCurrentDisplay) + #endif + + + + #ifndef GLX_VERSION_1_3 + #define GLX_VERSION_1_3 1 + + #define GLX_FRONT_LEFT_BUFFER_BIT 0x00000001 + #define GLX_RGBA_BIT 0x00000001 + #define GLX_WINDOW_BIT 0x00000001 + #define GLX_COLOR_INDEX_BIT 0x00000002 + #define GLX_FRONT_RIGHT_BUFFER_BIT 0x00000002 + #define GLX_PIXMAP_BIT 0x00000002 + #define GLX_BACK_LEFT_BUFFER_BIT 0x00000004 + #define GLX_PBUFFER_BIT 0x00000004 + #define GLX_BACK_RIGHT_BUFFER_BIT 0x00000008 + #define GLX_AUX_BUFFERS_BIT 0x00000010 + #define GLX_CONFIG_CAVEAT 0x20 + #define GLX_DEPTH_BUFFER_BIT 0x00000020 + #define GLX_X_VISUAL_TYPE 0x22 + #define GLX_TRANSPARENT_TYPE 0x23 + #define GLX_TRANSPARENT_INDEX_VALUE 0x24 + #define GLX_TRANSPARENT_RED_VALUE 0x25 + #define GLX_TRANSPARENT_GREEN_VALUE 0x26 + #define GLX_TRANSPARENT_BLUE_VALUE 0x27 + #define GLX_TRANSPARENT_ALPHA_VALUE 0x28 + #define GLX_STENCIL_BUFFER_BIT 0x00000040 + #define GLX_ACCUM_BUFFER_BIT 0x00000080 + #define GLX_NONE 0x8000 + #define GLX_SLOW_CONFIG 0x8001 + #define GLX_TRUE_COLOR 0x8002 + #define GLX_DIRECT_COLOR 0x8003 + #define GLX_PSEUDO_COLOR 0x8004 + #define GLX_STATIC_COLOR 0x8005 + #define GLX_GRAY_SCALE 0x8006 + #define GLX_STATIC_GRAY 0x8007 + #define GLX_TRANSPARENT_RGB 0x8008 + #define GLX_TRANSPARENT_INDEX 0x8009 + #define GLX_VISUAL_ID 0x800B + #define GLX_SCREEN 0x800C + #define GLX_NON_CONFORMANT_CONFIG 0x800D + #define GLX_DRAWABLE_TYPE 0x8010 + #define GLX_RENDER_TYPE 0x8011 + #define GLX_X_RENDERABLE 0x8012 + #define GLX_FBCONFIG_ID 0x8013 + #define GLX_RGBA_TYPE 0x8014 + #define GLX_COLOR_INDEX_TYPE 0x8015 + #define GLX_MAX_PBUFFER_WIDTH 0x8016 + #define GLX_MAX_PBUFFER_HEIGHT 0x8017 + #define GLX_MAX_PBUFFER_PIXELS 0x8018 + #define GLX_PRESERVED_CONTENTS 0x801B + #define GLX_LARGEST_PBUFFER 0x801C + #define GLX_WIDTH 0x801D + #define GLX_HEIGHT 0x801E + #define GLX_EVENT_MASK 0x801F + #define GLX_DAMAGED 0x8020 + #define GLX_SAVED 0x8021 + #define GLX_WINDOW 0x8022 + #define GLX_PBUFFER 0x8023 + #define GLX_PBUFFER_HEIGHT 0x8040 + #define GLX_PBUFFER_WIDTH 0x8041 + #define GLX_PBUFFER_CLOBBER_MASK 0x08000000 + #define GLX_DONT_CARE 0xFFFFFFFF + + typedef XID GLXFBConfigID; + typedef XID GLXPbuffer; + typedef XID GLXWindow; + typedef struct __GLXFBConfigRec *GLXFBConfig; + + typedef struct { + int event_type; + int draw_type; + unsigned long serial; + Bool send_event; + Display *display; + GLXDrawable drawable; + unsigned int buffer_mask; + unsigned int aux_buffer; + int x, y; + int width, height; + int count; + } GLXPbufferClobberEvent; + + typedef union __GLXEvent { + GLXPbufferClobberEvent glxpbufferclobber; + long pad[24]; + } GLXEvent; + + typedef GLXFBConfig* (* PFNGLXCHOOSEFBCONFIGPROC) (::Display *dpy, int screen, const int *attrib_list, int *nelements); + typedef GLXContext (* PFNGLXCREATENEWCONTEXTPROC) (::Display *dpy, GLXFBConfig config, int render_type, GLXContext share_list, Bool direct); + typedef GLXPbuffer (* PFNGLXCREATEPBUFFERPROC) (::Display *dpy, GLXFBConfig config, const int *attrib_list); + typedef GLXPixmap (* PFNGLXCREATEPIXMAPPROC) (::Display *dpy, GLXFBConfig config, Pixmap pixmap, const int *attrib_list); + typedef GLXWindow (* PFNGLXCREATEWINDOWPROC) (::Display *dpy, GLXFBConfig config, Window win, const int *attrib_list); + typedef void (* PFNGLXDESTROYPBUFFERPROC) (::Display *dpy, GLXPbuffer pbuf); + typedef void (* PFNGLXDESTROYPIXMAPPROC) (::Display *dpy, GLXPixmap pixmap); + typedef void (* PFNGLXDESTROYWINDOWPROC) (::Display *dpy, GLXWindow win); + typedef GLXDrawable (* PFNGLXGETCURRENTREADDRAWABLEPROC) (void); + typedef int (* PFNGLXGETFBCONFIGATTRIBPROC) (::Display *dpy, GLXFBConfig config, int attribute, int *value); + typedef GLXFBConfig* (* PFNGLXGETFBCONFIGSPROC) (::Display *dpy, int screen, int *nelements); + typedef void (* PFNGLXGETSELECTEDEVENTPROC) (::Display *dpy, GLXDrawable draw, unsigned long *event_mask); + typedef XVisualInfo* (* PFNGLXGETVISUALFROMFBCONFIGPROC) (::Display *dpy, GLXFBConfig config); + typedef Bool (* PFNGLXMAKECONTEXTCURRENTPROC) (::Display *display, GLXDrawable draw, GLXDrawable read, GLXContext ctx); + typedef int (* PFNGLXQUERYCONTEXTPROC) (::Display *dpy, GLXContext ctx, int attribute, int *value); + typedef void (* PFNGLXQUERYDRAWABLEPROC) (::Display *dpy, GLXDrawable draw, int attribute, unsigned int *value); + typedef void (* PFNGLXSELECTEVENTPROC) (::Display *dpy, GLXDrawable draw, unsigned long event_mask); + + #define glXChooseFBConfig GLEGetCurrentFunction(glXChooseFBConfig) + #define glXCreateNewContext GLEGetCurrentFunction(glXCreateNewContext) + #define glXCreatePbuffer GLEGetCurrentFunction(glXCreatePbuffer) + #define glXCreatePixmap GLEGetCurrentFunction(glXCreatePixmap) + #define glXCreateWindow GLEGetCurrentFunction(glXCreateWindow) + #define glXDestroyPbuffer GLEGetCurrentFunction(glXDestroyPbuffer) + #define glXDestroyPixmap GLEGetCurrentFunction(glXDestroyPixmap) + #define glXDestroyWindow GLEGetCurrentFunction(glXDestroyWindow) + #define glXGetCurrentReadDrawable GLEGetCurrentFunction(glXGetCurrentReadDrawable) + #define glXGetFBConfigAttrib GLEGetCurrentFunction(glXGetFBConfigAttrib) + #define glXGetFBConfigs GLEGetCurrentFunction(glXGetFBConfigs) + #define glXGetSelectedEvent GLEGetCurrentFunction(glXGetSelectedEvent) + #define glXGetVisualFromFBConfig GLEGetCurrentFunction(glXGetVisualFromFBConfig) + #define glXMakeContextCurrent GLEGetCurrentFunction(glXMakeContextCurrent) + #define glXQueryContext GLEGetCurrentFunction(glXQueryContext) + #define glXQueryDrawable GLEGetCurrentFunction(glXQueryDrawable) + #define glXSelectEvent GLEGetCurrentFunction(glXSelectEvent) + + #endif // GLX_VERSION_1_3 + + + + #ifndef GLX_VERSION_1_4 + #define GLX_VERSION_1_4 1 + + #define GLX_SAMPLE_BUFFERS 100000 + #define GLX_SAMPLES 100001 + + // This was glXGetProcAddressARB in GLX versions prior to v1.4. + // This function pointer is assumed to always be present. + extern void (* glXGetProcAddress(const GLubyte *procName)) (); + + // For backward compatibility + extern void (* glXGetProcAddressARB(const GLubyte *procName)) (); + #endif + + + + #ifndef GLX_ARB_create_context + #define GLX_ARB_create_context 1 + + #define GLX_CONTEXT_DEBUG_BIT_ARB 0x0001 + #define GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x0002 + #define GLX_CONTEXT_MAJOR_VERSION_ARB 0x2091 + #define GLX_CONTEXT_MINOR_VERSION_ARB 0x2092 + #define GLX_CONTEXT_FLAGS_ARB 0x2094 + + typedef GLXContext (* PFNGLXCREATECONTEXTATTRIBSARBPROC) (Display* dpy, GLXFBConfig config, GLXContext share_context, Bool direct, const int *attrib_list); + + #define glXCreateContextAttribsARB GLEGetCurrentFunction(glXCreateContextAttribsARB) + + #define GLE_GLX_ARB_create_context GLEGetCurrentVariable(gle_GLX_ARB_create_context) + #endif + + + #ifndef GLX_ARB_create_context_profile + #define GLX_ARB_create_context_profile 1 + + #define GLX_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 + #define GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002 + #define GLX_CONTEXT_PROFILE_MASK_ARB 0x9126 + + #define GLE_GLX_ARB_create_context_profile GLEGetCurrentVariable(gle_GLX_ARB_create_context_profile) + #endif + + + #ifndef GLX_ARB_create_context_robustness + #define GLX_ARB_create_context_robustness 1 + + #define GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004 + #define GLX_LOSE_CONTEXT_ON_RESET_ARB 0x8252 + #define GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 + #define GLX_NO_RESET_NOTIFICATION_ARB 0x8261 + + #define GLE_GLX_ARB_create_context_robustness GLEGetCurrentVariable(gle_GLX_ARB_create_context_robustness) + #endif + + + // Note: In order to detect the GLX extensions' availability, we need to call glXQueryExtensionsString instead of glGetString(GL_EXTENSIONS). + #ifndef GLX_EXT_swap_control + #define GLX_EXT_swap_control 1 + + #define GLX_SWAP_INTERVAL_EXT 0x20F1 + #define GLX_MAX_SWAP_INTERVAL_EXT 0x20F2 + + typedef void (* PFNGLXSWAPINTERVALEXTPROC) (Display* dpy, GLXDrawable drawable, int interval); + + #define glXSwapIntervalEXT GLEGetCurrentFunction(glXSwapIntervalEXT) + + #define GLE_GLX_EXT_swap_control GLEGetCurrentVariable(gle_GLX_EXT_swap_control) + #endif + + + #ifndef GLX_OML_sync_control + #define GLX_OML_sync_control 1 + + typedef Bool (* PFNGLXGETMSCRATEOMLPROC) (Display* dpy, GLXDrawable drawable, int32_t* numerator, int32_t* denominator); + typedef Bool (* PFNGLXGETSYNCVALUESOMLPROC) (Display* dpy, GLXDrawable drawable, int64_t* ust, int64_t* msc, int64_t* sbc); + typedef int64_t (* PFNGLXSWAPBUFFERSMSCOMLPROC) (Display* dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder); + typedef Bool (* PFNGLXWAITFORMSCOMLPROC) (Display* dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder, int64_t* ust, int64_t* msc, int64_t* sbc); + typedef Bool (* PFNGLXWAITFORSBCOMLPROC) (Display* dpy, GLXDrawable drawable, int64_t target_sbc, int64_t* ust, int64_t* msc, int64_t* sbc); + + #define glXGetMscRateOML GLEGetCurrentFunction(glXGetMscRateOML) + #define glXGetSyncValuesOML GLEGetCurrentFunction(glXGetSyncValuesOML) + #define glXSwapBuffersMscOML GLEGetCurrentFunction(glXSwapBuffersMscOML) + #define glXWaitForMscOML GLEGetCurrentFunction(glXWaitForMscOML) + #define glXWaitForSbcOML GLEGetCurrentFunction(glXWaitForSbcOML) + + #define GLE_GLX_OML_sync_control GLEGetCurrentVariable(gle_GLX_OML_sync_control) + #endif + + + #ifndef GLX_MESA_swap_control + #define GLX_MESA_swap_control 1 + + // GLX_MESA_swap_control has the same functionality as GLX_EXT_swap_control but with a different interface, so we have an independent entry for it here. + typedef int (* PFNGLXGETSWAPINTERVALMESAPROC) (void); + typedef int (* PFNGLXSWAPINTERVALMESAPROC) (unsigned int interval); + + #define glXGetSwapIntervalMESA GLEGetCurrentFunction(glXGetSwapIntervalMESA) + #define glXSwapIntervalMESA GLEGetCurrentFunction(glXSwapIntervalMESA) + + #define GLE_MESA_swap_control GLEGetCurrentVariable(gle_MESA_swap_control) + #endif + +#endif // GLE_GLX_ENABLED + + +// Undo some defines, because the user may include after including this header. +#if defined(GLE_WINGDIAPI_DEFINED) + #undef WINGDIAPI +#endif + + +#ifdef __cplusplus +} // extern "C" +#endif + + + +#endif // Header include guard + + + + + diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/CAPI/GL/CAPI_GL_DistortionRenderer.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/CAPI/GL/CAPI_GL_DistortionRenderer.cpp Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,1011 @@ +/************************************************************************************ + +Filename : CAPI_GL_DistortionRenderer.h +Content : Distortion renderer header for GL +Created : November 11, 2013 +Authors : David Borel, Lee Cooper + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#include "CAPI_GL_DistortionRenderer.h" + +#include "CAPI_GL_DistortionShaders.h" + +#include "../../OVR_CAPI_GL.h" +#include "../../Kernel/OVR_Color.h" + +#if defined(OVR_OS_LINUX) + #include "../../Displays/OVR_Linux_SDKWindow.h" +#elif defined(OVR_OS_MAC) + #include + #include +#endif + +namespace OVR { namespace CAPI { namespace GL { + + +// Distortion pixel shader lookup. +// Bit 0: Chroma Correction +// Bit 1: Timewarp + +enum { + DistortionVertexShaderBitMask = 3, + DistortionVertexShaderCount = DistortionVertexShaderBitMask + 1, + DistortionPixelShaderBitMask = 1, + DistortionPixelShaderCount = DistortionPixelShaderBitMask + 1 +}; + +struct ShaderInfo +{ + const char* ShaderData; + size_t ShaderSize; + const ShaderBase::Uniform* ReflectionData; + size_t ReflectionSize; +}; + +// Do add a new distortion shader use these macros (with or w/o reflection) +#define SI_NOREFL(shader) { shader, sizeof(shader), NULL, 0 } +#define SI_REFL__(shader) { shader, sizeof(shader), shader ## _refl, sizeof( shader ## _refl )/sizeof(*(shader ## _refl)) } + + +static ShaderInfo DistortionVertexShaderLookup[DistortionVertexShaderCount] = +{ + SI_REFL__(Distortion_vs), + SI_REFL__(DistortionChroma_vs), + SI_REFL__(DistortionTimewarp_vs), + SI_REFL__(DistortionTimewarpChroma_vs) +}; + +static ShaderInfo DistortionPixelShaderLookup[DistortionPixelShaderCount] = +{ + SI_NOREFL(Distortion_fs), + SI_NOREFL(DistortionChroma_fs) +}; + +void DistortionShaderBitIndexCheck() +{ + OVR_COMPILER_ASSERT(ovrDistortionCap_Chromatic == 1); + OVR_COMPILER_ASSERT(ovrDistortionCap_TimeWarp == 2); +} + + + +struct DistortionVertex +{ + Vector2f ScreenPosNDC; + Vector2f TanEyeAnglesR; + Vector2f TanEyeAnglesG; + Vector2f TanEyeAnglesB; + Color Col; +}; + + +// Vertex type; same format is used for all shapes for simplicity. +// Shapes are built by adding vertices to Model. +struct LatencyVertex +{ + Vector3f Pos; + LatencyVertex (const Vector3f& p) : Pos(p) {} +}; + + +//---------------------------------------------------------------------------- +// ***** GL::DistortionRenderer + +DistortionRenderer::DistortionRenderer(ovrHmd hmd, FrameTimeManager& timeManager, + const HMDRenderState& renderState) + : CAPI::DistortionRenderer(ovrRenderAPI_OpenGL, hmd, timeManager, renderState) + , RotateCCW90(false) + , LatencyVAO(0) + , OverdriveFbo(0) +{ + DistortionMeshVAOs[0] = 0; + DistortionMeshVAOs[1] = 0; + + // Initialize render params. + memset(&RParams, 0, sizeof(RParams)); +} + +DistortionRenderer::~DistortionRenderer() +{ + destroy(); +} + +// static +CAPI::DistortionRenderer* DistortionRenderer::Create(ovrHmd hmd, + FrameTimeManager& timeManager, + const HMDRenderState& renderState) +{ + InitGLExtensions(); + + return new DistortionRenderer(hmd, timeManager, renderState); +} + + +bool DistortionRenderer::Initialize(const ovrRenderAPIConfig* apiConfig) +{ + const ovrGLConfig* config = (const ovrGLConfig*)apiConfig; + + if (!config) + { + // Cleanup + pEyeTextures[0].Clear(); + pEyeTextures[1].Clear(); + memset(&RParams, 0, sizeof(RParams)); + return true; + } + + RParams.Multisample = config->OGL.Header.Multisample; + RParams.BackBufferSize = config->OGL.Header.BackBufferSize; +#if defined(OVR_OS_WIN32) + RParams.Window = (config->OGL.Window) ? config->OGL.Window : GetActiveWindow(); + RParams.DC = config->OGL.DC; +#elif defined(OVR_OS_LINUX) + RotateCCW90 = false; + if ( RState.DistortionCaps & ovrDistortionCap_LinuxDevFullscreen + && SDKWindow::getRotation(HMD) == DistRotateCCW90) + { + RotateCCW90 = true; + } + if (config->OGL.Disp) + { + RParams.Disp = config->OGL.Disp; + } + if (!RParams.Disp) + { + RParams.Disp = glXGetCurrentDisplay(); + } + if (!RParams.Disp) + { + OVR_DEBUG_LOG(("glXGetCurrentDisplay failed.")); + return false; + } +#endif + + DistortionMeshVAOs[0] = 0; + DistortionMeshVAOs[1] = 0; + + LatencyVAO = 0; + + GL::AutoContext autoGLContext(distortionContext); // Initializes distortionContext if not already, saves the current GL context, binds distortionContext, then at the end of scope re-binds the current GL context. + + pEyeTextures[0] = *new Texture(&RParams, 0, 0); + pEyeTextures[1] = *new Texture(&RParams, 0, 0); + + initBuffersAndShaders(); + + initOverdrive(); + + return true; +} + + +void DistortionRenderer::initOverdrive() +{ + if(RState.DistortionCaps & ovrDistortionCap_Overdrive) + { + LastUsedOverdriveTextureIndex = 0; + + glGenFramebuffers(1, &OverdriveFbo); + + GLint internalFormat = (RState.DistortionCaps & ovrDistortionCap_SRGB) ? GL_SRGB_ALPHA : GL_RGBA; + + for (int i = 0; i < NumOverdriveTextures ; i++) + { + pOverdriveTextures[i] = *new Texture(&RParams, RParams.BackBufferSize.w, RParams.BackBufferSize.h); + + glBindTexture(GL_TEXTURE_2D, pOverdriveTextures[i]->TexId); + glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, RParams.BackBufferSize.w, RParams.BackBufferSize.h, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); + OVR_ASSERT( glGetError() == GL_NO_ERROR ); + + pOverdriveTextures[i]->SetSampleMode(Sample_ClampBorder | Sample_Linear); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0); + OVR_ASSERT(glGetError() == 0); + + // clear the new buffer + glBindFramebuffer(GL_FRAMEBUFFER, OverdriveFbo ); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, pOverdriveTextures[i]->TexId, 0); + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, 0); + OVR_ASSERT(glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE); + GLenum drawBuffers[] = { GL_COLOR_ATTACHMENT0}; + glDrawBuffers(OVR_ARRAY_COUNT(drawBuffers), drawBuffers); + glClearColor(0,0,0,1); + glClear(GL_COLOR_BUFFER_BIT); + } + + { + OverdriveBackBufferTexture = *new Texture(&RParams, RParams.BackBufferSize.w, RParams.BackBufferSize.h); + + glBindTexture(GL_TEXTURE_2D, OverdriveBackBufferTexture->TexId); + glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, RParams.BackBufferSize.w, RParams.BackBufferSize.h, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); + OVR_ASSERT(glGetError() == 0); + + OverdriveBackBufferTexture->SetSampleMode(Sample_ClampBorder | Sample_Linear); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0); + OVR_ASSERT(glGetError() == 0); + + // clear the new buffer + glBindFramebuffer(GL_FRAMEBUFFER, OverdriveFbo ); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, OverdriveBackBufferTexture->TexId, 0); + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, 0); + OVR_ASSERT(glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE); + GLenum drawBuffers[] = { GL_COLOR_ATTACHMENT0}; + glDrawBuffers(OVR_ARRAY_COUNT(drawBuffers), drawBuffers); + glClearColor(0,0,0,1); + glClear(GL_COLOR_BUFFER_BIT); + } + + glBindFramebuffer(GL_FRAMEBUFFER, 0); + } + else + { + LastUsedOverdriveTextureIndex = -1; + } +} + +void DistortionRenderer::SubmitEye(int eyeId, const ovrTexture* eyeTexture) +{ + // Doesn't do a lot in here?? + const ovrGLTexture* tex = (const ovrGLTexture*)eyeTexture; + + if (tex) + { + // Write in values + eachEye[eyeId].texture = tex->OGL.TexId; + + // Its only at this point we discover what the viewport of the texture is. + // because presumably we allow users to realtime adjust the resolution. + eachEye[eyeId].TextureSize = tex->OGL.Header.TextureSize; + eachEye[eyeId].RenderViewport = tex->OGL.Header.RenderViewport; + + const ovrEyeRenderDesc& erd = RState.EyeRenderDesc[eyeId]; + + ovrHmd_GetRenderScaleAndOffset( erd.Fov, + eachEye[eyeId].TextureSize, eachEye[eyeId].RenderViewport, + eachEye[eyeId].UVScaleOffset ); + + if (!(RState.DistortionCaps & ovrDistortionCap_FlipInput)) + { + eachEye[eyeId].UVScaleOffset[0].y = -eachEye[eyeId].UVScaleOffset[0].y; + eachEye[eyeId].UVScaleOffset[1].y = 1.0f - eachEye[eyeId].UVScaleOffset[1].y; + } + + pEyeTextures[eyeId]->UpdatePlaceholderTexture(tex->OGL.TexId, + tex->OGL.Header.TextureSize); + } +} + +void DistortionRenderer::renderEndFrame() +{ + renderDistortion(pEyeTextures[0], pEyeTextures[1]); + + // TODO: Add rendering context to callback. + if(RegisteredPostDistortionCallback) + RegisteredPostDistortionCallback(NULL); + + if(LatencyTest2Active) + { + renderLatencyPixel(LatencyTest2DrawColor); + } +} + +void DistortionRenderer::EndFrame(bool swapBuffers) +{ + Context currContext; + currContext.InitFromCurrent(); +#if defined(OVR_OS_MAC) + distortionContext.SetSurface( currContext ); +#endif + + // Don't spin if we are explicitly asked not to + if ((RState.DistortionCaps & ovrDistortionCap_TimeWarp) && + !(RState.DistortionCaps & ovrDistortionCap_ProfileNoTimewarpSpinWaits)) + { + if (!TimeManager.NeedDistortionTimeMeasurement()) + { + // Wait for timewarp distortion if it is time and Gpu idle + FlushGpuAndWaitTillTime(TimeManager.GetFrameTiming().TimewarpPointTime); + + distortionContext.Bind(); + renderEndFrame(); + } + else + { + // If needed, measure distortion time so that TimeManager can better estimate + // latency-reducing time-warp wait timing. + WaitUntilGpuIdle(); + double distortionStartTime = ovr_GetTimeInSeconds(); + + distortionContext.Bind(); + renderEndFrame(); + + WaitUntilGpuIdle(); + TimeManager.AddDistortionTimeMeasurement(ovr_GetTimeInSeconds() - distortionStartTime); + } + } + else + { + distortionContext.Bind(); + renderEndFrame(); + } + + if(LatencyTestActive) + { + renderLatencyQuad(LatencyTestDrawColor); + } + + if (swapBuffers) + { + bool useVsync = ((RState.EnabledHmdCaps & ovrHmdCap_NoVSync) == 0); + int ourSwapInterval = (useVsync) ? 1 : 0; + int originalSwapInterval; + +#if defined(OVR_OS_WIN32) + originalSwapInterval = wglGetSwapIntervalEXT(); + + if (ourSwapInterval != originalSwapInterval) + wglSwapIntervalEXT(ourSwapInterval); + + HDC dc = (RParams.DC != NULL) ? RParams.DC : GetDC(RParams.Window); + BOOL success = SwapBuffers(dc); + OVR_ASSERT_AND_UNUSED(success, success); + + if (RParams.DC == NULL) + ReleaseDC(RParams.Window, dc); + +#elif defined(OVR_OS_MAC) + originalSwapInterval = 0; + CGLContextObj context = CGLGetCurrentContext(); + CGLError err = CGLGetParameter(context, kCGLCPSwapInterval, &originalSwapInterval); + OVR_ASSERT_AND_UNUSED(err == kCGLNoError, err); + + if (ourSwapInterval != originalSwapInterval) + CGLSetParameter(context, kCGLCPSwapInterval, &ourSwapInterval); + + CGLFlushDrawable(context); + +#elif defined(OVR_OS_LINUX) + originalSwapInterval = 0; + GLXDrawable drawable = glXGetCurrentDrawable(); + struct _XDisplay* x11Display = RParams.Disp; + + if(GLE_GLX_EXT_swap_control) + { + static_assert(sizeof(GLuint) == sizeof(originalSwapInterval), "size mismatch"); + glXQueryDrawable(x11Display, drawable, GLX_SWAP_INTERVAL_EXT, (GLuint*)&originalSwapInterval); + + if (ourSwapInterval != originalSwapInterval) + glXSwapIntervalEXT(x11Display, drawable, ourSwapInterval); + } + else if (GLE_MESA_swap_control) // There is also GLX_SGI_swap_control + { + originalSwapInterval = glXGetSwapIntervalMESA(); + + if (ourSwapInterval != originalSwapInterval) + glXSwapIntervalMESA(ourSwapInterval); + } + + glXSwapBuffers(x11Display, drawable); +#endif + + // Force GPU to flush the scene, resulting in the lowest possible latency. + // It's critical that this flush is *after* present, because it results in the wait + // below completing after the vsync. + // With the display driver (direct mode) this flush is obsolete and theoretically + // should be a no-op and so doesn't need to be done if running in direct mode. + if (RState.OurHMDInfo.InCompatibilityMode && + !(RState.DistortionCaps & ovrDistortionCap_ProfileNoTimewarpSpinWaits)) + WaitUntilGpuIdle(); + + // Restore the original swap interval if we changed it above. + if (originalSwapInterval != ourSwapInterval) + { +#if defined(OVR_OS_WIN32) + wglSwapIntervalEXT(originalSwapInterval); +#elif defined(OVR_OS_MAC) + CGLSetParameter(context, kCGLCPSwapInterval, &originalSwapInterval); +#elif defined(OVR_OS_LINUX) + if(GLE_GLX_EXT_swap_control) + glXSwapIntervalEXT(x11Display, drawable, (GLuint)originalSwapInterval); + else if(GLE_MESA_swap_control) + glXSwapIntervalMESA(originalSwapInterval); +#endif + } + } + + currContext.Bind(); +} + +void DistortionRenderer::WaitUntilGpuIdle() +{ + glFinish(); // Block until current OpenGL commands (including swap) are complete. +} + +double DistortionRenderer::FlushGpuAndWaitTillTime(double absTime) +{ + // because glFlush() is not strict enough certain GL drivers + // we do a glFinish(), but before doing so, we make sure we're not + // running late + double initialTime = ovr_GetTimeInSeconds(); + if (initialTime >= absTime) + return 0.0; + + glFinish(); + + return WaitTillTime(absTime); +} + +void DistortionRenderer::initBuffersAndShaders() +{ + for ( int eyeNum = 0; eyeNum < 2; eyeNum++ ) + { + // Allocate & generate distortion mesh vertices. + ovrDistortionMesh meshData; + + if (!ovrHmd_CreateDistortionMesh( HMD, + RState.EyeRenderDesc[eyeNum].Eye, + RState.EyeRenderDesc[eyeNum].Fov, + RState.DistortionCaps, + &meshData) ) + { + OVR_ASSERT(false); + continue; + } + + // Now parse the vertex data and create a render ready vertex buffer from it + DistortionVertex * pVBVerts = (DistortionVertex*)OVR_ALLOC ( sizeof(DistortionVertex) * meshData.VertexCount ); + DistortionVertex * pCurVBVert = pVBVerts; + ovrDistortionVertex* pCurOvrVert = meshData.pVertexData; + + for ( unsigned vertNum = 0; vertNum < meshData.VertexCount; vertNum++ ) + { + pCurVBVert->ScreenPosNDC.x = pCurOvrVert->ScreenPosNDC.x; + pCurVBVert->ScreenPosNDC.y = pCurOvrVert->ScreenPosNDC.y; + + if (RotateCCW90) + { + OVR::Alg::Swap(pCurVBVert->ScreenPosNDC.x, pCurVBVert->ScreenPosNDC.y); + pCurVBVert->ScreenPosNDC.x = -pCurVBVert->ScreenPosNDC.x; + } + + // Previous code here did this: pCurVBVert->TanEyeAnglesR = (*(Vector2f*)&pCurOvrVert->TanEyeAnglesR); However that's an usafe + // cast of unrelated types which can result in undefined behavior by a conforming compiler. A safe equivalent is simply memcpy. + static_assert(sizeof(OVR::Vector2f) == sizeof(ovrVector2f), "Mismatch of structs that are presumed binary equivalents."); + memcpy(&pCurVBVert->TanEyeAnglesR, &pCurOvrVert->TanEyeAnglesR, sizeof(pCurVBVert->TanEyeAnglesR)); + memcpy(&pCurVBVert->TanEyeAnglesG, &pCurOvrVert->TanEyeAnglesG, sizeof(pCurVBVert->TanEyeAnglesG)); + memcpy(&pCurVBVert->TanEyeAnglesB, &pCurOvrVert->TanEyeAnglesB, sizeof(pCurVBVert->TanEyeAnglesB)); + + // Convert [0.0f,1.0f] to [0,255] + if (RState.DistortionCaps & ovrDistortionCap_Vignette) + { + if(RState.DistortionCaps & ovrDistortionCap_SRGB) + pCurOvrVert->VignetteFactor = pow(pCurOvrVert->VignetteFactor, 2.1f); + + pCurVBVert->Col.R = (uint8_t)( Alg::Max ( pCurOvrVert->VignetteFactor, 0.0f ) * 255.99f ); + } + else + pCurVBVert->Col.R = 255; + + pCurVBVert->Col.G = pCurVBVert->Col.R; + pCurVBVert->Col.B = pCurVBVert->Col.R; + pCurVBVert->Col.A = (uint8_t)( pCurOvrVert->TimeWarpFactor * 255.99f );; + pCurOvrVert++; + pCurVBVert++; + } + + DistortionMeshVBs[eyeNum] = *new Buffer(&RParams); + DistortionMeshVBs[eyeNum]->Data ( Buffer_Vertex | Buffer_ReadOnly, pVBVerts, sizeof(DistortionVertex) * meshData.VertexCount ); + DistortionMeshIBs[eyeNum] = *new Buffer(&RParams); + DistortionMeshIBs[eyeNum]->Data ( Buffer_Index | Buffer_ReadOnly, meshData.pIndexData, ( sizeof(int16_t) * meshData.IndexCount ) ); + + OVR_FREE ( pVBVerts ); + ovrHmd_DestroyDistortionMesh( &meshData ); + } + + initShaders(); +} + +void DistortionRenderer::renderDistortion(Texture* leftEyeTexture, Texture* rightEyeTexture) +{ + bool overdriveActive = IsOverdriveActive(); + int currOverdriveTextureIndex = -1; + + if(overdriveActive) + { + currOverdriveTextureIndex = (LastUsedOverdriveTextureIndex + 1) % NumOverdriveTextures; + + //glBindFramebuffer(GL_FRAMEBUFFER, 0); + glBindFramebuffer(GL_FRAMEBUFFER, OverdriveFbo ); + + GLenum drawBuffers[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1}; + glDrawBuffers(OVR_ARRAY_COUNT(drawBuffers), drawBuffers); + + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, pOverdriveTextures[currOverdriveTextureIndex]->TexId, 0); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, OverdriveBackBufferTexture->TexId, 0); + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, 0); + OVR_ASSERT(glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE); + } + else + { + glBindFramebuffer(GL_FRAMEBUFFER, 0); + } + + setViewport( Recti(0,0, RParams.BackBufferSize.w, RParams.BackBufferSize.h) ); + + if (RState.DistortionCaps & ovrDistortionCap_SRGB) + glEnable(GL_FRAMEBUFFER_SRGB); + else + glDisable(GL_FRAMEBUFFER_SRGB); + + glDisable(GL_CULL_FACE); + glDisable(GL_DEPTH_TEST); + + if (GLE_EXT_draw_buffers2) + { + glDisablei(GL_BLEND, 0); + glColorMaski(0, GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE); + } + else + { + glDisable(GL_BLEND); + glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE); + } + + glDisable(GL_DITHER); + glDisable(GL_RASTERIZER_DISCARD); + if (GLEContext::GetCurrentContext()->WholeVersion >= 302) + { + glDisable(GL_SAMPLE_MASK); + } + + glClearColor( + RState.ClearColor[0], + RState.ClearColor[1], + RState.ClearColor[2], + RState.ClearColor[3] ); + + glClear(GL_COLOR_BUFFER_BIT); + + for (int eyeNum = 0; eyeNum < 2; eyeNum++) + { + ShaderFill distortionShaderFill(DistortionShader); + distortionShaderFill.SetTexture(0, eyeNum == 0 ? leftEyeTexture : rightEyeTexture); + + if(overdriveActive) + { + distortionShaderFill.SetTexture(1, pOverdriveTextures[LastUsedOverdriveTextureIndex]); + + float overdriveScaleRegularRise; + float overdriveScaleRegularFall; + GetOverdriveScales(overdriveScaleRegularRise, overdriveScaleRegularFall); + DistortionShader->SetUniform3f("OverdriveScales_IsSrgb", overdriveScaleRegularRise, overdriveScaleRegularFall, + (RState.DistortionCaps & ovrDistortionCap_SRGB) ? 1.0f : -1.0f); + } + else + { + // -1.0f disables PLO + DistortionShader->SetUniform3f("OverdriveScales_IsSrgb", -1.0f, -1.0f, -1.0f); + } + + DistortionShader->SetUniform2f("EyeToSourceUVScale", eachEye[eyeNum].UVScaleOffset[0].x, eachEye[eyeNum].UVScaleOffset[0].y); + // Convert Y to 1-Y as OpenGL is inverse of D3D + DistortionShader->SetUniform2f("EyeToSourceUVOffset", eachEye[eyeNum].UVScaleOffset[1].x, 1.0f - eachEye[eyeNum].UVScaleOffset[1].y); + + if (RState.DistortionCaps & ovrDistortionCap_TimeWarp) + { + ovrMatrix4f timeWarpMatrices[2]; + ovrHmd_GetEyeTimewarpMatrices(HMD, (ovrEyeType)eyeNum, + RState.EyeRenderPoses[eyeNum], timeWarpMatrices); + + // Feed identity like matrices in until we get proper timewarp calculation going on + DistortionShader->SetUniform4x4f("EyeRotationStart", Matrix4f(timeWarpMatrices[0]).Transposed()); + DistortionShader->SetUniform4x4f("EyeRotationEnd", Matrix4f(timeWarpMatrices[1]).Transposed()); + + renderPrimitives(&distortionShaderFill, DistortionMeshVBs[eyeNum], DistortionMeshIBs[eyeNum], + 0, (int)DistortionMeshIBs[eyeNum]->GetSize()/2, Prim_Triangles, &DistortionMeshVAOs[eyeNum], true); + } + else + { + renderPrimitives(&distortionShaderFill, DistortionMeshVBs[eyeNum], DistortionMeshIBs[eyeNum], + 0, (int)DistortionMeshIBs[eyeNum]->GetSize()/2, Prim_Triangles, &DistortionMeshVAOs[eyeNum], true); + } + } + + LastUsedOverdriveTextureIndex = currOverdriveTextureIndex; + + // Re-activate to only draw on back buffer + if(overdriveActive) + { + GLenum drawBuffers[] = { GL_COLOR_ATTACHMENT0}; + glDrawBuffers(OVR_ARRAY_COUNT(drawBuffers), drawBuffers); + + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); + //glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, 0); + //glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, 0, 0); + OVR_ASSERT(glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE); + + glBindFramebuffer( GL_READ_FRAMEBUFFER, OverdriveFbo ); + glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, OverdriveBackBufferTexture->TexId, 0); + glFramebufferRenderbuffer(GL_READ_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, 0); + OVR_ASSERT(glCheckFramebufferStatus(GL_READ_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE); + + glBlitFramebuffer( 0, 0, OverdriveBackBufferTexture->GetWidth(), OverdriveBackBufferTexture->GetHeight(), + 0, 0, OverdriveBackBufferTexture->GetWidth(), OverdriveBackBufferTexture->GetHeight(), + GL_COLOR_BUFFER_BIT, GL_NEAREST ); + + glBindFramebuffer( GL_FRAMEBUFFER, 0 ); + GLint err = glGetError(); + OVR_ASSERT(!err); OVR_UNUSED(err); + } +} + + +void DistortionRenderer::createDrawQuad() +{ + const int numQuadVerts = 4; + LatencyTesterQuadVB = *new Buffer(&RParams); + if(!LatencyTesterQuadVB) + { + return; + } + + LatencyTesterQuadVB->Data(Buffer_Vertex, NULL, numQuadVerts * sizeof(LatencyVertex)); + LatencyVertex* vertices = (LatencyVertex*)LatencyTesterQuadVB->Map(0, numQuadVerts * sizeof(LatencyVertex), Map_Discard); + if(!vertices) + { + OVR_ASSERT(false); // failed to lock vertex buffer + return; + } + + const float left = -1.0f; + const float top = -1.0f; + const float right = 1.0f; + const float bottom = 1.0f; + + vertices[0] = LatencyVertex(Vector3f(left, top, 0.0f)); + vertices[1] = LatencyVertex(Vector3f(left, bottom, 0.0f)); + vertices[2] = LatencyVertex(Vector3f(right, top, 0.0f)); + vertices[3] = LatencyVertex(Vector3f(right, bottom, 0.0f)); + + LatencyTesterQuadVB->Unmap(vertices); +} + +void DistortionRenderer::renderLatencyQuad(unsigned char* latencyTesterDrawColor) +{ + const int numQuadVerts = 4; + + if(!LatencyTesterQuadVB) + { + createDrawQuad(); + } + + Ptr quadShader = (RState.DistortionCaps & ovrDistortionCap_SRGB) ? SimpleQuadGammaShader : SimpleQuadShader; + ShaderFill quadFill(quadShader); + //quadFill.SetInputLayout(SimpleQuadVertexIL); + + setViewport(Recti(0,0, RParams.BackBufferSize.w, RParams.BackBufferSize.h)); + + quadShader->SetUniform2f("Scale", 0.3f, 0.3f); + quadShader->SetUniform4f("Color", (float)latencyTesterDrawColor[0] / 255.99f, + (float)latencyTesterDrawColor[0] / 255.99f, + (float)latencyTesterDrawColor[0] / 255.99f, + 1.0f); + + for(int eyeNum = 0; eyeNum < 2; eyeNum++) + { + quadShader->SetUniform2f("PositionOffset", eyeNum == 0 ? -0.5f : 0.5f, 0.0f); + renderPrimitives(&quadFill, LatencyTesterQuadVB, NULL, 0, numQuadVerts, Prim_TriangleStrip, &LatencyVAO, false); + } +} + +void DistortionRenderer::renderLatencyPixel(unsigned char* latencyTesterPixelColor) +{ + const int numQuadVerts = 4; + + if(!LatencyTesterQuadVB) + { + createDrawQuad(); + } + + Ptr quadShader = (RState.DistortionCaps & ovrDistortionCap_SRGB) ? SimpleQuadGammaShader : SimpleQuadShader; + ShaderFill quadFill(quadShader); + + setViewport(Recti(0,0, RParams.BackBufferSize.w, RParams.BackBufferSize.h)); + +#ifdef OVR_BUILD_DEBUG + quadShader->SetUniform4f("Color", (float)latencyTesterPixelColor[0] / 255.99f, + (float)latencyTesterPixelColor[1] / 255.99f, + (float)latencyTesterPixelColor[2] / 255.99f, + 1.0f); + + Vector2f scale(20.0f / RParams.BackBufferSize.w, 20.0f / RParams.BackBufferSize.h); +#else + quadShader->SetUniform4f("Color", (float)latencyTesterPixelColor[0] / 255.99f, + (float)latencyTesterPixelColor[0] / 255.99f, + (float)latencyTesterPixelColor[0] / 255.99f, + 1.0f); + + Vector2f scale(1.0f / RParams.BackBufferSize.w, 1.0f / RParams.BackBufferSize.h); +#endif + quadShader->SetUniform2f("Scale", scale.x, scale.y); + if (!RotateCCW90) + quadShader->SetUniform2f("PositionOffset", 1.0f-scale.x, 1.0f-scale.y); + else + quadShader->SetUniform2f("PositionOffset", -(1.0f-scale.x), 1.0f-scale.y); + renderPrimitives(&quadFill, LatencyTesterQuadVB, NULL, 0, numQuadVerts, Prim_TriangleStrip, &LatencyVAO, false); +} + +void DistortionRenderer::renderPrimitives( + const ShaderFill* fill, + Buffer* vertices, Buffer* indices, + int offset, int count, + PrimitiveType rprim, GLuint* vao, bool isDistortionMesh) +{ + GLenum prim; + switch (rprim) + { + case Prim_Triangles: + prim = GL_TRIANGLES; + break; + case Prim_Lines: + prim = GL_LINES; + break; + case Prim_TriangleStrip: + prim = GL_TRIANGLE_STRIP; + break; + default: + OVR_ASSERT(false); + return; + } + + fill->Set(); + + GLuint prog = fill->GetShaders()->Prog; + + if (vao != NULL) + { + if (*vao != 0) + { + glBindVertexArray(*vao); + + if (isDistortionMesh) + glDrawElements(prim, count, GL_UNSIGNED_SHORT, NULL); + else + glDrawArrays(prim, 0, count); + + glBindVertexArray(0); + } + else + { + if (GL_ARB_vertex_array_object) + { + glGenVertexArrays(1, vao); + glBindVertexArray(*vao); + } + + int attributeCount = (isDistortionMesh) ? 5 : 1; + int* locs = new int[attributeCount]; + + glBindBuffer(GL_ARRAY_BUFFER, ((Buffer*)vertices)->GLBuffer); + + if (isDistortionMesh) + { + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ((Buffer*)indices)->GLBuffer); + + locs[0] = glGetAttribLocation(prog, "Position"); + locs[1] = glGetAttribLocation(prog, "Color"); + locs[2] = glGetAttribLocation(prog, "TexCoord0"); + locs[3] = glGetAttribLocation(prog, "TexCoord1"); + locs[4] = glGetAttribLocation(prog, "TexCoord2"); + + glVertexAttribPointer(locs[0], 2, GL_FLOAT, false, sizeof(DistortionVertex), reinterpret_cast(offset)+offsetof(DistortionVertex, ScreenPosNDC)); + glVertexAttribPointer(locs[1], 4, GL_UNSIGNED_BYTE, true, sizeof(DistortionVertex), reinterpret_cast(offset)+offsetof(DistortionVertex, Col)); + glVertexAttribPointer(locs[2], 2, GL_FLOAT, false, sizeof(DistortionVertex), reinterpret_cast(offset)+offsetof(DistortionVertex, TanEyeAnglesR)); + glVertexAttribPointer(locs[3], 2, GL_FLOAT, false, sizeof(DistortionVertex), reinterpret_cast(offset)+offsetof(DistortionVertex, TanEyeAnglesG)); + glVertexAttribPointer(locs[4], 2, GL_FLOAT, false, sizeof(DistortionVertex), reinterpret_cast(offset)+offsetof(DistortionVertex, TanEyeAnglesB)); + } + else + { + locs[0] = glGetAttribLocation(prog, "Position"); + + glVertexAttribPointer(locs[0], 3, GL_FLOAT, false, sizeof(LatencyVertex), reinterpret_cast(offset)+offsetof(LatencyVertex, Pos)); + } + + for (int i = 0; i < attributeCount; ++i) + glEnableVertexAttribArray(locs[i]); + + if (isDistortionMesh) + glDrawElements(prim, count, GL_UNSIGNED_SHORT, NULL); + else + glDrawArrays(prim, 0, count); + + + if (!GL_ARB_vertex_array_object) + { + for (int i = 0; i < attributeCount; ++i) + glDisableVertexAttribArray(locs[i]); + } + + delete[] locs; + + if (GL_ARB_vertex_array_object) + { + glBindVertexArray(0); + } + } + } +} + +void DistortionRenderer::setViewport(const Recti& vp) +{ + glViewport(vp.x, vp.y, vp.w, vp.h); +} + + +void DistortionRenderer::initShaders() +{ + const char* shaderPrefix = (GLEContext::GetCurrentContext()->WholeVersion >= 302) ? glsl3Prefix : glsl2Prefix; + + { + ShaderInfo vsInfo = DistortionVertexShaderLookup[DistortionVertexShaderBitMask & RState.DistortionCaps]; + + size_t vsSize = strlen(shaderPrefix)+vsInfo.ShaderSize; + char* vsSource = new char[vsSize]; + OVR_strcpy(vsSource, vsSize, shaderPrefix); + OVR_strcat(vsSource, vsSize, vsInfo.ShaderData); + + Ptr vs = *new GL::VertexShader( + &RParams, + (void*)vsSource, vsSize, + vsInfo.ReflectionData, vsInfo.ReflectionSize); + + DistortionShader = *new ShaderSet; + DistortionShader->SetShader(vs); + + delete[](vsSource); + + ShaderInfo psInfo = DistortionPixelShaderLookup[DistortionPixelShaderBitMask & RState.DistortionCaps]; + + size_t psSize = strlen(shaderPrefix)+psInfo.ShaderSize; + char* psSource = new char[psSize]; + OVR_strcpy(psSource, psSize, shaderPrefix); + OVR_strcat(psSource, psSize, psInfo.ShaderData); + + Ptr ps = *new GL::FragmentShader( + &RParams, + (void*)psSource, psSize, + psInfo.ReflectionData, psInfo.ReflectionSize); + + DistortionShader->SetShader(ps); + + delete[](psSource); + } + { + size_t vsSize = strlen(shaderPrefix)+sizeof(SimpleQuad_vs); + char* vsSource = new char[vsSize]; + OVR_strcpy(vsSource, vsSize, shaderPrefix); + OVR_strcat(vsSource, vsSize, SimpleQuad_vs); + + Ptr vs = *new GL::VertexShader( + &RParams, + (void*)vsSource, vsSize, + SimpleQuad_vs_refl, sizeof(SimpleQuad_vs_refl) / sizeof(SimpleQuad_vs_refl[0])); + + SimpleQuadShader = *new ShaderSet; + SimpleQuadShader->SetShader(vs); + + delete[](vsSource); + + size_t psSize = strlen(shaderPrefix)+sizeof(SimpleQuad_fs); + char* psSource = new char[psSize]; + OVR_strcpy(psSource, psSize, shaderPrefix); + OVR_strcat(psSource, psSize, SimpleQuad_fs); + + Ptr ps = *new GL::FragmentShader( + &RParams, + (void*)psSource, psSize, + SimpleQuad_fs_refl, sizeof(SimpleQuad_fs_refl) / sizeof(SimpleQuad_fs_refl[0])); + + SimpleQuadShader->SetShader(ps); + + delete[](psSource); + } + { + size_t vsSize = strlen(shaderPrefix)+sizeof(SimpleQuad_vs); + char* vsSource = new char[vsSize]; + OVR_strcpy(vsSource, vsSize, shaderPrefix); + OVR_strcat(vsSource, vsSize, SimpleQuad_vs); + + Ptr vs = *new GL::VertexShader( + &RParams, + (void*)vsSource, vsSize, + SimpleQuad_vs_refl, sizeof(SimpleQuad_vs_refl) / sizeof(SimpleQuad_vs_refl[0])); + + SimpleQuadGammaShader = *new ShaderSet; + SimpleQuadGammaShader->SetShader(vs); + + delete[](vsSource); + + size_t psSize = strlen(shaderPrefix)+sizeof(SimpleQuadGamma_fs); + char* psSource = new char[psSize]; + OVR_strcpy(psSource, psSize, shaderPrefix); + OVR_strcat(psSource, psSize, SimpleQuadGamma_fs); + + Ptr ps = *new GL::FragmentShader( + &RParams, + (void*)psSource, psSize, + SimpleQuadGamma_fs_refl, sizeof(SimpleQuadGamma_fs_refl) / sizeof(SimpleQuadGamma_fs_refl[0])); + + SimpleQuadGammaShader->SetShader(ps); + + delete[](psSource); + } +} + + +void DistortionRenderer::destroy() +{ + Context currContext; + currContext.InitFromCurrent(); + + distortionContext.Bind(); + + for(int eyeNum = 0; eyeNum < 2; eyeNum++) + { + if (GL_ARB_vertex_array_object) + { + glDeleteVertexArrays(1, &DistortionMeshVAOs[eyeNum]); + } + + DistortionMeshVAOs[eyeNum] = 0; + + DistortionMeshVBs[eyeNum].Clear(); + DistortionMeshIBs[eyeNum].Clear(); + } + + if (DistortionShader) + { + DistortionShader->UnsetShader(Shader_Vertex); + DistortionShader->UnsetShader(Shader_Pixel); + DistortionShader.Clear(); + } + + LatencyTesterQuadVB.Clear(); + + if(LatencyVAO != 0) + { + glDeleteVertexArrays(1, &LatencyVAO); + LatencyVAO = 0; + } + + if(OverdriveFbo != 0) + { + glDeleteFramebuffers(1, &OverdriveFbo); + } + + currContext.Bind(); + distortionContext.Destroy(); + // Who is responsible for destroying the app's context? +} + + +}}} // OVR::CAPI::GL diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/CAPI/GL/CAPI_GL_DistortionRenderer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/CAPI/GL/CAPI_GL_DistortionRenderer.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,150 @@ +/************************************************************************************ + +Filename : CAPI_GL_DistortionRenderer.h +Content : Distortion renderer header for GL +Created : November 11, 2013 +Authors : David Borel, Lee Cooper + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#ifndef OVR_CAPI_GL_DistortionRenderer_h +#define OVR_CAPI_GL_DistortionRenderer_h + +#include "../CAPI_DistortionRenderer.h" + +#include "../../Kernel/OVR_Log.h" +#include "CAPI_GL_Util.h" + +namespace OVR { namespace CAPI { namespace GL { + +// ***** GL::DistortionRenderer + +// Implementation of DistortionRenderer for GL. + +class DistortionRenderer : public CAPI::DistortionRenderer +{ +public: + DistortionRenderer(ovrHmd hmd, + FrameTimeManager& timeManager, + const HMDRenderState& renderState); + virtual ~DistortionRenderer(); + + + // Creation function for the device. + static CAPI::DistortionRenderer* Create(ovrHmd hmd, + FrameTimeManager& timeManager, + const HMDRenderState& renderState); + + + // ***** Public DistortionRenderer interface + + virtual bool Initialize(const ovrRenderAPIConfig* apiConfig) OVR_OVERRIDE; + + virtual void SubmitEye(int eyeId, const ovrTexture* eyeTexture); + + virtual void EndFrame(bool swapBuffers); + + void WaitUntilGpuIdle(); + + // Similar to ovr_WaitTillTime but it also flushes GPU. + // Note, it exits when time expires, even if GPU is not in idle state yet. + double FlushGpuAndWaitTillTime(double absTime); + +protected: + + struct FOR_EACH_EYE + { + FOR_EACH_EYE() : numVerts(0), numIndices(0), texture(0), /*UVScaleOffset[],*/ TextureSize(0, 0), RenderViewport(0, 0, 0, 0) { } + + int numVerts; + int numIndices; + + GLuint texture; + + ovrVector2f UVScaleOffset[2]; + Sizei TextureSize; + Recti RenderViewport; + } eachEye[2]; + + Ptr pOverdriveTextures[NumOverdriveTextures]; + Ptr OverdriveBackBufferTexture; + + // GL context and utility variables. + RenderParams RParams; + Context distortionContext; // We are currently using this private OpenGL context instead of using the CAPI SaveGraphicsState/RestoreGraphicsState mechanism. To consider: Move this Context into SaveGraphicsState/RestoreGraphicState so there's consistency between DirectX and OpenGL. + + // Helpers + void initOverdrive(); + void initBuffersAndShaders(); + void initShaders(); + void initFullscreenQuad(); + void destroy(); + + void setViewport(const Recti& vp); + + void renderDistortion(Texture* leftEyeTexture, Texture* rightEyeTexture); + + void renderPrimitives(const ShaderFill* fill, Buffer* vertices, Buffer* indices, + int offset, int count, + PrimitiveType rprim, GLuint* vao, bool isDistortionMesh); + + void createDrawQuad(); + void renderLatencyQuad(unsigned char* latencyTesterDrawColor); + void renderLatencyPixel(unsigned char* latencyTesterPixelColor); + + void renderEndFrame(); + + Ptr pEyeTextures[2]; + + Ptr DistortionMeshVBs[2]; // one per-eye + Ptr DistortionMeshIBs[2]; // one per-eye + GLuint DistortionMeshVAOs[2]; // one per-eye + + Ptr DistortionShader; + + bool RotateCCW90; + + struct StandardUniformData + { + Matrix4f Proj; + Matrix4f View; + } StdUniforms; + + GLuint LatencyVAO; + Ptr LatencyTesterQuadVB; + Ptr SimpleQuadShader; + Ptr SimpleQuadGammaShader; + + GLuint OverdriveFbo; + + GLint SavedViewport[4]; + GLfloat SavedClearColor[4]; + GLint SavedDepthTest; + GLint SavedCullFace; + GLint SavedProgram; + GLint SavedActiveTexture; + GLint SavedBoundTexture; + GLint SavedVertexArray; + GLint SavedBoundFrameBuffer; +}; + +}}} // OVR::CAPI::GL + +#endif // OVR_CAPI_GL_DistortionRenderer_h diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/CAPI/GL/CAPI_GL_DistortionShaders.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/CAPI/GL/CAPI_GL_DistortionShaders.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,456 @@ +/************************************************************************************ + + Filename : CAPI_GL_Shaders.h + Content : Distortion shader header for GL + Created : November 11, 2013 + Authors : David Borel, Volga Aksoy + + Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + + ************************************************************************************/ + + +#ifndef OVR_CAPI_GL_Shaders_h +#define OVR_CAPI_GL_Shaders_h + + +#include "CAPI_GL_Util.h" + +namespace OVR { namespace CAPI { namespace GL { + + static const char glsl2Prefix[] = + "#version 110\n" + "#extension GL_ARB_shader_texture_lod : enable\n" + "#extension GL_ARB_draw_buffers : enable\n" + "#extension GL_EXT_gpu_shader4 : enable\n" + "#define _FRAGCOLOR_DECLARATION\n" + "#define _MRTFRAGCOLOR0_DECLARATION\n" + "#define _MRTFRAGCOLOR1_DECLARATION\n" + "#define _GLFRAGCOORD_DECLARATION\n" + "#define _VS_IN attribute\n" + "#define _VS_OUT varying\n" + "#define _FS_IN varying\n" + "#define _TEXTURELOD texture2DLod\n" + "#define _TEXTURE texture2D\n" + "#define _FRAGCOLOR gl_FragColor\n" + "#define _MRTFRAGCOLOR0 gl_FragData[0]\n" + "#define _MRTFRAGCOLOR1 gl_FragData[1]\n" // The texture coordinate [0.0,1.0] for texel i of a texture of size N is: (2i + 1)/2N + "#ifdef GL_EXT_gpu_shader4\n" + " #define _TEXELFETCHDECL vec4 texelFetch(sampler2D tex, ivec2 coord, int lod){ ivec2 size = textureSize2D(tex, lod); return texture2D(tex, vec2(float((coord.x * 2) + 1) / float(size.x * 2), float((coord.y * 2) + 1) / float(size.y * 2))); }\n" + "#endif\n"; + + static const char glsl3Prefix[] = + "#version 150\n" + "#define _FRAGCOLOR_DECLARATION out vec4 FragColor;\n" + "#define _MRTFRAGCOLOR0_DECLARATION out vec4 FragData0;\n" + "#define _MRTFRAGCOLOR1_DECLARATION out vec4 FragData1;\n" + "#define _GLFRAGCOORD_DECLARATION in vec4 gl_FragCoord;\n" + "#define _VS_IN in\n" + "#define _VS_OUT out\n" + "#define _FS_IN in\n" + "#define _TEXTURELOD textureLod\n" + "#define _TEXTURE texture\n" + "#define _FRAGCOLOR FragColor\n" + "#define _MRTFRAGCOLOR0 FragData0\n" + "#define _MRTFRAGCOLOR1 FragData1\n" + "#define _TEXELFETCHDECL\n"; + + static const char SimpleQuad_vs[] = + "uniform vec2 PositionOffset;\n" + "uniform vec2 Scale;\n" + + "_VS_IN vec3 Position;\n" + + "void main()\n" + "{\n" + " gl_Position = vec4(Position.xy * Scale + PositionOffset, 0.5, 1.0);\n" + "}\n"; + + const OVR::CAPI::GL::ShaderBase::Uniform SimpleQuad_vs_refl[] = + { + { "PositionOffset", OVR::CAPI::GL::ShaderBase::VARTYPE_FLOAT, 0, 8 }, + { "Scale", OVR::CAPI::GL::ShaderBase::VARTYPE_FLOAT, 8, 8 }, + }; + + static const char SimpleQuad_fs[] = + "uniform vec4 Color;\n" + + "_FRAGCOLOR_DECLARATION\n" + + "void main()\n" + "{\n" + " _FRAGCOLOR = Color;\n" + "}\n"; + + const OVR::CAPI::GL::ShaderBase::Uniform SimpleQuad_fs_refl[] = + { + { "Color", OVR::CAPI::GL::ShaderBase::VARTYPE_FLOAT, 0, 16 }, + }; + + static const char SimpleQuadGamma_fs[] = + "uniform vec4 Color;\n" + + "_FRAGCOLOR_DECLARATION\n" + + "void main()\n" + "{\n" + " _FRAGCOLOR.rgb = pow(Color.rgb, vec3(2.2));\n" + " _FRAGCOLOR.a = Color.a;\n" + "}\n"; + + const OVR::CAPI::GL::ShaderBase::Uniform SimpleQuadGamma_fs_refl[] = + { + { "Color", OVR::CAPI::GL::ShaderBase::VARTYPE_FLOAT, 0, 16 }, + }; + + // This must be prefixed with glsl2Prefix or glsl3Prefix before being compiled. + static const char SimpleTexturedQuad_vs[] = + "uniform vec2 PositionOffset;\n" + "uniform vec2 Scale;\n" + + "_VS_IN vec3 Position;\n" + "_VS_IN vec4 Color;\n" + "_VS_IN vec2 TexCoord;\n" + + "_VS_OUT vec4 oColor;\n" + "_VS_OUT vec2 oTexCoord;\n" + + "void main()\n" + "{\n" + " gl_Position = vec4(Position.xy * Scale + PositionOffset, 0.5, 1.0);\n" + " oColor = Color;\n" + " oTexCoord = TexCoord;\n" + "}\n"; + + // The following declaration is copied from the generated D3D SimpleTexturedQuad_vs_refl.h file, with D3D_NS renamed to GL. + const OVR::CAPI::GL::ShaderBase::Uniform SimpleTexturedQuad_vs_refl[] = + { + { "PositionOffset", OVR::CAPI::GL::ShaderBase::VARTYPE_FLOAT, 0, 8 }, + { "Scale", OVR::CAPI::GL::ShaderBase::VARTYPE_FLOAT, 8, 8 }, + }; + + + // This must be prefixed with glsl2Prefix or glsl3Prefix before being compiled. + static const char SimpleTexturedQuad_ps[] = + "uniform sampler2D Texture0;\n" + + "_FS_IN vec4 oColor;\n" + "_FS_IN vec2 oTexCoord;\n" + + "_FRAGCOLOR_DECLARATION\n" + + "void main()\n" + "{\n" + " _FRAGCOLOR = oColor * _TEXTURE(Texture0, oTexCoord);\n" + "}\n"; + + // The following is copied from the generated D3D SimpleTexturedQuad_ps_refl.h file, with D3D_NS renamed to GL. + const OVR::CAPI::GL::ShaderBase::Uniform SimpleTexturedQuad_ps_refl[] = + { + { "Color", OVR::CAPI::GL::ShaderBase::VARTYPE_FLOAT, 0, 16 }, + }; + + + static const char Distortion_vs[] = + "uniform vec2 EyeToSourceUVScale;\n" + "uniform vec2 EyeToSourceUVOffset;\n" + + "_VS_IN vec2 Position;\n" + "_VS_IN vec4 Color;\n" + "_VS_IN vec2 TexCoord0;\n" + + "_VS_OUT vec4 oColor;\n" + "_VS_OUT vec2 oTexCoord0;\n" + + "void main()\n" + "{\n" + " gl_Position.x = Position.x;\n" + " gl_Position.y = Position.y;\n" + " gl_Position.z = 0.5;\n" + " gl_Position.w = 1.0;\n" + // Vertex inputs are in TanEyeAngle space for the R,G,B channels (i.e. after chromatic aberration and distortion). + // Scale them into the correct [0-1],[0-1] UV lookup space (depending on eye) + " oTexCoord0 = TexCoord0 * EyeToSourceUVScale + EyeToSourceUVOffset;\n" + " oColor = Color;\n" // Used for vignette fade. + "}\n"; + + const OVR::CAPI::GL::ShaderBase::Uniform Distortion_vs_refl[] = + { + { "EyeToSourceUVScale", OVR::CAPI::GL::ShaderBase::VARTYPE_FLOAT, 0, 8 }, + { "EyeToSourceUVOffset", OVR::CAPI::GL::ShaderBase::VARTYPE_FLOAT, 8, 8 }, + }; + + static const char Distortion_fs[] = + "uniform sampler2D Texture0;\n" + + "_FS_IN vec4 oColor;\n" + "_FS_IN vec2 oTexCoord0;\n" + + "_FRAGCOLOR_DECLARATION\n" + + "void main()\n" + "{\n" + " _FRAGCOLOR = _TEXTURE(Texture0, oTexCoord0, 0.0);\n" + " _FRAGCOLOR.a = 1.0;\n" + "}\n"; + + + static const char DistortionTimewarp_vs[] = + "uniform vec2 EyeToSourceUVScale;\n" + "uniform vec2 EyeToSourceUVOffset;\n" + "uniform mat4 EyeRotationStart;\n" + "uniform mat4 EyeRotationEnd;\n" + + "_VS_IN vec2 Position;\n" + "_VS_IN vec4 Color;\n" + "_VS_IN vec2 TexCoord0;\n" + + "_VS_OUT vec4 oColor;\n" + "_VS_OUT vec2 oTexCoord0;\n" + + "void main()\n" + "{\n" + " gl_Position.x = Position.x;\n" + " gl_Position.y = Position.y;\n" + " gl_Position.z = 0.0;\n" + " gl_Position.w = 1.0;\n" + + // Vertex inputs are in TanEyeAngle space for the R,G,B channels (i.e. after chromatic aberration and distortion). + // These are now "real world" vectors in direction (x,y,1) relative to the eye of the HMD. + " vec3 TanEyeAngle = vec3 ( TexCoord0.x, TexCoord0.y, 1.0 );\n" + + // Accurate time warp lerp vs. faster +#if 1 + // Apply the two 3x3 timewarp rotations to these vectors. + " vec3 TransformedStart = (EyeRotationStart * vec4(TanEyeAngle, 0)).xyz;\n" + " vec3 TransformedEnd = (EyeRotationEnd * vec4(TanEyeAngle, 0)).xyz;\n" + // And blend between them. + " vec3 Transformed = mix ( TransformedStart, TransformedEnd, Color.a );\n" +#else + " mat4 EyeRotation = mix ( EyeRotationStart, EyeRotationEnd, Color.a );\n" + " vec3 Transformed = EyeRotation * TanEyeAngle;\n" +#endif + + // Project them back onto the Z=1 plane of the rendered images. + " float RecipZ = 1.0 / Transformed.z;\n" + " vec2 Flattened = vec2 ( Transformed.x * RecipZ, Transformed.y * RecipZ );\n" + + // These are now still in TanEyeAngle space. + // Scale them into the correct [0-1],[0-1] UV lookup space (depending on eye) + " vec2 SrcCoord = Flattened * EyeToSourceUVScale + EyeToSourceUVOffset;\n" + " oTexCoord0 = SrcCoord;\n" + " oColor = vec4(Color.r, Color.r, Color.r, Color.r);\n" // Used for vignette fade. + "}\n"; + + + const OVR::CAPI::GL::ShaderBase::Uniform DistortionTimewarp_vs_refl[] = + { + { "EyeToSourceUVScale", OVR::CAPI::GL::ShaderBase::VARTYPE_FLOAT, 0, 8 }, + { "EyeToSourceUVOffset", OVR::CAPI::GL::ShaderBase::VARTYPE_FLOAT, 8, 8 }, + }; + + static const char DistortionChroma_vs[] = + "uniform vec2 EyeToSourceUVScale;\n" + "uniform vec2 EyeToSourceUVOffset;\n" + + "_VS_IN vec2 Position;\n" + "_VS_IN vec4 Color;\n" + "_VS_IN vec2 TexCoord0;\n" + "_VS_IN vec2 TexCoord1;\n" + "_VS_IN vec2 TexCoord2;\n" + + "_VS_OUT vec4 oColor;\n" + "_VS_OUT vec2 oTexCoord0;\n" + "_VS_OUT vec2 oTexCoord1;\n" + "_VS_OUT vec2 oTexCoord2;\n" + + "void main()\n" + "{\n" + " gl_Position.x = Position.x;\n" + " gl_Position.y = Position.y;\n" + " gl_Position.z = 0.5;\n" + " gl_Position.w = 1.0;\n" + + // Vertex inputs are in TanEyeAngle space for the R,G,B channels (i.e. after chromatic aberration and distortion). + // Scale them into the correct [0-1],[0-1] UV lookup space (depending on eye) + " oTexCoord0 = TexCoord0 * EyeToSourceUVScale + EyeToSourceUVOffset;\n" + " oTexCoord1 = TexCoord1 * EyeToSourceUVScale + EyeToSourceUVOffset;\n" + " oTexCoord2 = TexCoord2 * EyeToSourceUVScale + EyeToSourceUVOffset;\n" + + " oColor = Color;\n" // Used for vignette fade. + "}\n"; + + const OVR::CAPI::GL::ShaderBase::Uniform DistortionChroma_vs_refl[] = + { + { "EyeToSourceUVScale", OVR::CAPI::GL::ShaderBase::VARTYPE_FLOAT, 0, 8 }, + { "EyeToSourceUVOffset", OVR::CAPI::GL::ShaderBase::VARTYPE_FLOAT, 8, 8 }, + }; + + static const char DistortionChroma_fs[] = + "uniform sampler2D Texture0;\n" + "uniform sampler2D Texture1;\n" + "uniform vec3 OverdriveScales_IsSrgb;\n" + + "_FS_IN vec4 oColor;\n" + "_FS_IN vec2 oTexCoord0;\n" + "_FS_IN vec2 oTexCoord1;\n" + "_FS_IN vec2 oTexCoord2;\n" + + "_MRTFRAGCOLOR0_DECLARATION\n" // Desired color (next frame's "PrevTexture") + "_MRTFRAGCOLOR1_DECLARATION\n" // Overdriven color (Back-buffer) + "_GLFRAGCOORD_DECLARATION\n" + + "#ifdef _TEXELFETCHDECL\n" + "_TEXELFETCHDECL\n" + "#endif\n" + + "void main()\n" + "{\n" + " float ResultR = _TEXTURE(Texture0, oTexCoord0, 0.0).r;\n" + " float ResultG = _TEXTURE(Texture0, oTexCoord1, 0.0).g;\n" + " float ResultB = _TEXTURE(Texture0, oTexCoord2, 0.0).b;\n" + " vec3 newColor = vec3(ResultR * oColor.r, ResultG * oColor.g, ResultB * oColor.b);\n" + + " _MRTFRAGCOLOR0 = vec4(newColor, 1);\n" + " _MRTFRAGCOLOR1 = _MRTFRAGCOLOR0;\n" + + " #ifdef _TEXELFETCHDECL\n" + // pixel luminance overdrive + " if(OverdriveScales_IsSrgb.x > 0.0)\n" + " {\n" + " ivec2 pixelCoord = ivec2(gl_FragCoord.x, gl_FragCoord.y);\n" + " vec3 oldColor = texelFetch(Texture1, pixelCoord, 0).rgb;\n" + + " vec3 adjustedScales;\n" + " adjustedScales.x = newColor.x > oldColor.x ? OverdriveScales_IsSrgb.x : OverdriveScales_IsSrgb.y;\n" + " adjustedScales.y = newColor.y > oldColor.y ? OverdriveScales_IsSrgb.x : OverdriveScales_IsSrgb.y;\n" + " adjustedScales.z = newColor.z > oldColor.z ? OverdriveScales_IsSrgb.x : OverdriveScales_IsSrgb.y;\n" + + // overdrive is tuned for gamma space so if we're in linear space fix gamma before doing the calculation + " vec3 overdriveColor;\n" + " if(OverdriveScales_IsSrgb.z > 0.0)\n" + " {\n" + " oldColor = pow(oldColor, vec3(1.0/2.2, 1.0/2.2, 1.0/2.2));\n" + " newColor = pow(newColor, vec3(1.0/2.2, 1.0/2.2, 1.0/2.2));\n" + " overdriveColor = clamp(newColor + (newColor - oldColor) * adjustedScales, 0.0, 1.0);\n" + " overdriveColor = pow(overdriveColor, vec3(2.2, 2.2, 2.2));\n" + " }\n" + " else\n" + " overdriveColor = clamp(newColor + (newColor - oldColor) * adjustedScales, 0.0, 1.0);\n" + + " _MRTFRAGCOLOR1 = vec4(overdriveColor, 1.0);\n" + " }\n" + " #else\n" + // If statement to keep OverdriveScales_IsSrgb from being optimized out. + " if(OverdriveScales_IsSrgb.x > 0.0)\n" + " _MRTFRAGCOLOR1 = vec4(newColor, 1);\n" + " #endif\n" + "}\n"; + + const OVR::CAPI::GL::ShaderBase::Uniform DistortionChroma_ps_refl[] = + { + { "OverdriveScales_IsSrgb", OVR::CAPI::GL::ShaderBase::VARTYPE_FLOAT, 0, 12 }, + }; + + static const char DistortionTimewarpChroma_vs[] = + "uniform vec2 EyeToSourceUVScale;\n" + "uniform vec2 EyeToSourceUVOffset;\n" + "uniform mat4 EyeRotationStart;\n" + "uniform mat4 EyeRotationEnd;\n" + + "_VS_IN vec2 Position;\n" + "_VS_IN vec4 Color;\n" + "_VS_IN vec2 TexCoord0;\n" + "_VS_IN vec2 TexCoord1;\n" + "_VS_IN vec2 TexCoord2;\n" + + "_VS_OUT vec4 oColor;\n" + "_VS_OUT vec2 oTexCoord0;\n" + "_VS_OUT vec2 oTexCoord1;\n" + "_VS_OUT vec2 oTexCoord2;\n" + + "void main()\n" + "{\n" + " gl_Position.x = Position.x;\n" + " gl_Position.y = Position.y;\n" + " gl_Position.z = 0.0;\n" + " gl_Position.w = 1.0;\n" + + // Vertex inputs are in TanEyeAngle space for the R,G,B channels (i.e. after chromatic aberration and distortion). + // These are now "real world" vectors in direction (x,y,1) relative to the eye of the HMD. + " vec3 TanEyeAngleR = vec3 ( TexCoord0.x, TexCoord0.y, 1.0 );\n" + " vec3 TanEyeAngleG = vec3 ( TexCoord1.x, TexCoord1.y, 1.0 );\n" + " vec3 TanEyeAngleB = vec3 ( TexCoord2.x, TexCoord2.y, 1.0 );\n" + + // Accurate time warp lerp vs. faster +#if 1 + // Apply the two 3x3 timewarp rotations to these vectors. + " vec3 TransformedRStart = (EyeRotationStart * vec4(TanEyeAngleR, 0)).xyz;\n" + " vec3 TransformedGStart = (EyeRotationStart * vec4(TanEyeAngleG, 0)).xyz;\n" + " vec3 TransformedBStart = (EyeRotationStart * vec4(TanEyeAngleB, 0)).xyz;\n" + " vec3 TransformedREnd = (EyeRotationEnd * vec4(TanEyeAngleR, 0)).xyz;\n" + " vec3 TransformedGEnd = (EyeRotationEnd * vec4(TanEyeAngleG, 0)).xyz;\n" + " vec3 TransformedBEnd = (EyeRotationEnd * vec4(TanEyeAngleB, 0)).xyz;\n" + + // And blend between them. + " vec3 TransformedR = mix ( TransformedRStart, TransformedREnd, Color.a );\n" + " vec3 TransformedG = mix ( TransformedGStart, TransformedGEnd, Color.a );\n" + " vec3 TransformedB = mix ( TransformedBStart, TransformedBEnd, Color.a );\n" +#else + " mat3 EyeRotation;\n" + " EyeRotation[0] = mix ( EyeRotationStart[0], EyeRotationEnd[0], Color.a ).xyz;\n" + " EyeRotation[1] = mix ( EyeRotationStart[1], EyeRotationEnd[1], Color.a ).xyz;\n" + " EyeRotation[2] = mix ( EyeRotationStart[2], EyeRotationEnd[2], Color.a ).xyz;\n" + " vec3 TransformedR = EyeRotation * TanEyeAngleR;\n" + " vec3 TransformedG = EyeRotation * TanEyeAngleG;\n" + " vec3 TransformedB = EyeRotation * TanEyeAngleB;\n" +#endif + + // Project them back onto the Z=1 plane of the rendered images. + " float RecipZR = 1.0 / TransformedR.z;\n" + " float RecipZG = 1.0 / TransformedG.z;\n" + " float RecipZB = 1.0 / TransformedB.z;\n" + " vec2 FlattenedR = vec2 ( TransformedR.x * RecipZR, TransformedR.y * RecipZR );\n" + " vec2 FlattenedG = vec2 ( TransformedG.x * RecipZG, TransformedG.y * RecipZG );\n" + " vec2 FlattenedB = vec2 ( TransformedB.x * RecipZB, TransformedB.y * RecipZB );\n" + + // These are now still in TanEyeAngle space. + // Scale them into the correct [0-1],[0-1] UV lookup space (depending on eye) + " vec2 SrcCoordR = FlattenedR * EyeToSourceUVScale + EyeToSourceUVOffset;\n" + " vec2 SrcCoordG = FlattenedG * EyeToSourceUVScale + EyeToSourceUVOffset;\n" + " vec2 SrcCoordB = FlattenedB * EyeToSourceUVScale + EyeToSourceUVOffset;\n" + + " oTexCoord0 = SrcCoordR;\n" + " oTexCoord1 = SrcCoordG;\n" + " oTexCoord2 = SrcCoordB;\n" + + " oColor = vec4(Color.r, Color.r, Color.r, Color.r);\n" // Used for vignette fade. + "}\n"; + + + const OVR::CAPI::GL::ShaderBase::Uniform DistortionTimewarpChroma_vs_refl[] = + { + { "EyeToSourceUVScale", OVR::CAPI::GL::ShaderBase::VARTYPE_FLOAT, 0, 8 }, + { "EyeToSourceUVOffset", OVR::CAPI::GL::ShaderBase::VARTYPE_FLOAT, 8, 8 }, + { "EyeRotationStart", OVR::CAPI::GL::ShaderBase::VARTYPE_FLOAT, 16, 64 }, + { "EyeRotationEnd", OVR::CAPI::GL::ShaderBase::VARTYPE_FLOAT, 80, 64 }, + }; + +}}} // OVR::CAPI::GL + +#endif // OVR_CAPI_GL_Shaders_h diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/CAPI/GL/CAPI_GL_HSWDisplay.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/CAPI/GL/CAPI_GL_HSWDisplay.cpp Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,500 @@ +/************************************************************************************ + +Filename : CAPI_GL_HSWDisplay.cpp +Content : Implements Health and Safety Warning system. +Created : July 7, 2014 +Authors : Paul Pedriana + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + + +#include "CAPI_GL_HSWDisplay.h" +#include "CAPI_GL_DistortionShaders.h" +#include "../../OVR_CAPI_GL.h" +#include "../../Kernel/OVR_File.h" +#include "../../Kernel/OVR_Math.h" +#include "../../Kernel/OVR_Allocator.h" +#include "../../Kernel/OVR_Color.h" + + +OVR_DISABLE_MSVC_WARNING(4996) // "This function or variable may be unsafe..." + + +namespace OVR { namespace CAPI { + + +// Loads the TGA data from the File as an array of width * height 32 bit Texture_RGBA values. +// Returned pointer must be freed with OVR_FREE. +uint8_t* LoadTextureTgaData(OVR::File* f, uint8_t alpha, int& width, int& height) +{ + // See http://www.fileformat.info/format/tga/egff.htm for format details. + // TGA files are stored with little-endian data. + uint8_t* pRGBA = NULL; + + f->SeekToBegin(); + + const int desclen = f->ReadUByte(); + const int palette = f->ReadUByte(); + OVR_UNUSED(palette); + const int imgtype = f->ReadUByte(); + f->ReadUInt16(); // Skip bytes + int palCount = f->ReadUInt16(); + int palSize = f->ReadUByte(); + f->ReadUInt16(); + f->ReadUInt16(); + width = f->ReadUInt16(); + height = f->ReadUInt16(); + int bpp = f->ReadUByte(); + f->ReadUByte(); + + const int ImgTypeBGRAUncompressed = 2; + const int ImgTypeBGRARLECompressed = 10; + + OVR_ASSERT(((imgtype == ImgTypeBGRAUncompressed) || (imgtype == ImgTypeBGRARLECompressed)) && ((bpp == 24) || (bpp == 32))); + + // imgType 2 is uncompressed true-color image. + // imgType 10 is run-length encoded true-color image. + if(((imgtype == ImgTypeBGRAUncompressed) || (imgtype == ImgTypeBGRARLECompressed)) && ((bpp == 24) || (bpp == 32))) + { + int imgsize = width * height * 4; + pRGBA = (uint8_t*) OVR_ALLOC(imgsize); + f->Skip(desclen); + f->Skip(palCount * (palSize + 7) >> 3); + int strideBytes = width * 4; // This is the number of bytes between successive rows. + + unsigned char buf[4] = { 0, 0, 0, alpha }; // If bpp is 24 then this alpha will be unmodified below. + + switch (imgtype) + { + case ImgTypeBGRAUncompressed: + switch (bpp) + { + case 24: + case 32: + for (int y = 0; y < height; y++) + { + for (int x = 0; x < width; x++) + { + f->Read(buf, bpp / 8); // Data is stored as B, G, R + pRGBA[y*strideBytes + x*4 + 0] = buf[2]; + pRGBA[y*strideBytes + x*4 + 1] = buf[1]; + pRGBA[y*strideBytes + x*4 + 2] = buf[0]; + pRGBA[y*strideBytes + x*4 + 3] = buf[3]; + } + } + break; + } + break; + + case ImgTypeBGRARLECompressed: + switch (bpp) + { + case 24: + case 32: + for (int y = 0; y < height; y++) // RLE spans don't cross successive rows. + { + int x = 0; + + while(x < width) + { + uint8_t rleByte; + f->Read(&rleByte, 1); + + if(rleByte & 0x80) // If the high byte is set then what follows are RLE bytes. + { + size_t rleCount = ((rleByte & 0x7f) + 1); + f->Read(buf, bpp / 8); // Data is stored as B, G, R, A + + for (; rleCount; --rleCount, ++x) + { + pRGBA[y*strideBytes + x*4 + 0] = buf[2]; + pRGBA[y*strideBytes + x*4 + 1] = buf[1]; + pRGBA[y*strideBytes + x*4 + 2] = buf[0]; + pRGBA[y*strideBytes + x*4 + 3] = buf[3]; + } + } + else // Else what follows are regular bytes of a count indicated by rleByte + { + for (size_t rleCount = (rleByte + 1); rleCount; --rleCount, ++x) + { + f->Read(buf, bpp / 8); // Data is stored as B, G, R, A + pRGBA[y*strideBytes + x*4 + 0] = buf[2]; + pRGBA[y*strideBytes + x*4 + 1] = buf[1]; + pRGBA[y*strideBytes + x*4 + 2] = buf[0]; + pRGBA[y*strideBytes + x*4 + 3] = buf[3]; + } + } + } + } + break; + } + break; + } + } + + return pRGBA; +} // LoadTextureTgaData + + + +namespace GL { + + +// To do: This needs to be promoted to a central version, possibly in CAPI_HSWDisplay.h +struct HASWVertex +{ + Vector3f Pos; + Color C; + float U, V; + + HASWVertex(const Vector3f& p, const Color& c = Color(64,0,0,255), float u = 0, float v = 0) + : Pos(p), C(c), U(u), V(v) + {} + + HASWVertex(float x, float y, float z, const Color& c = Color(64,0,0,255), float u = 0, float v = 0) + : Pos(x,y,z), C(c), U(u), V(v) + {} + + bool operator==(const HASWVertex& b) const + { + return (Pos == b.Pos) && (C == b.C) && (U == b.U) && (V == b.V); + } +}; + + + +// This is a temporary function implementation, and it functionality needs to be implemented in a more generic way. +Texture* LoadTextureTga(RenderParams& rParams, int samplerMode, OVR::File* f, uint8_t alpha) +{ + OVR::CAPI::GL::Texture* pTexture = NULL; + + int width, height; + const uint8_t* pRGBA = LoadTextureTgaData(f, alpha, width, height); + + if (pRGBA) + { + pTexture = new OVR::CAPI::GL::Texture(&rParams, width, height); + + // SetSampleMode forces the use of mipmaps through GL_LINEAR_MIPMAP_LINEAR. + pTexture->SetSampleMode(samplerMode); // Calls glBindTexture internally. + + // We are intentionally not using mipmaps. We need to use this because Texture::SetSampleMode unilaterally uses GL_LINEAR_MIPMAP_LINEAR. + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0); + OVR_ASSERT(glGetError() == 0); + + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pRGBA); + OVR_ASSERT(glGetError() == 0); + + // With OpenGL 4.2+ we can use this instead of glTexImage2D: + // glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, width, height); + // glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pRGBA); + + OVR_FREE(const_cast(pRGBA)); + } + + return pTexture; +} + + +// Loads a texture from a memory image of a TGA file. +Texture* LoadTextureTga(RenderParams& rParams, int samplerMode, const uint8_t* pData, int dataSize, uint8_t alpha) +{ + MemoryFile memoryFile("", pData, dataSize); + + return LoadTextureTga(rParams, samplerMode, &memoryFile, alpha); +} + + + + +// The texture below may conceivably be shared between HSWDisplay instances. However, +// beware that sharing may not be possible if two HMDs are using different locales +// simultaneously. As of this writing it's not clear if that can occur in practice. + +HSWDisplay::HSWDisplay(ovrRenderAPIType api, ovrHmd hmd, const HMDRenderState& renderState) + : OVR::CAPI::HSWDisplay(api, hmd, renderState) + , RenderParams() + , GLContext() + , FrameBuffer(0) + , pTexture() + , pShaderSet() + , pVertexShader() + , pFragmentShader() + , pVB() + , VAO(0) + , VAOInitialized(false) + , OrthoProjection() +{ +} + + +bool HSWDisplay::Initialize(const ovrRenderAPIConfig* apiConfig) +{ + const ovrGLConfig* config = (const ovrGLConfig*)apiConfig; + + if(config) + { + // The following is essentially copied from CAPI_GL_DistortionRender.cpp's + // Initialize function. To do: Merge this to a central location. + RenderParams.Multisample = config->OGL.Header.Multisample; + RenderParams.BackBufferSize = config->OGL.Header.BackBufferSize; + + #if defined(OVR_OS_WIN32) + RenderParams.Window = (config->OGL.Window) ? config->OGL.Window : GetActiveWindow(); + RenderParams.DC = config->OGL.DC; + #elif defined(OVR_OS_LINUX) + if (config->OGL.Disp) + { + RenderParams.Disp = config->OGL.Disp; + } + if (!RenderParams.Disp) + { + RenderParams.Disp = glXGetCurrentDisplay(); + } + if (!RenderParams.Disp) + { + OVR_DEBUG_LOG(("glXGetCurrentDisplay failed.")); + return false; + } + #endif + } + else + { + UnloadGraphics(); + } + + return true; +} + + +void HSWDisplay::Shutdown() +{ + UnloadGraphics(); +} + + +void HSWDisplay::DisplayInternal() +{ + HSWDISPLAY_LOG(("[HSWDisplay GL] DisplayInternal()")); + // We may want to call LoadGraphics here instead of within Render. +} + + +void HSWDisplay::DismissInternal() +{ + HSWDISPLAY_LOG(("[HSWDisplay GL] DismissInternal()")); + UnloadGraphicsRequested = true; // We don't directly call UnloadGraphics here because this may be executed within a different thread. +} + + +void HSWDisplay::UnloadGraphics() +{ + if(pTexture) // If initialized... + { + Context currentGLContext; + currentGLContext.InitFromCurrent(); + GLContext.Bind(); + + // RenderParams: No need to clear. + if(FrameBuffer != 0) + { + glDeleteFramebuffers(1, &FrameBuffer); + FrameBuffer = 0; + } + pTexture.Clear(); + pShaderSet.Clear(); + pVertexShader.Clear(); + pFragmentShader.Clear(); + pVB.Clear(); + if(VAO) + { + glDeleteVertexArrays(1, &VAO); + currentGLContext.Bind(); + GLContext.Destroy(); + } +} +} + + +void HSWDisplay::LoadGraphics() +{ + // We assume here that the current GL context is the one our resources will be associated with. + + if (FrameBuffer == 0) + { + glGenFramebuffers(1, &FrameBuffer); + } + + if (!pTexture) // To do: Add support for .dds files, which would be significantly smaller than the size of the tga. + { + size_t textureSize; + const uint8_t* TextureData = GetDefaultTexture(textureSize); + pTexture = *LoadTextureTga(RenderParams, Sample_Linear | Sample_Clamp, TextureData, (int)textureSize, 255); + } + + if (!pShaderSet) + { + pShaderSet = *new ShaderSet(); + } + + if(!pVertexShader) + { + OVR::String strShader((GLEContext::GetCurrentContext()->WholeVersion >= 302) ? glsl3Prefix : glsl2Prefix); + strShader += SimpleTexturedQuad_vs; + + pVertexShader = *new VertexShader(&RenderParams, const_cast(strShader.ToCStr()), strShader.GetLength(), SimpleTexturedQuad_vs_refl, OVR_ARRAY_COUNT(SimpleTexturedQuad_vs_refl)); + pShaderSet->SetShader(pVertexShader); + } + + if(!pFragmentShader) + { + OVR::String strShader((GLEContext::GetCurrentContext()->WholeVersion >= 302) ? glsl3Prefix : glsl2Prefix); + strShader += SimpleTexturedQuad_ps; + + pFragmentShader = *new FragmentShader(&RenderParams, const_cast(strShader.ToCStr()), strShader.GetLength(), SimpleTexturedQuad_ps_refl, OVR_ARRAY_COUNT(SimpleTexturedQuad_ps_refl)); + pShaderSet->SetShader(pFragmentShader); + } + + if(!pVB) + { + pVB = *new Buffer(&RenderParams); + + pVB->Data(Buffer_Vertex, NULL, 4 * sizeof(HASWVertex)); + HASWVertex* pVertices = (HASWVertex*)pVB->Map(0, 4 * sizeof(HASWVertex), Map_Discard); + OVR_ASSERT(pVertices); + + if(pVertices) + { + const bool flip = ((RenderState.DistortionCaps & ovrDistortionCap_FlipInput) != 0); + const float left = -1.0f; // We currently draw this in normalized device coordinates with an stereo translation + const float top = -1.1f; // applied as a vertex shader uniform. In the future when we have a more formal graphics + const float right = 1.0f; // API abstraction we may move this draw to an overlay layer or to a more formal + const float bottom = 0.9f; // model/mesh scheme with a perspective projection. + + pVertices[0] = HASWVertex(left, top, 0.f, Color(255, 255, 255, 255), 0.f, flip ? 1.f : 0.f); + pVertices[1] = HASWVertex(left, bottom, 0.f, Color(255, 255, 255, 255), 0.f, flip ? 0.f : 1.f); + pVertices[2] = HASWVertex(right, top, 0.f, Color(255, 255, 255, 255), 1.f, flip ? 1.f : 0.f); + pVertices[3] = HASWVertex(right, bottom, 0.f, Color(255, 255, 255, 255), 1.f, flip ? 0.f : 1.f); + + pVB->Unmap(pVertices); + } + } + + // We don't bind or initialize the vertex arrays here. + if (!VAO && GLE_ARB_vertex_array_object) + { + OVR_ASSERT(!VAOInitialized); + glGenVertexArrays(1, &VAO); + } +} + + +void HSWDisplay::RenderInternal(ovrEyeType eye, const ovrTexture* eyeTexture) +{ + if(RenderEnabled && eyeTexture) + { + // We need to render to the eyeTexture with the texture viewport. + // Setup rendering to the texture. + ovrGLTexture* eyeTextureGL = const_cast(reinterpret_cast(eyeTexture)); + OVR_ASSERT(eyeTextureGL->Texture.Header.API == ovrRenderAPI_OpenGL); + + GL::AutoContext autoGLContext(GLContext); // Saves the current GL context, binds our GLContext, then at the end of scope re-binds the current GL context. + + // Load the graphics if not loaded already. + if (!pTexture) + LoadGraphics(); + + // Calculate ortho projection. + GetOrthoProjection(RenderState, OrthoProjection); + + // Set the rendering to be to the eye texture. + glBindFramebuffer(GL_FRAMEBUFFER, FrameBuffer); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, eyeTextureGL->OGL.TexId, 0); + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, 0); // We aren't using depth, as we currently want this to overwrite everything. + GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER); + OVR_ASSERT(status == GL_FRAMEBUFFER_COMPLETE); OVR_UNUSED(status); + + // Set up the viewport + const GLint x = (GLint)eyeTextureGL->Texture.Header.RenderViewport.Pos.x; + const GLint y = (GLint)eyeTextureGL->Texture.Header.RenderViewport.Pos.y; // Note that GL uses bottom-up coordinates. + const GLsizei w = (GLsizei)eyeTextureGL->Texture.Header.RenderViewport.Size.w; + const GLsizei h = (GLsizei)eyeTextureGL->Texture.Header.RenderViewport.Size.h; + glViewport(x, y, w, h); + + // Set fixed-function render states. + //glDepthRange(0.0, 1.0); // This is the default + glDepthMask(GL_FALSE); + glDisable(GL_DEPTH_TEST); + glFrontFace(GL_CW); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + // Enable the buffer and shaders we use. + ShaderFill fill(pShaderSet); + if (pTexture) + fill.SetTexture(0, pTexture); + + // Set shader uniforms. + const float scale = HSWDISPLAY_SCALE * ((RenderState.OurHMDInfo.HmdType == HmdType_DK1) ? 0.70f : 1.f); + pShaderSet->SetUniform2f("Scale", scale, scale / 2.f); // X and Y scale. Y is a fixed proportion to X in order to give a certain aspect ratio. + pShaderSet->SetUniform2f("PositionOffset", OrthoProjection[eye].GetTranslation().x, 0.0f); + + // Set vertex attributes + if (GLE_ARB_vertex_array_object) + { + OVR_ASSERT(VAO != 0); + glBindVertexArray(VAO); + } + + if(!VAOInitialized) // This executes for the case that VAO isn't supported. + { + glBindBuffer(GL_ARRAY_BUFFER, pVB->GLBuffer); // This must be called before glVertexAttribPointer is called below. + + const GLuint shaderProgram = pShaderSet->Prog; + GLint attributeLocationArray[3]; + + attributeLocationArray[0] = glGetAttribLocation(shaderProgram, "Position"); + glVertexAttribPointer(attributeLocationArray[0], sizeof(Vector3f)/sizeof(float), GL_FLOAT, false, sizeof(HASWVertex), reinterpret_cast(offsetof(HASWVertex, Pos))); + + attributeLocationArray[1] = glGetAttribLocation(shaderProgram, "Color"); + glVertexAttribPointer(attributeLocationArray[1], sizeof(Color)/sizeof(uint8_t), GL_UNSIGNED_BYTE, true, sizeof(HASWVertex), reinterpret_cast(offsetof(HASWVertex, C))); // True because we want it to convert [0,255] to [0,1] for us. + + attributeLocationArray[2] = glGetAttribLocation(shaderProgram, "TexCoord"); + glVertexAttribPointer(attributeLocationArray[2], sizeof(float[2])/sizeof(float), GL_FLOAT, false, sizeof(HASWVertex), reinterpret_cast(offsetof(HASWVertex, U))); + + for (size_t i = 0; i < OVR_ARRAY_COUNT(attributeLocationArray); i++) + glEnableVertexAttribArray((GLuint)i); + } + + fill.Set(Prim_TriangleStrip); + + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + + if (GLE_ARB_vertex_array_object) + { + VAOInitialized = true; + glBindVertexArray(0); + } + } +} + + +}}} // namespace OVR::CAPI::GL diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/CAPI/GL/CAPI_GL_HSWDisplay.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/CAPI/GL/CAPI_GL_HSWDisplay.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,77 @@ +/************************************************************************************ + +Filename : CAPI_GL_HSWDisplay.h +Content : Implements Health and Safety Warning system. +Created : July 7, 2014 +Authors : Paul Pedriana + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#ifndef OVR_CAPI_GL_HSWDisplay_h +#define OVR_CAPI_GL_HSWDisplay_h + + +#include "../CAPI_HSWDisplay.h" +#include "CAPI_GL_Util.h" + + +namespace OVR { namespace CAPI { namespace GL { + + class HSWDisplay : public CAPI::HSWDisplay + { + public: + HSWDisplay(ovrRenderAPIType api, ovrHmd hmd, const HMDRenderState& renderState); + + // Must be called before use. apiConfig is such that: + // const ovrGLConfig* config = (const ovrGLConfig*)apiConfig; or + bool Initialize(const ovrRenderAPIConfig* apiConfig); + void Shutdown(); + void DisplayInternal(); + void DismissInternal(); + + // Draws the warning to the eye texture(s). This must be done at the end of a + // frame but prior to executing the distortion rendering of the eye textures. + void RenderInternal(ovrEyeType eye, const ovrTexture* eyeTexture); + + protected: + void UnloadGraphics(); + void LoadGraphics(); + + OVR::CAPI::GL::RenderParams RenderParams; + OVR::CAPI::GL::Context GLContext; // Our prive OpenGL context for drawing. + GLuint FrameBuffer; // This is a container for a texture, depth buffer, stencil buffer to be rendered to. To consider: Make a wrapper class, like the OculusWorldDemo RBuffer class. + Ptr pTexture; + Ptr pShaderSet; + Ptr pVertexShader; + Ptr pFragmentShader; + Ptr pVB; + GLuint VAO; // Vertex Array Object. + bool VAOInitialized; // True if the VAO was initialized with vertex buffer data. + Matrix4f OrthoProjection[2]; // Projection for 2D. + + private: + OVR_NON_COPYABLE(HSWDisplay) + }; + +}}} // namespace OVR::CAPI::GL + + +#endif // OVR_CAPI_GL_HSWDisplay_h + diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/CAPI/GL/CAPI_GL_Util.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/CAPI/GL/CAPI_GL_Util.cpp Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,571 @@ +/************************************************************************************ + +Filename : CAPI_GL_Util.cpp +Content : RenderDevice implementation for OpenGL +Created : September 10, 2012 +Authors : David Borel, Andrew Reisse + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#include "CAPI_GL_Util.h" +#include "../../Kernel/OVR_Log.h" +#include + +#if defined(OVR_OS_LINUX) + #include "../../Displays/OVR_Linux_SDKWindow.h" +#endif + +#if defined(OVR_OS_MAC) + #include + #include + +typedef void *CGSConnectionID; +typedef int32_t CGSWindowID; +typedef int32_t CGSSurfaceID; + +extern "C" CGLError CGLGetSurface(CGLContextObj ctx, CGSConnectionID *cid, CGSWindowID *wid, CGSSurfaceID *sid); +extern "C" CGLError CGLSetSurface(CGLContextObj ctx, CGSConnectionID cid, CGSWindowID wid, CGSSurfaceID sid); +#endif + + + + +namespace OVR { + + +OVR::GLEContext gleContext; + + +OVR::GLEContext* GetGLEContext() +{ + return &gleContext; +} + + +namespace CAPI { namespace GL { + + +void InitGLExtensions() +{ + if(!gleContext.IsInitialized()) + { + gleContext.SetCurrentContext(&gleContext); + gleContext.Init(); + } +} + + +Buffer::Buffer(RenderParams* rp) : pParams(rp), Size(0), Use(0), GLBuffer(0) +{ +} + +Buffer::~Buffer() +{ + if (GLBuffer) + glDeleteBuffers(1, &GLBuffer); +} + +bool Buffer::Data(int use, const void* buffer, size_t size) +{ + Size = size; + + switch (use & Buffer_TypeMask) + { + case Buffer_Index: Use = GL_ELEMENT_ARRAY_BUFFER; break; + default: Use = GL_ARRAY_BUFFER; break; + } + + if (!GLBuffer) + glGenBuffers(1, &GLBuffer); + + int mode = GL_DYNAMIC_DRAW; + if (use & Buffer_ReadOnly) + mode = GL_STATIC_DRAW; + + glBindBuffer(Use, GLBuffer); + glBufferData(Use, size, buffer, mode); + return 1; +} + +void* Buffer::Map(size_t, size_t, int) +{ + int mode = GL_WRITE_ONLY; + //if (flags & Map_Unsynchronized) + // mode |= GL_MAP_UNSYNCHRONIZED; + + glBindBuffer(Use, GLBuffer); + void* v = glMapBuffer(Use, mode); + return v; +} + +bool Buffer::Unmap(void*) +{ + glBindBuffer(Use, GLBuffer); + int r = glUnmapBuffer(Use); + return r != 0; +} + +ShaderSet::ShaderSet() : + //Shaders[], + UniformInfo(), + //Prog(0) + ProjLoc(0), + ViewLoc(0), + //TexLoc[], + UsesLighting(false), + LightingVer(0) +{ + memset(TexLoc, 0, sizeof(TexLoc)); + Prog = glCreateProgram(); +} +ShaderSet::~ShaderSet() +{ + glDeleteProgram(Prog); +} + +GLint ShaderSet::GetGLShader(Shader* s) +{ + switch (s->Stage) + { + case Shader_Vertex: { + ShaderImpl* gls = (ShaderImpl*)s; + return gls->GLShader; + } break; + case Shader_Fragment: { + ShaderImpl* gls = (ShaderImpl*)s; + return gls->GLShader; + } break; + default: break; + } + + return -1; +} + +void ShaderSet::SetShader(Shader *s) +{ + Shaders[s->Stage] = s; + GLint GLShader = GetGLShader(s); + glAttachShader(Prog, GLShader); + if (Shaders[Shader_Vertex] && Shaders[Shader_Fragment]) + Link(); +} + +void ShaderSet::UnsetShader(int stage) +{ + if (Shaders[stage] == NULL) + return; + + GLint GLShader = GetGLShader(Shaders[stage]); + glDetachShader(Prog, GLShader); + + Shaders[stage] = NULL; +} + +bool ShaderSet::SetUniform(const char* name, int n, const float* v) +{ + for (unsigned int i = 0; i < UniformInfo.GetSize(); i++) + if (!strcmp(UniformInfo[i].Name.ToCStr(), name)) + { + OVR_ASSERT(UniformInfo[i].Location >= 0); + glUseProgram(Prog); + switch (UniformInfo[i].Type) + { + case 1: glUniform1fv(UniformInfo[i].Location, n, v); break; + case 2: glUniform2fv(UniformInfo[i].Location, n/2, v); break; + case 3: glUniform3fv(UniformInfo[i].Location, n/3, v); break; + case 4: glUniform4fv(UniformInfo[i].Location, n/4, v); break; + case 12: glUniformMatrix3fv(UniformInfo[i].Location, 1, 1, v); break; + case 16: glUniformMatrix4fv(UniformInfo[i].Location, 1, 1, v); break; + default: OVR_ASSERT(0); + } + return 1; + } + + OVR_DEBUG_LOG(("Warning: uniform %s not present in selected shader", name)); + return 0; +} + +bool ShaderSet::Link() +{ + glLinkProgram(Prog); + GLint r; + glGetProgramiv(Prog, GL_LINK_STATUS, &r); + if (!r) + { + GLchar msg[1024]; + glGetProgramInfoLog(Prog, sizeof(msg), 0, msg); + OVR_DEBUG_LOG(("Linking shaders failed: %s\n", msg)); + if (!r) + return 0; + } + glUseProgram(Prog); + + UniformInfo.Clear(); + LightingVer = 0; + UsesLighting = 0; + + GLint uniformCount = 0; + glGetProgramiv(Prog, GL_ACTIVE_UNIFORMS, &uniformCount); + OVR_ASSERT(uniformCount >= 0); + + for(GLuint i = 0; i < (GLuint)uniformCount; i++) + { + GLsizei namelen; + GLint size = 0; + GLenum type; + GLchar name[32]; + glGetActiveUniform(Prog, i, sizeof(name), &namelen, &size, &type, name); + + if (size) + { + int l = glGetUniformLocation(Prog, name); + char *np = name; + while (*np) + { + if (*np == '[') + *np = 0; + np++; + } + Uniform u; + u.Name = name; + u.Location = l; + u.Size = size; + switch (type) + { + case GL_FLOAT: u.Type = 1; break; + case GL_FLOAT_VEC2: u.Type = 2; break; + case GL_FLOAT_VEC3: u.Type = 3; break; + case GL_FLOAT_VEC4: u.Type = 4; break; + case GL_FLOAT_MAT3: u.Type = 12; break; + case GL_FLOAT_MAT4: u.Type = 16; break; + default: + continue; + } + UniformInfo.PushBack(u); + if (!strcmp(name, "LightCount")) + UsesLighting = 1; + } + else + break; + } + + ProjLoc = glGetUniformLocation(Prog, "Proj"); + ViewLoc = glGetUniformLocation(Prog, "View"); + for (int i = 0; i < 8; i++) + { + char texv[32]; + OVR_sprintf(texv, 10, "Texture%d", i); + TexLoc[i] = glGetUniformLocation(Prog, texv); + if (TexLoc[i] < 0) + break; + + glUniform1i(TexLoc[i], i); + } + if (UsesLighting) + OVR_ASSERT(ProjLoc >= 0 && ViewLoc >= 0); + return 1; +} + +bool ShaderBase::SetUniform(const char* name, int n, const float* v) +{ + for(unsigned i = 0; i < UniformReflSize; i++) + { + if (!strcmp(UniformRefl[i].Name, name)) + { + memcpy(UniformData + UniformRefl[i].Offset, v, n * sizeof(float)); + return 1; + } + } + return 0; +} + +bool ShaderBase::SetUniformBool(const char* name, int n, const bool* v) +{ + OVR_UNUSED(n); + for(unsigned i = 0; i < UniformReflSize; i++) + { + if (!strcmp(UniformRefl[i].Name, name)) + { + memcpy(UniformData + UniformRefl[i].Offset, v, UniformRefl[i].Size); + return 1; + } + } + return 0; +} + +void ShaderBase::InitUniforms(const Uniform* refl, size_t reflSize) +{ + if(!refl) + { + UniformRefl = NULL; + UniformReflSize = 0; + + UniformsSize = 0; + if (UniformData) + { + OVR_FREE(UniformData); + UniformData = 0; + } + return; // no reflection data + } + + UniformRefl = refl; + UniformReflSize = reflSize; + + UniformsSize = UniformRefl[UniformReflSize-1].Offset + UniformRefl[UniformReflSize-1].Size; + UniformData = (unsigned char*)OVR_ALLOC(UniformsSize); +} + +Texture::Texture(RenderParams* rp, int w, int h) : IsUserAllocated(false), pParams(rp), TexId(0), Width(w), Height(h) +{ + if (w && h) + glGenTextures(1, &TexId); +} + +Texture::~Texture() +{ + if (TexId && !IsUserAllocated) + glDeleteTextures(1, &TexId); +} + +void Texture::Set(int slot, ShaderStage) const +{ + glActiveTexture(GL_TEXTURE0 + slot); + glBindTexture(GL_TEXTURE_2D, TexId); +} + +void Texture::SetSampleMode(int sm) +{ + glBindTexture(GL_TEXTURE_2D, TexId); + switch (sm & Sample_FilterMask) + { + case Sample_Linear: + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + if(GLE_EXT_texture_filter_anisotropic) + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1); + break; + + case Sample_Anisotropic: + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + if(GLE_EXT_texture_filter_anisotropic) + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 8); + break; + + case Sample_Nearest: + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + if(GLE_EXT_texture_filter_anisotropic) + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1); + break; + } + + switch (sm & Sample_AddressMask) + { + case Sample_Repeat: + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); + break; + + case Sample_Clamp: + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + break; + + case Sample_ClampBorder: + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); + break; + } +} + +void Texture::UpdatePlaceholderTexture(GLuint texId, const Sizei& textureSize) +{ + if (!IsUserAllocated && TexId && texId != TexId) + glDeleteTextures(1, &TexId); + + TexId = texId; + Width = textureSize.w; + Height = textureSize.h; + + IsUserAllocated = true; +} + + + + + +Context::Context() : initialized(false), ownsContext(true), incarnation(0) +{ +#if defined(OVR_OS_MAC) + systemContext = 0; +#elif defined(OVR_OS_WIN32) + hdc = 0; + systemContext = 0; +#elif defined(OVR_OS_LINUX) + x11Display = NULL; + x11Drawable = 0; + systemContext = 0; + memset(&x11Visual, 0, sizeof(x11Visual)); +#endif + +} + +void Context::InitFromCurrent() +{ + Destroy(); + + initialized = true; + ownsContext = false; + incarnation++; + +#if defined(OVR_OS_MAC) + systemContext = CGLGetCurrentContext(); + { + CGSConnectionID cid; + CGSWindowID wid; + CGSSurfaceID sid; + CGLError e = kCGLNoError; + e = CGLGetSurface(systemContext, &cid, &wid, &sid); + OVR_ASSERT(e == kCGLNoError); OVR_UNUSED(e); + } + +#elif defined(OVR_OS_WIN32) + hdc = wglGetCurrentDC(); + systemContext = wglGetCurrentContext(); +#elif defined(OVR_OS_LINUX) + x11Display = glXGetCurrentDisplay(); + x11Drawable = glXGetCurrentDrawable(); + systemContext = glXGetCurrentContext(); + if (!SDKWindow::getVisualFromDrawable(x11Drawable, &x11Visual)) + { + OVR::LogError("[Context] Unable to obtain x11 visual from context"); + memset(&x11Visual, 0, sizeof(x11Visual)); + } +#endif +} + + +void Context::CreateShared( Context & ctx ) +{ + Destroy(); + OVR_ASSERT( ctx.initialized == true ); + if( ctx.initialized == false ) + { + return; + } + + initialized = true; + ownsContext = true; + incarnation++; + +#if defined(OVR_OS_MAC) + CGLPixelFormatObj pixelFormat = CGLGetPixelFormat( ctx.systemContext ); + CGLError e = CGLCreateContext( pixelFormat, ctx.systemContext, &systemContext ); + OVR_ASSERT(e == kCGLNoError); OVR_UNUSED(e); + SetSurface(ctx); +#elif defined(OVR_OS_WIN32) + hdc = ctx.hdc; + systemContext = wglCreateContext( ctx.hdc ); + BOOL success = wglShareLists(ctx.systemContext, systemContext ); + OVR_ASSERT( success == TRUE ); + OVR_UNUSED(success); +#elif defined(OVR_OS_LINUX) + x11Display = ctx.x11Display; + x11Drawable = ctx.x11Drawable; + x11Visual = ctx.x11Visual; + systemContext = glXCreateContext( ctx.x11Display, &x11Visual, ctx.systemContext, True ); + OVR_ASSERT( systemContext != NULL ); +#endif +} + +#if defined(OVR_OS_MAC) +void Context::SetSurface( Context & ctx ) { + CGLError e = kCGLNoError; + CGSConnectionID cid, cid2; + CGSWindowID wid, wid2; + CGSSurfaceID sid, sid2; + + e = CGLGetSurface(ctx.systemContext, &cid, &wid, &sid); + OVR_ASSERT(e == kCGLNoError); OVR_UNUSED(e); + e = CGLGetSurface(systemContext, &cid2, &wid2, &sid2); + OVR_ASSERT(e == kCGLNoError); OVR_UNUSED(e); + if( sid && sid != sid2 ) { + e = CGLSetSurface(systemContext, cid, wid, sid); + OVR_ASSERT(e == kCGLNoError); OVR_UNUSED(e); + } +} +#endif + +void Context::Destroy() +{ + if( initialized == false ) + { + return; + } + + if (systemContext) + { +#if defined(OVR_OS_MAC) + CGLDestroyContext( systemContext ); +#elif defined(OVR_OS_WIN32) + BOOL success = wglDeleteContext( systemContext ); + OVR_ASSERT( success == TRUE ); + OVR_UNUSED( success ); +#elif defined(OVR_OS_LINUX) + glXDestroyContext( x11Display, systemContext ); +#endif + + systemContext = NULL; + } + + initialized = false; + ownsContext = true; +} + +void Context::Bind() +{ + if(systemContext) + { +#if defined(OVR_OS_MAC) + glFlush(); //Apple doesn't automatically flush within CGLSetCurrentContext, unlike other platforms. + CGLSetCurrentContext( systemContext ); +#elif defined(OVR_OS_WIN32) + wglMakeCurrent( hdc, systemContext ); +#elif defined(OVR_OS_LINUX) + glXMakeCurrent( x11Display, x11Drawable, systemContext ); +#endif + } +} + +void Context::Unbind() +{ +#if defined(OVR_OS_MAC) + glFlush(); //Apple doesn't automatically flush within CGLSetCurrentContext, unlike other platforms. + CGLSetCurrentContext( NULL ); +#elif defined(OVR_OS_WIN32) + wglMakeCurrent( hdc, NULL ); +#elif defined(OVR_OS_LINUX) + glXMakeCurrent( x11Display, None, NULL ); +#endif +} + +}}} // namespace OVR::CAPI::GL diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/CAPI/GL/CAPI_GL_Util.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/CAPI/GL/CAPI_GL_Util.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,553 @@ +/************************************************************************************ + +Filename : CAPI_GL_Util.h +Content : Utility header for OpenGL +Created : March 27, 2014 +Authors : Andrew Reisse, David Borel + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#ifndef INC_OVR_CAPI_GL_Util_h +#define INC_OVR_CAPI_GL_Util_h + +#include "../../OVR_CAPI.h" +#include "../../Kernel/OVR_Array.h" +#include "../../Kernel/OVR_Math.h" +#include "../../Kernel/OVR_RefCount.h" +#include "../../Kernel/OVR_String.h" +#include "../../Kernel/OVR_Types.h" +#include "../../Kernel/OVR_Log.h" + +#if defined(OVR_OS_WIN32) +#define WIN32_LEAN_AND_MEAN +#include +#endif + +#if !defined(OVR_DISABLE_GLE) // By default we use the GLE module in order to link to OpenGL functions. However, if an external user +#include "CAPI_GLE.h" // wants to use an alternative mechanism to connect to OpenGL functions, they can #define OVR_DISABLE_GLE. +#endif + + +#if defined(OVR_OS_MAC) + #include + #include +#endif + + +namespace OVR +{ + // Get the shared LibOVR GLEContext instance. + class GLEContext; + GLEContext* GetGLEContext(); +} + +namespace OVR { namespace CAPI { namespace GL { +void InitGLExtensions(); + + +// Rendering primitive type used to render Model. +enum PrimitiveType +{ + Prim_Triangles, + Prim_Lines, + Prim_TriangleStrip, + Prim_Unknown, + Prim_Count +}; + +// Types of shaders that can be stored together in a ShaderSet. +enum ShaderStage +{ + Shader_Vertex = 0, + Shader_Fragment = 2, + Shader_Pixel = 2, + Shader_Count = 3, +}; + +enum MapFlags +{ + Map_Discard = 1, + Map_Read = 2, // do not use + Map_Unsynchronized = 4, // like D3D11_MAP_NO_OVERWRITE +}; + + +// Buffer types used for uploading geometry & constants. +enum BufferUsage +{ + Buffer_Unknown = 0, + Buffer_Vertex = 1, + Buffer_Index = 2, + Buffer_Uniform = 4, + Buffer_TypeMask = 0xff, + Buffer_ReadOnly = 0x100, // Buffer must be created with Data(). +}; + +enum TextureFormat +{ + Texture_RGBA = 0x0100, + Texture_Depth = 0x8000, + Texture_TypeMask = 0xff00, + Texture_SamplesMask = 0x00ff, + Texture_RenderTarget = 0x10000, + Texture_GenMipmaps = 0x20000, +}; + +// Texture sampling modes. +enum SampleMode +{ + Sample_Linear = 0, + Sample_Nearest = 1, + Sample_Anisotropic = 2, + Sample_FilterMask = 3, + + Sample_Repeat = 0, + Sample_Clamp = 4, + Sample_ClampBorder = 8, // If unsupported Clamp is used instead. + Sample_AddressMask =12, + + Sample_Count =13, +}; + + +// Rendering parameters/pointers describing GL rendering setup. +struct RenderParams +{ +#if defined(OVR_OS_WIN32) + HWND Window; + HDC DC; +#elif defined(OVR_OS_LINUX) + struct _XDisplay* Disp; +#endif + + ovrSizei BackBufferSize; + int Multisample; +}; + + +class Buffer : public RefCountBase +{ +public: + RenderParams* pParams; + size_t Size; + GLenum Use; + GLuint GLBuffer; + +public: + Buffer(RenderParams* r); + ~Buffer(); + + GLuint GetBuffer() { return GLBuffer; } + + virtual size_t GetSize() { return Size; } + virtual void* Map(size_t start, size_t size, int flags = 0); + virtual bool Unmap(void *m); + virtual bool Data(int use, const void* buffer, size_t size); +}; + +class Texture : public RefCountBase +{ + bool IsUserAllocated; + +public: + RenderParams* pParams; + GLuint TexId; + int Width, Height; + + Texture(RenderParams* rp, int w, int h); + ~Texture(); + + virtual int GetWidth() const { return Width; } + virtual int GetHeight() const { return Height; } + + virtual void SetSampleMode(int sm); + + // Updates texture to point to specified resources + // - used for slave rendering. + void UpdatePlaceholderTexture(GLuint texId, + const Sizei& textureSize); + + virtual void Set(int slot, ShaderStage stage = Shader_Fragment) const; +}; + +// Base class for vertex and pixel shaders. Stored in ShaderSet. +class Shader : public RefCountBase +{ + friend class ShaderSet; + +protected: + ShaderStage Stage; + +public: + Shader(ShaderStage s) : Stage(s) {} + virtual ~Shader() {} + + ShaderStage GetStage() const { return Stage; } + + virtual void Set(PrimitiveType) const { } + virtual void SetUniformBuffer(class Buffer* buffers, int i = 0) { OVR_UNUSED2(buffers, i); } + +protected: + virtual bool SetUniform(const char* name, int n, const float* v) { OVR_UNUSED3(name, n, v); return false; } + virtual bool SetUniformBool(const char* name, int n, const bool* v) { OVR_UNUSED3(name, n, v); return false; } +}; + + + +// A group of shaders, one per stage. +// A ShaderSet is applied for rendering with a given fill. +class ShaderSet : public RefCountBase +{ +protected: + Ptr Shaders[Shader_Count]; + + struct Uniform + { + String Name; + int Location, Size; + int Type; // currently number of floats in vector + + Uniform() : Name(), Location(0), Size(0), Type(0){} + }; + Array UniformInfo; + +public: + GLuint Prog; + GLint ProjLoc, ViewLoc; + GLint TexLoc[8]; + bool UsesLighting; + int LightingVer; + + ShaderSet(); + ~ShaderSet(); + + virtual void SetShader(Shader *s); + virtual void UnsetShader(int stage); + Shader* GetShader(int stage) { return Shaders[stage]; } + + virtual void Set(PrimitiveType prim) const + { + glUseProgram(Prog); + + for (int i = 0; i < Shader_Count; i++) + if (Shaders[i]) + Shaders[i]->Set(prim); + } + + // Set a uniform (other than the standard matrices). It is undefined whether the + // uniforms from one shader occupy the same space as those in other shaders + // (unless a buffer is used, then each buffer is independent). + virtual bool SetUniform(const char* name, int n, const float* v); + bool SetUniform1f(const char* name, float x) + { + const float v[] = {x}; + return SetUniform(name, 1, v); + } + bool SetUniform2f(const char* name, float x, float y) + { + const float v[] = {x,y}; + return SetUniform(name, 2, v); + } + bool SetUniform3f(const char* name, float x, float y, float z) + { + const float v[] = {x,y,z}; + return SetUniform(name, 3, v); + } + bool SetUniform4f(const char* name, float x, float y, float z, float w = 1) + { + const float v[] = {x,y,z,w}; + return SetUniform(name, 4, v); + } + + bool SetUniformv(const char* name, const Vector3f& v) + { + const float a[] = {v.x,v.y,v.z,1}; + return SetUniform(name, 4, a); + } + + virtual bool SetUniform4x4f(const char* name, const Matrix4f& m) + { + Matrix4f mt = m.Transposed(); + return SetUniform(name, 16, &mt.M[0][0]); + } + + virtual bool SetUniform3x3f(const char* name, const Matrix4f& m) + { + Matrix4f mt = m.Transposed(); + // float3x3 is actually stored the same way as float4x3, with the last items ignored by the code. + return SetUniform(name, 12, &mt.M[0][0]); + } + + +protected: + GLint GetGLShader(Shader* s); + bool Link(); +}; + + +// Fill combines a ShaderSet (vertex, pixel) with textures, if any. +// Every model has a fill. +class ShaderFill : public RefCountBase +{ + Ptr Shaders; + Ptr Textures[8]; + void* InputLayout; // HACK this should be abstracted + +public: + ShaderFill(ShaderSet* sh) : Shaders(sh) { InputLayout = NULL; } + ShaderFill(ShaderSet& sh) : Shaders(sh) { InputLayout = NULL; } + + ShaderSet* GetShaders() const { return Shaders; } + void* GetInputLayout() const { return InputLayout; } + + virtual void Set(PrimitiveType prim = Prim_Unknown) const { + Shaders->Set(prim); + for(int i = 0; i < 8; i++) + { + if(Textures[i]) + { + Textures[i]->Set(i); + } + } + } + + virtual void SetTexture(int i, class Texture* tex) { if (i < 8) Textures[i] = tex; } +}; + + +struct DisplayId +{ + // Windows + String MonitorName; // Monitor name for fullscreen mode + + // MacOS + long CgDisplayId; // CGDirectDisplayID + + DisplayId() : CgDisplayId(0) {} + DisplayId(long id) : CgDisplayId(id) {} + DisplayId(String m, long id=0) : MonitorName(m), CgDisplayId(id) {} + + operator bool () const + { + return MonitorName.GetLength() || CgDisplayId; + } + + bool operator== (const DisplayId& b) const + { + return CgDisplayId == b.CgDisplayId && + (strstr(MonitorName.ToCStr(), b.MonitorName.ToCStr()) || + strstr(b.MonitorName.ToCStr(), MonitorName.ToCStr())); + } +}; + + +class ShaderBase : public Shader +{ +public: + RenderParams* pParams; + unsigned char* UniformData; + int UniformsSize; + + enum VarType + { + VARTYPE_FLOAT, + VARTYPE_INT, + VARTYPE_BOOL, + }; + + struct Uniform + { + const char* Name; + VarType Type; + int Offset; + int Size; + }; + + const Uniform* UniformRefl; + size_t UniformReflSize; + + ShaderBase(RenderParams* rp, ShaderStage stage) : + Shader(stage), + pParams(rp), + UniformData(NULL), + UniformsSize(0), + UniformRefl(NULL), + UniformReflSize(0) + { + } + ~ShaderBase() + { + if (UniformData) + { + OVR_FREE(UniformData); + UniformData = NULL; + } + + // Do not need to free UniformRefl + UniformRefl = NULL; + } + + void InitUniforms(const Uniform* refl, size_t reflSize); + bool SetUniform(const char* name, int n, const float* v); + bool SetUniformBool(const char* name, int n, const bool* v); +}; + + +template +class ShaderImpl : public ShaderBase +{ + friend class ShaderSet; + +public: + ShaderImpl(RenderParams* rp, void* s, size_t size, const Uniform* refl, size_t reflSize) + : ShaderBase(rp, SStage) + , GLShader(0) + { + bool success; + OVR_UNUSED(size); + success = Compile((const char*) s); + OVR_ASSERT(success); + OVR_UNUSED(success); + InitUniforms(refl, reflSize); + } + ~ShaderImpl() + { + if (GLShader) + { + glDeleteShader(GLShader); + GLShader = 0; + } + } + bool Compile(const char* src) + { + if (!GLShader) + GLShader = glCreateShader(GLStage()); + + glShaderSource(GLShader, 1, &src, 0); + glCompileShader(GLShader); + GLint r; + glGetShaderiv(GLShader, GL_COMPILE_STATUS, &r); + if (!r) + { + GLchar msg[1024]; + glGetShaderInfoLog(GLShader, sizeof(msg), 0, msg); + if (msg[0]) + OVR_DEBUG_LOG(("Compiling shader\n%s\nfailed: %s\n", src, msg)); + + return 0; + } + return 1; + } + + GLenum GLStage() const + { + return SType; + } + +private: + GLuint GLShader; +}; + +typedef ShaderImpl VertexShader; +typedef ShaderImpl FragmentShader; + + + +// Allows us to have independent OpenGL contexts for our systems. +class Context +{ + bool initialized; + bool ownsContext; + int incarnation; +#if defined(OVR_OS_WIN32) + HDC hdc; + HGLRC systemContext; +#elif defined(OVR_OS_LINUX) + Display *x11Display; + GLXDrawable x11Drawable; + GLXContext systemContext; + XVisualInfo x11Visual; +#elif defined(OVR_OS_MAC) + CGLContextObj systemContext; +#endif + +public: + + Context(); + void InitFromCurrent(); + void CreateShared( Context & ctx ); +#if defined(OVR_OS_MAC) + void SetSurface( Context & ctx ); +#endif + void Destroy(); + void Bind(); + void Unbind(); + int GetIncarnation() const { return incarnation; } + +}; + + +// AutoContext +// +// Implements a common sequence of function calls with the Context class. +// See the AutoContext constructor below for what it does. +// +// Example usage: +// void SomeClass::Draw() +// { +// AutoContext autoContext(someClassContext); +// +// +// } + +struct AutoContext +{ + Context savedCurrentContext; + Context& ourContext; + + AutoContext(Context& context) : + savedCurrentContext(), ourContext(context) + { + // We use a member savedCurrentContext which is initialized here, as opposed to having the user pass in a + // pre-existing Context (which the user could declare as a global or C++ member variable). We have to do this + // because if we were to use some pre-existing Context the app might delete its underlying GL context behind our back + // or associate it with another thread, which would cause our bind of it in our dtor to be a bad operation. + savedCurrentContext.InitFromCurrent(); + if(ourContext.GetIncarnation() == 0) // If not yet initialized... + ourContext.CreateShared(savedCurrentContext); + ourContext.Bind(); + #if defined(OVR_OS_MAC) // To consider: merge the following into the Bind function. + ourContext.SetSurface(savedCurrentContext); + #endif + } + + ~AutoContext() + { + savedCurrentContext.Bind(); + } + + OVR_NON_COPYABLE(AutoContext) +}; + + +}}} // namespace OVR::CAPI::GL + + +#endif // INC_OVR_CAPI_GL_Util_h diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/CAPI/Textures/healthAndSafety.tga.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/CAPI/Textures/healthAndSafety.tga.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,3363 @@ +const uint8_t healthAndSafety_tga[107525] = { + 0x00,0x00,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x02,0x20,0x08,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xc7,0x00,0x00,0x00,0xb3,0x81,0x7e,0x7e,0x7e,0xc7,0x00,0x52,0x52,0x52,0xbd, + 0x9f,0x00,0x00,0x00,0xb3,0x00,0x33,0x33,0x33,0xb8,0x81,0x7e,0x7e,0x7e,0xc7,0x00,0x33,0x33,0x33,0xb8,0xff,0x00,0x00,0x00,0xb3,0x00,0x00,0x00,0x00,0xb3,0x82,0x7e, + 0x7e,0x7e,0xc7,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0x8c,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xc6,0x00,0x00,0x00,0xb3,0x00,0xd2,0xd2,0xd2,0xe6,0x82,0xff,0xff,0xff,0xff,0x01,0xdc,0xdc,0xdc,0xeb,0x33,0x33,0x33,0xb8,0x9d,0x00, + 0x00,0x00,0xb3,0x00,0xf7,0xf7,0xf7,0xfa,0x82,0xff,0xff,0xff,0xff,0x00,0xbb,0xbb,0xbb,0xdc,0xfc,0x00,0x00,0x00,0xb3,0x01,0x52,0x52,0x52,0xbd,0xd2,0xd2,0xd2,0xe6, + 0x84,0xff,0xff,0xff,0xff,0x00,0xbb,0xbb,0xbb,0xdc,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0x8a,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xc6,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x83,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf, + 0xd6,0x9d,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x83,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0xfb,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x86, + 0xff,0xff,0xff,0xff,0x00,0xc7,0xc7,0xc7,0xe1,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0x89,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xc6,0x00,0x00,0x00,0xb3,0x05,0x52,0x52,0x52,0xbd,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0xe6,0xe6, + 0xe6,0xf0,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0x9d,0x00,0x00,0x00,0xb3,0x05,0x52,0x52,0x52,0xbd,0x00,0x00,0x00,0xb3,0x6a,0x6a,0x6a,0xc2,0xf7,0xf7,0xf7,0xfa, + 0xff,0xff,0xff,0xff,0xd2,0xd2,0xd2,0xe6,0xfc,0x00,0x00,0x00,0xb3,0x05,0xef,0xef,0xef,0xf5,0xe6,0xe6,0xe6,0xf0,0xa0,0xa0,0xa0,0xd1,0x7e,0x7e,0x7e,0xc7,0xa0,0xa0, + 0xa0,0xd1,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x00,0x52,0x52,0x52,0xbd,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0x88, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0x96,0x00,0x00,0x00,0xb3,0x02,0x6a,0x6a,0x6a,0xc2,0x7e,0x7e,0x7e, + 0xc7,0x52,0x52,0x52,0xbd,0x84,0x00,0x00,0x00,0xb3,0x00,0x6a,0x6a,0x6a,0xc2,0x81,0x7e,0x7e,0x7e,0xc7,0x84,0x00,0x00,0x00,0xb3,0x00,0x33,0x33,0x33,0xb8,0x81,0x7e, + 0x7e,0x7e,0xc7,0x00,0x52,0x52,0x52,0xbd,0x89,0x00,0x00,0x00,0xb3,0x02,0x33,0x33,0x33,0xb8,0x7e,0x7e,0x7e,0xc7,0x6a,0x6a,0x6a,0xc2,0x91,0x00,0x00,0x00,0xb3,0x00, + 0x90,0x90,0x90,0xcc,0x81,0xff,0xff,0xff,0xff,0x00,0xa0,0xa0,0xa0,0xd1,0x95,0x00,0x00,0x00,0xb3,0x00,0x33,0x33,0x33,0xb8,0x81,0x7e,0x7e,0x7e,0xc7,0x86,0x00,0x00, + 0x00,0xb3,0x00,0xbb,0xbb,0xbb,0xdc,0x81,0xff,0xff,0xff,0xff,0x00,0x52,0x52,0x52,0xbd,0x8a,0x00,0x00,0x00,0xb3,0x00,0x33,0x33,0x33,0xb8,0x81,0x7e,0x7e,0x7e,0xc7, + 0x00,0x33,0x33,0x33,0xb8,0x83,0x00,0x00,0x00,0xb3,0x00,0x52,0x52,0x52,0xbd,0x81,0x7e,0x7e,0x7e,0xc7,0x8b,0x00,0x00,0x00,0xb3,0x02,0x6a,0x6a,0x6a,0xc2,0x7e,0x7e, + 0x7e,0xc7,0x33,0x33,0x33,0xb8,0x87,0x00,0x00,0x00,0xb3,0x00,0x33,0x33,0x33,0xb8,0x81,0x7e,0x7e,0x7e,0xc7,0x99,0x00,0x00,0x00,0xb3,0x00,0x52,0x52,0x52,0xbd,0x81, + 0x7e,0x7e,0x7e,0xc7,0x9b,0x00,0x00,0x00,0xb3,0x02,0x6a,0x6a,0x6a,0xc2,0x7e,0x7e,0x7e,0xc7,0x52,0x52,0x52,0xbd,0x86,0x00,0x00,0x00,0xb3,0x81,0x7e,0x7e,0x7e,0xc7, + 0x86,0x00,0x00,0x00,0xb3,0x00,0x6a,0x6a,0x6a,0xc2,0x83,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x84,0x00, + 0x00,0x00,0xb3,0x02,0x6a,0x6a,0x6a,0xc2,0x7e,0x7e,0x7e,0xc7,0x52,0x52,0x52,0xbd,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0x00, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0x01,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff, + 0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x86,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x84,0x00,0x00,0x00,0xb3,0x01, + 0xaf,0xaf,0xaf,0xd6,0xef,0xef,0xef,0xf5,0x82,0xff,0xff,0xff,0xff,0x04,0xdc,0xdc,0xdc,0xeb,0x6a,0x6a,0x6a,0xc2,0x00,0x00,0x00,0xb3,0x90,0x90,0x90,0xcc,0xef,0xef, + 0xef,0xf5,0x83,0xff,0xff,0xff,0xff,0x03,0xbb,0xbb,0xbb,0xdc,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0xc7,0xc7,0xc7,0xe1,0x83,0xff,0xff,0xff,0xff,0x01,0xef,0xef, + 0xef,0xf5,0x6a,0x6a,0x6a,0xc2,0x86,0x00,0x00,0x00,0xb3,0x00,0xbb,0xbb,0xbb,0xdc,0x82,0xff,0xff,0xff,0xff,0x01,0xef,0xef,0xef,0xf5,0xd2,0xd2,0xd2,0xe6,0x81,0xff, + 0xff,0xff,0xff,0x01,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb, + 0x81,0xff,0xff,0xff,0xff,0x83,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x00,0xd2,0xd2,0xd2,0xe6,0x88,0x00,0x00,0x00,0xb3,0x00,0xdc, + 0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0x90,0x90,0x90,0xcc,0x81,0xff,0xff,0xff,0xff,0x04,0xf7,0xf7,0xf7,0xfa,0x52,0x52,0x52,0xbd, + 0x00,0x00,0x00,0xb3,0x52,0x52,0x52,0xbd,0xd2,0xd2,0xd2,0xe6,0x82,0xff,0xff,0xff,0xff,0x01,0xf7,0xf7,0xf7,0xfa,0xaf,0xaf,0xaf,0xd6,0x84,0x00,0x00,0x00,0xb3,0x00, + 0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x89,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x83,0xff,0xff,0xff,0xff,0x81,0x00,0x00, + 0x00,0xb3,0x01,0x6a,0x6a,0x6a,0xc2,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x01,0xf7,0xf7,0xf7,0xfa,0xaf,0xaf,0xaf,0xd6,0x87,0x00,0x00,0x00,0xb3,0x01,0x6a, + 0x6a,0x6a,0xc2,0xef,0xef,0xef,0xf5,0x82,0xff,0xff,0xff,0xff,0x00,0xbb,0xbb,0xbb,0xdc,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3, + 0x01,0x52,0x52,0x52,0xbd,0xd2,0xd2,0xd2,0xe6,0x82,0xff,0xff,0xff,0xff,0x02,0xf7,0xf7,0xf7,0xfa,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff, + 0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x00,0xbb,0xbb,0xbb,0xdc,0x81,0xff,0xff,0xff,0xff,0x01,0xdc,0xdc,0xdc,0xeb,0x33,0x33,0x33,0xb8,0x81,0xff,0xff, + 0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3, + 0x01,0x6a,0x6a,0x6a,0xc2,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x01,0xf7,0xf7,0xf7,0xfa,0xaf,0xaf,0xaf,0xd6,0x84,0x00,0x00,0x00,0xb3,0x00,0xe6,0xe6,0xe6, + 0xf0,0x81,0xff,0xff,0xff,0xff,0x00,0x6a,0x6a,0x6a,0xc2,0x81,0x00,0x00,0x00,0xb3,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x00,0xa0,0xa0,0xa0,0xd1,0x82, + 0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x82,0x00,0x00,0x00,0xb3,0x01,0xaf,0xaf,0xaf,0xd6,0xef,0xef,0xef,0xf5,0x82,0xff,0xff,0xff, + 0xff,0x01,0xdc,0xdc,0xdc,0xeb,0x6a,0x6a,0x6a,0xc2,0x82,0x00,0x00,0x00,0xb3,0x01,0x90,0x90,0x90,0xcc,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x01,0xef,0xef, + 0xef,0xf5,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x05,0x33,0x33,0x33,0xb8,0xc7,0xc7,0xc7,0xe1,0xf7,0xf7, + 0xf7,0xfa,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x01,0xaf,0xaf, + 0xaf,0xd6,0xef,0xef,0xef,0xf5,0x82,0xff,0xff,0xff,0xff,0x01,0xdc,0xdc,0xdc,0xeb,0x6a,0x6a,0x6a,0xc2,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xfe,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0x01,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff, + 0x00,0xaf,0xaf,0xaf,0xd6,0x86,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x83,0x00,0x00,0x00,0xb3,0x00,0xaf, + 0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x01,0xef,0xef,0xef,0xf5,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0x6a, + 0x6a,0x6a,0xc2,0x81,0xff,0xff,0xff,0xff,0x01,0xdc,0xdc,0xdc,0xeb,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x05,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xd2, + 0xd2,0xd2,0xe6,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x01,0xf7,0xf7,0xf7,0xfa,0x33,0x33,0x33,0xb8,0x84,0x00,0x00, + 0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0xaf,0xaf,0xaf,0xd6,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x01,0x00, + 0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff, + 0x83,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x00,0x52,0x52,0x52,0xbd,0x87,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff, + 0xff,0xff,0xff,0x02,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x03,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0x33,0x33, + 0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x01,0xdc,0xdc,0xdc,0xeb,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0x00, + 0x00,0x00,0xb3,0x01,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x00,0xef,0xef,0xef,0xf5,0x88,0x00,0x00,0x00,0xb3,0x00,0x52,0x52,0x52,0xbd, + 0x84,0xff,0xff,0xff,0xff,0x02,0x00,0x00,0x00,0xb3,0x52,0x52,0x52,0xbd,0xf7,0xf7,0xf7,0xfa,0x85,0xff,0xff,0xff,0xff,0x00,0xbb,0xbb,0xbb,0xdc,0x86,0x00,0x00,0x00, + 0xb3,0x02,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0x81,0xbb,0xbb,0xbb,0xdc,0x00,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x03,0xaf,0xaf, + 0xaf,0xd6,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0x84,0xff,0xff,0xff,0xff,0x01,0xc7,0xc7,0xc7,0xe1,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff, + 0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xf7,0xf7,0xf7,0xfa,0x33,0x33,0x33,0xb8,0x00,0x00,0x00,0xb3, + 0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x03,0x7e,0x7e,0x7e,0xc7,0x00,0x00, + 0x00,0xb3,0x52,0x52,0x52,0xbd,0xf7,0xf7,0xf7,0xfa,0x85,0xff,0xff,0xff,0xff,0x00,0xbb,0xbb,0xbb,0xdc,0x82,0x00,0x00,0x00,0xb3,0x00,0x6a,0x6a,0x6a,0xc2,0x82,0xff, + 0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0x00,0x00,0x00, + 0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x01,0xef,0xef,0xef,0xf5,0xdc, + 0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x87,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e, + 0xc7,0x81,0x00,0x00,0x00,0xb3,0x00,0xe6,0xe6,0xe6,0xf0,0x86,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81, + 0xff,0xff,0xff,0xff,0x01,0xef,0xef,0xef,0xf5,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xfe,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0x01,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff, + 0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x86,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00, + 0xb3,0x00,0x52,0x52,0x52,0xbd,0x81,0xff,0xff,0xff,0xff,0x00,0xd2,0xd2,0xd2,0xe6,0x81,0x00,0x00,0x00,0xb3,0x02,0x6a,0x6a,0x6a,0xc2,0xbb,0xbb,0xbb,0xdc,0x33,0x33, + 0x33,0xb8,0x81,0x00,0x00,0x00,0xb3,0x03,0xa0,0xa0,0xa0,0xd1,0x6a,0x6a,0x6a,0xc2,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0x81,0xff,0xff,0xff,0xff,0x03,0xdc,0xdc, + 0xdc,0xeb,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xbb,0xbb,0xbb,0xdc,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e, + 0x7e,0xc7,0x84,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x82,0x00,0x00,0x00,0xb3,0x00,0xd2,0xd2,0xd2,0xe6,0x81,0xff,0xff,0xff,0xff, + 0x01,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff, + 0xff,0xff,0x82,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x83,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x87,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb, + 0x81,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0xb3,0xd2,0xd2,0xd2,0xe6,0x81,0xff,0xff,0xff,0xff,0x00,0xbb,0xbb,0xbb,0xdc,0x81,0x00,0x00,0x00,0xb3,0x00,0xc7,0xc7, + 0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x00,0x6a,0x6a,0x6a,0xc2,0x81,0x00,0x00,0x00,0xb3,0x01,0xbb,0xbb,0xbb,0xdc,0x7e,0x7e,0x7e,0xc7,0x83,0x00,0x00,0x00,0xb3,0x00, + 0xaf,0xaf,0xaf,0xd6,0x83,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x87,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x04,0xd2,0xd2, + 0xd2,0xe6,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0x00,0x00,0x00,0xb3,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x03,0xd2,0xd2,0xd2,0xe6,0x7e,0x7e,0x7e,0xc7, + 0xa0,0xa0,0xa0,0xd1,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x00,0x52,0x52,0x52,0xbd,0x85,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf, + 0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0x6a,0x6a,0x6a,0xc2,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff, + 0xff,0xff,0x03,0xd2,0xd2,0xd2,0xe6,0x7e,0x7e,0x7e,0xc7,0xa0,0xa0,0xa0,0xd1,0xc7,0xc7,0xc7,0xe1,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc, + 0xdc,0xeb,0x33,0x33,0x33,0xb8,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x00,0x90,0x90,0x90,0xcc,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc, + 0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0xc7,0xc7,0xc7,0xe1,0x81, + 0xff,0xff,0xff,0xff,0x03,0xd2,0xd2,0xd2,0xe6,0x7e,0x7e,0x7e,0xc7,0xa0,0xa0,0xa0,0xd1,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x00,0x52,0x52,0x52,0xbd,0x81, + 0x00,0x00,0x00,0xb3,0x00,0xbb,0xbb,0xbb,0xdc,0x82,0xff,0xff,0xff,0xff,0x02,0xe6,0xe6,0xe6,0xf0,0x00,0x00,0x00,0xb3,0x6a,0x6a,0x6a,0xc2,0x83,0xff,0xff,0xff,0xff, + 0x00,0x52,0x52,0x52,0xbd,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0xb3,0x52,0x52,0x52,0xbd,0x81,0xff,0xff, + 0xff,0xff,0x00,0xd2,0xd2,0xd2,0xe6,0x81,0x00,0x00,0x00,0xb3,0x02,0x6a,0x6a,0x6a,0xc2,0xbb,0xbb,0xbb,0xdc,0x33,0x33,0x33,0xb8,0x81,0x00,0x00,0x00,0xb3,0x00,0xd2, + 0xd2,0xd2,0xe6,0x81,0xff,0xff,0xff,0xff,0x03,0xd2,0xd2,0xd2,0xe6,0x7e,0x7e,0x7e,0xc7,0x90,0x90,0x90,0xcc,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x02,0x7e, + 0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0xa0,0xa0,0xa0,0xd1,0x82,0xff,0xff,0xff,0xff,0x02,0xc7,0xc7,0xc7,0xe1,0xaf,0xaf,0xaf,0xd6,0xef,0xef,0xef,0xf5,0x81,0xff,0xff, + 0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0x52,0x52,0x52,0xbd,0x81,0xff,0xff,0xff,0xff,0x00,0xd2,0xd2,0xd2,0xe6,0x81,0x00,0x00,0x00,0xb3,0x02,0x6a, + 0x6a,0x6a,0xc2,0xbb,0xbb,0xbb,0xdc,0x33,0x33,0x33,0xb8,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xfe,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0x01,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x86,0x00,0x00,0x00, + 0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00, + 0xc7,0xc7,0xc7,0xe1,0x84,0xaf,0xaf,0xaf,0xd6,0x05,0x52,0x52,0x52,0xbd,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0xaf,0xaf,0xaf,0xd6,0xd2,0xd2,0xd2,0xe6,0xf7,0xf7, + 0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0x00,0x00,0x00,0xb3,0x02,0x7e,0x7e,0x7e,0xc7,0xbb,0xbb,0xbb,0xdc,0xe6,0xe6,0xe6,0xf0,0x82,0xff, + 0xff,0xff,0xff,0x00,0x52,0x52,0x52,0xbd,0x84,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x03,0xd2,0xd2,0xd2,0xe6,0x90,0x90,0x90,0xcc, + 0x7e,0x7e,0x7e,0xc7,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6, + 0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x82,0x00,0x00,0x00,0xb3,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x02,0xc7, + 0xc7,0xc7,0xe1,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0x87,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x00,0x90,0x90,0x90,0xcc,0x81, + 0xff,0xff,0xff,0xff,0x00,0xe6,0xe6,0xe6,0xf0,0x82,0x00,0x00,0x00,0xb3,0x02,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0x84,0xaf,0xaf,0xaf,0xd6, + 0x00,0xa0,0xa0,0xa0,0xd1,0x82,0x00,0x00,0x00,0xb3,0x01,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0x81,0xe6,0xe6,0xe6,0xf0,0x01,0xff,0xff,0xff,0xff,0xc7,0xc7,0xc7, + 0xe1,0x87,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x02,0xf7,0xf7,0xf7,0xfa,0xff, + 0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0x82,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x85,0x00,0x00,0x00,0xb3, + 0x03,0xdc,0xdc,0xdc,0xeb,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0xaf,0xaf,0xaf,0xd6,0x81,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x04,0xaf,0xaf,0xaf,0xd6, + 0x00,0x00,0x00,0xb3,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0x85,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x01,0xdc,0xdc,0xdc,0xeb,0xbb, + 0xbb,0xbb,0xdc,0x81,0xff,0xff,0xff,0xff,0x00,0xbb,0xbb,0xbb,0xdc,0x82,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00, + 0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x04,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5, + 0x82,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x02,0xef,0xef,0xef,0xf5,0xff,0xff, + 0xff,0xff,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x06,0x33,0x33,0x33,0xb8,0xbb,0xbb,0xbb,0xdc,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0xf7,0xf7,0xf7,0xfa, + 0xff,0xff,0xff,0xff,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6, + 0x81,0xff,0xff,0xff,0xff,0x00,0xc7,0xc7,0xc7,0xe1,0x84,0xaf,0xaf,0xaf,0xd6,0x01,0x52,0x52,0x52,0xbd,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xef,0xef, + 0xef,0xf5,0x82,0x00,0x00,0x00,0xb3,0x00,0x52,0x52,0x52,0xbd,0x81,0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0xd2,0xd2,0xd2,0xe6,0x81,0xff, + 0xff,0xff,0xff,0x00,0x90,0x90,0x90,0xcc,0x81,0x00,0x00,0x00,0xb3,0x05,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xaf,0xaf,0xaf,0xd6,0x00,0x00, + 0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0xc7,0xc7,0xc7,0xe1,0x84,0xaf,0xaf,0xaf,0xd6,0x00,0x52,0x52,0x52,0xbd,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xfd,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0x01,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e, + 0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x86,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82, + 0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x87,0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0xe6,0xe6,0xe6,0xf0,0x83,0xff,0xff,0xff,0xff, + 0x03,0xef,0xef,0xef,0xf5,0x6a,0x6a,0x6a,0xc2,0x00,0x00,0x00,0xb3,0x90,0x90,0x90,0xcc,0x84,0xff,0xff,0xff,0xff,0x00,0xbb,0xbb,0xbb,0xdc,0x86,0x00,0x00,0x00,0xb3, + 0x00,0xaf,0xaf,0xaf,0xd6,0x86,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00, + 0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0x52,0x52,0x52,0xbd,0x81,0xff,0xff,0xff,0xff,0x01,0xc7,0xc7,0xc7,0xe1, + 0x6a,0x6a,0x6a,0xc2,0x81,0xff,0xff,0xff,0xff,0x00,0x90,0x90,0x90,0xcc,0x86,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x00,0xf7,0xf7, + 0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x00,0x52,0x52,0x52,0xbd,0x82,0x00,0x00,0x00,0xb3,0x87,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3, + 0x00,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x01,0xa0,0xa0,0xa0,0xd1,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x33,0x33,0x33,0xb8,0x86,0x00,0x00, + 0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb, + 0x82,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x85,0x00,0x00,0x00,0xb3,0x01,0x6a,0x6a,0x6a,0xc2,0xe6,0xe6, + 0xe6,0xf0,0x85,0xff,0xff,0xff,0xff,0x01,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x85,0x00,0x00,0x00,0xb3,0x81, + 0xff,0xff,0xff,0xff,0x00,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x00,0xef,0xef,0xef,0xf5,0x83,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc, + 0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x01,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00, + 0xdc,0xdc,0xdc,0xeb,0x82,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0x90,0x90,0x90,0xcc, + 0x81,0xff,0xff,0xff,0xff,0x09,0xaf,0xaf,0xaf,0xd6,0xe6,0xe6,0xe6,0xf0,0xff,0xff,0xff,0xff,0x90,0x90,0x90,0xcc,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xbb,0xbb, + 0xbb,0xdc,0xd2,0xd2,0xd2,0xe6,0xff,0xff,0xff,0xff,0xe6,0xe6,0xe6,0xf0,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x01,0x00,0x00, + 0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x87,0xff,0xff,0xff,0xff,0x01,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x83,0x00, + 0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x83,0x00,0x00,0x00,0xb3,0x04, + 0xdc,0xdc,0xdc,0xeb,0xff,0xff,0xff,0xff,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x87,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xfd,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0x01,0x00,0x00,0x00, + 0xb3,0x7e,0x7e,0x7e,0xc7,0x85,0xff,0xff,0xff,0xff,0x01,0xdc,0xdc,0xdc,0xeb,0xa0,0xa0,0xa0,0xd1,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff, + 0xff,0xff,0x00,0xe6,0xe6,0xe6,0xf0,0x82,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x7e,0x7e,0x7e,0xc7, + 0x00,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x01,0x6a,0x6a,0x6a,0xc2,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xf7,0xf7,0xf7,0xfa,0xbb,0xbb,0xbb, + 0xdc,0x90,0x90,0x90,0xcc,0x82,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0xaf,0xaf,0xaf,0xd6,0x52,0x52,0x52, + 0xbd,0x88,0x00,0x00,0x00,0xb3,0x01,0x33,0x33,0x33,0xb8,0x7e,0x7e,0x7e,0xc7,0x81,0xaf,0xaf,0xaf,0xd6,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x01,0x00, + 0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0x00,0x00,0x00,0xb3,0x00,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff, + 0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x04,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff, + 0xd2,0xd2,0xd2,0xe6,0x86,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x00,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x00,0xa0,0xa0, + 0xa0,0xd1,0x82,0x00,0x00,0x00,0xb3,0x02,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0x82,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xd2, + 0xd2,0xd2,0xe6,0x81,0x00,0x00,0x00,0xb3,0x04,0xdc,0xdc,0xdc,0xeb,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0x33,0x33,0x33,0xb8,0x52,0x52,0x52,0xbd,0x81,0xff,0xff, + 0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x86,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3, + 0x03,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0x33,0x33,0x33,0xb8,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff, + 0x00,0xa0,0xa0,0xa0,0xd1,0x87,0x00,0x00,0x00,0xb3,0x01,0x6a,0x6a,0x6a,0xc2,0xa0,0xa0,0xa0,0xd1,0x81,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x05,0xaf,0xaf, + 0xaf,0xd6,0x00,0x00,0x00,0xb3,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0x33,0x33,0x33,0xb8,0x81,0x00,0x00,0x00,0xb3,0x00,0x33,0x33,0x33,0xb8, + 0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x04,0xef,0xef,0xef,0xf5,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0x6a,0x6a,0x6a,0xc2,0x82, + 0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xef,0xef,0xef,0xf5,0x81,0x00,0x00,0x00,0xb3,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x05,0x7e,0x7e, + 0x7e,0xc7,0x00,0x00,0x00,0xb3,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0x33,0x33,0x33,0xb8,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6, + 0x81,0xff,0xff,0xff,0xff,0x02,0xa0,0xa0,0xa0,0xd1,0x00,0x00,0x00,0xb3,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x03,0x52,0x52,0x52,0xbd,0xbb,0xbb,0xbb,0xdc, + 0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x01,0x7e,0x7e,0x7e,0xc7,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x02,0x6a,0x6a,0x6a,0xc2, + 0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0xb3,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6, + 0x81,0x7e,0x7e,0x7e,0xc7,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x05,0x6a,0x6a,0x6a,0xc2,0x00,0x00,0x00,0xb3,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff, + 0xf7,0xf7,0xf7,0xfa,0x33,0x33,0x33,0xb8,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3, + 0xd2,0xd2,0xd2,0xe6,0x81,0xff,0xff,0xff,0xff,0x00,0x90,0x90,0x90,0xcc,0x81,0x00,0x00,0x00,0xb3,0x05,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff, + 0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x7e,0x7e,0x7e,0xc7,0x00,0xc7,0xc7,0xc7,0xe1, + 0x81,0xff,0xff,0xff,0xff,0x00,0x6a,0x6a,0x6a,0xc2,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xfd,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0x01,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x87,0xff,0xff,0xff,0xff,0x02,0xbb,0xbb,0xbb,0xdc,0x00,0x00,0x00,0xb3,0x7e, + 0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xaf,0xaf,0xaf,0xd6,0x0a,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xe6, + 0xe6,0xe6,0xf0,0x33,0x33,0x33,0xb8,0x52,0x52,0x52,0xbd,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81, + 0xff,0xff,0xff,0xff,0x03,0xc7,0xc7,0xc7,0xe1,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0xa0,0xa0,0xa0,0xd1,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81, + 0xff,0xff,0xff,0xff,0x03,0x52,0x52,0x52,0xbd,0x33,0x33,0x33,0xb8,0xaf,0xaf,0xaf,0xd6,0x33,0x33,0x33,0xb8,0x87,0x00,0x00,0x00,0xb3,0x08,0xaf,0xaf,0xaf,0xd6,0x52, + 0x52,0x52,0xbd,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0xdc,0xdc,0xdc,0xeb,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x82, + 0xff,0xff,0xff,0xff,0x01,0xbb,0xbb,0xbb,0xdc,0xd2,0xd2,0xd2,0xe6,0x81,0xff,0xff,0xff,0xff,0x05,0xef,0xef,0xef,0xf5,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0xf7, + 0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0x81,0x00,0x00,0x00,0xb3,0x00,0xbb,0xbb,0xbb,0xdc,0x81,0xff,0xff,0xff,0xff,0x00,0x33,0x33,0x33,0xb8,0x85, + 0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x01,0x33,0x33,0x33,0xb8,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x00,0xa0,0xa0,0xa0, + 0xd1,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0xa0,0xa0,0xa0,0xd1,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff, + 0xff,0xff,0x02,0xa0,0xa0,0xa0,0xd1,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0x00,0x00,0x00,0xb3,0x02,0xe6, + 0xe6,0xe6,0xf0,0xff,0xff,0xff,0xff,0xe6,0xe6,0xe6,0xf0,0x85,0x00,0x00,0x00,0xb3,0x01,0xaf,0xaf,0xaf,0xd6,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x00,0xdc, + 0xdc,0xdc,0xeb,0x81,0xaf,0xaf,0xaf,0xd6,0x01,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0xef,0xef,0xef,0xf5,0xaf,0xaf,0xaf,0xd6,0xc7, + 0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x01,0xf7,0xf7,0xf7,0xfa,0x33,0x33,0x33,0xb8,0x86,0x00,0x00,0x00,0xb3,0x01,0x6a,0x6a,0x6a,0xc2,0xaf,0xaf,0xaf,0xd6,0x81, + 0x00,0x00,0x00,0xb3,0x00,0x90,0x90,0x90,0xcc,0x81,0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff, + 0x05,0xef,0xef,0xef,0xf5,0xaf,0xaf,0xaf,0xd6,0xc7,0xc7,0xc7,0xe1,0xe6,0xe6,0xe6,0xf0,0x33,0x33,0x33,0xb8,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x01,0xdc, + 0xdc,0xdc,0xeb,0x6a,0x6a,0x6a,0xc2,0x81,0xff,0xff,0xff,0xff,0x01,0xf7,0xf7,0xf7,0xfa,0x6a,0x6a,0x6a,0xc2,0x81,0x00,0x00,0x00,0xb3,0x82,0xff,0xff,0xff,0xff,0x01, + 0xd2,0xd2,0xd2,0xe6,0xbb,0xbb,0xbb,0xdc,0x82,0xff,0xff,0xff,0xff,0x02,0x52,0x52,0x52,0xbd,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02, + 0xef,0xef,0xef,0xf5,0xaf,0xaf,0xaf,0xd6,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x00,0xf7,0xf7,0xf7,0xfa,0x81,0x33,0x33,0x33,0xb8,0x81,0xff,0xff,0xff,0xff, + 0x02,0xe6,0xe6,0xe6,0xf0,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x02,0xf7,0xf7,0xf7,0xfa,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0x81, + 0xff,0xff,0xff,0xff,0x02,0xbb,0xbb,0xbb,0xdc,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x09,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0xf7, + 0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xe6,0xe6,0xe6,0xf0,0x33,0x33,0x33,0xb8,0x52,0x52,0x52,0xbd,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0x81, + 0x00,0x00,0x00,0xb3,0x00,0xbb,0xbb,0xbb,0xdc,0x81,0xff,0xff,0xff,0xff,0x03,0xef,0xef,0xef,0xf5,0xaf,0xaf,0xaf,0xd6,0xbb,0xbb,0xbb,0xdc,0xf7,0xf7,0xf7,0xfa,0x81, + 0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0xa0,0xa0,0xa0,0xd1,0x82,0xff,0xff,0xff,0xff,0x02,0xc7,0xc7,0xc7,0xe1,0xaf,0xaf,0xaf,0xd6,0xef, + 0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x0a,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xe6,0xe6,0xe6, + 0xf0,0x33,0x33,0x33,0xb8,0x52,0x52,0x52,0xbd,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xfe, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0x01,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff, + 0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xaf,0xaf,0xaf,0xd6,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x01,0x33,0x33,0x33,0xb8,0x7e,0x7e,0x7e,0xc7,0x81,0xff, + 0xff,0xff,0xff,0x00,0xe6,0xe6,0xe6,0xf0,0x82,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0xb3,0xa0,0xa0,0xa0,0xd1,0x85,0xff,0xff,0xff,0xff,0x00,0x90,0x90,0x90,0xcc, + 0x81,0x00,0x00,0x00,0xb3,0x00,0xe6,0xe6,0xe6,0xf0,0x84,0xff,0xff,0xff,0xff,0x02,0xa0,0xa0,0xa0,0xd1,0x00,0x00,0x00,0xb3,0x90,0x90,0x90,0xcc,0x84,0xff,0xff,0xff, + 0xff,0x01,0xe6,0xe6,0xe6,0xf0,0x33,0x33,0x33,0xb8,0x85,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x01,0xdc,0xdc,0xdc,0xeb,0xef,0xef, + 0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x02,0xa0,0xa0,0xa0,0xd1,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xf7,0xf7,0xf7,0xfa,0x83,0xff, + 0xff,0xff,0xff,0x02,0xc7,0xc7,0xc7,0xe1,0x00,0x00,0x00,0xb3,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00, + 0x6a,0x6a,0x6a,0xc2,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x85,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x08,0x00,0x00, + 0x00,0xb3,0x6a,0x6a,0x6a,0xc2,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0x6a,0x6a,0x6a,0xc2,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0xe6,0xe6, + 0xe6,0xf0,0x84,0xff,0xff,0xff,0xff,0x00,0xe6,0xe6,0xe6,0xf0,0x81,0x00,0x00,0x00,0xb3,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x00,0x6a,0x6a,0x6a,0xc2, + 0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x6a,0x6a,0x6a,0xc2,0x84,0x00,0x00,0x00,0xb3,0x86,0xff,0xff,0xff,0xff,0x02,0x00, + 0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0xe6,0xe6,0xe6,0xf0,0x85,0xff,0xff,0xff,0xff,0x00,0xa0,0xa0,0xa0,0xd1,0x86,0x00,0x00,0x00,0xb3,0x04,0x33,0x33,0x33,0xb8,0xf7, + 0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x00,0xef,0xef,0xef,0xf5,0x82,0x00,0x00,0x00,0xb3,0x00,0xe6, + 0xe6,0xe6,0xf0,0x84,0xff,0xff,0xff,0xff,0x01,0xe6,0xe6,0xe6,0xf0,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0xa0, + 0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x02,0xe6,0xe6,0xe6,0xf0,0x33,0x33,0x33,0xb8,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xf7,0xf7,0xf7,0xfa,0x83, + 0xff,0xff,0xff,0xff,0x00,0xef,0xef,0xef,0xf5,0x81,0x00,0x00,0x00,0xb3,0x01,0x33,0x33,0x33,0xb8,0xe6,0xe6,0xe6,0xf0,0x85,0xff,0xff,0xff,0xff,0x02,0xa0,0xa0,0xa0, + 0xd1,0x00,0x00,0x00,0xb3,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x82,0xff,0xff,0xff,0xff,0x00,0xd2,0xd2, + 0xd2,0xe6,0x81,0x00,0x00,0x00,0xb3,0x04,0xe6,0xe6,0xe6,0xf0,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff, + 0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x85,0xff,0xff,0xff,0xff,0x00,0x90,0x90,0x90,0xcc,0x81,0x00,0x00,0x00,0xb3,0x01,0x33,0x33,0x33,0xb8,0xf7, + 0xf7,0xf7,0xfa,0x86,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x00,0xe6,0xe6,0xe6,0xf0,0x83,0xff,0xff,0xff,0xff,0x00,0xf7,0xf7,0xf7, + 0xfa,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x85,0xff,0xff,0xff,0xff,0x00,0x90,0x90,0x90,0xcc,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xfe,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0x01,0x00,0x00, + 0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x00,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x01, + 0x7e,0x7e,0x7e,0xc7,0x6a,0x6a,0x6a,0xc2,0x81,0xdc,0xdc,0xdc,0xeb,0x03,0xa0,0xa0,0xa0,0xd1,0xaf,0xaf,0xaf,0xd6,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0x81,0x00, + 0x00,0x00,0xb3,0x01,0x7e,0x7e,0x7e,0xc7,0xd2,0xd2,0xd2,0xe6,0x81,0xff,0xff,0xff,0xff,0x01,0xe6,0xe6,0xe6,0xf0,0x90,0x90,0x90,0xcc,0x82,0x00,0x00,0x00,0xb3,0x06, + 0x33,0x33,0x33,0xb8,0xc7,0xc7,0xc7,0xe1,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0xc7,0xc7,0xc7,0xe1,0x52,0x52,0x52,0xbd,0x81,0x00,0x00,0x00, + 0xb3,0x01,0x90,0x90,0x90,0xcc,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x01,0xe6,0xe6,0xe6,0xf0,0xa0,0xa0,0xa0,0xd1,0x86,0x00,0x00,0x00,0xb3,0x02,0x33,0x33, + 0x33,0xb8,0xaf,0xaf,0xaf,0xd6,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x01,0xe6,0xe6,0xe6,0xf0,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0x6a,0x6a, + 0x6a,0xc2,0x81,0xdc,0xdc,0xdc,0xeb,0x01,0xa0,0xa0,0xa0,0xd1,0xbb,0xbb,0xbb,0xdc,0x81,0xff,0xff,0xff,0xff,0x03,0xc7,0xc7,0xc7,0xe1,0x33,0x33,0x33,0xb8,0x00,0x00, + 0x00,0xb3,0xc7,0xc7,0xc7,0xe1,0x81,0xdc,0xdc,0xdc,0xeb,0x00,0x33,0x33,0x33,0xb8,0x82,0x00,0x00,0x00,0xb3,0x02,0xd2,0xd2,0xd2,0xe6,0xdc,0xdc,0xdc,0xeb,0xc7,0xc7, + 0xc7,0xe1,0x85,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0x6a,0x6a,0x6a,0xc2,0x81,0xdc,0xdc,0xdc,0xeb, + 0x0b,0xd2,0xd2,0xd2,0xe6,0x33,0x33,0x33,0xb8,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0xaf,0xaf,0xaf,0xd6,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7, + 0xfa,0xc7,0xc7,0xc7,0xe1,0x33,0x33,0x33,0xb8,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0x81,0xdc,0xdc,0xdc,0xeb,0x00,0xc7,0xc7,0xc7,0xe1,0x82,0x00,0x00,0x00,0xb3, + 0x00,0x52,0x52,0x52,0xbd,0x81,0xdc,0xdc,0xdc,0xeb,0x00,0xaf,0xaf,0xaf,0xd6,0x84,0x00,0x00,0x00,0xb3,0x01,0xdc,0xdc,0xdc,0xeb,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff, + 0xff,0xff,0x00,0xef,0xef,0xef,0xf5,0x81,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x02,0x33,0x33,0x33,0xb8,0xaf,0xaf,0xaf,0xd6,0xef,0xef,0xef,0xf5,0x81,0xff, + 0xff,0xff,0xff,0x01,0xd2,0xd2,0xd2,0xe6,0x7e,0x7e,0x7e,0xc7,0x88,0x00,0x00,0x00,0xb3,0x06,0x7e,0x7e,0x7e,0xc7,0xd2,0xd2,0xd2,0xe6,0xf7,0xf7,0xf7,0xfa,0xff,0xff, + 0xff,0xff,0xf7,0xf7,0xf7,0xfa,0xd2,0xd2,0xd2,0xe6,0x52,0x52,0x52,0xbd,0x83,0x00,0x00,0x00,0xb3,0x01,0xaf,0xaf,0xaf,0xd6,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff, + 0xff,0x02,0xd2,0xd2,0xd2,0xe6,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0, + 0xa0,0xd1,0x81,0xdc,0xdc,0xdc,0xeb,0x01,0xbb,0xbb,0xbb,0xdc,0x00,0x00,0x00,0xb3,0x81,0xdc,0xdc,0xdc,0xeb,0x05,0xbb,0xbb,0xbb,0xdc,0xa0,0xa0,0xa0,0xd1,0xf7,0xf7, + 0xf7,0xfa,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0x6a,0x6a,0x6a,0xc2,0x82,0x00,0x00,0x00,0xb3,0x02,0x33,0x33,0x33,0xb8,0xaf,0xaf,0xaf,0xd6,0xef,0xef,0xef,0xf5, + 0x81,0xff,0xff,0xff,0xff,0x01,0xd2,0xd2,0xd2,0xe6,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xdc,0xdc,0xdc,0xeb,0x00,0x52,0x52, + 0x52,0xbd,0x81,0x00,0x00,0x00,0xb3,0x00,0xbb,0xbb,0xbb,0xdc,0x81,0xdc,0xdc,0xdc,0xeb,0x00,0x90,0x90,0x90,0xcc,0x81,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1, + 0x81,0xdc,0xdc,0xdc,0xeb,0x01,0x52,0x52,0x52,0xbd,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x82,0x00,0x00,0x00,0xb3,0x01,0x7e,0x7e,0x7e,0xc7,0xd2,0xd2,0xd2, + 0xe6,0x81,0xff,0xff,0xff,0xff,0x01,0xe6,0xe6,0xe6,0xf0,0x90,0x90,0x90,0xcc,0x83,0x00,0x00,0x00,0xb3,0x01,0x6a,0x6a,0x6a,0xc2,0xd2,0xd2,0xd2,0xe6,0x81,0xff,0xff, + 0xff,0xff,0x01,0xc7,0xc7,0xc7,0xe1,0xbb,0xbb,0xbb,0xdc,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x01,0x33,0x33,0x33,0xb8,0xc7, + 0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x01,0xd2,0xd2,0xd2,0xe6,0x6a,0x6a,0x6a,0xc2,0x81,0xdc,0xdc,0xdc,0xeb,0x00,0xa0,0xa0,0xa0,0xd1,0x82,0x00,0x00,0x00,0xb3, + 0x01,0x7e,0x7e,0x7e,0xc7,0xd2,0xd2,0xd2,0xe6,0x81,0xff,0xff,0xff,0xff,0x01,0xe6,0xe6,0xe6,0xf0,0x90,0x90,0x90,0xcc,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0x01,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff, + 0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x01,0x33,0x33,0x33,0xb8,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7, + 0xca,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0xa0,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf, + 0xaf,0xaf,0xd6,0xa5,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0xaa,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff, + 0xff,0x91,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0x93,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0x01,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e, + 0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xef,0xef,0xef,0xf5,0x81,0xdc,0xdc,0xdc,0xeb,0x00,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x00,0xf7,0xf7,0xf7,0xfa,0xcb, + 0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0xa0,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf, + 0xaf,0xd6,0xa5,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0xaa,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff, + 0x91,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0x93,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0x01,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7, + 0x87,0xff,0xff,0xff,0xff,0x00,0xa0,0xa0,0xa0,0xd1,0xcb,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0xa0,0x00,0x00,0x00,0xb3,0x00,0x33, + 0x33,0x33,0xb8,0x81,0x7e,0x7e,0x7e,0xc7,0x00,0x52,0x52,0x52,0xbd,0xa5,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0xaa,0x00,0x00,0x00, + 0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x91,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0x93,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0x01,0x00,0x00,0x00,0xb3,0x6a,0x6a,0x6a,0xc2,0x85,0xdc,0xdc,0xdc,0xeb,0x01,0xaf,0xaf,0xaf,0xd6,0x52,0x52,0x52,0xbd,0xcc,0x00,0x00,0x00,0xb3,0x00,0xdc, + 0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0xca,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0xaa,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc, + 0xeb,0x81,0xff,0xff,0xff,0xff,0x91,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0x93,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xd6,0x00,0x00, + 0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0xaf,0xaf,0xaf,0xd6,0xca,0x00,0x00,0x00,0xb3,0x81,0xaf,0xaf,0xaf,0xd6,0x00,0xa0,0xa0,0xa0,0xd1,0xaa,0x00,0x00,0x00,0xb3, + 0x00,0xa0,0xa0,0xa0,0xd1,0x81,0xaf,0xaf,0xaf,0xd6,0x91,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xaf,0xaf,0xaf,0xd6,0x00,0x52,0x52,0x52,0xbd,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0x93,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0x8f,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb4,0xf1,0x00,0x00,0x00,0xb4,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xfd,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xd6,0x00,0x00,0x00,0xb3,0xc3,0x00,0x00,0x00,0xb4,0xff,0x01,0x00,0x00,0xb4, + 0xdb,0x01,0x00,0x00,0xb4,0xc3,0x00,0x00,0x00,0xb4,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xc4,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xb5,0x00,0x00,0x00,0xb3,0x82,0x00,0x00,0x00,0xb4,0x8b,0x00,0x00,0x00,0xb3,0x97,0x00,0x00,0x00,0xb4,0x92,0x01,0x00,0x00,0xb4,0x91,0x01,0x00,0x00, + 0xb5,0x8c,0x01,0x01,0x00,0xb5,0xff,0x01,0x01,0x01,0xb6,0xf3,0x01,0x01,0x01,0xb6,0x8c,0x01,0x01,0x00,0xb5,0x91,0x01,0x00,0x00,0xb5,0x92,0x01,0x00,0x00,0xb4,0x97, + 0x00,0x00,0x00,0xb4,0x8b,0x00,0x00,0x00,0xb3,0x82,0x00,0x00,0x00,0xb4,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xa3,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xa8,0x00,0x00,0x00,0xb3,0x9b,0x00,0x00,0x00,0xb4,0x8e,0x01,0x00,0x00,0xb4,0x88,0x01,0x00,0x00,0xb5,0x81,0x01,0x01,0x00,0xb5, + 0x8f,0x01,0x01,0x01,0xb6,0x00,0x01,0x01,0x01,0xb7,0x8b,0x02,0x01,0x01,0xb7,0xa8,0x02,0x01,0x01,0xb8,0x00,0x02,0x02,0x01,0xb9,0x81,0x03,0x02,0x01,0xb9,0x82,0x02, + 0x02,0x01,0xb9,0x82,0x03,0x02,0x01,0xb9,0x83,0x02,0x02,0x01,0xb9,0x00,0x03,0x02,0x01,0xb9,0x81,0x02,0x02,0x01,0xb9,0x00,0x03,0x02,0x01,0xb9,0x81,0x02,0x02,0x01, + 0xb9,0x00,0x03,0x02,0x01,0xb9,0x85,0x02,0x02,0x01,0xb9,0x02,0x03,0x02,0x01,0xb9,0x02,0x02,0x01,0xb9,0x03,0x02,0x01,0xb9,0x82,0x02,0x02,0x01,0xb9,0x00,0x03,0x02, + 0x01,0xb9,0x82,0x02,0x02,0x01,0xb9,0x81,0x03,0x02,0x01,0xb9,0x81,0x02,0x02,0x01,0xb9,0x04,0x03,0x02,0x01,0xb9,0x02,0x02,0x01,0xb9,0x03,0x02,0x01,0xb9,0x02,0x02, + 0x01,0xb9,0x03,0x02,0x01,0xb9,0x84,0x02,0x02,0x01,0xb9,0x00,0x03,0x02,0x01,0xb9,0x81,0x02,0x02,0x01,0xb9,0x00,0x03,0x02,0x01,0xb9,0x83,0x02,0x02,0x01,0xb9,0x00, + 0x03,0x02,0x01,0xb9,0x85,0x02,0x02,0x01,0xb9,0x81,0x03,0x02,0x01,0xb9,0x82,0x02,0x02,0x01,0xb9,0x00,0x03,0x02,0x01,0xb9,0x83,0x02,0x02,0x01,0xb9,0x00,0x03,0x02, + 0x01,0xb9,0x81,0x02,0x02,0x01,0xb9,0x81,0x03,0x02,0x01,0xb9,0x02,0x02,0x02,0x01,0xb9,0x03,0x02,0x01,0xb9,0x02,0x02,0x01,0xb9,0x81,0x03,0x02,0x01,0xb9,0x81,0x02, + 0x02,0x01,0xb9,0x00,0x03,0x02,0x01,0xb9,0x81,0x02,0x02,0x01,0xb9,0x00,0x03,0x02,0x01,0xb9,0x8d,0x02,0x02,0x01,0xb9,0x01,0x03,0x02,0x01,0xb9,0x02,0x02,0x01,0xb9, + 0x81,0x03,0x02,0x01,0xb9,0x81,0x02,0x02,0x01,0xb9,0x00,0x03,0x02,0x01,0xb9,0x82,0x02,0x02,0x01,0xb9,0x00,0x03,0x02,0x01,0xb9,0x87,0x02,0x02,0x01,0xb9,0x81,0x03, + 0x02,0x01,0xb9,0x81,0x02,0x02,0x01,0xb9,0x00,0x03,0x02,0x01,0xb9,0x83,0x02,0x02,0x01,0xb9,0x00,0x03,0x02,0x01,0xb9,0x87,0x02,0x02,0x01,0xb9,0x00,0x03,0x02,0x01, + 0xb9,0x85,0x02,0x02,0x01,0xb9,0x00,0x03,0x02,0x01,0xb9,0x81,0x02,0x02,0x01,0xb9,0x00,0x03,0x02,0x01,0xb9,0x85,0x02,0x02,0x01,0xb9,0x00,0x03,0x02,0x01,0xb9,0x84, + 0x02,0x02,0x01,0xb9,0x82,0x03,0x02,0x01,0xb9,0x81,0x02,0x02,0x01,0xb9,0x00,0x03,0x02,0x01,0xb9,0x82,0x02,0x02,0x01,0xb9,0x01,0x03,0x02,0x01,0xb9,0x02,0x02,0x01, + 0xb9,0x82,0x03,0x02,0x01,0xb9,0x83,0x02,0x02,0x01,0xb9,0x00,0x03,0x02,0x01,0xb9,0x8b,0x02,0x02,0x01,0xb9,0x00,0x03,0x02,0x01,0xb9,0x82,0x02,0x02,0x01,0xb9,0x8d, + 0x02,0x01,0x01,0xb8,0x00,0x02,0x02,0x01,0xb8,0x90,0x02,0x01,0x01,0xb8,0x00,0x02,0x02,0x01,0xb8,0x87,0x02,0x01,0x01,0xb8,0x8b,0x02,0x01,0x01,0xb7,0x00,0x01,0x01, + 0x01,0xb7,0x8f,0x01,0x01,0x01,0xb6,0x81,0x01,0x01,0x00,0xb5,0x88,0x01,0x00,0x00,0xb5,0x8e,0x01,0x00,0x00,0xb4,0x9b,0x00,0x00,0x00,0xb4,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0x96,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xa6,0x00,0x00,0x00,0xb3,0x91,0x00,0x00,0x00,0xb4,0x87,0x01, + 0x00,0x00,0xb4,0x85,0x01,0x00,0x00,0xb5,0x88,0x01,0x01,0x00,0xb5,0x86,0x01,0x01,0x01,0xb6,0x81,0x01,0x01,0x01,0xb7,0x86,0x02,0x01,0x01,0xb7,0x83,0x02,0x01,0x01, + 0xb8,0x00,0x02,0x02,0x01,0xb8,0x86,0x02,0x01,0x01,0xb8,0x83,0x02,0x02,0x01,0xb9,0x81,0x03,0x02,0x01,0xb9,0x89,0x03,0x02,0x01,0xba,0x82,0x03,0x02,0x02,0xbb,0x00, + 0x03,0x02,0x01,0xbb,0x8c,0x03,0x02,0x02,0xbb,0x00,0x03,0x02,0x02,0xbc,0x8d,0x04,0x02,0x02,0xbc,0xff,0x04,0x03,0x02,0xbd,0xd9,0x04,0x03,0x02,0xbd,0x85,0x04,0x02, + 0x02,0xbc,0x00,0x04,0x03,0x02,0xbc,0x86,0x04,0x02,0x02,0xbc,0x00,0x03,0x02,0x02,0xbc,0x87,0x03,0x02,0x02,0xbb,0x00,0x03,0x02,0x01,0xbb,0x87,0x03,0x02,0x02,0xbb, + 0x89,0x03,0x02,0x01,0xba,0x00,0x03,0x02,0x01,0xb9,0x84,0x02,0x02,0x01,0xb9,0x8b,0x02,0x01,0x01,0xb8,0x86,0x02,0x01,0x01,0xb7,0x81,0x01,0x01,0x01,0xb7,0x86,0x01, + 0x01,0x01,0xb6,0x88,0x01,0x01,0x00,0xb5,0x85,0x01,0x00,0x00,0xb5,0x87,0x01,0x00,0x00,0xb4,0x91,0x00,0x00,0x00,0xb4,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0x94,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0x9d,0x00,0x00,0x00,0xb3,0x92,0x00,0x00,0x00,0xb4,0x88,0x01,0x00,0x00,0xb4,0x84, + 0x01,0x00,0x00,0xb5,0x86,0x01,0x01,0x00,0xb5,0x83,0x01,0x01,0x01,0xb6,0x01,0x02,0x01,0x01,0xb7,0x01,0x01,0x01,0xb7,0x85,0x02,0x01,0x01,0xb7,0x86,0x02,0x01,0x01, + 0xb8,0x82,0x02,0x02,0x01,0xb9,0x82,0x03,0x02,0x01,0xb9,0x83,0x03,0x02,0x01,0xba,0x00,0x03,0x02,0x01,0xbb,0x82,0x03,0x02,0x02,0xbb,0x00,0x03,0x02,0x01,0xbb,0x83, + 0x03,0x02,0x02,0xbb,0x81,0x03,0x02,0x02,0xbc,0x01,0x04,0x02,0x02,0xbc,0x03,0x02,0x02,0xbc,0x84,0x04,0x02,0x02,0xbc,0x88,0x04,0x03,0x02,0xbd,0x01,0x04,0x03,0x02, + 0xbe,0x05,0x03,0x02,0xbe,0x85,0x04,0x03,0x02,0xbe,0x00,0x04,0x03,0x02,0xbf,0x85,0x05,0x03,0x02,0xbf,0x85,0x05,0x03,0x02,0xc0,0x00,0x05,0x04,0x01,0xc0,0x81,0x05, + 0x03,0x02,0xc0,0x00,0x05,0x03,0x03,0xc0,0x8d,0x05,0x04,0x03,0xc0,0x00,0x06,0x04,0x03,0xc1,0x83,0x05,0x04,0x03,0xc1,0x02,0x06,0x04,0x03,0xc1,0x05,0x04,0x03,0xc1, + 0x05,0x04,0x01,0xc1,0x81,0x05,0x04,0x03,0xc1,0x81,0x06,0x04,0x03,0xc1,0x05,0x05,0x04,0x03,0xc1,0x06,0x04,0x03,0xc1,0x05,0x04,0x03,0xc1,0x06,0x04,0x03,0xc1,0x05, + 0x04,0x03,0xc1,0x06,0x04,0x03,0xc1,0x82,0x05,0x04,0x03,0xc1,0x00,0x05,0x04,0x01,0xc1,0x81,0x05,0x04,0x03,0xc1,0x00,0x06,0x04,0x03,0xc1,0x83,0x05,0x04,0x03,0xc1, + 0x00,0x06,0x04,0x03,0xc1,0x83,0x05,0x04,0x03,0xc1,0x00,0x05,0x04,0x01,0xc1,0x81,0x05,0x04,0x03,0xc1,0x00,0x06,0x04,0x03,0xc1,0x81,0x05,0x04,0x03,0xc1,0x02,0x06, + 0x04,0x03,0xc1,0x05,0x04,0x03,0xc1,0x06,0x04,0x03,0xc1,0x81,0x05,0x04,0x03,0xc1,0x02,0x06,0x04,0x03,0xc1,0x05,0x04,0x03,0xc1,0x06,0x04,0x03,0xc1,0x82,0x05,0x04, + 0x03,0xc1,0x00,0x06,0x04,0x03,0xc1,0x82,0x05,0x04,0x03,0xc1,0xd9,0x06,0x04,0x03,0xc2,0x05,0x05,0x04,0x03,0xc1,0x06,0x04,0x03,0xc1,0x05,0x04,0x03,0xc1,0x06,0x04, + 0x03,0xc1,0x05,0x04,0x03,0xc1,0x06,0x04,0x03,0xc1,0x83,0x05,0x04,0x03,0xc1,0x02,0x06,0x04,0x03,0xc1,0x05,0x04,0x03,0xc1,0x06,0x04,0x03,0xc1,0x81,0x05,0x04,0x03, + 0xc1,0x00,0x06,0x04,0x03,0xc1,0x81,0x05,0x04,0x03,0xc1,0x00,0x06,0x04,0x03,0xc1,0x82,0x05,0x04,0x03,0xc1,0x00,0x06,0x04,0x03,0xc1,0x82,0x05,0x04,0x03,0xc1,0x01, + 0x05,0x04,0x01,0xc1,0x05,0x04,0x03,0xc1,0x82,0x06,0x04,0x03,0xc1,0x00,0x05,0x04,0x03,0xc1,0x81,0x06,0x04,0x03,0xc1,0x03,0x05,0x04,0x03,0xc1,0x06,0x04,0x03,0xc1, + 0x05,0x04,0x03,0xc1,0x06,0x04,0x03,0xc1,0x85,0x05,0x04,0x03,0xc1,0x00,0x05,0x04,0x01,0xc1,0x81,0x05,0x04,0x03,0xc1,0x01,0x06,0x04,0x03,0xc1,0x05,0x04,0x03,0xc1, + 0x81,0x06,0x04,0x03,0xc1,0x81,0x05,0x04,0x03,0xc1,0x81,0x06,0x04,0x03,0xc1,0x8d,0x05,0x04,0x03,0xc0,0x00,0x05,0x03,0x03,0xc0,0x81,0x05,0x03,0x02,0xc0,0x00,0x05, + 0x04,0x01,0xc0,0x85,0x05,0x03,0x02,0xc0,0x85,0x05,0x03,0x02,0xbf,0x00,0x04,0x03,0x02,0xbf,0x81,0x04,0x03,0x02,0xbe,0x82,0x05,0x03,0x02,0xbe,0x02,0x04,0x03,0x02, + 0xbe,0x05,0x03,0x02,0xbe,0x04,0x03,0x02,0xbe,0x88,0x04,0x03,0x02,0xbd,0x84,0x04,0x02,0x02,0xbc,0x82,0x03,0x02,0x02,0xbc,0x00,0x04,0x02,0x02,0xbc,0x88,0x03,0x02, + 0x02,0xbb,0x83,0x03,0x02,0x01,0xba,0x82,0x03,0x02,0x01,0xb9,0x82,0x02,0x02,0x01,0xb9,0x86,0x02,0x01,0x01,0xb8,0x85,0x02,0x01,0x01,0xb7,0x81,0x01,0x01,0x01,0xb7, + 0x83,0x01,0x01,0x01,0xb6,0x86,0x01,0x01,0x00,0xb5,0x84,0x01,0x00,0x00,0xb5,0x88,0x01,0x00,0x00,0xb4,0x92,0x00,0x00,0x00,0xb4,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0x8b,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0x9b,0x00,0x00,0x00,0xb3,0x91,0x00,0x00,0x00,0xb4,0x87,0x01,0x00,0x00, + 0xb4,0x82,0x01,0x00,0x00,0xb5,0x81,0x01,0x01,0x00,0xb5,0x89,0x01,0x01,0x01,0xb6,0x81,0x02,0x01,0x01,0xb7,0x8a,0x02,0x01,0x01,0xb8,0x81,0x02,0x02,0x01,0xb9,0x81, + 0x03,0x02,0x01,0xb9,0x84,0x03,0x02,0x01,0xba,0x83,0x03,0x02,0x02,0xbb,0x00,0x03,0x02,0x02,0xbc,0x85,0x04,0x02,0x02,0xbc,0x84,0x04,0x03,0x02,0xbd,0x01,0x04,0x03, + 0x02,0xbe,0x05,0x03,0x02,0xbe,0x81,0x04,0x03,0x02,0xbe,0x81,0x05,0x03,0x02,0xbe,0x82,0x04,0x03,0x02,0xbe,0x00,0x04,0x03,0x02,0xbf,0x81,0x05,0x03,0x02,0xbf,0x82, + 0x05,0x03,0x02,0xc0,0x00,0x05,0x04,0x03,0xc0,0x81,0x05,0x04,0x03,0xc1,0x02,0x06,0x04,0x03,0xc1,0x05,0x04,0x03,0xc1,0x06,0x04,0x03,0xc1,0x85,0x05,0x04,0x03,0xc1, + 0x87,0x06,0x04,0x03,0xc2,0x86,0x06,0x04,0x03,0xc3,0x86,0x06,0x04,0x03,0xc4,0x81,0x07,0x04,0x03,0xc5,0x97,0x07,0x05,0x02,0xc5,0xa4,0x07,0x05,0x02,0xc6,0x8b,0x07, + 0x05,0x04,0xc6,0x00,0x07,0x05,0x02,0xc6,0x96,0x07,0x05,0x04,0xc6,0x00,0x07,0x05,0x02,0xc6,0x98,0x07,0x05,0x04,0xc6,0x00,0x07,0x05,0x02,0xc6,0x8b,0x07,0x05,0x04, + 0xc6,0x00,0x07,0x05,0x02,0xc6,0x88,0x07,0x05,0x04,0xc6,0x00,0x07,0x05,0x02,0xc6,0x85,0x07,0x05,0x04,0xc6,0xa4,0x07,0x05,0x02,0xc6,0x98,0x07,0x05,0x02,0xc5,0x00, + 0x07,0x04,0x03,0xc5,0x81,0x06,0x04,0x03,0xc4,0x81,0x07,0x04,0x03,0xc4,0x82,0x06,0x04,0x03,0xc4,0x86,0x06,0x04,0x03,0xc3,0x87,0x06,0x04,0x03,0xc2,0x82,0x06,0x04, + 0x03,0xc1,0x01,0x05,0x04,0x03,0xc1,0x06,0x04,0x03,0xc1,0x81,0x05,0x04,0x03,0xc1,0x00,0x05,0x04,0x01,0xc1,0x82,0x05,0x04,0x03,0xc1,0x01,0x05,0x04,0x03,0xc0,0x05, + 0x03,0x03,0xc0,0x81,0x05,0x03,0x02,0xc0,0x82,0x05,0x03,0x02,0xbf,0x00,0x05,0x03,0x02,0xbe,0x85,0x04,0x03,0x02,0xbe,0x01,0x05,0x03,0x02,0xbe,0x04,0x03,0x02,0xbe, + 0x84,0x04,0x03,0x02,0xbd,0x82,0x04,0x02,0x02,0xbc,0x00,0x04,0x03,0x02,0xbc,0x82,0x04,0x02,0x02,0xbc,0x83,0x03,0x02,0x02,0xbb,0x84,0x03,0x02,0x01,0xba,0x82,0x03, + 0x02,0x01,0xb9,0x00,0x02,0x02,0x01,0xb9,0x8a,0x02,0x01,0x01,0xb8,0x81,0x02,0x01,0x01,0xb7,0x89,0x01,0x01,0x01,0xb6,0x81,0x01,0x01,0x00,0xb5,0x82,0x01,0x00,0x00, + 0xb5,0x87,0x01,0x00,0x00,0xb4,0x91,0x00,0x00,0x00,0xb4,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0x89,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0x99,0x00,0x00,0x00,0xb3,0x91,0x00,0x00,0x00,0xb4,0x81,0x01,0x00,0x00,0xb4,0x87,0x01,0x00,0x00,0xb5,0x82,0x01,0x01,0x00,0xb5,0x83,0x01,0x01, + 0x01,0xb6,0x03,0x02,0x01,0x01,0xb7,0x01,0x01,0x01,0xb7,0x02,0x01,0x01,0xb7,0x01,0x01,0x01,0xb7,0x83,0x02,0x01,0x01,0xb7,0x82,0x02,0x01,0x01,0xb8,0x85,0x02,0x02, + 0x01,0xb9,0x85,0x03,0x02,0x01,0xba,0x82,0x03,0x02,0x02,0xbb,0x83,0x03,0x02,0x02,0xbc,0x82,0x04,0x02,0x02,0xbc,0x85,0x04,0x03,0x02,0xbd,0x81,0x04,0x03,0x02,0xbe, + 0x83,0x04,0x03,0x02,0xbf,0x00,0x05,0x03,0x02,0xbf,0x81,0x05,0x03,0x02,0xc0,0x01,0x05,0x03,0x03,0xc0,0x05,0x04,0x03,0xc0,0x86,0x05,0x04,0x03,0xc1,0x83,0x06,0x04, + 0x03,0xc2,0x81,0x06,0x04,0x03,0xc3,0x00,0x06,0x05,0x02,0xc3,0x83,0x06,0x04,0x03,0xc3,0x82,0x06,0x04,0x03,0xc4,0x81,0x07,0x04,0x03,0xc5,0x89,0x07,0x05,0x02,0xc5, + 0x04,0x07,0x05,0x02,0xc6,0x07,0x05,0x04,0xc6,0x07,0x05,0x02,0xc6,0x07,0x05,0x02,0xc7,0x07,0x05,0x04,0xc7,0x82,0x08,0x05,0x04,0xc7,0x00,0x08,0x05,0x02,0xc7,0x86, + 0x08,0x05,0x04,0xc7,0x86,0x08,0x05,0x04,0xc8,0x00,0x08,0x05,0x02,0xc8,0x8f,0x08,0x05,0x04,0xc8,0x81,0x08,0x05,0x04,0xc9,0xff,0x08,0x06,0x03,0xc9,0x9d,0x08,0x06, + 0x03,0xc9,0x81,0x08,0x05,0x04,0xc9,0x84,0x08,0x05,0x04,0xc8,0x00,0x08,0x06,0x03,0xc8,0x91,0x08,0x05,0x04,0xc8,0x89,0x08,0x05,0x04,0xc7,0x82,0x07,0x05,0x04,0xc7, + 0x02,0x07,0x05,0x02,0xc6,0x07,0x05,0x04,0xc6,0x07,0x05,0x02,0xc6,0x89,0x07,0x05,0x02,0xc5,0x81,0x07,0x04,0x03,0xc5,0x82,0x06,0x04,0x03,0xc4,0x86,0x06,0x04,0x03, + 0xc3,0x83,0x06,0x04,0x03,0xc2,0x00,0x05,0x04,0x03,0xc1,0x81,0x06,0x04,0x03,0xc1,0x01,0x05,0x04,0x03,0xc1,0x06,0x04,0x03,0xc1,0x81,0x05,0x04,0x03,0xc1,0x01,0x05, + 0x04,0x03,0xc0,0x05,0x03,0x03,0xc0,0x81,0x05,0x03,0x02,0xc0,0x83,0x05,0x03,0x02,0xbf,0x00,0x04,0x03,0x02,0xbf,0x81,0x04,0x03,0x02,0xbe,0x85,0x04,0x03,0x02,0xbd, + 0x82,0x04,0x02,0x02,0xbc,0x81,0x03,0x02,0x02,0xbc,0x01,0x04,0x02,0x02,0xbc,0x03,0x02,0x02,0xbc,0x82,0x03,0x02,0x02,0xbb,0x85,0x03,0x02,0x01,0xba,0x85,0x02,0x02, + 0x01,0xb9,0x82,0x02,0x01,0x01,0xb8,0x84,0x02,0x01,0x01,0xb7,0x82,0x01,0x01,0x01,0xb7,0x83,0x01,0x01,0x01,0xb6,0x82,0x01,0x01,0x00,0xb5,0x87,0x01,0x00,0x00,0xb5, + 0x81,0x01,0x00,0x00,0xb4,0x91,0x00,0x00,0x00,0xb4,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0x87,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0x99,0x00,0x00,0x00,0xb3,0x8d,0x00,0x00,0x00,0xb4,0x85,0x01,0x00,0x00,0xb4,0x87,0x01,0x00,0x00,0xb5,0x00,0x01,0x01,0x00,0xb5,0x87,0x01,0x01,0x01, + 0xb6,0x00,0x01,0x01,0x01,0xb7,0x82,0x02,0x01,0x01,0xb7,0x83,0x02,0x01,0x01,0xb8,0x00,0x02,0x02,0x01,0xb9,0x84,0x03,0x02,0x01,0xb9,0x84,0x03,0x02,0x01,0xba,0x02, + 0x03,0x02,0x02,0xbb,0x03,0x02,0x01,0xbb,0x03,0x02,0x02,0xbb,0x81,0x04,0x02,0x02,0xbc,0x01,0x04,0x03,0x02,0xbc,0x04,0x02,0x02,0xbc,0x85,0x04,0x03,0x02,0xbd,0x02, + 0x04,0x03,0x02,0xbe,0x05,0x03,0x02,0xbe,0x04,0x03,0x02,0xbf,0x83,0x05,0x03,0x02,0xbf,0x81,0x05,0x03,0x02,0xc0,0x81,0x05,0x03,0x03,0xc0,0x81,0x05,0x04,0x03,0xc0, + 0x81,0x05,0x04,0x03,0xc1,0x86,0x06,0x04,0x03,0xc2,0x81,0x06,0x04,0x03,0xc3,0x00,0x07,0x04,0x03,0xc4,0x81,0x06,0x04,0x03,0xc4,0x81,0x07,0x04,0x03,0xc4,0x82,0x06, + 0x04,0x03,0xc4,0x00,0x07,0x04,0x03,0xc5,0x84,0x07,0x05,0x02,0xc5,0x81,0x07,0x05,0x04,0xc6,0x02,0x07,0x05,0x04,0xc7,0x08,0x05,0x04,0xc7,0x07,0x05,0x02,0xc7,0x81, + 0x08,0x05,0x04,0xc7,0x81,0x07,0x05,0x04,0xc7,0x82,0x08,0x05,0x04,0xc7,0x87,0x08,0x05,0x04,0xc8,0x00,0x08,0x05,0x04,0xc9,0x89,0x08,0x06,0x03,0xc9,0x00,0x09,0x06, + 0x03,0xca,0x88,0x08,0x06,0x03,0xca,0x02,0x09,0x06,0x03,0xca,0x08,0x06,0x03,0xca,0x09,0x06,0x03,0xca,0x85,0x08,0x06,0x03,0xca,0x00,0x09,0x06,0x03,0xca,0xff,0x09, + 0x06,0x03,0xcb,0xa1,0x09,0x06,0x03,0xcb,0x01,0x08,0x06,0x03,0xca,0x09,0x06,0x03,0xca,0x86,0x08,0x06,0x03,0xca,0x00,0x09,0x06,0x03,0xca,0x82,0x08,0x06,0x03,0xca, + 0x02,0x09,0x06,0x03,0xca,0x08,0x06,0x03,0xca,0x09,0x06,0x03,0xca,0x83,0x08,0x06,0x03,0xca,0x89,0x08,0x06,0x03,0xc9,0x00,0x08,0x05,0x04,0xc9,0x83,0x08,0x05,0x04, + 0xc8,0x00,0x08,0x06,0x03,0xc8,0x82,0x08,0x05,0x04,0xc8,0x81,0x08,0x05,0x04,0xc7,0x81,0x07,0x05,0x04,0xc7,0x02,0x08,0x05,0x04,0xc7,0x07,0x05,0x04,0xc7,0x08,0x05, + 0x04,0xc7,0x82,0x07,0x05,0x04,0xc7,0x81,0x07,0x05,0x04,0xc6,0x84,0x07,0x05,0x02,0xc5,0x00,0x07,0x04,0x03,0xc5,0x81,0x06,0x04,0x03,0xc4,0x03,0x07,0x04,0x03,0xc4, + 0x06,0x04,0x03,0xc4,0x07,0x05,0x02,0xc4,0x07,0x04,0x03,0xc4,0x81,0x06,0x04,0x03,0xc4,0x81,0x06,0x04,0x03,0xc3,0x86,0x06,0x04,0x03,0xc2,0x81,0x05,0x04,0x03,0xc1, + 0x81,0x05,0x04,0x03,0xc0,0x81,0x05,0x03,0x03,0xc0,0x81,0x05,0x03,0x02,0xc0,0x83,0x05,0x03,0x02,0xbf,0x02,0x04,0x03,0x02,0xbf,0x05,0x03,0x02,0xbe,0x04,0x03,0x02, + 0xbe,0x85,0x04,0x03,0x02,0xbd,0x82,0x04,0x02,0x02,0xbc,0x00,0x03,0x02,0x02,0xbc,0x82,0x03,0x02,0x02,0xbb,0x84,0x03,0x02,0x01,0xba,0x83,0x03,0x02,0x01,0xb9,0x81, + 0x02,0x02,0x01,0xb9,0x83,0x02,0x01,0x01,0xb8,0x82,0x02,0x01,0x01,0xb7,0x00,0x01,0x01,0x01,0xb7,0x87,0x01,0x01,0x01,0xb6,0x00,0x01,0x01,0x00,0xb5,0x87,0x01,0x00, + 0x00,0xb5,0x85,0x01,0x00,0x00,0xb4,0x8d,0x00,0x00,0x00,0xb4,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0x87,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0x99,0x00,0x00,0x00,0xb3,0x91,0x00,0x00,0x00,0xb4,0x81,0x01,0x00,0x00,0xb4,0x87,0x01,0x00,0x00,0xb5,0x00,0x01,0x01,0x00,0xb5,0x87,0x01, + 0x01,0x01,0xb6,0x00,0x01,0x01,0x01,0xb7,0x82,0x02,0x01,0x01,0xb7,0x83,0x02,0x01,0x01,0xb8,0x00,0x02,0x02,0x01,0xb9,0x84,0x03,0x02,0x01,0xb9,0x84,0x03,0x02,0x01, + 0xba,0x82,0x03,0x02,0x02,0xbb,0x00,0x03,0x02,0x02,0xbc,0x82,0x04,0x02,0x02,0xbc,0x85,0x04,0x03,0x02,0xbd,0x01,0x05,0x03,0x02,0xbe,0x04,0x03,0x02,0xbe,0x82,0x04, + 0x03,0x02,0xbf,0x81,0x05,0x03,0x02,0xbf,0x02,0x05,0x04,0x01,0xc0,0x05,0x03,0x02,0xc0,0x05,0x03,0x03,0xc0,0x82,0x05,0x04,0x03,0xc0,0x81,0x06,0x04,0x03,0xc1,0x86, + 0x06,0x04,0x03,0xc2,0x81,0x06,0x04,0x03,0xc3,0x84,0x06,0x04,0x03,0xc4,0x03,0x07,0x04,0x03,0xc4,0x06,0x04,0x03,0xc4,0x07,0x04,0x03,0xc4,0x07,0x05,0x02,0xc4,0x82, + 0x07,0x05,0x02,0xc5,0x00,0x07,0x05,0x02,0xc6,0x81,0x07,0x05,0x04,0xc6,0x00,0x08,0x05,0x04,0xc6,0x81,0x07,0x05,0x04,0xc7,0x87,0x08,0x05,0x04,0xc7,0x83,0x08,0x05, + 0x04,0xc8,0x8b,0x08,0x06,0x03,0xc9,0x01,0x09,0x06,0x03,0xc9,0x09,0x06,0x03,0xca,0x81,0x08,0x06,0x03,0xca,0x00,0x09,0x06,0x03,0xca,0x84,0x08,0x06,0x03,0xca,0x81, + 0x09,0x06,0x03,0xca,0x85,0x08,0x06,0x03,0xca,0x81,0x09,0x06,0x03,0xca,0xff,0x09,0x06,0x03,0xcb,0xa7,0x09,0x06,0x03,0xcb,0x81,0x09,0x06,0x03,0xca,0x81,0x08,0x06, + 0x03,0xca,0x06,0x09,0x06,0x03,0xca,0x08,0x06,0x03,0xca,0x09,0x06,0x03,0xca,0x08,0x06,0x03,0xca,0x09,0x06,0x03,0xca,0x08,0x06,0x03,0xca,0x09,0x06,0x03,0xca,0x81, + 0x08,0x06,0x03,0xca,0x00,0x09,0x06,0x03,0xca,0x81,0x08,0x06,0x03,0xca,0x02,0x09,0x06,0x03,0xca,0x08,0x06,0x03,0xca,0x09,0x06,0x03,0xca,0x8c,0x08,0x06,0x03,0xc9, + 0x83,0x08,0x05,0x04,0xc8,0x87,0x08,0x05,0x04,0xc7,0x81,0x07,0x05,0x04,0xc7,0x82,0x07,0x05,0x04,0xc6,0x00,0x07,0x05,0x02,0xc6,0x82,0x07,0x05,0x02,0xc5,0x83,0x06, + 0x04,0x03,0xc4,0x02,0x07,0x05,0x02,0xc4,0x07,0x04,0x03,0xc4,0x06,0x04,0x03,0xc4,0x81,0x07,0x04,0x03,0xc4,0x81,0x06,0x04,0x03,0xc3,0x86,0x06,0x04,0x03,0xc2,0x81, + 0x06,0x04,0x03,0xc1,0x81,0x05,0x04,0x03,0xc0,0x81,0x05,0x03,0x03,0xc0,0x81,0x05,0x03,0x02,0xc0,0x81,0x05,0x03,0x02,0xbf,0x82,0x04,0x03,0x02,0xbf,0x01,0x04,0x03, + 0x02,0xbe,0x05,0x03,0x02,0xbe,0x85,0x04,0x03,0x02,0xbd,0x82,0x04,0x02,0x02,0xbc,0x00,0x03,0x02,0x02,0xbc,0x81,0x03,0x02,0x02,0xbb,0x00,0x03,0x02,0x01,0xbb,0x84, + 0x03,0x02,0x01,0xba,0x83,0x03,0x02,0x01,0xb9,0x81,0x02,0x02,0x01,0xb9,0x83,0x02,0x01,0x01,0xb8,0x82,0x02,0x01,0x01,0xb7,0x00,0x01,0x01,0x01,0xb7,0x87,0x01,0x01, + 0x01,0xb6,0x00,0x01,0x01,0x00,0xb5,0x87,0x01,0x00,0x00,0xb5,0x81,0x01,0x00,0x00,0xb4,0x91,0x00,0x00,0x00,0xb4,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0x87,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0x9b,0x00,0x00,0x00,0xb3,0x8f,0x00,0x00,0x00,0xb4,0x81,0x01,0x00,0x00,0xb4,0x85,0x01, + 0x00,0x00,0xb5,0x01,0x01,0x01,0x00,0xb5,0x01,0x00,0x00,0xb5,0x82,0x01,0x01,0x00,0xb5,0x86,0x01,0x01,0x01,0xb6,0x00,0x01,0x01,0x01,0xb7,0x84,0x02,0x01,0x01,0xb7, + 0x81,0x02,0x01,0x01,0xb8,0x86,0x02,0x02,0x01,0xb9,0x00,0x03,0x02,0x01,0xb9,0x83,0x03,0x02,0x01,0xba,0x81,0x03,0x02,0x02,0xbb,0x86,0x04,0x02,0x02,0xbc,0x82,0x04, + 0x03,0x02,0xbd,0x00,0x04,0x03,0x02,0xbe,0x82,0x05,0x03,0x02,0xbe,0x00,0x04,0x03,0x02,0xbf,0x81,0x05,0x03,0x02,0xbf,0x84,0x05,0x03,0x02,0xc0,0x01,0x05,0x03,0x03, + 0xc0,0x05,0x04,0x03,0xc0,0x81,0x05,0x04,0x03,0xc1,0x87,0x06,0x04,0x03,0xc2,0x82,0x06,0x04,0x03,0xc3,0x81,0x07,0x04,0x03,0xc4,0x00,0x06,0x04,0x03,0xc4,0x84,0x07, + 0x04,0x03,0xc5,0x81,0x07,0x05,0x02,0xc5,0x82,0x07,0x05,0x02,0xc6,0x83,0x07,0x05,0x04,0xc6,0x00,0x08,0x05,0x04,0xc6,0x81,0x07,0x05,0x04,0xc7,0x00,0x08,0x05,0x04, + 0xc7,0x83,0x07,0x05,0x04,0xc7,0x00,0x08,0x05,0x04,0xc7,0x8e,0x08,0x05,0x04,0xc8,0x02,0x08,0x06,0x03,0xc8,0x08,0x05,0x04,0xc8,0x08,0x05,0x04,0xc9,0x87,0x08,0x06, + 0x03,0xc9,0x00,0x08,0x06,0x03,0xca,0x82,0x09,0x06,0x03,0xca,0x04,0x08,0x06,0x03,0xca,0x09,0x06,0x03,0xca,0x08,0x06,0x03,0xca,0x09,0x06,0x03,0xca,0x08,0x06,0x03, + 0xca,0x81,0x09,0x06,0x03,0xca,0x85,0x08,0x06,0x03,0xca,0x81,0x09,0x06,0x03,0xca,0x81,0x08,0x06,0x03,0xca,0x03,0x09,0x06,0x03,0xca,0x08,0x06,0x03,0xca,0x09,0x06, + 0x03,0xca,0x08,0x06,0x03,0xca,0x81,0x09,0x06,0x03,0xca,0x84,0x08,0x06,0x03,0xca,0x06,0x09,0x06,0x03,0xca,0x08,0x06,0x03,0xca,0x09,0x06,0x03,0xca,0x08,0x06,0x03, + 0xca,0x09,0x06,0x03,0xca,0x08,0x06,0x03,0xca,0x09,0x06,0x03,0xca,0x87,0x08,0x06,0x03,0xca,0x81,0x09,0x06,0x03,0xca,0x82,0x08,0x06,0x03,0xca,0x00,0x09,0x06,0x03, + 0xca,0x81,0x08,0x06,0x03,0xca,0x02,0x09,0x06,0x03,0xca,0x08,0x06,0x03,0xca,0x09,0x06,0x03,0xca,0x84,0x08,0x06,0x03,0xca,0x81,0x09,0x06,0x03,0xca,0x88,0x08,0x06, + 0x03,0xca,0x00,0x09,0x06,0x03,0xca,0x81,0x08,0x06,0x03,0xca,0x00,0x09,0x06,0x03,0xca,0x81,0x08,0x06,0x03,0xca,0x81,0x09,0x06,0x03,0xca,0x81,0x08,0x06,0x03,0xca, + 0x81,0x09,0x06,0x03,0xca,0x84,0x08,0x06,0x03,0xca,0x01,0x09,0x06,0x03,0xca,0x08,0x06,0x03,0xca,0x81,0x09,0x06,0x03,0xca,0x81,0x08,0x06,0x03,0xca,0x00,0x09,0x06, + 0x03,0xca,0x81,0x08,0x06,0x03,0xca,0x82,0x09,0x06,0x03,0xca,0x84,0x08,0x06,0x03,0xca,0x00,0x09,0x06,0x03,0xca,0x81,0x08,0x06,0x03,0xca,0x00,0x09,0x06,0x03,0xca, + 0x81,0x08,0x06,0x03,0xca,0x81,0x09,0x06,0x03,0xca,0x01,0x08,0x06,0x03,0xca,0x09,0x06,0x03,0xca,0x81,0x08,0x06,0x03,0xca,0x00,0x09,0x06,0x03,0xca,0x82,0x08,0x06, + 0x03,0xca,0x00,0x09,0x06,0x03,0xca,0x84,0x08,0x06,0x03,0xca,0x00,0x09,0x06,0x03,0xca,0x85,0x08,0x06,0x03,0xca,0x00,0x09,0x06,0x03,0xca,0x81,0x08,0x06,0x03,0xca, + 0x00,0x09,0x06,0x03,0xca,0x8a,0x08,0x06,0x03,0xca,0x00,0x09,0x06,0x03,0xca,0x83,0x08,0x06,0x03,0xca,0x00,0x09,0x06,0x03,0xca,0x84,0x08,0x06,0x03,0xca,0x01,0x09, + 0x06,0x03,0xca,0x08,0x06,0x03,0xca,0x81,0x09,0x06,0x03,0xca,0x82,0x08,0x06,0x03,0xca,0x00,0x09,0x06,0x03,0xca,0x83,0x08,0x06,0x03,0xca,0x81,0x09,0x06,0x03,0xca, + 0x82,0x08,0x06,0x03,0xca,0x01,0x08,0x06,0x03,0xc9,0x09,0x06,0x03,0xc9,0x85,0x08,0x06,0x03,0xc9,0x00,0x08,0x05,0x04,0xc9,0x90,0x08,0x05,0x04,0xc8,0x05,0x08,0x05, + 0x04,0xc7,0x07,0x05,0x04,0xc7,0x08,0x05,0x04,0xc7,0x07,0x05,0x04,0xc7,0x07,0x05,0x02,0xc7,0x07,0x05,0x04,0xc7,0x81,0x08,0x05,0x04,0xc7,0x00,0x08,0x05,0x04,0xc6, + 0x83,0x07,0x05,0x04,0xc6,0x82,0x07,0x05,0x02,0xc6,0x81,0x07,0x05,0x02,0xc5,0x84,0x07,0x04,0x03,0xc5,0x00,0x07,0x04,0x03,0xc4,0x81,0x06,0x04,0x03,0xc4,0x82,0x06, + 0x04,0x03,0xc3,0x87,0x06,0x04,0x03,0xc2,0x03,0x06,0x04,0x03,0xc1,0x05,0x04,0x03,0xc1,0x05,0x04,0x03,0xc0,0x05,0x03,0x03,0xc0,0x84,0x05,0x03,0x02,0xc0,0x81,0x05, + 0x03,0x02,0xbf,0x00,0x04,0x03,0x02,0xbf,0x81,0x04,0x03,0x02,0xbe,0x01,0x05,0x03,0x02,0xbe,0x04,0x03,0x02,0xbe,0x82,0x04,0x03,0x02,0xbd,0x84,0x04,0x02,0x02,0xbc, + 0x01,0x04,0x03,0x02,0xbc,0x03,0x02,0x02,0xbc,0x81,0x03,0x02,0x02,0xbb,0x83,0x03,0x02,0x01,0xba,0x81,0x03,0x02,0x01,0xb9,0x85,0x02,0x02,0x01,0xb9,0x81,0x02,0x01, + 0x01,0xb8,0x85,0x02,0x01,0x01,0xb7,0x86,0x01,0x01,0x01,0xb6,0x82,0x01,0x01,0x00,0xb5,0x87,0x01,0x00,0x00,0xb5,0x81,0x01,0x00,0x00,0xb4,0x8f,0x00,0x00,0x00,0xb4, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0x89,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0x9b,0x00,0x00,0x00,0xb3,0x91,0x00, + 0x00,0x00,0xb4,0x81,0x01,0x00,0x00,0xb4,0x85,0x01,0x00,0x00,0xb5,0x85,0x01,0x01,0x00,0xb5,0x83,0x01,0x01,0x01,0xb6,0x00,0x01,0x01,0x01,0xb7,0x84,0x02,0x01,0x01, + 0xb7,0x87,0x02,0x01,0x01,0xb8,0x81,0x02,0x02,0x01,0xb9,0x81,0x03,0x02,0x01,0xb9,0x83,0x03,0x02,0x01,0xba,0x84,0x03,0x02,0x02,0xbb,0x00,0x03,0x02,0x02,0xbc,0x84, + 0x04,0x02,0x02,0xbc,0x82,0x04,0x03,0x02,0xbd,0x83,0x04,0x03,0x02,0xbe,0x01,0x05,0x03,0x02,0xbe,0x04,0x03,0x02,0xbe,0x82,0x05,0x03,0x02,0xbf,0x83,0x05,0x03,0x02, + 0xc0,0x81,0x05,0x03,0x03,0xc0,0x82,0x05,0x04,0x03,0xc0,0x81,0x05,0x04,0x03,0xc1,0x86,0x06,0x04,0x03,0xc2,0x81,0x06,0x04,0x03,0xc3,0x00,0x07,0x05,0x02,0xc4,0x82, + 0x06,0x04,0x03,0xc4,0x02,0x07,0x04,0x03,0xc4,0x06,0x04,0x03,0xc4,0x07,0x04,0x03,0xc4,0x81,0x06,0x04,0x03,0xc4,0x89,0x07,0x05,0x02,0xc5,0x00,0x07,0x05,0x02,0xc6, + 0x89,0x07,0x05,0x04,0xc6,0x00,0x07,0x05,0x02,0xc7,0x81,0x07,0x05,0x04,0xc7,0x02,0x07,0x05,0x02,0xc7,0x08,0x05,0x04,0xc7,0x07,0x05,0x02,0xc7,0x81,0x07,0x05,0x04, + 0xc7,0x85,0x08,0x05,0x04,0xc7,0x88,0x08,0x05,0x04,0xc8,0x00,0x08,0x05,0x02,0xc8,0xb5,0x08,0x05,0x04,0xc8,0x00,0x08,0x06,0x03,0xc8,0x81,0x08,0x05,0x04,0xc8,0x00, + 0x08,0x06,0x03,0xc8,0xbd,0x08,0x05,0x04,0xc8,0x00,0x08,0x06,0x03,0xc8,0xa7,0x08,0x05,0x04,0xc8,0x00,0x08,0x05,0x02,0xc8,0x83,0x08,0x05,0x04,0xc8,0x00,0x08,0x05, + 0x02,0xc8,0x84,0x08,0x05,0x04,0xc8,0x01,0x08,0x05,0x02,0xc8,0x08,0x05,0x04,0xc8,0x85,0x08,0x05,0x04,0xc7,0x85,0x07,0x05,0x04,0xc7,0x81,0x08,0x05,0x04,0xc7,0x81, + 0x07,0x05,0x04,0xc6,0x00,0x07,0x05,0x02,0xc6,0x86,0x07,0x05,0x04,0xc6,0x00,0x07,0x05,0x02,0xc6,0x88,0x07,0x05,0x02,0xc5,0x01,0x07,0x04,0x03,0xc5,0x07,0x04,0x03, + 0xc4,0x87,0x06,0x04,0x03,0xc4,0x81,0x06,0x04,0x03,0xc3,0x86,0x06,0x04,0x03,0xc2,0x81,0x05,0x04,0x03,0xc1,0x82,0x05,0x04,0x03,0xc0,0x81,0x05,0x03,0x03,0xc0,0x83, + 0x05,0x03,0x02,0xc0,0x81,0x05,0x03,0x02,0xbf,0x00,0x04,0x03,0x02,0xbf,0x85,0x04,0x03,0x02,0xbe,0x82,0x04,0x03,0x02,0xbd,0x83,0x04,0x02,0x02,0xbc,0x01,0x03,0x02, + 0x02,0xbc,0x04,0x02,0x02,0xbc,0x84,0x03,0x02,0x02,0xbb,0x83,0x03,0x02,0x01,0xba,0x00,0x03,0x02,0x01,0xb9,0x82,0x02,0x02,0x01,0xb9,0x87,0x02,0x01,0x01,0xb8,0x85, + 0x02,0x01,0x01,0xb7,0x83,0x01,0x01,0x01,0xb6,0x85,0x01,0x01,0x00,0xb5,0x85,0x01,0x00,0x00,0xb5,0x81,0x01,0x00,0x00,0xb4,0x91,0x00,0x00,0x00,0xb4,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0x89,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0x9d,0x00,0x00,0x00,0xb3,0x8f,0x00,0x00,0x00,0xb4, + 0x87,0x01,0x00,0x00,0xb4,0x83,0x01,0x00,0x00,0xb5,0x86,0x01,0x01,0x00,0xb5,0x84,0x01,0x01,0x01,0xb6,0x00,0x01,0x01,0x01,0xb7,0x86,0x02,0x01,0x01,0xb7,0x84,0x02, + 0x01,0x01,0xb8,0x01,0x02,0x02,0x01,0xb9,0x03,0x02,0x01,0xb9,0x83,0x03,0x02,0x01,0xba,0x85,0x03,0x02,0x02,0xbb,0x01,0x03,0x02,0x02,0xbc,0x04,0x03,0x02,0xbc,0x81, + 0x04,0x02,0x02,0xbc,0x01,0x04,0x03,0x02,0xbc,0x04,0x02,0x02,0xbc,0x85,0x04,0x03,0x02,0xbd,0x88,0x04,0x03,0x02,0xbe,0x82,0x05,0x03,0x02,0xbf,0x81,0x05,0x03,0x02, + 0xc0,0x03,0x05,0x03,0x03,0xc0,0x05,0x04,0x03,0xc0,0x05,0x04,0x03,0xc1,0x06,0x04,0x03,0xc1,0x81,0x05,0x04,0x03,0xc1,0x00,0x06,0x04,0x03,0xc1,0x81,0x05,0x04,0x03, + 0xc1,0x8a,0x06,0x04,0x03,0xc2,0x87,0x06,0x04,0x03,0xc3,0x84,0x06,0x04,0x03,0xc4,0x00,0x07,0x04,0x03,0xc4,0x81,0x06,0x04,0x03,0xc4,0x89,0x07,0x04,0x03,0xc5,0x9f, + 0x07,0x05,0x02,0xc5,0xff,0x07,0x05,0x02,0xc6,0x83,0x07,0x05,0x02,0xc6,0x9f,0x07,0x05,0x02,0xc5,0x83,0x07,0x04,0x03,0xc5,0x00,0x07,0x05,0x02,0xc5,0x84,0x07,0x04, + 0x03,0xc5,0x87,0x06,0x04,0x03,0xc4,0x00,0x06,0x05,0x02,0xc3,0x86,0x06,0x04,0x03,0xc3,0x8a,0x06,0x04,0x03,0xc2,0x00,0x06,0x04,0x03,0xc1,0x83,0x05,0x04,0x03,0xc1, + 0x81,0x06,0x04,0x03,0xc1,0x01,0x05,0x04,0x03,0xc0,0x05,0x03,0x03,0xc0,0x81,0x05,0x03,0x02,0xc0,0x81,0x05,0x03,0x02,0xbf,0x00,0x04,0x03,0x02,0xbf,0x83,0x04,0x03, + 0x02,0xbe,0x00,0x05,0x03,0x02,0xbe,0x83,0x04,0x03,0x02,0xbe,0x85,0x04,0x03,0x02,0xbd,0x85,0x04,0x02,0x02,0xbc,0x85,0x03,0x02,0x02,0xbb,0x83,0x03,0x02,0x01,0xba, + 0x01,0x03,0x02,0x01,0xb9,0x02,0x02,0x01,0xb9,0x84,0x02,0x01,0x01,0xb8,0x86,0x02,0x01,0x01,0xb7,0x00,0x01,0x01,0x01,0xb7,0x84,0x01,0x01,0x01,0xb6,0x86,0x01,0x01, + 0x00,0xb5,0x83,0x01,0x00,0x00,0xb5,0x87,0x01,0x00,0x00,0xb4,0x8f,0x00,0x00,0x00,0xb4,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0x8b,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xa2,0x00,0x00,0x00,0xb3,0x92,0x00,0x00,0x00,0xb4,0x83,0x01,0x00,0x00,0xb4,0x00,0x01,0x00,0x00,0xb5,0x85,0x01, + 0x01,0x00,0xb5,0x88,0x01,0x01,0x01,0xb6,0x83,0x01,0x01,0x01,0xb7,0x85,0x02,0x01,0x01,0xb7,0x82,0x02,0x01,0x01,0xb8,0x82,0x02,0x02,0x01,0xb9,0x82,0x03,0x02,0x01, + 0xb9,0x82,0x03,0x02,0x01,0xba,0x88,0x03,0x02,0x02,0xbb,0x83,0x04,0x02,0x02,0xbc,0x8a,0x04,0x03,0x02,0xbd,0x00,0x04,0x03,0x02,0xbe,0x81,0x05,0x03,0x02,0xbe,0x00, + 0x04,0x03,0x02,0xbe,0x87,0x05,0x03,0x02,0xbf,0x81,0x05,0x03,0x02,0xc0,0x86,0x05,0x03,0x03,0xc0,0x00,0x05,0x04,0x03,0xc0,0x81,0x05,0x04,0x03,0xc1,0x00,0x05,0x04, + 0x01,0xc1,0x82,0x05,0x04,0x03,0xc1,0x00,0x06,0x04,0x03,0xc1,0x81,0x05,0x04,0x03,0xc1,0xa0,0x06,0x04,0x03,0xc2,0xcf,0x06,0x04,0x03,0xc3,0x00,0x06,0x05,0x02,0xc3, + 0xd0,0x06,0x04,0x03,0xc3,0xa0,0x06,0x04,0x03,0xc2,0x83,0x05,0x04,0x03,0xc1,0x00,0x06,0x04,0x03,0xc1,0x83,0x05,0x04,0x03,0xc1,0x00,0x05,0x04,0x01,0xc0,0x86,0x05, + 0x03,0x03,0xc0,0x81,0x05,0x03,0x02,0xc0,0x86,0x05,0x03,0x02,0xbf,0x00,0x04,0x03,0x02,0xbf,0x83,0x04,0x03,0x02,0xbe,0x8a,0x04,0x03,0x02,0xbd,0x82,0x04,0x02,0x02, + 0xbc,0x00,0x03,0x02,0x02,0xbc,0x85,0x03,0x02,0x02,0xbb,0x00,0x03,0x02,0x01,0xbb,0x81,0x03,0x02,0x02,0xbb,0x82,0x03,0x02,0x01,0xba,0x83,0x03,0x02,0x01,0xb9,0x81, + 0x02,0x02,0x01,0xb9,0x82,0x02,0x01,0x01,0xb8,0x86,0x02,0x01,0x01,0xb7,0x82,0x01,0x01,0x01,0xb7,0x88,0x01,0x01,0x01,0xb6,0x85,0x01,0x01,0x00,0xb5,0x00,0x01,0x00, + 0x00,0xb5,0x83,0x01,0x00,0x00,0xb4,0x92,0x00,0x00,0x00,0xb4,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0x90,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xa6,0x00,0x00,0x00,0xb3,0x8e,0x00,0x00,0x00,0xb4,0x82,0x01,0x00,0x00,0xb4,0x87,0x01,0x00,0x00,0xb5,0x86,0x01,0x01,0x00,0xb5,0x87,0x01, + 0x01,0x01,0xb6,0x86,0x02,0x01,0x01,0xb7,0x86,0x02,0x01,0x01,0xb8,0x01,0x02,0x02,0x01,0xb8,0x02,0x01,0x01,0xb8,0x81,0x02,0x02,0x01,0xb9,0x00,0x03,0x02,0x01,0xb9, + 0x88,0x03,0x02,0x01,0xba,0x85,0x03,0x02,0x02,0xbb,0x02,0x03,0x02,0x01,0xbb,0x04,0x02,0x02,0xbc,0x03,0x02,0x02,0xbc,0x85,0x04,0x02,0x02,0xbc,0x89,0x04,0x03,0x02, + 0xbd,0x8d,0x04,0x03,0x02,0xbe,0x00,0x04,0x03,0x02,0xbf,0x89,0x05,0x03,0x02,0xbf,0x8c,0x05,0x03,0x02,0xc0,0x90,0x05,0x03,0x03,0xc0,0x00,0x05,0x04,0x03,0xc0,0x87, + 0x05,0x03,0x03,0xc0,0x83,0x05,0x04,0x03,0xc0,0x02,0x05,0x04,0x01,0xc0,0x05,0x04,0x03,0xc0,0x05,0x04,0x01,0xc0,0x88,0x05,0x04,0x03,0xc0,0x00,0x05,0x04,0x01,0xc0, + 0x86,0x05,0x04,0x03,0xc0,0x00,0x05,0x04,0x01,0xc0,0x8e,0x05,0x04,0x03,0xc0,0x00,0x05,0x04,0x01,0xc0,0xa1,0x05,0x04,0x03,0xc0,0x00,0x05,0x04,0x01,0xc0,0x98,0x05, + 0x04,0x03,0xc0,0x00,0x05,0x04,0x01,0xc0,0x92,0x05,0x04,0x03,0xc0,0x00,0x05,0x04,0x01,0xc0,0x8d,0x05,0x04,0x03,0xc0,0x99,0x05,0x03,0x03,0xc0,0x8c,0x05,0x03,0x02, + 0xc0,0x8a,0x05,0x03,0x02,0xbf,0x02,0x04,0x03,0x02,0xbe,0x05,0x03,0x02,0xbe,0x04,0x03,0x02,0xbe,0x81,0x05,0x03,0x02,0xbe,0x00,0x04,0x03,0x02,0xbe,0x83,0x05,0x03, + 0x02,0xbe,0x01,0x04,0x03,0x02,0xbe,0x05,0x03,0x02,0xbe,0x81,0x04,0x03,0x02,0xbe,0x89,0x04,0x03,0x02,0xbd,0x85,0x04,0x02,0x02,0xbc,0x81,0x03,0x02,0x02,0xbc,0x86, + 0x03,0x02,0x02,0xbb,0x88,0x03,0x02,0x01,0xba,0x81,0x03,0x02,0x01,0xb9,0x00,0x02,0x02,0x01,0xb9,0x88,0x02,0x01,0x01,0xb8,0x85,0x02,0x01,0x01,0xb7,0x00,0x01,0x01, + 0x01,0xb7,0x87,0x01,0x01,0x01,0xb6,0x86,0x01,0x01,0x00,0xb5,0x87,0x01,0x00,0x00,0xb5,0x82,0x01,0x00,0x00,0xb4,0x8e,0x00,0x00,0x00,0xb4,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0x94,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xa6,0x00,0x00,0x00,0xb3,0x91,0x00,0x00,0x00,0xb4,0x85,0x01, + 0x00,0x00,0xb4,0x88,0x01,0x00,0x00,0xb5,0x81,0x01,0x01,0x00,0xb5,0x8c,0x01,0x01,0x01,0xb6,0x00,0x01,0x01,0x01,0xb7,0x87,0x02,0x01,0x01,0xb7,0x89,0x02,0x01,0x01, + 0xb8,0x85,0x02,0x02,0x01,0xb9,0x00,0x03,0x02,0x01,0xb9,0x8b,0x03,0x02,0x01,0xba,0x89,0x03,0x02,0x02,0xbb,0x00,0x03,0x02,0x02,0xbc,0x8c,0x04,0x02,0x02,0xbc,0xaf, + 0x04,0x03,0x02,0xbd,0x83,0x04,0x03,0x02,0xbe,0x00,0x05,0x03,0x02,0xbe,0x88,0x04,0x03,0x02,0xbe,0x00,0x05,0x03,0x02,0xbe,0x83,0x04,0x03,0x02,0xbe,0x02,0x05,0x03, + 0x02,0xbe,0x04,0x03,0x02,0xbe,0x05,0x03,0x02,0xbe,0x84,0x04,0x03,0x02,0xbe,0x00,0x05,0x03,0x02,0xbe,0x81,0x04,0x03,0x02,0xbe,0x00,0x05,0x03,0x02,0xbe,0x83,0x04, + 0x03,0x02,0xbe,0x04,0x05,0x03,0x02,0xbe,0x04,0x03,0x02,0xbe,0x05,0x03,0x02,0xbe,0x04,0x03,0x02,0xbe,0x05,0x03,0x02,0xbe,0x88,0x04,0x03,0x02,0xbe,0x00,0x05,0x03, + 0x02,0xbe,0x82,0x04,0x03,0x02,0xbe,0x04,0x05,0x03,0x02,0xbe,0x04,0x03,0x02,0xbe,0x05,0x03,0x02,0xbe,0x04,0x03,0x02,0xbe,0x05,0x03,0x02,0xbe,0x81,0x04,0x03,0x02, + 0xbe,0x00,0x05,0x03,0x02,0xbe,0x82,0x04,0x03,0x02,0xbe,0x00,0x05,0x03,0x02,0xbe,0x82,0x04,0x03,0x02,0xbe,0x81,0x05,0x03,0x02,0xbe,0x82,0x04,0x03,0x02,0xbe,0x81, + 0x05,0x03,0x02,0xbe,0x81,0x04,0x03,0x02,0xbe,0x00,0x05,0x03,0x02,0xbe,0x82,0x04,0x03,0x02,0xbe,0x81,0x05,0x03,0x02,0xbe,0x81,0x04,0x03,0x02,0xbe,0x81,0x05,0x03, + 0x02,0xbe,0x85,0x04,0x03,0x02,0xbe,0x00,0x05,0x03,0x02,0xbe,0x82,0x04,0x03,0x02,0xbe,0x81,0x05,0x03,0x02,0xbe,0x85,0x04,0x03,0x02,0xbe,0x00,0x05,0x03,0x02,0xbe, + 0x86,0x04,0x03,0x02,0xbe,0x02,0x05,0x03,0x02,0xbe,0x04,0x03,0x02,0xbe,0x05,0x03,0x02,0xbe,0x81,0x04,0x03,0x02,0xbe,0x00,0x05,0x03,0x02,0xbe,0x85,0x04,0x03,0x02, + 0xbe,0x81,0x05,0x03,0x02,0xbe,0x03,0x04,0x03,0x02,0xbe,0x05,0x03,0x02,0xbe,0x04,0x03,0x02,0xbe,0x05,0x03,0x02,0xbe,0x84,0x04,0x03,0x02,0xbe,0xaf,0x04,0x03,0x02, + 0xbd,0x8a,0x04,0x02,0x02,0xbc,0x00,0x04,0x03,0x02,0xbc,0x81,0x04,0x02,0x02,0xbc,0x86,0x03,0x02,0x02,0xbb,0x00,0x03,0x02,0x01,0xbb,0x81,0x03,0x02,0x02,0xbb,0x8b, + 0x03,0x02,0x01,0xba,0x00,0x03,0x02,0x01,0xb9,0x85,0x02,0x02,0x01,0xb9,0x89,0x02,0x01,0x01,0xb8,0x87,0x02,0x01,0x01,0xb7,0x00,0x01,0x01,0x01,0xb7,0x8c,0x01,0x01, + 0x01,0xb6,0x81,0x01,0x01,0x00,0xb5,0x88,0x01,0x00,0x00,0xb5,0x85,0x01,0x00,0x00,0xb4,0x91,0x00,0x00,0x00,0xb4,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0x94,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xa8,0x00,0x00,0x00,0xb3,0x95,0x00,0x00,0x00,0xb4,0x83,0x01,0x00,0x00,0xb4,0x81,0x00, + 0x00,0x00,0xb4,0x81,0x01,0x00,0x00,0xb4,0x00,0x01,0x00,0x00,0xb5,0x8c,0x01,0x01,0x00,0xb5,0x87,0x01,0x01,0x01,0xb6,0x01,0x02,0x01,0x01,0xb7,0x01,0x01,0x01,0xb7, + 0x8c,0x02,0x01,0x01,0xb7,0x83,0x02,0x01,0x01,0xb8,0x00,0x02,0x02,0x01,0xb8,0x87,0x02,0x01,0x01,0xb8,0x83,0x02,0x02,0x01,0xb9,0x00,0x03,0x02,0x01,0xb9,0x9b,0x03, + 0x02,0x01,0xba,0xa0,0x03,0x02,0x02,0xbb,0x00,0x03,0x02,0x01,0xbb,0x8f,0x03,0x02,0x02,0xbb,0x00,0x03,0x02,0x01,0xbb,0x8c,0x03,0x02,0x02,0xbb,0x00,0x03,0x02,0x02, + 0xbc,0x96,0x04,0x02,0x02,0xbc,0x00,0x04,0x03,0x02,0xbc,0xb0,0x04,0x02,0x02,0xbc,0x00,0x04,0x03,0x02,0xbc,0x92,0x04,0x02,0x02,0xbc,0x82,0x03,0x02,0x02,0xbb,0x00, + 0x03,0x02,0x01,0xbb,0x8e,0x03,0x02,0x02,0xbb,0x00,0x03,0x02,0x01,0xbb,0x82,0x03,0x02,0x02,0xbb,0x00,0x03,0x02,0x01,0xbb,0xa2,0x03,0x02,0x02,0xbb,0x00,0x03,0x02, + 0x01,0xbb,0x83,0x03,0x02,0x02,0xbb,0x9b,0x03,0x02,0x01,0xba,0x00,0x03,0x02,0x01,0xb9,0x83,0x02,0x02,0x01,0xb9,0x8c,0x02,0x01,0x01,0xb8,0x8e,0x02,0x01,0x01,0xb7, + 0x87,0x01,0x01,0x01,0xb6,0x8c,0x01,0x01,0x00,0xb5,0x00,0x01,0x00,0x00,0xb5,0x81,0x01,0x00,0x00,0xb4,0x81,0x00,0x00,0x00,0xb4,0x83,0x01,0x00,0x00,0xb4,0x95,0x00, + 0x00,0x00,0xb4,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0x96,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xb1,0x00,0x00,0x00, + 0xb3,0x99,0x00,0x00,0x00,0xb4,0x87,0x01,0x00,0x00,0xb4,0x86,0x01,0x00,0x00,0xb5,0x81,0x01,0x01,0x00,0xb5,0x8e,0x01,0x01,0x01,0xb6,0x81,0x01,0x01,0x01,0xb7,0x01, + 0x02,0x01,0x01,0xb7,0x01,0x01,0x01,0xb7,0x8a,0x02,0x01,0x01,0xb7,0x92,0x02,0x01,0x01,0xb8,0x02,0x02,0x02,0x01,0xb8,0x02,0x01,0x01,0xb8,0x02,0x02,0x01,0xb8,0x89, + 0x02,0x01,0x01,0xb8,0x82,0x02,0x02,0x01,0xb9,0x00,0x03,0x02,0x01,0xb9,0x89,0x02,0x02,0x01,0xb9,0x81,0x03,0x02,0x01,0xb9,0xff,0x03,0x02,0x01,0xba,0xbb,0x03,0x02, + 0x01,0xba,0x81,0x03,0x02,0x01,0xb9,0x82,0x02,0x02,0x01,0xb9,0x81,0x03,0x02,0x01,0xb9,0x01,0x02,0x02,0x01,0xb9,0x03,0x02,0x01,0xb9,0x81,0x02,0x02,0x01,0xb9,0x82, + 0x03,0x02,0x01,0xb9,0x81,0x02,0x02,0x01,0xb9,0x9f,0x02,0x01,0x01,0xb8,0x8a,0x02,0x01,0x01,0xb7,0x03,0x01,0x01,0x01,0xb7,0x02,0x01,0x01,0xb7,0x01,0x01,0x01,0xb7, + 0x02,0x01,0x01,0xb7,0x8e,0x01,0x01,0x01,0xb6,0x81,0x01,0x01,0x00,0xb5,0x86,0x01,0x00,0x00,0xb5,0x87,0x01,0x00,0x00,0xb4,0x99,0x00,0x00,0x00,0xb4,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0x9f,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xb9,0x00,0x00,0x00,0xb3,0x99,0x00,0x00,0x00,0xb4, + 0x88,0x01,0x00,0x00,0xb4,0x87,0x01,0x00,0x00,0xb5,0x89,0x01,0x01,0x00,0xb5,0x96,0x01,0x01,0x01,0xb6,0x01,0x02,0x01,0x01,0xb7,0x01,0x01,0x01,0xb7,0x9f,0x02,0x01, + 0x01,0xb7,0xff,0x02,0x01,0x01,0xb8,0xc1,0x02,0x01,0x01,0xb8,0x9f,0x02,0x01,0x01,0xb7,0x01,0x01,0x01,0x01,0xb7,0x02,0x01,0x01,0xb7,0x96,0x01,0x01,0x01,0xb6,0x89, + 0x01,0x01,0x00,0xb5,0x87,0x01,0x00,0x00,0xb5,0x88,0x01,0x00,0x00,0xb4,0x99,0x00,0x00,0x00,0xb4,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xa7,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xbf,0x00,0x00,0x00,0xb3,0x9c,0x00,0x00,0x00,0xb4,0x8c,0x01,0x00,0x00,0xb4,0x8f,0x01,0x00,0x00,0xb5, + 0x89,0x01,0x01,0x00,0xb5,0xd1,0x01,0x01,0x01,0xb6,0x81,0x01,0x01,0x01,0xb7,0xe1,0x02,0x01,0x01,0xb7,0x81,0x01,0x01,0x01,0xb7,0xd1,0x01,0x01,0x01,0xb6,0x89,0x01, + 0x01,0x00,0xb5,0x88,0x01,0x00,0x00,0xb5,0x02,0x01,0x01,0x00,0xb5,0x01,0x00,0x00,0xb5,0x01,0x01,0x00,0xb5,0x83,0x01,0x00,0x00,0xb5,0x8c,0x01,0x00,0x00,0xb4,0x9c, + 0x00,0x00,0x00,0xb4,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xad,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xc7,0x00,0x00, + 0x00,0xb3,0xa1,0x00,0x00,0x00,0xb4,0x93,0x01,0x00,0x00,0xb4,0x86,0x01,0x00,0x00,0xb5,0x00,0x01,0x01,0x00,0xb5,0x9e,0x01,0x00,0x00,0xb5,0xff,0x01,0x01,0x00,0xb5, + 0xc7,0x01,0x01,0x00,0xb5,0x87,0x01,0x00,0x00,0xb5,0x00,0x01,0x01,0x00,0xb5,0x81,0x01,0x00,0x00,0xb5,0x00,0x01,0x01,0x00,0xb5,0x9a,0x01,0x00,0x00,0xb5,0x93,0x01, + 0x00,0x00,0xb4,0xa1,0x00,0x00,0x00,0xb4,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xb5,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xd2,0x00,0x00,0x00,0xb3,0x87,0x00,0x00,0x00,0xb4,0x83,0x00,0x00,0x00,0xb3,0x9e,0x00,0x00,0x00,0xb4,0x91,0x01,0x00,0x00,0xb4,0x94,0x00,0x00,0x00,0xb4,0x8e, + 0x01,0x00,0x00,0xb4,0x87,0x01,0x00,0x00,0xb5,0x00,0x01,0x01,0x00,0xb5,0x9a,0x01,0x00,0x00,0xb5,0xe1,0x01,0x00,0x00,0xb4,0x01,0x01,0x00,0x00,0xb5,0x01,0x01,0x00, + 0xb5,0x9b,0x01,0x00,0x00,0xb5,0x00,0x01,0x01,0x00,0xb5,0x84,0x01,0x00,0x00,0xb5,0x8e,0x01,0x00,0x00,0xb4,0x94,0x00,0x00,0x00,0xb4,0x91,0x01,0x00,0x00,0xb4,0x9e, + 0x00,0x00,0x00,0xb4,0x83,0x00,0x00,0x00,0xb3,0x87,0x00,0x00,0x00,0xb4,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xc0,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xeb,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb4,0xff,0x00,0x00,0x00,0xb4,0xb9,0x00,0x00,0x00,0xb4,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xd9,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xfe,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb4,0xff,0x00, + 0x00,0x00,0xb4,0x93,0x00,0x00,0x00,0xb4,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xec,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xfc,0x00,0x00,0x00,0xb3, + 0x00,0x52,0x52,0x52,0xbd,0x81,0x7e,0x7e,0x7e,0xc7,0x00,0x52,0x52,0x52,0xbd,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xfe,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xfa,0x00,0x00,0x00,0xb3,0x01,0xaf,0xaf,0xaf,0xd6,0xef,0xef,0xef,0xf5, + 0x83,0xff,0xff,0xff,0xff,0x01,0xef,0xef,0xef,0xf5,0x6a,0x6a,0x6a,0xc2,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xfc,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xf9,0x00,0x00,0x00,0xb3,0x01,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0x85, + 0xff,0xff,0xff,0xff,0x01,0xf7,0xf7,0xf7,0xfa,0x6a,0x6a,0x6a,0xc2,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xfb,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xfa,0x00,0x00,0x00,0xb3,0x02,0xa0,0xa0,0xa0,0xd1,0xff,0xff,0xff,0xff,0xbb,0xbb, + 0xbb,0xdc,0x81,0x7e,0x7e,0x7e,0xc7,0x00,0xd2,0xd2,0xd2,0xe6,0x81,0xff,0xff,0xff,0xff,0x00,0xc7,0xc7,0xc7,0xe1,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xfb,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0x86,0x00,0x00,0x00,0xb3,0x00,0x33,0x33,0x33,0xb8,0x81,0x7e, + 0x7e,0x7e,0xc7,0x00,0x33,0x33,0x33,0xb8,0x8d,0x00,0x00,0x00,0xb3,0x00,0x33,0x33,0x33,0xb8,0x81,0x7e,0x7e,0x7e,0xc7,0xc2,0x00,0x00,0x00,0xb3,0x00,0x52,0x52,0x52, + 0xbd,0x81,0x7e,0x7e,0x7e,0xc7,0x87,0x00,0x00,0x00,0xb3,0x00,0x33,0x33,0x33,0xb8,0x81,0x7e,0x7e,0x7e,0xc7,0x83,0x00,0x00,0x00,0xb3,0x02,0x33,0x33,0x33,0xb8,0x7e, + 0x7e,0x7e,0xc7,0x6a,0x6a,0x6a,0xc2,0x8b,0x00,0x00,0x00,0xb3,0x02,0x33,0x33,0x33,0xb8,0x7e,0x7e,0x7e,0xc7,0x6a,0x6a,0x6a,0xc2,0x86,0x00,0x00,0x00,0xb3,0x00,0x52, + 0x52,0x52,0xbd,0x81,0x7e,0x7e,0x7e,0xc7,0x00,0x33,0x33,0x33,0xb8,0x8b,0x00,0x00,0x00,0xb3,0x02,0x6a,0x6a,0x6a,0xc2,0x7e,0x7e,0x7e,0xc7,0x52,0x52,0x52,0xbd,0x84, + 0x00,0x00,0x00,0xb3,0x00,0x33,0x33,0x33,0xb8,0x81,0x7e,0x7e,0x7e,0xc7,0x00,0x33,0x33,0x33,0xb8,0x92,0x00,0x00,0x00,0xb3,0x02,0xaf,0xaf,0xaf,0xd6,0xdc,0xdc,0xdc, + 0xeb,0x52,0x52,0x52,0xbd,0x95,0x00,0x00,0x00,0xb3,0x81,0x7e,0x7e,0x7e,0xc7,0xa7,0x00,0x00,0x00,0xb3,0x00,0x6a,0x6a,0x6a,0xc2,0x83,0x00,0x00,0x00,0xb3,0x02,0xef, + 0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0x82,0x00,0x00,0x00,0xb3,0x00,0x52,0x52,0x52,0xbd,0x81,0x7e,0x7e,0x7e,0xc7,0x00,0x33,0x33,0x33,0xb8,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xf4,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xf2,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e, + 0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0x90,0x90,0x90,0xcc,0x81,0xff,0xff,0xff,0xff,0x00,0x6a,0x6a,0x6a,0xc2, + 0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x01,0x33,0x33,0x33,0xb8,0xc7,0xc7, + 0xc7,0xe1,0x83,0xff,0xff,0xff,0xff,0x01,0xc7,0xc7,0xc7,0xe1,0x33,0x33,0x33,0xb8,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x84, + 0x00,0x00,0x00,0xb3,0x01,0x52,0x52,0x52,0xbd,0xd2,0xd2,0xd2,0xe6,0x82,0xff,0xff,0xff,0xff,0x01,0xf7,0xf7,0xf7,0xfa,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3, + 0x02,0xdc,0xdc,0xdc,0xeb,0xff,0xff,0xff,0xff,0xaf,0xaf,0xaf,0xd6,0x88,0x00,0x00,0x00,0xb3,0x00,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x00,0x6a,0x6a,0x6a, + 0xc2,0x81,0x00,0x00,0x00,0xb3,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x00,0xa0,0xa0,0xa0,0xd1,0x84,0x00,0x00,0x00,0xb3,0x00,0xe6,0xe6,0xe6,0xf0,0x81, + 0xff,0xff,0xff,0xff,0x00,0x6a,0x6a,0x6a,0xc2,0x81,0x00,0x00,0x00,0xb3,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x00,0xa0,0xa0,0xa0,0xd1,0x84,0x00,0x00, + 0x00,0xb3,0x00,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x00,0x6a,0x6a,0x6a,0xc2,0x81,0x00,0x00,0x00,0xb3,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff, + 0x00,0xa0,0xa0,0xa0,0xd1,0x81,0x00,0x00,0x00,0xb3,0x02,0xaf,0xaf,0xaf,0xd6,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0x82,0x00,0x00,0x00,0xb3,0x01,0x6a,0x6a,0x6a, + 0xc2,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x01,0xf7,0xf7,0xf7,0xfa,0xaf,0xaf,0xaf,0xd6,0x83,0x00,0x00,0x00,0xb3,0x01,0x52,0x52,0x52,0xbd,0xd2,0xd2,0xd2, + 0xe6,0x82,0xff,0xff,0xff,0xff,0x04,0xf7,0xf7,0xf7,0xfa,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xa0,0xa0,0xa0,0xd1,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff, + 0x01,0xc7,0xc7,0xc7,0xe1,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00, + 0x00,0xb3,0x01,0xa0,0xa0,0xa0,0xd1,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x01,0xc7,0xc7,0xc7,0xe1,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x02,0x00, + 0x00,0x00,0xb3,0x6a,0x6a,0x6a,0xc2,0xdc,0xdc,0xdc,0xeb,0x83,0xff,0xff,0xff,0xff,0x06,0xdc,0xdc,0xdc,0xeb,0x33,0x33,0x33,0xb8,0x00,0x00,0x00,0xb3,0x52,0x52,0x52, + 0xbd,0xef,0xef,0xef,0xf5,0xf7,0xf7,0xf7,0xfa,0x90,0x90,0x90,0xcc,0x82,0x00,0x00,0x00,0xb3,0x01,0xaf,0xaf,0xaf,0xd6,0xef,0xef,0xef,0xf5,0x82,0xff,0xff,0xff,0xff, + 0x04,0xdc,0xdc,0xdc,0xeb,0x6a,0x6a,0x6a,0xc2,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0xc7,0xc7,0xc7,0xe1,0x83,0xff,0xff,0xff,0xff,0x01,0xc7,0xc7,0xc7,0xe1,0x33, + 0x33,0x33,0xb8,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff, + 0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x03,0x7e,0x7e,0x7e,0xc7,0xdc,0xdc,0xdc,0xeb,0xff,0xff, + 0xff,0xff,0xaf,0xaf,0xaf,0xd6,0x86,0x00,0x00,0x00,0xb3,0x00,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x00,0x6a,0x6a,0x6a,0xc2,0x81,0x00,0x00,0x00,0xb3,0x00, + 0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x00,0xa0,0xa0,0xa0,0xd1,0x82,0x00,0x00,0x00,0xb3,0x01,0xa0,0xa0,0xa0,0xd1,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff, + 0xff,0x01,0xf7,0xf7,0xf7,0xfa,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x01,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc, + 0xdc,0xeb,0x83,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb, + 0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff, + 0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x82,0x00,0x00,0x00,0xb3,0x05,0x90,0x90,0x90,0xcc,0xe6, + 0xe6,0xe6,0xf0,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0xaf,0xaf,0xaf,0xd6,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x02,0x00,0x00,0x00,0xb3,0x6a,0x6a,0x6a, + 0xc2,0xdc,0xdc,0xdc,0xeb,0x83,0xff,0xff,0xff,0xff,0x01,0xdc,0xdc,0xdc,0xeb,0x33,0x33,0x33,0xb8,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xf2,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xf2,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6, + 0x81,0x00,0x00,0x00,0xb3,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff, + 0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x00,0xe6,0xe6,0xe6,0xf0,0x85,0xff,0xff,0xff,0xff,0x00,0xe6,0xe6,0xe6,0xf0,0x81,0x00,0x00,0x00, + 0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x83,0x00,0x00,0x00,0xb3,0x01,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x01,0xdc, + 0xdc,0xdc,0xeb,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x87,0x00, + 0x00,0x00,0xb3,0x00,0x6a,0x6a,0x6a,0xc2,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff, + 0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x83,0x00,0x00,0x00,0xb3,0x00,0x6a,0x6a,0x6a,0xc2,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00, + 0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x83,0x00,0x00,0x00,0xb3,0x00,0x6a,0x6a,0x6a,0xc2,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf, + 0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x82,0xff,0xff,0xff,0xff, + 0x03,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0x52,0x52,0x52,0xbd,0xf7,0xf7,0xf7,0xfa,0x85,0xff,0xff,0xff,0xff,0x00,0xbb,0xbb,0xbb,0xdc,0x81,0x00,0x00,0x00,0xb3, + 0x01,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0x84,0xff,0xff,0xff,0xff,0x02,0xc7,0xc7,0xc7,0xe1,0x00,0x00,0x00,0xb3,0xf7,0xf7,0xf7,0xfa,0x86,0xff,0xff,0xff,0xff, + 0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0xf7,0xf7,0xf7,0xfa,0x86,0xff,0xff,0xff,0xff,0x03,0x00, + 0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0x81,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00, + 0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x84,0xff,0xff,0xff,0xff,0x03, + 0xf7,0xf7,0xf7,0xfa,0x6a,0x6a,0x6a,0xc2,0x00,0x00,0x00,0xb3,0xe6,0xe6,0xe6,0xf0,0x85,0xff,0xff,0xff,0xff,0x00,0xe6,0xe6,0xe6,0xf0,0x81,0x00,0x00,0x00,0xb3,0x00, + 0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00, + 0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x03,0x7e,0x7e,0x7e,0xc7,0xa0,0xa0,0xa0,0xd1,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0x85,0x00,0x00, + 0x00,0xb3,0x00,0x6a,0x6a,0x6a,0xc2,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff, + 0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x00,0x52,0x52,0x52,0xbd,0x81,0xff,0xff,0xff,0xff,0x02,0xef,0xef,0xef,0xf5,0xaf,0xaf,0xaf,0xd6,0xc7,0xc7,0xc7, + 0xe1,0x82,0xff,0xff,0xff,0xff,0x01,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x83,0x00,0x00,0x00,0xb3,0x00,0x7e, + 0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00, + 0xb3,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00, + 0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0x90,0x90,0x90,0xcc,0x87,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0xb3, + 0x33,0x33,0x33,0xb8,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0x81,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xf2,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xf2,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff, + 0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x00,0xf7,0xf7,0xf7,0xfa,0x81,0x00,0x00,0x00, + 0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x00,0xe6,0xe6, + 0xe6,0xf0,0x81,0x90,0x90,0x90,0xcc,0x00,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x02,0xa0,0xa0,0xa0,0xd1,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff, + 0xff,0xff,0xff,0x83,0x00,0x00,0x00,0xb3,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x00,0x6a,0x6a,0x6a,0xc2,0x81,0x00,0x00,0x00,0xb3,0x01,0xbb,0xbb,0xbb, + 0xdc,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x03,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0x87,0x00,0x00,0x00,0xb3, + 0x00,0xbb,0xbb,0xbb,0xdc,0x82,0xff,0xff,0xff,0xff,0x02,0xe6,0xe6,0xe6,0xf0,0x00,0x00,0x00,0xb3,0x6a,0x6a,0x6a,0xc2,0x83,0xff,0xff,0xff,0xff,0x00,0x52,0x52,0x52, + 0xbd,0x82,0x00,0x00,0x00,0xb3,0x00,0xbb,0xbb,0xbb,0xdc,0x82,0xff,0xff,0xff,0xff,0x02,0xe6,0xe6,0xe6,0xf0,0x00,0x00,0x00,0xb3,0x6a,0x6a,0x6a,0xc2,0x83,0xff,0xff, + 0xff,0xff,0x00,0x52,0x52,0x52,0xbd,0x82,0x00,0x00,0x00,0xb3,0x00,0xbb,0xbb,0xbb,0xdc,0x82,0xff,0xff,0xff,0xff,0x02,0xe6,0xe6,0xe6,0xf0,0x00,0x00,0x00,0xb3,0x6a, + 0x6a,0x6a,0xc2,0x83,0xff,0xff,0xff,0xff,0x07,0x52,0x52,0x52,0xbd,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0x33,0x33,0x33, + 0xb8,0x00,0x00,0x00,0xb3,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x03,0xd2,0xd2,0xd2,0xe6,0x7e,0x7e,0x7e,0xc7,0xa0,0xa0,0xa0,0xd1,0xf7,0xf7,0xf7,0xfa,0x81, + 0xff,0xff,0xff,0xff,0x02,0x52,0x52,0x52,0xbd,0x00,0x00,0x00,0xb3,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x05,0xd2,0xd2,0xd2,0xe6,0x7e,0x7e,0x7e,0xc7,0xa0, + 0xa0,0xa0,0xd1,0xc7,0xc7,0xc7,0xe1,0x00,0x00,0x00,0xb3,0x6a,0x6a,0x6a,0xc2,0x81,0xff,0xff,0xff,0xff,0x02,0xf7,0xf7,0xf7,0xfa,0x90,0x90,0x90,0xcc,0xaf,0xaf,0xaf, + 0xd6,0x82,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0xb3,0x6a,0x6a,0x6a,0xc2,0x81,0xff, + 0xff,0xff,0xff,0x02,0xf7,0xf7,0xf7,0xfa,0x90,0x90,0x90,0xcc,0xaf,0xaf,0xaf,0xd6,0x82,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x01,0x6a,0x6a,0x6a,0xc2,0xa0, + 0xa0,0xa0,0xd1,0x81,0x00,0x00,0x00,0xb3,0x00,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff, + 0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0x52,0x52,0x52,0xbd,0x81,0xff,0xff,0xff,0xff,0x06,0xf7,0xf7,0xf7,0xfa,0xa0,0xa0,0xa0,0xd1,0x7e,0x7e,0x7e,0xc7,0xd2, + 0xd2,0xd2,0xe6,0x6a,0x6a,0x6a,0xc2,0x00,0x00,0x00,0xb3,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x00,0xe6,0xe6,0xe6,0xf0,0x81,0x90,0x90,0x90,0xcc,0x00,0xe6, + 0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x02,0xa0,0xa0,0xa0,0xd1,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81, + 0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x04,0x7e,0x7e, + 0x7e,0xc7,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0x90,0x90,0x90,0xcc,0x84,0x00,0x00,0x00,0xb3,0x00,0xbb,0xbb,0xbb,0xdc,0x82,0xff,0xff,0xff, + 0xff,0x02,0xe6,0xe6,0xe6,0xf0,0x00,0x00,0x00,0xb3,0x6a,0x6a,0x6a,0xc2,0x83,0xff,0xff,0xff,0xff,0x02,0x52,0x52,0x52,0xbd,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7, + 0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x01,0x7e,0x7e,0x7e,0xc7,0x00,0x00, + 0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x83,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6, + 0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00, + 0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81, + 0x00,0x00,0x00,0xb3,0x00,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x02,0xef,0xef,0xef,0xf5,0xaf,0xaf,0xaf,0xd6,0xc7,0xc7,0xc7,0xe1,0x82,0xff,0xff,0xff,0xff, + 0x81,0x00,0x00,0x00,0xb3,0x01,0x6a,0x6a,0x6a,0xc2,0xa0,0xa0,0xa0,0xd1,0x81,0x00,0x00,0x00,0xb3,0x00,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xf2,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xf2,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7, + 0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xa0,0xa0,0xa0,0xd1,0x83,0xff,0xff,0xff,0xff,0x02,0x90,0x90,0x90,0xcc,0x00,0x00,0x00,0xb3, + 0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0xd2,0xd2,0xd2,0xe6,0x81,0xff,0xff,0xff,0xff,0x00,0x52,0x52,0x52,0xbd, + 0x81,0x00,0x00,0x00,0xb3,0x00,0x52,0x52,0x52,0xbd,0x81,0xff,0xff,0xff,0xff,0x02,0xd2,0xd2,0xd2,0xe6,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff, + 0xff,0x83,0x00,0x00,0x00,0xb3,0x02,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0x84,0xaf,0xaf,0xaf,0xd6,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0x00,0x00, + 0x00,0xb3,0x01,0x33,0x33,0x33,0xb8,0x7e,0x7e,0x7e,0xc7,0x88,0x00,0x00,0x00,0xb3,0x02,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff, + 0xff,0xff,0x06,0x33,0x33,0x33,0xb8,0xbb,0xbb,0xbb,0xdc,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xaf,0xaf,0xaf,0xd6,0x82, + 0x00,0x00,0x00,0xb3,0x02,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x06,0x33,0x33,0x33,0xb8,0xbb,0xbb,0xbb,0xdc,0xff, + 0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x02,0xef,0xef,0xef,0xf5,0xff,0xff,0xff, + 0xff,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x06,0x33,0x33,0x33,0xb8,0xbb,0xbb,0xbb,0xdc,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0xf7,0xf7,0xf7,0xfa,0xff, + 0xff,0xff,0xff,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x01,0x7e,0x7e,0x7e,0xc7,0x33,0x33,0x33,0xb8,0x81,0x00,0x00,0x00,0xb3,0x02,0xf7,0xf7,0xf7,0xfa,0xff, + 0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0x82,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x04,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xf7, + 0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0x84,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xbb,0xbb,0xbb,0xdc,0x81, + 0x00,0x00,0x00,0xb3,0x00,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x01,0x00,0x00, + 0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xbb,0xbb,0xbb,0xdc,0x81,0x00,0x00,0x00,0xb3,0x00,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x82, + 0x00,0x00,0x00,0xb3,0x02,0xa0,0xa0,0xa0,0xd1,0xc7,0xc7,0xc7,0xe1,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x00,0xef,0xef,0xef,0xf5,0x81,0x00,0x00,0x00,0xb3, + 0x01,0x52,0x52,0x52,0xbd,0x6a,0x6a,0x6a,0xc2,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0xa0,0xa0,0xa0,0xd1,0x84,0x00,0x00, + 0x00,0xb3,0x00,0xd2,0xd2,0xd2,0xe6,0x81,0xff,0xff,0xff,0xff,0x00,0x52,0x52,0x52,0xbd,0x81,0x00,0x00,0x00,0xb3,0x00,0x52,0x52,0x52,0xbd,0x81,0xff,0xff,0xff,0xff, + 0x02,0xd2,0xd2,0xd2,0xe6,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff, + 0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x04,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0xc7,0xc7, + 0xc7,0xe1,0xff,0xff,0xff,0xff,0xd2,0xd2,0xd2,0xe6,0x84,0x00,0x00,0x00,0xb3,0x02,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff, + 0xff,0x0e,0x33,0x33,0x33,0xb8,0xbb,0xbb,0xbb,0xdc,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xaf,0xaf,0xaf,0xd6,0x00,0x00, + 0x00,0xb3,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xe6,0xe6,0xe6,0xf0,0xa0,0xa0,0xa0,0xd1,0x7e,0x7e,0x7e,0xc7,0xaf,0xaf,0xaf,0xd6,0x81,0xff, + 0xff,0xff,0xff,0x01,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x83,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7, + 0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x81,0xff, + 0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00, + 0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0xb3,0x6a,0x6a,0x6a,0xc2,0x81,0xff,0xff,0xff,0xff,0x00,0xe6,0xe6,0xe6,0xf0,0x82,0x00,0x00,0x00, + 0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x82,0x00,0x00,0x00,0xb3,0x02,0xa0,0xa0,0xa0,0xd1,0xc7,0xc7,0xc7,0xe1,0xef,0xef,0xef,0xf5,0x81,0xff,0xff, + 0xff,0xff,0x00,0xef,0xef,0xef,0xf5,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xf2,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xf2,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x03,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xd2,0xd2,0xd2,0xe6,0xff,0xff,0xff,0xff, + 0x81,0xf7,0xf7,0xf7,0xfa,0x03,0xff,0xff,0xff,0xff,0xc7,0xc7,0xc7,0xe1,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7, + 0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x83,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3, + 0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x83,0x00,0x00,0x00,0xb3,0x87,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x8b,0x00,0x00,0x00,0xb3,0x00,0x90,0x90, + 0x90,0xcc,0x81,0xff,0xff,0xff,0xff,0x09,0xaf,0xaf,0xaf,0xd6,0xe6,0xe6,0xe6,0xf0,0xff,0xff,0xff,0xff,0x90,0x90,0x90,0xcc,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff, + 0xbb,0xbb,0xbb,0xdc,0xd2,0xd2,0xd2,0xe6,0xff,0xff,0xff,0xff,0xe6,0xe6,0xe6,0xf0,0x81,0x00,0x00,0x00,0xb3,0x00,0x90,0x90,0x90,0xcc,0x81,0xff,0xff,0xff,0xff,0x09, + 0xaf,0xaf,0xaf,0xd6,0xe6,0xe6,0xe6,0xf0,0xff,0xff,0xff,0xff,0x90,0x90,0x90,0xcc,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xbb,0xbb,0xbb,0xdc,0xd2,0xd2,0xd2,0xe6, + 0xff,0xff,0xff,0xff,0xe6,0xe6,0xe6,0xf0,0x81,0x00,0x00,0x00,0xb3,0x00,0x90,0x90,0x90,0xcc,0x81,0xff,0xff,0xff,0xff,0x09,0xaf,0xaf,0xaf,0xd6,0xe6,0xe6,0xe6,0xf0, + 0xff,0xff,0xff,0xff,0x90,0x90,0x90,0xcc,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xbb,0xbb,0xbb,0xdc,0xd2,0xd2,0xd2,0xe6,0xff,0xff,0xff,0xff,0xe6,0xe6,0xe6,0xf0, + 0x85,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x01,0xaf, + 0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x84,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff, + 0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff, + 0xff,0xff,0xff,0x01,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb, + 0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0xbb,0xbb,0xbb,0xdc,0x83,0xff,0xff,0xff,0xff,0x01,0xf7,0xf7,0xf7,0xfa,0xa0,0xa0,0xa0,0xd1,0x85,0x00,0x00, + 0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x84,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff, + 0x83,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e, + 0xc7,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02, + 0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0x6a,0x6a,0x6a,0xc2,0x81,0xff,0xff,0xff,0xff,0x00,0x33,0x33,0x33,0xb8,0x82,0x00,0x00,0x00,0xb3,0x00,0x90,0x90,0x90,0xcc, + 0x81,0xff,0xff,0xff,0xff,0x09,0xaf,0xaf,0xaf,0xd6,0xe6,0xe6,0xe6,0xf0,0xff,0xff,0xff,0xff,0x90,0x90,0x90,0xcc,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xbb,0xbb, + 0xbb,0xdc,0xd2,0xd2,0xd2,0xe6,0xff,0xff,0xff,0xff,0xe6,0xe6,0xe6,0xf0,0x81,0x00,0x00,0x00,0xb3,0x01,0x90,0x90,0x90,0xcc,0xf7,0xf7,0xf7,0xfa,0x85,0xff,0xff,0xff, + 0xff,0x01,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x83,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff, + 0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff, + 0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc, + 0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x00, + 0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0xbb,0xbb,0xbb,0xdc,0x83,0xff,0xff,0xff,0xff,0x01,0xf7,0xf7,0xf7,0xfa,0xa0,0xa0,0xa0, + 0xd1,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xf2,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xf2,0x00,0x00,0x00,0xb3,0x00, + 0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x01,0xaf,0xaf,0xaf,0xd6,0x33,0x33,0x33,0xb8,0x81,0xff,0xff,0xff,0xff,0x81,0xc7,0xc7,0xc7,0xe1,0x03,0xff,0xff,0xff, + 0xff,0xf7,0xf7,0xf7,0xfa,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0xc7,0xc7,0xc7,0xe1,0x81, + 0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xc7,0xc7,0xc7,0xe1,0x00,0x00,0x00, + 0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x00,0x90,0x90,0x90,0xcc,0x82,0x00,0x00,0x00,0xb3,0x02,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xef,0xef,0xef, + 0xf5,0x82,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xd2,0xd2,0xd2,0xe6,0x81,0x00,0x00,0x00,0xb3,0x01,0x33,0x33,0x33,0xb8,0x7e,0x7e,0x7e,0xc7,0x87,0x00, + 0x00,0x00,0xb3,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x03,0x52,0x52,0x52,0xbd,0xbb,0xbb,0xbb,0xdc,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0x81,0xff, + 0xff,0xff,0xff,0x01,0x7e,0x7e,0x7e,0xc7,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x02,0x6a,0x6a,0x6a,0xc2,0x00,0x00,0x00,0xb3,0xc7,0xc7,0xc7,0xe1,0x81,0xff, + 0xff,0xff,0xff,0x03,0x52,0x52,0x52,0xbd,0xbb,0xbb,0xbb,0xdc,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x01,0x7e,0x7e,0x7e,0xc7,0xa0,0xa0, + 0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x02,0x6a,0x6a,0x6a,0xc2,0x00,0x00,0x00,0xb3,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x03,0x52,0x52,0x52,0xbd,0xbb,0xbb, + 0xbb,0xdc,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x01,0x7e,0x7e,0x7e,0xc7,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x00,0x6a,0x6a, + 0x6a,0xc2,0x84,0x00,0x00,0x00,0xb3,0x03,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0x33,0x33,0x33,0xb8,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf, + 0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x05,0xa0,0xa0,0xa0,0xd1,0x00,0x00,0x00,0xb3,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0x33,0x33,0x33,0xb8, + 0x81,0x00,0x00,0x00,0xb3,0x02,0x33,0x33,0x33,0xb8,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00, + 0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0xb3,0x7e, + 0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00, + 0xb3,0x82,0xff,0xff,0xff,0xff,0x02,0xc7,0xc7,0xc7,0xe1,0xa0,0xa0,0xa0,0xd1,0x33,0x33,0x33,0xb8,0x86,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff, + 0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0x33,0x33,0x33,0xb8,0x81,0x00,0x00,0x00,0xb3,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff, + 0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xc7,0xc7,0xc7,0xe1,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf, + 0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0xa0,0xa0,0xa0,0xd1,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0x81,0xff,0xff,0xff,0xff,0x00,0xef,0xef,0xef,0xf5,0x81,0x00,0x00, + 0x00,0xb3,0x00,0xbb,0xbb,0xbb,0xdc,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x02,0xe6,0xe6,0xe6,0xf0,0xff,0xff,0xff,0xff,0xaf, + 0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x03,0x52,0x52,0x52,0xbd,0xbb,0xbb,0xbb,0xdc,0xff,0xff,0xff,0xff,0xdc, + 0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x01,0x7e,0x7e,0x7e,0xc7,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x00,0x6a,0x6a,0x6a,0xc2,0x82,0x00,0x00,0x00,0xb3, + 0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xaf,0xaf,0xaf,0xd6,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x01,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0x82,0xff,0xff, + 0xff,0xff,0x00,0x33,0x33,0x33,0xb8,0x82,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0x00,0x00,0x00,0xb3, + 0x00,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e, + 0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0x00,0x00,0x00,0xb3,0x00,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0xb3,0x6a, + 0x6a,0x6a,0xc2,0x81,0xff,0xff,0xff,0xff,0x00,0xe6,0xe6,0xe6,0xf0,0x82,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00, + 0xb3,0x82,0xff,0xff,0xff,0xff,0x02,0xc7,0xc7,0xc7,0xe1,0xa0,0xa0,0xa0,0xd1,0x33,0x33,0x33,0xb8,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xf3,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xf2,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x01,0xaf,0xaf,0xaf,0xd6, + 0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x01,0x7e,0x7e,0x7e,0xc7,0x6a,0x6a,0x6a,0xc2,0x81,0xff,0xff,0xff,0xff,0x01,0xa0,0xa0,0xa0,0xd1,0xaf,0xaf,0xaf,0xd6, + 0x81,0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xf7,0xf7,0xf7,0xfa,0x81,0xbb,0xbb,0xbb, + 0xdc,0x00,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x04,0xf7,0xf7, + 0xf7,0xfa,0xbb,0xbb,0xbb,0xdc,0xaf,0xaf,0xaf,0xd6,0x7e,0x7e,0x7e,0xc7,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0xa0,0xa0,0xa0,0xd1,0x00,0x00,0x00,0xb3, + 0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x05,0xa0,0xa0,0xa0,0xd1,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xdc,0xdc, + 0xdc,0xeb,0x85,0x00,0x00,0x00,0xb3,0x00,0x33,0x33,0x33,0xb8,0x81,0xff,0xff,0xff,0xff,0x02,0xe6,0xe6,0xe6,0xf0,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x82,0xff, + 0xff,0xff,0xff,0x02,0xf7,0xf7,0xf7,0xfa,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0x81,0xff,0xff,0xff,0xff,0x01,0xbb,0xbb,0xbb,0xdc,0x33,0x33,0x33,0xb8,0x81,0xff, + 0xff,0xff,0xff,0x02,0xe6,0xe6,0xe6,0xf0,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x02,0xf7,0xf7,0xf7,0xfa,0x00,0x00,0x00,0xb3,0x33,0x33, + 0x33,0xb8,0x81,0xff,0xff,0xff,0xff,0x01,0xbb,0xbb,0xbb,0xdc,0x33,0x33,0x33,0xb8,0x81,0xff,0xff,0xff,0xff,0x02,0xe6,0xe6,0xe6,0xf0,0x00,0x00,0x00,0xb3,0x7e,0x7e, + 0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x02,0xf7,0xf7,0xf7,0xfa,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0x81,0xff,0xff,0xff,0xff,0x00,0xbb,0xbb,0xbb,0xdc,0x84,0x00, + 0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0xef,0xef,0xef,0xf5,0xaf,0xaf,0xaf,0xd6,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x03, + 0xf7,0xf7,0xf7,0xfa,0x33,0x33,0x33,0xb8,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x05,0xef,0xef,0xef,0xf5,0xaf,0xaf,0xaf,0xd6,0xc7,0xc7, + 0xc7,0xe1,0xe6,0xe6,0xe6,0xf0,0x33,0x33,0x33,0xb8,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc, + 0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81, + 0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff, + 0xff,0xff,0x03,0xe6,0xe6,0xe6,0xf0,0x33,0x33,0x33,0xb8,0x52,0x52,0x52,0xbd,0xaf,0xaf,0xaf,0xd6,0x86,0x00,0x00,0x00,0xb3,0x01,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7, + 0xfa,0x81,0xff,0xff,0xff,0xff,0x05,0xc7,0xc7,0xc7,0xe1,0xaf,0xaf,0xaf,0xd6,0xef,0xef,0xef,0xf5,0xa0,0xa0,0xa0,0xd1,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81, + 0xff,0xff,0xff,0xff,0x00,0xf7,0xf7,0xf7,0xfa,0x81,0xbb,0xbb,0xbb,0xdc,0x00,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00, + 0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0xf7,0xf7,0xf7,0xfa,0xaf,0xaf,0xaf,0xd6,0xd2,0xd2,0xd2,0xe6,0x82,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc, + 0xeb,0xaf,0xaf,0xaf,0xd6,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x00,0x52,0x52,0x52,0xbd,0x81,0x00,0x00,0x00,0xb3,0x02,0xaf,0xaf,0xaf,0xd6,0xff,0xff,0xff, + 0xff,0xef,0xef,0xef,0xf5,0x81,0x00,0x00,0x00,0xb3,0x00,0x33,0x33,0x33,0xb8,0x81,0xff,0xff,0xff,0xff,0x02,0xe6,0xe6,0xe6,0xf0,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e, + 0xc7,0x82,0xff,0xff,0xff,0xff,0x02,0xf7,0xf7,0xf7,0xfa,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0x81,0xff,0xff,0xff,0xff,0x00,0xbb,0xbb,0xbb,0xdc,0x81,0x00,0x00, + 0x00,0xb3,0x01,0xa0,0xa0,0xa0,0xd1,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x00,0xbb,0xbb,0xbb,0xdc,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x82, + 0xff,0xff,0xff,0xff,0x00,0xef,0xef,0xef,0xf5,0x81,0xaf,0xaf,0xaf,0xd6,0x01,0x52,0x52,0x52,0xbd,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x01,0xbb,0xbb,0xbb, + 0xdc,0xd2,0xd2,0xd2,0xe6,0x81,0xff,0xff,0xff,0xff,0x00,0xef,0xef,0xef,0xf5,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00, + 0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x01,0xbb,0xbb,0xbb,0xdc,0xd2,0xd2,0xd2,0xe6,0x81,0xff,0xff,0xff,0xff,0x00,0xef,0xef,0xef,0xf5,0x81,0x00, + 0x00,0x00,0xb3,0x00,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x02,0xef,0xef,0xef,0xf5,0xaf,0xaf,0xaf,0xd6,0xc7,0xc7,0xc7,0xe1,0x82,0xff,0xff,0xff,0xff,0x81, + 0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x03,0xe6,0xe6,0xe6,0xf0,0x33,0x33,0x33,0xb8,0x52,0x52,0x52,0xbd,0xaf,0xaf,0xaf,0xd6,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xf3,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xf2,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff, + 0xff,0xff,0x03,0xaf,0xaf,0xaf,0xd6,0xd2,0xd2,0xd2,0xe6,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0x81,0x00,0x00,0x00,0xb3,0x03,0xef,0xef,0xef,0xf5,0xff,0xff,0xff, + 0xff,0xd2,0xd2,0xd2,0xe6,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x00,0xc7,0xc7,0xc7,0xe1,0x85,0xff,0xff, + 0xff,0xff,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x00,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff, + 0x02,0xaf,0xaf,0xaf,0xd6,0x33,0x33,0x33,0xb8,0xe6,0xe6,0xe6,0xf0,0x84,0xff,0xff,0xff,0xff,0x00,0xe6,0xe6,0xe6,0xf0,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e, + 0xc7,0x82,0xff,0xff,0xff,0xff,0x85,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x82, + 0xff,0xff,0xff,0xff,0x00,0xd2,0xd2,0xd2,0xe6,0x81,0x00,0x00,0x00,0xb3,0x03,0xe6,0xe6,0xe6,0xf0,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0xa0,0xa0,0xa0,0xd1,0x81, + 0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x82,0xff,0xff,0xff,0xff,0x00,0xd2,0xd2,0xd2,0xe6,0x81,0x00,0x00,0x00,0xb3,0x03,0xe6,0xe6, + 0xe6,0xf0,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x82,0xff,0xff, + 0xff,0xff,0x00,0xd2,0xd2,0xd2,0xe6,0x81,0x00,0x00,0x00,0xb3,0x02,0xe6,0xe6,0xe6,0xf0,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0x84,0x00,0x00,0x00,0xb3,0x01,0x33, + 0x33,0x33,0xb8,0xe6,0xe6,0xe6,0xf0,0x85,0xff,0xff,0xff,0xff,0x00,0xa0,0xa0,0xa0,0xd1,0x82,0x00,0x00,0x00,0xb3,0x00,0xe6,0xe6,0xe6,0xf0,0x84,0xff,0xff,0xff,0xff, + 0x01,0xe6,0xe6,0xe6,0xf0,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff, + 0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00, + 0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0xbb,0xbb,0xbb,0xdc,0x84,0xff,0xff, + 0xff,0xff,0x00,0xc7,0xc7,0xc7,0xe1,0x86,0x00,0x00,0x00,0xb3,0x00,0x90,0x90,0x90,0xcc,0x85,0xff,0xff,0xff,0xff,0x02,0x90,0x90,0x90,0xcc,0x00,0x00,0x00,0xb3,0xc7, + 0xc7,0xc7,0xe1,0x85,0xff,0xff,0xff,0xff,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0xf7,0xf7,0xf7, + 0xfa,0x83,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x83,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0x00,0x00,0x00,0xb3,0x00,0x33,0x33,0x33,0xb8,0x81, + 0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3, + 0x82,0xff,0xff,0xff,0xff,0x00,0xd2,0xd2,0xd2,0xe6,0x81,0x00,0x00,0x00,0xb3,0x04,0xe6,0xe6,0xe6,0xf0,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0x00,0x00,0x00,0xb3, + 0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x81,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff, + 0xff,0xff,0x01,0xef,0xef,0xef,0xf5,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x81,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xf7,0xf7,0xf7,0xfa,0x83, + 0xff,0xff,0xff,0xff,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7, + 0x81,0xff,0xff,0xff,0xff,0x00,0xf7,0xf7,0xf7,0xfa,0x83,0xff,0xff,0xff,0xff,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0x00,0x00,0x00,0xb3,0x00,0x90,0x90,0x90,0xcc,0x84,0xff, + 0xff,0xff,0xff,0x00,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0xbb,0xbb,0xbb,0xdc,0x84,0xff,0xff,0xff,0xff,0x00,0xc7,0xc7,0xc7, + 0xe1,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xf2,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xf2,0x00,0x00,0x00,0xb3,0x00, + 0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xbb,0xbb,0xbb,0xdc,0x81,0xff,0xff,0xff,0xff,0x00,0xbb,0xbb,0xbb,0xdc,0x81,0x00,0x00,0x00,0xb3,0x00,0xbb,0xbb, + 0xbb,0xdc,0x81,0xff,0xff,0xff,0xff,0x00,0xbb,0xbb,0xbb,0xdc,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0x00,0x00,0x00,0xb3,0x01,0xa0,0xa0,0xa0,0xd1, + 0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x01,0xe6,0xe6,0xe6,0xf0,0xa0,0xa0,0xa0,0xd1,0x82,0x00,0x00,0x00,0xb3,0x00,0xbb,0xbb,0xbb,0xdc,0x81,0xdc,0xdc,0xdc, + 0xeb,0x0b,0x6a,0x6a,0x6a,0xc2,0xdc,0xdc,0xdc,0xeb,0xff,0xff,0xff,0xff,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0xaf,0xaf,0xaf,0xd6,0xef,0xef, + 0xef,0xf5,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0xc7,0xc7,0xc7,0xe1,0x33,0x33,0x33,0xb8,0x82,0x00,0x00,0x00,0xb3,0x02,0xdc,0xdc,0xdc,0xeb,0xff,0xff,0xff,0xff, + 0xaf,0xaf,0xaf,0xd6,0x85,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xdc,0xdc,0xdc,0xeb,0x00,0x52,0x52,0x52,0xbd,0x81,0x00,0x00,0x00,0xb3,0x00,0xbb,0xbb, + 0xbb,0xdc,0x81,0xdc,0xdc,0xdc,0xeb,0x00,0x90,0x90,0x90,0xcc,0x81,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0xdc,0xdc,0xdc,0xeb,0x00,0xaf,0xaf,0xaf,0xd6, + 0x81,0xdc,0xdc,0xdc,0xeb,0x00,0x52,0x52,0x52,0xbd,0x81,0x00,0x00,0x00,0xb3,0x00,0xbb,0xbb,0xbb,0xdc,0x81,0xdc,0xdc,0xdc,0xeb,0x00,0x90,0x90,0x90,0xcc,0x81,0x00, + 0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0xdc,0xdc,0xdc,0xeb,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xdc,0xdc,0xdc,0xeb,0x00,0x52,0x52,0x52,0xbd,0x81,0x00,0x00,0x00, + 0xb3,0x00,0xbb,0xbb,0xbb,0xdc,0x81,0xdc,0xdc,0xdc,0xeb,0x00,0x90,0x90,0x90,0xcc,0x81,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0xdc,0xdc,0xdc,0xeb,0x00, + 0x52,0x52,0x52,0xbd,0x84,0x00,0x00,0x00,0xb3,0x02,0x33,0x33,0x33,0xb8,0xaf,0xaf,0xaf,0xd6,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x01,0xd2,0xd2,0xd2,0xe6, + 0x7e,0x7e,0x7e,0xc7,0x84,0x00,0x00,0x00,0xb3,0x01,0xaf,0xaf,0xaf,0xd6,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x02,0xd2,0xd2,0xd2,0xe6,0x7e,0x7e,0x7e,0xc7, + 0x6a,0x6a,0x6a,0xc2,0x81,0xdc,0xdc,0xdc,0xeb,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0x00,0x00,0x00,0xb3,0x00,0xbb,0xbb,0xbb,0xdc,0x81,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00, + 0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0xb3,0x6a,0x6a,0x6a,0xc2,0x81,0xdc,0xdc,0xdc,0xeb,0x00,0xa0,0xa0,0xa0,0xd1,0x81, + 0x00,0x00,0x00,0xb3,0x00,0xbb,0xbb,0xbb,0xdc,0x81,0xdc,0xdc,0xdc,0xeb,0x82,0x00,0x00,0x00,0xb3,0x01,0xaf,0xaf,0xaf,0xd6,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff, + 0xff,0x01,0xd2,0xd2,0xd2,0xe6,0x7e,0x7e,0x7e,0xc7,0x87,0x00,0x00,0x00,0xb3,0x06,0x6a,0x6a,0x6a,0xc2,0xd2,0xd2,0xd2,0xe6,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff, + 0xef,0xef,0xef,0xf5,0xaf,0xaf,0xaf,0xd6,0x33,0x33,0x33,0xb8,0x81,0x00,0x00,0x00,0xb3,0x01,0xa0,0xa0,0xa0,0xd1,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x01, + 0xe6,0xe6,0xe6,0xf0,0xa0,0xa0,0xa0,0xd1,0x82,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0xdc,0xdc,0xdc,0xeb,0x06,0x7e,0x7e,0x7e,0xc7,0xd2,0xd2,0xd2,0xe6, + 0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xbb,0xbb,0xbb,0xdc,0x81,0xff,0xff,0xff,0xff,0x01,0xdc,0xdc,0xdc,0xeb,0x6a,0x6a, + 0x6a,0xc2,0x83,0x00,0x00,0x00,0xb3,0x04,0xc7,0xc7,0xc7,0xe1,0xff,0xff,0xff,0xff,0xc7,0xc7,0xc7,0xe1,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xdc,0xdc,0xdc, + 0xeb,0x00,0x52,0x52,0x52,0xbd,0x81,0x00,0x00,0x00,0xb3,0x00,0xbb,0xbb,0xbb,0xdc,0x81,0xdc,0xdc,0xdc,0xeb,0x00,0x90,0x90,0x90,0xcc,0x81,0x00,0x00,0x00,0xb3,0x00, + 0xa0,0xa0,0xa0,0xd1,0x81,0xdc,0xdc,0xdc,0xeb,0x03,0x52,0x52,0x52,0xbd,0x00,0x00,0x00,0xb3,0xa0,0xa0,0xa0,0xd1,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x02, + 0xef,0xef,0xef,0xf5,0xbb,0xbb,0xbb,0xdc,0x33,0x33,0x33,0xb8,0x81,0x00,0x00,0x00,0xb3,0x81,0xdc,0xdc,0xdc,0xeb,0x05,0xbb,0xbb,0xbb,0xdc,0x90,0x90,0x90,0xcc,0xef, + 0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0x7e,0x7e,0x7e,0xc7,0x6a,0x6a,0x6a,0xc2,0x81,0xdc,0xdc,0xdc,0xeb,0x01,0xa0,0xa0,0xa0,0xd1,0xbb,0xbb,0xbb,0xdc,0x81,0xff,0xff, + 0xff,0xff,0x01,0xc7,0xc7,0xc7,0xe1,0x33,0x33,0x33,0xb8,0x81,0x00,0x00,0x00,0xb3,0x81,0xdc,0xdc,0xdc,0xeb,0x02,0xbb,0xbb,0xbb,0xdc,0x00,0x00,0x00,0xb3,0x6a,0x6a, + 0x6a,0xc2,0x81,0xdc,0xdc,0xdc,0xeb,0x01,0xa0,0xa0,0xa0,0xd1,0xbb,0xbb,0xbb,0xdc,0x81,0xff,0xff,0xff,0xff,0x01,0xc7,0xc7,0xc7,0xe1,0x33,0x33,0x33,0xb8,0x82,0x00, + 0x00,0x00,0xb3,0x05,0x90,0x90,0x90,0xcc,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0xaf,0xaf,0xaf,0xd6,0xa0,0xa0,0xa0,0xd1,0x81,0xdc,0xdc,0xdc, + 0xeb,0x82,0x00,0x00,0x00,0xb3,0x01,0xaf,0xaf,0xaf,0xd6,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x01,0xd2,0xd2,0xd2,0xe6,0x7e,0x7e,0x7e,0xc7,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xf2,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xf2,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7, + 0x81,0xff,0xff,0xff,0xff,0x00,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x00,0x6a,0x6a,0x6a,0xc2,0x81,0x00,0x00,0x00,0xb3,0x00,0x52,0x52,0x52,0xbd,0x81,0xff, + 0xff,0xff,0xff,0x00,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0xf6,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff, + 0xff,0xbe,0x00,0x00,0x00,0xb3,0x03,0x90,0x90,0x90,0xcc,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0x33,0x33,0x33,0xb8,0xab,0x00,0x00,0x00,0xb3,0x01,0x33,0x33,0x33, + 0xb8,0x7e,0x7e,0x7e,0xc7,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0x91,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xf2,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x83,0xff,0xff,0xff,0xff,0x00,0xe6,0xe6,0xe6,0xf0,0x83,0x00,0x00,0x00,0xb3,0x00,0xe6,0xe6,0xe6, + 0xf0,0x83,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0xf6,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0xbf,0x00,0x00,0x00,0xb3,0x02, + 0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xa0,0xa0,0xa0,0xd1,0xaa,0x00,0x00,0x00,0xb3,0x03,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xdc,0xdc, + 0xdc,0xeb,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0x90,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xf2,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x83,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x83,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x83,0xff, + 0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0xf6,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0xbf,0x00,0x00,0x00,0xb3,0x02,0xaf,0xaf,0xaf, + 0xd6,0xff,0xff,0xff,0xff,0xe6,0xe6,0xe6,0xf0,0xaa,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0x90,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xf2,0x00,0x00,0x00,0xb3,0x00,0x6a,0x6a,0x6a,0xc2, + 0x83,0xdc,0xdc,0xdc,0xeb,0x00,0x52,0x52,0x52,0xbd,0x83,0x00,0x00,0x00,0xb3,0x00,0x52,0x52,0x52,0xbd,0x83,0xdc,0xdc,0xdc,0xeb,0x00,0x6a,0x6a,0x6a,0xc2,0xf6,0x00, + 0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0xbf,0x00,0x00,0x00,0xb3,0x00,0x52,0x52,0x52,0xbd,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e, + 0xc7,0xaa,0x00,0x00,0x00,0xb3,0x02,0xdc,0xdc,0xdc,0xeb,0xff,0xff,0xff,0xff,0xaf,0xaf,0xaf,0xd6,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0x90,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xf9,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1, + 0x81,0xaf,0xaf,0xaf,0xd6,0xc0,0x00,0x00,0x00,0xb3,0x01,0xaf,0xaf,0xaf,0xd6,0x90,0x90,0x90,0xcc,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xbf,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0x03,0x00, + 0x00,0x00,0xb3,0x6a,0x6a,0x6a,0xc2,0x7e,0x7e,0x7e,0xc7,0x33,0x33,0x33,0xb8,0x8a,0x00,0x00,0x00,0xb3,0x00,0x33,0x33,0x33,0xb8,0x81,0x7e,0x7e,0x7e,0xc7,0x00,0x52, + 0x52,0x52,0xbd,0x86,0x00,0x00,0x00,0xb3,0x02,0x6a,0x6a,0x6a,0xc2,0x7e,0x7e,0x7e,0xc7,0x52,0x52,0x52,0xbd,0x84,0x00,0x00,0x00,0xb3,0x00,0x52,0x52,0x52,0xbd,0x81, + 0x7e,0x7e,0x7e,0xc7,0x9e,0x00,0x00,0x00,0xb3,0x81,0x7e,0x7e,0x7e,0xc7,0x00,0x52,0x52,0x52,0xbd,0x8d,0x00,0x00,0x00,0xb3,0x00,0x33,0x33,0x33,0xb8,0x81,0x7e,0x7e, + 0x7e,0xc7,0x00,0x33,0x33,0x33,0xb8,0x88,0x00,0x00,0x00,0xb3,0x00,0x33,0x33,0x33,0xb8,0x81,0x7e,0x7e,0x7e,0xc7,0x00,0x33,0x33,0x33,0xb8,0x9e,0x00,0x00,0x00,0xb3, + 0x81,0x7e,0x7e,0x7e,0xc7,0x00,0x33,0x33,0x33,0xb8,0x84,0x00,0x00,0x00,0xb3,0x02,0x52,0x52,0x52,0xbd,0x7e,0x7e,0x7e,0xc7,0x52,0x52,0x52,0xbd,0x8b,0x00,0x00,0x00, + 0xb3,0x00,0x33,0x33,0x33,0xb8,0x81,0x7e,0x7e,0x7e,0xc7,0x00,0x33,0x33,0x33,0xb8,0x9a,0x00,0x00,0x00,0xb3,0x02,0x52,0x52,0x52,0xbd,0x7e,0x7e,0x7e,0xc7,0x6a,0x6a, + 0x6a,0xc2,0x85,0x00,0x00,0x00,0xb3,0x02,0x6a,0x6a,0x6a,0xc2,0x7e,0x7e,0x7e,0xc7,0x33,0x33,0x33,0xb8,0x87,0x00,0x00,0x00,0xb3,0x02,0x52,0x52,0x52,0xbd,0x7e,0x7e, + 0x7e,0xc7,0x6a,0x6a,0x6a,0xc2,0x84,0x00,0x00,0x00,0xb3,0x00,0x52,0x52,0x52,0xbd,0x81,0x7e,0x7e,0x7e,0xc7,0x89,0x00,0x00,0x00,0xb3,0x81,0x7e,0x7e,0x7e,0xc7,0x00, + 0x52,0x52,0x52,0xbd,0x8f,0x00,0x00,0x00,0xb3,0x00,0x6a,0x6a,0x6a,0xc2,0x81,0x7e,0x7e,0x7e,0xc7,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0x85,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xfe,0x00,0x00,0x00,0xb3,0x01,0x6a,0x6a,0x6a,0xc2,0xe6,0xe6,0xe6,0xf0,0x81, + 0xff,0xff,0xff,0xff,0x01,0xf7,0xf7,0xf7,0xfa,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81, + 0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x33,0x33,0x33,0xb8,0xc7,0xc7,0xc7,0xe1,0x83,0xff,0xff,0xff,0xff,0x01,0xef,0xef,0xef,0xf5,0x6a,0x6a,0x6a,0xc2,0x82, + 0x00,0x00,0x00,0xb3,0x01,0xaf,0xaf,0xaf,0xd6,0xef,0xef,0xef,0xf5,0x82,0xff,0xff,0xff,0xff,0x04,0xdc,0xdc,0xdc,0xeb,0x6a,0x6a,0x6a,0xc2,0x00,0x00,0x00,0xb3,0x6a, + 0x6a,0x6a,0xc2,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x01,0xf7,0xf7,0xf7,0xfa,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81, + 0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc, + 0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x83,0x00,0x00,0x00,0xb3, + 0x01,0xaf,0xaf,0xaf,0xd6,0xf7,0xf7,0xf7,0xfa,0x82,0xff,0xff,0xff,0xff,0x01,0xdc,0xdc,0xdc,0xeb,0x6a,0x6a,0x6a,0xc2,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf, + 0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x84,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x83,0xff,0xff,0xff,0xff,0x86,0x00,0x00,0x00,0xb3,0x01, + 0x33,0x33,0x33,0xb8,0xc7,0xc7,0xc7,0xe1,0x83,0xff,0xff,0xff,0xff,0x01,0xc7,0xc7,0xc7,0xe1,0x33,0x33,0x33,0xb8,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6, + 0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x88,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e, + 0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x02,0x33,0x33,0x33,0xb8,0xbb,0xbb,0xbb,0xdc,0xf7,0xf7,0xf7,0xfa,0x82, + 0xff,0xff,0xff,0xff,0x04,0xc7,0xc7,0xc7,0xe1,0x33,0x33,0x33,0xb8,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x05,0xdc, + 0xdc,0xdc,0xeb,0xe6,0xe6,0xe6,0xf0,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e, + 0xc7,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x83,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e, + 0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x86,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc, + 0xeb,0x84,0x00,0x00,0x00,0xb3,0x01,0x7e,0x7e,0x7e,0xc7,0xe6,0xe6,0xe6,0xf0,0x82,0xff,0xff,0xff,0xff,0x01,0xef,0xef,0xef,0xf5,0x90,0x90,0x90,0xcc,0x81,0x00,0x00, + 0x00,0xb3,0x01,0x6a,0x6a,0x6a,0xc2,0xef,0xef,0xef,0xf5,0x82,0xff,0xff,0xff,0xff,0x00,0xbb,0xbb,0xbb,0xdc,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81, + 0x00,0x00,0x00,0xb3,0x01,0x7e,0x7e,0x7e,0xc7,0xe6,0xe6,0xe6,0xf0,0x82,0xff,0xff,0xff,0xff,0x01,0xef,0xef,0xef,0xf5,0x90,0x90,0x90,0xcc,0x81,0x00,0x00,0x00,0xb3, + 0x00,0xd2,0xd2,0xd2,0xe6,0x82,0xff,0xff,0xff,0xff,0x01,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0x00,0x00, + 0x00,0xb3,0x01,0xaf,0xaf,0xaf,0xd6,0xf7,0xf7,0xf7,0xfa,0x82,0xff,0xff,0xff,0xff,0x01,0xdc,0xdc,0xdc,0xeb,0x6a,0x6a,0x6a,0xc2,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e, + 0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x02,0x00,0x00,0x00, + 0xb3,0x90,0x90,0x90,0xcc,0xef,0xef,0xef,0xf5,0x83,0xff,0xff,0xff,0xff,0x00,0xbb,0xbb,0xbb,0xdc,0x81,0x00,0x00,0x00,0xb3,0x03,0x90,0x90,0x90,0xcc,0xf7,0xf7,0xf7, + 0xfa,0xef,0xef,0xef,0xf5,0x52,0x52,0x52,0xbd,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xfd,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xfd,0x00,0x00,0x00,0xb3,0x01,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0x86,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0x7e,0x7e, + 0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x05,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xd2,0xd2,0xd2,0xe6,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0xdc,0xdc,0xdc,0xeb, + 0x81,0xff,0xff,0xff,0xff,0x03,0xf7,0xf7,0xf7,0xfa,0x33,0x33,0x33,0xb8,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x84,0xff,0xff,0xff,0xff,0x03,0xf7,0xf7,0xf7,0xfa, + 0x6a,0x6a,0x6a,0xc2,0x52,0x52,0x52,0xbd,0xf7,0xf7,0xf7,0xfa,0x85,0xff,0xff,0xff,0xff,0x00,0xbb,0xbb,0xbb,0xdc,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb, + 0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc, + 0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00, + 0xb3,0x00,0xbb,0xbb,0xbb,0xdc,0x85,0xff,0xff,0xff,0xff,0x03,0xf7,0xf7,0xf7,0xfa,0x52,0x52,0x52,0xbd,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff, + 0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x83,0x00,0x00,0x00,0xb3,0x00,0x52,0x52,0x52,0xbd,0x84,0xff,0xff,0xff,0xff,0x86,0x00,0x00,0x00,0xb3,0x00,0xe6,0xe6,0xe6,0xf0,0x85, + 0xff,0xff,0xff,0xff,0x00,0xe6,0xe6,0xe6,0xf0,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x88,0x00,0x00, + 0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6, + 0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00, + 0x00,0xb3,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x02,0xc7,0xc7,0xc7,0xe1,0xaf,0xaf,0xaf,0xd6,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc, + 0xdc,0xeb,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0x52,0x52,0x52,0xbd,0x84,0xff,0xff,0xff, + 0xff,0x01,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc, + 0xdc,0xdc,0xeb,0x86,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x83,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff, + 0xff,0x09,0xf7,0xf7,0xf7,0xfa,0xdc,0xdc,0xdc,0xeb,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0x33,0x33,0x33,0xb8,0x00,0x00,0x00,0xb3,0xef,0xef, + 0xef,0xf5,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0x81,0xbb,0xbb,0xbb,0xdc,0x00,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00, + 0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x85,0xff,0xff,0xff,0xff,0x02,0xa0,0xa0,0xa0,0xd1,0x00,0x00,0x00,0xb3,0xa0,0xa0,0xa0,0xd1,0x83,0xff,0xff,0xff,0xff,0x01,0xdc,0xdc, + 0xdc,0xeb,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x00,0xbb,0xbb,0xbb,0xdc,0x85,0xff,0xff,0xff,0xff,0x03, + 0xf7,0xf7,0xf7,0xfa,0x52,0x52,0x52,0xbd,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00, + 0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0xb3,0x6a,0x6a,0x6a,0xc2,0x81,0xff,0xff,0xff,0xff,0x01,0xdc,0xdc,0xdc,0xeb,0xef,0xef,0xef,0xf5, + 0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xfd,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xfd,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81, + 0xff,0xff,0xff,0xff,0x03,0xe6,0xe6,0xe6,0xf0,0x90,0x90,0x90,0xcc,0x7e,0x7e,0x7e,0xc7,0xd2,0xd2,0xd2,0xe6,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00, + 0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x03,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00, + 0x00,0xb3,0x00,0xbb,0xbb,0xbb,0xdc,0x81,0xff,0xff,0xff,0xff,0x01,0x7e,0x7e,0x7e,0xc7,0x52,0x52,0x52,0xbd,0x81,0xff,0xff,0xff,0xff,0x06,0xf7,0xf7,0xf7,0xfa,0xa0, + 0xa0,0xa0,0xd1,0x7e,0x7e,0x7e,0xc7,0xd2,0xd2,0xd2,0xe6,0x6a,0x6a,0x6a,0xc2,0x00,0x00,0x00,0xb3,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x03,0xd2,0xd2,0xd2, + 0xe6,0x7e,0x7e,0x7e,0xc7,0xa0,0xa0,0xa0,0xd1,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x02,0x52,0x52,0x52,0xbd,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81, + 0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc, + 0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3, + 0x00,0x52,0x52,0x52,0xbd,0x81,0xff,0xff,0xff,0xff,0x03,0xf7,0xf7,0xf7,0xfa,0xa0,0xa0,0xa0,0xd1,0x7e,0x7e,0x7e,0xc7,0xd2,0xd2,0xd2,0xe6,0x81,0xff,0xff,0xff,0xff, + 0x02,0xc7,0xc7,0xc7,0xe1,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x83,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e, + 0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xd2,0xd2,0xd2,0xe6,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0x85,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff, + 0xff,0xff,0x00,0xe6,0xe6,0xe6,0xf0,0x81,0x90,0x90,0x90,0xcc,0x00,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x02,0xa0,0xa0,0xa0,0xd1,0x00,0x00,0x00,0xb3,0xaf, + 0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x88,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00, + 0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf, + 0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x01,0xa0,0xa0,0xa0,0xd1,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x02,0xdc,0xdc,0xdc,0xeb,0xff,0xff,0xff,0xff,0xdc,0xdc, + 0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x05,0x33,0x33,0x33,0xb8,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6, + 0x81,0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x04,0xd2,0xd2,0xd2,0xe6,0x00,0x00,0x00,0xb3, + 0x33,0x33,0x33,0xb8,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff, + 0x00,0xdc,0xdc,0xdc,0xeb,0x86,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x83,0x00,0x00,0x00,0xb3,0x07,0xef,0xef,0xef,0xf5,0xff,0xff, + 0xff,0xff,0xef,0xef,0xef,0xf5,0x33,0x33,0x33,0xb8,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0xc7,0xc7,0xc7,0xe1,0x52,0x52,0x52,0xbd,0x81,0x00,0x00,0x00,0xb3,0x81, + 0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0x6a,0x6a,0x6a,0xc2,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00, + 0xb3,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x03,0xaf,0xaf,0xaf,0xd6,0x7e,0x7e,0x7e,0xc7,0xbb,0xbb,0xbb,0xdc,0xa0,0xa0,0xa0,0xd1,0x81,0x00,0x00,0x00,0xb3, + 0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x03,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff, + 0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0x52,0x52,0x52,0xbd,0x81,0xff,0xff,0xff,0xff,0x03,0xf7,0xf7,0xf7,0xfa,0xa0,0xa0,0xa0,0xd1,0x7e,0x7e,0x7e,0xc7,0xd2, + 0xd2,0xd2,0xe6,0x81,0xff,0xff,0xff,0xff,0x02,0xc7,0xc7,0xc7,0xe1,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81, + 0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x03,0xa0,0xa0,0xa0,0xd1,0x6a,0x6a,0x6a,0xc2,0x00,0x00,0x00,0xb3, + 0x33,0x33,0x33,0xb8,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xfd,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xfd,0x00,0x00,0x00,0xb3,0x00,0xdc, + 0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x00,0x52,0x52,0x52,0xbd,0x82,0x00,0x00,0x00,0xb3,0x04,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xaf,0xaf,0xaf,0xd6,0x00, + 0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x02,0x7e,0x7e,0x7e,0xc7,0xbb,0xbb,0xbb,0xdc,0xe6, + 0xe6,0xe6,0xf0,0x82,0xff,0xff,0xff,0xff,0x01,0x52,0x52,0x52,0xbd,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0xa0,0xa0,0xa0,0xd1,0x84,0x00,0x00,0x00,0xb3, + 0x02,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0x82,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf, + 0xd6,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf, + 0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff, + 0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0xa0,0xa0,0xa0,0xd1,0x82,0x00,0x00,0x00,0xb3,0x04,0xef, + 0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x83,0x00,0x00, + 0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x87,0x00,0x00,0x00,0xb3,0x00,0xd2,0xd2,0xd2,0xe6,0x81,0xff,0xff,0xff,0xff, + 0x00,0x52,0x52,0x52,0xbd,0x81,0x00,0x00,0x00,0xb3,0x00,0x52,0x52,0x52,0xbd,0x81,0xff,0xff,0xff,0xff,0x02,0xd2,0xd2,0xd2,0xe6,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf, + 0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x88,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00, + 0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xd2,0xd2,0xd2,0xe6,0x81,0xff,0xff,0xff,0xff,0x85,0xaf,0xaf,0xaf,0xd6, + 0x01,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0xbb,0xbb,0xbb,0xdc,0x81,0x7e,0x7e,0x7e,0xc7,0x04,0xe6,0xe6,0xe6,0xf0,0xff,0xff,0xff, + 0xff,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81, + 0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00, + 0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x86,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0x00,0x00,0x00,0xb3, + 0x00,0x6a,0x6a,0x6a,0xc2,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x84,0xaf,0xaf,0xaf,0xd6,0x05,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc, + 0xeb,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0xaf,0xaf,0xaf,0xd6,0x81,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x01,0xaf,0xaf,0xaf,0xd6,0x6a,0x6a,0x6a,0xc2, + 0x81,0xff,0xff,0xff,0xff,0x00,0xc7,0xc7,0xc7,0xe1,0x85,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0x00, + 0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0xa0,0xa0,0xa0,0xd1,0x82, + 0x00,0x00,0x00,0xb3,0x04,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf, + 0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x03,0x33,0x33,0x33,0xb8,0xaf,0xaf,0xaf,0xd6, + 0xd2,0xd2,0xd2,0xe6,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0x00,0x00,0x00,0xb3,0x01,0x6a,0x6a,0x6a,0xc2,0x52,0x52,0x52,0xbd, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xfe,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xfd,0x00,0x00,0x00,0xb3,0x00,0xdc, + 0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x83,0x00,0x00,0x00,0xb3,0x04,0xdc,0xdc,0xdc,0xeb,0xff,0xff,0xff,0xff,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0x7e,0x7e, + 0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0x90,0x90,0x90,0xcc,0x84,0xff,0xff,0xff,0xff,0x02,0xbb,0xbb,0xbb,0xdc,0x00,0x00, + 0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x84,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x82, + 0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff, + 0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff, + 0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf, + 0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0xb3,0xaf, + 0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x83,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf, + 0xd6,0x87,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x83,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00, + 0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x88,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff, + 0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x87,0xff,0xff,0xff, + 0xff,0x02,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0xd2,0xd2,0xd2,0xe6,0x85,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6, + 0x81,0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00, + 0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x86, + 0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x87,0xff,0xff,0xff,0xff,0x03,0xaf,0xaf, + 0xaf,0xd6,0x00,0x00,0x00,0xb3,0x6a,0x6a,0x6a,0xc2,0xe6,0xe6,0xe6,0xf0,0x85,0xff,0xff,0xff,0xff,0x01,0xaf,0xaf,0xaf,0xd6,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff, + 0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x85,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0x00,0x00,0x00,0xb3,0x81, + 0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0x00,0x00,0x00,0xb3, + 0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00, + 0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0xe6,0xe6,0xe6,0xf0,0x83,0xff,0xff,0xff,0xff,0x01,0xef,0xef,0xef,0xf5, + 0x6a,0x6a,0x6a,0xc2,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0x82,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xfd,0x00,0x00,0x00,0xb3,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x05,0x33,0x33,0x33,0xb8, + 0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00, + 0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0xaf,0xaf,0xaf,0xd6,0x52,0x52,0x52,0xbd,0x81,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0, + 0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0x33,0x33,0x33,0xb8,0x81,0x00,0x00,0x00,0xb3,0x03,0xef,0xef,0xef,0xf5, + 0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0x33,0x33,0x33,0xb8,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0xa0,0xa0,0xa0,0xd1, + 0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x02,0x52,0x52,0x52,0xbd,0x00,0x00,0x00,0xb3,0x90,0x90,0x90,0xcc,0x81,0xff,0xff,0xff,0xff,0x00, + 0xc7,0xc7,0xc7,0xe1,0x81,0x00,0x00,0x00,0xb3,0x00,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff, + 0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3, + 0x05,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0xbb, + 0xbb,0xbb,0xdc,0x83,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x87,0x00,0x00,0x00,0xb3,0x00,0xc7,0xc7,0xc7, + 0xe1,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xc7,0xc7,0xc7,0xe1,0x00, + 0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0xbb,0xbb,0xbb,0xdc,0x88,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff, + 0x02,0x52,0x52,0x52,0xbd,0x00,0x00,0x00,0xb3,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xc7,0xc7,0xc7,0xe1,0x81, + 0xff,0xff,0xff,0xff,0x00,0x90,0x90,0x90,0xcc,0x81,0x7e,0x7e,0x7e,0xc7,0x02,0xe6,0xe6,0xe6,0xf0,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0x82,0x00,0x00,0x00,0xb3, + 0x01,0x52,0x52,0x52,0xbd,0x90,0x90,0x90,0xcc,0x81,0xaf,0xaf,0xaf,0xd6,0x04,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0xaf, + 0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82, + 0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0xa0,0xa0,0xa0,0xd1,0x00,0x00,0x00,0xb3,0x52,0x52,0x52,0xbd,0x81,0xff,0xff,0xff,0xff, + 0x00,0xdc,0xdc,0xdc,0xeb,0x86,0x00,0x00,0x00,0xb3,0x82,0xff,0xff,0xff,0xff,0x00,0x33,0x33,0x33,0xb8,0x81,0x00,0x00,0x00,0xb3,0x00,0x52,0x52,0x52,0xbd,0x81,0xff, + 0xff,0xff,0xff,0x00,0xd2,0xd2,0xd2,0xe6,0x81,0x7e,0x7e,0x7e,0xc7,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00, + 0xb3,0x01,0x6a,0x6a,0x6a,0xc2,0xa0,0xa0,0xa0,0xd1,0x81,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x01,0xaf,0xaf,0xaf,0xd6,0x52,0x52,0x52,0xbd,0x81,0xff,0xff, + 0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x00,0x33,0x33,0x33,0xb8,0x82,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff, + 0x00,0x7e,0x7e,0x7e,0xc7,0x82,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff, + 0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x05,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0x00,0x00,0x00,0xb3, + 0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0x00,0x00,0x00,0xb3,0x00,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x01,0x00,0x00, + 0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xf7,0xf7,0xf7,0xfa,0xbb,0xbb,0xbb,0xdc,0x90,0x90,0x90,0xcc,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0x84,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xfd,0x00,0x00,0x00,0xb3,0x00,0x90,0x90,0x90,0xcc, + 0x81,0xff,0xff,0xff,0xff,0x03,0xf7,0xf7,0xf7,0xfa,0xbb,0xbb,0xbb,0xdc,0xaf,0xaf,0xaf,0xd6,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6, + 0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x06, + 0x52,0x52,0x52,0xbd,0x33,0x33,0x33,0xb8,0xaf,0xaf,0xaf,0xd6,0x33,0x33,0x33,0xb8,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff, + 0xff,0x05,0xc7,0xc7,0xc7,0xe1,0xaf,0xaf,0xaf,0xd6,0xef,0xef,0xef,0xf5,0xa0,0xa0,0xa0,0xd1,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02, + 0xef,0xef,0xef,0xf5,0xaf,0xaf,0xaf,0xd6,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x03,0xf7,0xf7,0xf7,0xfa,0x33,0x33,0x33,0xb8,0x00,0x00,0x00,0xb3,0xdc,0xdc, + 0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x02,0xe6,0xe6,0xe6,0xf0,0xaf,0xaf,0xaf,0xd6,0xe6,0xe6,0xe6,0xf0,0x82,0xff,0xff,0xff,0xff,0x01,0xc7,0xc7,0xc7,0xe1,0xbb,0xbb, + 0xbb,0xdc,0x81,0xff,0xff,0xff,0xff,0x03,0xef,0xef,0xef,0xf5,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x04,0xdc,0xdc, + 0xdc,0xeb,0xaf,0xaf,0xaf,0xd6,0x7e,0x7e,0x7e,0xc7,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x02,0xc7,0xc7,0xc7,0xe1,0xaf,0xaf,0xaf,0xd6, + 0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x82,0xff,0xff,0xff,0xff,0x04,0xc7,0xc7,0xc7,0xe1, + 0xaf,0xaf,0xaf,0xd6,0xa0,0xa0,0xa0,0xd1,0xaf,0xaf,0xaf,0xd6,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xaf,0xaf,0xaf,0xd6,0x85, + 0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xf7,0xf7,0xf7,0xfa,0x81,0xbb,0xbb,0xbb,0xdc,0x00,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff, + 0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x82,0xff,0xff,0xff,0xff,0x02,0xc7,0xc7,0xc7,0xe1,0xaf,0xaf,0xaf,0xd6,0xa0,0xa0,0xa0, + 0xd1,0x85,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x02,0xe6,0xe6,0xe6,0xf0,0xaf,0xaf,0xaf,0xd6,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff, + 0xff,0xff,0x02,0xa0,0xa0,0xa0,0xd1,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xc7,0xc7,0xc7,0xe1,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e, + 0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0x00,0x00,0x00,0xb3,0x09,0x33,0x33,0x33,0xb8,0xaf,0xaf,0xaf,0xd6,0x33,0x33,0x33,0xb8,0x00,0x00,0x00, + 0xb3,0x52,0x52,0x52,0xbd,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0x7e, + 0x7e,0x7e,0xc7,0xaf,0xaf,0xaf,0xd6,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xaf,0xaf,0xaf,0xd6,0x01,0x00,0x00,0x00,0xb3,0xaf, + 0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0xf7,0xf7,0xf7,0xfa,0xaf,0xaf,0xaf,0xd6,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x00,0xc7,0xc7,0xc7,0xe1,0x86, + 0x00,0x00,0x00,0xb3,0x82,0xff,0xff,0xff,0xff,0x00,0xef,0xef,0xef,0xf5,0x81,0xaf,0xaf,0xaf,0xd6,0x06,0x52,0x52,0x52,0xbd,0xdc,0xdc,0xdc,0xeb,0xff,0xff,0xff,0xff, + 0xf7,0xf7,0xf7,0xfa,0x6a,0x6a,0x6a,0xc2,0x33,0x33,0x33,0xb8,0xd2,0xd2,0xd2,0xe6,0x81,0xff,0xff,0xff,0xff,0x00,0x52,0x52,0x52,0xbd,0x81,0x00,0x00,0x00,0xb3,0x01, + 0x6a,0x6a,0x6a,0xc2,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0x90,0x90,0x90,0xcc,0x81,0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3, + 0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x06,0xdc,0xdc,0xdc,0xeb,0xaf,0xaf,0xaf,0xd6,0xdc,0xdc,0xdc,0xeb,0xc7,0xc7,0xc7,0xe1,0x52,0x52,0x52,0xbd,0xaf,0xaf, + 0xaf,0xd6,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x03,0xc7,0xc7,0xc7,0xe1,0xaf,0xaf,0xaf,0xd6,0xa0,0xa0,0xa0,0xd1,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff, + 0xff,0x03,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x02,0xc7,0xc7,0xc7,0xe1,0xaf,0xaf,0xaf,0xd6, + 0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x01,0xbb,0xbb,0xbb,0xdc, + 0xd2,0xd2,0xd2,0xe6,0x81,0xff,0xff,0xff,0xff,0x02,0xef,0xef,0xef,0xf5,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x03,0xc7,0xc7,0xc7,0xe1, + 0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0xa0,0xa0,0xa0,0xd1,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0x83,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xfe,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x86,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00, + 0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0x90,0x90,0x90,0xcc,0x84,0xff,0xff,0xff,0xff,0x03,0xe6,0xe6, + 0xe6,0xf0,0x33,0x33,0x33,0xb8,0x00,0x00,0x00,0xb3,0x90,0x90,0x90,0xcc,0x85,0xff,0xff,0xff,0xff,0x02,0x90,0x90,0x90,0xcc,0x33,0x33,0x33,0xb8,0xe6,0xe6,0xe6,0xf0, + 0x85,0xff,0xff,0xff,0xff,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x00,0xf7,0xf7,0xf7,0xfa,0x82,0xff, + 0xff,0xff,0xff,0x01,0xf7,0xf7,0xf7,0xfa,0xe6,0xe6,0xe6,0xf0,0x83,0xff,0xff,0xff,0xff,0x01,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0x85,0xff,0xff,0xff,0xff,0x02, + 0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xa0,0xa0,0xa0,0xd1,0x85,0xff,0xff,0xff,0xff,0x03,0xe6,0xe6,0xe6,0xf0,0x33,0x33,0x33,0xb8,0x00,0x00,0x00,0xb3,0xaf,0xaf, + 0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x86,0xff,0xff,0xff,0xff,0x86,0x00,0x00,0x00,0xb3, + 0x00,0xc7,0xc7,0xc7,0xe1,0x85,0xff,0xff,0xff,0xff,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0xe6, + 0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x85,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x00,0xf7,0xf7,0xf7, + 0xfa,0x83,0xff,0xff,0xff,0xff,0x00,0x52,0x52,0x52,0xbd,0x81,0x00,0x00,0x00,0xb3,0x00,0xc7,0xc7,0xc7,0xe1,0x84,0xff,0xff,0xff,0xff,0x01,0xf7,0xf7,0xf7,0xfa,0x52, + 0x52,0x52,0xbd,0x81,0x00,0x00,0x00,0xb3,0x04,0xdc,0xdc,0xdc,0xeb,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0xdc,0xdc,0xdc,0xeb,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff, + 0xff,0xff,0x02,0x52,0x52,0x52,0xbd,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x86,0xff,0xff,0xff,0xff,0x01,0x00, + 0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0xf7,0xf7,0xf7,0xfa,0x83,0xff,0xff,0xff,0xff,0x00,0xa0,0xa0,0xa0,0xd1,0x86,0x00,0x00,0x00,0xb3, + 0x81,0xff,0xff,0xff,0xff,0x01,0xef,0xef,0xef,0xf5,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x6a,0x6a,0x6a,0xc2,0xf7,0xf7,0xf7,0xfa, + 0x84,0xff,0xff,0xff,0xff,0x00,0xbb,0xbb,0xbb,0xdc,0x81,0x00,0x00,0x00,0xb3,0x04,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5, + 0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x00,0xef,0xef,0xef,0xf5,0x81,0x00,0x00,0x00,0xb3,0x01,0x52,0x52,0x52,0xbd,0xf7,0xf7,0xf7,0xfa,0x84,0xff,0xff,0xff, + 0xff,0x00,0xe6,0xe6,0xe6,0xf0,0x85,0xff,0xff,0xff,0xff,0x01,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00, + 0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x85,0xff,0xff,0xff,0xff,0x03,0xe6,0xe6,0xe6,0xf0,0x33,0x33,0x33,0xb8,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff, + 0xff,0xff,0xff,0x00,0xf7,0xf7,0xf7,0xfa,0x83,0xff,0xff,0xff,0xff,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0x00,0x00,0x00,0xb3,0x00,0xe6,0xe6,0xe6,0xf0,0x84,0xff,0xff,0xff, + 0xff,0x00,0xa0,0xa0,0xa0,0xd1,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0x82,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xfe,0x00,0x00,0x00,0xb3,0x05,0x33,0x33,0x33,0xb8,0xc7,0xc7,0xc7,0xe1,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0xaf,0xaf, + 0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0x6a,0x6a,0x6a,0xc2,0x81,0xdc,0xdc,0xdc,0xeb,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0x00, + 0x00,0x00,0xb3,0x01,0x90,0x90,0x90,0xcc,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x01,0xe6,0xe6,0xe6,0xf0,0xa0,0xa0,0xa0,0xd1,0x82,0x00,0x00,0x00,0xb3,0x0a, + 0x6a,0x6a,0x6a,0xc2,0xd2,0xd2,0xd2,0xe6,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0xaf,0xaf,0xaf,0xd6,0x33,0x33,0x33,0xb8,0x00,0x00,0x00,0xb3, + 0x33,0x33,0x33,0xb8,0xaf,0xaf,0xaf,0xd6,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x01,0xd2,0xd2,0xd2,0xe6,0x7e,0x7e,0x7e,0xc7,0x82,0x00,0x00,0x00,0xb3,0x00, + 0xbb,0xbb,0xbb,0xdc,0x81,0xdc,0xdc,0xdc,0xeb,0x06,0x6a,0x6a,0x6a,0xc2,0xe6,0xe6,0xe6,0xf0,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0x90,0x90,0x90,0xcc,0x33,0x33, + 0x33,0xb8,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x04,0xc7,0xc7,0xc7,0xe1,0x33,0x33,0x33,0xb8,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0xe6,0xe6,0xe6,0xf0, + 0x81,0xff,0xff,0xff,0xff,0x02,0xef,0xef,0xef,0xf5,0xdc,0xdc,0xdc,0xeb,0xa0,0xa0,0xa0,0xd1,0x81,0x00,0x00,0x00,0xb3,0x01,0x7e,0x7e,0x7e,0xc7,0xd2,0xd2,0xd2,0xe6, + 0x81,0xff,0xff,0xff,0xff,0x02,0xef,0xef,0xef,0xf5,0xaf,0xaf,0xaf,0xd6,0x33,0x33,0x33,0xb8,0x81,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0xdc,0xdc,0xdc, + 0xeb,0x02,0x7e,0x7e,0x7e,0xc7,0xc7,0xc7,0xc7,0xe1,0xff,0xff,0xff,0xff,0x81,0xdc,0xdc,0xdc,0xeb,0x00,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x00,0xef,0xef, + 0xef,0xf5,0x81,0xdc,0xdc,0xdc,0xeb,0x87,0x00,0x00,0x00,0xb3,0x01,0xa0,0xa0,0xa0,0xd1,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x01,0xe6,0xe6,0xe6,0xf0,0xa0, + 0xa0,0xa0,0xd1,0x82,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0xdc,0xdc,0xdc,0xeb,0x03,0x7e,0x7e,0x7e,0xc7,0xc7,0xc7,0xc7,0xe1,0xff,0xff,0xff,0xff,0xdc, + 0xdc,0xdc,0xeb,0x85,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x04,0x90,0x90,0x90,0xcc,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xef, + 0xef,0xef,0xf5,0x90,0x90,0x90,0xcc,0x83,0x00,0x00,0x00,0xb3,0x01,0xa0,0xa0,0xa0,0xd1,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x01,0xd2,0xd2,0xd2,0xe6,0x6a, + 0x6a,0x6a,0xc2,0x82,0x00,0x00,0x00,0xb3,0x02,0x52,0x52,0x52,0xbd,0xc7,0xc7,0xc7,0xe1,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x01,0xdc,0xdc,0xdc,0xeb,0x7e, + 0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7,0xdc,0xdc,0xdc,0xeb,0xe6,0xe6,0xe6,0xf0,0x81, + 0xff,0xff,0xff,0xff,0x00,0xef,0xef,0xef,0xf5,0x81,0xdc,0xdc,0xdc,0xeb,0x01,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x04,0xaf,0xaf,0xaf, + 0xd6,0xdc,0xdc,0xdc,0xeb,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0xaf,0xaf,0xaf,0xd6,0x87,0x00,0x00,0x00,0xb3,0x81,0xdc,0xdc,0xdc,0xeb,0x0b,0xbb,0xbb,0xbb,0xdc, + 0x90,0x90,0x90,0xcc,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0x52,0x52,0x52,0xbd,0xc7,0xc7,0xc7,0xe1,0xf7,0xf7,0xf7,0xfa, + 0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0xaf,0xaf,0xaf,0xd6,0x83,0x00,0x00,0x00,0xb3,0x06,0x7e,0x7e,0x7e,0xc7,0xd2,0xd2,0xd2,0xe6,0xf7,0xf7,0xf7,0xfa,0xff,0xff, + 0xff,0xff,0xf7,0xf7,0xf7,0xfa,0xd2,0xd2,0xd2,0xe6,0x52,0x52,0x52,0xbd,0x82,0x00,0x00,0x00,0xb3,0x08,0x33,0x33,0x33,0xb8,0xc7,0xc7,0xc7,0xe1,0xef,0xef,0xef,0xf5, + 0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0xc7,0xc7,0xc7,0xe1,0x6a,0x6a,0x6a,0xc2,0xdc,0xdc,0xdc,0xeb,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x03,0xe6,0xe6, + 0xe6,0xf0,0xdc,0xdc,0xdc,0xeb,0xbb,0xbb,0xbb,0xdc,0x00,0x00,0x00,0xb3,0x81,0xdc,0xdc,0xdc,0xeb,0x00,0xbb,0xbb,0xbb,0xdc,0x82,0x00,0x00,0x00,0xb3,0x01,0x7e,0x7e, + 0x7e,0xc7,0xd2,0xd2,0xd2,0xe6,0x81,0xff,0xff,0xff,0xff,0x02,0xef,0xef,0xef,0xf5,0xaf,0xaf,0xaf,0xd6,0x33,0x33,0x33,0xb8,0x81,0x00,0x00,0x00,0xb3,0x00,0x6a,0x6a, + 0x6a,0xc2,0x81,0xdc,0xdc,0xdc,0xeb,0x01,0xa0,0xa0,0xa0,0xd1,0xbb,0xbb,0xbb,0xdc,0x81,0xff,0xff,0xff,0xff,0x01,0xc7,0xc7,0xc7,0xe1,0x33,0x33,0x33,0xb8,0x81,0x00, + 0x00,0x00,0xb3,0x06,0x33,0x33,0x33,0xb8,0xc7,0xc7,0xc7,0xe1,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0xc7,0xc7,0xc7,0xe1,0x52,0x52,0x52,0xbd, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0x82,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0x83,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x01,0x52,0x52,0x52, + 0xbd,0x6a,0x6a,0x6a,0xc2,0xad,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x94,0x00,0x00,0x00,0xb3,0x00,0x7e, + 0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x9f,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x9a,0x00,0x00,0x00, + 0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf, + 0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0xaf,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6, + 0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0x00,0x00,0x00,0xb3,0x01,0x33,0x33,0x33,0xb8,0x7e,0x7e,0x7e,0xc7,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xa1,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0x83,0x00,0x00,0x00,0xb3, + 0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf, + 0xd6,0xac,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x94,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81, + 0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x9f,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x9a,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf, + 0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00, + 0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0xaf,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff, + 0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x03,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xa0,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0x83, + 0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff, + 0x00,0xdc,0xdc,0xdc,0xeb,0xac,0x00,0x00,0x00,0xb3,0x00,0x52,0x52,0x52,0xbd,0x81,0xff,0xff,0xff,0xff,0x00,0xf7,0xf7,0xf7,0xfa,0x81,0xaf,0xaf,0xaf,0xd6,0x92,0x00, + 0x00,0x00,0xb3,0x00,0x33,0x33,0x33,0xb8,0x81,0x7e,0x7e,0x7e,0xc7,0x00,0x52,0x52,0x52,0xbd,0x9f,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff, + 0xff,0x9a,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0x81,0x7e,0x7e, + 0x7e,0xc7,0x00,0x52,0x52,0x52,0xbd,0x82,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0xaf,0x00,0x00,0x00,0xb3, + 0x00,0x52,0x52,0x52,0xbd,0x81,0x7e,0x7e,0x7e,0xc7,0x00,0x33,0x33,0x33,0xb8,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xa0,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0x83,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x05,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0x52,0x52,0x52,0xbd,0xef,0xef,0xef, + 0xf5,0xf7,0xf7,0xf7,0xfa,0x90,0x90,0x90,0xcc,0xad,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0xb6,0x00,0x00, + 0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x9a,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7, + 0x87,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0xb6,0x00,0x00,0x00,0xb3,0x02,0xdc,0xdc,0xdc,0xeb,0xff,0xff, + 0xff,0xff,0xaf,0xaf,0xaf,0xd6,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xa0,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0x83,0x00,0x00,0x00,0xb3,0x00,0x52,0x52,0x52,0xbd,0x81,0xaf,0xaf,0xaf,0xd6,0x00,0x7e,0x7e,0x7e,0xc7,0xb2,0x00,0x00, + 0x00,0xb3,0x01,0x33,0x33,0x33,0xb8,0xaf,0xaf,0xaf,0xd6,0x81,0xdc,0xdc,0xdc,0xeb,0x00,0xbb,0xbb,0xbb,0xdc,0xb6,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x81, + 0xaf,0xaf,0xaf,0xd6,0x9a,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xaf,0xaf,0xaf,0xd6,0x00,0x52,0x52,0x52,0xbd,0x87,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e, + 0x7e,0xc7,0x81,0xaf,0xaf,0xaf,0xd6,0x00,0x52,0x52,0x52,0xbd,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xda,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xa7,0x00,0x00,0x00, + 0xb3,0x00,0x33,0x33,0x33,0xb8,0x81,0x7e,0x7e,0x7e,0xc7,0x00,0x33,0x33,0x33,0xb8,0xff,0x00,0x00,0x00,0xb3,0x97,0x00,0x00,0x00,0xb3,0x02,0x6a,0x6a,0x6a,0xc2,0x7e, + 0x7e,0x7e,0xc7,0x6a,0x6a,0x6a,0xc2,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xb8,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xe4,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0xbe,0x00,0x00,0x00,0xb3,0x00,0xf7, + 0xf7,0xf7,0xfa,0x82,0xff,0xff,0xff,0xff,0x00,0xbb,0xbb,0xbb,0xdc,0xb4,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0xdd,0x00,0x00,0x00, + 0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0xff,0xff,0xff,0xff,0x01,0xef,0xef,0xef,0xf5,0x6a,0x6a,0x6a,0xc2,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xb6,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xe4,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff, + 0xff,0x00,0x7e,0x7e,0x7e,0xc7,0xbe,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x83,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0xb3,0x00,0x00,0x00,0xb3,0x81, + 0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0xdd,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x83,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xb6,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xe4,0x00,0x00,0x00,0xb3, + 0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0xbe,0x00,0x00,0x00,0xb3,0x05,0x52,0x52,0x52,0xbd,0x00,0x00,0x00,0xb3,0x6a,0x6a,0x6a, + 0xc2,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xd2,0xd2,0xd2,0xe6,0xb3,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0xdd,0x00,0x00,0x00, + 0xb3,0x81,0x33,0x33,0x33,0xb8,0x01,0x00,0x00,0x00,0xb3,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x00,0x6a,0x6a,0x6a,0xc2,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xb5,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xaa,0x00,0x00,0x00,0xb3,0x02,0x6a,0x6a,0x6a,0xc2,0x7e,0x7e,0x7e,0xc7, + 0x52,0x52,0x52,0xbd,0x97,0x00,0x00,0x00,0xb3,0x02,0x33,0x33,0x33,0xb8,0x7e,0x7e,0x7e,0xc7,0x6a,0x6a,0x6a,0xc2,0x90,0x00,0x00,0x00,0xb3,0x81,0x7e,0x7e,0x7e,0xc7, + 0x00,0x33,0x33,0x33,0xb8,0x94,0x00,0x00,0x00,0xb3,0x02,0x52,0x52,0x52,0xbd,0x7e,0x7e,0x7e,0xc7,0x52,0x52,0x52,0xbd,0x91,0x00,0x00,0x00,0xb3,0x02,0x33,0x33,0x33, + 0xb8,0x7e,0x7e,0x7e,0xc7,0x6a,0x6a,0x6a,0xc2,0x88,0x00,0x00,0x00,0xb3,0x00,0x33,0x33,0x33,0xb8,0x81,0x7e,0x7e,0x7e,0xc7,0x9c,0x00,0x00,0x00,0xb3,0x04,0x21,0x21, + 0x21,0xba,0x43,0x43,0x43,0xc2,0x4d,0x4d,0x4d,0xc5,0x41,0x41,0x41,0xc2,0x13,0x13,0x13,0xb7,0x91,0x00,0x00,0x00,0xb3,0x00,0x33,0x33,0x33,0xb8,0x81,0x7e,0x7e,0x7e, + 0xc7,0x00,0x52,0x52,0x52,0xbd,0x86,0x00,0x00,0x00,0xb3,0x00,0x33,0x33,0x33,0xb8,0x81,0x7e,0x7e,0x7e,0xc7,0x00,0x33,0x33,0x33,0xb8,0x83,0x00,0x00,0x00,0xb3,0x00, + 0x52,0x52,0x52,0xbd,0x81,0x7e,0x7e,0x7e,0xc7,0x84,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x01,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00, + 0xb3,0x81,0x7e,0x7e,0x7e,0xc7,0x8a,0x00,0x00,0x00,0xb3,0x02,0x33,0x33,0x33,0xb8,0x7e,0x7e,0x7e,0xc7,0x6a,0x6a,0x6a,0xc2,0x86,0x00,0x00,0x00,0xb3,0x00,0x52,0x52, + 0x52,0xbd,0x81,0x7e,0x7e,0x7e,0xc7,0x00,0x33,0x33,0x33,0xb8,0x86,0x00,0x00,0x00,0xb3,0x81,0x7e,0x7e,0x7e,0xc7,0x00,0x33,0x33,0x33,0xb8,0x9b,0x00,0x00,0x00,0xb3, + 0x00,0xbb,0xbb,0xbb,0xdc,0x81,0xff,0xff,0xff,0xff,0x00,0x52,0x52,0x52,0xbd,0x86,0x00,0x00,0x00,0xb3,0x81,0x7e,0x7e,0x7e,0xc7,0x00,0x52,0x52,0x52,0xbd,0x85,0x00, + 0x00,0x00,0xb3,0x02,0x33,0x33,0x33,0xb8,0x7e,0x7e,0x7e,0xc7,0x6a,0x6a,0x6a,0xc2,0x8d,0x00,0x00,0x00,0xb3,0x00,0x33,0x33,0x33,0xb8,0x81,0x7e,0x7e,0x7e,0xc7,0x8e, + 0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x04,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0x52,0x52,0x52,0xbd,0x7e,0x7e,0x7e,0xc7,0x52,0x52,0x52,0xbd,0x86,0x00, + 0x00,0x00,0xb3,0x02,0x52,0x52,0x52,0xbd,0x7e,0x7e,0x7e,0xc7,0x6a,0x6a,0x6a,0xc2,0x92,0x00,0x00,0x00,0xb3,0x00,0x33,0x33,0x33,0xb8,0x81,0x7e,0x7e,0x7e,0xc7,0x91, + 0x00,0x00,0x00,0xb3,0x02,0x52,0x52,0x52,0xbd,0x7e,0x7e,0x7e,0xc7,0x6a,0x6a,0x6a,0xc2,0x85,0x00,0x00,0x00,0xb3,0x81,0x7e,0x7e,0x7e,0xc7,0x00,0x33,0x33,0x33,0xb8, + 0x8a,0x00,0x00,0x00,0xb3,0x81,0x7e,0x7e,0x7e,0xc7,0x91,0x00,0x00,0x00,0xb3,0x00,0x33,0x33,0x33,0xb8,0x81,0xff,0xff,0xff,0xff,0x00,0xc7,0xc7,0xc7,0xe1,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xb5,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xa8,0x00,0x00,0x00,0xb3,0x01,0xaf,0xaf,0xaf, + 0xd6,0xef,0xef,0xef,0xf5,0x82,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x6a,0x6a,0x6a,0xc2,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e, + 0xc7,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf, + 0xaf,0xd6,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0xff, + 0xff,0xff,0xff,0x01,0xdc,0xdc,0xdc,0xeb,0xbb,0xbb,0xbb,0xdc,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff, + 0x00,0x7e,0x7e,0x7e,0xc7,0x83,0x00,0x00,0x00,0xb3,0x02,0x33,0x33,0x33,0xb8,0xbb,0xbb,0xbb,0xdc,0xf7,0xf7,0xf7,0xfa,0x82,0xff,0xff,0xff,0xff,0x03,0xc7,0xc7,0xc7, + 0xe1,0x33,0x33,0x33,0xb8,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc, + 0xeb,0x81,0xff,0xff,0xff,0xff,0x87,0x00,0x00,0x00,0xb3,0x00,0xbb,0xbb,0xbb,0xdc,0x82,0xff,0xff,0xff,0xff,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x02, + 0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb, + 0x81,0xff,0xff,0xff,0xff,0x82,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0xff,0xff,0xff,0xff,0x01,0xdc,0xdc,0xdc,0xeb,0xbb,0xbb,0xbb,0xdc,0x81,0xff,0xff, + 0xff,0xff,0x82,0x00,0x00,0x00,0xb3,0x01,0x52,0x52,0x52,0xbd,0xd2,0xd2,0xd2,0xe6,0x82,0xff,0xff,0xff,0xff,0x01,0xf7,0xf7,0xf7,0xfa,0xaf,0xaf,0xaf,0xd6,0x81,0x00, + 0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x87,0x00,0x00,0x00,0xb3,0x00,0xd7,0xd7,0xd7,0xf0,0x86,0xff,0xff,0xff, + 0xff,0x00,0x89,0x89,0x89,0xd6,0x81,0x00,0x00,0x00,0xb3,0x01,0x9e,0x9e,0x9e,0xdc,0xec,0xec,0xec,0xf8,0x83,0xff,0xff,0xff,0xff,0x02,0xfd,0xfd,0xfd,0xff,0xca,0xca, + 0xca,0xeb,0x3c,0x3c,0x3c,0xc1,0x83,0x00,0x00,0x00,0xb3,0x02,0xaf,0xaf,0xaf,0xd6,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0x86,0x00,0x00,0x00,0xb3,0x01,0x6a,0x6a, + 0x6a,0xc2,0xdc,0xdc,0xdc,0xeb,0x83,0xff,0xff,0xff,0xff,0x01,0xef,0xef,0xef,0xf5,0x7e,0x7e,0x7e,0xc7,0x83,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x83,0xff, + 0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x01,0x6a,0x6a,0x6a,0xc2,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x01,0xf7,0xf7,0xf7,0xfa,0xaf,0xaf,0xaf,0xd6,0x82, + 0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x01,0xc7,0xc7,0xc7,0xe1,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x01,0xef,0xef,0xef, + 0xf5,0x6a,0x6a,0x6a,0xc2,0x87,0x00,0x00,0x00,0xb3,0x01,0xa0,0xa0,0xa0,0xd1,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x01,0xc7,0xc7,0xc7,0xe1,0xdc,0xdc,0xdc, + 0xeb,0x81,0xff,0xff,0xff,0xff,0x02,0x00,0x00,0x00,0xb3,0x6a,0x6a,0x6a,0xc2,0xdc,0xdc,0xdc,0xeb,0x83,0xff,0xff,0xff,0xff,0x01,0xdc,0xdc,0xdc,0xeb,0x33,0x33,0x33, + 0xb8,0x81,0x00,0x00,0x00,0xb3,0x02,0x33,0x33,0x33,0xb8,0xbb,0xbb,0xbb,0xdc,0xf7,0xf7,0xf7,0xfa,0x82,0xff,0xff,0xff,0xff,0x01,0xc7,0xc7,0xc7,0xe1,0x33,0x33,0x33, + 0xb8,0x86,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00, + 0x7e,0x7e,0x7e,0xc7,0x89,0x00,0x00,0x00,0xb3,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x84,0x00,0x00,0x00,0xb3,0x01,0xaf,0xaf, + 0xaf,0xd6,0xf7,0xf7,0xf7,0xfa,0x82,0xff,0xff,0xff,0xff,0x01,0xdc,0xdc,0xdc,0xeb,0x6a,0x6a,0x6a,0xc2,0x82,0x00,0x00,0x00,0xb3,0x01,0xa0,0xa0,0xa0,0xd1,0xf7,0xf7, + 0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x01,0xc7,0xc7,0xc7,0xe1,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x87,0x00,0x00,0x00,0xb3,0x01,0x52,0x52,0x52,0xbd,0xd2, + 0xd2,0xd2,0xe6,0x82,0xff,0xff,0xff,0xff,0x07,0xf7,0xf7,0xf7,0xfa,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0x52,0x52,0x52,0xbd,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff, + 0xff,0xf7,0xf7,0xf7,0xfa,0x52,0x52,0x52,0xbd,0x81,0x00,0x00,0x00,0xb3,0x00,0xbb,0xbb,0xbb,0xdc,0x81,0xff,0xff,0xff,0xff,0x01,0xc7,0xc7,0xc7,0xe1,0x00,0x00,0x00, + 0xb3,0x81,0xff,0xff,0xff,0xff,0x01,0xe6,0xe6,0xe6,0xf0,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x00,0xbb,0xbb,0xbb,0xdc,0x83,0x00,0x00,0x00,0xb3,0x01,0x7e, + 0x7e,0x7e,0xc7,0xe6,0xe6,0xe6,0xf0,0x82,0xff,0xff,0xff,0xff,0x01,0xef,0xef,0xef,0xf5,0x90,0x90,0x90,0xcc,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81, + 0xff,0xff,0xff,0xff,0x83,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x01,0x52,0x52, + 0x52,0xbd,0xd2,0xd2,0xd2,0xe6,0x82,0xff,0xff,0xff,0xff,0x01,0xf7,0xf7,0xf7,0xfa,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff, + 0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0x00,0x00,0x00,0xb3,0x01,0x7e,0x7e,0x7e, + 0xc7,0xe6,0xe6,0xe6,0xf0,0x82,0xff,0xff,0xff,0xff,0x05,0xef,0xef,0xef,0xf5,0x90,0x90,0x90,0xcc,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0xbb,0xbb,0xbb,0xdc,0xf7, + 0xf7,0xf7,0xfa,0x82,0xff,0xff,0xff,0xff,0x01,0xc7,0xc7,0xc7,0xe1,0x33,0x33,0x33,0xb8,0x86,0x00,0x00,0x00,0xb3,0x01,0xa0,0xa0,0xa0,0xd1,0xf7,0xf7,0xf7,0xfa,0x81, + 0xff,0xff,0xff,0xff,0x01,0xf7,0xf7,0xf7,0xfa,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x01,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff, + 0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0x00,0x00,0x00,0xb3,0x00,0x52, + 0x52,0x52,0xbd,0x81,0xff,0xff,0xff,0xff,0x00,0xf7,0xf7,0xf7,0xfa,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xb5,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xa7,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x84,0xff,0xff,0xff,0xff,0x02,0xf7,0xf7,0xf7,0xfa,0x6a,0x6a,0x6a,0xc2,0xaf,0xaf, + 0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0x7e, + 0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00, + 0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x87,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7, + 0x83,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00, + 0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x86, + 0x00,0x00,0x00,0xb3,0x00,0x6a,0x6a,0x6a,0xc2,0x86,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff, + 0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x87,0xff, + 0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x01,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x01,0xdc,0xdc,0xdc,0xeb,0xef,0xef,0xef,0xf5,0x81, + 0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x87,0x00,0x00,0x00,0xb3, + 0x00,0xd7,0xd7,0xd7,0xf0,0x86,0xff,0xff,0xff,0xff,0x00,0x89,0x89,0x89,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xe1,0xe1,0xe1,0xf3,0x86,0xff,0xff,0xff,0xff,0x01,0xf6, + 0xf6,0xf6,0xfc,0x41,0x41,0x41,0xc2,0x82,0x00,0x00,0x00,0xb3,0x82,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x84,0x00,0x00,0x00,0xb3,0x01,0x33,0x33,0x33,0xb8, + 0xe6,0xe6,0xe6,0xf0,0x86,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x00,0x52,0x52,0x52,0xbd,0x84,0xff,0xff,0xff,0xff,0x02,0x00,0x00, + 0x00,0xb3,0x52,0x52,0x52,0xbd,0xf7,0xf7,0xf7,0xfa,0x85,0xff,0xff,0xff,0xff,0x00,0xbb,0xbb,0xbb,0xdc,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x86,0xff, + 0xff,0xff,0xff,0x01,0xef,0xef,0xef,0xf5,0x33,0x33,0x33,0xb8,0x86,0x00,0x00,0x00,0xb3,0x00,0xf7,0xf7,0xf7,0xfa,0x86,0xff,0xff,0xff,0xff,0x03,0x00,0x00,0x00,0xb3, + 0x33,0x33,0x33,0xb8,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0x81,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3, + 0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x86,0x00,0x00,0x00,0xb3,0x81,0xff, + 0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x88,0x00,0x00,0x00, + 0xb3,0x01,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x00,0xef,0xef,0xef,0xf5,0x83,0x00,0x00,0x00,0xb3,0x00,0xbb,0xbb,0xbb,0xdc,0x85,0xff, + 0xff,0xff,0xff,0x01,0xf7,0xf7,0xf7,0xfa,0x52,0x52,0x52,0xbd,0x81,0x00,0x00,0x00,0xb3,0x00,0xf7,0xf7,0xf7,0xfa,0x86,0xff,0xff,0xff,0xff,0x86,0x00,0x00,0x00,0xb3, + 0x01,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x01,0xdc,0xdc,0xdc,0xeb,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e, + 0xc7,0x00,0x00,0x00,0xb3,0x90,0x90,0x90,0xcc,0x81,0xff,0xff,0xff,0xff,0x02,0xe6,0xe6,0xe6,0xf0,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff, + 0x00,0xe6,0xe6,0xe6,0xf0,0x81,0x00,0x00,0x00,0xb3,0x87,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff, + 0xff,0xff,0xff,0x07,0xf7,0xf7,0xf7,0xfa,0xdc,0xdc,0xdc,0xeb,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0x33,0x33,0x33,0xb8,0x00,0x00,0x00,0xb3, + 0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x83,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x03,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00, + 0xb3,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x01,0xdc,0xdc,0xdc,0xeb,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e, + 0xc7,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc, + 0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x85,0xff,0xff,0xff,0xff,0x02,0xa0,0xa0,0xa0,0xd1,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff, + 0xff,0xff,0xff,0x81,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x85,0x00,0x00,0x00,0xb3,0x00,0x52,0x52,0x52,0xbd,0x81,0xff,0xff,0xff, + 0xff,0x02,0xef,0xef,0xef,0xf5,0xaf,0xaf,0xaf,0xd6,0xc7,0xc7,0xc7,0xe1,0x82,0xff,0xff,0xff,0xff,0x01,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff, + 0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0x00,0x00,0x00,0xb3,0x00, + 0xaf,0xaf,0xaf,0xd6,0x82,0xff,0xff,0xff,0xff,0x00,0xa0,0xa0,0xa0,0xd1,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xb4,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xa6,0x00,0x00,0x00,0xb3,0x00,0x52,0x52,0x52,0xbd,0x81,0xff,0xff,0xff,0xff,0x06,0xf7,0xf7,0xf7,0xfa,0xa0,0xa0,0xa0,0xd1,0x7e, + 0x7e,0x7e,0xc7,0xd2,0xd2,0xd2,0xe6,0x6a,0x6a,0x6a,0xc2,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00, + 0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00, + 0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x03,0xaf,0xaf, + 0xaf,0xd6,0x7e,0x7e,0x7e,0xc7,0xa0,0xa0,0xa0,0xd1,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff, + 0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3, + 0x01,0xa0,0xa0,0xa0,0xd1,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00, + 0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x86,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0xe6,0xe6,0xe6,0xf0, + 0x7e,0x7e,0x7e,0xc7,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00, + 0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff, + 0xff,0xff,0x03,0xaf,0xaf,0xaf,0xd6,0x7e,0x7e,0x7e,0xc7,0xa0,0xa0,0xa0,0xd1,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0xc7,0xc7, + 0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x00,0x6a,0x6a,0x6a,0xc2,0x81,0x00,0x00,0x00,0xb3,0x01,0xbb,0xbb,0xbb,0xdc,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x00, + 0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x87,0x00,0x00,0x00,0xb3,0x02,0x28,0x28,0x28,0xbc,0x34,0x34,0x34,0xbf,0x63,0x63,0x63,0xcb, + 0x81,0xff,0xff,0xff,0xff,0x00,0xef,0xef,0xef,0xf9,0x81,0x34,0x34,0x34,0xbf,0x00,0x17,0x17,0x17,0xb8,0x81,0x00,0x00,0x00,0xb3,0x06,0xe0,0xe0,0xe0,0xf3,0xce,0xce, + 0xce,0xec,0x7d,0x7d,0x7d,0xd2,0x46,0x46,0x46,0xc3,0x44,0x44,0x44,0xc3,0x7e,0x7e,0x7e,0xd2,0xef,0xef,0xef,0xf9,0x81,0xff,0xff,0xff,0xff,0x00,0xc3,0xc3,0xc3,0xe8, + 0x82,0x00,0x00,0x00,0xb3,0x03,0xdc,0xdc,0xdc,0xeb,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0x33,0x33,0x33,0xb8,0x85,0x00,0x00,0x00,0xb3,0x05,0x52,0x52,0x52,0xbd, + 0xf7,0xf7,0xf7,0xfa,0xe6,0xe6,0xe6,0xf0,0xa0,0xa0,0xa0,0xd1,0x7e,0x7e,0x7e,0xc7,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0xe6,0xe6,0xe6,0xf0,0x81,0x00, + 0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x04,0xd2,0xd2,0xd2,0xe6,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0x00,0x00,0x00,0xb3,0xc7,0xc7, + 0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x03,0xd2,0xd2,0xd2,0xe6,0x7e,0x7e,0x7e,0xc7,0xa0,0xa0,0xa0,0xd1,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x02,0x52,0x52, + 0x52,0xbd,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x03,0xd2,0xd2,0xd2,0xe6,0x7e,0x7e,0x7e,0xc7,0x90,0x90,0x90,0xcc,0xe6,0xe6,0xe6,0xf0, + 0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x85,0x00,0x00,0x00,0xb3,0x00,0x6a,0x6a,0x6a,0xc2,0x81,0xff,0xff,0xff,0xff,0x02,0xf7,0xf7,0xf7,0xfa,0x90,0x90, + 0x90,0xcc,0xaf,0xaf,0xaf,0xd6,0x82,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x01,0x6a,0x6a,0x6a,0xc2,0xa0,0xa0,0xa0,0xd1,0x81,0x00,0x00,0x00,0xb3,0x00,0xe6, + 0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0xb3,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3, + 0x01,0xa0,0xa0,0xa0,0xd1,0xaf,0xaf,0xaf,0xd6,0x87,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf, + 0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x88,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x83,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7, + 0x81,0x00,0x00,0x00,0xb3,0x00,0x52,0x52,0x52,0xbd,0x81,0xff,0xff,0xff,0xff,0x03,0xf7,0xf7,0xf7,0xfa,0xa0,0xa0,0xa0,0xd1,0x7e,0x7e,0x7e,0xc7,0xd2,0xd2,0xd2,0xe6, + 0x81,0xff,0xff,0xff,0xff,0x02,0xc7,0xc7,0xc7,0xe1,0x00,0x00,0x00,0xb3,0x6a,0x6a,0x6a,0xc2,0x81,0xff,0xff,0xff,0xff,0x02,0xf7,0xf7,0xf7,0xfa,0x90,0x90,0x90,0xcc, + 0xaf,0xaf,0xaf,0xd6,0x82,0xff,0xff,0xff,0xff,0x86,0x00,0x00,0x00,0xb3,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x00,0x6a,0x6a,0x6a,0xc2,0x81,0x00,0x00, + 0x00,0xb3,0x01,0xbb,0xbb,0xbb,0xdc,0x7e,0x7e,0x7e,0xc7,0x82,0x00,0x00,0x00,0xb3,0x00,0xbb,0xbb,0xbb,0xdc,0x81,0xff,0xff,0xff,0xff,0x04,0xbb,0xbb,0xbb,0xdc,0xef, + 0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0x52,0x52,0x52,0xbd,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x03,0xf7,0xf7,0xf7,0xfa,0xa0,0xa0, + 0xa0,0xd1,0x7e,0x7e,0x7e,0xc7,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0xf7,0xf7,0xf7,0xfa,0x81,0x00,0x00,0x00,0xb3,0x07,0xef,0xef,0xef,0xf5,0xff,0xff, + 0xff,0xff,0xef,0xef,0xef,0xf5,0x33,0x33,0x33,0xb8,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0xc7,0xc7,0xc7,0xe1,0x52,0x52,0x52,0xbd,0x81,0x00,0x00,0x00,0xb3,0x00, + 0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x83,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00, + 0xb3,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x00,0x6a,0x6a,0x6a,0xc2,0x81,0x00,0x00,0x00,0xb3,0x01,0xbb,0xbb,0xbb,0xdc,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00, + 0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb, + 0x81,0x00,0x00,0x00,0xb3,0x00,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x05,0xaf,0xaf,0xaf,0xd6,0x7e,0x7e,0x7e,0xc7,0xbb,0xbb,0xbb,0xdc,0xa0,0xa0,0xa0,0xd1, + 0x00,0x00,0x00,0xb3,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x01,0xa0,0xa0,0xa0,0xd1,0xaf,0xaf,0xaf,0xd6, + 0x86,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff, + 0xff,0xff,0xff,0x01,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6, + 0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x01,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0x82,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc, + 0xdc,0xeb,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xb4,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xa6,0x00,0x00,0x00,0xb3, + 0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0xa0,0xa0,0xa0,0xd1,0x84,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e, + 0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02, + 0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x81,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xc7,0xc7,0xc7,0xe1, + 0x82,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e, + 0x7e,0x7e,0xc7,0x82,0x00,0x00,0x00,0xb3,0x00,0xd2,0xd2,0xd2,0xe6,0x81,0xff,0xff,0xff,0xff,0x85,0xaf,0xaf,0xaf,0xd6,0x01,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7, + 0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x86,0x00,0x00,0x00,0xb3,0x00,0xaf, + 0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0x90,0x90,0x90,0xcc,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00, + 0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff, + 0x01,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xc7,0xc7,0xc7,0xe1,0x82,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff, + 0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x02,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0x84,0xaf,0xaf,0xaf,0xd6,0x02,0xa0,0xa0,0xa0,0xd1,0x00,0x00, + 0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x89,0x00,0x00,0x00,0xb3,0x00,0x3e,0x3e,0x3e,0xc1,0x81,0xff,0xff,0xff,0xff,0x00, + 0xed,0xed,0xed,0xf8,0x84,0x00,0x00,0x00,0xb3,0x00,0x2b,0x2b,0x2b,0xbd,0x84,0x00,0x00,0x00,0xb3,0x00,0x7c,0x7c,0x7c,0xd2,0x81,0xff,0xff,0xff,0xff,0x00,0xe9,0xe9, + 0xe9,0xf7,0x83,0x00,0x00,0x00,0xb3,0x01,0x7e,0x7e,0x7e,0xc7,0x33,0x33,0x33,0xb8,0x87,0x00,0x00,0x00,0xb3,0x01,0x6a,0x6a,0x6a,0xc2,0x33,0x33,0x33,0xb8,0x82,0x00, + 0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf, + 0xd6,0x82,0x00,0x00,0x00,0xb3,0x02,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0x82,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff, + 0xff,0xff,0x04,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0x82,0x00,0x00,0x00,0xb3,0x00,0x52,0x52,0x52, + 0xbd,0x81,0xff,0xff,0xff,0xff,0x00,0xd2,0xd2,0xd2,0xe6,0x85,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xbb,0xbb,0xbb,0xdc,0x81, + 0x00,0x00,0x00,0xb3,0x00,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x82,0x00,0x00,0x00,0xb3,0x02,0xa0,0xa0,0xa0,0xd1,0xc7,0xc7,0xc7,0xe1,0xef,0xef,0xef,0xf5, + 0x81,0xff,0xff,0xff,0xff,0x02,0xef,0xef,0xef,0xf5,0x00,0x00,0x00,0xb3,0xd2,0xd2,0xd2,0xe6,0x81,0xff,0xff,0xff,0xff,0x85,0xaf,0xaf,0xaf,0xd6,0x86,0x00,0x00,0x00, + 0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x88, + 0x00,0x00,0x00,0xb3,0x01,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0x81,0xe6,0xe6,0xe6,0xf0,0x01,0xff,0xff,0xff,0xff,0xc7,0xc7,0xc7,0xe1,0x81,0x00,0x00,0x00,0xb3, + 0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0xa0,0xa0,0xa0,0xd1,0x82,0x00,0x00,0x00,0xb3,0x04,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7, + 0xfa,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xbb,0xbb,0xbb,0xdc,0x81,0x00,0x00,0x00,0xb3,0x00,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff, + 0xff,0xff,0x86,0x00,0x00,0x00,0xb3,0x02,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0x84,0xaf,0xaf,0xaf,0xd6,0x00,0xa0,0xa0,0xa0,0xd1,0x82,0x00, + 0x00,0x00,0xb3,0x00,0xe6,0xe6,0xe6,0xf0,0x83,0xff,0xff,0xff,0xff,0x00,0xa0,0xa0,0xa0,0xd1,0x82,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xa0,0xa0,0xa0, + 0xd1,0x82,0x00,0x00,0x00,0xb3,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x81,0x6a,0x6a,0x6a,0xc2,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x84, + 0xaf,0xaf,0xaf,0xd6,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x83,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7, + 0x81,0xff,0xff,0xff,0xff,0x04,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0x84,0xaf,0xaf,0xaf,0xd6,0x02, + 0xa0,0xa0,0xa0,0xd1,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff, + 0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0x6a,0x6a,0x6a,0xc2,0x81,0xff,0xff,0xff,0xff,0x00,0xc7,0xc7,0xc7,0xe1,0x84,0x00,0x00,0x00,0xb3,0x00,0xd2,0xd2,0xd2, + 0xe6,0x81,0xff,0xff,0xff,0xff,0x85,0xaf,0xaf,0xaf,0xd6,0x85,0x00,0x00,0x00,0xb3,0x06,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xe6,0xe6,0xe6, + 0xf0,0xa0,0xa0,0xa0,0xd1,0x7e,0x7e,0x7e,0xc7,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x01,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff, + 0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x00,0xa0, + 0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x00,0x52,0x52,0x52,0xbd,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xb3,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xa6,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00, + 0x7e,0x7e,0x7e,0xc7,0x84,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff, + 0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf, + 0xd6,0x81,0xff,0xff,0xff,0xff,0x81,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81, + 0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc, + 0xdc,0xeb,0x87,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00, + 0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x86,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00, + 0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00, + 0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6, + 0x82,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x87,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00, + 0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x89,0x00,0x00,0x00,0xb3,0x00,0x3e,0x3e,0x3e,0xc1,0x81,0xff,0xff,0xff,0xff,0x00, + 0xed,0xed,0xed,0xf8,0x8a,0x00,0x00,0x00,0xb3,0x00,0x92,0x92,0x92,0xd8,0x81,0xff,0xff,0xff,0xff,0x00,0xdb,0xdb,0xdb,0xf1,0x91,0x00,0x00,0x00,0xb3,0x00,0x90,0x90, + 0x90,0xcc,0x82,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3, + 0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x04,0xaf,0xaf,0xaf,0xd6,0x00,0x00, + 0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0x83,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x85,0x00,0x00, + 0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff, + 0x81,0x00,0x00,0x00,0xb3,0x00,0xbb,0xbb,0xbb,0xdc,0x83,0xff,0xff,0xff,0xff,0x03,0xf7,0xf7,0xf7,0xfa,0xa0,0xa0,0xa0,0xd1,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb, + 0x87,0xff,0xff,0xff,0xff,0x86,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff, + 0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x87,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x01,0xa0,0xa0,0xa0,0xd1,0xaf,0xaf,0xaf,0xd6, + 0x81,0xff,0xff,0xff,0xff,0x02,0x33,0x33,0x33,0xb8,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0x00,0x00,0x00, + 0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00, + 0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x86,0x00,0x00,0x00,0xb3,0x87,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0x00,0x00,0x00, + 0xb3,0x00,0x52,0x52,0x52,0xbd,0x82,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x83,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x82, + 0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x81,0x7e,0x7e,0x7e,0xc7,0x87,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00, + 0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x83,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x01,0xaf,0xaf,0xaf,0xd6,0x00,0x00, + 0x00,0xb3,0x87,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00, + 0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x84, + 0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x87,0xff,0xff,0xff,0xff,0x86,0x00,0x00,0x00,0xb3,0x01,0x90,0x90,0x90,0xcc,0xf7,0xf7,0xf7,0xfa,0x85,0xff,0xff,0xff, + 0xff,0x01,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff, + 0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x06,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0x00,0x00,0x00,0xb3,0xf7,0xf7, + 0xf7,0xfa,0xff,0xff,0xff,0xff,0xbb,0xbb,0xbb,0xdc,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xb3,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xa6,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0x33,0x33,0x33, + 0xb8,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0xa0,0xa0,0xa0,0xd1,0x00,0x00,0x00,0xb3,0x52,0x52,0x52,0xbd,0x81,0xff,0xff, + 0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf, + 0xd6,0x81,0xff,0xff,0xff,0xff,0x01,0x7e,0x7e,0x7e,0xc7,0x52,0x52,0x52,0xbd,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0x00,0x00,0x00,0xb3,0x00,0xaf, + 0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0xbb,0xbb,0xbb,0xdc,0x82,0x00,0x00,0x00, + 0xb3,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x00,0x90,0x90,0x90,0xcc,0x81,0x7e,0x7e,0x7e,0xc7,0x04,0xe6,0xe6,0xe6,0xf0,0xff,0xff,0xff,0xff,0xf7,0xf7, + 0xf7,0xfa,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0x00,0x00,0x00,0xb3,0x00,0xef,0xef,0xef,0xf5,0x81,0xff, + 0xff,0xff,0xff,0x86,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff, + 0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0x00,0x00,0x00,0xb3,0x00,0xef,0xef, + 0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0xb3,0x52,0x52,0x52,0xbd,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0x00,0x00,0x00,0xb3,0x00, + 0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x02,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0x82,0x7e,0x7e,0x7e,0xc7, + 0x81,0xff,0xff,0xff,0xff,0x02,0xd2,0xd2,0xd2,0xe6,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xe6,0xe6,0xe6,0xf0,0x89,0x00,0x00,0x00, + 0xb3,0x00,0x3e,0x3e,0x3e,0xc1,0x81,0xff,0xff,0xff,0xff,0x00,0xed,0xed,0xed,0xf8,0x87,0x00,0x00,0x00,0xb3,0x02,0xb0,0xb0,0xb0,0xe1,0xba,0xba,0xba,0xe5,0xd2,0xd2, + 0xd2,0xee,0x81,0xff,0xff,0xff,0xff,0x01,0xf8,0xf8,0xf8,0xfd,0x58,0x58,0x58,0xc8,0x8e,0x00,0x00,0x00,0xb3,0x02,0x6a,0x6a,0x6a,0xc2,0xbb,0xbb,0xbb,0xdc,0xef,0xef, + 0xef,0xf5,0x82,0xff,0xff,0xff,0xff,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6, + 0x82,0x00,0x00,0x00,0xb3,0x03,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0x33,0x33,0x33,0xb8,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6, + 0x81,0xff,0xff,0xff,0xff,0x05,0xa0,0xa0,0xa0,0xd1,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0x33,0x33,0x33,0xb8,0x81,0x00, + 0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xd2,0xd2,0xd2,0xe6,0x85,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff, + 0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x82,0xff,0xff,0xff,0xff,0x02, + 0xc7,0xc7,0xc7,0xe1,0xa0,0xa0,0xa0,0xd1,0x33,0x33,0x33,0xb8,0x81,0x00,0x00,0x00,0xb3,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x00,0x90,0x90,0x90,0xcc, + 0x81,0x7e,0x7e,0x7e,0xc7,0x02,0xe6,0xe6,0xe6,0xf0,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0x86,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc, + 0xeb,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x87,0x00,0x00,0x00,0xb3,0x04,0xdc,0xdc,0xdc,0xeb,0xff, + 0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0x33,0x33,0x33,0xb8,0x52,0x52,0x52,0xbd,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xa0,0xa0,0xa0, + 0xd1,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x05,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xef,0xef,0xef, + 0xf5,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff, + 0xff,0xff,0x86,0x00,0x00,0x00,0xb3,0x02,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0x82,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xd2, + 0xd2,0xd2,0xe6,0x82,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0xff,0xff,0xff,0xff,0x01,0xf7,0xf7,0xf7,0xfa,0x52,0x52,0x52,0xbd,0x82,0x00,0x00,0x00,0xb3, + 0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x01,0x6a,0x6a,0x6a,0xc2,0x52,0x52, + 0x52,0xbd,0x81,0xff,0xff,0xff,0xff,0x00,0xd2,0xd2,0xd2,0xe6,0x81,0x7e,0x7e,0x7e,0xc7,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6, + 0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x00,0x90,0x90,0x90,0xcc,0x82,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff, + 0xff,0x04,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0x82,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff, + 0x02,0xd2,0xd2,0xd2,0xe6,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0xa0,0xa0,0xa0,0xd1,0x00,0x00,0x00,0xb3,0x52,0x52,0x52,0xbd,0x81, + 0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0x52,0x52,0x52,0xbd,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3, + 0x00,0x33,0x33,0x33,0xb8,0x81,0x00,0x00,0x00,0xb3,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x00,0x90,0x90,0x90,0xcc,0x81,0x7e,0x7e,0x7e,0xc7,0x02,0xe6, + 0xe6,0xe6,0xf0,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0x88,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xaf,0xaf,0xaf,0xd6,0x00,0xc7,0xc7,0xc7,0xe1,0x81, + 0xff,0xff,0xff,0xff,0x01,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xef,0xef,0xef,0xf5,0x81,0x00,0x00,0x00,0xb3,0x00,0xc7,0xc7,0xc7, + 0xe1,0x81,0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x04,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00, + 0xb3,0xc7,0xc7,0xc7,0xe1,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xb3,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xa6,0x00,0x00,0x00,0xb3,0x01,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x05,0xc7,0xc7,0xc7,0xe1,0xaf,0xaf, + 0xaf,0xd6,0xef,0xef,0xef,0xf5,0xa0,0xa0,0xa0,0xd1,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0xf7,0xf7,0xf7,0xfa,0xaf,0xaf,0xaf,0xd6, + 0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x02,0xc7,0xc7,0xc7,0xe1,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6, + 0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x02, + 0xdc,0xdc,0xdc,0xeb,0xaf,0xaf,0xaf,0xd6,0xc7,0xc7,0xc7,0xe1,0x82,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0xff,0xff,0xff,0xff, + 0x03,0xc7,0xc7,0xc7,0xe1,0xaf,0xaf,0xaf,0xd6,0xa0,0xa0,0xa0,0xd1,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xc7,0xc7,0xc7,0xe1,0x00,0x00,0x00,0xb3,0x7e, + 0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xc7,0xc7,0xc7,0xe1,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x01,0xbb,0xbb,0xbb,0xdc,0xd2, + 0xd2,0xd2,0xe6,0x81,0xff,0xff,0xff,0xff,0x00,0xef,0xef,0xef,0xf5,0x86,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e, + 0xc7,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x01,0xbb,0xbb, + 0xbb,0xdc,0xd2,0xd2,0xd2,0xe6,0x81,0xff,0xff,0xff,0xff,0x00,0xef,0xef,0xef,0xf5,0x81,0x00,0x00,0x00,0xb3,0x00,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x02, + 0xdc,0xdc,0xdc,0xeb,0xaf,0xaf,0xaf,0xd6,0xc7,0xc7,0xc7,0xe1,0x82,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff, + 0x02,0xa0,0xa0,0xa0,0xd1,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0xa0,0xa0,0xa0,0xd1,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x82, + 0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xaf,0xaf,0xaf,0xd6,0x86,0x00,0x00,0x00,0xb3,0x00,0x3e,0x3e,0x3e,0xc1,0x81,0xff,0xff,0xff,0xff,0x00,0xed,0xed, + 0xed,0xf8,0x87,0x00,0x00,0x00,0xb3,0x00,0xf5,0xf5,0xf5,0xfc,0x82,0xff,0xff,0xff,0xff,0x01,0xca,0xca,0xca,0xeb,0x2b,0x2b,0x2b,0xbd,0x8e,0x00,0x00,0x00,0xb3,0x00, + 0xc7,0xc7,0xc7,0xe1,0x84,0xff,0xff,0xff,0xff,0x04,0xdc,0xdc,0xdc,0xeb,0x33,0x33,0x33,0xb8,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0xc7,0xc7,0xc7,0xe1,0x81,0xff, + 0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xaf,0xaf,0xaf,0xd6,0x01,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0xef,0xef,0xef,0xf5, + 0xaf,0xaf,0xaf,0xd6,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x03,0xf7,0xf7,0xf7,0xfa,0x33,0x33,0x33,0xb8,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff, + 0xff,0xff,0xff,0x03,0xef,0xef,0xef,0xf5,0xaf,0xaf,0xaf,0xd6,0xbb,0xbb,0xbb,0xdc,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x00,0xa0,0xa0,0xa0,0xd1,0x85,0x00, + 0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff, + 0xff,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x03,0xe6,0xe6,0xe6,0xf0,0x33,0x33,0x33,0xb8,0x52,0x52,0x52,0xbd,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00, + 0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xc7,0xc7,0xc7,0xe1,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xc7,0xc7, + 0xc7,0xe1,0x86,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x03,0xdc,0xdc,0xdc,0xeb,0x52,0x52,0x52,0xbd,0xaf,0xaf,0xaf,0xd6,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff, + 0xff,0xff,0x02,0xc7,0xc7,0xc7,0xe1,0xaf,0xaf,0xaf,0xd6,0x52,0x52,0x52,0xbd,0x84,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xc7, + 0xc7,0xc7,0xe1,0x81,0x00,0x00,0x00,0xb3,0x05,0xe6,0xe6,0xe6,0xf0,0xff,0xff,0xff,0xff,0xe6,0xe6,0xe6,0xf0,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7, + 0xfa,0x81,0xff,0xff,0xff,0xff,0x02,0xc7,0xc7,0xc7,0xe1,0xaf,0xaf,0xaf,0xd6,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00, + 0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x86,0x00, + 0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0xa0,0xa0,0xa0,0xd1,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00, + 0xa0,0xa0,0xa0,0xd1,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x03,0xe6,0xe6,0xe6,0xf0,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff, + 0xe6,0xe6,0xe6,0xf0,0x82,0x00,0x00,0x00,0xb3,0x82,0xff,0xff,0xff,0xff,0x02,0xc7,0xc7,0xc7,0xe1,0xaf,0xaf,0xaf,0xd6,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff, + 0x00,0xef,0xef,0xef,0xf5,0x81,0x00,0x00,0x00,0xb3,0x05,0xdc,0xdc,0xdc,0xeb,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0x6a,0x6a,0x6a,0xc2,0x33,0x33,0x33,0xb8,0xd2, + 0xd2,0xd2,0xe6,0x81,0xff,0xff,0xff,0xff,0x02,0x52,0x52,0x52,0xbd,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x02,0xf7,0xf7,0xf7,0xfa,0xbb, + 0xbb,0xbb,0xdc,0xaf,0xaf,0xaf,0xd6,0x81,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff, + 0xff,0xff,0xff,0x02,0xa0,0xa0,0xa0,0xd1,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0xa0,0xa0,0xa0,0xd1,0x00,0x00,0x00,0xb3,0xaf,0xaf, + 0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0xf7,0xf7,0xf7,0xfa,0xaf,0xaf,0xaf,0xd6,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0x00, + 0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x05,0xdc,0xdc,0xdc,0xeb,0xaf,0xaf,0xaf,0xd6,0xdc,0xdc,0xdc,0xeb,0xc7,0xc7,0xc7,0xe1,0x00,0x00, + 0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xc7,0xc7,0xc7,0xe1,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xc7,0xc7, + 0xc7,0xe1,0x87,0x00,0x00,0x00,0xb3,0x01,0xa0,0xa0,0xa0,0xd1,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x00,0xbb,0xbb,0xbb,0xdc,0x81,0xff,0xff,0xff,0xff,0x81, + 0x00,0x00,0x00,0xb3,0x82,0xff,0xff,0xff,0xff,0x01,0xd2,0xd2,0xd2,0xe6,0xbb,0xbb,0xbb,0xdc,0x82,0xff,0xff,0xff,0xff,0x02,0x52,0x52,0x52,0xbd,0x00,0x00,0x00,0xb3, + 0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x02,0x52,0x52,0x52,0xbd,0x00,0x00,0x00,0xb3,0x90,0x90,0x90,0xcc,0x81,0xff,0xff,0xff,0xff,0x00,0x90,0x90,0x90,0xcc, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xb2,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xa7,0x00,0x00,0x00,0xb3,0x00,0x90, + 0x90,0x90,0xcc,0x85,0xff,0xff,0xff,0xff,0x01,0x90,0x90,0x90,0xcc,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0xf7,0xf7,0xf7,0xfa,0x83,0xff,0xff,0xff,0xff, + 0x02,0xa0,0xa0,0xa0,0xd1,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81, + 0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x87,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6, + 0x81,0xff,0xff,0xff,0xff,0x00,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0xc7,0xc7,0xc7,0xe1,0x84,0xff,0xff,0xff, + 0xff,0x03,0xf7,0xf7,0xf7,0xfa,0x52,0x52,0x52,0xbd,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xf7,0xf7,0xf7,0xfa,0x83,0xff,0xff,0xff, + 0xff,0x00,0xc7,0xc7,0xc7,0xe1,0x86,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x81, + 0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xf7,0xf7,0xf7,0xfa,0x83,0xff,0xff,0xff,0xff, + 0x00,0xc7,0xc7,0xc7,0xe1,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x87,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x01,0x33,0x33,0x33,0xb8,0xe6,0xe6, + 0xe6,0xf0,0x84,0xff,0xff,0xff,0xff,0x00,0xe6,0xe6,0xe6,0xf0,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xe6,0xe6,0xe6,0xf0, + 0x82,0xff,0xff,0xff,0xff,0x86,0x00,0x00,0x00,0xb3,0x00,0x3e,0x3e,0x3e,0xc1,0x81,0xff,0xff,0xff,0xff,0x00,0xed,0xed,0xed,0xf8,0x87,0x00,0x00,0x00,0xb3,0x02,0xa2, + 0xa2,0xa2,0xdd,0xac,0xac,0xac,0xe1,0xcf,0xcf,0xcf,0xed,0x81,0xff,0xff,0xff,0xff,0x01,0xc5,0xc5,0xc5,0xe9,0x04,0x04,0x04,0xb4,0x8c,0x00,0x00,0x00,0xb3,0x00,0xaf, + 0xaf,0xaf,0xd6,0x82,0xff,0xff,0xff,0xff,0x02,0xef,0xef,0xef,0xf5,0xbb,0xbb,0xbb,0xdc,0x6a,0x6a,0x6a,0xc2,0x82,0x00,0x00,0x00,0xb3,0x86,0xff,0xff,0xff,0xff,0x02, + 0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0xe6,0xe6,0xe6,0xf0,0x85,0xff,0xff,0xff,0xff,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6, + 0x81,0xff,0xff,0xff,0xff,0x00,0xf7,0xf7,0xf7,0xfa,0x83,0xff,0xff,0xff,0xff,0x00,0xe6,0xe6,0xe6,0xf0,0x86,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff, + 0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0xbb,0xbb,0xbb, + 0xdc,0x84,0xff,0xff,0xff,0xff,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0x00,0x00,0x00,0xb3,0x00,0xc7,0xc7,0xc7,0xe1,0x84,0xff,0xff,0xff,0xff,0x01,0xf7,0xf7,0xf7,0xfa,0x52, + 0x52,0x52,0xbd,0x86,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x01,0xdc,0xdc,0xdc,0xeb,0x7e,0x7e,0x7e,0xc7,0x85,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7, + 0x84,0x00,0x00,0x00,0xb3,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x00,0x6a,0x6a,0x6a,0xc2,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff, + 0xff,0xff,0xff,0x02,0x6a,0x6a,0x6a,0xc2,0x00,0x00,0x00,0xb3,0xa0,0xa0,0xa0,0xd1,0x85,0xff,0xff,0xff,0xff,0x03,0xe6,0xe6,0xe6,0xf0,0x33,0x33,0x33,0xb8,0x00,0x00, + 0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x86, + 0x00,0x00,0x00,0xb3,0x01,0x33,0x33,0x33,0xb8,0xe6,0xe6,0xe6,0xf0,0x84,0xff,0xff,0xff,0xff,0x00,0xe6,0xe6,0xe6,0xf0,0x81,0x00,0x00,0x00,0xb3,0x01,0x33,0x33,0x33, + 0xb8,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x01,0x6a,0x6a,0x6a,0xc2,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00, + 0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xf7,0xf7,0xf7,0xfa,0x84,0xff,0xff,0xff,0xff,0x00,0x90,0x90,0x90,0xcc,0x81,0x00,0x00,0x00,0xb3,0x01,0x6a,0x6a,0x6a,0xc2, + 0xf7,0xf7,0xf7,0xfa,0x84,0xff,0xff,0xff,0xff,0x00,0xbb,0xbb,0xbb,0xdc,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x00,0xe6,0xe6, + 0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x01,0xaf,0xaf,0xaf,0xd6,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x03,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0x33,0x33, + 0x33,0xb8,0xe6,0xe6,0xe6,0xf0,0x84,0xff,0xff,0xff,0xff,0x00,0xe6,0xe6,0xe6,0xf0,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00, + 0xf7,0xf7,0xf7,0xfa,0x83,0xff,0xff,0xff,0xff,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0x00,0x00,0x00,0xb3,0x01,0x52,0x52,0x52,0xbd,0xf7,0xf7,0xf7,0xfa,0x84,0xff,0xff,0xff, + 0xff,0x02,0xbb,0xbb,0xbb,0xdc,0x00,0x00,0x00,0xb3,0xc7,0xc7,0xc7,0xe1,0x84,0xff,0xff,0xff,0xff,0x01,0xf7,0xf7,0xf7,0xfa,0x52,0x52,0x52,0xbd,0x86,0x00,0x00,0x00, + 0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x81,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0x00,0x00,0x00,0xb3,0x81, + 0xff,0xff,0xff,0xff,0x00,0xf7,0xf7,0xf7,0xfa,0x83,0xff,0xff,0xff,0xff,0x02,0xef,0xef,0xef,0xf5,0x00,0x00,0x00,0xb3,0x52,0x52,0x52,0xbd,0x81,0xff,0xff,0xff,0xff, + 0x00,0xd2,0xd2,0xd2,0xe6,0x82,0x00,0x00,0x00,0xb3,0x02,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xd2,0xd2,0xd2,0xe6,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xb2,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xa8,0x00,0x00,0x00,0xb3,0x07,0x6a,0x6a,0x6a,0xc2,0xd2,0xd2,0xd2,0xe6,0xf7,0xf7, + 0xf7,0xfa,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0xaf,0xaf,0xaf,0xd6,0x33,0x33,0x33,0xb8,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x04,0xaf,0xaf,0xaf,0xd6, + 0xdc,0xdc,0xdc,0xeb,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0x6a,0x6a,0x6a,0xc2,0x81,0xdc,0xdc,0xdc,0xeb,0x02, + 0xa0,0xa0,0xa0,0xd1,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x05,0x90,0x90,0x90,0xcc, + 0xe6,0xe6,0xe6,0xf0,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0xaf,0xaf,0xaf,0xd6,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0xa0, + 0xa0,0xa0,0xd1,0x81,0xdc,0xdc,0xdc,0xeb,0x03,0x7e,0x7e,0x7e,0xc7,0xc7,0xc7,0xc7,0xe1,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x01,0xa0, + 0xa0,0xa0,0xd1,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x01,0xd2,0xd2,0xd2,0xe6,0x6a,0x6a,0x6a,0xc2,0x81,0x00,0x00,0x00,0xb3,0x00,0x6a,0x6a,0x6a,0xc2,0x81, + 0xdc,0xdc,0xdc,0xeb,0x01,0xa0,0xa0,0xa0,0xd1,0xbb,0xbb,0xbb,0xdc,0x81,0xff,0xff,0xff,0xff,0x01,0xc7,0xc7,0xc7,0xe1,0x33,0x33,0x33,0xb8,0x86,0x00,0x00,0x00,0xb3, + 0x00,0xa0,0xa0,0xa0,0xd1,0x81,0xdc,0xdc,0xdc,0xeb,0x00,0x6a,0x6a,0x6a,0xc2,0x81,0x00,0x00,0x00,0xb3,0x81,0xdc,0xdc,0xdc,0xeb,0x02,0xbb,0xbb,0xbb,0xdc,0x00,0x00, + 0x00,0xb3,0x6a,0x6a,0x6a,0xc2,0x81,0xdc,0xdc,0xdc,0xeb,0x01,0xa0,0xa0,0xa0,0xd1,0xbb,0xbb,0xbb,0xdc,0x81,0xff,0xff,0xff,0xff,0x01,0xc7,0xc7,0xc7,0xe1,0x33,0x33, + 0x33,0xb8,0x82,0x00,0x00,0x00,0xb3,0x05,0x90,0x90,0x90,0xcc,0xe6,0xe6,0xe6,0xf0,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0xaf,0xaf,0xaf,0xd6,0xdc,0xdc,0xdc,0xeb, + 0x81,0xff,0xff,0xff,0xff,0x82,0x00,0x00,0x00,0xb3,0x06,0x33,0x33,0x33,0xb8,0xaf,0xaf,0xaf,0xd6,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0xc7, + 0xc7,0xc7,0xe1,0x33,0x33,0x33,0xb8,0x81,0x00,0x00,0x00,0xb3,0x00,0x6a,0x6a,0x6a,0xc2,0x81,0xdc,0xdc,0xdc,0xeb,0x03,0xa0,0xa0,0xa0,0xd1,0xaf,0xaf,0xaf,0xd6,0xf7, + 0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0x84,0x00,0x00,0x00,0xb3,0x02,0x50,0x50,0x50,0xc6,0x63,0x63,0x63,0xcb,0x86,0x86,0x86,0xd5,0x81,0xff,0xff,0xff,0xff,0x00,0xed, + 0xed,0xed,0xf8,0x8a,0x00,0x00,0x00,0xb3,0x00,0xba,0xba,0xba,0xe5,0x81,0xff,0xff,0xff,0xff,0x00,0x72,0x72,0x72,0xcf,0x8c,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc, + 0xeb,0x81,0xff,0xff,0xff,0xff,0x00,0xbb,0xbb,0xbb,0xdc,0x85,0x00,0x00,0x00,0xb3,0x01,0xdc,0xdc,0xdc,0xeb,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x00,0xef, + 0xef,0xef,0xf5,0x81,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x02,0x33,0x33,0x33,0xb8,0xaf,0xaf,0xaf,0xd6,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x01, + 0xd2,0xd2,0xd2,0xe6,0x7e,0x7e,0x7e,0xc7,0x82,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0xdc,0xdc,0xdc,0xeb,0x05,0x6a,0x6a,0x6a,0xc2,0xdc,0xdc,0xdc,0xeb, + 0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0xbb,0xbb,0xbb,0xdc,0x33,0x33,0x33,0xb8,0x86,0x00,0x00,0x00,0xb3,0x00,0x6a,0x6a,0x6a,0xc2,0x81,0xdc,0xdc,0xdc,0xeb,0x00, + 0xa0,0xa0,0xa0,0xd1,0x81,0x00,0x00,0x00,0xb3,0x00,0xbb,0xbb,0xbb,0xdc,0x81,0xdc,0xdc,0xdc,0xeb,0x82,0x00,0x00,0x00,0xb3,0x01,0xaf,0xaf,0xaf,0xd6,0xef,0xef,0xef, + 0xf5,0x81,0xff,0xff,0xff,0xff,0x01,0xd2,0xd2,0xd2,0xe6,0x7e,0x7e,0x7e,0xc7,0x82,0x00,0x00,0x00,0xb3,0x01,0xa0,0xa0,0xa0,0xd1,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff, + 0xff,0xff,0x01,0xd2,0xd2,0xd2,0xe6,0x6a,0x6a,0x6a,0xc2,0x87,0x00,0x00,0x00,0xb3,0x81,0xdc,0xdc,0xdc,0xeb,0x03,0xbb,0xbb,0xbb,0xdc,0x6a,0x6a,0x6a,0xc2,0xdc,0xdc, + 0xdc,0xeb,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x02,0xe6,0xe6,0xe6,0xf0,0xdc,0xdc,0xdc,0xeb,0x6a,0x6a,0x6a,0xc2,0x83,0x00,0x00,0x00,0xb3,0x00,0x33,0x33, + 0x33,0xb8,0x81,0xdc,0xdc,0xdc,0xeb,0x00,0xc7,0xc7,0xc7,0xe1,0x82,0x00,0x00,0x00,0xb3,0x00,0x52,0x52,0x52,0xbd,0x81,0xdc,0xdc,0xdc,0xeb,0x00,0xaf,0xaf,0xaf,0xd6, + 0x81,0x00,0x00,0x00,0xb3,0x01,0x7e,0x7e,0x7e,0xc7,0xd2,0xd2,0xd2,0xe6,0x81,0xff,0xff,0xff,0xff,0x02,0xef,0xef,0xef,0xf5,0xaf,0xaf,0xaf,0xd6,0x33,0x33,0x33,0xb8, + 0x81,0x00,0x00,0x00,0xb3,0x00,0x6a,0x6a,0x6a,0xc2,0x81,0xdc,0xdc,0xdc,0xeb,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0x00,0x00,0x00,0xb3,0x00,0xbb,0xbb,0xbb,0xdc,0x81,0xdc, + 0xdc,0xdc,0xeb,0x87,0x00,0x00,0x00,0xb3,0x06,0x33,0x33,0x33,0xb8,0xaf,0xaf,0xaf,0xd6,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0xc7,0xc7,0xc7, + 0xe1,0x33,0x33,0x33,0xb8,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xdc,0xdc,0xdc,0xeb,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xc7, + 0xc7,0xc7,0xe1,0x81,0xdc,0xdc,0xdc,0xeb,0x01,0x52,0x52,0x52,0xbd,0x00,0x00,0x00,0xb3,0x81,0xdc,0xdc,0xdc,0xeb,0x05,0xa0,0xa0,0xa0,0xd1,0xaf,0xaf,0xaf,0xd6,0xf7, + 0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xe6,0xe6,0xe6,0xf0,0x7e,0x7e,0x7e,0xc7,0x83,0x00,0x00,0x00,0xb3,0x05,0x52,0x52,0x52,0xbd,0xc7,0xc7,0xc7,0xe1,0xf7,0xf7,0xf7, + 0xfa,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x00,0xbb,0xbb,0xbb,0xdc,0x81,0xdc,0xdc,0xdc,0xeb,0x04,0x6a,0x6a,0x6a, + 0xc2,0xdc,0xdc,0xdc,0xeb,0xff,0xff,0xff,0xff,0xaf,0xaf,0xaf,0xd6,0x6a,0x6a,0x6a,0xc2,0x81,0xdc,0xdc,0xdc,0xeb,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0x00,0x00,0x00,0xb3, + 0x06,0x33,0x33,0x33,0xb8,0xaf,0xaf,0xaf,0xd6,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0xc7,0xc7,0xc7,0xe1,0x33,0x33,0x33,0xb8,0x81,0x00,0x00, + 0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0xdc,0xdc,0xdc,0xeb,0x04,0x7e,0x7e,0x7e,0xc7,0xdc,0xdc,0xdc,0xeb,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0xaf,0xaf,0xaf, + 0xd6,0x83,0x00,0x00,0x00,0xb3,0x06,0x33,0x33,0x33,0xb8,0xc7,0xc7,0xc7,0xe1,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0xc7,0xc7,0xc7,0xe1,0x52, + 0x52,0x52,0xbd,0x81,0x00,0x00,0x00,0xb3,0x01,0xa0,0xa0,0xa0,0xd1,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x01,0xd2,0xd2,0xd2,0xe6,0x6a,0x6a,0x6a,0xc2,0x88, + 0x00,0x00,0x00,0xb3,0x01,0xa0,0xa0,0xa0,0xd1,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x02,0xef,0xef,0xef,0xf5,0xbb,0xbb,0xbb,0xdc,0x33,0x33,0x33,0xb8,0x81, + 0x00,0x00,0x00,0xb3,0x81,0xdc,0xdc,0xdc,0xeb,0x07,0xbb,0xbb,0xbb,0xdc,0xa0,0xa0,0xa0,0xd1,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0x6a,0x6a, + 0x6a,0xc2,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xdc,0xdc,0xdc,0xeb,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xdc, + 0xdc,0xdc,0xeb,0x00,0x33,0x33,0x33,0xb8,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xb1,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xaf,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x86,0x00,0x00,0x00,0xb3,0x01,0x52,0x52,0x52,0xbd,0x6a, + 0x6a,0x6a,0xc2,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x86,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc, + 0xeb,0x81,0xff,0xff,0xff,0xff,0xbd,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x97,0x00,0x00,0x00,0xb3,0x00,0xd7,0xd7,0xd7,0xf0,0x83, + 0xff,0xff,0xff,0xff,0x00,0xed,0xed,0xed,0xf8,0x84,0x00,0x00,0x00,0xb3,0x02,0x7b,0x7b,0x7b,0xd1,0xa2,0xa2,0xa2,0xdd,0x2c,0x2c,0x2c,0xbd,0x81,0x00,0x00,0x00,0xb3, + 0x01,0x07,0x07,0x07,0xb5,0xcd,0xcd,0xcd,0xec,0x81,0xff,0xff,0xff,0xff,0x00,0xa3,0xa3,0xa3,0xdd,0x8c,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff, + 0xff,0xff,0x00,0x90,0x90,0x90,0xcc,0x82,0x00,0x00,0x00,0xb3,0x00,0x33,0x33,0x33,0xb8,0x82,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff, + 0x00,0xaf,0xaf,0xaf,0xd6,0xc0,0x00,0x00,0x00,0xb3,0x01,0x33,0x33,0x33,0xb8,0x7e,0x7e,0x7e,0xc7,0x82,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff, + 0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0xdd,0x00,0x00,0x00,0xb3,0x01,0x52,0x52,0x52,0xbd,0x6a,0x6a,0x6a,0xc2,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xfe, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xaf,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e, + 0x7e,0xc7,0x85,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff, + 0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x86,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0xbd,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc, + 0xeb,0x81,0xff,0xff,0xff,0xff,0x97,0x00,0x00,0x00,0xb3,0x01,0xa7,0xa7,0xa7,0xdf,0xdc,0xdc,0xdc,0xf2,0x82,0xff,0xff,0xff,0xff,0x00,0xed,0xed,0xed,0xf8,0x84,0x00, + 0x00,0x00,0xb3,0x00,0x91,0x91,0x91,0xd8,0x81,0xff,0xff,0xff,0xff,0x02,0xe8,0xe8,0xe8,0xf6,0xdc,0xdc,0xdc,0xf1,0xf4,0xf4,0xf4,0xfb,0x82,0xff,0xff,0xff,0xff,0x00, + 0x79,0x79,0x79,0xd1,0x8c,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x05,0xf7,0xf7,0xf7,0xfa,0xbb,0xbb,0xbb,0xdc,0xaf,0xaf,0xaf,0xd6, + 0xef,0xef,0xef,0xf5,0xe6,0xe6,0xe6,0xf0,0x33,0x33,0x33,0xb8,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6, + 0xbf,0x00,0x00,0x00,0xb3,0x03,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6, + 0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0xdc,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xfd,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xaf,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf, + 0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x85,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00, + 0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x86,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff, + 0xbd,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x99,0x00,0x00,0x00,0xb3,0x00,0x53,0x53,0x53,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xed, + 0xed,0xed,0xf8,0x84,0x00,0x00,0x00,0xb3,0x00,0x87,0x87,0x87,0xd5,0x86,0xff,0xff,0xff,0xff,0x01,0xbb,0xbb,0xbb,0xe5,0x03,0x03,0x03,0xb4,0x8d,0x00,0x00,0x00,0xb3, + 0x00,0xdc,0xdc,0xdc,0xeb,0x85,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x00,0x33,0x33,0x33,0xb8,0x81,0x7e,0x7e,0x7e,0xc7,0x00,0x52, + 0x52,0x52,0xbd,0xbf,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff, + 0xff,0x02,0xe6,0xe6,0xe6,0xf0,0xaf,0xaf,0xaf,0xd6,0x90,0x90,0x90,0xcc,0xda,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc, + 0xdc,0xeb,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xfd,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xaf,0x00,0x00,0x00,0xb3, + 0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x85,0x00,0x00,0x00,0xb3,0x05,0x52,0x52,0x52,0xbd,0xef,0xef,0xef,0xf5,0xf7,0xf7,0xf7, + 0xfa,0x90,0x90,0x90,0xcc,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x86,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc, + 0xeb,0x81,0xff,0xff,0xff,0xff,0xbd,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x9a,0x00,0x00,0x00,0xb3,0x02,0x6e,0x6e,0x6e,0xce,0x79, + 0x79,0x79,0xd1,0x6e,0x6e,0x6e,0xce,0x85,0x00,0x00,0x00,0xb3,0x06,0x2f,0x2f,0x2f,0xbe,0x74,0x74,0x74,0xcf,0x9e,0x9e,0x9e,0xdc,0xae,0xae,0xae,0xe1,0xa9,0xa9,0xa9, + 0xdf,0x89,0x89,0x89,0xd6,0x3c,0x3c,0x3c,0xc1,0x90,0x00,0x00,0x00,0xb3,0x01,0xa0,0xa0,0xa0,0xd1,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x02,0xef,0xef,0xef, + 0xf5,0xc7,0xc7,0xc7,0xe1,0x52,0x52,0x52,0xbd,0xc6,0x00,0x00,0x00,0xb3,0x02,0xdc,0xdc,0xdc,0xeb,0xff,0xff,0xff,0xff,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3, + 0x01,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0xda,0x00,0x00,0x00,0xb3,0x03,0x52,0x52,0x52,0xbd,0xef,0xef,0xef, + 0xf5,0xf7,0xf7,0xf7,0xfa,0x90,0x90,0x90,0xcc,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xfd,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xaf,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xaf,0xaf,0xaf,0xd6,0x00,0x52,0x52,0x52,0xbd,0x8a,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7, + 0x81,0xaf,0xaf,0xaf,0xd6,0x00,0x52,0x52,0x52,0xbd,0x86,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0xaf,0xaf,0xaf,0xd6,0xbd,0x00,0x00,0x00,0xb3,0x00,0xa0, + 0xa0,0xa0,0xd1,0x81,0xaf,0xaf,0xaf,0xd6,0xff,0x00,0x00,0x00,0xb3,0x8f,0x00,0x00,0x00,0xb3,0x01,0x52,0x52,0x52,0xbd,0xbb,0xbb,0xbb,0xdc,0x81,0xdc,0xdc,0xdc,0xeb, + 0x00,0xa0,0xa0,0xa0,0xd1,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xdc,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xc9,0x00,0x00,0x00,0xb3,0x02, + 0x6a,0x6a,0x6a,0xc2,0x7e,0x7e,0x7e,0xc7,0x6a,0x6a,0x6a,0xc2,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xb2,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xc8,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0xff, + 0xff,0xff,0xff,0x01,0xef,0xef,0xef,0xf5,0x6a,0x6a,0x6a,0xc2,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xb0,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xc8,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x83,0xff, + 0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xb0,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xc8,0x00,0x00,0x00,0xb3,0x81,0x33,0x33,0x33,0xb8,0x01,0x00,0x00,0x00,0xb3,0xc7, + 0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x00,0x6a,0x6a,0x6a,0xc2,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xaf,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xae,0x00,0x00,0x00,0xb3,0x81,0x7e,0x7e,0x7e,0xc7,0x00,0x6a,0x6a,0x6a,0xc2,0x90,0x00,0x00,0x00,0xb3,0x00,0x33,0x33,0x33,0xb8,0x81, + 0x7e,0x7e,0x7e,0xc7,0x00,0x33,0x33,0x33,0xb8,0x85,0x00,0x00,0x00,0xb3,0x02,0x52,0x52,0x52,0xbd,0x7e,0x7e,0x7e,0xc7,0x52,0x52,0x52,0xbd,0x8c,0x00,0x00,0x00,0xb3, + 0x02,0x6a,0x6a,0x6a,0xc2,0x7e,0x7e,0x7e,0xc7,0x33,0x33,0x33,0xb8,0x8e,0x00,0x00,0x00,0xb3,0x02,0x52,0x52,0x52,0xbd,0x7e,0x7e,0x7e,0xc7,0x52,0x52,0x52,0xbd,0x87, + 0x00,0x00,0x00,0xb3,0x81,0x7e,0x7e,0x7e,0xc7,0x00,0x33,0x33,0x33,0xb8,0x8b,0x00,0x00,0x00,0xb3,0x02,0x52,0x52,0x52,0xbd,0x7e,0x7e,0x7e,0xc7,0x6a,0x6a,0x6a,0xc2, + 0x83,0x00,0x00,0x00,0xb3,0x02,0x52,0x52,0x52,0xbd,0x7e,0x7e,0x7e,0xc7,0x52,0x52,0x52,0xbd,0x92,0x00,0x00,0x00,0xb3,0x02,0x6a,0x6a,0x6a,0xc2,0x7e,0x7e,0x7e,0xc7, + 0x33,0x33,0x33,0xb8,0x8c,0x00,0x00,0x00,0xb3,0x81,0x7e,0x7e,0x7e,0xc7,0x87,0x00,0x00,0x00,0xb3,0x00,0x33,0x33,0x33,0xb8,0x81,0x7e,0x7e,0x7e,0xc7,0x00,0x33,0x33, + 0x33,0xb8,0x83,0x00,0x00,0x00,0xb3,0x00,0x33,0x33,0x33,0xb8,0x81,0x7e,0x7e,0x7e,0xc7,0x86,0x00,0x00,0x00,0xb3,0x02,0x52,0x52,0x52,0xbd,0x7e,0x7e,0x7e,0xc7,0x52, + 0x52,0x52,0xbd,0x94,0x00,0x00,0x00,0xb3,0x02,0x6a,0x6a,0x6a,0xc2,0x7e,0x7e,0x7e,0xc7,0x6a,0x6a,0x6a,0xc2,0x94,0x00,0x00,0x00,0xb3,0x81,0x7e,0x7e,0x7e,0xc7,0x00, + 0x33,0x33,0x33,0xb8,0x84,0x00,0x00,0x00,0xb3,0x02,0x52,0x52,0x52,0xbd,0x7e,0x7e,0x7e,0xc7,0x52,0x52,0x52,0xbd,0x88,0x00,0x00,0x00,0xb3,0x81,0x7e,0x7e,0x7e,0xc7, + 0x00,0x33,0x33,0x33,0xb8,0x92,0x00,0x00,0x00,0xb3,0x02,0x33,0x33,0x33,0xb8,0x7e,0x7e,0x7e,0xc7,0x6a,0x6a,0x6a,0xc2,0x86,0x00,0x00,0x00,0xb3,0x00,0x6a,0x6a,0x6a, + 0xc2,0x81,0x7e,0x7e,0x7e,0xc7,0x87,0x00,0x00,0x00,0xb3,0x81,0x7e,0x7e,0x7e,0xc7,0x00,0x33,0x33,0x33,0xb8,0xa5,0x00,0x00,0x00,0xb3,0x81,0x7e,0x7e,0x7e,0xc7,0x00, + 0x52,0x52,0x52,0xbd,0x86,0x00,0x00,0x00,0xb3,0x00,0x52,0x52,0x52,0xbd,0x81,0x7e,0x7e,0x7e,0xc7,0x90,0x00,0x00,0x00,0xb3,0x02,0x6a,0x6a,0x6a,0xc2,0x7e,0x7e,0x7e, + 0xc7,0x6a,0x6a,0x6a,0xc2,0x92,0x00,0x00,0x00,0xb3,0x02,0x52,0x52,0x52,0xbd,0x7e,0x7e,0x7e,0xc7,0x52,0x52,0x52,0xbd,0x86,0x00,0x00,0x00,0xb3,0x00,0x6a,0x6a,0x6a, + 0xc2,0x81,0x7e,0x7e,0x7e,0xc7,0x86,0x00,0x00,0x00,0xb3,0x00,0x33,0x33,0x33,0xb8,0x81,0x7e,0x7e,0x7e,0xc7,0x8d,0x00,0x00,0x00,0xb3,0x02,0x6a,0x6a,0x6a,0xc2,0x7e, + 0x7e,0x7e,0xc7,0x33,0x33,0x33,0xb8,0x85,0x00,0x00,0x00,0xb3,0x00,0x33,0x33,0x33,0xb8,0x81,0xff,0xff,0xff,0xff,0x00,0xc7,0xc7,0xc7,0xe1,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xaf,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xac,0x00,0x00,0x00,0xb3,0x01,0xaf,0xaf,0xaf,0xd6,0xf7,0xf7, + 0xf7,0xfa,0x82,0xff,0xff,0xff,0xff,0x01,0xf7,0xf7,0xf7,0xfa,0xa0,0xa0,0xa0,0xd1,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81, + 0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x01,0x33,0x33,0x33,0xb8,0xc7,0xc7,0xc7, + 0xe1,0x83,0xff,0xff,0xff,0xff,0x01,0xc7,0xc7,0xc7,0xe1,0x33,0x33,0x33,0xb8,0x82,0x00,0x00,0x00,0xb3,0x00,0xbb,0xbb,0xbb,0xdc,0x82,0xff,0xff,0xff,0xff,0x00,0xa0, + 0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81, + 0x00,0x00,0x00,0xb3,0x01,0x6a,0x6a,0x6a,0xc2,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x01,0xf7,0xf7,0xf7,0xfa,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff, + 0x00,0xaf,0xaf,0xaf,0xd6,0x86,0x00,0x00,0x00,0xb3,0x03,0xdc,0xdc,0xdc,0xeb,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0xbb,0xbb,0xbb,0xdc,0x82,0xff,0xff,0xff,0xff, + 0x01,0xd2,0xd2,0xd2,0xe6,0x33,0x33,0x33,0xb8,0x82,0x00,0x00,0x00,0xb3,0x02,0x33,0x33,0x33,0xb8,0xbb,0xbb,0xbb,0xdc,0xf7,0xf7,0xf7,0xfa,0x82,0xff,0xff,0xff,0xff, + 0x01,0xc7,0xc7,0xc7,0xe1,0x33,0x33,0x33,0xb8,0x87,0x00,0x00,0x00,0xb3,0x01,0x7e,0x7e,0x7e,0xc7,0xe6,0xe6,0xe6,0xf0,0x82,0xff,0xff,0xff,0xff,0x03,0xef,0xef,0xef, + 0xf5,0x90,0x90,0x90,0xcc,0x33,0x33,0x33,0xb8,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x05,0xdc,0xdc,0xdc,0xeb,0xe6,0xe6,0xe6,0xf0,0xff,0xff,0xff,0xff,0xdc, + 0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81, + 0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x01,0xbb,0xbb,0xbb,0xdc,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00, + 0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x83,0x00,0x00,0x00,0xb3,0x01,0xa0,0xa0,0xa0,0xd1,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x01,0xf7, + 0xf7,0xf7,0xfa,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x83,0xff,0xff,0xff,0xff, + 0x81,0x00,0x00,0x00,0xb3,0x01,0x52,0x52,0x52,0xbd,0xd2,0xd2,0xd2,0xe6,0x82,0xff,0xff,0xff,0xff,0x01,0xf7,0xf7,0xf7,0xfa,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00, + 0xb3,0x01,0x33,0x33,0x33,0xb8,0xd2,0xd2,0xd2,0xe6,0x82,0xff,0xff,0xff,0xff,0x03,0xbb,0xbb,0xbb,0xdc,0xdc,0xdc,0xdc,0xeb,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb, + 0x87,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x83,0x00,0x00,0x00,0xb3,0x01,0x90,0x90,0x90,0xcc,0xef,0xef,0xef,0xf5,0x82,0xff,0xff, + 0xff,0xff,0x01,0xef,0xef,0xef,0xf5,0x90,0x90,0x90,0xcc,0x82,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x89,0x00,0x00,0x00,0xb3,0x02, + 0x33,0x33,0x33,0xb8,0xbb,0xbb,0xbb,0xdc,0xf7,0xf7,0xf7,0xfa,0x82,0xff,0xff,0xff,0xff,0x04,0xc7,0xc7,0xc7,0xe1,0x33,0x33,0x33,0xb8,0x00,0x00,0x00,0xb3,0x33,0x33, + 0x33,0xb8,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x03,0xdc,0xdc,0xdc,0xeb,0xe6,0xe6,0xe6,0xf0,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00, + 0xb3,0x02,0x33,0x33,0x33,0xb8,0xbb,0xbb,0xbb,0xdc,0xf7,0xf7,0xf7,0xfa,0x82,0xff,0xff,0xff,0xff,0x02,0xc7,0xc7,0xc7,0xe1,0x33,0x33,0x33,0xb8,0xdc,0xdc,0xdc,0xeb, + 0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x86,0x00,0x00,0x00,0xb3,0x01,0xa0, + 0xa0,0xa0,0xd1,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x01,0xc7,0xc7,0xc7,0xe1,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x02,0x00,0x00,0x00,0xb3,0x90, + 0x90,0x90,0xcc,0xef,0xef,0xef,0xf5,0x83,0xff,0xff,0xff,0xff,0x00,0xbb,0xbb,0xbb,0xdc,0x82,0x00,0x00,0x00,0xb3,0x02,0x33,0x33,0x33,0xb8,0xbb,0xbb,0xbb,0xdc,0xf7, + 0xf7,0xf7,0xfa,0x82,0xff,0xff,0xff,0xff,0x03,0xc7,0xc7,0xc7,0xe1,0x33,0x33,0x33,0xb8,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf, + 0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x03,0x52,0x52,0x52,0xbd,0xef,0xef,0xef,0xf5,0xf7,0xf7,0xf7,0xfa,0x90,0x90,0x90,0xcc,0x86,0x00,0x00,0x00,0xb3,0x00,0xdc, + 0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x84,0x00,0x00,0x00,0xb3,0x00,0xbb,0xbb,0xbb,0xdc,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00, + 0xb3,0x01,0xaf,0xaf,0xaf,0xd6,0xf7,0xf7,0xf7,0xfa,0x82,0xff,0xff,0xff,0xff,0x01,0xdc,0xdc,0xdc,0xeb,0x6a,0x6a,0x6a,0xc2,0x83,0x00,0x00,0x00,0xb3,0x00,0xd2,0xd2, + 0xd2,0xe6,0x82,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x86,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x83,0x00,0x00,0x00,0xb3, + 0x01,0x90,0x90,0x90,0xcc,0xef,0xef,0xef,0xf5,0x82,0xff,0xff,0xff,0xff,0x01,0xef,0xef,0xef,0xf5,0x90,0x90,0x90,0xcc,0x82,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff, + 0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x89,0x00,0x00,0x00,0xb3,0x00,0xbb,0xbb,0xbb,0xdc,0x82,0xff,0xff,0xff,0xff,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x03, + 0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0x90,0x90,0x90,0xcc,0xef,0xef,0xef,0xf5,0x83,0xff,0xff,0xff,0xff,0x00,0xbb,0xbb,0xbb,0xdc,0x82,0x00,0x00,0x00,0xb3,0x01, + 0x52,0x52,0x52,0xbd,0xd2,0xd2,0xd2,0xe6,0x82,0xff,0xff,0xff,0xff,0x01,0xf7,0xf7,0xf7,0xfa,0xaf,0xaf,0xaf,0xd6,0x87,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff, + 0x01,0xbb,0xbb,0xbb,0xdc,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x84,0x00,0x00,0x00,0xb3,0x00,0x52,0x52,0x52,0xbd,0x81,0xff,0xff, + 0xff,0xff,0x00,0xf7,0xf7,0xf7,0xfa,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xaf,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xac,0x00,0x00,0x00,0xb3,0x04,0xaf,0xaf,0xaf,0xd6,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0xdc,0xdc,0xdc,0xeb,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x02, + 0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff, + 0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xe6,0xe6,0xe6,0xf0,0x85,0xff,0xff,0xff,0xff,0x00,0xe6,0xe6,0xe6,0xf0,0x81,0x00,0x00,0x00,0xb3,0x00,0x6a, + 0x6a,0x6a,0xc2,0x86,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x03,0xaf,0xaf,0xaf,0xd6,0x00, + 0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0x86,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x86,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x86, + 0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff, + 0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x86,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x85,0xff,0xff,0xff,0xff,0x01,0xa0,0xa0,0xa0,0xd1,0xc7,0xc7,0xc7,0xe1,0x81, + 0xff,0xff,0xff,0xff,0x02,0xc7,0xc7,0xc7,0xe1,0xaf,0xaf,0xaf,0xd6,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0xdc, + 0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x87,0xff,0xff,0xff, + 0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0x00,0x00,0x00,0xb3,0x00,0x52,0x52,0x52,0xbd,0x81, + 0xff,0xff,0xff,0xff,0x02,0xef,0xef,0xef,0xf5,0xaf,0xaf,0xaf,0xd6,0xc7,0xc7,0xc7,0xe1,0x82,0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0x52, + 0x52,0x52,0xbd,0x84,0xff,0xff,0xff,0xff,0x02,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x01,0xdc,0xdc,0xdc,0xeb,0xef, + 0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x86,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc, + 0xeb,0x87,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0x00,0x00,0x00,0xb3,0x00,0x90,0x90,0x90,0xcc,0x86,0xff,0xff,0xff,0xff,0x00, + 0x90,0x90,0x90,0xcc,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x89,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff, + 0xff,0xff,0x81,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x02,0xc7, + 0xc7,0xc7,0xe1,0xaf,0xaf,0xaf,0xd6,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x84, + 0xff,0xff,0xff,0xff,0x02,0xe6,0xe6,0xe6,0xf0,0x33,0x33,0x33,0xb8,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7, + 0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x86,0x00,0x00,0x00,0xb3,0x00,0xf7,0xf7,0xf7,0xfa,0x86,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0xb3,0x6a,0x6a, + 0x6a,0xc2,0x81,0xff,0xff,0xff,0xff,0x01,0xdc,0xdc,0xdc,0xeb,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00, + 0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7, + 0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x86,0x00, + 0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x83,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x83,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf, + 0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xbb,0xbb,0xbb,0xdc,0x85,0xff,0xff,0xff,0xff,0x01,0xf7,0xf7,0xf7,0xfa,0x52,0x52,0x52,0xbd,0x81,0x00,0x00,0x00,0xb3,0x00,0xa0, + 0xa0,0xa0,0xd1,0x83,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x86,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0x00,0x00,0x00, + 0xb3,0x00,0x90,0x90,0x90,0xcc,0x86,0xff,0xff,0xff,0xff,0x00,0x90,0x90,0x90,0xcc,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x88, + 0x00,0x00,0x00,0xb3,0x00,0x6a,0x6a,0x6a,0xc2,0x86,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0x6a,0x6a,0x6a,0xc2,0x81,0xff,0xff,0xff,0xff, + 0x01,0xdc,0xdc,0xdc,0xeb,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x03,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0x81, + 0xff,0xff,0xff,0xff,0x01,0xdc,0xdc,0xdc,0xeb,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x86,0x00,0x00,0x00,0xb3,0x87,0xff,0xff,0xff, + 0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x83,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0xff,0xff,0xff,0xff,0x00,0xa0,0xa0,0xa0,0xd1,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xae,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xad,0x00,0x00,0x00,0xb3,0x03,0xaf,0xaf,0xaf,0xd6,0x33,0x33,0x33, + 0xb8,0x00,0x00,0x00,0xb3,0x90,0x90,0x90,0xcc,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff, + 0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff, + 0xff,0x00,0xe6,0xe6,0xe6,0xf0,0x81,0x90,0x90,0x90,0xcc,0x00,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x02,0xa0,0xa0,0xa0,0xd1,0x00,0x00,0x00,0xb3,0xaf,0xaf, + 0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0xe6,0xe6,0xe6,0xf0,0x7e,0x7e,0x7e,0xc7,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00, + 0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x03,0xe6,0xe6, + 0xe6,0xf0,0x90,0x90,0x90,0xcc,0x7e,0x7e,0x7e,0xc7,0xd2,0xd2,0xd2,0xe6,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x86,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc, + 0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x03,0xaf,0xaf,0xaf,0xd6,0x7e,0x7e,0x7e,0xc7,0xa0,0xa0,0xa0,0xd1,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x02,0x6a,0x6a, + 0x6a,0xc2,0x00,0x00,0x00,0xb3,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x01,0xa0,0xa0,0xa0,0xd1,0xaf,0xaf, + 0xaf,0xd6,0x87,0x00,0x00,0x00,0xb3,0x00,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x07,0xaf,0xaf,0xaf,0xd6,0x7e,0x7e,0x7e,0xc7,0xbb,0xbb,0xbb,0xdc,0xa0,0xa0, + 0xa0,0xd1,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x05,0x33,0x33,0x33,0xb8,0xef,0xef,0xef,0xf5, + 0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00, + 0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x03,0xf7,0xf7,0xf7,0xfa,0xa0,0xa0,0xa0,0xd1,0x7e,0x7e,0x7e,0xc7,0xaf,0xaf,0xaf,0xd6,0x81, + 0xff,0xff,0xff,0xff,0x00,0xf7,0xf7,0xf7,0xfa,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e, + 0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7, + 0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x04,0xd2,0xd2,0xd2,0xe6,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0x00,0x00,0x00,0xb3,0xc7,0xc7, + 0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x00,0x6a,0x6a,0x6a,0xc2,0x81,0x00,0x00,0x00,0xb3,0x01,0xbb,0xbb,0xbb,0xdc,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x00, + 0x6a,0x6a,0x6a,0xc2,0x81,0xff,0xff,0xff,0xff,0x03,0xf7,0xf7,0xf7,0xfa,0xa0,0xa0,0xa0,0xd1,0x7e,0x7e,0x7e,0xc7,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00, + 0xdc,0xdc,0xdc,0xeb,0x87,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0x00,0x00,0x00,0xb3,0x00,0xef,0xef,0xef,0xf5,0x81,0xff,0xff, + 0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x7e,0x7e,0x7e,0xc7,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0xef,0xef,0xef,0xf5,0x81,0x00,0x00,0x00,0xb3,0x81,0xff, + 0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x88,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00, + 0xb3,0x01,0xa0,0xa0,0xa0,0xd1,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x02,0xdc,0xdc,0xdc,0xeb,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00, + 0xb3,0x05,0x33,0x33,0x33,0xb8,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x00, + 0xe6,0xe6,0xe6,0xf0,0x81,0x90,0x90,0x90,0xcc,0x03,0xd2,0xd2,0xd2,0xe6,0x33,0x33,0x33,0xb8,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81, + 0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x85,0x00,0x00,0x00,0xb3,0x00,0x6a,0x6a,0x6a,0xc2,0x81,0xff,0xff, + 0xff,0xff,0x02,0xf7,0xf7,0xf7,0xfa,0x90,0x90,0x90,0xcc,0xaf,0xaf,0xaf,0xd6,0x82,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x03,0xa0,0xa0,0xa0,0xd1,0x6a,0x6a, + 0x6a,0xc2,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff, + 0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x01,0xa0,0xa0,0xa0,0xd1,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff, + 0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x86,0x00,0x00,0x00, + 0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x83,0x00,0x00,0x00,0xb3,0x00,0xe6,0xe6,0xe6,0xf0,0x83,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00, + 0x00,0x00,0xb3,0x52,0x52,0x52,0xbd,0x81,0xff,0xff,0xff,0xff,0x03,0xf7,0xf7,0xf7,0xfa,0xa0,0xa0,0xa0,0xd1,0x7e,0x7e,0x7e,0xc7,0xd2,0xd2,0xd2,0xe6,0x81,0xff,0xff, + 0xff,0xff,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0x33, + 0x33,0x33,0xb8,0x86,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0x00,0x00,0x00,0xb3,0x00,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff, + 0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x7e,0x7e,0x7e,0xc7,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0xef,0xef,0xef,0xf5,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff, + 0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x88,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0xe6,0xe6,0xe6,0xf0,0x7e,0x7e,0x7e,0xc7,0xc7, + 0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x03,0xa0,0xa0,0xa0,0xd1,0x6a,0x6a,0x6a,0xc2,0x00,0x00,0x00,0xb3,0x33, + 0x33,0x33,0xb8,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x00,0x6a,0x6a,0x6a,0xc2,0x81, + 0x00,0x00,0x00,0xb3,0x01,0xbb,0xbb,0xbb,0xdc,0x7e,0x7e,0x7e,0xc7,0x87,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x03,0xf7,0xf7,0xf7,0xfa,0xa0,0xa0,0xa0,0xd1, + 0x7e,0x7e,0x7e,0xc7,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0xf7,0xf7,0xf7,0xfa,0x82,0x00,0x00,0x00,0xb3,0x01,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa, + 0x82,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xae,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xad,0x00,0x00,0x00,0xb3,0x02,0x52,0x52,0x52,0xbd,0xaf,0xaf,0xaf,0xd6,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x02,0xa0,0xa0,0xa0,0xd1,0x00, + 0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6, + 0x00,0x00,0x00,0xb3,0xd2,0xd2,0xd2,0xe6,0x81,0xff,0xff,0xff,0xff,0x00,0x52,0x52,0x52,0xbd,0x81,0x00,0x00,0x00,0xb3,0x00,0x52,0x52,0x52,0xbd,0x81,0xff,0xff,0xff, + 0xff,0x02,0xd2,0xd2,0xd2,0xe6,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0x90,0x90,0x90,0xcc,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8, + 0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3, + 0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x00,0x52,0x52,0x52,0xbd,0x82,0x00,0x00,0x00,0xb3,0x02,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xaf,0xaf,0xaf,0xd6, + 0x86,0x00,0x00,0x00,0xb3,0x02,0xdc,0xdc,0xdc,0xeb,0xff,0xff,0xff,0xff,0xc7,0xc7,0xc7,0xe1,0x82,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff, + 0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xd2,0xd2,0xd2,0xe6,0x81,0xff,0xff,0xff,0xff,0x85,0xaf,0xaf,0xaf,0xd6,0x85,0x00,0x00,0x00,0xb3,0x00,0x6a,0x6a, + 0x6a,0xc2,0x81,0xff,0xff,0xff,0xff,0x00,0xc7,0xc7,0xc7,0xe1,0x84,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0xbb,0xbb,0xbb,0xdc, + 0x81,0x7e,0x7e,0x7e,0xc7,0x04,0xe6,0xe6,0xe6,0xf0,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81, + 0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xa0,0xa0,0xa0,0xd1,0x82,0x00,0x00, + 0x00,0xb3,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x01,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x82, + 0x00,0x00,0x00,0xb3,0x06,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xe6,0xe6,0xe6,0xf0,0xa0,0xa0,0xa0,0xd1,0x7e,0x7e,0x7e,0xc7,0xaf,0xaf,0xaf, + 0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00, + 0x00,0xb3,0x02,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0x84,0xaf,0xaf,0xaf,0xd6,0x02,0xa0,0xa0,0xa0,0xd1,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf, + 0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0xa0,0xa0,0xa0,0xd1,0x82,0x00,0x00,0x00,0xb3,0x02,0xc7,0xc7,0xc7,0xe1,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0x87,0x00,0x00, + 0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x00,0x6a,0x6a,0x6a,0xc2,0x81,0xff,0xff,0xff,0xff,0x00,0xc7,0xc7,0xc7,0xe1, + 0x82,0x00,0x00,0x00,0xb3,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x01,0x6a,0x6a,0x6a,0xc2,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc, + 0xdc,0xeb,0x88,0x00,0x00,0x00,0xb3,0x00,0xd2,0xd2,0xd2,0xe6,0x81,0xff,0xff,0xff,0xff,0x85,0xaf,0xaf,0xaf,0xd6,0x01,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81, + 0xff,0xff,0xff,0xff,0x00,0xbb,0xbb,0xbb,0xdc,0x81,0x7e,0x7e,0x7e,0xc7,0x04,0xe6,0xe6,0xe6,0xf0,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0xd2, + 0xd2,0xd2,0xe6,0x81,0xff,0xff,0xff,0xff,0x00,0x52,0x52,0x52,0xbd,0x84,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00, + 0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x85,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00, + 0xbb,0xbb,0xbb,0xdc,0x81,0x00,0x00,0x00,0xb3,0x00,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x03,0x33,0x33,0x33,0xb8,0xaf,0xaf,0xaf, + 0xd6,0xd2,0xd2,0xd2,0xe6,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x02,0xc7,0xc7,0xc7,0xe1,0x00,0x00,0x00,0xb3,0xd2,0xd2,0xd2,0xe6,0x81,0xff,0xff,0xff,0xff, + 0x85,0xaf,0xaf,0xaf,0xd6,0x01,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x01,0x52,0x52, + 0x52,0xbd,0x6a,0x6a,0x6a,0xc2,0x87,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x82,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x84, + 0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0xa0,0xa0,0xa0,0xd1,0x82,0x00,0x00,0x00,0xb3, + 0x02,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e, + 0xc7,0x88,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x00,0x6a,0x6a,0x6a,0xc2,0x81,0xff,0xff,0xff,0xff,0x00, + 0xc7,0xc7,0xc7,0xe1,0x82,0x00,0x00,0x00,0xb3,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x01,0x6a,0x6a,0x6a,0xc2,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff, + 0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x88,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0x90,0x90,0x90,0xcc,0x00,0x00,0x00,0xb3,0x33,0x33, + 0x33,0xb8,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x03,0x33,0x33,0x33,0xb8,0xaf,0xaf,0xaf,0xd6,0xd2,0xd2,0xd2,0xe6,0xf7,0xf7, + 0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x04,0xc7,0xc7,0xc7,0xe1,0x00,0x00,0x00,0xb3,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0x84,0xaf,0xaf,0xaf, + 0xd6,0x00,0xa0,0xa0,0xa0,0xd1,0x86,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xa0,0xa0,0xa0,0xd1,0x82,0x00,0x00,0x00,0xb3,0x00,0xc7,0xc7,0xc7,0xe1,0x81, + 0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff, + 0xff,0xff,0x00,0x52,0x52,0x52,0xbd,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xad,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xac,0x00,0x00,0x00,0xb3,0x01,0x52,0x52,0x52,0xbd,0xf7,0xf7,0xf7,0xfa,0x83,0xff,0xff,0xff,0xff,0x03,0xdc,0xdc,0xdc,0xeb,0x33,0x33,0x33,0xb8,0x00,0x00,0x00,0xb3, + 0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00, + 0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x83,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf, + 0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0x7e,0x7e, + 0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x83,0x00,0x00,0x00,0xb3,0x02,0xdc, + 0xdc,0xdc,0xeb,0xff,0xff,0xff,0xff,0xaf,0xaf,0xaf,0xd6,0x86,0x00,0x00,0x00,0xb3,0x02,0xdc,0xdc,0xdc,0xeb,0xff,0xff,0xff,0xff,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00, + 0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x87,0xff,0xff,0xff,0xff,0x85,0x00, + 0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x84,0x00,0x00,0x00,0xb3,0x01,0x33,0x33,0x33,0xb8,0xd2,0xd2,0xd2,0xe6, + 0x85,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff, + 0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81, + 0xff,0xff,0xff,0xff,0x01,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x83,0x00,0x00,0x00,0xb3,0x01,0x90,0x90,0x90, + 0xcc,0xf7,0xf7,0xf7,0xfa,0x85,0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf, + 0xd6,0x82,0x00,0x00,0x00,0xb3,0x87,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e, + 0x7e,0xc7,0x82,0x00,0x00,0x00,0xb3,0x02,0xaf,0xaf,0xaf,0xd6,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0x87,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc, + 0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf, + 0xd6,0x81,0xff,0xff,0xff,0xff,0x01,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x88,0x00,0x00,0x00,0xb3,0x00,0xdc, + 0xdc,0xdc,0xeb,0x87,0xff,0xff,0xff,0xff,0x02,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0xd2,0xd2,0xd2,0xe6,0x85,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00, + 0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x85,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3, + 0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x85,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf, + 0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0xe6,0xe6,0xe6,0xf0,0x83,0xff,0xff,0xff, + 0xff,0x03,0xef,0xef,0xef,0xf5,0x6a,0x6a,0x6a,0xc2,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x87,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7, + 0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x8c,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x01,0x52, + 0x52,0x52,0xbd,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x00,0xbb,0xbb,0xbb,0xdc,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xaf, + 0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00, + 0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x88,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81, + 0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff, + 0xff,0xff,0x01,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x88,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81, + 0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x00,0xe6,0xe6, + 0xe6,0xf0,0x83,0xff,0xff,0xff,0xff,0x02,0xef,0xef,0xef,0xf5,0x6a,0x6a,0x6a,0xc2,0x00,0x00,0x00,0xb3,0x87,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x86,0x00, + 0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e, + 0xc7,0x81,0x00,0x00,0x00,0xb3,0x06,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0x00,0x00,0x00,0xb3,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xbb, + 0xbb,0xbb,0xdc,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xad,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xac,0x00,0x00,0x00, + 0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0xef,0xef,0xef,0xf5,0xaf,0xaf,0xaf,0xd6,0x6a,0x6a,0x6a,0xc2,0x82,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc, + 0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x02,0x52,0x52,0x52,0xbd,0x00,0x00,0x00,0xb3,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00, + 0x00,0xb3,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02, + 0xc7,0xc7,0xc7,0xe1,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff, + 0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xc7,0xc7,0xc7,0xe1,0x81, + 0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x03,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xaf,0xaf,0xaf,0xd6,0x86, + 0x00,0x00,0x00,0xb3,0x02,0xdc,0xdc,0xdc,0xeb,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0x82,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff, + 0x02,0xa0,0xa0,0xa0,0xd1,0x00,0x00,0x00,0xb3,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x00,0x90,0x90,0x90,0xcc,0x81,0x7e,0x7e,0x7e,0xc7,0x02,0xe6,0xe6,0xe6, + 0xf0,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0x85,0x00,0x00,0x00,0xb3,0x00,0x52,0x52,0x52,0xbd,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00, + 0x00,0xb3,0x00,0x33,0x33,0x33,0xb8,0x83,0x00,0x00,0x00,0xb3,0x01,0x52,0x52,0x52,0xbd,0x90,0x90,0x90,0xcc,0x81,0xaf,0xaf,0xaf,0xd6,0x04,0xef,0xef,0xef,0xf5,0xff, + 0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc, + 0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff, + 0xff,0x01,0x52,0x52,0x52,0xbd,0x00,0x00,0x00,0xb3,0x82,0xff,0xff,0xff,0xff,0x00,0x33,0x33,0x33,0xb8,0x84,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xaf, + 0xaf,0xaf,0xd6,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00, + 0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x02,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0x82,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff, + 0x02,0xd2,0xd2,0xd2,0xe6,0x00,0x00,0x00,0xb3,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x02,0xdc,0xdc,0xdc, + 0xeb,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0x87,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x00,0x52,0x52, + 0x52,0xbd,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x01,0x52,0x52,0x52,0xbd, + 0x00,0x00,0x00,0xb3,0x82,0xff,0xff,0xff,0xff,0x00,0x33,0x33,0x33,0xb8,0x87,0x00,0x00,0x00,0xb3,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x00,0x90,0x90, + 0x90,0xcc,0x81,0x7e,0x7e,0x7e,0xc7,0x02,0xe6,0xe6,0xe6,0xf0,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0x82,0x00,0x00,0x00,0xb3,0x01,0x52,0x52,0x52,0xbd,0x90,0x90, + 0x90,0xcc,0x81,0xaf,0xaf,0xaf,0xd6,0x04,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff, + 0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x00,0x33,0x33,0x33,0xb8,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x02, + 0x52,0x52,0x52,0xbd,0x00,0x00,0x00,0xb3,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x85,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7, + 0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0xb3,0x7e,0x7e, + 0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xf7,0xf7,0xf7,0xfa,0xbb,0xbb,0xbb,0xdc,0x90,0x90,0x90,0xcc,0x82,0x00,0x00,0x00,0xb3,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0xff, + 0xff,0xff,0xff,0x00,0x90,0x90,0x90,0xcc,0x81,0x7e,0x7e,0x7e,0xc7,0x04,0xe6,0xe6,0xe6,0xf0,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0x00,0x00,0x00,0xb3,0x7e,0x7e, + 0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xe6,0xe6,0xe6,0xf0,0x8c,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3, + 0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x01,0xdc,0xdc,0xdc,0xeb,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00, + 0xb3,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x03,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff, + 0xff,0xef,0xef,0xef,0xf5,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x88,0x00,0x00,0x00,0xb3,0x81,0xff, + 0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x00,0x52,0x52,0x52,0xbd,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0x00,0x00,0x00, + 0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x01,0x52,0x52,0x52,0xbd,0x00,0x00,0x00,0xb3,0x82,0xff,0xff,0xff,0xff,0x00,0x33,0x33,0x33,0xb8,0x87,0x00, + 0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc, + 0xeb,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xf7,0xf7,0xf7,0xfa,0xbb,0xbb,0xbb,0xdc,0x90,0x90,0x90,0xcc,0x82,0x00,0x00,0x00,0xb3, + 0x02,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0x82,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xd2,0xd2,0xd2,0xe6,0x86,0x00,0x00,0x00, + 0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x02,0x52,0x52,0x52,0xbd,0x00, + 0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x04,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xc7,0xc7,0xc7,0xe1,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7, + 0xfa,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xad,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xac,0x00,0x00,0x00,0xb3,0x00, + 0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x03,0xa0,0xa0,0xa0,0xd1,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x6a,0x6a,0x6a,0xc2,0x81,0x00,0x00,0x00,0xb3,0x00, + 0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x02,0xe6,0xe6,0xe6,0xf0,0xaf,0xaf,0xaf,0xd6,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x02,0xa0,0xa0,0xa0,0xd1, + 0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xf7,0xf7,0xf7,0xfa,0x81,0xbb,0xbb,0xbb,0xdc,0x00,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff, + 0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff, + 0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0x90,0x90,0x90, + 0xcc,0x81,0xff,0xff,0xff,0xff,0x03,0xf7,0xf7,0xf7,0xfa,0xbb,0xbb,0xbb,0xdc,0xaf,0xaf,0xaf,0xd6,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf, + 0xd6,0x86,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0xaf,0xaf,0xaf,0xd6,0xc7,0xc7,0xc7,0xe1,0x82,0xff,0xff, + 0xff,0xff,0x02,0x52,0x52,0x52,0xbd,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xc7,0xc7,0xc7,0xe1,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e, + 0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xc7,0xc7,0xc7,0xe1,0x86,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x03,0xdc,0xdc,0xdc,0xeb,0xaf, + 0xaf,0xaf,0xd6,0xdc,0xdc,0xdc,0xeb,0xc7,0xc7,0xc7,0xe1,0x81,0x00,0x00,0x00,0xb3,0x09,0x33,0x33,0x33,0xb8,0xaf,0xaf,0xaf,0xd6,0x33,0x33,0x33,0xb8,0x00,0x00,0x00, + 0xb3,0x52,0x52,0x52,0xbd,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00, + 0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x82,0xff,0xff,0xff,0xff,0x02,0xc7,0xc7,0xc7,0xe1,0xaf,0xaf,0xaf,0xd6, + 0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x00,0xef,0xef,0xef,0xf5,0x81,0x00,0x00,0x00,0xb3,0x82,0xff,0xff,0xff,0xff,0x00,0xef,0xef,0xef,0xf5,0x81,0xaf,0xaf, + 0xaf,0xd6,0x03,0x52,0x52,0x52,0xbd,0x00,0x00,0x00,0xb3,0xa0,0xa0,0xa0,0xd1,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x00,0xbb,0xbb,0xbb,0xdc,0x81,0xff,0xff, + 0xff,0xff,0x02,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xaf,0xaf,0xaf,0xd6,0x01,0x00, + 0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0xa0,0xa0,0xa0,0xd1,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0xa0, + 0xa0,0xa0,0xd1,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0x82,0xff,0xff,0xff,0xff,0x02,0xc7,0xc7,0xc7,0xe1,0xaf,0xaf,0xaf,0xd6,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff, + 0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x85,0x00,0x00,0x00,0xb3,0x01,0xa0,0xa0,0xa0,0xd1,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x04,0xef,0xef,0xef,0xf5,0xaf, + 0xaf,0xaf,0xd6,0xa0,0xa0,0xa0,0xd1,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0xaf,0xaf,0xaf,0xd6,0xdc,0xdc,0xdc, + 0xeb,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x82,0xff,0xff,0xff,0xff,0x00,0xef,0xef,0xef,0xf5,0x81,0xaf,0xaf,0xaf,0xd6,0x00, + 0x52,0x52,0x52,0xbd,0x84,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xc7,0xc7,0xc7,0xe1,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7, + 0x81,0xff,0xff,0xff,0xff,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0x00,0x00,0x00,0xb3,0x09,0x33,0x33,0x33,0xb8,0xaf,0xaf,0xaf,0xd6,0x33,0x33,0x33,0xb8,0x00,0x00,0x00,0xb3, + 0x52,0x52,0x52,0xbd,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xf7,0xf7, + 0xf7,0xfa,0x81,0xbb,0xbb,0xbb,0xdc,0x03,0xef,0xef,0xef,0xf5,0x6a,0x6a,0x6a,0xc2,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x02,0xe6,0xe6, + 0xe6,0xf0,0xaf,0xaf,0xaf,0xd6,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x00,0xa0,0xa0,0xa0,0xd1,0x85,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff, + 0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7, + 0x81,0xff,0xff,0xff,0xff,0x03,0xc7,0xc7,0xc7,0xe1,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0xa0,0xa0,0xa0,0xd1,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7, + 0x81,0xff,0xff,0xff,0xff,0x02,0xc7,0xc7,0xc7,0xe1,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xc7,0xc7,0xc7,0xe1,0x00,0x00,0x00,0xb3, + 0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xaf,0xaf,0xaf,0xd6,0x89,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff, + 0xff,0xff,0x01,0x00,0x00,0x00,0xb3,0x90,0x90,0x90,0xcc,0x81,0xff,0xff,0xff,0xff,0x02,0xf7,0xf7,0xf7,0xfa,0x52,0x52,0x52,0xbd,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff, + 0xff,0xff,0x03,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x02,0xc7,0xc7,0xc7,0xe1,0xaf,0xaf,0xaf, + 0xd6,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x03,0xaf,0xaf,0xaf,0xd6,0x52,0x52,0x52,0xbd,0xaf,0xaf,0xaf,0xd6,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff, + 0x02,0xc7,0xc7,0xc7,0xe1,0xaf,0xaf,0xaf,0xd6,0xa0,0xa0,0xa0,0xd1,0x84,0x00,0x00,0x00,0xb3,0x01,0xa0,0xa0,0xa0,0xd1,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff, + 0x04,0xef,0xef,0xef,0xf5,0xaf,0xaf,0xaf,0xd6,0xa0,0xa0,0xa0,0xd1,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0xaf, + 0xaf,0xaf,0xd6,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x82,0xff,0xff,0xff,0xff,0x00,0xef,0xef,0xef,0xf5, + 0x81,0xaf,0xaf,0xaf,0xd6,0x00,0x52,0x52,0x52,0xbd,0x84,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00, + 0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x03,0xc7,0xc7,0xc7,0xe1,0x00, + 0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0xa0,0xa0,0xa0,0xd1,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0xa0,0xa0,0xa0,0xd1,0x00, + 0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0xa0,0xa0,0xa0,0xd1,0x86,0x00,0x00,0x00,0xb3,0x82,0xff,0xff,0xff,0xff,0x02,0xc7,0xc7,0xc7,0xe1, + 0xaf,0xaf,0xaf,0xd6,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x00,0xef,0xef,0xef,0xf5,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff, + 0xff,0x02,0x52,0x52,0x52,0xbd,0x00,0x00,0x00,0xb3,0x90,0x90,0x90,0xcc,0x81,0xff,0xff,0xff,0xff,0x00,0x90,0x90,0x90,0xcc,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xac,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xac,0x00,0x00,0x00,0xb3,0x01,0x52,0x52,0x52,0xbd,0xf7,0xf7,0xf7,0xfa,0x83, + 0xff,0xff,0xff,0xff,0x03,0xf7,0xf7,0xf7,0xfa,0x6a,0x6a,0x6a,0xc2,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x00,0xf7,0xf7,0xf7,0xfa,0x83, + 0xff,0xff,0xff,0xff,0x00,0x52,0x52,0x52,0xbd,0x81,0x00,0x00,0x00,0xb3,0x00,0xc7,0xc7,0xc7,0xe1,0x85,0xff,0xff,0xff,0xff,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0x00,0x00, + 0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb, + 0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x86,0xff,0xff,0xff, + 0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x86,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x86,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x00, + 0xc7,0xc7,0xc7,0xe1,0x84,0xff,0xff,0xff,0xff,0x01,0xf7,0xf7,0xf7,0xfa,0x52,0x52,0x52,0xbd,0x86,0x00,0x00,0x00,0xb3,0x01,0x52,0x52,0x52,0xbd,0xf7,0xf7,0xf7,0xfa, + 0x84,0xff,0xff,0xff,0xff,0x06,0xbb,0xbb,0xbb,0xdc,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0xdc,0xdc,0xdc,0xeb,0xf7,0xf7, + 0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x02,0x52,0x52,0x52,0xbd,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x81,0xff, + 0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x87,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff, + 0xff,0x01,0xef,0xef,0xef,0xf5,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x81,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x81,0xe6,0xe6,0xe6,0xf0,0x81,0xff, + 0xff,0xff,0xff,0x01,0xc7,0xc7,0xc7,0xe1,0x00,0x00,0x00,0xb3,0x86,0xff,0xff,0xff,0xff,0x02,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0xe6,0xe6,0xe6,0xf0,0x84,0xff, + 0xff,0xff,0xff,0x00,0xe6,0xe6,0xe6,0xf0,0x82,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x86,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x85,0x00,0x00,0x00, + 0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x84,0xff,0xff,0xff,0xff,0x03,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0x6a,0x6a,0x6a,0xc2,0xf7,0xf7,0xf7,0xfa,0x84,0xff,0xff,0xff, + 0xff,0x01,0xf7,0xf7,0xf7,0xfa,0x6a,0x6a,0x6a,0xc2,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x01,0xef,0xef,0xef,0xf5,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff, + 0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x85,0x00,0x00,0x00,0xb3,0x00,0xc7,0xc7,0xc7,0xe1,0x84,0xff,0xff,0xff,0xff,0x01,0xf7,0xf7,0xf7,0xfa,0x52,0x52,0x52,0xbd,0x81, + 0x00,0x00,0x00,0xb3,0x04,0xdc,0xdc,0xdc,0xeb,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0xdc,0xdc,0xdc,0xeb,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x00,0x52, + 0x52,0x52,0xbd,0x81,0x00,0x00,0x00,0xb3,0x00,0xbb,0xbb,0xbb,0xdc,0x84,0xff,0xff,0xff,0xff,0x02,0xf7,0xf7,0xf7,0xfa,0x52,0x52,0x52,0xbd,0xdc,0xdc,0xdc,0xeb,0x81, + 0xff,0xff,0xff,0xff,0x00,0xf7,0xf7,0xf7,0xfa,0x83,0xff,0xff,0xff,0xff,0x00,0x52,0x52,0x52,0xbd,0x85,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff, + 0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0xe6,0xe6,0xe6,0xf0, + 0x84,0xff,0xff,0xff,0xff,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0x00,0x00,0x00,0xb3,0x00,0xc7,0xc7,0xc7,0xe1,0x84,0xff,0xff,0xff,0xff,0x03,0xf7,0xf7,0xf7,0xfa,0x52,0x52, + 0x52,0xbd,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xe6,0xe6,0xe6,0xf0,0x82,0xff,0xff,0xff,0xff,0x89,0x00,0x00,0x00,0xb3,0x00,0xdc, + 0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x01,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0x7e, + 0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x85,0xff,0xff,0xff,0xff,0x02,0xe6,0xe6,0xe6, + 0xf0,0x33,0x33,0x33,0xb8,0x7e,0x7e,0x7e,0xc7,0x85,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x84,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x84,0xff,0xff, + 0xff,0xff,0x03,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0x6a,0x6a,0x6a,0xc2,0xf7,0xf7,0xf7,0xfa,0x84,0xff,0xff,0xff,0xff,0x01,0xf7,0xf7,0xf7,0xfa,0x6a,0x6a,0x6a, + 0xc2,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x01,0xef,0xef,0xef,0xf5,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x84,0x00, + 0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc, + 0xeb,0x81,0x00,0x00,0x00,0xb3,0x00,0xe6,0xe6,0xe6,0xf0,0x84,0xff,0xff,0xff,0xff,0x03,0xa0,0xa0,0xa0,0xd1,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0xe6,0xe6,0xe6, + 0xf0,0x84,0xff,0xff,0xff,0xff,0x00,0xe6,0xe6,0xe6,0xf0,0x87,0x00,0x00,0x00,0xb3,0x87,0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0x52,0x52, + 0x52,0xbd,0x81,0xff,0xff,0xff,0xff,0x00,0xd2,0xd2,0xd2,0xe6,0x82,0x00,0x00,0x00,0xb3,0x02,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xd2,0xd2,0xd2,0xe6,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xac,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xad,0x00,0x00,0x00,0xb3,0x01,0x6a,0x6a,0x6a, + 0xc2,0xd2,0xd2,0xd2,0xe6,0x81,0xff,0xff,0xff,0xff,0x04,0xef,0xef,0xef,0xf5,0xaf,0xaf,0xaf,0xd6,0x33,0x33,0x33,0xb8,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81, + 0xff,0xff,0xff,0xff,0x04,0x90,0x90,0x90,0xcc,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0x90,0x90,0x90,0xcc,0x83,0x00,0x00,0x00,0xb3,0x01,0xa0, + 0xa0,0xa0,0xd1,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x01,0xe6,0xe6,0xe6,0xf0,0xa0,0xa0,0xa0,0xd1,0x82,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x81, + 0xdc,0xdc,0xdc,0xeb,0x00,0x6a,0x6a,0x6a,0xc2,0x81,0x00,0x00,0x00,0xb3,0x81,0xdc,0xdc,0xdc,0xeb,0x02,0xbb,0xbb,0xbb,0xdc,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7, + 0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x05,0x33,0x33,0x33,0xb8,0xc7,0xc7,0xc7,0xe1,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff, + 0xdc,0xdc,0xdc,0xeb,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x86,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff, + 0xff,0x04,0x90,0x90,0x90,0xcc,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0xaf,0xaf,0xaf,0xd6,0x84,0x00,0x00,0x00,0xb3,0x01,0xa0,0xa0,0xa0,0xd1, + 0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x01,0xd2,0xd2,0xd2,0xe6,0x6a,0x6a,0x6a,0xc2,0x88,0x00,0x00,0x00,0xb3,0x0a,0x33,0x33,0x33,0xb8,0xc7,0xc7,0xc7,0xe1, + 0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0xc7,0xc7,0xc7,0xe1,0x52,0x52,0x52,0xbd,0x00,0x00,0x00,0xb3,0x52,0x52,0x52,0xbd,0xc7,0xc7,0xc7,0xe1, + 0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x01,0xdc,0xdc,0xdc,0xeb,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff, + 0xff,0x81,0x00,0x00,0x00,0xb3,0x81,0xdc,0xdc,0xdc,0xeb,0x00,0xbb,0xbb,0xbb,0xdc,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x05,0xdc,0xdc,0xdc,0xeb,0xaf, + 0xaf,0xaf,0xd6,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xe6,0xe6,0xe6,0xf0,0x90,0x90,0x90,0xcc,0x82,0x00,0x00,0x00,0xb3,0x81,0xdc,0xdc,0xdc,0xeb,0x07,0xbb,0xbb, + 0xbb,0xdc,0x90,0x90,0x90,0xcc,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0xa0,0xa0,0xa0,0xd1,0xdc,0xdc,0xdc,0xeb,0x81,0xff, + 0xff,0xff,0xff,0x05,0xef,0xef,0xef,0xf5,0xbb,0xbb,0xbb,0xdc,0x33,0x33,0x33,0xb8,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff, + 0xff,0x00,0xef,0xef,0xef,0xf5,0x81,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x06,0x33,0x33,0x33,0xb8,0xaf,0xaf,0xaf,0xd6,0xef,0xef,0xef,0xf5,0xff,0xff,0xff, + 0xff,0xf7,0xf7,0xf7,0xfa,0xc7,0xc7,0xc7,0xe1,0x33,0x33,0x33,0xb8,0x83,0x00,0x00,0x00,0xb3,0x04,0xaf,0xaf,0xaf,0xd6,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xef, + 0xef,0xef,0xf5,0x90,0x90,0x90,0xcc,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x85,0x00,0x00,0x00,0xb3,0x01,0xbb,0xbb,0xbb,0xdc,0xdc,0xdc,0xdc,0xeb,0x81, + 0xff,0xff,0xff,0xff,0x02,0xf7,0xf7,0xf7,0xfa,0xdc,0xdc,0xdc,0xeb,0xbb,0xbb,0xbb,0xdc,0x81,0x00,0x00,0x00,0xb3,0x06,0x52,0x52,0x52,0xbd,0xc7,0xc7,0xc7,0xe1,0xf7, + 0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0xc7,0xc7,0xc7,0xe1,0x52,0x52,0x52,0xbd,0x82,0x00,0x00,0x00,0xb3,0x81,0xdc,0xdc,0xdc,0xeb,0x04,0xbb,0xbb, + 0xbb,0xdc,0x90,0x90,0x90,0xcc,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0x7e,0x7e,0x7e,0xc7,0x86,0x00,0x00,0x00,0xb3,0x01,0xa0,0xa0,0xa0,0xd1,0xe6,0xe6,0xe6,0xf0, + 0x81,0xff,0xff,0xff,0xff,0x01,0xd2,0xd2,0xd2,0xe6,0x6a,0x6a,0x6a,0xc2,0x82,0x00,0x00,0x00,0xb3,0x02,0x52,0x52,0x52,0xbd,0xc7,0xc7,0xc7,0xe1,0xef,0xef,0xef,0xf5, + 0x81,0xff,0xff,0xff,0xff,0x01,0xdc,0xdc,0xdc,0xeb,0x7e,0x7e,0x7e,0xc7,0x83,0x00,0x00,0x00,0xb3,0x01,0x90,0x90,0x90,0xcc,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff, + 0xff,0x03,0xe6,0xe6,0xe6,0xf0,0xa0,0xa0,0xa0,0xd1,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x04,0x90,0x90,0x90,0xcc,0xef,0xef,0xef,0xf5, + 0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0x90,0x90,0x90,0xcc,0x86,0x00,0x00,0x00,0xb3,0x00,0x6a,0x6a,0x6a,0xc2,0x81,0xdc,0xdc,0xdc,0xeb,0x00,0xa0,0xa0,0xa0,0xd1, + 0x81,0x00,0x00,0x00,0xb3,0x00,0xbb,0xbb,0xbb,0xdc,0x81,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x06,0x33,0x33,0x33,0xb8,0xc7,0xc7,0xc7,0xe1,0xf7,0xf7,0xf7, + 0xfa,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0xc7,0xc7,0xc7,0xe1,0x52,0x52,0x52,0xbd,0x82,0x00,0x00,0x00,0xb3,0x01,0xa0,0xa0,0xa0,0xd1,0xe6,0xe6,0xe6,0xf0,0x81, + 0xff,0xff,0xff,0xff,0x01,0xd2,0xd2,0xd2,0xe6,0x6a,0x6a,0x6a,0xc2,0x81,0x00,0x00,0x00,0xb3,0x00,0x6a,0x6a,0x6a,0xc2,0x81,0xdc,0xdc,0xdc,0xeb,0x03,0xa0,0xa0,0xa0, + 0xd1,0xaf,0xaf,0xaf,0xd6,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0x89,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x00,0xbb,0xbb,0xbb, + 0xdc,0x81,0xff,0xff,0xff,0xff,0x00,0xe6,0xe6,0xe6,0xf0,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82, + 0x00,0x00,0x00,0xb3,0x01,0x7e,0x7e,0x7e,0xc7,0xd2,0xd2,0xd2,0xe6,0x81,0xff,0xff,0xff,0xff,0x06,0xef,0xef,0xef,0xf5,0xaf,0xaf,0xaf,0xd6,0x33,0x33,0x33,0xb8,0x00, + 0x00,0x00,0xb3,0x6a,0x6a,0x6a,0xc2,0xdc,0xdc,0xdc,0xeb,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x02,0xe6,0xe6,0xe6,0xf0,0xdc,0xdc,0xdc,0xeb,0xbb,0xbb,0xbb, + 0xdc,0x84,0x00,0x00,0x00,0xb3,0x01,0xbb,0xbb,0xbb,0xdc,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x02,0xf7,0xf7,0xf7,0xfa,0xdc,0xdc,0xdc,0xeb,0xbb,0xbb,0xbb, + 0xdc,0x81,0x00,0x00,0x00,0xb3,0x06,0x52,0x52,0x52,0xbd,0xc7,0xc7,0xc7,0xe1,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0xc7,0xc7,0xc7,0xe1,0x52, + 0x52,0x52,0xbd,0x82,0x00,0x00,0x00,0xb3,0x81,0xdc,0xdc,0xdc,0xeb,0x04,0xbb,0xbb,0xbb,0xdc,0x90,0x90,0x90,0xcc,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0x7e,0x7e, + 0x7e,0xc7,0x84,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0xdc,0xdc,0xdc,0xeb,0x00,0x6a,0x6a,0x6a,0xc2,0x81,0x00,0x00,0x00,0xb3,0x81,0xdc,0xdc,0xdc,0xeb, + 0x00,0xbb,0xbb,0xbb,0xdc,0x81,0x00,0x00,0x00,0xb3,0x06,0x33,0x33,0x33,0xb8,0xc7,0xc7,0xc7,0xe1,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0xc7, + 0xc7,0xc7,0xe1,0x52,0x52,0x52,0xbd,0x81,0x00,0x00,0x00,0xb3,0x06,0x33,0x33,0x33,0xb8,0xaf,0xaf,0xaf,0xd6,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7, + 0xfa,0xc7,0xc7,0xc7,0xe1,0x33,0x33,0x33,0xb8,0x87,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x05,0xdc,0xdc,0xdc,0xeb,0xaf,0xaf,0xaf,0xd6,0xf7,0xf7,0xf7,0xfa, + 0xff,0xff,0xff,0xff,0xe6,0xe6,0xe6,0xf0,0x90,0x90,0x90,0xcc,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xdc,0xdc,0xdc,0xeb,0x00,0x7e,0x7e,0x7e,0xc7, + 0x82,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xdc,0xdc,0xdc,0xeb,0x00,0x33,0x33,0x33,0xb8,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xab,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xb5,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x9b,0x00,0x00,0x00, + 0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x86,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00, + 0xaf,0xaf,0xaf,0xd6,0x86,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0xa9,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff, + 0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x01,0x33,0x33,0x33,0xb8,0x7e,0x7e,0x7e,0xc7,0x82,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x98, + 0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x93,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc, + 0xdc,0xeb,0x87,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0xb6,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff, + 0xb9,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x84,0xff,0xff,0xff,0xff,0x00,0x6a,0x6a,0x6a,0xc2,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff, + 0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x8c,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x88,0x00,0x00,0x00, + 0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0xbc,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xbd,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xb5,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff, + 0xff,0xff,0x9b,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x86,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7, + 0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x86,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0xa9,0x00,0x00,0x00,0xb3,0x00,0xdc, + 0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x04,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00, + 0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x98,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6, + 0x93,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x87,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0xb6,0x00, + 0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0xb9,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x83,0xff,0xff,0xff,0xff,0x00,0xbb,0xbb,0xbb, + 0xdc,0x82,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x8c,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81, + 0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x88,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0xbc,0x00,0x00,0x00,0xb3,0x81,0xff,0xff, + 0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xbd,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xb5,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x9b,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf, + 0xaf,0xaf,0xd6,0x86,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x86,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc, + 0xeb,0x81,0xff,0xff,0xff,0xff,0xa9,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x82,0xff, + 0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x98,0x00,0x00,0x00,0xb3,0x00,0x33,0x33,0x33,0xb8,0x81,0x7e,0x7e,0x7e, + 0xc7,0x00,0x52,0x52,0x52,0xbd,0x93,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x87,0x00,0x00,0x00,0xb3,0x00,0xef,0xef,0xef,0xf5,0x81, + 0xff,0xff,0xff,0xff,0x81,0xbb,0xbb,0xbb,0xdc,0xb4,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0xb9,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc, + 0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x01,0xef,0xef,0xef,0xf5,0x33,0x33,0x33,0xb8,0x82,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00, + 0xaf,0xaf,0xaf,0xd6,0x8c,0x00,0x00,0x00,0xb3,0x00,0x52,0x52,0x52,0xbd,0x81,0x7e,0x7e,0x7e,0xc7,0x00,0x33,0x33,0x33,0xb8,0x88,0x00,0x00,0x00,0xb3,0x00,0xef,0xef, + 0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x81,0xbb,0xbb,0xbb,0xdc,0xba,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xbd,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xb5,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff, + 0xff,0xff,0xff,0x9b,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x86,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e, + 0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x86,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0xa9,0x00,0x00,0x00,0xb3,0x00, + 0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x02,0xdc,0xdc,0xdc,0xeb,0xff,0xff,0xff,0xff,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3, + 0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0xb0,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x87,0x00,0x00,0x00,0xb3,0x00,0xaf, + 0xaf,0xaf,0xd6,0x83,0xff,0xff,0xff,0xff,0xb4,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0xb9,0x00,0x00,0x00,0xb3,0x00,0xbb,0xbb,0xbb, + 0xdc,0x82,0xdc,0xdc,0xdc,0xeb,0x00,0x90,0x90,0x90,0xcc,0x83,0x00,0x00,0x00,0xb3,0x00,0x6a,0x6a,0x6a,0xc2,0x81,0xdc,0xdc,0xdc,0xeb,0x00,0xa0,0xa0,0xa0,0xd1,0x99, + 0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x83,0xff,0xff,0xff,0xff,0xba,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xbd,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xb5,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1, + 0x81,0xaf,0xaf,0xaf,0xd6,0x9b,0x00,0x00,0x00,0xb3,0x00,0x52,0x52,0x52,0xbd,0x81,0xaf,0xaf,0xaf,0xd6,0x00,0x7e,0x7e,0x7e,0xc7,0x86,0x00,0x00,0x00,0xb3,0x00,0x52, + 0x52,0x52,0xbd,0x81,0xaf,0xaf,0xaf,0xd6,0x00,0x7e,0x7e,0x7e,0xc7,0x86,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0xaf,0xaf,0xaf,0xd6,0xa9,0x00,0x00,0x00, + 0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0xaf,0xaf,0xaf,0xd6,0x86,0x00,0x00,0x00,0xb3,0x81,0xaf,0xaf,0xaf,0xd6,0x00,0xa0,0xa0,0xa0,0xd1,0xb0,0x00,0x00,0x00,0xb3,0x81, + 0xaf,0xaf,0xaf,0xd6,0x00,0xa0,0xa0,0xa0,0xd1,0x88,0x00,0x00,0x00,0xb3,0x01,0xa0,0xa0,0xa0,0xd1,0xd2,0xd2,0xd2,0xe6,0x81,0xdc,0xdc,0xdc,0xeb,0xb4,0x00,0x00,0x00, + 0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0xaf,0xaf,0xaf,0xd6,0xe1,0x00,0x00,0x00,0xb3,0x01,0xa0,0xa0,0xa0,0xd1,0xd2,0xd2,0xd2,0xe6,0x81,0xdc,0xdc,0xdc,0xeb,0xba,0x00, + 0x00,0x00,0xb3,0x81,0xaf,0xaf,0xaf,0xd6,0x00,0xa0,0xa0,0xa0,0xd1,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xbd,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xc9,0x00,0x00,0x00,0xb3,0x00,0x33,0x33,0x33,0xb8,0x81,0x7e,0x7e,0x7e,0xc7,0x88,0x00,0x00, + 0x00,0xb3,0x02,0x52,0x52,0x52,0xbd,0x7e,0x7e,0x7e,0xc7,0x52,0x52,0x52,0xbd,0x87,0x00,0x00,0x00,0xb3,0x02,0x33,0x33,0x33,0xb8,0x7e,0x7e,0x7e,0xc7,0x6a,0x6a,0x6a, + 0xc2,0x88,0x00,0x00,0x00,0xb3,0x00,0x33,0x33,0x33,0xb8,0x81,0x7e,0x7e,0x7e,0xc7,0x86,0x00,0x00,0x00,0xb3,0x02,0x6a,0x6a,0x6a,0xc2,0x7e,0x7e,0x7e,0xc7,0x33,0x33, + 0x33,0xb8,0xa0,0x00,0x00,0x00,0xb3,0x00,0x33,0x33,0x33,0xb8,0x81,0x7e,0x7e,0x7e,0xc7,0x00,0x33,0x33,0x33,0xb8,0x92,0x00,0x00,0x00,0xb3,0x00,0x52,0x52,0x52,0xbd, + 0x81,0x7e,0x7e,0x7e,0xc7,0x8f,0x00,0x00,0x00,0xb3,0x81,0x7e,0x7e,0x7e,0xc7,0x00,0x33,0x33,0x33,0xb8,0x99,0x00,0x00,0x00,0xb3,0x02,0x6a,0x6a,0x6a,0xc2,0x7e,0x7e, + 0x7e,0xc7,0x52,0x52,0x52,0xbd,0x84,0x00,0x00,0x00,0xb3,0x02,0x33,0x33,0x33,0xb8,0x7e,0x7e,0x7e,0xc7,0x6a,0x6a,0x6a,0xc2,0x87,0x00,0x00,0x00,0xb3,0x02,0x52,0x52, + 0x52,0xbd,0x7e,0x7e,0x7e,0xc7,0x52,0x52,0x52,0xbd,0x86,0x00,0x00,0x00,0xb3,0x00,0x6a,0x6a,0x6a,0xc2,0x81,0x7e,0x7e,0x7e,0xc7,0x86,0x00,0x00,0x00,0xb3,0x00,0x33, + 0x33,0x33,0xb8,0x81,0x7e,0x7e,0x7e,0xc7,0x86,0x00,0x00,0x00,0xb3,0x00,0x52,0x52,0x52,0xbd,0x81,0x7e,0x7e,0x7e,0xc7,0x8a,0x00,0x00,0x00,0xb3,0x02,0x33,0x33,0x33, + 0xb8,0x7e,0x7e,0x7e,0xc7,0x6a,0x6a,0x6a,0xc2,0x87,0x00,0x00,0x00,0xb3,0x02,0x6a,0x6a,0x6a,0xc2,0x7e,0x7e,0x7e,0xc7,0x52,0x52,0x52,0xbd,0x8c,0x00,0x00,0x00,0xb3, + 0x00,0x33,0x33,0x33,0xb8,0x81,0x7e,0x7e,0x7e,0xc7,0x00,0x33,0x33,0x33,0xb8,0x8e,0x00,0x00,0x00,0xb3,0x81,0x7e,0x7e,0x7e,0xc7,0x00,0x33,0x33,0x33,0xb8,0x8a,0x00, + 0x00,0x00,0xb3,0x02,0x6a,0x6a,0x6a,0xc2,0x7e,0x7e,0x7e,0xc7,0x33,0x33,0x33,0xb8,0x85,0x00,0x00,0x00,0xb3,0x00,0x33,0x33,0x33,0xb8,0x81,0x7e,0x7e,0x7e,0xc7,0x00, + 0x52,0x52,0x52,0xbd,0x86,0x00,0x00,0x00,0xb3,0x02,0x6a,0x6a,0x6a,0xc2,0x7e,0x7e,0x7e,0xc7,0x52,0x52,0x52,0xbd,0x9f,0x00,0x00,0x00,0xb3,0x81,0x7e,0x7e,0x7e,0xc7, + 0x00,0x33,0x33,0x33,0xb8,0x84,0x00,0x00,0x00,0xb3,0x02,0x52,0x52,0x52,0xbd,0x7e,0x7e,0x7e,0xc7,0x52,0x52,0x52,0xbd,0x87,0x00,0x00,0x00,0xb3,0x02,0x6a,0x6a,0x6a, + 0xc2,0x7e,0x7e,0x7e,0xc7,0x33,0x33,0x33,0xb8,0x86,0x00,0x00,0x00,0xb3,0x81,0x7e,0x7e,0x7e,0xc7,0x00,0x6a,0x6a,0x6a,0xc2,0x86,0x00,0x00,0x00,0xb3,0x02,0x52,0x52, + 0x52,0xbd,0x7e,0x7e,0x7e,0xc7,0x6a,0x6a,0x6a,0xc2,0x86,0x00,0x00,0x00,0xb3,0x02,0x6a,0x6a,0x6a,0xc2,0x7e,0x7e,0x7e,0xc7,0x6a,0x6a,0x6a,0xc2,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xb7,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xb7,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81, + 0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff, + 0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x01,0x52,0x52,0x52,0xbd,0xd2,0xd2,0xd2,0xe6,0x82,0xff,0xff,0xff,0xff,0x02,0xf7,0xf7,0xf7,0xfa,0xaf, + 0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x00,0xbb,0xbb,0xbb,0xdc,0x82,0xff,0xff,0xff,0xff, + 0x00,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0xff,0xff,0xff,0xff,0x01,0xdc, + 0xdc,0xdc,0xeb,0xbb,0xbb,0xbb,0xdc,0x81,0xff,0xff,0xff,0xff,0x82,0x00,0x00,0x00,0xb3,0x01,0x52,0x52,0x52,0xbd,0xd2,0xd2,0xd2,0xe6,0x82,0xff,0xff,0xff,0xff,0x01, + 0xf7,0xf7,0xf7,0xfa,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x01,0x6a,0x6a,0x6a,0xc2,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x01,0xf7,0xf7,0xf7,0xfa, + 0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x88,0x00,0x00,0x00,0xb3,0x00,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x00,0x6a,0x6a, + 0x6a,0xc2,0x81,0x00,0x00,0x00,0xb3,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x00,0xa0,0xa0,0xa0,0xd1,0x82,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb, + 0x81,0xff,0xff,0xff,0xff,0x82,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x83,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff, + 0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x87,0x00,0x00,0x00,0xb3,0x00,0xd2,0xd2,0xd2,0xe6, + 0x82,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e, + 0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x02,0x33,0x33,0x33,0xb8,0xbb,0xbb,0xbb,0xdc,0xf7,0xf7,0xf7,0xfa,0x82,0xff,0xff, + 0xff,0xff,0x01,0xc7,0xc7,0xc7,0xe1,0x33,0x33,0x33,0xb8,0x86,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x84,0x00,0x00,0x00,0xb3,0x00, + 0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x01,0xaf,0xaf,0xaf,0xd6,0xef,0xef,0xef,0xf5,0x82,0xff,0xff,0xff, + 0xff,0x01,0xdc,0xdc,0xdc,0xeb,0x6a,0x6a,0x6a,0xc2,0x81,0x00,0x00,0x00,0xb3,0x00,0xbb,0xbb,0xbb,0xdc,0x82,0xff,0xff,0xff,0xff,0x01,0xef,0xef,0xef,0xf5,0xd2,0xd2, + 0xd2,0xe6,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x01,0x33,0x33,0x33,0xb8,0xd2,0xd2,0xd2,0xe6,0x82,0xff,0xff,0xff,0xff,0x06,0xbb,0xbb,0xbb,0xdc,0xdc, + 0xdc,0xdc,0xeb,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0x90,0x90,0x90,0xcc,0xef,0xef,0xef,0xf5,0x83,0xff,0xff,0xff,0xff,0x00,0xbb,0xbb,0xbb, + 0xdc,0x82,0x00,0x00,0x00,0xb3,0x01,0x52,0x52,0x52,0xbd,0xd2,0xd2,0xd2,0xe6,0x82,0xff,0xff,0xff,0xff,0x01,0xf7,0xf7,0xf7,0xfa,0xaf,0xaf,0xaf,0xd6,0x83,0x00,0x00, + 0x00,0xb3,0x00,0xd2,0xd2,0xd2,0xe6,0x82,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x85,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff, + 0x01,0xa0,0xa0,0xa0,0xd1,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x01,0xe6,0xe6,0xe6,0xf0,0x6a,0x6a,0x6a,0xc2,0x83,0x00,0x00,0x00,0xb3,0x01,0xaf,0xaf,0xaf, + 0xd6,0xef,0xef,0xef,0xf5,0x82,0xff,0xff,0xff,0xff,0x01,0xdc,0xdc,0xdc,0xeb,0x6a,0x6a,0x6a,0xc2,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff, + 0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x01,0x33,0x33,0x33,0xb8,0xc7,0xc7,0xc7,0xe1,0x83,0xff,0xff,0xff,0xff,0x01,0xc7,0xc7,0xc7,0xe1,0x33, + 0x33,0x33,0xb8,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x83,0x00,0x00,0x00,0xb3,0x02,0x33,0x33,0x33, + 0xb8,0xbb,0xbb,0xbb,0xdc,0xf7,0xf7,0xf7,0xfa,0x82,0xff,0xff,0xff,0xff,0x01,0xc7,0xc7,0xc7,0xe1,0x33,0x33,0x33,0xb8,0x86,0x00,0x00,0x00,0xb3,0x01,0x33,0x33,0x33, + 0xb8,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x01,0xf7,0xf7,0xf7,0xfa,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x33,0x33,0x33, + 0xb8,0xc7,0xc7,0xc7,0xe1,0x83,0xff,0xff,0xff,0xff,0x01,0xef,0xef,0xef,0xf5,0x6a,0x6a,0x6a,0xc2,0x82,0x00,0x00,0x00,0xb3,0x01,0xaf,0xaf,0xaf,0xd6,0xef,0xef,0xef, + 0xf5,0x82,0xff,0xff,0xff,0xff,0x01,0xdc,0xdc,0xdc,0xeb,0x6a,0x6a,0x6a,0xc2,0x81,0x00,0x00,0x00,0xb3,0x03,0x90,0x90,0x90,0xcc,0xf7,0xf7,0xf7,0xfa,0xef,0xef,0xef, + 0xf5,0x52,0x52,0x52,0xbd,0x86,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x84,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff, + 0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x02,0x33,0x33,0x33,0xb8,0xbb,0xbb,0xbb,0xdc,0xf7,0xf7,0xf7,0xfa,0x82,0xff,0xff,0xff,0xff,0x04, + 0xc7,0xc7,0xc7,0xe1,0x33,0x33,0x33,0xb8,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x03,0xdc,0xdc,0xdc,0xeb,0xe6,0xe6, + 0xe6,0xf0,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x01,0x6a,0x6a,0x6a,0xc2,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x01,0xf7,0xf7, + 0xf7,0xfa,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x03,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0xf7,0xf7,0xf7,0xfa,0x82,0xff,0xff,0xff, + 0xff,0x01,0xf7,0xf7,0xf7,0xfa,0xa0,0xa0,0xa0,0xd1,0x82,0x00,0x00,0x00,0xb3,0x01,0x7e,0x7e,0x7e,0xc7,0xe6,0xe6,0xe6,0xf0,0x82,0xff,0xff,0xff,0xff,0x01,0xef,0xef, + 0xef,0xf5,0x90,0x90,0x90,0xcc,0x82,0x00,0x00,0x00,0xb3,0x01,0x52,0x52,0x52,0xbd,0xe6,0xe6,0xe6,0xf0,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xb6,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xb7,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc, + 0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81, + 0xff,0xff,0xff,0xff,0x03,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0x84,0xff,0xff,0xff,0xff,0x01,0xc7,0xc7,0xc7,0xe1,0x00, + 0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0x6a,0x6a,0x6a,0xc2,0x86,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81, + 0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x87,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x01,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff, + 0xff,0x01,0xdc,0xdc,0xdc,0xeb,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x03,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa, + 0x86,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x87,0x00,0x00,0x00,0xb3,0x00,0x6a,0x6a,0x6a,0xc2,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00, + 0x00,0x00,0xb3,0x00,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff, + 0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0x52,0x52,0x52,0xbd,0x84,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00, + 0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x86,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x83,0xff,0xff,0xff, + 0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff, + 0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff, + 0x00,0xaf,0xaf,0xaf,0xd6,0x86,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x84,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff, + 0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x01,0xef,0xef,0xef,0xf5,0xdc,0xdc,0xdc,0xeb, + 0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0xaf,0xaf,0xaf,0xd6, + 0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x86,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00, + 0xb3,0x6a,0x6a,0x6a,0xc2,0x81,0xff,0xff,0xff,0xff,0x01,0xdc,0xdc,0xdc,0xeb,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x03,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00, + 0xb3,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x01,0xdc,0xdc,0xdc,0xeb,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e, + 0xc7,0x81,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x83,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x85,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x86, + 0xff,0xff,0xff,0xff,0x01,0xf7,0xf7,0xf7,0xfa,0x33,0x33,0x33,0xb8,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x01,0xef,0xef,0xef, + 0xf5,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf, + 0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x00,0xe6,0xe6,0xe6,0xf0,0x85,0xff,0xff,0xff,0xff,0x00,0xe6,0xe6,0xe6,0xf0,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf, + 0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x83,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0xe6,0xe6,0xe6,0xf0,0x81, + 0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x86,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x86,0xff,0xff,0xff,0xff,0x05,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00, + 0xb3,0xd2,0xd2,0xd2,0xe6,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x03,0xf7,0xf7,0xf7,0xfa,0x33,0x33,0x33,0xb8,0x00, + 0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x01,0xef,0xef,0xef,0xf5,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81, + 0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x86,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc, + 0xdc,0xeb,0x84,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb, + 0x81,0xff,0xff,0xff,0xff,0x81,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff, + 0xff,0x02,0xc7,0xc7,0xc7,0xe1,0xaf,0xaf,0xaf,0xd6,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x03,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8, + 0xf7,0xf7,0xf7,0xfa,0x86,0xff,0xff,0xff,0xff,0x06,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0xdc,0xdc, + 0xdc,0xeb,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x05,0xf7,0xf7, + 0xf7,0xfa,0xdc,0xdc,0xdc,0xeb,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0x33,0x33,0x33,0xb8,0x81,0x00,0x00,0x00,0xb3,0x00,0xc7,0xc7,0xc7,0xe1, + 0x83,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xb6,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xb7,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc, + 0xeb,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff, + 0xff,0xff,0x03,0xd2,0xd2,0xd2,0xe6,0x7e,0x7e,0x7e,0xc7,0xa0,0xa0,0xa0,0xd1,0xc7,0xc7,0xc7,0xe1,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc, + 0xdc,0xeb,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0xe6,0xe6,0xe6,0xf0,0x7e,0x7e,0x7e,0xc7,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff, + 0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x00,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x03,0xaf,0xaf,0xaf,0xd6,0x7e,0x7e,0x7e,0xc7,0xa0,0xa0, + 0xa0,0xd1,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x00,0x6a,0x6a,0x6a,0xc2,0x81, + 0x00,0x00,0x00,0xb3,0x01,0xbb,0xbb,0xbb,0xdc,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x03,0xe6,0xe6,0xe6, + 0xf0,0x90,0x90,0x90,0xcc,0x7e,0x7e,0x7e,0xc7,0xd2,0xd2,0xd2,0xe6,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x87,0x00,0x00,0x00,0xb3,0x00,0xbb,0xbb,0xbb, + 0xdc,0x82,0xff,0xff,0xff,0xff,0x02,0xe6,0xe6,0xe6,0xf0,0x00,0x00,0x00,0xb3,0x6a,0x6a,0x6a,0xc2,0x83,0xff,0xff,0xff,0xff,0x00,0x52,0x52,0x52,0xbd,0x81,0x00,0x00, + 0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x04,0xd2,0xd2,0xd2,0xe6, + 0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81, + 0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x86,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x04,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00, + 0xb3,0x33,0x33,0x33,0xb8,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff, + 0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x01,0xa0,0xa0, + 0xa0,0xd1,0xaf,0xaf,0xaf,0xd6,0x87,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x84,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81, + 0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0x52,0x52,0x52,0xbd,0x81,0xff,0xff,0xff,0xff,0x00,0xd2,0xd2,0xd2,0xe6,0x81,0x00,0x00,0x00,0xb3, + 0x04,0x6a,0x6a,0x6a,0xc2,0xbb,0xbb,0xbb,0xdc,0x33,0x33,0x33,0xb8,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x82,0x00,0x00,0x00,0xb3,0x00, + 0xd2,0xd2,0xd2,0xe6,0x81,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0xb3,0x6a,0x6a,0x6a,0xc2,0x81,0xff,0xff,0xff,0xff,0x03,0xf7,0xf7,0xf7,0xfa,0xa0,0xa0,0xa0,0xd1, + 0x7e,0x7e,0x7e,0xc7,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x03,0xa0,0xa0,0xa0,0xd1,0x6a,0x6a,0x6a,0xc2, + 0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x00, + 0x6a,0x6a,0x6a,0xc2,0x81,0x00,0x00,0x00,0xb3,0x01,0xbb,0xbb,0xbb,0xdc,0x7e,0x7e,0x7e,0xc7,0x82,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff, + 0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0x85,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x03,0xd2,0xd2, + 0xd2,0xe6,0x7e,0x7e,0x7e,0xc7,0x90,0x90,0x90,0xcc,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0x52,0x52,0x52,0xbd, + 0x81,0xff,0xff,0xff,0xff,0x00,0xd2,0xd2,0xd2,0xe6,0x81,0x00,0x00,0x00,0xb3,0x02,0x6a,0x6a,0x6a,0xc2,0xbb,0xbb,0xbb,0xdc,0x33,0x33,0x33,0xb8,0x81,0x00,0x00,0x00, + 0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x00, + 0xe6,0xe6,0xe6,0xf0,0x81,0x90,0x90,0x90,0xcc,0x00,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x02,0xa0,0xa0,0xa0,0xd1,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6, + 0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00, + 0x00,0x00,0xb3,0x01,0xa0,0xa0,0xa0,0xd1,0xaf,0xaf,0xaf,0xd6,0x87,0x00,0x00,0x00,0xb3,0x00,0xd2,0xd2,0xd2,0xe6,0x81,0xff,0xff,0xff,0xff,0x02,0xc7,0xc7,0xc7,0xe1, + 0x7e,0x7e,0x7e,0xc7,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x03,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0xaf,0xaf,0xaf,0xd6,0x81,0x00, + 0x00,0x00,0xb3,0x00,0xbb,0xbb,0xbb,0xdc,0x81,0xff,0xff,0xff,0xff,0x01,0x7e,0x7e,0x7e,0xc7,0x52,0x52,0x52,0xbd,0x81,0xff,0xff,0xff,0xff,0x00,0xd2,0xd2,0xd2,0xe6, + 0x81,0x00,0x00,0x00,0xb3,0x02,0x6a,0x6a,0x6a,0xc2,0xbb,0xbb,0xbb,0xdc,0x33,0x33,0x33,0xb8,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff, + 0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x86,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x84,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81, + 0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3, + 0x01,0xa0,0xa0,0xa0,0xd1,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x02,0xdc,0xdc,0xdc,0xeb,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3, + 0x05,0x33,0x33,0x33,0xb8,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x03,0xe6, + 0xe6,0xe6,0xf0,0x90,0x90,0x90,0xcc,0x7e,0x7e,0x7e,0xc7,0xd2,0xd2,0xd2,0xe6,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x03,0xaf, + 0xaf,0xaf,0xd6,0x33,0x33,0x33,0xb8,0x00,0x00,0x00,0xb3,0x90,0x90,0x90,0xcc,0x81,0xff,0xff,0xff,0xff,0x09,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xef,0xef,0xef, + 0xf5,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0x33,0x33,0x33,0xb8,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0xc7,0xc7,0xc7,0xe1,0x52,0x52,0x52,0xbd,0x82,0x00,0x00, + 0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x02,0x6a,0x6a,0x6a,0xc2,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xb6,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xb7,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff, + 0xff,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x04, + 0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0x85,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x02,0xdc, + 0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0x90,0x90,0x90,0xcc,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0x81,0xff,0xff, + 0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xc7,0xc7,0xc7,0xe1,0x82,0x00,0x00,0x00,0xb3,0x00,0xa0, + 0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x02,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0x84,0xaf,0xaf,0xaf,0xd6,0x02, + 0xa0,0xa0,0xa0,0xd1,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x00,0x52,0x52,0x52,0xbd,0x82,0x00,0x00,0x00,0xb3,0x02,0xef,0xef,0xef,0xf5, + 0xff,0xff,0xff,0xff,0xaf,0xaf,0xaf,0xd6,0x87,0x00,0x00,0x00,0xb3,0x02,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x06, + 0x33,0x33,0x33,0xb8,0xbb,0xbb,0xbb,0xdc,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00, + 0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82, + 0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf, + 0xaf,0xd6,0x86,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb, + 0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xd2,0xd2,0xd2, + 0xe6,0x81,0xff,0xff,0xff,0xff,0x85,0xaf,0xaf,0xaf,0xd6,0x86,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x84,0x00,0x00,0x00,0xb3,0x00, + 0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0xc7,0xc7,0xc7,0xe1, + 0x84,0xaf,0xaf,0xaf,0xd6,0x01,0x52,0x52,0x52,0xbd,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x03,0xd2,0xd2,0xd2,0xe6,0x90,0x90,0x90,0xcc,0x7e,0x7e,0x7e,0xc7, + 0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0xa0,0xa0,0xa0,0xd1,0x82,0x00,0x00,0x00, + 0xb3,0x02,0xc7,0xc7,0xc7,0xe1,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x03,0x33,0x33,0x33,0xb8,0xaf,0xaf,0xaf,0xd6,0xd2,0xd2,0xd2,0xe6, + 0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x04,0xc7,0xc7,0xc7,0xe1,0x00,0x00,0x00,0xb3,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0x84,0xaf, + 0xaf,0xaf,0xd6,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x87,0x00,0x00,0x00, + 0xb3,0x02,0xaf,0xaf,0xaf,0xd6,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0x82,0x00,0x00,0x00,0xb3,0x00,0x52,0x52,0x52,0xbd,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc, + 0xdc,0xeb,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0xc7,0xc7,0xc7,0xe1,0x84,0xaf,0xaf,0xaf,0xd6,0x02,0x52,0x52,0x52,0xbd,0x00,0x00, + 0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xd2,0xd2,0xd2,0xe6,0x81,0xff,0xff,0xff,0xff,0x00, + 0x52,0x52,0x52,0xbd,0x81,0x00,0x00,0x00,0xb3,0x00,0x52,0x52,0x52,0xbd,0x81,0xff,0xff,0xff,0xff,0x02,0xd2,0xd2,0xd2,0xe6,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6, + 0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0x00,0x00,0x00,0xb3,0x00,0xd2,0xd2,0xd2,0xe6,0x81,0xff,0xff,0xff,0xff,0x85,0xaf,0xaf,0xaf,0xd6,0x86,0x00, + 0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x02,0x33,0x33,0x33,0xb8,0x00,0x00,0x00,0xb3,0x90,0x90,0x90,0xcc,0x81,0xff,0xff,0xff,0xff,0x00, + 0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x02,0x7e,0x7e,0x7e,0xc7,0xbb,0xbb,0xbb,0xdc,0xe6,0xe6,0xe6,0xf0,0x82,0xff,0xff,0xff,0xff,0x01,0x52,0x52,0x52,0xbd, + 0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0xc7,0xc7,0xc7,0xe1,0x84,0xaf,0xaf,0xaf,0xd6,0x00,0x52,0x52,0x52,0xbd,0x81,0x00,0x00,0x00,0xb3,0x01,0x6a,0x6a, + 0x6a,0xc2,0x52,0x52,0x52,0xbd,0x87,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x84,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81, + 0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0xd2,0xd2,0xd2,0xe6,0x81,0xff,0xff,0xff,0xff,0x85,0xaf,0xaf,0xaf,0xd6,0x01,0x00,0x00,0x00,0xb3, + 0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0xbb,0xbb,0xbb,0xdc,0x81,0x7e,0x7e,0x7e,0xc7,0x04,0xe6,0xe6,0xe6,0xf0,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb, + 0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x00,0x52,0x52,0x52,0xbd,0x82,0x00,0x00,0x00,0xb3,0x02,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff, + 0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x02,0x52,0x52,0x52,0xbd,0xaf,0xaf,0xaf,0xd6,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x01,0xa0,0xa0,0xa0,0xd1, + 0x6a,0x6a,0x6a,0xc2,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x84,0xaf,0xaf,0xaf,0xd6,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc, + 0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xb9,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xb7,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00, + 0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x01,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb, + 0x85,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e, + 0xc7,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf, + 0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x87,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb, + 0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x83,0x00,0x00,0x00,0xb3,0x02,0xdc,0xdc,0xdc,0xeb,0xff,0xff,0xff,0xff,0xaf,0xaf,0xaf,0xd6,0x86, + 0x00,0x00,0x00,0xb3,0x00,0x90,0x90,0x90,0xcc,0x81,0xff,0xff,0xff,0xff,0x09,0xaf,0xaf,0xaf,0xd6,0xe6,0xe6,0xe6,0xf0,0xff,0xff,0xff,0xff,0x90,0x90,0x90,0xcc,0xef, + 0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xbb,0xbb,0xbb,0xdc,0xd2,0xd2,0xd2,0xe6,0xff,0xff,0xff,0xff,0xe6,0xe6,0xe6,0xf0,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc, + 0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x00, + 0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x86,0x00,0x00, + 0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff, + 0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x87,0xff,0xff,0xff, + 0xff,0x86,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x84,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02, + 0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x87,0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x86,0xff, + 0xff,0xff,0xff,0x01,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0x00,0x00,0x00,0xb3,0x02,0xaf,0xaf,0xaf,0xd6, + 0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x00,0xe6,0xe6,0xe6,0xf0,0x83,0xff,0xff,0xff,0xff,0x02,0xef,0xef,0xef,0xf5,0x6a,0x6a,0x6a,0xc2, + 0x00,0x00,0x00,0xb3,0x87,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e, + 0x7e,0xc7,0x87,0x00,0x00,0x00,0xb3,0x02,0xaf,0xaf,0xaf,0xd6,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0x83,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x02,0xdc, + 0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x87,0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff, + 0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x83,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff, + 0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc, + 0xeb,0x87,0xff,0xff,0xff,0xff,0x86,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81, + 0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0x90,0x90,0x90,0xcc,0x84,0xff,0xff,0xff,0xff,0x02,0xbb,0xbb,0xbb,0xdc,0x00,0x00,0x00,0xb3,0xaf, + 0xaf,0xaf,0xd6,0x87,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x8b,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x84,0x00,0x00,0x00, + 0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x87,0xff,0xff,0xff,0xff,0x02,0x00,0x00, + 0x00,0xb3,0x33,0x33,0x33,0xb8,0xd2,0xd2,0xd2,0xe6,0x85,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff, + 0xff,0x83,0x00,0x00,0x00,0xb3,0x05,0xdc,0xdc,0xdc,0xeb,0xff,0xff,0xff,0xff,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0x52,0x52,0x52,0xbd,0xf7,0xf7,0xf7,0xfa,0x83, + 0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x33,0x33,0x33,0xb8,0x7e,0x7e,0x7e,0xc7,0x87,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3, + 0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xb9,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xb7,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xef,0xef,0xef, + 0xf5,0x81,0x00,0x00,0x00,0xb3,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x05,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0xef,0xef,0xef,0xf5,0xff,0xff,0xff, + 0xff,0xf7,0xf7,0xf7,0xfa,0x33,0x33,0x33,0xb8,0x81,0x00,0x00,0x00,0xb3,0x00,0x33,0x33,0x33,0xb8,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc, + 0xdc,0xeb,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x02,0xdc, + 0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0x52,0x52,0x52,0xbd,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81, + 0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x02,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0x82,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff, + 0x02,0xd2,0xd2,0xd2,0xe6,0x00,0x00,0x00,0xb3,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x03,0x33,0x33,0x33, + 0xb8,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xaf,0xaf,0xaf,0xd6,0x86,0x00,0x00,0x00,0xb3,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x03,0x52,0x52,0x52, + 0xbd,0xbb,0xbb,0xbb,0xdc,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x01,0x7e,0x7e,0x7e,0xc7,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff, + 0x02,0x6a,0x6a,0x6a,0xc2,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff, + 0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x02,0x52,0x52,0x52,0xbd,0x00,0x00,0x00,0xb3,0xa0,0xa0, + 0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x86,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7, + 0x82,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x02,0x52,0x52,0x52,0xbd,0x00,0x00,0x00,0xb3,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff, + 0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x00,0x90,0x90,0x90,0xcc,0x81,0x7e,0x7e,0x7e,0xc7,0x02,0xe6,0xe6, + 0xe6,0xf0,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0x86,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x84,0xaf,0xaf,0xaf,0xd6,0x00,0xc7, + 0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81, + 0x7e,0x7e,0x7e,0xc7,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x00,0x6a,0x6a,0x6a,0xc2,0x81,0x00,0x00,0x00,0xb3,0x01,0x33,0x33,0x33,0xb8,0x7e,0x7e,0x7e, + 0xc7,0x81,0xaf,0xaf,0xaf,0xd6,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0xb3,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x00,0xaf, + 0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x04,0xdc,0xdc,0xdc,0xeb,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff, + 0xff,0xff,0x02,0xf7,0xf7,0xf7,0xfa,0xbb,0xbb,0xbb,0xdc,0x90,0x90,0x90,0xcc,0x82,0x00,0x00,0x00,0xb3,0x02,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xef,0xef,0xef, + 0xf5,0x82,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xd2,0xd2,0xd2,0xe6,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00, + 0x7e,0x7e,0x7e,0xc7,0x87,0x00,0x00,0x00,0xb3,0x03,0xaf,0xaf,0xaf,0xd6,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0x33,0x33,0x33,0xb8,0x81,0x00,0x00,0x00,0xb3,0x00, + 0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xc7,0xc7,0xc7,0xe1,0x00,0x00,0x00,0xb3,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6, + 0x81,0x7e,0x7e,0x7e,0xc7,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x02,0x6a,0x6a,0x6a,0xc2,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff, + 0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x00, + 0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xc7,0xc7,0xc7,0xe1,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0xbb,0xbb,0xbb,0xdc, + 0x82,0x00,0x00,0x00,0xb3,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x00,0x90,0x90,0x90,0xcc,0x81,0x7e,0x7e,0x7e,0xc7,0x02,0xe6,0xe6,0xe6,0xf0,0xff,0xff, + 0xff,0xff,0xf7,0xf7,0xf7,0xfa,0x86,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81, + 0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0xaf,0xaf,0xaf,0xd6,0x52, + 0x52,0x52,0xbd,0x81,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x7e,0x7e,0x7e,0xc7,0x00,0xc7,0xc7,0xc7, + 0xe1,0x81,0xff,0xff,0xff,0xff,0x00,0x6a,0x6a,0x6a,0xc2,0x8b,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xef,0xef,0xef,0xf5,0x84,0xaf,0xaf,0xaf,0xd6,0x00, + 0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x00,0x90,0x90,0x90,0xcc, + 0x81,0x7e,0x7e,0x7e,0xc7,0x02,0xe6,0xe6,0xe6,0xf0,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0x82,0x00,0x00,0x00,0xb3,0x01,0x52,0x52,0x52,0xbd,0x90,0x90,0x90,0xcc, + 0x81,0xaf,0xaf,0xaf,0xd6,0x04,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x00, + 0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x05,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xaf,0xaf, + 0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0xef,0xef,0xef,0xf5,0xaf,0xaf,0xaf,0xd6,0x6a,0x6a,0x6a,0xc2,0x81,0x00,0x00,0x00,0xb3,0x00,0x52,0x52,0x52,0xbd,0x81,0xff, + 0xff,0xff,0xff,0x00,0xd2,0xd2,0xd2,0xe6,0x81,0x7e,0x7e,0x7e,0xc7,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00, + 0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xb9,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xb7,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x82,0xff,0xff,0xff,0xff,0x01,0xd2,0xd2, + 0xd2,0xe6,0xbb,0xbb,0xbb,0xdc,0x82,0xff,0xff,0xff,0xff,0x02,0x52,0x52,0x52,0xbd,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x05,0xef,0xef, + 0xef,0xf5,0xaf,0xaf,0xaf,0xd6,0xc7,0xc7,0xc7,0xe1,0xe6,0xe6,0xe6,0xf0,0x33,0x33,0x33,0xb8,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb, + 0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc, + 0xeb,0x81,0x00,0x00,0x00,0xb3,0x00,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0xaf,0xaf,0xaf,0xd6,0xc7,0xc7,0xc7,0xe1,0x82,0xff,0xff, + 0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0xa0,0xa0,0xa0,0xd1,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff, + 0xff,0xff,0xff,0x02,0xa0,0xa0,0xa0,0xd1,0x00,0x00,0x00,0xb3,0x90,0x90,0x90,0xcc,0x81,0xff,0xff,0xff,0xff,0x03,0xf7,0xf7,0xf7,0xfa,0xbb,0xbb,0xbb,0xdc,0xaf,0xaf, + 0xaf,0xd6,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x85,0x00,0x00,0x00,0xb3,0x00,0x33,0x33,0x33,0xb8,0x81,0xff,0xff,0xff,0xff,0x02, + 0xe6,0xe6,0xe6,0xf0,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x02,0xf7,0xf7,0xf7,0xfa,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0x81,0xff, + 0xff,0xff,0xff,0x02,0xbb,0xbb,0xbb,0xdc,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x02,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0xc7,0xc7, + 0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xaf,0xaf,0xaf,0xd6,0x01,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x02, + 0xe6,0xe6,0xe6,0xf0,0xaf,0xaf,0xaf,0xd6,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x00,0xa0,0xa0,0xa0,0xd1,0x84,0x00,0x00,0x00,0xb3,0x02,0x52,0x52,0x52,0xbd, + 0xaf,0xaf,0xaf,0xd6,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x04,0xc7,0xc7,0xc7,0xe1,0xaf,0xaf,0xaf,0xd6,0xa0,0xa0,0xa0,0xd1,0x00,0x00,0x00,0xb3,0xdc,0xdc, + 0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x02,0xe6,0xe6,0xe6,0xf0,0xaf,0xaf,0xaf,0xd6,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x02,0xa0,0xa0,0xa0,0xd1,0x00,0x00, + 0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xc7,0xc7,0xc7,0xe1,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xc7,0xc7, + 0xc7,0xe1,0x86,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x89,0xff,0xff,0xff,0xff,0x0a,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0xf7,0xf7, + 0xf7,0xfa,0xff,0xff,0xff,0xff,0xe6,0xe6,0xe6,0xf0,0x33,0x33,0x33,0xb8,0x52,0x52,0x52,0xbd,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0x82,0x00, + 0x00,0x00,0xb3,0x08,0xaf,0xaf,0xaf,0xd6,0x52,0x52,0x52,0xbd,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0xdc,0xdc,0xdc,0xeb,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb, + 0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0x82,0xff,0xff,0xff,0xff,0x02,0xc7,0xc7,0xc7,0xe1,0xaf,0xaf,0xaf,0xd6,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x02, + 0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x03,0xc7,0xc7,0xc7,0xe1,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0xa0,0xa0, + 0xa0,0xd1,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0xa0,0xa0,0xa0,0xd1,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff, + 0xff,0xff,0xff,0x03,0xa0,0xa0,0xa0,0xd1,0x52,0x52,0x52,0xbd,0xaf,0xaf,0xaf,0xd6,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x02,0xc7,0xc7,0xc7,0xe1,0xaf,0xaf, + 0xaf,0xd6,0xa0,0xa0,0xa0,0xd1,0x85,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x03,0xef,0xef,0xef,0xf5,0xaf,0xaf,0xaf,0xd6,0xbb,0xbb, + 0xbb,0xdc,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x0d,0xa0,0xa0,0xa0,0xd1,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff, + 0xe6,0xe6,0xe6,0xf0,0x33,0x33,0x33,0xb8,0x52,0x52,0x52,0xbd,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6, + 0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x01,0xdc,0xdc,0xdc,0xeb,0xaf,0xaf,0xaf,0xd6,0x81,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xf7,0xf7,0xf7, + 0xfa,0x81,0xbb,0xbb,0xbb,0xdc,0x00,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x82,0xff,0xff, + 0xff,0xff,0x03,0xc7,0xc7,0xc7,0xe1,0xaf,0xaf,0xaf,0xd6,0xa0,0xa0,0xa0,0xd1,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xc7,0xc7,0xc7,0xe1,0x00,0x00,0x00, + 0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xc7,0xc7,0xc7,0xe1,0x86,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00, + 0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x0d, + 0x52,0x52,0x52,0xbd,0x33,0x33,0x33,0xb8,0xaf,0xaf,0xaf,0xd6,0x33,0x33,0x33,0xb8,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff, + 0xe6,0xe6,0xe6,0xf0,0x33,0x33,0x33,0xb8,0x52,0x52,0x52,0xbd,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0x8c,0x00,0x00,0x00,0xb3,0x8a,0xff,0xff, + 0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xc7,0xc7,0xc7,0xe1,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e, + 0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0x00,0x00,0x00,0xb3,0x09,0x33,0x33,0x33,0xb8,0xaf,0xaf,0xaf,0xd6,0x33,0x33,0x33,0xb8,0x00,0x00,0x00, + 0xb3,0x52,0x52,0x52,0xbd,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0x90,0x90,0x90,0xcc,0x81,0xff,0xff,0xff,0xff,0x03,0xf7, + 0xf7,0xf7,0xfa,0xbb,0xbb,0xbb,0xdc,0xaf,0xaf,0xaf,0xd6,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf, + 0xd6,0x81,0xff,0xff,0xff,0xff,0x03,0xa0,0xa0,0xa0,0xd1,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x6a,0x6a,0x6a,0xc2,0x81,0x00,0x00,0x00,0xb3,0x05,0xdc,0xdc,0xdc, + 0xeb,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0x6a,0x6a,0x6a,0xc2,0x33,0x33,0x33,0xb8,0xd2,0xd2,0xd2,0xe6,0x81,0xff,0xff,0xff,0xff,0x03,0x52,0x52,0x52,0xbd,0x7e, + 0x7e,0x7e,0xc7,0xaf,0xaf,0xaf,0xd6,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x81,0xaf,0xaf,0xaf,0xd6,0x00,0x7e,0x7e,0x7e,0xc7,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xb6,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xb7,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff, + 0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xf7,0xf7,0xf7,0xfa,0x83,0xff,0xff,0xff,0xff,0x00,0xef,0xef,0xef,0xf5,0x82,0x00,0x00,0x00,0xb3, + 0x00,0xe6,0xe6,0xe6,0xf0,0x84,0xff,0xff,0xff,0xff,0x01,0xe6,0xe6,0xe6,0xf0,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00, + 0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00, + 0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x87,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x01,0x33,0x33,0x33,0xb8,0xe6,0xe6,0xe6,0xf0,0x84,0xff,0xff,0xff,0xff, + 0x00,0xe6,0xe6,0xe6,0xf0,0x82,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x86,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x85,0x00,0x00,0x00,0xb3,0x00,0xa0, + 0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x82,0xff,0xff,0xff,0xff,0x00,0xd2,0xd2,0xd2,0xe6,0x81,0x00,0x00,0x00, + 0xb3,0x04,0xe6,0xe6,0xe6,0xf0,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0xb3, + 0x86,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x00,0xf7,0xf7,0xf7,0xfa,0x83,0xff,0xff,0xff,0xff,0x00,0x52,0x52, + 0x52,0xbd,0x84,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x85,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff, + 0xff,0xff,0xff,0x00,0xf7,0xf7,0xf7,0xfa,0x83,0xff,0xff,0xff,0xff,0x00,0x52,0x52,0x52,0xbd,0x81,0x00,0x00,0x00,0xb3,0x00,0xc7,0xc7,0xc7,0xe1,0x84,0xff,0xff,0xff, + 0xff,0x01,0xf7,0xf7,0xf7,0xfa,0x52,0x52,0x52,0xbd,0x86,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x89,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00, + 0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x85,0xff,0xff,0xff,0xff,0x00,0x90,0x90,0x90,0xcc,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff, + 0xff,0x01,0xdc,0xdc,0xdc,0xeb,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x86,0xff, + 0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x00,0xe6,0xe6,0xe6,0xf0,0x84,0xff,0xff,0xff,0xff,0x03,0xa0,0xa0,0xa0,0xd1,0x00,0x00,0x00,0xb3, + 0x33,0x33,0x33,0xb8,0xe6,0xe6,0xe6,0xf0,0x84,0xff,0xff,0xff,0xff,0x02,0xe6,0xe6,0xe6,0xf0,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x85,0xff,0xff,0xff,0xff,0x00, + 0xdc,0xdc,0xdc,0xeb,0x85,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x86,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0, + 0xa0,0xd1,0x85,0xff,0xff,0xff,0xff,0x01,0x90,0x90,0x90,0xcc,0x00,0x00,0x00,0xb3,0x85,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xc7,0xc7, + 0xc7,0xe1,0x85,0xff,0xff,0xff,0xff,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0xe6,0xe6,0xe6,0xf0, + 0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0xc7,0xc7,0xc7,0xe1,0x84,0xff,0xff,0xff,0xff,0x01,0xf7,0xf7,0xf7,0xfa,0x52,0x52,0x52,0xbd, + 0x86,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xaf, + 0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0x90,0x90,0x90,0xcc,0x84,0xff,0xff,0xff,0xff,0x03,0xe6,0xe6,0xe6,0xf0,0x33,0x33,0x33,0xb8,0x00,0x00,0x00,0xb3,0xa0,0xa0,0xa0, + 0xd1,0x85,0xff,0xff,0xff,0xff,0x00,0x90,0x90,0x90,0xcc,0x8c,0x00,0x00,0x00,0xb3,0x8a,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x00, + 0xc7,0xc7,0xc7,0xe1,0x84,0xff,0xff,0xff,0xff,0x01,0xf7,0xf7,0xf7,0xfa,0x52,0x52,0x52,0xbd,0x81,0x00,0x00,0x00,0xb3,0x04,0xdc,0xdc,0xdc,0xeb,0xff,0xff,0xff,0xff, + 0xf7,0xf7,0xf7,0xfa,0xdc,0xdc,0xdc,0xeb,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x00,0x52,0x52,0x52,0xbd,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb, + 0x86,0xff,0xff,0xff,0xff,0x03,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0x52,0x52,0x52,0xbd,0xf7,0xf7,0xf7,0xfa,0x83,0xff,0xff,0xff,0xff,0x04,0xf7,0xf7,0xf7,0xfa, + 0x6a,0x6a,0x6a,0xc2,0x00,0x00,0x00,0xb3,0x6a,0x6a,0x6a,0xc2,0xf7,0xf7,0xf7,0xfa,0x84,0xff,0xff,0xff,0xff,0x02,0xbb,0xbb,0xbb,0xdc,0x00,0x00,0x00,0xb3,0xaf,0xaf, + 0xaf,0xd6,0x85,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xb6,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xb7,0x00,0x00,0x00,0xb3,0x00,0xbb,0xbb,0xbb,0xdc,0x81,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x81,0xdc,0xdc,0xdc,0xeb,0x05,0xbb, + 0xbb,0xbb,0xdc,0xa0,0xa0,0xa0,0xd1,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0x6a,0x6a,0x6a,0xc2,0x83,0x00,0x00,0x00,0xb3,0x01,0xaf,0xaf,0xaf, + 0xd6,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x02,0xd2,0xd2,0xd2,0xe6,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc, + 0xeb,0x00,0x00,0x00,0xb3,0xa0,0xa0,0xa0,0xd1,0x81,0xdc,0xdc,0xdc,0xeb,0x00,0x6a,0x6a,0x6a,0xc2,0x81,0x00,0x00,0x00,0xb3,0x81,0xdc,0xdc,0xdc,0xeb,0x00,0xbb,0xbb, + 0xbb,0xdc,0x82,0x00,0x00,0x00,0xb3,0x05,0x90,0x90,0x90,0xcc,0xe6,0xe6,0xe6,0xf0,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0xaf,0xaf,0xaf,0xd6,0xdc,0xdc,0xdc,0xeb, + 0x81,0xff,0xff,0xff,0xff,0x82,0x00,0x00,0x00,0xb3,0x06,0x33,0x33,0x33,0xb8,0xaf,0xaf,0xaf,0xd6,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0xc7, + 0xc7,0xc7,0xe1,0x33,0x33,0x33,0xb8,0x82,0x00,0x00,0x00,0xb3,0x05,0x33,0x33,0x33,0xb8,0xc7,0xc7,0xc7,0xe1,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc, + 0xeb,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x85,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xdc,0xdc,0xdc,0xeb,0x00,0x52, + 0x52,0x52,0xbd,0x81,0x00,0x00,0x00,0xb3,0x00,0xbb,0xbb,0xbb,0xdc,0x81,0xdc,0xdc,0xdc,0xeb,0x00,0x90,0x90,0x90,0xcc,0x81,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0, + 0xd1,0x81,0xdc,0xdc,0xdc,0xeb,0x01,0x52,0x52,0x52,0xbd,0xbb,0xbb,0xbb,0xdc,0x81,0xdc,0xdc,0xdc,0xeb,0x02,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0xe6,0xe6,0xe6, + 0xf0,0x81,0xff,0xff,0xff,0xff,0x00,0xef,0xef,0xef,0xf5,0x81,0xdc,0xdc,0xdc,0xeb,0x01,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x04,0x90, + 0x90,0x90,0xcc,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0x90,0x90,0x90,0xcc,0x85,0x00,0x00,0x00,0xb3,0x02,0x6a,0x6a,0x6a,0xc2,0xdc,0xdc,0xdc, + 0xeb,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x04,0xe6,0xe6,0xe6,0xf0,0xdc,0xdc,0xdc,0xeb,0xbb,0xbb,0xbb,0xdc,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81, + 0xff,0xff,0xff,0xff,0x04,0x90,0x90,0x90,0xcc,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0x90,0x90,0x90,0xcc,0x83,0x00,0x00,0x00,0xb3,0x01,0xa0, + 0xa0,0xa0,0xd1,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x01,0xd2,0xd2,0xd2,0xe6,0x6a,0x6a,0x6a,0xc2,0x87,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81, + 0xff,0xff,0xff,0xff,0x84,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x01,0x7e,0x7e, + 0x7e,0xc7,0xd2,0xd2,0xd2,0xe6,0x81,0xff,0xff,0xff,0xff,0x01,0xe6,0xe6,0xe6,0xf0,0x90,0x90,0x90,0xcc,0x82,0x00,0x00,0x00,0xb3,0x02,0x33,0x33,0x33,0xb8,0xaf,0xaf, + 0xaf,0xd6,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x01,0xe6,0xe6,0xe6,0xf0,0xaf,0xaf,0xaf,0xd6,0x83,0x00,0x00,0x00,0xb3,0x04,0xaf,0xaf,0xaf,0xd6,0xef,0xef, + 0xef,0xf5,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0x90,0x90,0x90,0xcc,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x06,0x33,0x33, + 0x33,0xb8,0xc7,0xc7,0xc7,0xe1,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0xc7,0xc7,0xc7,0xe1,0x52,0x52,0x52,0xbd,0x81,0x00,0x00,0x00,0xb3,0x0a, + 0x33,0x33,0x33,0xb8,0xaf,0xaf,0xaf,0xd6,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0xc7,0xc7,0xc7,0xe1,0x33,0x33,0x33,0xb8,0x00,0x00,0x00,0xb3, + 0x6a,0x6a,0x6a,0xc2,0xdc,0xdc,0xdc,0xeb,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x02,0xe6,0xe6,0xe6,0xf0,0xdc,0xdc,0xdc,0xeb,0xbb,0xbb,0xbb,0xdc,0x85,0x00, + 0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x05,0xaf,0xaf,0xaf,0xd6,0xdc,0xdc,0xdc,0xeb,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0xc7,0xc7, + 0xc7,0xe1,0x33,0x33,0x33,0xb8,0x83,0x00,0x00,0x00,0xb3,0x01,0x7e,0x7e,0x7e,0xc7,0xd2,0xd2,0xd2,0xe6,0x81,0xff,0xff,0xff,0xff,0x01,0xe6,0xe6,0xe6,0xf0,0x90,0x90, + 0x90,0xcc,0x81,0x00,0x00,0x00,0xb3,0x01,0xdc,0xdc,0xdc,0xeb,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x02,0xef,0xef,0xef,0xf5,0xdc,0xdc,0xdc,0xeb,0xa0,0xa0, + 0xa0,0xd1,0x81,0x00,0x00,0x00,0xb3,0x01,0xa0,0xa0,0xa0,0xd1,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x01,0xe6,0xe6,0xe6,0xf0,0xa0,0xa0,0xa0,0xd1,0x82,0x00, + 0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0xdc,0xdc,0xdc,0xeb,0x03,0x7e,0x7e,0x7e,0xc7,0xc7,0xc7,0xc7,0xe1,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0x81,0x00, + 0x00,0x00,0xb3,0x01,0xa0,0xa0,0xa0,0xd1,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x01,0xd2,0xd2,0xd2,0xe6,0x6a,0x6a,0x6a,0xc2,0x87,0x00,0x00,0x00,0xb3,0x00, + 0xbb,0xbb,0xbb,0xdc,0x81,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x00,0x6a,0x6a,0x6a,0xc2,0x81,0xdc,0xdc,0xdc,0xeb,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0x00,0x00, + 0x00,0xb3,0x01,0x90,0x90,0x90,0xcc,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x01,0xe6,0xe6,0xe6,0xf0,0xa0,0xa0,0xa0,0xd1,0x82,0x00,0x00,0x00,0xb3,0x01,0x7e, + 0x7e,0x7e,0xc7,0xd2,0xd2,0xd2,0xe6,0x81,0xff,0xff,0xff,0xff,0x01,0xe6,0xe6,0xe6,0xf0,0x90,0x90,0x90,0xcc,0x8d,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00, + 0xdc,0xdc,0xdc,0xeb,0x84,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0x00,0x00,0x00,0xb3,0x01,0xa0,0xa0, + 0xa0,0xd1,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x01,0xd2,0xd2,0xd2,0xe6,0x6a,0x6a,0x6a,0xc2,0x82,0x00,0x00,0x00,0xb3,0x02,0x52,0x52,0x52,0xbd,0xc7,0xc7, + 0xc7,0xe1,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x01,0xdc,0xdc,0xdc,0xeb,0x7e,0x7e,0x7e,0xc7,0x82,0x00,0x00,0x00,0xb3,0x05,0x33,0x33,0x33,0xb8,0xc7,0xc7, + 0xc7,0xe1,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00, + 0xb3,0x01,0x6a,0x6a,0x6a,0xc2,0xd2,0xd2,0xd2,0xe6,0x81,0xff,0xff,0xff,0xff,0x02,0xef,0xef,0xef,0xf5,0xaf,0xaf,0xaf,0xd6,0x33,0x33,0x33,0xb8,0x81,0x00,0x00,0x00, + 0xb3,0x05,0x52,0x52,0x52,0xbd,0xc7,0xc7,0xc7,0xe1,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x02, + 0xa0,0xa0,0xa0,0xd1,0xdc,0xdc,0xdc,0xeb,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x81,0xdc,0xdc,0xdc,0xeb,0x00,0xa0,0xa0,0xa0,0xd1,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xb6,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xb8,0x00,0x00,0x00,0xb3,0x01,0x7e,0x7e,0x7e,0xc7,0x33,0x33, + 0x33,0xb8,0x94,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x91,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff, + 0x91,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x96,0x00,0x00,0x00,0xb3,0x01,0x7e,0x7e,0x7e,0xc7,0x33,0x33, + 0x33,0xb8,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb, + 0x81,0xff,0xff,0xff,0xff,0x8c,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0x00,0x00,0x00,0xb3,0x00,0xdc, + 0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x96,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x84,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e, + 0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x9b,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x94,0x00,0x00,0x00,0xb3,0x00, + 0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x87,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e, + 0x7e,0xc7,0x91,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0xcb,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff, + 0x00,0xdc,0xdc,0xdc,0xeb,0x84,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x9a,0x00,0x00,0x00,0xb3,0x00,0x7e, + 0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x94,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xb9,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xb7,0x00,0x00,0x00,0xb3,0x03,0xdc,0xdc,0xdc,0xeb,0xff, + 0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0x33,0x33,0x33,0xb8,0x93,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x91,0x00,0x00,0x00,0xb3,0x00, + 0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x91,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x95,0x00,0x00, + 0x00,0xb3,0x05,0xdc,0xdc,0xdc,0xeb,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0x33,0x33,0x33,0xb8,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff, + 0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x8c,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff, + 0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x96,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc, + 0xeb,0x81,0xff,0xff,0xff,0xff,0x84,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x9b,0x00,0x00,0x00,0xb3,0x81, + 0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x94,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x87,0x00,0x00, + 0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x91,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff, + 0x00,0xaf,0xaf,0xaf,0xd6,0xcb,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x84,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff, + 0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x9a,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x94,0x00,0x00,0x00, + 0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xb9,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xb7,0x00,0x00,0x00,0xb3,0x82,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x93,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc, + 0xdc,0xeb,0x91,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x91,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff, + 0x00,0xaf,0xaf,0xaf,0xd6,0x95,0x00,0x00,0x00,0xb3,0x82,0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0x81,0x7e,0x7e,0x7e, + 0xc7,0x00,0x52,0x52,0x52,0xbd,0x82,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x8c,0x00,0x00,0x00,0xb3,0x00,0x52,0x52,0x52,0xbd,0x81, + 0x7e,0x7e,0x7e,0xc7,0x00,0x33,0x33,0x33,0xb8,0x82,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x96,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc, + 0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x84,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x9b,0x00,0x00,0x00,0xb3, + 0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x94,0x00,0x00,0x00,0xb3,0x00,0x52,0x52,0x52,0xbd,0x81,0x7e,0x7e,0x7e,0xc7,0x00,0x33,0x33,0x33,0xb8,0x87,0x00, + 0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x91,0x00,0x00,0x00,0xb3,0x00,0x52,0x52,0x52,0xbd,0x81,0xff,0xff,0xff, + 0xff,0x00,0xf7,0xf7,0xf7,0xfa,0x81,0xaf,0xaf,0xaf,0xd6,0xc9,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x84,0x00,0x00,0x00,0xb3,0x00, + 0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x9a,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf, + 0xaf,0xd6,0x94,0x00,0x00,0x00,0xb3,0x00,0x6a,0x6a,0x6a,0xc2,0x81,0x7e,0x7e,0x7e,0xc7,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xb9,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xb7,0x00,0x00,0x00,0xb3,0x02,0xaf,0xaf,0xaf,0xd6,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0x94,0x00,0x00,0x00, + 0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x91,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x91,0x00,0x00,0x00,0xb3,0x00, + 0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x95,0x00,0x00,0x00,0xb3,0x02,0xaf,0xaf,0xaf,0xd6,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb, + 0x88,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x93,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x96,0x00, + 0x00,0x00,0xb3,0x00,0xbb,0xbb,0xbb,0xdc,0x81,0xdc,0xdc,0xdc,0xeb,0x84,0x00,0x00,0x00,0xb3,0x00,0x6a,0x6a,0x6a,0xc2,0x81,0xdc,0xdc,0xdc,0xeb,0x00,0xa0,0xa0,0xa0, + 0xd1,0x9b,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0xa0,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00, + 0x7e,0x7e,0x7e,0xc7,0x92,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0xc9,0x00,0x00,0x00,0xb3,0x81,0xdc,0xdc, + 0xdc,0xeb,0x00,0xbb,0xbb,0xbb,0xdc,0x84,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0xdc,0xdc,0xdc,0xeb,0x00,0x6a,0x6a,0x6a,0xc2,0x9a,0x00,0x00,0x00,0xb3, + 0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xd1,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xcf,0x00,0x00,0x00,0xb3,0x81,0xaf,0xaf,0xaf,0xd6,0x00,0xa0,0xa0,0xa0,0xd1,0x91,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0, + 0xd1,0x81,0xaf,0xaf,0xaf,0xd6,0x91,0x00,0x00,0x00,0xb3,0x00,0x52,0x52,0x52,0xbd,0x81,0xaf,0xaf,0xaf,0xd6,0x00,0x7e,0x7e,0x7e,0xc7,0xa1,0x00,0x00,0x00,0xb3,0x00, + 0xa0,0xa0,0xa0,0xd1,0x81,0xaf,0xaf,0xaf,0xd6,0x93,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0xaf,0xaf,0xaf,0xd6,0xbe,0x00,0x00,0x00,0xb3,0x81,0xaf,0xaf, + 0xaf,0xd6,0x00,0xa0,0xa0,0xa0,0xd1,0xa0,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xaf,0xaf,0xaf,0xd6,0x00,0x52,0x52,0x52,0xbd,0x92,0x00,0x00,0x00,0xb3, + 0x01,0x33,0x33,0x33,0xb8,0xaf,0xaf,0xaf,0xd6,0x81,0xdc,0xdc,0xdc,0xeb,0x00,0xbb,0xbb,0xbb,0xdc,0xf0,0x00,0x00,0x00,0xb3,0x00,0x52,0x52,0x52,0xbd,0x81,0xaf,0xaf, + 0xaf,0xd6,0x00,0x7e,0x7e,0x7e,0xc7,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xd1,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xa3,0x00,0x00,0x00,0xb3,0x82,0x7e,0x7e,0x7e,0xc7,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xd8,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xa0,0x00,0x00,0x00,0xb3,0x01,0x52,0x52,0x52,0xbd,0xd2,0xd2,0xd2,0xe6,0x84,0xff,0xff,0xff,0xff,0x00,0xbb,0xbb,0xbb,0xdc,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xd6,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xa0,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x86,0xff,0xff,0xff,0xff,0x00,0xc7,0xc7,0xc7,0xe1,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xd5,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xa1,0x00,0x00,0x00,0xb3,0x05,0xef,0xef,0xef,0xf5,0xe6,0xe6,0xe6,0xf0,0xa0,0xa0,0xa0,0xd1,0x7e,0x7e,0x7e,0xc7,0xa0,0xa0,0xa0,0xd1,0xf7,0xf7,0xf7,0xfa,0x81,0xff, + 0xff,0xff,0xff,0x00,0x52,0x52,0x52,0xbd,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xd4,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xce,0x00,0x00,0x00,0xb3,0x02,0x52,0x52,0x52,0xbd,0x7e,0x7e,0x7e,0xc7,0x6a,0x6a,0x6a,0xc2,0x85,0x00,0x00,0x00,0xb3,0x02,0x6a,0x6a, + 0x6a,0xc2,0x7e,0x7e,0x7e,0xc7,0x33,0x33,0x33,0xb8,0x86,0x00,0x00,0x00,0xb3,0x02,0x33,0x33,0x33,0xb8,0x7e,0x7e,0x7e,0xc7,0x6a,0x6a,0x6a,0xc2,0x8c,0x00,0x00,0x00, + 0xb3,0x02,0x52,0x52,0x52,0xbd,0x7e,0x7e,0x7e,0xc7,0x52,0x52,0x52,0xbd,0x91,0x00,0x00,0x00,0xb3,0x02,0x52,0x52,0x52,0xbd,0x7e,0x7e,0x7e,0xc7,0x52,0x52,0x52,0xbd, + 0x94,0x00,0x00,0x00,0xb3,0x02,0x6a,0x6a,0x6a,0xc2,0x7e,0x7e,0x7e,0xc7,0x6a,0x6a,0x6a,0xc2,0x90,0x00,0x00,0x00,0xb3,0x00,0x52,0x52,0x52,0xbd,0x81,0x7e,0x7e,0x7e, + 0xc7,0x9a,0x00,0x00,0x00,0xb3,0x02,0x6a,0x6a,0x6a,0xc2,0x7e,0x7e,0x7e,0xc7,0x33,0x33,0x33,0xb8,0xa3,0x00,0x00,0x00,0xb3,0x02,0x52,0x52,0x52,0xbd,0x7e,0x7e,0x7e, + 0xc7,0x52,0x52,0x52,0xbd,0xa6,0x00,0x00,0x00,0xb3,0x00,0x6a,0x6a,0x6a,0xc2,0x83,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x00,0xaf, + 0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x81,0x7e,0x7e,0x7e,0xc7,0x00,0x6a,0x6a,0x6a,0xc2,0x8a,0x00,0x00,0x00,0xb3,0x02,0x6a,0x6a,0x6a,0xc2,0x7e,0x7e,0x7e,0xc7, + 0x33,0x33,0x33,0xb8,0x91,0x00,0x00,0x00,0xb3,0x02,0x6a,0x6a,0x6a,0xc2,0x7e,0x7e,0x7e,0xc7,0x33,0x33,0x33,0xb8,0x9a,0x00,0x00,0x00,0xb3,0x00,0x6a,0x6a,0x6a,0xc2, + 0x81,0x7e,0x7e,0x7e,0xc7,0x86,0x00,0x00,0x00,0xb3,0x81,0x7e,0x7e,0x7e,0xc7,0x00,0x52,0x52,0x52,0xbd,0x8a,0x00,0x00,0x00,0xb3,0x81,0x7e,0x7e,0x7e,0xc7,0x88,0x00, + 0x00,0x00,0xb3,0x00,0x33,0x33,0x33,0xb8,0x81,0x7e,0x7e,0x7e,0xc7,0x84,0x00,0x00,0x00,0xb3,0x00,0x33,0x33,0x33,0xb8,0x81,0x7e,0x7e,0x7e,0xc7,0x00,0x33,0x33,0x33, + 0xb8,0x88,0x00,0x00,0x00,0xb3,0x02,0x6a,0x6a,0x6a,0xc2,0x7e,0x7e,0x7e,0xc7,0x6a,0x6a,0x6a,0xc2,0x8f,0x00,0x00,0x00,0xb3,0x00,0x52,0x52,0x52,0xbd,0x81,0x7e,0x7e, + 0x7e,0xc7,0x00,0x33,0x33,0x33,0xb8,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xc1,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xbf,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff, + 0xff,0xff,0xff,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0x00,0x00,0x00,0xb3,0x01,0x7e,0x7e,0x7e,0xc7,0xe6,0xe6,0xe6,0xf0,0x82,0xff,0xff,0xff,0xff,0x01,0xef,0xef,0xef,0xf5, + 0x90,0x90,0x90,0xcc,0x81,0x00,0x00,0x00,0xb3,0x01,0x6a,0x6a,0x6a,0xc2,0xef,0xef,0xef,0xf5,0x82,0xff,0xff,0xff,0xff,0x00,0xbb,0xbb,0xbb,0xdc,0x81,0xff,0xff,0xff, + 0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0xff,0xff,0xff,0xff,0x01,0xdc,0xdc,0xdc,0xeb,0xbb,0xbb,0xbb,0xdc,0x81,0xff, + 0xff,0xff,0xff,0x86,0x00,0x00,0x00,0xb3,0x01,0x33,0x33,0x33,0xb8,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x05,0xdc,0xdc,0xdc,0xeb,0xe6,0xe6,0xe6,0xf0,0xff, + 0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff, + 0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x01,0x33,0x33,0x33,0xb8,0xd2,0xd2,0xd2,0xe6,0x82,0xff,0xff,0xff,0xff,0x03,0xbb,0xbb,0xbb,0xdc, + 0xdc,0xdc,0xdc,0xeb,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0x87,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x83,0x00,0x00,0x00,0xb3, + 0x01,0x90,0x90,0x90,0xcc,0xef,0xef,0xef,0xf5,0x82,0xff,0xff,0xff,0xff,0x01,0xef,0xef,0xef,0xf5,0x90,0x90,0x90,0xcc,0x82,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff, + 0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x01,0x6a,0x6a, + 0x6a,0xc2,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x01,0xf7,0xf7,0xf7,0xfa,0xaf,0xaf,0xaf,0xd6,0x84,0x00,0x00,0x00,0xb3,0x00,0xe6,0xe6,0xe6,0xf0,0x81,0xff, + 0xff,0xff,0xff,0x00,0x6a,0x6a,0x6a,0xc2,0x81,0x00,0x00,0x00,0xb3,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x00,0xa0,0xa0,0xa0,0xd1,0x87,0x00,0x00,0x00, + 0xb3,0x01,0x6a,0x6a,0x6a,0xc2,0xef,0xef,0xef,0xf5,0x82,0xff,0xff,0xff,0xff,0x00,0xbb,0xbb,0xbb,0xdc,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00, + 0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x87,0x00,0x00,0x00,0xb3,0x00, + 0x90,0x90,0x90,0xcc,0x81,0xff,0xff,0xff,0xff,0x00,0xd2,0xd2,0xd2,0xe6,0x81,0x00,0x00,0x00,0xb3,0x00,0x52,0x52,0x52,0xbd,0x81,0xff,0xff,0xff,0xff,0x00,0xef,0xef, + 0xef,0xf5,0x82,0x00,0x00,0x00,0xb3,0x01,0x33,0x33,0x33,0xb8,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x05,0xdc,0xdc,0xdc,0xeb,0xe6,0xe6,0xe6,0xf0,0xff,0xff, + 0xff,0xff,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x83,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc, + 0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xaf, + 0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00, + 0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x05,0x33,0x33,0x33,0xb8,0xc7,0xc7,0xc7,0xe1,0xf7,0xf7,0xf7,0xfa, + 0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x03,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0xf7,0xf7, + 0xf7,0xfa,0x82,0xff,0xff,0xff,0xff,0x01,0xf7,0xf7,0xf7,0xfa,0xa0,0xa0,0xa0,0xd1,0x86,0x00,0x00,0x00,0xb3,0x01,0x6a,0x6a,0x6a,0xc2,0xef,0xef,0xef,0xf5,0x82,0xff, + 0xff,0xff,0xff,0x00,0xbb,0xbb,0xbb,0xdc,0x81,0xff,0xff,0xff,0xff,0x01,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb, + 0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x01,0x6a,0x6a,0x6a,0xc2,0xe6,0xe6, + 0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x01,0xf7,0xf7,0xf7,0xfa,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x86,0x00,0x00,0x00,0xb3,0x81, + 0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3, + 0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x02,0x00,0x00,0x00,0xb3,0x90,0x90,0x90,0xcc,0xef,0xef,0xef,0xf5,0x83,0xff,0xff,0xff,0xff,0x00,0xbb,0xbb,0xbb, + 0xdc,0x82,0x00,0x00,0x00,0xb3,0x01,0x7e,0x7e,0x7e,0xc7,0xf7,0xf7,0xf7,0xfa,0x82,0xff,0xff,0xff,0xff,0x81,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf, + 0xaf,0xaf,0xd6,0x83,0x00,0x00,0x00,0xb3,0x01,0x6a,0x6a,0x6a,0xc2,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x01,0xe6,0xe6,0xe6,0xf0,0xbb,0xbb,0xbb,0xdc,0x81, + 0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x01,0x52,0x52,0x52,0xbd,0xd2,0xd2,0xd2,0xe6,0x82,0xff,0xff,0xff,0xff,0x01,0xf7,0xf7,0xf7, + 0xfa,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x83,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff, + 0xff,0xff,0x82,0x00,0x00,0x00,0xb3,0x01,0x90,0x90,0x90,0xcc,0xef,0xef,0xef,0xf5,0x82,0xff,0xff,0xff,0xff,0x01,0xef,0xef,0xef,0xf5,0x90,0x90,0x90,0xcc,0x82,0x00, + 0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e, + 0xc7,0x6a,0x6a,0x6a,0xc2,0xdc,0xdc,0xdc,0xeb,0x83,0xff,0xff,0xff,0xff,0x01,0xdc,0xdc,0xdc,0xeb,0x33,0x33,0x33,0xb8,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xbf,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xbf,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00, + 0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x03,0xf7,0xf7,0xf7,0xfa,0x33,0x33,0x33,0xb8,0x00,0x00,0x00,0xb3, + 0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x09,0xf7,0xf7,0xf7,0xfa,0xdc,0xdc,0xdc,0xeb,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0x33,0x33, + 0x33,0xb8,0x00,0x00,0x00,0xb3,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0x81,0xbb,0xbb,0xbb,0xdc,0x00,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff, + 0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x87,0xff,0xff,0xff,0xff,0x86,0x00,0x00,0x00,0xb3,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff, + 0xff,0xff,0x02,0xc7,0xc7,0xc7,0xe1,0xaf,0xaf,0xaf,0xd6,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc, + 0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00, + 0xdc,0xdc,0xdc,0xeb,0x86,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x87,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0x00,0x00, + 0x00,0xb3,0x00,0x90,0x90,0x90,0xcc,0x86,0xff,0xff,0xff,0xff,0x00,0x90,0x90,0x90,0xcc,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb, + 0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x03,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0x52,0x52,0x52,0xbd,0xf7,0xf7,0xf7,0xfa,0x85,0xff, + 0xff,0xff,0xff,0x00,0xbb,0xbb,0xbb,0xdc,0x82,0x00,0x00,0x00,0xb3,0x00,0x6a,0x6a,0x6a,0xc2,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00, + 0xb3,0x00,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x87,0x00,0x00,0x00,0xb3,0x02,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xf7,0xf7, + 0xf7,0xfa,0x81,0xbb,0xbb,0xbb,0xdc,0x00,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff, + 0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x87,0x00,0x00,0x00,0xb3,0x00,0xd2,0xd2,0xd2,0xe6,0x82,0xff,0xff,0xff, + 0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x82,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x00,0xc7,0xc7,0xc7,0xe1,0x81, + 0xff,0xff,0xff,0xff,0x02,0xc7,0xc7,0xc7,0xe1,0xaf,0xaf,0xaf,0xd6,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0xaf, + 0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x83,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00, + 0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0x7e,0x7e, + 0x7e,0xc7,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf, + 0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xe6,0xe6,0xe6,0xf0,0x86,0xff,0xff,0xff,0xff,0x06,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0xff, + 0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0xdc,0xdc,0xdc,0xeb,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x85,0x00,0x00,0x00,0xb3,0x02,0xef, + 0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0x81,0xbb,0xbb,0xbb,0xdc,0x00,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x01,0xaf,0xaf,0xaf,0xd6,0x00, + 0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x03,0x7e,0x7e,0x7e, + 0xc7,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0x86,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x86,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff, + 0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc, + 0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0xb3,0x6a,0x6a,0x6a,0xc2,0x81,0xff,0xff,0xff,0xff,0x01,0xdc,0xdc,0xdc,0xeb,0xef,0xef,0xef,0xf5,0x81,0xff, + 0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xef,0xef,0xef,0xf5,0x83,0xff,0xff,0xff,0xff,0x81,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff, + 0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x83,0x00,0x00,0x00,0xb3,0x00,0xd2,0xd2,0xd2,0xe6,0x86,0xff,0xff,0xff,0xff,0x03,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0x33,0x33, + 0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0x84,0xff,0xff,0xff,0xff,0x02,0xc7,0xc7,0xc7,0xe1,0x00,0x00,0x00,0xb3,0x52,0x52,0x52,0xbd,0x84,0xff,0xff,0xff,0xff,0x01,0x00,0x00, + 0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0x90,0x90,0x90,0xcc,0x86,0xff,0xff,0xff,0xff,0x00,0x90,0x90,0x90,0xcc,0x81, + 0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x03,0x7e,0x7e, + 0x7e,0xc7,0x33,0x33,0x33,0xb8,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0x81,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xbf,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xbf,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7, + 0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0x00, + 0x00,0x00,0xb3,0x07,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0x33,0x33,0x33,0xb8,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0xc7,0xc7,0xc7,0xe1, + 0x52,0x52,0x52,0xbd,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0x6a,0x6a,0x6a,0xc2,0x81,0xff,0xff, + 0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x03,0xaf,0xaf,0xaf,0xd6,0x7e,0x7e,0x7e,0xc7,0xa0,0xa0,0xa0, + 0xd1,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x86,0x00,0x00,0x00,0xb3,0x02,0xdc,0xdc,0xdc,0xeb,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00, + 0xb3,0x05,0x33,0x33,0x33,0xb8,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81, + 0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0x6a,0x6a,0x6a,0xc2,0x81,0xff,0xff,0xff,0xff, + 0x03,0xf7,0xf7,0xf7,0xfa,0xa0,0xa0,0xa0,0xd1,0x7e,0x7e,0x7e,0xc7,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x87,0x00,0x00,0x00,0xb3, + 0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0x00,0x00,0x00,0xb3,0x00,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x7e,0x7e, + 0x7e,0xc7,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0xef,0xef,0xef,0xf5,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00, + 0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x03,0xd2, + 0xd2,0xd2,0xe6,0x7e,0x7e,0x7e,0xc7,0xa0,0xa0,0xa0,0xd1,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x00,0x52,0x52,0x52,0xbd,0x81,0x00,0x00,0x00,0xb3,0x00,0xbb, + 0xbb,0xbb,0xdc,0x82,0xff,0xff,0xff,0xff,0x02,0xe6,0xe6,0xe6,0xf0,0x00,0x00,0x00,0xb3,0x6a,0x6a,0x6a,0xc2,0x83,0xff,0xff,0xff,0xff,0x00,0x52,0x52,0x52,0xbd,0x86, + 0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0x6a,0x6a,0x6a,0xc2,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf, + 0xaf,0xd6,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x86,0x00, + 0x00,0x00,0xb3,0x00,0x33,0x33,0x33,0xb8,0x83,0xff,0xff,0xff,0xff,0x02,0x90,0x90,0x90,0xcc,0x00,0x00,0x00,0xb3,0xd2,0xd2,0xd2,0xe6,0x82,0xff,0xff,0xff,0xff,0x00, + 0xc7,0xc7,0xc7,0xe1,0x81,0x00,0x00,0x00,0xb3,0x02,0xdc,0xdc,0xdc,0xeb,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x05,0x33,0x33,0x33,0xb8, + 0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x83,0x00, + 0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf, + 0xd6,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff, + 0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xa0,0xa0,0xa0,0xd1,0x82,0xff,0xff,0xff, + 0xff,0x02,0xc7,0xc7,0xc7,0xe1,0xaf,0xaf,0xaf,0xd6,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x03,0xaf,0xaf, + 0xaf,0xd6,0x33,0x33,0x33,0xb8,0x00,0x00,0x00,0xb3,0x90,0x90,0x90,0xcc,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x85,0x00,0x00,0x00,0xb3,0x81,0xff,0xff, + 0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0x6a,0x6a,0x6a,0xc2,0x81,0xff,0xff,0xff,0xff,0x01,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0x81, + 0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00, + 0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x03,0xe6,0xe6,0xe6,0xf0,0x90,0x90,0x90,0xcc,0x7e,0x7e,0x7e,0xc7,0xd2,0xd2,0xd2,0xe6,0x81,0xff,0xff,0xff,0xff, + 0x00,0xaf,0xaf,0xaf,0xd6,0x86,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff, + 0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x03,0xa0,0xa0,0xa0,0xd1,0x6a, + 0x6a,0x6a,0xc2,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x04, + 0xef,0xef,0xef,0xf5,0x33,0x33,0x33,0xb8,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x83,0x00, + 0x00,0x00,0xb3,0x00,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x90,0x90,0x90,0xcc,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x02, + 0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x03,0xd2,0xd2,0xd2,0xe6,0x7e,0x7e,0x7e,0xc7,0xa0,0xa0,0xa0,0xd1,0xc7,0xc7, + 0xc7,0xe1,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x04,0xd2,0xd2,0xd2,0xe6,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0x00,0x00, + 0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x7e, + 0x7e,0x7e,0xc7,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0xef,0xef,0xef,0xf5,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb, + 0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x03,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0x6a,0x6a,0x6a,0xc2,0xa0,0xa0,0xa0,0xd1, + 0x81,0x00,0x00,0x00,0xb3,0x00,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xbf,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xbf,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3, + 0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x00,0x6a,0x6a,0x6a,0xc2,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc, + 0xdc,0xeb,0x84,0xaf,0xaf,0xaf,0xd6,0x05,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0xaf,0xaf,0xaf,0xd6, + 0x81,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x01,0xaf,0xaf,0xaf,0xd6,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xc7,0xc7,0xc7,0xe1,0x82,0x00,0x00, + 0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x86,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0xbb,0xbb,0xbb,0xdc, + 0x81,0x7e,0x7e,0x7e,0xc7,0x04,0xe6,0xe6,0xe6,0xf0,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81, + 0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff, + 0x00,0xa0,0xa0,0xa0,0xd1,0x82,0x00,0x00,0x00,0xb3,0x02,0xc7,0xc7,0xc7,0xe1,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0x87,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff, + 0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x00,0x6a,0x6a,0x6a,0xc2,0x81,0xff,0xff,0xff,0xff,0x00,0xc7,0xc7,0xc7,0xe1,0x82,0x00,0x00,0x00,0xb3,0x00, + 0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x01,0x6a,0x6a,0x6a,0xc2,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3, + 0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x04,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0x82,0x00, + 0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x02,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff, + 0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x06,0x33,0x33,0x33,0xb8,0xbb,0xbb,0xbb,0xdc,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0xf7,0xf7,0xf7,0xfa,0xff,0xff, + 0xff,0xff,0xaf,0xaf,0xaf,0xd6,0x86,0x00,0x00,0x00,0xb3,0x03,0xdc,0xdc,0xdc,0xeb,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0xaf,0xaf,0xaf,0xd6,0x81,0x7e,0x7e,0x7e, + 0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff, + 0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x86,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x03,0xdc,0xdc,0xdc,0xeb,0xff,0xff,0xff,0xff,0xbb, + 0xbb,0xbb,0xdc,0x33,0x33,0x33,0xb8,0x81,0xff,0xff,0xff,0xff,0x02,0xe6,0xe6,0xe6,0xf0,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf, + 0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0xbb,0xbb,0xbb,0xdc,0x81,0x7e,0x7e,0x7e,0xc7,0x04,0xe6,0xe6,0xe6,0xf0,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0x00, + 0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x83,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff, + 0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff, + 0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff, + 0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xd2,0xd2,0xd2,0xe6,0x81,0xff,0xff,0xff,0xff,0x00,0x90,0x90,0x90,0xcc,0x81,0x00,0x00,0x00,0xb3,0x03,0x33, + 0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x02,0x52,0x52,0x52,0xbd,0xaf,0xaf,0xaf,0xd6,0xdc,0xdc,0xdc, + 0xeb,0x82,0xff,0xff,0xff,0xff,0x00,0xa0,0xa0,0xa0,0xd1,0x85,0x00,0x00,0x00,0xb3,0x03,0xdc,0xdc,0xdc,0xeb,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0xaf,0xaf,0xaf, + 0xd6,0x81,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x01,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00, + 0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x00, + 0x52,0x52,0x52,0xbd,0x82,0x00,0x00,0x00,0xb3,0x02,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xaf,0xaf,0xaf,0xd6,0x86,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff, + 0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc, + 0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x03,0x33,0x33,0x33,0xb8,0xaf,0xaf,0xaf,0xd6,0xd2,0xd2,0xd2,0xe6,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff, + 0xff,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81, + 0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x83,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xe6,0xe6,0xe6,0xf0,0x81,0x00,0x00,0x00,0xb3,0x00,0xbb,0xbb, + 0xbb,0xdc,0x81,0xff,0xff,0xff,0xff,0x04,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0x85,0x00,0x00,0x00, + 0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x01, + 0x00,0x00,0x00,0xb3,0x6a,0x6a,0x6a,0xc2,0x81,0xff,0xff,0xff,0xff,0x00,0xc7,0xc7,0xc7,0xe1,0x82,0x00,0x00,0x00,0xb3,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff, + 0xff,0x01,0x6a,0x6a,0x6a,0xc2,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff, + 0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x02,0xa0,0xa0,0xa0,0xd1,0xc7,0xc7,0xc7,0xe1,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x00, + 0xef,0xef,0xef,0xf5,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xbf,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xbf,0x00,0x00, + 0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x00,0x6a, + 0x6a,0x6a,0xc2,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x87,0xff,0xff,0xff,0xff,0x03,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0x6a,0x6a,0x6a,0xc2,0xe6, + 0xe6,0xe6,0xf0,0x85,0xff,0xff,0xff,0xff,0x01,0xaf,0xaf,0xaf,0xd6,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3, + 0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x86,0x00,0x00,0x00,0xb3,0x01,0x33,0x33,0x33,0xb8,0xd2,0xd2,0xd2,0xe6,0x85,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc, + 0xdc,0xeb,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xaf, + 0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0x00,0x00,0x00,0xb3,0x02,0xaf,0xaf,0xaf,0xd6,0xff, + 0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0x87,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7, + 0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x01,0x7e,0x7e,0x7e,0xc7,0x00,0x00, + 0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x01,0x7e,0x7e,0x7e,0xc7,0x00,0x00, + 0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6, + 0x00,0x00,0x00,0xb3,0x90,0x90,0x90,0xcc,0x81,0xff,0xff,0xff,0xff,0x09,0xaf,0xaf,0xaf,0xd6,0xe6,0xe6,0xe6,0xf0,0xff,0xff,0xff,0xff,0x90,0x90,0x90,0xcc,0xef,0xef, + 0xef,0xf5,0xff,0xff,0xff,0xff,0xbb,0xbb,0xbb,0xdc,0xd2,0xd2,0xd2,0xe6,0xff,0xff,0xff,0xff,0xe6,0xe6,0xe6,0xf0,0x86,0x00,0x00,0x00,0xb3,0x01,0x6a,0x6a,0x6a,0xc2, + 0xe6,0xe6,0xe6,0xf0,0x85,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3, + 0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x86,0x00,0x00,0x00,0xb3,0x06,0xe6,0xe6,0xe6,0xf0,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0x90,0x90,0x90,0xcc, + 0xff,0xff,0xff,0xff,0xe6,0xe6,0xe6,0xf0,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x03,0x90,0x90,0x90,0xcc, + 0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0xd2,0xd2,0xd2,0xe6,0x85,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff, + 0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x83,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e, + 0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00, + 0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00, + 0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x83,0x00,0x00,0x00,0xb3,0x05,0xdc,0xdc,0xdc,0xeb,0xff,0xff,0xff,0xff,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00, + 0xb3,0x52,0x52,0x52,0xbd,0xf7,0xf7,0xf7,0xfa,0x83,0xff,0xff,0xff,0xff,0x01,0xdc,0xdc,0xdc,0xeb,0x33,0x33,0x33,0xb8,0x85,0x00,0x00,0x00,0xb3,0x01,0x6a,0x6a,0x6a, + 0xc2,0xe6,0xe6,0xe6,0xf0,0x85,0xff,0xff,0xff,0xff,0x01,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00, + 0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x83,0x00, + 0x00,0x00,0xb3,0x02,0xdc,0xdc,0xdc,0xeb,0xff,0xff,0xff,0xff,0xaf,0xaf,0xaf,0xd6,0x86,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00, + 0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff, + 0x81,0x00,0x00,0x00,0xb3,0x00,0xe6,0xe6,0xe6,0xf0,0x83,0xff,0xff,0xff,0xff,0x01,0xef,0xef,0xef,0xf5,0x6a,0x6a,0x6a,0xc2,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff, + 0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x83,0x00,0x00,0x00,0xb3, + 0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x01,0x7e,0x7e,0x7e,0xc7,0x00,0x00, + 0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x85,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6, + 0x82,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf, + 0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x01,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00, + 0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0xbb,0xbb,0xbb,0xdc, + 0x83,0xff,0xff,0xff,0xff,0x01,0xf7,0xf7,0xf7,0xfa,0xa0,0xa0,0xa0,0xd1,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xbf,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xbf,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x85,0xff,0xff,0xff,0xff,0x01,0xf7,0xf7,0xf7,0xfa,0xaf,0xaf,0xaf,0xd6,0x81, + 0x00,0x00,0x00,0xb3,0x00,0x52,0x52,0x52,0xbd,0x81,0xff,0xff,0xff,0xff,0x00,0xd2,0xd2,0xd2,0xe6,0x81,0x7e,0x7e,0x7e,0xc7,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff, + 0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x01,0x6a,0x6a,0x6a,0xc2,0xa0,0xa0,0xa0,0xd1,0x81,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x01, + 0xaf,0xaf,0xaf,0xd6,0x52,0x52,0x52,0xbd,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff, + 0xff,0x88,0x00,0x00,0x00,0xb3,0x01,0x52,0x52,0x52,0xbd,0x90,0x90,0x90,0xcc,0x81,0xaf,0xaf,0xaf,0xd6,0x04,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc, + 0xeb,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x02,0x52,0x52,0x52,0xbd,0x00,0x00,0x00,0xb3,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff, + 0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x02,0xdc,0xdc,0xdc, + 0xeb,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0x87,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x00,0x52,0x52, + 0x52,0xbd,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x01,0x52,0x52,0x52,0xbd, + 0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x05,0x7e,0x7e,0x7e,0xc7, + 0x00,0x00,0x00,0xb3,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0x33,0x33,0x33,0xb8,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff, + 0xff,0xff,0xff,0x02,0xa0,0xa0,0xa0,0xd1,0x00,0x00,0x00,0xb3,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x03,0x52,0x52,0x52,0xbd,0xbb,0xbb,0xbb,0xdc,0xff,0xff, + 0xff,0xff,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x01,0x7e,0x7e,0x7e,0xc7,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x00,0x6a,0x6a,0x6a,0xc2,0x87,0x00, + 0x00,0x00,0xb3,0x01,0x6a,0x6a,0x6a,0xc2,0xa0,0xa0,0xa0,0xd1,0x81,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xdc, + 0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x85,0x00,0x00,0x00,0xb3,0x00,0x52,0x52,0x52, + 0xbd,0x81,0xff,0xff,0xff,0xff,0x01,0xc7,0xc7,0xc7,0xe1,0x33,0x33,0x33,0xb8,0x81,0xff,0xff,0xff,0xff,0x06,0xdc,0xdc,0xdc,0xeb,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc, + 0xeb,0x00,0x00,0x00,0xb3,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xd2,0xd2,0xd2,0xe6,0x82,0x00,0x00,0x00,0xb3,0x01,0x52,0x52,0x52,0xbd,0x90,0x90,0x90,0xcc,0x81, + 0xaf,0xaf,0xaf,0xd6,0x04,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0xbb, + 0xbb,0xbb,0xdc,0x83,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x02,0x52,0x52,0x52,0xbd,0x00,0x00,0x00,0xb3,0xa0,0xa0,0xa0,0xd1,0x81, + 0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0xdc, + 0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x02,0x52,0x52,0x52,0xbd,0x00,0x00,0x00,0xb3,0xa0,0xa0,0xa0,0xd1,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00, + 0x00,0x00,0xb3,0xd2,0xd2,0xd2,0xe6,0x81,0xff,0xff,0xff,0xff,0x00,0x90,0x90,0x90,0xcc,0x81,0x00,0x00,0x00,0xb3,0x05,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0xff, + 0xff,0xff,0xff,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0xef,0xef,0xef,0xf5,0xaf,0xaf,0xaf,0xd6,0x6a,0x6a,0x6a, + 0xc2,0x89,0x00,0x00,0x00,0xb3,0x01,0x6a,0x6a,0x6a,0xc2,0xa0,0xa0,0xa0,0xd1,0x81,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x01,0xaf,0xaf,0xaf,0xd6,0x00,0x00, + 0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xef,0xef,0xef,0xf5,0x81,0x00,0x00,0x00,0xb3,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7, + 0x00,0x00,0x00,0xb3,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x03,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa, + 0xff,0xff,0xff,0xff,0xaf,0xaf,0xaf,0xd6,0x86,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81, + 0xff,0xff,0xff,0xff,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0x00,0x00,0x00,0xb3,0x00,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e, + 0xc7,0x81,0xff,0xff,0xff,0xff,0x02,0xf7,0xf7,0xf7,0xfa,0xbb,0xbb,0xbb,0xdc,0x90,0x90,0x90,0xcc,0x83,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc, + 0xdc,0xeb,0x82,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xe6,0xe6,0xe6,0xf0,0x83,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff, + 0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x05,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0xef,0xef,0xef, + 0xf5,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0x33,0x33,0x33,0xb8,0x81,0x00,0x00,0x00,0xb3,0x00,0x33,0x33,0x33,0xb8,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e, + 0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0xb3,0x52, + 0x52,0x52,0xbd,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x01,0x52,0x52,0x52, + 0xbd,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xef,0xef,0xef,0xf5,0x81,0x00,0x00,0x00,0xb3,0x00,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x01,0x7e, + 0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0x82,0xff,0xff,0xff,0xff,0x02,0xc7,0xc7,0xc7,0xe1,0xa0,0xa0,0xa0,0xd1,0x33,0x33,0x33,0xb8,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xc0,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xbf,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x87,0xff,0xff,0xff, + 0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x05,0xdc,0xdc,0xdc,0xeb,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0x6a,0x6a,0x6a,0xc2,0x33,0x33,0x33,0xb8, + 0xd2,0xd2,0xd2,0xe6,0x81,0xff,0xff,0xff,0xff,0x00,0x52,0x52,0x52,0xbd,0x81,0x00,0x00,0x00,0xb3,0x01,0x6a,0x6a,0x6a,0xc2,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00, + 0xb3,0x00,0x90,0x90,0x90,0xcc,0x81,0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc, + 0xdc,0xeb,0xaf,0xaf,0xaf,0xd6,0xc7,0xc7,0xc7,0xe1,0x82,0xff,0xff,0xff,0xff,0x87,0x00,0x00,0x00,0xb3,0x09,0x33,0x33,0x33,0xb8,0xaf,0xaf,0xaf,0xd6,0x33,0x33,0x33, + 0xb8,0x00,0x00,0x00,0xb3,0x52,0x52,0x52,0xbd,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff, + 0xff,0xff,0x02,0xe6,0xe6,0xe6,0xf0,0xaf,0xaf,0xaf,0xd6,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x02,0xa0,0xa0,0xa0,0xd1,0x00,0x00,0x00,0xb3,0x33,0x33,0x33, + 0xb8,0x82,0xff,0xff,0xff,0xff,0x02,0xc7,0xc7,0xc7,0xe1,0xaf,0xaf,0xaf,0xd6,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x85,0x00,0x00, + 0x00,0xb3,0x01,0xa0,0xa0,0xa0,0xd1,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x04,0xef,0xef,0xef,0xf5,0xaf,0xaf,0xaf,0xd6,0xa0,0xa0,0xa0,0xd1,0x00,0x00,0x00, + 0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0xaf,0xaf,0xaf,0xd6,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc, + 0xeb,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0x7e,0x7e, + 0x7e,0xc7,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0xef,0xef,0xef,0xf5,0xaf,0xaf,0xaf,0xd6,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff, + 0xff,0x00,0xf7,0xf7,0xf7,0xfa,0x81,0x33,0x33,0x33,0xb8,0x81,0xff,0xff,0xff,0xff,0x02,0xe6,0xe6,0xe6,0xf0,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff, + 0xff,0xff,0x02,0xf7,0xf7,0xf7,0xfa,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0x81,0xff,0xff,0xff,0xff,0x00,0xbb,0xbb,0xbb,0xdc,0x86,0x00,0x00,0x00,0xb3,0x01,0x6a, + 0x6a,0x6a,0xc2,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0x90,0x90,0x90,0xcc,0x81,0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0xdc, + 0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x85,0x00,0x00,0x00,0xb3,0x00,0xbb,0xbb,0xbb, + 0xdc,0x81,0xff,0xff,0xff,0xff,0x02,0x90,0x90,0x90,0xcc,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00, + 0xb3,0xbb,0xbb,0xbb,0xdc,0x81,0xff,0xff,0xff,0xff,0x0b,0x33,0x33,0x33,0xb8,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0xaf,0xaf,0xaf,0xd6,0x33,0x33,0x33,0xb8,0x00, + 0x00,0x00,0xb3,0x52,0x52,0x52,0xbd,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x82,0xff,0xff,0xff,0xff, + 0x04,0xc7,0xc7,0xc7,0xe1,0xaf,0xaf,0xaf,0xd6,0xa0,0xa0,0xa0,0xd1,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x02,0xe6,0xe6,0xe6,0xf0,0xaf, + 0xaf,0xaf,0xd6,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x02,0xa0,0xa0,0xa0,0xd1,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0x7e, + 0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x02,0xe6,0xe6,0xe6,0xf0,0xaf,0xaf,0xaf,0xd6,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff, + 0xff,0xff,0x02,0xa0,0xa0,0xa0,0xd1,0x00,0x00,0x00,0xb3,0xa0,0xa0,0xa0,0xd1,0x82,0xff,0xff,0xff,0xff,0x02,0xc7,0xc7,0xc7,0xe1,0xaf,0xaf,0xaf,0xd6,0xef,0xef,0xef, + 0xf5,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x03,0xa0,0xa0,0xa0,0xd1,0x00,0x00,0x00, + 0xb3,0xaf,0xaf,0xaf,0xd6,0x6a,0x6a,0x6a,0xc2,0x87,0x00,0x00,0x00,0xb3,0x01,0x6a,0x6a,0x6a,0xc2,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0x90,0x90,0x90, + 0xcc,0x81,0xff,0xff,0xff,0xff,0x01,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0x82,0xff,0xff,0xff,0xff,0x01,0xd2,0xd2,0xd2,0xe6,0xbb,0xbb,0xbb,0xdc,0x82,0xff,0xff, + 0xff,0xff,0x02,0x52,0x52,0x52,0xbd,0x00,0x00,0x00,0xb3,0x90,0x90,0x90,0xcc,0x81,0xff,0xff,0xff,0xff,0x03,0xf7,0xf7,0xf7,0xfa,0xbb,0xbb,0xbb,0xdc,0xaf,0xaf,0xaf, + 0xd6,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x86,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00, + 0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x01,0xbb,0xbb,0xbb,0xdc,0xd2,0xd2,0xd2,0xe6,0x81,0xff,0xff,0xff,0xff,0x02,0xef,0xef,0xef,0xf5,0x00,0x00, + 0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x06,0xc7,0xc7,0xc7,0xe1,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0xa0,0xa0,0xa0,0xd1,0x00,0x00,0x00,0xb3, + 0xa0,0xa0,0xa0,0xd1,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0xef,0xef,0xef,0xf5,0x81,0xaf,0xaf,0xaf,0xd6,0x01,0x52,0x52,0x52,0xbd,0x7e,0x7e,0x7e,0xc7, + 0x82,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00, + 0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x06, + 0xef,0xef,0xef,0xf5,0xaf,0xaf,0xaf,0xd6,0xc7,0xc7,0xc7,0xe1,0xe6,0xe6,0xe6,0xf0,0x33,0x33,0x33,0xb8,0xaf,0xaf,0xaf,0xd6,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff, + 0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xaf,0xaf,0xaf,0xd6,0x01,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc, + 0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0xaf,0xaf,0xaf,0xd6,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81, + 0x00,0x00,0x00,0xb3,0x82,0xff,0xff,0xff,0xff,0x01,0xd2,0xd2,0xd2,0xe6,0xbb,0xbb,0xbb,0xdc,0x82,0xff,0xff,0xff,0xff,0x01,0x52,0x52,0x52,0xbd,0x00,0x00,0x00,0xb3, + 0x81,0xff,0xff,0xff,0xff,0x03,0xe6,0xe6,0xe6,0xf0,0x33,0x33,0x33,0xb8,0x52,0x52,0x52,0xbd,0xaf,0xaf,0xaf,0xd6,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xc0,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xbf,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xdc, + 0xdc,0xdc,0xeb,0x81,0xaf,0xaf,0xaf,0xd6,0x00,0xc7,0xc7,0xc7,0xe1,0x82,0xff,0xff,0xff,0xff,0x03,0x90,0x90,0x90,0xcc,0x00,0x00,0x00,0xb3,0x6a,0x6a,0x6a,0xc2,0xf7, + 0xf7,0xf7,0xfa,0x84,0xff,0xff,0xff,0xff,0x00,0xbb,0xbb,0xbb,0xdc,0x81,0x00,0x00,0x00,0xb3,0x04,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xef, + 0xef,0xef,0xf5,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x00,0xef,0xef,0xef,0xf5,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x87,0xff,0xff,0xff,0xff, + 0x87,0x00,0x00,0x00,0xb3,0x04,0xdc,0xdc,0xdc,0xeb,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0xdc,0xdc,0xdc,0xeb,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x02, + 0x52,0x52,0x52,0xbd,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x00,0xf7,0xf7,0xf7,0xfa,0x83,0xff,0xff,0xff,0xff,0x00,0x52,0x52,0x52,0xbd, + 0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x86,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x85,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x84,0xff, + 0xff,0xff,0xff,0x03,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0x6a,0x6a,0x6a,0xc2,0xf7,0xf7,0xf7,0xfa,0x84,0xff,0xff,0xff,0xff,0x01,0xf7,0xf7,0xf7,0xfa,0x6a,0x6a, + 0x6a,0xc2,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x03,0x7e, + 0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0xe6,0xe6,0xe6,0xf0,0x85,0xff,0xff,0xff,0xff,0x02,0xa0,0xa0,0xa0,0xd1,0x00,0x00,0x00,0xb3,0xa0,0xa0,0xa0, + 0xd1,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x82,0xff,0xff,0xff,0xff,0x00,0xd2,0xd2,0xd2,0xe6,0x81,0x00,0x00,0x00,0xb3,0x02, + 0xe6,0xe6,0xe6,0xf0,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0x85,0x00,0x00,0x00,0xb3,0x04,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xef,0xef, + 0xef,0xf5,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x00,0xef,0xef,0xef,0xf5,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81, + 0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x85,0x00,0x00,0x00,0xb3,0x02,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa, + 0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0xff,0xff,0xff,0xff,0x02,0x6a,0x6a,0x6a,0xc2,0x00,0x00,0x00,0xb3,0x90,0x90,0x90,0xcc,0x81,0xff,0xff,0xff, + 0xff,0x06,0xa0,0xa0,0xa0,0xd1,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0xdc,0xdc,0xdc,0xeb,0xf7,0xf7,0xf7,0xfa,0x81,0xff, + 0xff,0xff,0xff,0x02,0x52,0x52,0x52,0xbd,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x02, + 0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x00,0xf7,0xf7,0xf7,0xfa,0x83,0xff,0xff,0xff,0xff,0x02,0x52,0x52,0x52,0xbd, + 0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x00, + 0xf7,0xf7,0xf7,0xfa,0x83,0xff,0xff,0xff,0xff,0x00,0x52,0x52,0x52,0xbd,0x81,0x00,0x00,0x00,0xb3,0x00,0xe6,0xe6,0xe6,0xf0,0x83,0xff,0xff,0xff,0xff,0x00,0xf7,0xf7, + 0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x03,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0x52,0x52,0x52,0xbd,0xf7,0xf7,0xf7,0xfa,0x83,0xff,0xff,0xff,0xff,0x01,0xf7,0xf7, + 0xf7,0xfa,0x6a,0x6a,0x6a,0xc2,0x85,0x00,0x00,0x00,0xb3,0x04,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0xdc,0xdc,0xdc,0xeb, + 0x81,0xff,0xff,0xff,0xff,0x00,0xef,0xef,0xef,0xf5,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xf7,0xf7,0xf7,0xfa,0x83,0xff,0xff,0xff,0xff,0x00,0xef, + 0xef,0xef,0xf5,0x82,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x86,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x86,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff, + 0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xf7,0xf7,0xf7,0xfa,0x83,0xff,0xff,0xff,0xff,0x00,0xc7,0xc7, + 0xc7,0xe1,0x81,0x00,0x00,0x00,0xb3,0x00,0xe6,0xe6,0xe6,0xf0,0x84,0xff,0xff,0xff,0xff,0x01,0xa0,0xa0,0xa0,0xd1,0xdc,0xdc,0xdc,0xeb,0x85,0xff,0xff,0xff,0xff,0x81, + 0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xe6,0xe6,0xe6,0xf0,0x82,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc, + 0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x00,0xe6,0xe6,0xe6,0xf0, + 0x84,0xff,0xff,0xff,0xff,0x00,0xe6,0xe6,0xe6,0xf0,0x86,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00, + 0x00,0xb3,0x01,0x6a,0x6a,0x6a,0xc2,0xf7,0xf7,0xf7,0xfa,0x84,0xff,0xff,0xff,0xff,0x01,0xf7,0xf7,0xf7,0xfa,0x6a,0x6a,0x6a,0xc2,0x81,0x00,0x00,0x00,0xb3,0x81,0xff, + 0xff,0xff,0xff,0x00,0xf7,0xf7,0xf7,0xfa,0x83,0xff,0xff,0xff,0xff,0x00,0xef,0xef,0xef,0xf5,0x81,0x00,0x00,0x00,0xb3,0x00,0xbb,0xbb,0xbb,0xdc,0x84,0xff,0xff,0xff, + 0xff,0x00,0xc7,0xc7,0xc7,0xe1,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xbf,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xbf, + 0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x00,0xbb,0xbb,0xbb,0xdc,0x81,0xff,0xff, + 0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x05,0x52,0x52,0x52,0xbd,0xc7,0xc7,0xc7,0xe1,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xef,0xef,0xef, + 0xf5,0xaf,0xaf,0xaf,0xd6,0x83,0x00,0x00,0x00,0xb3,0x06,0x7e,0x7e,0x7e,0xc7,0xd2,0xd2,0xd2,0xe6,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0xd2, + 0xd2,0xd2,0xe6,0x52,0x52,0x52,0xbd,0x82,0x00,0x00,0x00,0xb3,0x05,0x90,0x90,0x90,0xcc,0xe6,0xe6,0xe6,0xf0,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0xaf,0xaf,0xaf, + 0xd6,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x87,0x00,0x00,0x00,0xb3,0x02,0x52,0x52,0x52,0xbd,0xc7,0xc7,0xc7,0xe1,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff, + 0xff,0x01,0xdc,0xdc,0xdc,0xeb,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x00,0xbb,0xbb,0xbb,0xdc,0x81,0xdc,0xdc,0xdc,0xeb,0x04,0x6a,0x6a,0x6a,0xc2,0xef,0xef, + 0xef,0xf5,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0x90,0x90,0x90,0xcc,0x83,0x00,0x00,0x00,0xb3,0x04,0xaf,0xaf,0xaf,0xd6,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff, + 0xef,0xef,0xef,0xf5,0x90,0x90,0x90,0xcc,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x85,0x00,0x00,0x00,0xb3,0x01,0xbb,0xbb,0xbb,0xdc,0xdc,0xdc,0xdc,0xeb, + 0x81,0xff,0xff,0xff,0xff,0x02,0xf7,0xf7,0xf7,0xfa,0xdc,0xdc,0xdc,0xeb,0xbb,0xbb,0xbb,0xdc,0x81,0x00,0x00,0x00,0xb3,0x06,0x52,0x52,0x52,0xbd,0xc7,0xc7,0xc7,0xe1, + 0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0xc7,0xc7,0xc7,0xe1,0x52,0x52,0x52,0xbd,0x82,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x02,0xdc, + 0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x02,0x33,0x33,0x33,0xb8,0xaf, + 0xaf,0xaf,0xd6,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x01,0xd2,0xd2,0xd2,0xe6,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81, + 0xdc,0xdc,0xdc,0xeb,0x00,0x52,0x52,0x52,0xbd,0x81,0x00,0x00,0x00,0xb3,0x00,0xbb,0xbb,0xbb,0xdc,0x81,0xdc,0xdc,0xdc,0xeb,0x00,0x90,0x90,0x90,0xcc,0x81,0x00,0x00, + 0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0xdc,0xdc,0xdc,0xeb,0x00,0x52,0x52,0x52,0xbd,0x85,0x00,0x00,0x00,0xb3,0x06,0x7e,0x7e,0x7e,0xc7,0xd2,0xd2,0xd2,0xe6,0xf7, + 0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0xd2,0xd2,0xd2,0xe6,0x52,0x52,0x52,0xbd,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff, + 0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x84,0x00,0x00,0x00,0xb3,0x00,0x52,0x52,0x52,0xbd,0x81,0xdc,0xdc,0xdc,0xeb, + 0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0x6a,0x6a,0x6a,0xc2,0x81,0xdc,0xdc,0xdc,0xeb,0x00,0xd2,0xd2,0xd2,0xe6,0x82,0x00,0x00,0x00,0xb3,0x81,0xdc, + 0xdc,0xdc,0xeb,0x04,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0x52,0x52,0x52,0xbd,0xc7,0xc7,0xc7,0xe1,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x01,0xdc,0xdc, + 0xdc,0xeb,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0xdc,0xdc,0xdc,0xeb,0x05,0x7e,0x7e,0x7e,0xc7,0xc7,0xc7,0xc7,0xe1,0xff,0xff, + 0xff,0xff,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0xbb,0xbb,0xbb,0xdc,0x81,0xdc,0xdc,0xdc,0xeb,0x04,0x6a,0x6a,0x6a,0xc2,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff, + 0xef,0xef,0xef,0xf5,0x90,0x90,0x90,0xcc,0x81,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0xdc,0xdc,0xdc,0xeb,0x02,0x6a,0x6a,0x6a,0xc2,0x00,0x00,0x00,0xb3, + 0xbb,0xbb,0xbb,0xdc,0x81,0xdc,0xdc,0xdc,0xeb,0x04,0x6a,0x6a,0x6a,0xc2,0xef,0xef,0xef,0xf5,0xff,0xff,0xff,0xff,0xef,0xef,0xef,0xf5,0x90,0x90,0x90,0xcc,0x82,0x00, + 0x00,0x00,0xb3,0x01,0x33,0x33,0x33,0xb8,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff,0xff,0x01,0xd2,0xd2,0xd2,0xe6,0x6a,0x6a,0x6a,0xc2,0x81,0xdc,0xdc,0xdc,0xeb,0x00, + 0xa0,0xa0,0xa0,0xd1,0x81,0x00,0x00,0x00,0xb3,0x01,0x6a,0x6a,0x6a,0xc2,0xd2,0xd2,0xd2,0xe6,0x81,0xff,0xff,0xff,0xff,0x02,0xef,0xef,0xef,0xf5,0xaf,0xaf,0xaf,0xd6, + 0x33,0x33,0x33,0xb8,0x86,0x00,0x00,0x00,0xb3,0x06,0x7e,0x7e,0x7e,0xc7,0xd2,0xd2,0xd2,0xe6,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0xd2,0xd2, + 0xd2,0xe6,0x52,0x52,0x52,0xbd,0x81,0x00,0x00,0x00,0xb3,0x81,0xdc,0xdc,0xdc,0xeb,0x05,0xbb,0xbb,0xbb,0xdc,0xa0,0xa0,0xa0,0xd1,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff, + 0xff,0xdc,0xdc,0xdc,0xeb,0x6a,0x6a,0x6a,0xc2,0x82,0x00,0x00,0x00,0xb3,0x05,0x33,0x33,0x33,0xb8,0xc7,0xc7,0xc7,0xe1,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xdc, + 0xdc,0xdc,0xeb,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x86,0x00,0x00,0x00,0xb3,0x81,0xdc,0xdc,0xdc,0xeb,0x02,0xbb,0xbb,0xbb,0xdc, + 0x00,0x00,0x00,0xb3,0x6a,0x6a,0x6a,0xc2,0x81,0xdc,0xdc,0xdc,0xeb,0x01,0xa0,0xa0,0xa0,0xd1,0xbb,0xbb,0xbb,0xdc,0x81,0xff,0xff,0xff,0xff,0x01,0xc7,0xc7,0xc7,0xe1, + 0x33,0x33,0x33,0xb8,0x81,0x00,0x00,0x00,0xb3,0x08,0x33,0x33,0x33,0xb8,0xc7,0xc7,0xc7,0xe1,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0xc7,0xc7, + 0xc7,0xe1,0x52,0x52,0x52,0xbd,0xbb,0xbb,0xbb,0xdc,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x00,0xf7,0xf7,0xf7,0xfa,0x81,0xdc,0xdc,0xdc,0xeb,0x81,0x6a,0x6a, + 0x6a,0xc2,0x81,0xdc,0xdc,0xdc,0xeb,0x04,0xa0,0xa0,0xa0,0xd1,0xaf,0xaf,0xaf,0xd6,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0xb3,0x81,0xdc,0xdc,0xdc, + 0xeb,0x00,0xbb,0xbb,0xbb,0xdc,0x81,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0xdc,0xdc,0xdc,0xeb,0x00,0x6a,0x6a,0x6a,0xc2,0x82,0x00,0x00,0x00,0xb3,0x01, + 0xaf,0xaf,0xaf,0xd6,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x03,0xd2,0xd2,0xd2,0xe6,0x7e,0x7e,0x7e,0xc7,0xdc,0xdc,0xdc,0xeb,0xe6,0xe6,0xe6,0xf0,0x81,0xff, + 0xff,0xff,0xff,0x00,0xef,0xef,0xef,0xf5,0x81,0xdc,0xdc,0xdc,0xeb,0x01,0x00,0x00,0x00,0xb3,0xbb,0xbb,0xbb,0xdc,0x81,0xdc,0xdc,0xdc,0xeb,0x82,0x00,0x00,0x00,0xb3, + 0x06,0x52,0x52,0x52,0xbd,0xc7,0xc7,0xc7,0xe1,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0xc7,0xc7,0xc7,0xe1,0x52,0x52,0x52,0xbd,0x82,0x00,0x00, + 0x00,0xb3,0x81,0xdc,0xdc,0xdc,0xeb,0x05,0xbb,0xbb,0xbb,0xdc,0xa0,0xa0,0xa0,0xd1,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0x6a,0x6a,0x6a,0xc2, + 0x82,0x00,0x00,0x00,0xb3,0x01,0xaf,0xaf,0xaf,0xd6,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x01,0xd2,0xd2,0xd2,0xe6,0x7e,0x7e,0x7e,0xc7,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xbf,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xbf,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81, + 0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x00,0xd2,0xd2,0xd2,0xe6,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x9a,0x00,0x00, + 0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0xa1,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x87,0x00,0x00,0x00,0xb3, + 0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x8d,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf, + 0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0xa9,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x81, + 0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0xb1,0x00,0x00,0x00,0xb3,0x01,0x6a,0x6a,0x6a,0xc2,0x52,0x52,0x52,0xbd,0xbe,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e, + 0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x86,0x00,0x00,0x00,0xb3,0x01,0x33,0x33,0x33,0xb8,0x7e,0x7e,0x7e,0xc7,0x95,0x00,0x00,0x00,0xb3,0x81,0xff, + 0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x9d,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x83,0x00,0x00,0x00, + 0xb3,0x01,0x7e,0x7e,0x7e,0xc7,0x33,0x33,0x33,0xb8,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xdd,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xbf,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xef,0xef,0xef,0xf5,0x81,0xdc,0xdc,0xdc,0xeb,0x00,0xef,0xef,0xef, + 0xf5,0x82,0xff,0xff,0xff,0xff,0x00,0x6a,0x6a,0x6a,0xc2,0x9a,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0xa1,0x00,0x00,0x00,0xb3,0x81, + 0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x87,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x8d,0x00,0x00,0x00,0xb3,0x81,0xff,0xff, + 0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0xa9,0x00,0x00,0x00,0xb3,0x00,0xdc, + 0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0xb0,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf, + 0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0xbd,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x85, + 0x00,0x00,0x00,0xb3,0x03,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb,0x94,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00, + 0xdc,0xdc,0xdc,0xeb,0x9d,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x03,0xdc,0xdc, + 0xdc,0xeb,0xff,0xff,0xff,0xff,0xf7,0xf7,0xf7,0xfa,0x33,0x33,0x33,0xb8,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xdc,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xbf,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x87,0xff,0xff,0xff,0xff,0x00,0xbb,0xbb,0xbb,0xdc,0x9b,0x00,0x00,0x00,0xb3, + 0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0xa1,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x87,0x00,0x00,0x00,0xb3,0x00,0xef, + 0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x81,0xbb,0xbb,0xbb,0xdc,0x8b,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3, + 0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0xa9,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0x00,0x00, + 0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0xb0,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6, + 0xbd,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x85,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff, + 0xff,0xff,0xff,0x94,0x00,0x00,0x00,0xb3,0x81,0x7e,0x7e,0x7e,0xc7,0x00,0x6a,0x6a,0x6a,0xc2,0x9d,0x00,0x00,0x00,0xb3,0x00,0x33,0x33,0x33,0xb8,0x81,0x7e,0x7e,0x7e, + 0xc7,0x00,0x52,0x52,0x52,0xbd,0x82,0x00,0x00,0x00,0xb3,0x82,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xdc, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xbf,0x00,0x00,0x00,0xb3,0x00,0x6a,0x6a,0x6a,0xc2,0x85,0xdc,0xdc,0xdc,0xeb,0x01,0xbb,0xbb, + 0xbb,0xdc,0x7e,0x7e,0x7e,0xc7,0x9c,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0xa1,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00, + 0xdc,0xdc,0xdc,0xeb,0x87,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x83,0xff,0xff,0xff,0xff,0x8b,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc, + 0xdc,0xeb,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x81,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0xa9,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff, + 0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x81,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0xb0,0x00,0x00,0x00,0xb3,0x03,0x90,0x90,0x90,0xcc,0xf7,0xf7,0xf7,0xfa, + 0xef,0xef,0xef,0xf5,0x52,0x52,0x52,0xbd,0xbd,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x86,0x00,0x00,0x00, + 0xb3,0x02,0xdc,0xdc,0xdc,0xeb,0xff,0xff,0xff,0xff,0xaf,0xaf,0xaf,0xd6,0xbc,0x00,0x00,0x00,0xb3,0x02,0xaf,0xaf,0xaf,0xd6,0xff,0xff,0xff,0xff,0xdc,0xdc,0xdc,0xeb, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xdd,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xe5,0x00,0x00,0x00,0xb3,0x00,0xa0, + 0xa0,0xa0,0xd1,0x81,0xaf,0xaf,0xaf,0xd6,0xa1,0x00,0x00,0x00,0xb3,0x81,0xaf,0xaf,0xaf,0xd6,0x00,0xa0,0xa0,0xa0,0xd1,0x88,0x00,0x00,0x00,0xb3,0x01,0xa0,0xa0,0xa0, + 0xd1,0xd2,0xd2,0xd2,0xe6,0x81,0xdc,0xdc,0xdc,0xeb,0x8b,0x00,0x00,0x00,0xb3,0x81,0xaf,0xaf,0xaf,0xd6,0x02,0xa0,0xa0,0xa0,0xd1,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e, + 0xc7,0x81,0xaf,0xaf,0xaf,0xd6,0x00,0x52,0x52,0x52,0xbd,0xa9,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x81, + 0xaf,0xaf,0xaf,0xd6,0x00,0xa0,0xa0,0xa0,0xd1,0xf2,0x00,0x00,0x00,0xb3,0x00,0x52,0x52,0x52,0xbd,0x81,0xaf,0xaf,0xaf,0xd6,0x00,0x7e,0x7e,0x7e,0xc7,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xa7,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xbb,0x00,0x00,0x00,0xb3,0x00,0x6a,0x6a, + 0x6a,0xc2,0x82,0xaf,0xaf,0xaf,0xd6,0x01,0x90,0x90,0x90,0xcc,0x33,0x33,0x33,0xb8,0x87,0x00,0x00,0x00,0xb3,0x00,0x33,0x33,0x33,0xb8,0x89,0x00,0x00,0x00,0xb3,0x01, + 0x6a,0x6a,0x6a,0xc2,0xa0,0xa0,0xa0,0xd1,0x82,0xaf,0xaf,0xaf,0xd6,0x00,0x6a,0x6a,0x6a,0xc2,0xff,0x00,0x00,0x00,0xb3,0xcb,0x00,0x00,0x00,0xb3,0x01,0x33,0x33,0x33, + 0xb8,0x7e,0x7e,0x7e,0xc7,0x83,0xaf,0xaf,0xaf,0xd6,0x01,0x7e,0x7e,0x7e,0xc7,0x52,0x52,0x52,0xbd,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xd0,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xd0,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x86,0x00,0x00,0x00,0xb3, + 0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x8b,0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00, + 0x00,0xb3,0xe6,0xe6,0xe6,0xf0,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x87,0x00,0x00,0x00,0xb3,0x00,0x6a,0x6a,0x6a,0xc2,0x83,0xff,0xff,0xff,0xff,0x01, + 0x52,0x52,0x52,0xbd,0x00,0x00,0x00,0xb3,0x8a,0xff,0xff,0xff,0xff,0x82,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x86,0x00,0x00,0x00, + 0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x86,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x8a, + 0x00,0x00,0x00,0xb3,0x01,0x7e,0x7e,0x7e,0xc7,0xef,0xef,0xef,0xf5,0x84,0xff,0xff,0xff,0xff,0x04,0xf7,0xf7,0xf7,0xfa,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0x6a, + 0x6a,0x6a,0xc2,0xf7,0xf7,0xf7,0xfa,0x82,0xff,0xff,0xff,0xff,0x00,0xc7,0xc7,0xc7,0xe1,0x88,0x00,0x00,0x00,0xb3,0x01,0x90,0x90,0x90,0xcc,0xe6,0xe6,0xe6,0xf0,0x85, + 0xff,0xff,0xff,0xff,0x01,0xef,0xef,0xef,0xf5,0x7e,0x7e,0x7e,0xc7,0x82,0x00,0x00,0x00,0xb3,0x00,0xe6,0xe6,0xe6,0xf0,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf, + 0xd6,0x87,0x00,0x00,0x00,0xb3,0x00,0x6a,0x6a,0x6a,0xc2,0x83,0xff,0xff,0xff,0xff,0x02,0x52,0x52,0x52,0xbd,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x82,0xff,0xff, + 0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x89,0x00,0x00,0x00,0xb3,0x8b,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x84,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7, + 0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x8a,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x91,0x00,0x00,0x00,0xb3,0x82,0xff, + 0xff,0xff,0xff,0x00,0xc7,0xc7,0xc7,0xe1,0x86,0x00,0x00,0x00,0xb3,0x00,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x00,0xe6,0xe6,0xe6,0xf0,0x83,0x00,0x00,0x00, + 0xb3,0x00,0x90,0x90,0x90,0xcc,0x82,0xff,0xff,0xff,0xff,0x00,0xf7,0xf7,0xf7,0xfa,0x88,0x00,0x00,0x00,0xb3,0x00,0xd2,0xd2,0xd2,0xe6,0x82,0xff,0xff,0xff,0xff,0x02, + 0xc7,0xc7,0xc7,0xe1,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x83,0x00,0x00,0x00,0xb3,0x01,0x33,0x33,0x33,0xb8, + 0xf7,0xf7,0xf7,0xfa,0x82,0xff,0xff,0xff,0xff,0x02,0xd2,0xd2,0xd2,0xe6,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6, + 0x85,0x00,0x00,0x00,0xb3,0x01,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0x83,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e, + 0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x86,0x00,0x00,0x00,0xb3, + 0x00,0xaf,0xaf,0xaf,0xd6,0x84,0xff,0xff,0xff,0xff,0x85,0x00,0x00,0x00,0xb3,0x01,0x52,0x52,0x52,0xbd,0xc7,0xc7,0xc7,0xe1,0x87,0xff,0xff,0xff,0xff,0x02,0xef,0xef, + 0xef,0xf5,0xbb,0xbb,0xbb,0xdc,0x52,0x52,0x52,0xbd,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xcd,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xd0,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x86,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff, + 0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x8b,0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0xa0,0xa0,0xa0,0xd1,0x82,0xff,0xff, + 0xff,0xff,0x00,0xe6,0xe6,0xe6,0xf0,0x87,0x00,0x00,0x00,0xb3,0x00,0xc7,0xc7,0xc7,0xe1,0x82,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3, + 0x8a,0xff,0xff,0xff,0xff,0x82,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x86,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff, + 0xff,0xff,0xff,0x86,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x89,0x00,0x00,0x00,0xb3,0x00,0x90,0x90,0x90, + 0xcc,0x88,0xff,0xff,0xff,0xff,0x01,0xd2,0xd2,0xd2,0xe6,0xe6,0xe6,0xe6,0xf0,0x82,0xff,0xff,0xff,0xff,0x00,0xe6,0xe6,0xe6,0xf0,0x88,0x00,0x00,0x00,0xb3,0x00,0xaf, + 0xaf,0xaf,0xd6,0x89,0xff,0xff,0xff,0xff,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x82,0xff,0xff,0xff,0xff,0x00,0xe6,0xe6,0xe6, + 0xf0,0x87,0x00,0x00,0x00,0xb3,0x00,0xc7,0xc7,0xc7,0xe1,0x82,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x82, + 0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x89,0x00,0x00,0x00,0xb3,0x8b,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x84,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e, + 0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x8a,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x90,0x00,0x00,0x00,0xb3, + 0x00,0x90,0x90,0x90,0xcc,0x82,0xff,0xff,0xff,0xff,0x00,0xf7,0xf7,0xf7,0xfa,0x85,0x00,0x00,0x00,0xb3,0x00,0x6a,0x6a,0x6a,0xc2,0x83,0xff,0xff,0xff,0xff,0x00,0x52, + 0x52,0x52,0xbd,0x83,0x00,0x00,0x00,0xb3,0x00,0xef,0xef,0xef,0xf5,0x82,0xff,0xff,0xff,0xff,0x00,0x90,0x90,0x90,0xcc,0x86,0x00,0x00,0x00,0xb3,0x00,0x52,0x52,0x52, + 0xbd,0x83,0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x83,0x00,0x00, + 0x00,0xb3,0x00,0xbb,0xbb,0xbb,0xdc,0x82,0xff,0xff,0xff,0xff,0x03,0xf7,0xf7,0xf7,0xfa,0x33,0x33,0x33,0xb8,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff, + 0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x85,0x00,0x00,0x00,0xb3,0x00,0xbb,0xbb,0xbb,0xdc,0x84,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3, + 0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x85,0x00, + 0x00,0x00,0xb3,0x01,0x52,0x52,0x52,0xbd,0xf7,0xf7,0xf7,0xfa,0x84,0xff,0xff,0xff,0xff,0x84,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x8c,0xff,0xff,0xff,0xff, + 0x00,0x6a,0x6a,0x6a,0xc2,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xcc,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xd0,0x00, + 0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x86,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf, + 0xd6,0x82,0x00,0x00,0x00,0xb3,0x8b,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x00,0xf7,0xf7,0xf7,0xfa,0x82,0xff,0xff,0xff,0xff,0x00, + 0x6a,0x6a,0x6a,0xc2,0x85,0x00,0x00,0x00,0xb3,0x01,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0x82,0xff,0xff,0xff,0xff,0x00,0x90,0x90,0x90,0xcc,0x81,0x00,0x00,0x00, + 0xb3,0x8a,0xff,0xff,0xff,0xff,0x82,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x86,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82, + 0xff,0xff,0xff,0xff,0x86,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x88,0x00,0x00,0x00,0xb3,0x01,0x33,0x33, + 0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0x83,0xff,0xff,0xff,0xff,0x01,0xdc,0xdc,0xdc,0xeb,0xe6,0xe6,0xe6,0xf0,0x86,0xff,0xff,0xff,0xff,0x01,0xe6,0xe6,0xe6,0xf0,0x33,0x33, + 0x33,0xb8,0x88,0x00,0x00,0x00,0xb3,0x01,0x52,0x52,0x52,0xbd,0xf7,0xf7,0xf7,0xfa,0x88,0xff,0xff,0xff,0xff,0x01,0xf7,0xf7,0xf7,0xfa,0x52,0x52,0x52,0xbd,0x81,0x00, + 0x00,0x00,0xb3,0x00,0xf7,0xf7,0xf7,0xfa,0x82,0xff,0xff,0xff,0xff,0x00,0x6a,0x6a,0x6a,0xc2,0x85,0x00,0x00,0x00,0xb3,0x01,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa, + 0x82,0xff,0xff,0xff,0xff,0x00,0x90,0x90,0x90,0xcc,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x89,0x00, + 0x00,0x00,0xb3,0x8b,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x84,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf, + 0xd6,0x8a,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x90,0x00,0x00,0x00,0xb3,0x00,0xbb,0xbb,0xbb,0xdc,0x83,0xff,0xff,0xff,0xff,0x00, + 0x7e,0x7e,0x7e,0xc7,0x84,0x00,0x00,0x00,0xb3,0x00,0xbb,0xbb,0xbb,0xdc,0x83,0xff,0xff,0xff,0xff,0x00,0xa0,0xa0,0xa0,0xd1,0x83,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf, + 0xaf,0xd6,0x82,0xff,0xff,0xff,0xff,0x00,0xd2,0xd2,0xd2,0xe6,0x86,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0xff,0xff,0xff,0xff,0x00,0xe6,0xe6,0xe6,0xf0, + 0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x00,0x52,0x52,0x52,0xbd,0x83,0xff, + 0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x84,0x00,0x00,0x00, + 0xb3,0x00,0x6a,0x6a,0x6a,0xc2,0x85,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00, + 0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x85,0x00,0x00,0x00,0xb3,0x00,0xd2,0xd2,0xd2,0xe6,0x85,0xff,0xff, + 0xff,0xff,0x83,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x8d,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xcc,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xd0,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x86,0x00, + 0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x82,0xff,0xff,0xff,0xff,0x00,0xef,0xef,0xef, + 0xf5,0x87,0xaf,0xaf,0xaf,0xd6,0x00,0x52,0x52,0x52,0xbd,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0xff,0xff,0xff,0xff,0x00,0xd2,0xd2,0xd2,0xe6,0x85, + 0x7e,0x7e,0x7e,0xc7,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0xff,0xff,0xff,0xff,0x00,0xef,0xef,0xef,0xf5,0x82,0x00,0x00,0x00,0xb3,0x82,0xff,0xff,0xff,0xff,0x00,0xef,0xef, + 0xef,0xf5,0x86,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x86,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb, + 0x82,0xff,0xff,0xff,0xff,0x86,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x88,0x00,0x00,0x00,0xb3,0x00,0xa0, + 0xa0,0xa0,0xd1,0x82,0xff,0xff,0xff,0xff,0x01,0xf7,0xf7,0xf7,0xfa,0x6a,0x6a,0x6a,0xc2,0x81,0x00,0x00,0x00,0xb3,0x01,0x7e,0x7e,0x7e,0xc7,0xef,0xef,0xef,0xf5,0x83, + 0xff,0xff,0xff,0xff,0x01,0xe6,0xe6,0xe6,0xf0,0x33,0x33,0x33,0xb8,0x8a,0x00,0x00,0x00,0xb3,0x00,0x6a,0x6a,0x6a,0xc2,0x81,0xf7,0xf7,0xf7,0xfa,0x04,0xa0,0xa0,0xa0, + 0xd1,0x33,0x33,0x33,0xb8,0x00,0x00,0x00,0xb3,0x6a,0x6a,0x6a,0xc2,0xd2,0xd2,0xd2,0xe6,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3, + 0x00,0xaf,0xaf,0xaf,0xd6,0x82,0xff,0xff,0xff,0xff,0x00,0xd2,0xd2,0xd2,0xe6,0x85,0x7e,0x7e,0x7e,0xc7,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0xff,0xff,0xff,0xff,0x00,0xef, + 0xef,0xef,0xf5,0x82,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x89,0x00,0x00,0x00,0xb3,0x82,0xff,0xff,0xff, + 0xff,0x00,0xef,0xef,0xef,0xf5,0x87,0xaf,0xaf,0xaf,0xd6,0x00,0x52,0x52,0x52,0xbd,0x84,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00, + 0xaf,0xaf,0xaf,0xd6,0x8a,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x90,0x00,0x00,0x00,0xb3,0x00,0xef,0xef,0xef,0xf5,0x83,0xff,0xff, + 0xff,0xff,0x00,0xbb,0xbb,0xbb,0xdc,0x84,0x00,0x00,0x00,0xb3,0x00,0xef,0xef,0xef,0xf5,0x83,0xff,0xff,0xff,0xff,0x00,0xd2,0xd2,0xd2,0xe6,0x83,0x00,0x00,0x00,0xb3, + 0x01,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0x82,0xff,0xff,0xff,0xff,0x00,0x90,0x90,0x90,0xcc,0x85,0x7e,0x7e,0x7e,0xc7,0x00,0xef,0xef,0xef,0xf5,0x82,0xff,0xff, + 0xff,0xff,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3, + 0x00,0xc7,0xc7,0xc7,0xe1,0x82,0xff,0xff,0xff,0xff,0x00,0xe6,0xe6,0xe6,0xf0,0x82,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf, + 0xaf,0xaf,0xd6,0x84,0x00,0x00,0x00,0xb3,0x00,0xe6,0xe6,0xe6,0xf0,0x85,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e, + 0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x84,0x00,0x00,0x00,0xb3,0x00, + 0x90,0x90,0x90,0xcc,0x86,0xff,0xff,0xff,0xff,0x82,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x83,0xff,0xff,0xff,0xff,0x02,0xf7,0xf7,0xf7,0xfa,0xaf,0xaf,0xaf, + 0xd6,0x52,0x52,0x52,0xbd,0x81,0x00,0x00,0x00,0xb3,0x02,0x6a,0x6a,0x6a,0xc2,0xaf,0xaf,0xaf,0xd6,0xef,0xef,0xef,0xf5,0x82,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e, + 0xc7,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xcc,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xd0,0x00,0x00,0x00,0xb3,0x00, + 0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x86,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00, + 0x00,0xb3,0x82,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x8a,0x00,0x00,0x00,0xb3,0x00,0x52,0x52,0x52,0xbd,0x8d,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6, + 0x82,0x00,0x00,0x00,0xb3,0x82,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x89,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x86,0x00, + 0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x86,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf, + 0xd6,0x88,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0xff,0xff,0xff,0xff,0x00,0xbb,0xbb,0xbb,0xdc,0x82,0x00,0x00,0x00,0xb3,0x01,0x33,0x33,0x33,0xb8,0xe6, + 0xe6,0xe6,0xf0,0x83,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x8c,0x00,0x00,0x00,0xb3,0x01,0x7e,0x7e,0x7e,0xc7,0x6a,0x6a,0x6a,0xc2,0x83,0x00,0x00,0x00,0xb3, + 0x00,0x33,0x33,0x33,0xb8,0x82,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x00,0x52,0x52,0x52,0xbd,0x8d,0xff,0xff,0xff,0xff,0x00,0xaf, + 0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x89,0x00,0x00,0x00,0xb3,0x82,0xff,0xff,0xff, + 0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x8d,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x8a,0x00,0x00,0x00,0xb3,0x00, + 0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x8f,0x00,0x00,0x00,0xb3,0x00,0x6a,0x6a,0x6a,0xc2,0x84,0xff,0xff,0xff,0xff,0x00,0xef,0xef,0xef,0xf5,0x83,0x00,0x00, + 0x00,0xb3,0x00,0x6a,0x6a,0x6a,0xc2,0x84,0xff,0xff,0xff,0xff,0x00,0xf7,0xf7,0xf7,0xfa,0x84,0x00,0x00,0x00,0xb3,0x00,0xc7,0xc7,0xc7,0xe1,0x8c,0xff,0xff,0xff,0xff, + 0x00,0xf7,0xf7,0xf7,0xfa,0x82,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0x6a, + 0x6a,0x6a,0xc2,0x83,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf, + 0xd6,0x83,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x86,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82, + 0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x83,0x00,0x00,0x00,0xb3,0x01,0x33,0x33, + 0x33,0xb8,0xef,0xef,0xef,0xf5,0x86,0xff,0xff,0xff,0xff,0x82,0x00,0x00,0x00,0xb3,0x00,0xe6,0xe6,0xe6,0xf0,0x82,0xff,0xff,0xff,0xff,0x01,0xe6,0xe6,0xe6,0xf0,0x33, + 0x33,0x33,0xb8,0x85,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xcc,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xd0,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x86, + 0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x82,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc, + 0xdc,0xeb,0x8b,0x00,0x00,0x00,0xb3,0x00,0xc7,0xc7,0xc7,0xe1,0x8b,0xff,0xff,0xff,0xff,0x01,0xf7,0xf7,0xf7,0xfa,0x33,0x33,0x33,0xb8,0x82,0x00,0x00,0x00,0xb3,0x82, + 0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x89,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x86,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc, + 0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x86,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x88,0x00,0x00,0x00,0xb3, + 0x00,0xaf,0xaf,0xaf,0xd6,0x82,0xff,0xff,0xff,0xff,0x00,0xbb,0xbb,0xbb,0xdc,0x82,0x00,0x00,0x00,0xb3,0x00,0xd2,0xd2,0xd2,0xe6,0x85,0xff,0xff,0xff,0xff,0x00,0x7e, + 0x7e,0x7e,0xc7,0x91,0x00,0x00,0x00,0xb3,0x00,0x52,0x52,0x52,0xbd,0x82,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0x00,0x00,0x00,0xb3,0x00,0xc7,0xc7,0xc7, + 0xe1,0x8b,0xff,0xff,0xff,0xff,0x01,0xf7,0xf7,0xf7,0xfa,0x33,0x33,0x33,0xb8,0x82,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0xff,0xff,0xff,0xff,0x00,0x7e, + 0x7e,0x7e,0xc7,0x89,0x00,0x00,0x00,0xb3,0x82,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x8d,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff, + 0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x8a,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x8f,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x85, + 0xff,0xff,0xff,0xff,0x00,0x6a,0x6a,0x6a,0xc2,0x82,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x85,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x83,0x00,0x00, + 0x00,0xb3,0x00,0x52,0x52,0x52,0xbd,0x8c,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff, + 0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x00,0xc7,0xc7,0xc7,0xe1,0x83,0x00,0x00,0x00,0xb3,0x00,0x7e, + 0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x01,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0x82,0xff,0xff,0xff,0xff, + 0x00,0xef,0xef,0xef,0xf5,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf, + 0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x83,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x83,0xff,0xff,0xff, + 0xff,0x00,0xef,0xef,0xef,0xf5,0x82,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0x6a,0x6a,0x6a,0xc2,0x83,0xff,0xff,0xff,0xff,0x00,0x6a,0x6a,0x6a,0xc2,0x86, + 0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xcc,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xd0,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x86,0x00,0x00,0x00,0xb3, + 0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x82,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x8b,0x00, + 0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x8b,0xff,0xff,0xff,0xff,0x00,0xc7,0xc7,0xc7,0xe1,0x83,0x00,0x00,0x00,0xb3,0x82,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc, + 0xeb,0x89,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x86,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x86, + 0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x88,0x00,0x00,0x00,0xb3,0x00,0x6a,0x6a,0x6a,0xc2,0x82,0xff,0xff, + 0xff,0xff,0x03,0xf7,0xf7,0xf7,0xfa,0x6a,0x6a,0x6a,0xc2,0x00,0x00,0x00,0xb3,0xc7,0xc7,0xc7,0xe1,0x82,0xff,0xff,0xff,0xff,0x00,0xf7,0xf7,0xf7,0xfa,0x82,0xff,0xff, + 0xff,0xff,0x01,0xf7,0xf7,0xf7,0xfa,0x33,0x33,0x33,0xb8,0x8f,0x00,0x00,0x00,0xb3,0x01,0xa0,0xa0,0xa0,0xd1,0xef,0xef,0xef,0xf5,0x82,0xff,0xff,0xff,0xff,0x00,0xd2, + 0xd2,0xd2,0xe6,0x82,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x8b,0xff,0xff,0xff,0xff,0x00,0xc7,0xc7,0xc7,0xe1,0x83,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf, + 0xd6,0x82,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x89,0x00,0x00,0x00,0xb3,0x82,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x8d,0x00,0x00,0x00,0xb3,0x00, + 0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x8a,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x8f,0x00,0x00, + 0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x81,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3, + 0x00,0xe6,0xe6,0xe6,0xf0,0x81,0xff,0xff,0xff,0xff,0x01,0xe6,0xe6,0xe6,0xf0,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x00,0xbb,0xbb,0xbb,0xdc,0x84,0x00,0x00, + 0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x8b,0xff,0xff,0xff,0xff,0x00,0x52,0x52,0x52,0xbd,0x82,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff, + 0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x01,0xf7,0xf7,0xf7,0xfa,0x33,0x33,0x33,0xb8,0x83,0x00,0x00,0x00,0xb3, + 0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x00,0xd2,0xd2,0xd2,0xe6,0x82,0xff,0xff,0xff,0xff,0x01,0xf7, + 0xf7,0xf7,0xfa,0x90,0x90,0x90,0xcc,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff, + 0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x82,0x00,0x00,0x00,0xb3,0x00,0x6a,0x6a,0x6a,0xc2,0x83,0xff, + 0xff,0xff,0xff,0x01,0xaf,0xaf,0xaf,0xd6,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0xff,0xff,0xff,0xff, + 0x00,0xc7,0xc7,0xc7,0xe1,0x87,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xcc,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xd0,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff, + 0xff,0x86,0x7e,0x7e,0x7e,0xc7,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x82,0xff,0xff,0xff,0xff,0x00, + 0xf7,0xf7,0xf7,0xfa,0x86,0xdc,0xdc,0xdc,0xeb,0x00,0x6a,0x6a,0x6a,0xc2,0x84,0x00,0x00,0x00,0xb3,0x00,0xef,0xef,0xef,0xf5,0x82,0xff,0xff,0xff,0xff,0x00,0x52,0x52, + 0x52,0xbd,0x81,0x00,0x00,0x00,0xb3,0x01,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0x82,0xff,0xff,0xff,0xff,0x00,0x52,0x52,0x52,0xbd,0x83,0x00,0x00,0x00,0xb3,0x82, + 0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x89,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x86,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc, + 0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x86,0x7e,0x7e,0x7e,0xc7,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x89,0x00,0x00,0x00,0xb3, + 0x00,0xd2,0xd2,0xd2,0xe6,0x83,0xff,0xff,0xff,0xff,0x00,0xe6,0xe6,0xe6,0xf0,0x83,0xff,0xff,0xff,0xff,0x01,0xa0,0xa0,0xa0,0xd1,0xbb,0xbb,0xbb,0xdc,0x82,0xff,0xff, + 0xff,0xff,0x00,0xd2,0xd2,0xd2,0xe6,0x8c,0x00,0x00,0x00,0xb3,0x02,0x90,0x90,0x90,0xcc,0xc7,0xc7,0xc7,0xe1,0xf7,0xf7,0xf7,0xfa,0x84,0xff,0xff,0xff,0xff,0x00,0xa0, + 0xa0,0xa0,0xd1,0x83,0x00,0x00,0x00,0xb3,0x00,0xef,0xef,0xef,0xf5,0x82,0xff,0xff,0xff,0xff,0x00,0x52,0x52,0x52,0xbd,0x81,0x00,0x00,0x00,0xb3,0x01,0x33,0x33,0x33, + 0xb8,0xf7,0xf7,0xf7,0xfa,0x82,0xff,0xff,0xff,0xff,0x00,0x52,0x52,0x52,0xbd,0x83,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x89,0xff,0xff,0xff,0xff,0x00,0xaf, + 0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x82,0xff,0xff,0xff,0xff,0x00,0xf7,0xf7,0xf7,0xfa,0x86,0xdc,0xdc,0xdc,0xeb,0x00,0x6a,0x6a,0x6a,0xc2,0x85,0x00,0x00,0x00, + 0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x8a,0x00,0x00,0x00,0xb3,0x00,0xe6,0xe6,0xe6,0xf0,0x82,0xff,0xff,0xff,0xff,0x00, + 0x33,0x33,0x33,0xb8,0x8d,0x00,0x00,0x00,0xb3,0x00,0x33,0x33,0x33,0xb8,0x82,0xff,0xff,0xff,0xff,0x01,0xd2,0xd2,0xd2,0xe6,0xc7,0xc7,0xc7,0xe1,0x81,0xff,0xff,0xff, + 0xff,0x00,0xe6,0xe6,0xe6,0xf0,0x81,0x00,0x00,0x00,0xb3,0x00,0x52,0x52,0x52,0xbd,0x82,0xff,0xff,0xff,0xff,0x01,0xaf,0xaf,0xaf,0xd6,0xd2,0xd2,0xd2,0xe6,0x81,0xff, + 0xff,0xff,0xff,0x00,0xef,0xef,0xef,0xf5,0x84,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x82,0xff,0xff,0xff,0xff,0x00,0xc7,0xc7,0xc7,0xe1,0x82,0x00,0x00,0x00, + 0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0xff,0xff,0xff,0xff,0x00,0xc7,0xc7,0xc7,0xe1,0x83,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x88,0xff,0xff,0xff,0xff,0x01, + 0xe6,0xe6,0xe6,0xf0,0x90,0x90,0x90,0xcc,0x83,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00, + 0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x83,0xff,0xff,0xff,0xff,0x01,0xaf,0xaf,0xaf,0xd6,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00, + 0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff, + 0xff,0x82,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x02,0xef,0xef,0xef,0xf5,0x33,0x33,0x33,0xb8,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff, + 0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0xd2,0xd2,0xd2,0xe6,0x82,0xff,0xff,0xff,0xff,0x00,0xa0,0xa0,0xa0,0xd1,0x84,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb, + 0x85,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xcc,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xd0,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x8d,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x8a,0xff,0xff,0xff, + 0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x84,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00, + 0xa0,0xa0,0xa0,0xd1,0x82,0xff,0xff,0xff,0xff,0x00,0xd2,0xd2,0xd2,0xe6,0x84,0x00,0x00,0x00,0xb3,0x82,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x89,0x00,0x00, + 0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x86,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x8d,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6, + 0x89,0x00,0x00,0x00,0xb3,0x01,0x33,0x33,0x33,0xb8,0xe6,0xe6,0xe6,0xf0,0x86,0xff,0xff,0xff,0xff,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0x00,0x00,0x00,0xb3,0x00,0xe6,0xe6, + 0xe6,0xf0,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x89,0x00,0x00,0x00,0xb3,0x01,0x90,0x90,0x90,0xcc,0xef,0xef,0xef,0xf5,0x86,0xff,0xff,0xff,0xff,0x00, + 0xc7,0xc7,0xc7,0xe1,0x84,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0, + 0xa0,0xd1,0x82,0xff,0xff,0xff,0xff,0x00,0xd2,0xd2,0xd2,0xe6,0x84,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x89,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6, + 0x82,0x00,0x00,0x00,0xb3,0x8a,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x85,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf, + 0xaf,0xaf,0xd6,0x89,0x00,0x00,0x00,0xb3,0x00,0x90,0x90,0x90,0xcc,0x83,0xff,0xff,0xff,0xff,0x00,0xbb,0xbb,0xbb,0xdc,0x8d,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0, + 0xd1,0x82,0xff,0xff,0xff,0xff,0x01,0xaf,0xaf,0xaf,0xd6,0x90,0x90,0x90,0xcc,0x82,0xff,0xff,0xff,0xff,0x02,0x52,0x52,0x52,0xbd,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf, + 0xd6,0x82,0xff,0xff,0xff,0xff,0x01,0x52,0x52,0x52,0xbd,0xaf,0xaf,0xaf,0xd6,0x82,0xff,0xff,0xff,0xff,0x00,0x52,0x52,0x52,0xbd,0x84,0x00,0x00,0x00,0xb3,0x00,0xef, + 0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x01,0xf7,0xf7,0xf7,0xfa,0x33,0x33,0x33,0xb8,0x81,0x00,0x00,0x00,0xb3,0x00,0xef,0xef,0xef,0xf5,0x82,0xff,0xff,0xff,0xff, + 0x00,0x6a,0x6a,0x6a,0xc2,0x83,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x8a,0xff,0xff,0xff,0xff,0x01,0xdc,0xdc,0xdc,0xeb,0x33,0x33,0x33,0xb8,0x81,0x00,0x00, + 0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x03,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0x33,0x33,0x33,0xb8,0xef,0xef,0xef,0xf5,0x82,0xff,0xff, + 0xff,0xff,0x02,0xe6,0xe6,0xe6,0xf0,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e, + 0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00, + 0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x83,0xff,0xff,0xff,0xff,0x02,0x90,0x90,0x90,0xcc,0x00,0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x81,0x00,0x00, + 0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x84,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x85,0xff,0xff,0xff,0xff, + 0x00,0x7e,0x7e,0x7e,0xc7,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xcc,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xd0,0x00, + 0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x8d,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x8a,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e, + 0xc7,0x84,0x00,0x00,0x00,0xb3,0x01,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x00,0xef,0xef,0xef,0xf5,0x81,0x00,0x00,0x00,0xb3,0x00,0xe6, + 0xe6,0xe6,0xf0,0x82,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x84,0x00,0x00,0x00,0xb3,0x82,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x89,0x00,0x00,0x00, + 0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x86,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x8d,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x8b, + 0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x84,0xff,0xff,0xff,0xff,0x01,0xf7,0xf7,0xf7,0xfa,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x00,0x52,0x52,0x52, + 0xbd,0x83,0x7e,0x7e,0x7e,0xc7,0x88,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x86,0xff,0xff,0xff,0xff,0x01,0xf7,0xf7,0xf7,0xfa,0xaf,0xaf,0xaf,0xd6,0x85,0x00, + 0x00,0x00,0xb3,0x01,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x00,0xef,0xef,0xef,0xf5,0x81,0x00,0x00,0x00,0xb3,0x00,0xe6,0xe6,0xe6,0xf0, + 0x82,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x84,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x89,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00, + 0x00,0x00,0xb3,0x8a,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x85,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf, + 0xd6,0x88,0x00,0x00,0x00,0xb3,0x01,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0x84,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x8c,0x00,0x00,0x00,0xb3,0x00,0xc7, + 0xc7,0xc7,0xe1,0x82,0xff,0xff,0xff,0xff,0x02,0x6a,0x6a,0x6a,0xc2,0x00,0x00,0x00,0xb3,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00, + 0x00,0x00,0xb3,0xdc,0xdc,0xdc,0xeb,0x81,0xff,0xff,0xff,0xff,0x02,0xe6,0xe6,0xe6,0xf0,0x00,0x00,0x00,0xb3,0x6a,0x6a,0x6a,0xc2,0x82,0xff,0xff,0xff,0xff,0x00,0xaf, + 0xaf,0xaf,0xd6,0x84,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0xff,0xff,0xff,0xff,0x02,0xa0,0xa0,0xa0,0xd1,0x00,0x00,0x00,0xb3,0x90,0x90,0x90,0xcc,0x82, + 0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x84,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x8b,0xff,0xff,0xff,0xff,0x00,0xbb,0xbb,0xbb,0xdc,0x81,0x00,0x00, + 0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xaf,0xaf,0xaf,0xd6,0x83,0xff,0xff,0xff,0xff,0x02,0x6a, + 0x6a,0x6a,0xc2,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82, + 0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x02,0x00,0x00,0x00,0xb3,0x33,0x33,0x33, + 0xb8,0xf7,0xf7,0xf7,0xfa,0x82,0xff,0xff,0xff,0xff,0x00,0xd2,0xd2,0xd2,0xe6,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x81,0x00, + 0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x84,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x85,0xff,0xff,0xff, + 0xff,0x00,0x7e,0x7e,0x7e,0xc7,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xcc,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xd0, + 0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x8d,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x82,0xff,0xff,0xff,0xff,0x00,0xf7,0xf7, + 0xf7,0xfa,0x86,0xdc,0xdc,0xdc,0xeb,0x00,0x6a,0x6a,0x6a,0xc2,0x85,0x00,0x00,0x00,0xb3,0x00,0xbb,0xbb,0xbb,0xdc,0x82,0xff,0xff,0xff,0xff,0x01,0x7e,0x7e,0x7e,0xc7, + 0x6a,0x6a,0x6a,0xc2,0x82,0xff,0xff,0xff,0xff,0x00,0xef,0xef,0xef,0xf5,0x85,0x00,0x00,0x00,0xb3,0x82,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x89,0x00,0x00, + 0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x86,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x8d,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6, + 0x8b,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x86,0xff,0xff,0xff,0xff,0x00,0xa0,0xa0,0xa0,0xd1,0x8d,0x00,0x00,0x00,0xb3,0x00,0x52,0x52,0x52,0xbd,0x84,0xff, + 0xff,0xff,0xff,0x03,0xf7,0xf7,0xf7,0xfa,0xc7,0xc7,0xc7,0xe1,0x90,0x90,0x90,0xcc,0x33,0x33,0x33,0xb8,0x87,0x00,0x00,0x00,0xb3,0x00,0xbb,0xbb,0xbb,0xdc,0x82,0xff, + 0xff,0xff,0xff,0x01,0x7e,0x7e,0x7e,0xc7,0x6a,0x6a,0x6a,0xc2,0x82,0xff,0xff,0xff,0xff,0x00,0xef,0xef,0xef,0xf5,0x85,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6, + 0x82,0xff,0xff,0xff,0xff,0x00,0xc7,0xc7,0xc7,0xe1,0x85,0xaf,0xaf,0xaf,0xd6,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0x00,0x00,0x00,0xb3,0x82,0xff,0xff,0xff,0xff,0x00,0xf7, + 0xf7,0xf7,0xfa,0x86,0xdc,0xdc,0xdc,0xeb,0x00,0x6a,0x6a,0x6a,0xc2,0x85,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf, + 0xd6,0x88,0x00,0x00,0x00,0xb3,0x00,0xd2,0xd2,0xd2,0xe6,0x85,0xff,0xff,0xff,0xff,0x01,0xef,0xef,0xef,0xf5,0x33,0x33,0x33,0xb8,0x8b,0x00,0x00,0x00,0xb3,0x00,0xf7, + 0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x00,0xf7,0xf7,0xf7,0xfa,0x81,0x00,0x00,0x00,0xb3,0x00,0xd2,0xd2,0xd2,0xe6,0x81,0xff,0xff,0xff,0xff,0x01,0xe6,0xe6,0xe6, + 0xf0,0x33,0x33,0x33,0xb8,0x82,0xff,0xff,0xff,0xff,0x00,0xbb,0xbb,0xbb,0xdc,0x81,0x00,0x00,0x00,0xb3,0x00,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x00,0xd2, + 0xd2,0xd2,0xe6,0x84,0x00,0x00,0x00,0xb3,0x00,0x33,0x33,0x33,0xb8,0x82,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0xd2,0xd2,0xd2,0xe6,0x82, + 0xff,0xff,0xff,0xff,0x00,0xa0,0xa0,0xa0,0xd1,0x84,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xc7,0xc7,0xc7,0xe1,0x82,0x7e,0x7e, + 0x7e,0xc7,0x01,0x90,0x90,0x90,0xcc,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x00,0xf7,0xf7,0xf7,0xfa,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82, + 0xff,0xff,0xff,0xff,0x01,0xaf,0xaf,0xaf,0xd6,0x52,0x52,0x52,0xbd,0x83,0xff,0xff,0xff,0xff,0x00,0xbb,0xbb,0xbb,0xdc,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e, + 0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82, + 0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0xb3,0xc7,0xc7,0xc7,0xe1,0x82,0xff,0xff,0xff,0xff,0x01,0xf7,0xf7,0xf7, + 0xfa,0x52,0x52,0x52,0xbd,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0xc7,0xc7,0xc7,0xe1,0x82,0xff, + 0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x84,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x85,0xaf,0xaf,0xaf,0xd6,0x00,0x52,0x52,0x52,0xbd,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xcc,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xd0,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82, + 0xff,0xff,0xff,0xff,0x86,0x7e,0x7e,0x7e,0xc7,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x82,0xff,0xff, + 0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x8d,0x00,0x00,0x00,0xb3,0x00,0x52,0x52,0x52,0xbd,0x82,0xff,0xff,0xff,0xff,0x01,0xc7,0xc7,0xc7,0xe1,0xbb,0xbb,0xbb,0xdc,0x82, + 0xff,0xff,0xff,0xff,0x00,0xa0,0xa0,0xa0,0xd1,0x85,0x00,0x00,0x00,0xb3,0x82,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x89,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc, + 0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x86,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x86,0x7e,0x7e,0x7e,0xc7,0x00,0xaf,0xaf,0xaf,0xd6, + 0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x8a,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x83,0xff,0xff,0xff,0xff,0x01,0xbb,0xbb,0xbb,0xdc,0xf7,0xf7, + 0xf7,0xfa,0x82,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x8c,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0xff,0xff,0xff,0xff,0x01,0xf7,0xf7,0xf7,0xfa, + 0xaf,0xaf,0xaf,0xd6,0x8b,0x00,0x00,0x00,0xb3,0x00,0x52,0x52,0x52,0xbd,0x82,0xff,0xff,0xff,0xff,0x01,0xc7,0xc7,0xc7,0xe1,0xbb,0xbb,0xbb,0xdc,0x82,0xff,0xff,0xff, + 0xff,0x00,0xa0,0xa0,0xa0,0xd1,0x85,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x89,0x00,0x00,0x00,0xb3,0x82, + 0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x8d,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x87,0x00,0x00, + 0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x01,0xef,0xef,0xef,0xf5,0xc7,0xc7,0xc7,0xe1,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x8a, + 0x00,0x00,0x00,0xb3,0x00,0x6a,0x6a,0x6a,0xc2,0x82,0xff,0xff,0xff,0xff,0x00,0xd2,0xd2,0xd2,0xe6,0x81,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x82,0xff,0xff, + 0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0xff,0xff,0xff,0xff,0x00,0x6a,0x6a,0x6a,0xc2,0x81,0x00,0x00,0x00,0xb3,0x00,0xd2,0xd2,0xd2,0xe6,0x82,0xff,0xff,0xff,0xff, + 0x85,0x00,0x00,0x00,0xb3,0x00,0xc7,0xc7,0xc7,0xe1,0x82,0xff,0xff,0xff,0xff,0x00,0x6a,0x6a,0x6a,0xc2,0x82,0xff,0xff,0xff,0xff,0x00,0xef,0xef,0xef,0xf5,0x85,0x00, + 0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x84,0x00,0x00,0x00,0xb3,0x00,0xef,0xef,0xef,0xf5,0x82,0xff,0xff,0xff, + 0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x01,0xaf,0xaf,0xaf,0xd6,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff, + 0xff,0x01,0xef,0xef,0xef,0xf5,0x33,0x33,0x33,0xb8,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00, + 0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff, + 0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x83,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x81, + 0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xd9,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xd0,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x86,0x00,0x00,0x00,0xb3, + 0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x82,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x8e,0x00, + 0x00,0x00,0xb3,0x00,0xd2,0xd2,0xd2,0xe6,0x82,0xff,0xff,0xff,0xff,0x00,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x01,0xf7,0xf7,0xf7,0xfa,0x33,0x33,0x33,0xb8, + 0x85,0x00,0x00,0x00,0xb3,0x82,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x89,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x86,0x00, + 0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x86,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf, + 0xd6,0x8a,0x00,0x00,0x00,0xb3,0x00,0xc7,0xc7,0xc7,0xe1,0x82,0xff,0xff,0xff,0xff,0x03,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0x6a,0x6a,0x6a,0xc2,0xf7,0xf7,0xf7, + 0xfa,0x81,0xff,0xff,0xff,0xff,0x00,0xe6,0xe6,0xe6,0xf0,0x8c,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0xff,0xff,0xff,0xff,0x00,0xbb,0xbb,0xbb,0xdc,0x8d, + 0x00,0x00,0x00,0xb3,0x00,0xd2,0xd2,0xd2,0xe6,0x82,0xff,0xff,0xff,0xff,0x00,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x01,0xf7,0xf7,0xf7,0xfa,0x33,0x33,0x33, + 0xb8,0x85,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x89,0x00,0x00,0x00,0xb3,0x82,0xff,0xff,0xff,0xff,0x00, + 0xdc,0xdc,0xdc,0xeb,0x8d,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x86,0x00,0x00,0x00,0xb3,0x01,0x33,0x33, + 0x33,0xb8,0xef,0xef,0xef,0xf5,0x82,0xff,0xff,0xff,0xff,0x02,0xa0,0xa0,0xa0,0xd1,0x52,0x52,0x52,0xbd,0xf7,0xf7,0xf7,0xfa,0x82,0xff,0xff,0xff,0xff,0x00,0x6a,0x6a, + 0x6a,0xc2,0x89,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0x33,0x33,0x33,0xb8, + 0x82,0xff,0xff,0xff,0xff,0x00,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x00,0xef,0xef,0xef,0xf5,0x82,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0xff, + 0xff,0xff,0xff,0x00,0x90,0x90,0x90,0xcc,0x84,0x00,0x00,0x00,0xb3,0x00,0x6a,0x6a,0x6a,0xc2,0x82,0xff,0xff,0xff,0xff,0x00,0xf7,0xf7,0xf7,0xfa,0x82,0xff,0xff,0xff, + 0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x85,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x84,0x00,0x00,0x00,0xb3,0x00, + 0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x02,0x7e,0x7e,0x7e,0xc7,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xef,0xef,0xef,0xf5, + 0x83,0xff,0xff,0xff,0xff,0x00,0x90,0x90,0x90,0xcc,0x82,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00, + 0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff, + 0xff,0x00,0xef,0xef,0xef,0xf5,0x82,0xff,0xff,0xff,0xff,0x00,0xe6,0xe6,0xe6,0xf0,0x83,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x81, + 0x00,0x00,0x00,0xb3,0x00,0x52,0x52,0x52,0xbd,0x83,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xd8,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xd0,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x86,0x00,0x00,0x00,0xb3, + 0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x82,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x8e,0x00, + 0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x85,0xff,0xff,0xff,0xff,0x00,0xbb,0xbb,0xbb,0xdc,0x86,0x00,0x00,0x00,0xb3,0x82,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc, + 0xeb,0x89,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x86,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x86, + 0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x8a,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff, + 0xff,0xff,0x82,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0xff,0xff,0xff,0xff,0x8c,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0xff,0xff,0xff,0xff, + 0x00,0xc7,0xc7,0xc7,0xe1,0x83,0x00,0x00,0x00,0xb3,0x01,0x52,0x52,0x52,0xbd,0x33,0x33,0x33,0xb8,0x87,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x85,0xff,0xff, + 0xff,0xff,0x00,0xbb,0xbb,0xbb,0xdc,0x86,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x89,0x00,0x00,0x00,0xb3, + 0x82,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x8d,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x86,0x00, + 0x00,0x00,0xb3,0x00,0xbb,0xbb,0xbb,0xdc,0x82,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0xff,0xff,0xff, + 0xff,0x00,0xe6,0xe6,0xe6,0xf0,0x89,0x00,0x00,0x00,0xb3,0x00,0xe6,0xe6,0xe6,0xf0,0x82,0xff,0xff,0xff,0xff,0x00,0x6a,0x6a,0x6a,0xc2,0x82,0x00,0x00,0x00,0xb3,0x00, + 0xd2,0xd2,0xd2,0xe6,0x84,0xff,0xff,0xff,0xff,0x00,0xbb,0xbb,0xbb,0xdc,0x82,0x00,0x00,0x00,0xb3,0x00,0x6a,0x6a,0x6a,0xc2,0x82,0xff,0xff,0xff,0xff,0x00,0xbb,0xbb, + 0xbb,0xdc,0x85,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x85,0xff,0xff,0xff,0xff,0x00,0x33,0x33,0x33,0xb8,0x85,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7, + 0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x83,0x00,0x00,0x00,0xb3,0x01,0x6a,0x6a,0x6a,0xc2,0xf7,0xf7,0xf7,0xfa,0x82,0xff,0xff,0xff,0xff,0x02,0x6a,0x6a, + 0x6a,0xc2,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x86,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x83,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff, + 0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00, + 0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x86,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x83,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x82, + 0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x01,0xf7,0xf7,0xf7,0xfa,0x7e,0x7e,0x7e,0xc7,0x85,0x00,0x00,0x00,0xb3,0x01,0xbb,0xbb,0xbb, + 0xdc,0xa0,0xa0,0xa0,0xd1,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xcf,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xd0,0x00, + 0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x86,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf, + 0xd6,0x82,0x00,0x00,0x00,0xb3,0x82,0xff,0xff,0xff,0xff,0x00,0xf7,0xf7,0xf7,0xfa,0x86,0xdc,0xdc,0xdc,0xeb,0x00,0xbb,0xbb,0xbb,0xdc,0x87,0x00,0x00,0x00,0xb3,0x00, + 0xef,0xef,0xef,0xf5,0x84,0xff,0xff,0xff,0xff,0x00,0x52,0x52,0x52,0xbd,0x86,0x00,0x00,0x00,0xb3,0x82,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x84,0x00,0x00, + 0x00,0xb3,0x00,0xbb,0xbb,0xbb,0xdc,0x83,0xdc,0xdc,0xdc,0xeb,0x00,0xf7,0xf7,0xf7,0xfa,0x82,0xff,0xff,0xff,0xff,0x84,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3, + 0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x86,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x8a,0x00, + 0x00,0x00,0xb3,0x00,0xd2,0xd2,0xd2,0xe6,0x82,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff, + 0xff,0x8c,0x00,0x00,0x00,0xb3,0x00,0x52,0x52,0x52,0xbd,0x83,0xff,0xff,0xff,0xff,0x06,0xc7,0xc7,0xc7,0xe1,0x90,0x90,0x90,0xcc,0x7e,0x7e,0x7e,0xc7,0xaf,0xaf,0xaf, + 0xd6,0xef,0xef,0xef,0xf5,0xe6,0xe6,0xe6,0xf0,0x33,0x33,0x33,0xb8,0x87,0x00,0x00,0x00,0xb3,0x00,0xef,0xef,0xef,0xf5,0x84,0xff,0xff,0xff,0xff,0x00,0x52,0x52,0x52, + 0xbd,0x86,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0xff,0xff,0xff,0xff,0x00,0xe6,0xe6,0xe6,0xf0,0x86,0xdc,0xdc,0xdc,0xeb,0x00,0x6a,0x6a,0x6a,0xc2,0x81, + 0x00,0x00,0x00,0xb3,0x82,0xff,0xff,0xff,0xff,0x00,0xf7,0xf7,0xf7,0xfa,0x86,0xdc,0xdc,0xdc,0xeb,0x02,0xbb,0xbb,0xbb,0xdc,0x00,0x00,0x00,0xb3,0x6a,0x6a,0x6a,0xc2, + 0x83,0xdc,0xdc,0xdc,0xeb,0x00,0xe6,0xe6,0xe6,0xf0,0x82,0xff,0xff,0xff,0xff,0x00,0xef,0xef,0xef,0xf5,0x83,0xdc,0xdc,0xdc,0xeb,0x02,0xa0,0xa0,0xa0,0xd1,0x00,0x00, + 0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x83,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0x00,0x00,0x00,0xb3,0x00,0xef,0xef,0xef,0xf5,0x82,0xff,0xff,0xff,0xff,0x00, + 0xaf,0xaf,0xaf,0xd6,0x87,0x00,0x00,0x00,0xb3,0x00,0x52,0x52,0x52,0xbd,0x82,0xff,0xff,0xff,0xff,0x00,0xf7,0xf7,0xf7,0xfa,0x83,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0, + 0xa0,0xd1,0x84,0xff,0xff,0xff,0xff,0x00,0x90,0x90,0x90,0xcc,0x83,0x00,0x00,0x00,0xb3,0x00,0xf7,0xf7,0xf7,0xfa,0x81,0xff,0xff,0xff,0xff,0x00,0xef,0xef,0xef,0xf5, + 0x85,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x84,0xff,0xff,0xff,0xff,0x00,0xc7,0xc7,0xc7,0xe1,0x86,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff, + 0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xaf,0xaf,0xaf,0xd6,0x01,0xc7,0xc7,0xc7,0xe1,0xf7,0xf7,0xf7,0xfa,0x82,0xff,0xff,0xff,0xff,0x00,0xef,0xef,0xef,0xf5, + 0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x85,0xff,0xff,0xff,0xff,0x01,0xf7,0xf7,0xf7,0xfa,0x52,0x52,0x52,0xbd,0x83,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e, + 0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6, + 0x82,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x85,0xff,0xff,0xff,0xff,0x00,0xbb,0xbb,0xbb,0xdc,0x84,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff, + 0xff,0xff,0xff,0x82,0x00,0x00,0x00,0xb3,0x01,0x52,0x52,0x52,0xbd,0xf7,0xf7,0xf7,0xfa,0x83,0xff,0xff,0xff,0xff,0x01,0xc7,0xc7,0xc7,0xe1,0xa0,0xa0,0xa0,0xd1,0x81, + 0x7e,0x7e,0x7e,0xc7,0x01,0xaf,0xaf,0xaf,0xd6,0xef,0xef,0xef,0xf5,0x81,0xff,0xff,0xff,0xff,0x00,0x90,0x90,0x90,0xcc,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xce,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xd0,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x86, + 0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3,0x8a,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc, + 0xdc,0xeb,0x87,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x83,0xff,0xff,0xff,0xff,0x00,0xd2,0xd2,0xd2,0xe6,0x87,0x00,0x00,0x00,0xb3,0x82,0xff,0xff,0xff,0xff, + 0x00,0xdc,0xdc,0xdc,0xeb,0x84,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x8c,0xff,0xff,0xff,0xff,0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff, + 0xff,0xff,0xff,0x86,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x8a,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0, + 0xd1,0x83,0xff,0xff,0xff,0xff,0x01,0xdc,0xdc,0xdc,0xeb,0xef,0xef,0xef,0xf5,0x82,0xff,0xff,0xff,0xff,0x00,0xd2,0xd2,0xd2,0xe6,0x8d,0x00,0x00,0x00,0xb3,0x00,0xbb, + 0xbb,0xbb,0xdc,0x88,0xff,0xff,0xff,0xff,0x01,0xe6,0xe6,0xe6,0xf0,0x33,0x33,0x33,0xb8,0x86,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x83,0xff,0xff,0xff,0xff, + 0x00,0xd2,0xd2,0xd2,0xe6,0x87,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x8a,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3,0x8a,0xff, + 0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x8c,0xff,0xff,0xff,0xff,0x02,0xaf,0xaf,0xaf,0xd6,0x00,0x00,0x00,0xb3,0xef,0xef, + 0xef,0xf5,0x82,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x83,0x00,0x00,0x00,0xb3,0x00,0x90,0x90,0x90,0xcc,0x83,0xff,0xff,0xff,0xff,0x00,0x52,0x52,0x52,0xbd, + 0x86,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x82,0xff,0xff,0xff,0xff,0x00,0xd2,0xd2,0xd2,0xe6,0x83,0x00,0x00,0x00,0xb3,0x00,0x33,0x33,0x33,0xb8,0x83,0xff, + 0xff,0xff,0xff,0x00,0xf7,0xf7,0xf7,0xfa,0x84,0x00,0x00,0x00,0xb3,0x00,0xd2,0xd2,0xd2,0xe6,0x82,0xff,0xff,0xff,0xff,0x00,0x52,0x52,0x52,0xbd,0x85,0x00,0x00,0x00, + 0xb3,0x00,0xef,0xef,0xef,0xf5,0x83,0xff,0xff,0xff,0xff,0x00,0x6a,0x6a,0x6a,0xc2,0x86,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x8b,0xff,0xff,0xff,0xff,0x00, + 0x90,0x90,0x90,0xcc,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x85,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x84,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e, + 0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6, + 0x82,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x84,0xff,0xff,0xff,0xff,0x01,0xf7,0xf7,0xf7,0xfa,0x33,0x33,0x33,0xb8,0x84,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc, + 0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x83,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x8b,0xff,0xff,0xff,0xff,0x01,0xf7,0xf7,0xf7,0xfa,0x7e,0x7e,0x7e,0xc7,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xcd,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xd0,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc, + 0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x86,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00,0x00,0x00,0xb3, + 0x8a,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x87,0x00,0x00,0x00,0xb3,0x01,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0x82,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e, + 0x7e,0xc7,0x87,0x00,0x00,0x00,0xb3,0x82,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x84,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x8c,0xff,0xff,0xff,0xff, + 0x81,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x86,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf, + 0xaf,0xaf,0xd6,0x8b,0x00,0x00,0x00,0xb3,0x00,0xe6,0xe6,0xe6,0xf0,0x86,0xff,0xff,0xff,0xff,0x01,0xf7,0xf7,0xf7,0xfa,0x6a,0x6a,0x6a,0xc2,0x8e,0x00,0x00,0x00,0xb3, + 0x00,0xd2,0xd2,0xd2,0xe6,0x88,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x86,0x00,0x00,0x00,0xb3,0x01,0x33,0x33,0x33,0xb8,0xf7,0xf7,0xf7,0xfa,0x82,0xff,0xff, + 0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x87,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x8a,0xff,0xff,0xff,0xff,0x00,0x7e,0x7e,0x7e,0xc7,0x81,0x00,0x00,0x00,0xb3, + 0x8a,0xff,0xff,0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0x00,0x00,0x00,0xb3,0x7e,0x7e,0x7e,0xc7,0x8c,0xff,0xff,0xff,0xff,0x81,0xaf,0xaf,0xaf,0xd6,0x83,0xff,0xff,0xff, + 0xff,0x00,0x52,0x52,0x52,0xbd,0x84,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x86,0x00,0x00,0x00,0xb3,0x00, + 0xd2,0xd2,0xd2,0xe6,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x84,0x00,0x00,0x00,0xb3,0x00,0xd2,0xd2,0xd2,0xe6,0x82,0xff,0xff,0xff,0xff,0x00,0xc7,0xc7, + 0xc7,0xe1,0x84,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x85,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6, + 0x82,0xff,0xff,0xff,0xff,0x00,0xdc,0xdc,0xdc,0xeb,0x87,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x89,0xff,0xff,0xff,0xff,0x01,0xf7,0xf7,0xf7,0xfa,0xa0,0xa0, + 0xa0,0xd1,0x82,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x84,0xff,0xff,0xff,0xff,0x00,0xef,0xef,0xef,0xf5,0x85,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7, + 0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0x00,0x00,0x00,0xb3,0x00,0x7e,0x7e,0x7e,0xc7,0x82,0xff,0xff,0xff,0xff,0x00,0xaf,0xaf,0xaf,0xd6,0x82,0x00, + 0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x84,0xff,0xff,0xff,0xff,0x00,0xa0,0xa0,0xa0,0xd1,0x85,0x00,0x00,0x00,0xb3,0x00,0xdc,0xdc,0xdc,0xeb,0x82,0xff,0xff,0xff, + 0xff,0x84,0x00,0x00,0x00,0xb3,0x01,0x7e,0x7e,0x7e,0xc7,0xef,0xef,0xef,0xf5,0x89,0xff,0xff,0xff,0xff,0x01,0xef,0xef,0xef,0xf5,0x6a,0x6a,0x6a,0xc2,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xcd,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xd0,0x00,0x00,0x00,0xb3,0x00,0xbb,0xbb,0xbb,0xdc, + 0x82,0xdc,0xdc,0xdc,0xeb,0x86,0x00,0x00,0x00,0xb3,0x00,0x6a,0x6a,0x6a,0xc2,0x82,0xdc,0xdc,0xdc,0xeb,0x00,0xa0,0xa0,0xa0,0xd1,0x82,0x00,0x00,0x00,0xb3,0x8a,0xdc, + 0xdc,0xdc,0xeb,0x00,0xbb,0xbb,0xbb,0xdc,0x88,0x00,0x00,0x00,0xb3,0x00,0xaf,0xaf,0xaf,0xd6,0x81,0xdc,0xdc,0xdc,0xeb,0x00,0xd2,0xd2,0xd2,0xe6,0x88,0x00,0x00,0x00, + 0xb3,0x82,0xdc,0xdc,0xdc,0xeb,0x00,0xbb,0xbb,0xbb,0xdc,0x84,0x00,0x00,0x00,0xb3,0x00,0xbb,0xbb,0xbb,0xdc,0x8c,0xdc,0xdc,0xdc,0xeb,0x81,0x00,0x00,0x00,0xb3,0x00, + 0xbb,0xbb,0xbb,0xdc,0x82,0xdc,0xdc,0xdc,0xeb,0x86,0x00,0x00,0x00,0xb3,0x00,0x6a,0x6a,0x6a,0xc2,0x82,0xdc,0xdc,0xdc,0xeb,0x00,0xa0,0xa0,0xa0,0xd1,0x8b,0x00,0x00, + 0x00,0xb3,0x02,0x33,0x33,0x33,0xb8,0xaf,0xaf,0xaf,0xd6,0xf7,0xf7,0xf7,0xfa,0x83,0xff,0xff,0xff,0xff,0x01,0xd2,0xd2,0xd2,0xe6,0x6a,0x6a,0x6a,0xc2,0x90,0x00,0x00, + 0x00,0xb3,0x01,0xa0,0xa0,0xa0,0xd1,0xe6,0xe6,0xe6,0xf0,0x84,0xff,0xff,0xff,0xff,0x01,0xd2,0xd2,0xd2,0xe6,0x7e,0x7e,0x7e,0xc7,0x88,0x00,0x00,0x00,0xb3,0x00,0xaf, + 0xaf,0xaf,0xd6,0x81,0xdc,0xdc,0xdc,0xeb,0x00,0xd2,0xd2,0xd2,0xe6,0x88,0x00,0x00,0x00,0xb3,0x00,0xa0,0xa0,0xa0,0xd1,0x8a,0xdc,0xdc,0xdc,0xeb,0x00,0x6a,0x6a,0x6a, + 0xc2,0x81,0x00,0x00,0x00,0xb3,0x8a,0xdc,0xdc,0xdc,0xeb,0x02,0xbb,0xbb,0xbb,0xdc,0x00,0x00,0x00,0xb3,0x6a,0x6a,0x6a,0xc2,0x8c,0xdc,0xdc,0xdc,0xeb,0x00,0xaf,0xaf, + 0xaf,0xd6,0x83,0xdc,0xdc,0xdc,0xeb,0x00,0xaf,0xaf,0xaf,0xd6,0x85,0x00,0x00,0x00,0xb3,0x00,0x52,0x52,0x52,0xbd,0x83,0xdc,0xdc,0xdc,0xeb,0x00,0x7e,0x7e,0x7e,0xc7, + 0x85,0x00,0x00,0x00,0xb3,0x00,0xd2,0xd2,0xd2,0xe6,0x82,0xdc,0xdc,0xdc,0xeb,0x00,0x6a,0x6a,0x6a,0xc2,0x84,0x00,0x00,0x00,0xb3,0x00,0x90,0x90,0x90,0xcc,0x82,0xdc, + 0xdc,0xdc,0xeb,0x00,0x7e,0x7e,0x7e,0xc7,0x84,0x00,0x00,0x00,0xb3,0x00,0x6a,0x6a,0x6a,0xc2,0x82,0xdc,0xdc,0xdc,0xeb,0x00,0xaf,0xaf,0xaf,0xd6,0x85,0x00,0x00,0x00, + 0xb3,0x00,0x33,0x33,0x33,0xb8,0x82,0xdc,0xdc,0xdc,0xeb,0x00,0x90,0x90,0x90,0xcc,0x87,0x00,0x00,0x00,0xb3,0x00,0x6a,0x6a,0x6a,0xc2,0x87,0xdc,0xdc,0xdc,0xeb,0x02, + 0xbb,0xbb,0xbb,0xdc,0xa0,0xa0,0xa0,0xd1,0x33,0x33,0x33,0xb8,0x83,0x00,0x00,0x00,0xb3,0x00,0x6a,0x6a,0x6a,0xc2,0x84,0xdc,0xdc,0xdc,0xeb,0x00,0x7e,0x7e,0x7e,0xc7, + 0x85,0x00,0x00,0x00,0xb3,0x00,0x6a,0x6a,0x6a,0xc2,0x82,0xdc,0xdc,0xdc,0xeb,0x00,0xa0,0xa0,0xa0,0xd1,0x81,0x00,0x00,0x00,0xb3,0x00,0x6a,0x6a,0x6a,0xc2,0x82,0xdc, + 0xdc,0xdc,0xeb,0x00,0xa0,0xa0,0xa0,0xd1,0x82,0x00,0x00,0x00,0xb3,0x00,0xbb,0xbb,0xbb,0xdc,0x83,0xdc,0xdc,0xdc,0xeb,0x00,0xc7,0xc7,0xc7,0xe1,0x86,0x00,0x00,0x00, + 0xb3,0x00,0xbb,0xbb,0xbb,0xdc,0x82,0xdc,0xdc,0xdc,0xeb,0x85,0x00,0x00,0x00,0xb3,0x02,0x33,0x33,0x33,0xb8,0xaf,0xaf,0xaf,0xd6,0xe6,0xe6,0xe6,0xf0,0x85,0xff,0xff, + 0xff,0xff,0x02,0xdc,0xdc,0xdc,0xeb,0xa0,0xa0,0xa0,0xd1,0x33,0x33,0x33,0xb8,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xce,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xbd,0x00,0x00,0x00,0xb3,0x00,0x6a,0x6a,0x6a,0xc2,0x81,0x7e,0x7e,0x7e,0xc7,0x00,0x33,0x33,0x33, + 0xb8,0x94,0x00,0x00,0x00,0xb3,0x00,0x33,0x33,0x33,0xb8,0x82,0x7e,0x7e,0x7e,0xc7,0xff,0x00,0x00,0x00,0xb3,0xcd,0x00,0x00,0x00,0xb3,0x82,0x7e,0x7e,0x7e,0xc7,0x00, + 0x6a,0x6a,0x6a,0xc2,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xd2,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xf2,0x00,0x00,0x00,0xb3,0x02,0x04,0x04,0x13,0xb7,0x20,0x24,0xa9,0xdf,0x26,0x2e,0xd7,0xef,0x91,0x28,0x2f,0xd9,0xf0,0x02,0x26,0x2e,0xd7,0xef,0x1f,0x25, + 0xa8,0xde,0x04,0x04,0x13,0xb7,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xf4,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xf2,0x00,0x00,0x00,0xb3,0x00,0x23,0x28,0xbb,0xe5,0x95,0x2e,0x37,0xff,0xff,0x00,0x22,0x27,0xb6,0xe4,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xf4,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xf2,0x00,0x00,0x00,0xb3,0x00,0x2d,0x35,0xf7,0xfb,0x88,0x2e,0x37,0xff,0xff,0x00,0x26,0x2b,0xcb,0xea,0x81,0x20,0x25,0xad,0xe1,0x00,0x26,0x2b,0xcc,0xea,0x88,0x2e, + 0x37,0xff,0xff,0x00,0x2c,0x34,0xf2,0xf9,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xf4,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xf2,0x00,0x00,0x00,0xb3,0x00,0x28,0x30,0xde,0xf1,0x87,0x2e,0x37,0xff,0xff,0x00,0x24,0x2b,0xc4,0xe8,0x83, + 0x00,0x00,0x00,0xb3,0x00,0x25,0x2a,0xc7,0xea,0x87,0x2e,0x37,0xff,0xff,0x00,0x26,0x2e,0xd7,0xef,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xf4,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xf2,0x00,0x00,0x00,0xb3,0x00,0x13,0x17,0x68,0xcb, + 0x87,0x2e,0x37,0xff,0xff,0x00,0x1f,0x25,0xab,0xe0,0x83,0x00,0x00,0x00,0xb3,0x00,0x1f,0x25,0xab,0xe0,0x87,0x2e,0x37,0xff,0xff,0x00,0x13,0x16,0x61,0xca,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xf4,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xf3,0x00,0x00,0x00,0xb3,0x00,0x25,0x2c,0xcd,0xec,0x86,0x2e,0x37,0xff,0xff,0x01,0x26,0x2d,0xd2,0xed,0x01,0x01,0x05,0xb4,0x81,0x00,0x00,0x00,0xb3,0x01,0x01, + 0x01,0x06,0xb4,0x27,0x2e,0xd6,0xef,0x86,0x2e,0x37,0xff,0xff,0x00,0x26,0x2b,0xcb,0xea,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xf5,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xf3,0x00,0x00,0x00,0xb3,0x01,0x0d,0x0e,0x40,0xc1,0x2e,0x37, + 0xfd,0xfe,0x86,0x2e,0x37,0xff,0xff,0x00,0x2b,0x31,0xe9,0xf5,0x81,0x28,0x2f,0xd9,0xf0,0x00,0x2b,0x31,0xe9,0xf6,0x86,0x2e,0x37,0xff,0xff,0x01,0x2d,0x36,0xfc,0xfe, + 0x0c,0x0d,0x3b,0xc0,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xf5,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xf4,0x00,0x00,0x00,0xb3,0x00,0x20,0x26,0xb0,0xe1,0x91,0x2e,0x37,0xff,0xff,0x00,0x20,0x24,0xa9,0xdf,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xf6,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xf4,0x00, + 0x00,0x00,0xb3,0x01,0x06,0x07,0x1e,0xb9,0x2c,0x34,0xf4,0xfb,0x84,0x2e,0x37,0xff,0xff,0x01,0x2e,0x37,0xfe,0xff,0x24,0x2b,0xc5,0xe8,0x81,0x20,0x25,0xad,0xe1,0x00, + 0x25,0x2a,0xc6,0xe9,0x85,0x2e,0x37,0xff,0xff,0x01,0x2c,0x34,0xf2,0xfa,0x05,0x06,0x1b,0xb9,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xf6,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xf5,0x00,0x00,0x00,0xb3,0x00,0x19,0x1f,0x8b,0xd5,0x84, + 0x2e,0x37,0xff,0xff,0x00,0x24,0x2a,0xc4,0xe8,0x83,0x00,0x00,0x00,0xb3,0x00,0x25,0x2a,0xc7,0xe9,0x84,0x2e,0x37,0xff,0xff,0x00,0x19,0x1d,0x85,0xd4,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xf7,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xf5,0x00,0x00,0x00,0xb3,0x01,0x02,0x02,0x09,0xb5,0x2a,0x30,0xe4,0xf4,0x83,0x2e,0x37,0xff,0xff,0x00,0x1f,0x25,0xab,0xe0,0x83,0x00,0x00,0x00,0xb3,0x00,0x1f,0x25, + 0xab,0xe0,0x83,0x2e,0x37,0xff,0xff,0x01,0x29,0x31,0xe2,0xf3,0x01,0x01,0x06,0xb4,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xf7, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xf6,0x00,0x00,0x00,0xb3,0x00,0x13,0x16,0x62,0xca,0x83,0x2e,0x37, + 0xff,0xff,0x00,0x1f,0x25,0xab,0xe0,0x83,0x00,0x00,0x00,0xb3,0x00,0x1f,0x25,0xab,0xe0,0x83,0x2e,0x37,0xff,0xff,0x00,0x11,0x14,0x5c,0xc8,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xf8,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xf7,0x00, + 0x00,0x00,0xb3,0x00,0x26,0x2b,0xcc,0xea,0x82,0x2e,0x37,0xff,0xff,0x00,0x1f,0x25,0xab,0xe0,0x83,0x00,0x00,0x00,0xb3,0x00,0x1f,0x25,0xab,0xe0,0x82,0x2e,0x37,0xff, + 0xff,0x00,0x24,0x2b,0xc5,0xe9,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xf9,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xf7,0x00,0x00,0x00,0xb3,0x01,0x0c,0x0d,0x3b,0xc0,0x2d,0x36,0xfc,0xfe,0x81,0x2e,0x37,0xff,0xff,0x00,0x1f,0x25,0xab, + 0xe0,0x83,0x00,0x00,0x00,0xb3,0x00,0x1f,0x25,0xab,0xe0,0x81,0x2e,0x37,0xff,0xff,0x01,0x2d,0x36,0xfb,0xfe,0x0a,0x0c,0x36,0xbf,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xf9,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xf8,0x00,0x00,0x00, + 0xb3,0x00,0x20,0x24,0xa9,0xdf,0x81,0x2e,0x37,0xff,0xff,0x00,0x21,0x26,0xb2,0xe2,0x83,0x00,0x00,0x00,0xb3,0x00,0x21,0x26,0xb2,0xe2,0x81,0x2e,0x37,0xff,0xff,0x00, + 0x1f,0x24,0xa4,0xde,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xfa,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xf8,0x00,0x00,0x00,0xb3,0x04,0x05,0x06,0x1b,0xb9,0x2c,0x34,0xf3,0xfa,0x2e,0x37,0xff,0xff,0x2c,0x34,0xf3,0xfa,0x14,0x16,0x65, + 0xcb,0x81,0x0d,0x0f,0x44,0xc2,0x04,0x14,0x17,0x67,0xcb,0x2c,0x34,0xf4,0xfb,0x2e,0x37,0xff,0xff,0x2b,0x33,0xf1,0xf9,0x05,0x05,0x17,0xb8,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xfa,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xf9,0x00, + 0x00,0x00,0xb3,0x00,0x19,0x1d,0x85,0xd4,0x87,0x2e,0x37,0xff,0xff,0x00,0x18,0x1c,0x81,0xd2,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xfb,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xf9,0x00,0x00,0x00,0xb3,0x01,0x02,0x02,0x07,0xb4,0x29, + 0x31,0xe2,0xf3,0x85,0x2e,0x37,0xff,0xff,0x01,0x28,0x30,0xdf,0xf2,0x01,0x01,0x05,0xb4,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xfb,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xfa,0x00,0x00,0x00,0xb3,0x00,0x12,0x14,0x5d,0xc8,0x85,0x2e, + 0x37,0xff,0xff,0x00,0x10,0x13,0x56,0xc7,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xfc,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xfb,0x00,0x00,0x00,0xb3,0x00,0x25,0x2a,0xc6,0xe9,0x83,0x2e,0x37,0xff,0xff,0x00,0x23,0x2a,0xc2,0xe7,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xfd,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xfb,0x00,0x00,0x00,0xb3,0x01,0x0a,0x0c,0x36,0xbf,0x2e,0x36,0xf9,0xfc,0x81,0x2e,0x37,0xff,0xff,0x01,0x2c,0x35,0xf8,0xfc,0x09,0x0a,0x30,0xbd,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xfd,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xfc,0x00,0x00,0x00,0xb3,0x03,0x10,0x12,0x52,0xc6,0x25,0x2a,0xc7,0xe9,0x25,0x2a,0xc6,0xe9,0x0f,0x10,0x4d,0xc5,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xfe,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff, + 0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00, + 0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3, + 0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00, + 0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00, + 0xb3,0xff,0x00,0x00,0x00,0xb3,0xff,0x00,0x00,0x00,0xb3,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x54,0x52,0x55,0x45,0x56,0x49,0x53,0x49,0x4f,0x4e,0x2d,0x58,0x46, + 0x49,0x4c,0x45,0x2e,0x00 +}; diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Displays/OVR_Display.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Displays/OVR_Display.cpp Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,36 @@ +/************************************************************************************ + +PublicHeader: None +Filename : OVR_Display.cpp +Content : Common implementation for display device +Created : May 6, 2014 +Notes : + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#include "OVR_Display.h" + +namespace OVR { + + +// Place platform-independent code here + + +} // namespace OVR diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Displays/OVR_Display.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Displays/OVR_Display.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,203 @@ +/************************************************************************************ + +PublicHeader: None +Filename : OVR_Display.h +Content : Contains platform independent display management +Created : May 6, 2014 +Notes : + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#ifndef OVR_Display_h +#define OVR_Display_h + +#include "../Sensors/OVR_DeviceConstants.h" // Required for HmdTypeEnum + +#include "../Kernel/OVR_Types.h" +#include "../Kernel/OVR_Atomic.h" +#include "../Kernel/OVR_RefCount.h" +#include "../Kernel/OVR_Array.h" +#include "../Kernel/OVR_String.h" +#include "../Kernel/OVR_Math.h" + +namespace OVR { + + +class DisplaySearchHandle : virtual public RefCountBaseV +{ +public: + DisplaySearchHandle() {} + + virtual ~DisplaySearchHandle() {} + + void operator= (const DisplaySearchHandle&) {} +}; + +//------------------------------------------------------------------------------------- +// ***** Display + +// Display object describes an Oculus HMD screen in LibOVR, providing information such +// as EDID serial number and resolution in platform-independent manner. +// +// Display is an abstract base class to support OS and driver specific implementations. +// It support HMD screen enumeration through GetDisplayCount/GetDisplay static functions. +// +// Examples of implementations of Display are the following: +// Display_Win32_Generic - Compatibly mode implementation that maintains operation on +// systems without drivers. +// Display_Win32_Driver - Driver-Based display +// Display_OSX_Generic - Additional compatibility mode implementation for OS X + +class Display : public RefCountBase +{ +protected: + enum MirrorMode + { + MirrorEnabled = 0, + MirrorDisabled = 1 + }; + + MirrorMode mirrorMode; + + Display( + HmdTypeEnum deviceTypeGuess, +#ifdef OVR_OS_MAC + uint32_t displayID, +#else + const String& displayID, +#endif + const String& modelName, + const String& editSerial, + const Sizei& logicalRes, + const Sizei& nativeRes, + const Vector2i& displayOffset, + const uint64_t devNumber, + const uint32_t rotation, + const bool appExclusive): + mirrorMode(MirrorDisabled), + DeviceTypeGuess(deviceTypeGuess), + DisplayID(displayID), + ModelName(modelName), + EdidSerialNumber(editSerial), + LogicalResolutionInPixels(logicalRes), + NativeResolutionInPixels(nativeRes), + DesktopDisplayOffset(displayOffset), + DeviceNumber(devNumber), + Rotation(rotation), + ApplicationExclusive(appExclusive) + { + } + + void operator = (const Display&) { } // Quiet warning. + +public: + virtual ~Display() { } + + // ----- Platform specific static Display functionality ----- + + // Mandatory function that sets up the display environment with + // any necessary shimming and function hooks. This should be one + // of the very first things your application does when it + // initializes LibOVR + static bool Initialize(); + + // Returns a count of the detected displays. These are Rift displays + // attached directly to an active display port + static int GetDisplayCount( DisplaySearchHandle* handle = NULL, bool extended = true, bool applicationOnly = true, bool extendedEDIDSerials = false ); + // Returns a specific index of a display. Displays are sorted in no particular order. + static Ptr GetDisplay( int index = 0, DisplaySearchHandle* handle = NULL ); + + + // Returns true if we are referencing the same display; useful for matching display + // objects with the ones already detected. + bool MatchDisplay(const Display* other) + { + // Note this is not checking the DeviceName, which corresponds to which monitor the device is. + // This allows matching to match a display that has changed how it is plugged in. + return (DisplayID == other->DisplayID) && + (EdidSerialNumber == other->EdidSerialNumber) && + (NativeResolutionInPixels == other->NativeResolutionInPixels) && + (DesktopDisplayOffset == other->DesktopDisplayOffset) && + (ApplicationExclusive == other->ApplicationExclusive); + } + + + // ----- Device independent instance based Display functionality ----- + + // Device type guess based on display info. + const HmdTypeEnum DeviceTypeGuess; +#if defined(OVR_OS_MAC) + // CGDirectDisplayID for the rift. + const uint32_t DisplayID; +#else + // A string denoting the display device name so that apps can recognize the monitor + const String DisplayID; +#endif + // A literal string containing the name of the model, i.e. Rift DK2 + const String ModelName; + // Part of the serial number encoded in Edid, used for monitor <-> sensor matching. + const String EdidSerialNumber; + // Logical resolution is the display resolution in presentation terms. + // That is to say, the resolution that represents the orientation the + // display is projected to the user. For DK2, while being a portrait display + // the display is held in landscape and therefore the logical resolution + // is 1920x1080 + const Sizei LogicalResolutionInPixels; + // Native resolution is the resolution reported by the EDID and represents the + // exact hardware resolution of the Rift. For example, on DK2 + // this is 1080x1920 + // In theory, an OS rotated Rift's native and logical resolutions should match + const Sizei NativeResolutionInPixels; + // For displays that are attached to the desktop, this return value has meaning. + // Otherwise it should always return origin + const Vector2i DesktopDisplayOffset; + // For Windows machines this value stores the ChildUid used to identify this display + const uint64_t DeviceNumber; + // Stores the device specific default rotation of the screen + // E.g. DK2 is rotated 90 degrees as it is a portrait display + const uint32_t Rotation; + // Is set if the Display is capable in Application-Only mode + const bool ApplicationExclusive; + + // Functionality for rendering within the window + virtual MirrorMode SetMirrorMode( MirrorMode newMode ) = 0; + + // Functionality for enabling/disabling display + virtual bool SetDisplaySleep(bool off) + { + // Override to implement if supported + OVR_UNUSED(off); + return false; + } + + // Check if right now the current rendering application should be in compatibility mode + static bool InCompatibilityMode( bool displaySearch = true ); + + // Get/set the mode for all applications + static bool GetDriverMode(bool& driverInstalled, bool& compatMode, bool& hideDK1Mode); + static bool SetDriverMode(bool compatMode, bool hideDK1Mode); + + static DisplaySearchHandle* GetDisplaySearchHandle(); +}; + + +} // namespace OVR + +#endif diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Displays/OVR_Linux_Display.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Displays/OVR_Linux_Display.cpp Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,494 @@ +/************************************************************************************ + +Filename : OVR_Linux_Display.cpp +Content : Linux-specific Display declarations +Created : July 2, 2014 +Authors : James Hughes + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +*************************************************************************************/ + +#include "OVR_Linux_Display.h" +#include "../Kernel/OVR_Log.h" + +#include "../../../3rdParty/EDID/edid.h" + +#include +#include +#include +#include + +//------------------------------------------------------------------------------------- +// ***** Display enumeration Helpers + +namespace OVR { + +static const uint8_t edid_v1_header[] = { 0x00, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0x00 }; + +static const uint8_t edid_v1_descriptor_flag[] = { 0x00, 0x00 }; + +static const int DESCRIPTOR_DATA = 5; +static const int UNKNOWN_DESCRIPTOR = -1; +static const int DETAILED_TIMING_BLOCK = -2; + +// The following three functions were pulled from OVR_Linux_Display.cpp +// and modified slightly. +static int blockType(uint8_t* block) +{ + if (!strncmp((const char*)edid_v1_descriptor_flag, (const char*)block, 2)) + { + if (block[2] != 0) + { + return UNKNOWN_DESCRIPTOR; + } + else + { + return block[3]; + } + } + else + { + return DETAILED_TIMING_BLOCK; + } +} + +static char* getMonitorName(const uint8_t* block) +{ + static char name[13]; + uint8_t const* ptr = block + DESCRIPTOR_DATA; + + for (int i = 0; i < 13; i++, ptr++) + { + if (*ptr == 0xa) + { + name[i] = 0; + return name; + } + + name[i] = *ptr; + } + + return name; +} + +// Returns -1 on failure, 0 otherwise. +static int parseEdid(uint8_t* edid, Linux::DisplayEDID& edidResult) +{ + const int EDID_LENGTH = 0x80; + const int EDID_HEADER = 0x00; + const int EDID_HEADER_END = 0x07; + + // const int EDID_STRUCT_VERSION = 0x12; + // const int EDID_STRUCT_REVISION = 0x13; + + const int MONITOR_NAME = 0xfc; + // const int MONITOR_LIMITS = 0xfd; + const int MONITOR_SERIAL = 0xff; + + // const int ESTABLISHED_TIMING_1 = 0x23; + // const int ESTABLISHED_TIMING_2 = 0x24; + // const int MANUFACTURERS_TIMINGS = 0x25; + + const int DETAILED_TIMING_DESCRIPTIONS_START = 0x36; + const int DETAILED_TIMING_DESCRIPTION_SIZE = 18; + const int NO_DETAILED_TIMING_DESCRIPTIONS = 4; + + // const int DETAILED_TIMING_DESCRIPTION_1 = 0x36; + // const int DETAILED_TIMING_DESCRIPTION_2 = 0x48; + // const int DETAILED_TIMING_DESCRIPTION_3 = 0x5a; + // const int DETAILED_TIMING_DESCRIPTION_4 = 0x6c; + + const char* monitorName = "Unknown"; + uint8_t* block = NULL; + uint8_t checksum = 0; + + for (int i = 0; i < EDID_LENGTH; i++) + { + checksum += edid[i]; + } + + // Bad checksum, fail EDID + if (checksum != 0) + { + return -1; + } + + if (strncmp((const char*)edid + EDID_HEADER, + (const char*)edid_v1_header, EDID_HEADER_END + 1)) + { + // First bytes don't match EDID version 1 header + return -1; + } + + // Monitor name and timings + char serialNumber[14]; + memset(serialNumber, 0, 14); + + block = edid + DETAILED_TIMING_DESCRIPTIONS_START; + + for (int i = 0; i < NO_DETAILED_TIMING_DESCRIPTIONS; + i++, block += DETAILED_TIMING_DESCRIPTION_SIZE) + { + + if (blockType(block) == MONITOR_NAME) + { + monitorName = getMonitorName(block); + } + + if (blockType(block) == MONITOR_SERIAL) + { + memcpy(serialNumber, block + 5, 13); + break; + } + } + + uint8_t vendorString[4] = {0}; + + vendorString[0] = (edid[8] >> 2 & 31) + 64; + vendorString[1] = (((edid[8] & 3) << 3) | (edid[9] >> 5)) + 64; + vendorString[2] = (edid[9] & 31) + 64; + + edidResult.ModelNumber = *(uint16_t*)&edid[10]; + edidResult.MonitorName = monitorName; + edidResult.VendorName = reinterpret_cast(vendorString); + edidResult.SerialNumber = serialNumber; + + // FIXME: Get timings as well + + // std::cout << "# EDID version " << static_cast(edid[EDID_STRUCT_VERSION]) + // << " revision " << static_cast(edid[EDID_STRUCT_REVISION]) + // << std::endl; + + return 0; +} + + +// Returns -1 in the case of failure, 0 otherwise. +// Parameters: +// data OUT This pointer is modified to point to the output from +// XRRGetOutputProperty. You *must* call XFree on this pointer. +// dataLen OUT The length of the data returned in 'data'. +static int getXRRProperty(struct _XDisplay* display, RROutput output, Atom atom, + uint8_t** data, int* dataLen) +{ + unsigned long nitems; + unsigned long bytesAfter; + int actualFormat; + Atom actualType; + + int ret = XRRGetOutputProperty(display, output, atom, 0, 100, + False, False, AnyPropertyType, + &actualType, &actualFormat, &nitems, + &bytesAfter, data); + + if (None != ret) + { + *dataLen = nitems; + return 0; + } + else + { + return -1; + } +} + +static XRRModeInfo* findModeByXID(XRRScreenResources* screen, RRMode xid) +{ + for (int m = 0; m < screen->nmode; ++m) + { + XRRModeInfo* mode = &screen->modes[m]; + if (xid == mode->id) + { + return mode; + } + } + return NULL; +} + +static int discoverExtendedRifts(OVR::Linux::DisplayDesc* descriptorArray, int inputArraySize, bool /*edidInfo*/) +{ + int result = 0; + + struct _XDisplay* display = XOpenDisplay(NULL); + + if (display == NULL) + { + OVR::LogError("[Linux Display] Unable to open X Display!"); + return 0; + } + + Atom EDIDAtom = XInternAtom(display, RR_PROPERTY_RANDR_EDID, False); + int numScreens = XScreenCount(display); + for (int i = 0; i < numScreens; ++i) + { + Window sr = XRootWindow(display, i); + XRRScreenResources* screen = XRRGetScreenResources(display, sr); + + for (int ii = 0; ii < screen->ncrtc; ++ii) + { + XRRCrtcInfo* crtcInfo = XRRGetCrtcInfo(display, screen, screen->crtcs[ii]); + + if (0 == crtcInfo->noutput) + { + XRRFreeCrtcInfo(crtcInfo); + continue; + } + + bool foundOutput = false; + RROutput output = crtcInfo->outputs[0]; + for (int k = 0; k < crtcInfo->noutput; ++k) + { + XRROutputInfo* outputInfo = + XRRGetOutputInfo(display, screen, crtcInfo->outputs[k]); + + for (int kk = 0; kk < outputInfo->nmode; ++kk) + { + if (outputInfo->modes[kk] == crtcInfo->mode) + { + output = crtcInfo->outputs[k]; + foundOutput = true; + break; + } + } + XRRFreeOutputInfo(outputInfo); + if (foundOutput) + { + break; + } + } + + if (!foundOutput) + { + XRRFreeCrtcInfo(crtcInfo); + continue; + } + + XRROutputInfo* outputInfo = XRRGetOutputInfo(display, screen, output); + if (RR_Connected != outputInfo->connection) + { + XRRFreeOutputInfo(outputInfo); + XRRFreeCrtcInfo(crtcInfo); + continue; + } + + // Read EDID associated with crtc. + uint8_t* data = NULL; + int dataLen = 0; + if (getXRRProperty(display, output, EDIDAtom, &data, &dataLen) != 0) + { + // Identify rifts based on EDID. + Linux::DisplayEDID edid; + parseEdid(data, edid); + XFree(data); + data = NULL; + + // TODO: Remove either this 3rdParty call to read EDID data + // or remove our own parsing of the EDID. Probably opt + // to remove our parsing. + MonitorInfo* mi = read_edid_data(display, output); + if (mi == NULL) + { + XRRFreeOutputInfo(outputInfo); + XRRFreeCrtcInfo(crtcInfo); + continue; + } + + if (edid.VendorName == "OVR") + { + if( result >= inputArraySize ) + { + delete mi; + XRRFreeOutputInfo(outputInfo); + XRRFreeCrtcInfo(crtcInfo); + return result; + } + + XRRModeInfo* modeInfo = findModeByXID(screen, crtcInfo->mode); + + int width = modeInfo->width; + int height = modeInfo->height; + + if ( crtcInfo->rotation == RR_Rotate_90 + || crtcInfo->rotation == RR_Rotate_270 ) + { + width = modeInfo->height; + height = modeInfo->width; + } + + int x = crtcInfo->x; + int y = crtcInfo->y; + + // Generate a device ID string similar Windows does it + char device_id[32]; + OVR_sprintf(device_id, 32, "%s%04d-%d", + mi->manufacturer_code, mi->product_code, + screen->crtcs[ii]); + + OVR::Linux::DisplayDesc& desc = descriptorArray[result++]; + desc.DisplayID = device_id; + desc.ModelName = edid.MonitorName; + desc.EdidSerialNumber = edid.SerialNumber; + desc.LogicalResolutionInPixels = Sizei(width, height); + desc.DesktopDisplayOffset = Vector2i(x, y); + + switch (mi->product_code) + { + case 3: desc.DeviceTypeGuess = HmdType_DK2; break; + case 2: desc.DeviceTypeGuess = HmdType_DKHDProto; break; + case 1: desc.DeviceTypeGuess = HmdType_DK1; break; + + default: + case 0: desc.DeviceTypeGuess = HmdType_Unknown; break; + } + + // Hard-coded defaults in case the device doesn't have the + // data itself. DK2 prototypes (0003) or DK HD Prototypes (0002). + if ( desc.DeviceTypeGuess == HmdType_DK2 + || desc.DeviceTypeGuess == HmdType_DKHDProto) + { + desc.LogicalResolutionInPixels = Sizei(1920, 1080); + desc.NativeResolutionInPixels = Sizei(1080, 1920); + } + else + { + desc.LogicalResolutionInPixels = Sizei(width, height); + desc.NativeResolutionInPixels = Sizei(width, height); + } + } + + delete mi; + mi = NULL; + } + + XRRFreeOutputInfo(outputInfo); + XRRFreeCrtcInfo(crtcInfo); + } + + XRRFreeScreenResources(screen); + } + + XCloseDisplay(display); + + return result; +} + + +//------------------------------------------------------------------------------------- +// ***** Display + +bool Display::Initialize() +{ + // Nothing to initialize. OS X only supports compatibility mode. + return true; +} + +bool Display::GetDriverMode(bool& driverInstalled, bool& compatMode, bool& hideDK1Mode) +{ + driverInstalled = false; + compatMode = true; + hideDK1Mode = false; + return true; +} + +bool Display::SetDriverMode(bool /*compatMode*/, bool /*hideDK1Mode*/) +{ + return false; +} + +DisplaySearchHandle* Display::GetDisplaySearchHandle() +{ + return new Linux::LinuxDisplaySearchHandle(); +} + +bool Display::InCompatibilityMode( bool displaySearch ) +{ + OVR_UNUSED( displaySearch ); + return true; +} + +int Display::GetDisplayCount(DisplaySearchHandle* handle, bool extended, bool applicationOnly, bool edidInfo) +{ + OVR_UNUSED4(handle, extended, applicationOnly, edidInfo); + + static int extendedCount = -1; + + Linux::LinuxDisplaySearchHandle* localHandle = (Linux::LinuxDisplaySearchHandle*)handle; + if (localHandle == NULL) + { + OVR::LogError("[Linux Display] No search handle passed into GetDisplayCount. Return 0 rifts."); + return 0; + } + + if (extendedCount == -1 || extended) + { + extendedCount = discoverExtendedRifts(localHandle->cachedDescriptorArray, Linux::LinuxDisplaySearchHandle::DescArraySize, edidInfo); + } + + localHandle->extended = true; + localHandle->extendedDisplayCount = extendedCount; + int totalCount = extendedCount; + + /// FIXME: Implement application mode for OS X. + localHandle->application = false; + localHandle->applicationDisplayCount = 0; + + localHandle->displayCount = totalCount; + + return totalCount; +} + + +Ptr Display::GetDisplay( int index, DisplaySearchHandle* handle ) +{ + Ptr result = NULL; + + if (index < 0) + { + OVR::LogError("[Linux Display] Invalid index given to GetDisplay."); + return NULL; + } + + Linux::LinuxDisplaySearchHandle* localHandle = (Linux::LinuxDisplaySearchHandle*)handle; + if (localHandle == NULL) + { + OVR::LogError("[Linux Display] No search handle passed into GetDisplay. Return 0 rifts."); + return NULL; + } + + if (localHandle->extended) + { + if (index >= 0 && index < (int)localHandle->extendedDisplayCount) + { + return *new Linux::LinuxDisplayGeneric(localHandle->cachedDescriptorArray[index]); + } + + index -= localHandle->extendedDisplayCount; + } + + if (localHandle->application) + { + OVR::LogError("[Linux Display] Mac does not support application displays."); + } + + return result; +} + + +} // namespace OVR diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Displays/OVR_Linux_Display.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Displays/OVR_Linux_Display.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,133 @@ +/************************************************************************************ + +Filename : OVR_Linux_Display.h +Content : Linux-specific Display declarations +Created : July 2, 2014 +Authors : James Hughes + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +*************************************************************************************/ + +#ifndef OVR_Linux_Display_h +#define OVR_Linux_Display_h + +#include "OVR_Display.h" + +namespace OVR { namespace Linux { + + +//------------------------------------------------------------------------------------- +// DisplayDesc + +// Display information enumerable through OS . +// TBD: Should we just move this to public header, so it's a const member of Display? +struct DisplayDesc +{ + HmdTypeEnum DeviceTypeGuess; + String DisplayID; // This is the device identifier string from MONITORINFO (for app usage) + String ModelName; // This is a "DK2" type string + String EdidSerialNumber; + Sizei LogicalResolutionInPixels; + Sizei NativeResolutionInPixels; + Vector2i DesktopDisplayOffset; +}; + + +//------------------------------------------------------------------------------------- +// DisplayEDID + +// Describes EDID information as reported from our display driver. +struct DisplayEDID +{ + DisplayEDID() : + ModelNumber(0) + {} + + String MonitorName; + UInt16 ModelNumber; + String VendorName; + String SerialNumber; +}; + + +//------------------------------------------------------------------------------------- +// Linux Display Search Handle +class LinuxDisplaySearchHandle : public DisplaySearchHandle +{ +public: + LinuxDisplaySearchHandle() : + extended(false), + application(false), + extendedDisplayCount(0), + applicationDisplayCount(0), + displayCount(0) + {} + virtual ~LinuxDisplaySearchHandle() {} + + static const int DescArraySize = 16; + + Linux::DisplayDesc cachedDescriptorArray[DescArraySize]; + bool extended; + bool application; + int extendedDisplayCount; + int applicationDisplayCount; + int displayCount; +}; + +//------------------------------------------------------------------------------------- +// LinuxDisplayGeneric + +// Describes Linux display in Compatibility mode, containing basic data +class LinuxDisplayGeneric : public Display +{ +public: + LinuxDisplayGeneric( const DisplayDesc& dd ) : + Display(dd.DeviceTypeGuess, + dd.DisplayID, + dd.ModelName, + dd.EdidSerialNumber, + dd.LogicalResolutionInPixels, + dd.NativeResolutionInPixels, + dd.DesktopDisplayOffset, + 0, + 0, + false) + { + } + + virtual ~LinuxDisplayGeneric() + { + } + + virtual bool InCompatibilityMode() const + { + return true; + } + + // Generic displays are not capable of mirroring + virtual MirrorMode SetMirrorMode( MirrorMode newMode ) + { + OVR_UNUSED( newMode ); + return MirrorDisabled; + } +}; + +}} // namespace OVR::Linux + +#endif // OVR_Linux_Display_h diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Displays/OVR_Linux_SDKWindow.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Displays/OVR_Linux_SDKWindow.cpp Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,649 @@ +/******************************************************************************* + +Filename : OVR_Linux_SDKWindow.cpp +Content : SDK generated Linux window. +Created : October 1, 2014 +Authors : James Hughes + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +*******************************************************************************/ + +#include "OVR_Linux_SDKWindow.h" +#include "../Kernel/OVR_Log.h" +#include "../Kernel/OVR_Log.h" +#include "../../../3rdParty/EDID/edid.h" + +namespace OVR { + +// Forward declarations +static Window constructWindow(struct _XDisplay* display, int xscreen, + XVisualInfo* xvisual, + const LinuxDeviceScreen& screen); + +static XRRModeInfo* findModeByXID(XRRScreenResources* screen, RRMode xid) +{ + for (int m = 0; m < screen->nmode; ++m) + { + XRRModeInfo* mode = &screen->modes[m]; + if (xid == mode->id) + { + return mode; + } + } + return NULL; +} + +/// Retrieves a list of available device screens on which we can build +/// SDK windows. Returns number of devices found. +/// screens Array which this function will populate. +/// maxNumScreens Maximum number of screens to store in screens. +static int getDeviceScreens(LinuxDeviceScreen* screens, int maxNumDevices) +{ + struct _XDisplay* disp = XOpenDisplay(NULL); + if (!disp) + { + OVR::LogError("[SDKWindow] Unable to open X Display."); + return 0; + } + + int numDevices = 0; + int numScreens = XScreenCount(disp); + for (int i = 0; i < numScreens; ++i) + { + // Screen root is used to detect what video output the crtc is using. + Window sr = XRootWindow(disp, i); + XRRScreenResources* screen = XRRGetScreenResources(disp, sr); + + for (int ii = 0; ii < screen->ncrtc; ++ii) + { + XRRCrtcInfo* crtcInfo = XRRGetCrtcInfo(disp, screen, screen->crtcs[ii]); + + if (0 == crtcInfo->noutput) + { + XRRFreeCrtcInfo(crtcInfo); + continue; + } + + bool foundOutput = false; + RROutput output = crtcInfo->outputs[0]; + for (int k = 0; k < crtcInfo->noutput; ++k) + { + XRROutputInfo* outputInfo = + XRRGetOutputInfo(disp, screen, crtcInfo->outputs[k]); + for (int kk = 0 ; kk < outputInfo->nmode; ++kk) + { + if (outputInfo->modes[kk] == crtcInfo->mode) + { + output = crtcInfo->outputs[k]; + foundOutput = true; + break; + } + } + XRRFreeOutputInfo(outputInfo); + if (foundOutput) { break; } + } + + if (!foundOutput) + { + XRRFreeCrtcInfo(crtcInfo); + continue; + } + + XRROutputInfo* outputInfo = XRRGetOutputInfo(disp, screen, output); + if (RR_Connected != outputInfo->connection) + { + XRRFreeOutputInfo(outputInfo); + XRRFreeCrtcInfo(crtcInfo); + continue; + } + + // Read EDID associated with crtc. + MonitorInfo* mi = read_edid_data(disp, output); + if (mi == NULL) + { + XRRFreeOutputInfo(outputInfo); + XRRFreeCrtcInfo(crtcInfo); + continue; + } + + if (strcmp(mi->manufacturer_code, "OVR") == 0) + { + XRRModeInfo* modeInfo = findModeByXID(screen, crtcInfo->mode); + + DistortionRotation desiredRot = DistRotateNone; + if (mi->product_code == 3) + { + // This is a DK2, we may have to rotate our output. + // If we don't have to, we should alert the user that + // rotating the display using the DM or graphics + // card settings is highly non-optimal. + desiredRot = DistRotateCCW90; + if (crtcInfo->rotation != RR_Rotate_0) + { + OVR::LogError("Please do not rotate your rift's screen."); + + if (crtcInfo->rotation == RR_Rotate_90) + { + // The user has manually rotated the screen. + // So apply no rotation on our end. + desiredRot = DistRotateNone; + } + } + } + else + { + if (crtcInfo->rotation != RR_Rotate_0) + { + OVR::LogError("Please do not rotate your rift's screen."); + } + } + + int width = modeInfo->width; + int height = modeInfo->height; + + // Swap width / height if display is rotated (shouldn't be on linux). + if ( crtcInfo->rotation == RR_Rotate_90 + || crtcInfo->rotation == RR_Rotate_270) + { + width = modeInfo->height; + height = modeInfo->width; + } + + // Push detected monitor. + screens[numDevices].set(i, screen->crtcs[ii], desiredRot, + mi->product_code, width, height, + crtcInfo->x, crtcInfo->y); + ++numDevices; + } + + delete mi; + + if (numDevices == maxNumDevices) + { + XRRFreeOutputInfo(outputInfo); + XRRFreeCrtcInfo(crtcInfo); + XRRFreeScreenResources(screen); + OVR::LogError("[SDKWindow] Maxed out number of devices.."); + XCloseDisplay(disp); + return numDevices; + } + + XRRFreeOutputInfo(outputInfo); + XRRFreeCrtcInfo(crtcInfo); + } + + XRRFreeScreenResources(screen); + } + XCloseDisplay(disp); + return numDevices; +} + + +LinuxDeviceScreen SDKWindow::findDevScreenForHMD(const ovrHmd& hmd) +{ + return findDevScreenForDevID(hmd->DisplayDeviceName); +} + +LinuxDeviceScreen SDKWindow::findDevScreenForDevID(const char* deviceIDIn) +{ + const int maxNumDevices = 5; + LinuxDeviceScreen screens[maxNumDevices]; + int numDevices = getDeviceScreens(screens, maxNumDevices); + + if (numDevices > 0) + { + // Identify target for SDK window via hmd info. + for (int i = 0; i < numDevices; ++i) + { + LinuxDeviceScreen& screen = screens[i]; + + char deviceID[32]; + OVR_sprintf(deviceID, 32, "OVR%04d-%d", + screen.productCode, screen.crtcid); + + if (strcmp(deviceIDIn, deviceID) == 0) + { + return screen; + } + } + } + + return LinuxDeviceScreen(); +} + +DistortionRotation SDKWindow::getRotation(const ovrHmd& hmd) +{ + LinuxDeviceScreen screen = findDevScreenForHMD(hmd); + if (screen.isValid()) + { + return screen.rotation; + } + else + { + return DistRotateNone; + } +} + + +bool SDKWindow::getVisualFromDrawable(GLXDrawable drawable, XVisualInfo* vinfoOut) +{ + struct _XDisplay* display = glXGetCurrentDisplay(); + + unsigned int value; + glXQueryDrawable(display, drawable, GLX_FBCONFIG_ID, &value); + const int attribs[] = {GLX_FBCONFIG_ID, (int)value, None}; + int screen; + glXQueryContext(display, glXGetCurrentContext(), GLX_SCREEN, &screen); + int numElems; + GLXFBConfig* config = glXChooseFBConfig(display, screen, attribs, &numElems); + if (numElems > 0) + { + XVisualInfo* chosen = glXGetVisualFromFBConfig(display, *config); + *vinfoOut = *chosen; + XFree(config); + return true; + } + return false; +} + +SDKWindow::SDKWindow(const ovrHmd& hmd) : + mXDisplay(NULL), + mXScreen(-1), + mXVisual(NULL), + mXUniqueContext(-1), + mXWindow(0), + mFBConfigID(0) +{ + OVR_UNUSED(hmd); +} + +SDKWindow::~SDKWindow() +{ + if (mXWindow) + { + XDeleteContext(mXDisplay, mXWindow, mXUniqueContext); + XUnmapWindow(mXDisplay, mXWindow); + XDestroyWindow(mXDisplay, mXWindow); + mXWindow = static_cast(0); + } + + if (mXVisual) + { + XFree(mXVisual); + mXVisual = NULL; + } + + if (mXDisplay) + { + XCloseDisplay(mXDisplay); + } +} + +void SDKWindow::buildVisualAndWindow(const LinuxDeviceScreen& devScreen) +{ + mXDisplay = XOpenDisplay(NULL); + mXUniqueContext = XUniqueContext(); + mXScreen = devScreen.screen; + mFBConfigID = chooseFBConfigID(mXDisplay, mXScreen); + + mXVisual = getVisual(mXDisplay, mFBConfigID, mXScreen); + if (mXVisual != NULL) + { + mXWindow = constructWindow(mXDisplay, mXScreen, mXVisual, devScreen); + mDeviceScreen = devScreen; + } +} + +// Used in chooseVisual. May need to expose this to the end use so they can +// choose an appropriate framebuffer configuration. +struct FBConfig +{ + FBConfig() : + redBits(8), + greenBits(8), + blueBits(8), + alphaBits(8), + depthBits(8), + stencilBits(-1), + doubleBuffer(true), + auxBuffers(-1) + {} + + int redBits; + int greenBits; + int blueBits; + int alphaBits; + int depthBits; + int stencilBits; + bool doubleBuffer; + int auxBuffers; + + int xcfg; +}; + +static int fbCalcContrib(int desired, int current) +{ + int diff = desired - current; + if (current != -1) { return diff * diff; } + else { return 0; } +} + +// Choose frame buffer configuration and return fbConfigID. +int SDKWindow::chooseFBConfigID(struct _XDisplay* display, int xscreen) +{ + int nativeCount = 0; + GLXFBConfig* nativeConfigs = + glXGetFBConfigs(display, xscreen, &nativeCount); + if (!nativeCount) + { + OVR::LogError("[SDKWindow] No valid frame buffer configurations found."); + return 0; + } + + FBConfig* usables = static_cast(calloc(nativeCount, sizeof(FBConfig))); + int numUsables = 0; + + for (int i = 0; i < nativeCount; ++i) + { + GLXFBConfig native = nativeConfigs[i]; + FBConfig* usable = &usables[numUsables]; + int v = 0; + + // Only frame buffer configcs with attached visuals. + glXGetFBConfigAttrib(display, native, GLX_VISUAL_ID, &v); + if (!v) { continue; } + + // Only RGBA frame buffers. + glXGetFBConfigAttrib(display, native, GLX_RENDER_TYPE, &v); + if (!(v & GLX_RGBA_BIT)) { continue; } + + glXGetFBConfigAttrib(display, native, GLX_DRAWABLE_TYPE, &v); + if (!(v & GLX_WINDOW_BIT)) { continue; } + + glXGetFBConfigAttrib(display, native, GLX_DEPTH_SIZE, &usable->depthBits); + glXGetFBConfigAttrib(display, native, GLX_STENCIL_SIZE, &usable->stencilBits); + + glXGetFBConfigAttrib(display, native, GLX_RED_SIZE, &usable->redBits); + glXGetFBConfigAttrib(display, native, GLX_GREEN_SIZE, &usable->greenBits); + glXGetFBConfigAttrib(display, native, GLX_BLUE_SIZE, &usable->blueBits); + glXGetFBConfigAttrib(display, native, GLX_ALPHA_SIZE, &usable->alphaBits); + + glXGetFBConfigAttrib(display, native, GLX_ALPHA_SIZE, &usable->auxBuffers); + + glXGetFBConfigAttrib(display, native, GLX_DOUBLEBUFFER, &v); + usable->doubleBuffer = v ? true : false; + + glXGetFBConfigAttrib(display, native, GLX_FBCONFIG_ID, &usable->xcfg); + + ++numUsables; + } + + // We really want std::numeric_limits::max() instead of hardcoded vals. + const int MostMissing = 100; + int leastMissing = MostMissing; + int leastBias = MostMissing; + + const FBConfig* closest = NULL; + + // Desired is currently the default config built by constructor. + FBConfig desired; + + for (int i = 0; i < numUsables; ++i) + { + const FBConfig* cur = &usables[i]; + + if (desired.doubleBuffer != cur->doubleBuffer) { continue; } + + int missing = 0; + if (desired.alphaBits > 0 && cur->alphaBits == 0) { ++missing; } + if (desired.depthBits > 0 && cur->depthBits == 0) { ++missing; } + if (desired.stencilBits > 0 && cur->stencilBits == 0) { ++missing; } + if (desired.redBits > 0 && desired.redBits != cur->redBits) { ++missing; } + if (desired.greenBits > 0 && desired.greenBits != cur->greenBits) { ++missing; } + if (desired.blueBits > 0 && desired.blueBits != cur->blueBits) { ++missing; } + + int bias = fbCalcContrib(desired.redBits, cur->redBits) + + fbCalcContrib(desired.greenBits, cur->greenBits) + + fbCalcContrib(desired.blueBits, cur->blueBits) + + fbCalcContrib(desired.alphaBits, cur->alphaBits) + + fbCalcContrib(desired.depthBits, cur->depthBits) + + fbCalcContrib(desired.stencilBits, cur->stencilBits); + + if (missing < leastMissing) + { + closest = cur; + } + else if (missing == leastMissing) + { + // Now select against squared differences. + if (bias < leastBias) + { + closest = cur; + } + } + + if (closest == cur) + { + leastMissing = missing; + leastBias = bias; + } + } + + if (closest == NULL) + { + OVR::LogError("[SDKWindow] Failed to select appropriate frame buffer."); + XFree(nativeConfigs); + free(usables); + return 0; + } + + int retVal = closest->xcfg; + + XFree(nativeConfigs); + free(usables); + + return retVal; +} + +// Obtain visual from frame buffer configuration ID. +XVisualInfo* SDKWindow::getVisual(struct _XDisplay* display, + int fbConfigID, int xscreen) +{ + GLXFBConfig* cfg = getGLXFBConfig(display, fbConfigID, xscreen); + XVisualInfo* viOut = NULL; + if (cfg != NULL) + { + viOut = glXGetVisualFromFBConfig(display, *cfg); + XFree(cfg); + cfg = NULL; + } + else + { + OVR::LogError("Unable to find fb config ID."); + } + return viOut; +} + +// GLXFBConfig pointer from frame buffer configuration ID. You must call +// XFree on the GLXFBConfig pointer. +GLXFBConfig* SDKWindow::getGLXFBConfig(struct _XDisplay* display, + int fbConfigID, int xscreen) +{ + const int attribs[] = {GLX_FBCONFIG_ID, (int)fbConfigID, None}; + int numElems; + + GLXFBConfig* config = glXChooseFBConfig(display, xscreen, attribs, &numElems); + if (numElems > 0) + { + return config; + } + else + { + return NULL; + } +} + + +static int gXLastError = -1; +static int handleXError(struct _XDisplay* display, XErrorEvent* event) +{ + OVR_UNUSED(display); + gXLastError = event->error_code; + return 0; +} + +static void obtainXErrorHandler() +{ + gXLastError = Success; + XSetErrorHandler(handleXError); +} + +static void releaseXErrorHandler(struct _XDisplay* display) +{ + XSync(display, False); + XSetErrorHandler(NULL); +} + +// Returns 0 on error, otherwise a valid X window is returned. +static Window constructWindow(struct _XDisplay* xDisp, int xScreen, + XVisualInfo* xVisual, + const LinuxDeviceScreen& devScreen) +{ + XSetWindowAttributes wa; + + Window root = XRootWindow(xDisp, xScreen); + Window xWindowOut = 0; + + // Create Window + { + Colormap xWinColorMapOut = XCreateColormap( + xDisp, root, xVisual->visual, AllocNone); + unsigned long wamask = CWBorderPixel | CWColormap | CWEventMask; + + wa.colormap = xWinColorMapOut; + wa.border_pixel = 0; + wa.event_mask = StructureNotifyMask | ExposureMask | FocusChangeMask + | VisibilityChangeMask | EnterWindowMask | LeaveWindowMask + | PropertyChangeMask; + + obtainXErrorHandler(); + + xWindowOut = XCreateWindow(xDisp, root, + 0, 0, + devScreen.width, devScreen.height, + 0, + xVisual->depth, + InputOutput, + xVisual->visual, + wamask, + &wa); + + releaseXErrorHandler(xDisp); + + if (!xWindowOut) + { + OVR::LogError("[SDKWindow] Failed to create SDK window."); + return 0; + } + + XFreeColormap(xDisp, xWinColorMapOut); + } + + // OVERRIDE REDIRECT. + XSetWindowAttributes attributes; + attributes.override_redirect = True; + XChangeWindowAttributes(xDisp, xWindowOut, + CWOverrideRedirect, &attributes); + + // Show the window (do this in full screen or windowed). + XMapRaised(xDisp, xWindowOut); + XFlush(xDisp); + + // Position ourselves manually since there should be no WM managing us. + XRaiseWindow(xDisp, xWindowOut); + XMoveWindow(xDisp, xWindowOut, devScreen.offsetX, devScreen.offsetY); + XResizeWindow(xDisp, xWindowOut, devScreen.width, devScreen.height); + + XFlush(xDisp); + + // WM Backup in case there still exists a WM managing us... + Atom NET_WM_BYPASS_COMPOSITOR = + XInternAtom(xDisp, "_NET_WM_BYPASS_COMPOSITOR", False); + Atom NET_WM_STATE = + XInternAtom(xDisp, "_NET_WM_STATE", False); + Atom NET_WM_STATE_FULLSCREEN = + XInternAtom(xDisp, "_NET_WM_STATE_FULLSCREEN", False); + Atom NET_ACTIVE_WINDOW = + XInternAtom(xDisp, "_NET_ACTIVE_WINDOW", False); + + // Bypass compositor if we are under a compositing WM. + // Just in case a WM ignores our override_redirect. + if (NET_WM_BYPASS_COMPOSITOR) + { + const unsigned long bypass = 1; + XChangeProperty(xDisp, xWindowOut, + NET_WM_BYPASS_COMPOSITOR, + XA_CARDINAL, 32, PropModeReplace, + (unsigned char*)&bypass, 1); + } + + if (NET_WM_STATE && NET_WM_STATE_FULLSCREEN) + { + // BACKUP: If we are still managed by a WM we want fullscreen. + const int EWMH_STATE_ADD = 1; + + if (NET_ACTIVE_WINDOW) + { + XEvent event; + memset(&event, 0, sizeof(event)); + + event.type = ClientMessage; + event.xclient.window = xWindowOut; + event.xclient.format = 32; + event.xclient.message_type = NET_ACTIVE_WINDOW; + event.xclient.data.l[0] = 1; + event.xclient.data.l[1] = 0; + + XSendEvent(xDisp, root, False, + SubstructureNotifyMask | SubstructureRedirectMask, + &event); + } + + XEvent event; + memset(&event, 0, sizeof(event)); + + event.type = ClientMessage; + event.xclient.window = xWindowOut; + event.xclient.format = 32; + event.xclient.message_type = NET_WM_STATE; + event.xclient.data.l[0] = EWMH_STATE_ADD; + event.xclient.data.l[1] = NET_WM_STATE_FULLSCREEN; + event.xclient.data.l[2] = 0; + event.xclient.data.l[3] = 1; + + XSendEvent(xDisp, root, False, + SubstructureNotifyMask | SubstructureRedirectMask, + &event); + } + + return xWindowOut; +} + +} // namespace OVR + diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Displays/OVR_Linux_SDKWindow.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Displays/OVR_Linux_SDKWindow.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,147 @@ +/******************************************************************************* + +Filename : OVR_Linux_SDKWindow.h +Content : SDK generated Linux window. +Created : October 1, 2014 +Authors : James Hughes + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +*******************************************************************************/ + +#ifndef OVR_Linux_SDKWindow_h +#define OVR_Linux_SDKWindow_h + +#include "../OVR_CAPI.h" +#include "../CAPI/GL/CAPI_GL_Util.h" + +#include +#include +#include +#include +#include + +namespace OVR { + +enum DistortionRotation +{ + DistRotateNone, + DistRotateCCW90 +}; + +struct LinuxDeviceScreen +{ + LinuxDeviceScreen() : + screen(-1), + crtcid(0), + rotation(DistRotateNone), + productCode(-1), + width(-1), + height(-1), + offsetX(-1), + offsetY(-1) + {} + + void set(int xScreen, XID xid, DistortionRotation rot, int prodCode, + int w, int h, int x, int y) + { + screen = xScreen; + crtcid = xid; + rotation = rot; + productCode = prodCode; + + width = w; + height = h; + offsetX = x; + offsetY = y; + } + + bool isValid() {return (screen != -1);} + + int screen; ///< X Screen this device occupies. + XID crtcid; ///< XID uniquely identifying this device on XDisplay. + DistortionRotation rotation; + int productCode; + + // Actual width and height of screen. + int width; + int height; + + // Offset if using twinview + int offsetX; + int offsetY; +}; + +class SDKWindow +{ +public: + + SDKWindow(const ovrHmd& hmd); + ~SDKWindow(); + + /// Rotation necessary to correctly orient this SDK window. + DistortionRotation GetDistortionRotation() {return mDeviceScreen.rotation;} + + struct _XDisplay* GetDisplay() {return mXDisplay;} + XVisualInfo* GetVisual() {return mXVisual;} + Window GetDrawable() {return mXWindow;} + bool HasValidWindow() {return (mXWindow != 0);} + + // Choose frame buffer configuration and return fbConfigID. Returns -1 if + // a failure occurs. + static int chooseFBConfigID(struct _XDisplay* display, int xscreen); + + // Obtain visual from frame buffer configuration ID. You must call XFree + // on the XVisualInfo* pointer. + static XVisualInfo* getVisual(struct _XDisplay* display, + int fbConfigID, int xscreen); + + // GLXFBConfig pointer from frame buffer configuration ID. You must call + // XFree on the GLXFBConfig pointer. + static GLXFBConfig* getGLXFBConfig(struct _XDisplay* display, + int fbConfigID, int xscreen); + + static LinuxDeviceScreen findDevScreenForHMD(const ovrHmd& hmd); + static LinuxDeviceScreen findDevScreenForDevID(const char* deviceID); + + static DistortionRotation getRotation(const ovrHmd& hmd); + + // Obtains XVisualInfo for currently bound context. Returns true if a + // visual was successfully obtained. False otherwise. + static bool getVisualFromDrawable(GLXDrawable drawable, XVisualInfo* vinfoOut); + +private: + + /// Constructs SDK window on the given device screen. + void buildVisualAndWindow(const LinuxDeviceScreen& devScreen); + + // Added m in front of variables so as to not conflict with X names. + struct _XDisplay* mXDisplay; + int mXScreen; + XVisualInfo* mXVisual; + XContext mXUniqueContext; + Window mXWindow; + int mFBConfigID; + + LinuxDeviceScreen mDeviceScreen; +}; + + +} // namespace OVR + +#endif // OVR_Linux_SDKWindow_h diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Kernel/OVR_Alg.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Kernel/OVR_Alg.cpp Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,57 @@ +/************************************************************************************ + +Filename : OVR_Alg.cpp +Content : Static lookup tables for Alg functions +Created : September 19, 2012 +Notes : + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#include "OVR_Types.h" + +namespace OVR { namespace Alg { + +//------------------------------------------------------------------------ +extern const uint8_t UpperBitTable[256] = +{ + 0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, + 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, + 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, + 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, + 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, + 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, + 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, + 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7 +}; + +extern const uint8_t LowerBitTable[256] = +{ + 8,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, + 5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, + 6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, + 5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, + 7,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, + 5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, + 6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, + 5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0 +}; + + +}} // OVE::Alg diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Kernel/OVR_Alg.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Kernel/OVR_Alg.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,1062 @@ +/************************************************************************************ + +PublicHeader: OVR_Kernel.h +Filename : OVR_Alg.h +Content : Simple general purpose algorithms: Sort, Binary Search, etc. +Created : September 19, 2012 +Notes : + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#ifndef OVR_Alg_h +#define OVR_Alg_h + +#include "OVR_Types.h" +#include + +namespace OVR { namespace Alg { + + +//----------------------------------------------------------------------------------- +// ***** Operator extensions + +template OVR_FORCE_INLINE void Swap(T &a, T &b) +{ T temp(a); a = b; b = temp; } + + +// ***** min/max are not implemented in Visual Studio 6 standard STL + +template OVR_FORCE_INLINE const T Min(const T a, const T b) +{ return (a < b) ? a : b; } + +template OVR_FORCE_INLINE const T Max(const T a, const T b) +{ return (b < a) ? a : b; } + +template OVR_FORCE_INLINE const T Clamp(const T v, const T minVal, const T maxVal) +{ return Max(minVal, Min(v, maxVal)); } + +template OVR_FORCE_INLINE int Chop(T f) +{ return (int)f; } + +template OVR_FORCE_INLINE T Lerp(T a, T b, T f) +{ return (b - a) * f + a; } + + +// These functions stand to fix a stupid VC++ warning (with /Wp64 on): +// "warning C4267: 'argument' : conversion from 'size_t' to 'const unsigned', possible loss of data" +// Use these functions instead of gmin/gmax if the argument has size +// of the pointer to avoid the warning. Though, functionally they are +// absolutelly the same as regular gmin/gmax. +template OVR_FORCE_INLINE const T PMin(const T a, const T b) +{ + OVR_COMPILER_ASSERT(sizeof(T) == sizeof(size_t)); + return (a < b) ? a : b; +} +template OVR_FORCE_INLINE const T PMax(const T a, const T b) +{ + OVR_COMPILER_ASSERT(sizeof(T) == sizeof(size_t)); + return (b < a) ? a : b; +} + + +template OVR_FORCE_INLINE const T Abs(const T v) +{ return (v>=0) ? v : -v; } + + +//----------------------------------------------------------------------------------- +// ***** OperatorLess +// +template struct OperatorLess +{ + static bool Compare(const T& a, const T& b) + { + return a < b; + } +}; + + +//----------------------------------------------------------------------------------- +// ***** QuickSortSliced +// +// Sort any part of any array: plain, Array, ArrayPaged, ArrayUnsafe. +// The range is specified with start, end, where "end" is exclusive! +// The comparison predicate must be specified. +template +void QuickSortSliced(Array& arr, size_t start, size_t end, Less less) +{ + enum + { + Threshold = 9 + }; + + if(end - start < 2) return; + + intptr_t stack[80]; + intptr_t* top = stack; + intptr_t base = (intptr_t)start; + intptr_t limit = (intptr_t)end; + + for(;;) + { + intptr_t len = limit - base; + intptr_t i, j, pivot; + + if(len > Threshold) + { + // we use base + len/2 as the pivot + pivot = base + len / 2; + Swap(arr[base], arr[pivot]); + + i = base + 1; + j = limit - 1; + + // now ensure that *i <= *base <= *j + if(less(arr[j], arr[i])) Swap(arr[j], arr[i]); + if(less(arr[base], arr[i])) Swap(arr[base], arr[i]); + if(less(arr[j], arr[base])) Swap(arr[j], arr[base]); + + for(;;) + { + do i++; while( less(arr[i], arr[base]) ); + do j--; while( less(arr[base], arr[j]) ); + + if( i > j ) + { + break; + } + + Swap(arr[i], arr[j]); + } + + Swap(arr[base], arr[j]); + + // now, push the largest sub-array + if(j - base > limit - i) + { + top[0] = base; + top[1] = j; + base = i; + } + else + { + top[0] = i; + top[1] = limit; + limit = j; + } + top += 2; + } + else + { + // the sub-array is small, perform insertion sort + j = base; + i = j + 1; + + for(; i < limit; j = i, i++) + { + for(; less(arr[j + 1], arr[j]); j--) + { + Swap(arr[j + 1], arr[j]); + if(j == base) + { + break; + } + } + } + if(top > stack) + { + top -= 2; + base = top[0]; + limit = top[1]; + } + else + { + break; + } + } + } +} + + +//----------------------------------------------------------------------------------- +// ***** QuickSortSliced +// +// Sort any part of any array: plain, Array, ArrayPaged, ArrayUnsafe. +// The range is specified with start, end, where "end" is exclusive! +// The data type must have a defined "<" operator. +template +void QuickSortSliced(Array& arr, size_t start, size_t end) +{ + typedef typename Array::ValueType ValueType; + QuickSortSliced(arr, start, end, OperatorLess::Compare); +} + +// Same as corresponding G_QuickSortSliced but with checking array limits to avoid +// crash in the case of wrong comparator functor. +template +bool QuickSortSlicedSafe(Array& arr, size_t start, size_t end, Less less) +{ + enum + { + Threshold = 9 + }; + + if(end - start < 2) return true; + + intptr_t stack[80]; + intptr_t* top = stack; + intptr_t base = (intptr_t)start; + intptr_t limit = (intptr_t)end; + + for(;;) + { + intptr_t len = limit - base; + intptr_t i, j, pivot; + + if(len > Threshold) + { + // we use base + len/2 as the pivot + pivot = base + len / 2; + Swap(arr[base], arr[pivot]); + + i = base + 1; + j = limit - 1; + + // now ensure that *i <= *base <= *j + if(less(arr[j], arr[i])) Swap(arr[j], arr[i]); + if(less(arr[base], arr[i])) Swap(arr[base], arr[i]); + if(less(arr[j], arr[base])) Swap(arr[j], arr[base]); + + for(;;) + { + do + { + i++; + if (i >= limit) + return false; + } while( less(arr[i], arr[base]) ); + do + { + j--; + if (j < 0) + return false; + } while( less(arr[base], arr[j]) ); + + if( i > j ) + { + break; + } + + Swap(arr[i], arr[j]); + } + + Swap(arr[base], arr[j]); + + // now, push the largest sub-array + if(j - base > limit - i) + { + top[0] = base; + top[1] = j; + base = i; + } + else + { + top[0] = i; + top[1] = limit; + limit = j; + } + top += 2; + } + else + { + // the sub-array is small, perform insertion sort + j = base; + i = j + 1; + + for(; i < limit; j = i, i++) + { + for(; less(arr[j + 1], arr[j]); j--) + { + Swap(arr[j + 1], arr[j]); + if(j == base) + { + break; + } + } + } + if(top > stack) + { + top -= 2; + base = top[0]; + limit = top[1]; + } + else + { + break; + } + } + } + return true; +} + +template +bool QuickSortSlicedSafe(Array& arr, size_t start, size_t end) +{ + typedef typename Array::ValueType ValueType; + return QuickSortSlicedSafe(arr, start, end, OperatorLess::Compare); +} + +//----------------------------------------------------------------------------------- +// ***** QuickSort +// +// Sort an array Array, ArrayPaged, ArrayUnsafe. +// The array must have GetSize() function. +// The comparison predicate must be specified. +template +void QuickSort(Array& arr, Less less) +{ + QuickSortSliced(arr, 0, arr.GetSize(), less); +} + +// checks for boundaries +template +bool QuickSortSafe(Array& arr, Less less) +{ + return QuickSortSlicedSafe(arr, 0, arr.GetSize(), less); +} + + +//----------------------------------------------------------------------------------- +// ***** QuickSort +// +// Sort an array Array, ArrayPaged, ArrayUnsafe. +// The array must have GetSize() function. +// The data type must have a defined "<" operator. +template +void QuickSort(Array& arr) +{ + typedef typename Array::ValueType ValueType; + QuickSortSliced(arr, 0, arr.GetSize(), OperatorLess::Compare); +} + +template +bool QuickSortSafe(Array& arr) +{ + typedef typename Array::ValueType ValueType; + return QuickSortSlicedSafe(arr, 0, arr.GetSize(), OperatorLess::Compare); +} + +//----------------------------------------------------------------------------------- +// ***** InsertionSortSliced +// +// Sort any part of any array: plain, Array, ArrayPaged, ArrayUnsafe. +// The range is specified with start, end, where "end" is exclusive! +// The comparison predicate must be specified. +// Unlike Quick Sort, the Insertion Sort works much slower in average, +// but may be much faster on almost sorted arrays. Besides, it guarantees +// that the elements will not be swapped if not necessary. For example, +// an array with all equal elements will remain "untouched", while +// Quick Sort will considerably shuffle the elements in this case. +template +void InsertionSortSliced(Array& arr, size_t start, size_t end, Less less) +{ + size_t j = start; + size_t i = j + 1; + size_t limit = end; + + for(; i < limit; j = i, i++) + { + for(; less(arr[j + 1], arr[j]); j--) + { + Swap(arr[j + 1], arr[j]); + if(j <= start) + { + break; + } + } + } +} + + +//----------------------------------------------------------------------------------- +// ***** InsertionSortSliced +// +// Sort any part of any array: plain, Array, ArrayPaged, ArrayUnsafe. +// The range is specified with start, end, where "end" is exclusive! +// The data type must have a defined "<" operator. +template +void InsertionSortSliced(Array& arr, size_t start, size_t end) +{ + typedef typename Array::ValueType ValueType; + InsertionSortSliced(arr, start, end, OperatorLess::Compare); +} + +//----------------------------------------------------------------------------------- +// ***** InsertionSort +// +// Sort an array Array, ArrayPaged, ArrayUnsafe. +// The array must have GetSize() function. +// The comparison predicate must be specified. + +template +void InsertionSort(Array& arr, Less less) +{ + InsertionSortSliced(arr, 0, arr.GetSize(), less); +} + +//----------------------------------------------------------------------------------- +// ***** InsertionSort +// +// Sort an array Array, ArrayPaged, ArrayUnsafe. +// The array must have GetSize() function. +// The data type must have a defined "<" operator. +template +void InsertionSort(Array& arr) +{ + typedef typename Array::ValueType ValueType; + InsertionSortSliced(arr, 0, arr.GetSize(), OperatorLess::Compare); +} + +//----------------------------------------------------------------------------------- +// ***** Median +// Returns a median value of the input array. +// Caveats: partially sorts the array, returns a reference to the array element +// TBD: This needs to be optimized and generalized +// +template +typename Array::ValueType& Median(Array& arr) +{ + size_t count = arr.GetSize(); + size_t mid = (count - 1) / 2; + OVR_ASSERT(count > 0); + + for (size_t j = 0; j <= mid; j++) + { + size_t min = j; + for (size_t k = j + 1; k < count; k++) + if (arr[k] < arr[min]) + min = k; + Swap(arr[j], arr[min]); + } + return arr[mid]; +} + +//----------------------------------------------------------------------------------- +// ***** LowerBoundSliced +// +template +size_t LowerBoundSliced(const Array& arr, size_t start, size_t end, const Value& val, Less less) +{ + intptr_t first = (intptr_t)start; + intptr_t len = (intptr_t)(end - start); + intptr_t half; + intptr_t middle; + + while(len > 0) + { + half = len >> 1; + middle = first + half; + if(less(arr[middle], val)) + { + first = middle + 1; + len = len - half - 1; + } + else + { + len = half; + } + } + return (size_t)first; +} + + +//----------------------------------------------------------------------------------- +// ***** LowerBoundSliced +// +template +size_t LowerBoundSliced(const Array& arr, size_t start, size_t end, const Value& val) +{ + return LowerBoundSliced(arr, start, end, val, OperatorLess::Compare); +} + +//----------------------------------------------------------------------------------- +// ***** LowerBoundSized +// +template +size_t LowerBoundSized(const Array& arr, size_t size, const Value& val) +{ + return LowerBoundSliced(arr, 0, size, val, OperatorLess::Compare); +} + +//----------------------------------------------------------------------------------- +// ***** LowerBound +// +template +size_t LowerBound(const Array& arr, const Value& val, Less less) +{ + return LowerBoundSliced(arr, 0, arr.GetSize(), val, less); +} + + +//----------------------------------------------------------------------------------- +// ***** LowerBound +// +template +size_t LowerBound(const Array& arr, const Value& val) +{ + return LowerBoundSliced(arr, 0, arr.GetSize(), val, OperatorLess::Compare); +} + + + +//----------------------------------------------------------------------------------- +// ***** UpperBoundSliced +// +template +size_t UpperBoundSliced(const Array& arr, size_t start, size_t end, const Value& val, Less less) +{ + intptr_t first = (intptr_t)start; + intptr_t len = (intptr_t)(end - start); + intptr_t half; + intptr_t middle; + + while(len > 0) + { + half = len >> 1; + middle = first + half; + if(less(val, arr[middle])) + { + len = half; + } + else + { + first = middle + 1; + len = len - half - 1; + } + } + return (size_t)first; +} + + +//----------------------------------------------------------------------------------- +// ***** UpperBoundSliced +// +template +size_t UpperBoundSliced(const Array& arr, size_t start, size_t end, const Value& val) +{ + return UpperBoundSliced(arr, start, end, val, OperatorLess::Compare); +} + + +//----------------------------------------------------------------------------------- +// ***** UpperBoundSized +// +template +size_t UpperBoundSized(const Array& arr, size_t size, const Value& val) +{ + return UpperBoundSliced(arr, 0, size, val, OperatorLess::Compare); +} + + +//----------------------------------------------------------------------------------- +// ***** UpperBound +// +template +size_t UpperBound(const Array& arr, const Value& val, Less less) +{ + return UpperBoundSliced(arr, 0, arr.GetSize(), val, less); +} + + +//----------------------------------------------------------------------------------- +// ***** UpperBound +// +template +size_t UpperBound(const Array& arr, const Value& val) +{ + return UpperBoundSliced(arr, 0, arr.GetSize(), val, OperatorLess::Compare); +} + + +//----------------------------------------------------------------------------------- +// ***** ReverseArray +// +template void ReverseArray(Array& arr) +{ + intptr_t from = 0; + intptr_t to = arr.GetSize() - 1; + while(from < to) + { + Swap(arr[from], arr[to]); + ++from; + --to; + } +} + + +// ***** AppendArray +// +template +void AppendArray(CDst& dst, const CSrc& src) +{ + size_t i; + for(i = 0; i < src.GetSize(); i++) + dst.PushBack(src[i]); +} + +//----------------------------------------------------------------------------------- +// ***** ArrayAdaptor +// +// A simple adapter that provides the GetSize() method and overloads +// operator []. Used to wrap plain arrays in QuickSort and such. +template class ArrayAdaptor +{ +public: + typedef T ValueType; + ArrayAdaptor() : Data(0), Size(0) {} + ArrayAdaptor(T* ptr, size_t size) : Data(ptr), Size(size) {} + size_t GetSize() const { return Size; } + int GetSizeI() const { return (int)GetSize(); } + const T& operator [] (size_t i) const { return Data[i]; } + T& operator [] (size_t i) { return Data[i]; } +private: + T* Data; + size_t Size; +}; + + +//----------------------------------------------------------------------------------- +// ***** GConstArrayAdaptor +// +// A simple const adapter that provides the GetSize() method and overloads +// operator []. Used to wrap plain arrays in LowerBound and such. +template class ConstArrayAdaptor +{ +public: + typedef T ValueType; + ConstArrayAdaptor() : Data(0), Size(0) {} + ConstArrayAdaptor(const T* ptr, size_t size) : Data(ptr), Size(size) {} + size_t GetSize() const { return Size; } + int GetSizeI() const { return (int)GetSize(); } + const T& operator [] (size_t i) const { return Data[i]; } +private: + const T* Data; + size_t Size; +}; + + + +//----------------------------------------------------------------------------------- +extern const uint8_t UpperBitTable[256]; +extern const uint8_t LowerBitTable[256]; + + + +//----------------------------------------------------------------------------------- +inline uint8_t UpperBit(size_t val) +{ +#ifndef OVR_64BIT_POINTERS + + if (val & 0xFFFF0000) + { + return (val & 0xFF000000) ? + UpperBitTable[(val >> 24) ] + 24: + UpperBitTable[(val >> 16) & 0xFF] + 16; + } + return (val & 0xFF00) ? + UpperBitTable[(val >> 8) & 0xFF] + 8: + UpperBitTable[(val ) & 0xFF]; + +#else + + if (val & 0xFFFFFFFF00000000) + { + if (val & 0xFFFF000000000000) + { + return (val & 0xFF00000000000000) ? + UpperBitTable[(val >> 56) ] + 56: + UpperBitTable[(val >> 48) & 0xFF] + 48; + } + return (val & 0xFF0000000000) ? + UpperBitTable[(val >> 40) & 0xFF] + 40: + UpperBitTable[(val >> 32) & 0xFF] + 32; + } + else + { + if (val & 0xFFFF0000) + { + return (val & 0xFF000000) ? + UpperBitTable[(val >> 24) ] + 24: + UpperBitTable[(val >> 16) & 0xFF] + 16; + } + return (val & 0xFF00) ? + UpperBitTable[(val >> 8) & 0xFF] + 8: + UpperBitTable[(val ) & 0xFF]; + } + +#endif +} + +//----------------------------------------------------------------------------------- +inline uint8_t LowerBit(size_t val) +{ +#ifndef OVR_64BIT_POINTERS + + if (val & 0xFFFF) + { + return (val & 0xFF) ? + LowerBitTable[ val & 0xFF]: + LowerBitTable[(val >> 8) & 0xFF] + 8; + } + return (val & 0xFF0000) ? + LowerBitTable[(val >> 16) & 0xFF] + 16: + LowerBitTable[(val >> 24) & 0xFF] + 24; + +#else + + if (val & 0xFFFFFFFF) + { + if (val & 0xFFFF) + { + return (val & 0xFF) ? + LowerBitTable[ val & 0xFF]: + LowerBitTable[(val >> 8) & 0xFF] + 8; + } + return (val & 0xFF0000) ? + LowerBitTable[(val >> 16) & 0xFF] + 16: + LowerBitTable[(val >> 24) & 0xFF] + 24; + } + else + { + if (val & 0xFFFF00000000) + { + return (val & 0xFF00000000) ? + LowerBitTable[(val >> 32) & 0xFF] + 32: + LowerBitTable[(val >> 40) & 0xFF] + 40; + } + return (val & 0xFF000000000000) ? + LowerBitTable[(val >> 48) & 0xFF] + 48: + LowerBitTable[(val >> 56) & 0xFF] + 56; + } + +#endif +} + + + +// ******* Special (optimized) memory routines +// Note: null (bad) pointer is not tested +class MemUtil +{ +public: + + // Memory compare + static int Cmp (const void* p1, const void* p2, size_t byteCount) { return memcmp(p1, p2, byteCount); } + static int Cmp16(const void* p1, const void* p2, size_t int16Count); + static int Cmp32(const void* p1, const void* p2, size_t int32Count); + static int Cmp64(const void* p1, const void* p2, size_t int64Count); +}; + +// ** Inline Implementation + +inline int MemUtil::Cmp16(const void* p1, const void* p2, size_t int16Count) +{ + int16_t* pa = (int16_t*)p1; + int16_t* pb = (int16_t*)p2; + unsigned ic = 0; + if (int16Count == 0) + return 0; + while (pa[ic] == pb[ic]) + if (++ic==int16Count) + return 0; + return pa[ic] > pb[ic] ? 1 : -1; +} +inline int MemUtil::Cmp32(const void* p1, const void* p2, size_t int32Count) +{ + int32_t* pa = (int32_t*)p1; + int32_t* pb = (int32_t*)p2; + unsigned ic = 0; + if (int32Count == 0) + return 0; + while (pa[ic] == pb[ic]) + if (++ic==int32Count) + return 0; + return pa[ic] > pb[ic] ? 1 : -1; +} +inline int MemUtil::Cmp64(const void* p1, const void* p2, size_t int64Count) +{ + int64_t* pa = (int64_t*)p1; + int64_t* pb = (int64_t*)p2; + unsigned ic = 0; + if (int64Count == 0) + return 0; + while (pa[ic] == pb[ic]) + if (++ic==int64Count) + return 0; + return pa[ic] > pb[ic] ? 1 : -1; +} + +// ** End Inline Implementation + + +//----------------------------------------------------------------------------------- +// ******* Byte Order Conversions +namespace ByteUtil { + + // *** Swap Byte Order + + // Swap the byte order of a byte array + inline void SwapOrder(void* pv, int size) + { + uint8_t* pb = (uint8_t*)pv; + uint8_t temp; + for (int i = 0; i < size>>1; i++) + { + temp = pb[size-1-i]; + pb[size-1-i] = pb[i]; + pb[i] = temp; + } + } + + // Swap the byte order of primitive types + inline uint8_t SwapOrder(uint8_t v) { return v; } + inline int8_t SwapOrder(int8_t v) { return v; } + inline uint16_t SwapOrder(uint16_t v) { return uint16_t(v>>8)|uint16_t(v<<8); } + inline int16_t SwapOrder(int16_t v) { return int16_t((uint16_t(v)>>8)|(v<<8)); } + inline uint32_t SwapOrder(uint32_t v) { return (v>>24)|((v&0x00FF0000)>>8)|((v&0x0000FF00)<<8)|(v<<24); } + inline int32_t SwapOrder(int32_t p) { return (int32_t)SwapOrder(uint32_t(p)); } + inline uint64_t SwapOrder(uint64_t v) + { + return (v>>56) | + ((v&uint64_t(0x00FF000000000000ULL))>>40) | + ((v&uint64_t(0x0000FF0000000000ULL))>>24) | + ((v&uint64_t(0x000000FF00000000ULL))>>8) | + ((v&uint64_t(0x00000000FF000000ULL))<<8) | + ((v&uint64_t(0x0000000000FF0000ULL))<<24) | + ((v&uint64_t(0x000000000000FF00ULL))<<40) | + (v<<56); + } + inline int64_t SwapOrder(int64_t v) { return (int64_t)SwapOrder(uint64_t(v)); } + inline float SwapOrder(float p) + { + union { + float p; + uint32_t v; + } u; + u.p = p; + u.v = SwapOrder(u.v); + return u.p; + } + + inline double SwapOrder(double p) + { + union { + double p; + uint64_t v; + } u; + u.p = p; + u.v = SwapOrder(u.v); + return u.p; + } + + // *** Byte-order conversion + +#if (OVR_BYTE_ORDER == OVR_LITTLE_ENDIAN) + // Little Endian to System (LE) + inline uint8_t LEToSystem(uint8_t v) { return v; } + inline int8_t LEToSystem(int8_t v) { return v; } + inline uint16_t LEToSystem(uint16_t v) { return v; } + inline int16_t LEToSystem(int16_t v) { return v; } + inline uint32_t LEToSystem(uint32_t v) { return v; } + inline int32_t LEToSystem(int32_t v) { return v; } + inline uint64_t LEToSystem(uint64_t v) { return v; } + inline int64_t LEToSystem(int64_t v) { return v; } + inline float LEToSystem(float v) { return v; } + inline double LEToSystem(double v) { return v; } + + // Big Endian to System (LE) + inline uint8_t BEToSystem(uint8_t v) { return SwapOrder(v); } + inline int8_t BEToSystem(int8_t v) { return SwapOrder(v); } + inline uint16_t BEToSystem(uint16_t v) { return SwapOrder(v); } + inline int16_t BEToSystem(int16_t v) { return SwapOrder(v); } + inline uint32_t BEToSystem(uint32_t v) { return SwapOrder(v); } + inline int32_t BEToSystem(int32_t v) { return SwapOrder(v); } + inline uint64_t BEToSystem(uint64_t v) { return SwapOrder(v); } + inline int64_t BEToSystem(int64_t v) { return SwapOrder(v); } + inline float BEToSystem(float v) { return SwapOrder(v); } + inline double BEToSystem(double v) { return SwapOrder(v); } + + // System (LE) to Little Endian + inline uint8_t SystemToLE(uint8_t v) { return v; } + inline int8_t SystemToLE(int8_t v) { return v; } + inline uint16_t SystemToLE(uint16_t v) { return v; } + inline int16_t SystemToLE(int16_t v) { return v; } + inline uint32_t SystemToLE(uint32_t v) { return v; } + inline int32_t SystemToLE(int32_t v) { return v; } + inline uint64_t SystemToLE(uint64_t v) { return v; } + inline int64_t SystemToLE(int64_t v) { return v; } + inline float SystemToLE(float v) { return v; } + inline double SystemToLE(double v) { return v; } + + // System (LE) to Big Endian + inline uint8_t SystemToBE(uint8_t v) { return SwapOrder(v); } + inline int8_t SystemToBE(int8_t v) { return SwapOrder(v); } + inline uint16_t SystemToBE(uint16_t v) { return SwapOrder(v); } + inline int16_t SystemToBE(int16_t v) { return SwapOrder(v); } + inline uint32_t SystemToBE(uint32_t v) { return SwapOrder(v); } + inline int32_t SystemToBE(int32_t v) { return SwapOrder(v); } + inline uint64_t SystemToBE(uint64_t v) { return SwapOrder(v); } + inline int64_t SystemToBE(int64_t v) { return SwapOrder(v); } + inline float SystemToBE(float v) { return SwapOrder(v); } + inline double SystemToBE(double v) { return SwapOrder(v); } + +#elif (OVR_BYTE_ORDER == OVR_BIG_ENDIAN) + // Little Endian to System (BE) + inline uint8_t LEToSystem(uint8_t v) { return SwapOrder(v); } + inline int8_t LEToSystem(int8_t v) { return SwapOrder(v); } + inline uint16_t LEToSystem(uint16_t v) { return SwapOrder(v); } + inline int16_t LEToSystem(int16_t v) { return SwapOrder(v); } + inline uint32_t LEToSystem(uint32_t v) { return SwapOrder(v); } + inline int32_t LEToSystem(int32_t v) { return SwapOrder(v); } + inline uint64_t LEToSystem(uint64_t v) { return SwapOrder(v); } + inline int64_t LEToSystem(int64_t v) { return SwapOrder(v); } + inline float LEToSystem(float v) { return SwapOrder(v); } + inline double LEToSystem(double v) { return SwapOrder(v); } + + // Big Endian to System (BE) + inline uint8_t BEToSystem(uint8_t v) { return v; } + inline int8_t BEToSystem(int8_t v) { return v; } + inline uint16_t BEToSystem(uint16_t v) { return v; } + inline int16_t BEToSystem(int16_t v) { return v; } + inline uint32_t BEToSystem(uint32_t v) { return v; } + inline int32_t BEToSystem(int32_t v) { return v; } + inline uint64_t BEToSystem(uint64_t v) { return v; } + inline int64_t BEToSystem(int64_t v) { return v; } + inline float BEToSystem(float v) { return v; } + inline double BEToSystem(double v) { return v; } + + // System (BE) to Little Endian + inline uint8_t SystemToLE(uint8_t v) { return SwapOrder(v); } + inline int8_t SystemToLE(int8_t v) { return SwapOrder(v); } + inline uint16_t SystemToLE(uint16_t v) { return SwapOrder(v); } + inline int16_t SystemToLE(int16_t v) { return SwapOrder(v); } + inline uint32_t SystemToLE(uint32_t v) { return SwapOrder(v); } + inline int32_t SystemToLE(int32_t v) { return SwapOrder(v); } + inline uint64_t SystemToLE(uint64_t v) { return SwapOrder(v); } + inline int64_t SystemToLE(int64_t v) { return SwapOrder(v); } + inline float SystemToLE(float v) { return SwapOrder(v); } + inline double SystemToLE(double v) { return SwapOrder(v); } + + // System (BE) to Big Endian + inline uint8_t SystemToBE(uint8_t v) { return v; } + inline int8_t SystemToBE(int8_t v) { return v; } + inline uint16_t SystemToBE(uint16_t v) { return v; } + inline int16_t SystemToBE(int16_t v) { return v; } + inline uint32_t SystemToBE(uint32_t v) { return v; } + inline int32_t SystemToBE(int32_t v) { return v; } + inline uint64_t SystemToBE(uint64_t v) { return v; } + inline int64_t SystemToBE(int64_t v) { return v; } + inline float SystemToBE(float v) { return v; } + inline double SystemToBE(double v) { return v; } + +#else + #error "OVR_BYTE_ORDER must be defined to OVR_LITTLE_ENDIAN or OVR_BIG_ENDIAN" +#endif + +} // namespace ByteUtil + + + +// Used primarily for hardware interfacing such as sensor reports, firmware, etc. +// Reported data is all little-endian. +inline uint16_t DecodeUInt16(const uint8_t* buffer) +{ + return ByteUtil::LEToSystem ( *(const uint16_t*)buffer ); +} + +inline int16_t DecodeSInt16(const uint8_t* buffer) +{ + return ByteUtil::LEToSystem ( *(const int16_t*)buffer ); +} + +inline uint32_t DecodeUInt32(const uint8_t* buffer) +{ + return ByteUtil::LEToSystem ( *(const uint32_t*)buffer ); +} + +inline int32_t DecodeSInt32(const uint8_t* buffer) +{ + return ByteUtil::LEToSystem ( *(const int32_t*)buffer ); +} + +inline float DecodeFloat(const uint8_t* buffer) +{ + union { + uint32_t U; + float F; + }; + + U = DecodeUInt32(buffer); + return F; +} + +inline void EncodeUInt16(uint8_t* buffer, uint16_t val) +{ + *(uint16_t*)buffer = ByteUtil::SystemToLE ( val ); +} + +inline void EncodeSInt16(uint8_t* buffer, int16_t val) +{ + *(int16_t*)buffer = ByteUtil::SystemToLE ( val ); +} + +inline void EncodeUInt32(uint8_t* buffer, uint32_t val) +{ + *(uint32_t*)buffer = ByteUtil::SystemToLE ( val ); +} + +inline void EncodeSInt32(uint8_t* buffer, int32_t val) +{ + *(int32_t*)buffer = ByteUtil::SystemToLE ( val ); +} + +inline void EncodeFloat(uint8_t* buffer, float val) +{ + union { + uint32_t U; + float F; + }; + + F = val; + EncodeUInt32(buffer, U); +} + +// Converts an 8-bit binary-coded decimal +inline int8_t DecodeBCD(uint8_t byte) +{ + uint8_t digit1 = (byte >> 4) & 0x0f; + uint8_t digit2 = byte & 0x0f; + int decimal = digit1 * 10 + digit2; // maximum value = 99 + return (int8_t)decimal; +} + + +}} // OVR::Alg + +#endif diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Kernel/OVR_Allocator.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Kernel/OVR_Allocator.cpp Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,141 @@ +/************************************************************************************ + +Filename : OVR_Allocator.cpp +Content : Installable memory allocator implementation +Created : September 19, 2012 +Notes : + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#include "OVR_Allocator.h" +#ifdef OVR_OS_MAC + #include +#else + #include +#endif + +#if defined(OVR_OS_MS) + #include +#elif defined(OVR_OS_MAC) || defined(OVR_OS_UNIX) + #include + #include +#endif + + +namespace OVR { + +//----------------------------------------------------------------------------------- +// ***** Allocator + +Allocator* Allocator::pInstance = 0; + +// Default AlignedAlloc implementation will delegate to Alloc/Free after doing rounding. +void* Allocator::AllocAligned(size_t size, size_t align) +{ + OVR_ASSERT((align & (align-1)) == 0); + align = (align > sizeof(size_t)) ? align : sizeof(size_t); + size_t p = (size_t)Alloc(size+align); + size_t aligned = 0; + if (p) + { + aligned = (size_t(p) + align-1) & ~(align-1); + if (aligned == p) + aligned += align; + *(((size_t*)aligned)-1) = aligned-p; + } + return (void*)aligned; +} + +void Allocator::FreeAligned(void* p) +{ + size_t src = size_t(p) - *(((size_t*)p)-1); + Free((void*)src); +} + + +//------------------------------------------------------------------------ +// ***** Default Allocator + +// This allocator is created and used if no other allocator is installed. +// Default allocator delegates to system malloc. + +void* DefaultAllocator::Alloc(size_t size) +{ + return malloc(size); +} +void* DefaultAllocator::AllocDebug(size_t size, const char* file, unsigned line) +{ + OVR_UNUSED2(file, line); // should be here for debugopt config +#if defined(OVR_CC_MSVC) && defined(_CRTDBG_MAP_ALLOC) + return _malloc_dbg(size, _NORMAL_BLOCK, file, line); +#else + return malloc(size); +#endif +} + +void* DefaultAllocator::Realloc(void* p, size_t newSize) +{ + return realloc(p, newSize); +} +void DefaultAllocator::Free(void *p) +{ + return free(p); +} + + + + +void* MMapAlloc(size_t size) +{ + #if defined(OVR_OS_MS) + return VirtualAlloc(NULL, size, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); // size is rounded up to a page. // Returned memory is 0-filled. + + #elif defined(OVR_OS_MAC) || defined(OVR_OS_UNIX) + #if !defined(MAP_FAILED) + #define MAP_FAILED ((void*)-1) + #endif + + void* result = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0); // Returned memory is 0-filled. + if(result == MAP_FAILED) // mmap returns MAP_FAILED (-1) upon failure. + result = NULL; + return result; + #endif +} + + + + +void MMapFree(void* memory, size_t size) +{ + #if defined(OVR_OS_MS) + OVR_UNUSED(size); + VirtualFree(memory, 0, MEM_RELEASE); + + #elif defined(OVR_OS_MAC) || defined(OVR_OS_UNIX) + size_t pageSize = getpagesize(); + size = (((size + (pageSize - 1)) / pageSize) * pageSize); + munmap(memory, size); // Must supply the size to munmap. + #endif +} + + + + +} // OVR diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Kernel/OVR_Allocator.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Kernel/OVR_Allocator.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,360 @@ +/************************************************************************************ + +PublicHeader: OVR_Kernel.h +Filename : OVR_Allocator.h +Content : Installable memory allocator +Created : September 19, 2012 +Notes : + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#ifndef OVR_Allocator_h +#define OVR_Allocator_h + +#include "OVR_Types.h" + +//----------------------------------------------------------------------------------- + +// ***** Disable template-unfriendly MS VC++ warnings +#if defined(OVR_CC_MSVC) +// Pragma to prevent long name warnings in in VC++ +#pragma warning(disable : 4503) +#pragma warning(disable : 4786) +// In MSVC 7.1, warning about placement new POD default initializer +#pragma warning(disable : 4345) +#endif + +// Un-define new so that placement constructors work +#undef new + + +//----------------------------------------------------------------------------------- +// ***** Placement new overrides + +// Calls constructor on own memory created with "new(ptr) type" +#ifndef __PLACEMENT_NEW_INLINE +#define __PLACEMENT_NEW_INLINE + +# if defined(OVR_CC_MWERKS) || defined(OVR_CC_BORLAND) || defined(OVR_CC_GNU) +# include +# else + // Useful on MSVC + OVR_FORCE_INLINE void* operator new (size_t n, void *ptr) { OVR_UNUSED(n); return ptr; } + OVR_FORCE_INLINE void operator delete (void *, void *) { } +# endif + +#endif // __PLACEMENT_NEW_INLINE + + + +//------------------------------------------------------------------------ +// ***** Macros to redefine class new/delete operators + +// Types specifically declared to allow disambiguation of address in +// class member operator new. + +#define OVR_MEMORY_REDEFINE_NEW_IMPL(class_name, check_delete) \ + void* operator new(size_t sz) \ + { void *p = OVR_ALLOC_DEBUG(sz, __FILE__, __LINE__); return p; } \ + void* operator new(size_t sz, const char* file, int line) \ + { void* p = OVR_ALLOC_DEBUG(sz, file, line); OVR_UNUSED2(file, line); return p; } \ + void operator delete(void *p) \ + { check_delete(class_name, p); OVR_FREE(p); } \ + void operator delete(void *p, const char*, int) \ + { check_delete(class_name, p); OVR_FREE(p); } + +#define OVR_MEMORY_DEFINE_PLACEMENT_NEW \ + void* operator new (size_t n, void *ptr) { OVR_UNUSED(n); return ptr; } \ + void operator delete (void *ptr, void *ptr2) { OVR_UNUSED2(ptr,ptr2); } + + +#define OVR_MEMORY_CHECK_DELETE_NONE(class_name, p) + +// Redefined all delete/new operators in a class without custom memory initialization +#define OVR_MEMORY_REDEFINE_NEW(class_name) \ + OVR_MEMORY_REDEFINE_NEW_IMPL(class_name, OVR_MEMORY_CHECK_DELETE_NONE) + + +namespace OVR { + +//----------------------------------------------------------------------------------- +// ***** Construct / Destruct + +// Construct/Destruct functions are useful when new is redefined, as they can +// be called instead of placement new constructors. + + +template +OVR_FORCE_INLINE T* Construct(void *p) +{ + return ::new(p) T(); +} + +template +OVR_FORCE_INLINE T* Construct(void *p, const T& source) +{ + return ::new(p) T(source); +} + +// Same as above, but allows for a different type of constructor. +template +OVR_FORCE_INLINE T* ConstructAlt(void *p, const S& source) +{ + return ::new(p) T(source); +} + +template +OVR_FORCE_INLINE T* ConstructAlt(void *p, const S1& src1, const S2& src2) +{ + return ::new(p) T(src1, src2); +} + +template +OVR_FORCE_INLINE void ConstructArray(void *p, size_t count) +{ + uint8_t *pdata = (uint8_t*)p; + for (size_t i=0; i< count; ++i, pdata += sizeof(T)) + { + Construct(pdata); + } +} + +template +OVR_FORCE_INLINE void ConstructArray(void *p, size_t count, const T& source) +{ + uint8_t *pdata = (uint8_t*)p; + for (size_t i=0; i< count; ++i, pdata += sizeof(T)) + { + Construct(pdata, source); + } +} + +template +OVR_FORCE_INLINE void Destruct(T *pobj) +{ + pobj->~T(); + OVR_UNUSED1(pobj); // Fix incorrect 'unused variable' MSVC warning. +} + +template +OVR_FORCE_INLINE void DestructArray(T *pobj, size_t count) +{ + for (size_t i=0; i~T(); +} + + +//----------------------------------------------------------------------------------- +// ***** Allocator + +// Allocator defines a memory allocation interface that developers can override +// to to provide memory for OVR; an instance of this class is typically created on +// application startup and passed into System or OVR::System constructor. +// +// +// Users implementing this interface must provide three functions: Alloc, Free, +// and Realloc. Implementations of these functions must honor the requested alignment. +// Although arbitrary alignment requests are possible, requested alignment will +// typically be small, such as 16 bytes or less. + +class Allocator +{ + friend class System; +public: + virtual ~Allocator(){} + + // *** Standard Alignment Alloc/Free + + // Allocate memory of specified size with default alignment. + // Alloc of size==0 will allocate a tiny block & return a valid pointer; + // this makes it suitable for new operator. + virtual void* Alloc(size_t size) = 0; + // Same as Alloc, but provides an option of passing debug data. + virtual void* AllocDebug(size_t size, const char* file, unsigned line) + { OVR_UNUSED2(file, line); return Alloc(size); } + + // Reallocate memory block to a new size, copying data if necessary. Returns the pointer to + // new memory block, which may be the same as original pointer. Will return 0 if reallocation + // failed, in which case previous memory is still valid. + // Realloc to decrease size will never fail. + // Realloc of pointer == 0 is equivalent to Alloc + // Realloc to size == 0, shrinks to the minimal size, pointer remains valid and requires Free(). + virtual void* Realloc(void* p, size_t newSize) = 0; + + // Frees memory allocated by Alloc/Realloc. + // Free of null pointer is valid and will do nothing. + virtual void Free(void *p) = 0; + + + // *** Standard Alignment Alloc/Free + + // Allocate memory of specified alignment. + // Memory allocated with AllocAligned MUST be freed with FreeAligned. + // Default implementation will delegate to Alloc/Free after doing rounding. + virtual void* AllocAligned(size_t size, size_t align); + // Frees memory allocated with AllocAligned. + virtual void FreeAligned(void* p); + + // Returns the pointer to the current globally installed Allocator instance. + // This pointer is used for most of the memory allocations. + static Allocator* GetInstance() { return pInstance; } + + +protected: + // onSystemShutdown is called on the allocator during System::Shutdown. + // At this point, all allocations should've been freed. + virtual void onSystemShutdown() { } + +public: + static void setInstance(Allocator* palloc) + { + OVR_ASSERT((pInstance == 0) || (palloc == 0)); + pInstance = palloc; + } + +private: + + static Allocator* pInstance; +}; + + + +//------------------------------------------------------------------------ +// ***** Allocator_SingletonSupport + +// Allocator_SingletonSupport is a Allocator wrapper class that implements +// the InitSystemSingleton static function, used to create a global singleton +// used for the OVR::System default argument initialization. +// +// End users implementing custom Allocator interface don't need to make use of this base +// class; they can just create an instance of their own class on stack and pass it to System. + +template +class Allocator_SingletonSupport : public Allocator +{ + struct AllocContainer + { + size_t Data[(sizeof(D) + sizeof(size_t)-1) / sizeof(size_t)]; + bool Initialized; + AllocContainer() : Initialized(0) { } + }; + + AllocContainer* pContainer; + +public: + Allocator_SingletonSupport() : pContainer(0) { } + + // Creates a singleton instance of this Allocator class used + // on OVR_DEFAULT_ALLOCATOR during System initialization. + static D* InitSystemSingleton() + { + static AllocContainer Container; + OVR_ASSERT(Container.Initialized == false); + + Allocator_SingletonSupport *presult = Construct((void*)Container.Data); + presult->pContainer = &Container; + Container.Initialized = true; + return (D*)presult; + } + +protected: + virtual void onSystemShutdown() + { + Allocator::onSystemShutdown(); + if (pContainer) + { + pContainer->Initialized = false; + Destruct((D*)this); + pContainer = 0; + } + } +}; + +//------------------------------------------------------------------------ +// ***** Default Allocator + +// This allocator is created and used if no other allocator is installed. +// Default allocator delegates to system malloc. + +class DefaultAllocator : public Allocator_SingletonSupport +{ +public: + virtual void* Alloc(size_t size); + virtual void* AllocDebug(size_t size, const char* file, unsigned line); + virtual void* Realloc(void* p, size_t newSize); + virtual void Free(void *p); +}; + + +//------------------------------------------------------------------------ +// ***** Memory Allocation Macros + +// These macros should be used for global allocation. In the future, these +// macros will allows allocation to be extended with debug file/line information +// if necessary. + +#define OVR_REALLOC(p,s) OVR::Allocator::GetInstance()->Realloc((p),(s)) +#define OVR_FREE(p) OVR::Allocator::GetInstance()->Free((p)) +#define OVR_ALLOC_ALIGNED(s,a) OVR::Allocator::GetInstance()->AllocAligned((s),(a)) +#define OVR_FREE_ALIGNED(p) OVR::Allocator::GetInstance()->FreeAligned((p)) + +#ifdef OVR_BUILD_DEBUG +#define OVR_ALLOC(s) OVR::Allocator::GetInstance()->AllocDebug((s), __FILE__, __LINE__) +#define OVR_ALLOC_DEBUG(s,f,l) OVR::Allocator::GetInstance()->AllocDebug((s), f, l) +#else +#define OVR_ALLOC(s) OVR::Allocator::GetInstance()->Alloc((s)) +#define OVR_ALLOC_DEBUG(s,f,l) OVR::Allocator::GetInstance()->Alloc((s)) +#endif + +//------------------------------------------------------------------------ + +// Base class that overrides the new and delete operators. +// Deriving from this class, even as a multiple base, incurs no space overhead. +class NewOverrideBase +{ +public: + + // Redefine all new & delete operators. + OVR_MEMORY_REDEFINE_NEW(NewOverrideBase) +}; + + +//------------------------------------------------------------------------ +// ***** Mapped memory allocation +// +// Equates to VirtualAlloc/VirtualFree on Windows, mmap/munmap on Unix. +// These are useful for when you need system-supplied memory pages. +// These are also useful for when you need to allocate memory in a way +// that doesn't affect the application heap. + +void* MMapAlloc(size_t size); +void MMapFree(void* memory, size_t size); + + +} // OVR + + +// Redefine operator 'new' if necessary. +#if defined(OVR_DEFINE_NEW) +#define new OVR_DEFINE_NEW +#endif + + +#endif // OVR_Memory diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Kernel/OVR_Array.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Kernel/OVR_Array.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,837 @@ +/************************************************************************************ + +PublicHeader: OVR_Kernel.h +Filename : OVR_Array.h +Content : Template implementation for Array +Created : September 19, 2012 +Notes : + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#ifndef OVR_Array_h +#define OVR_Array_h + +#include "OVR_ContainerAllocator.h" + +namespace OVR { + +//----------------------------------------------------------------------------------- +// ***** ArrayDefaultPolicy +// +// Default resize behavior. No minimal capacity, Granularity=4, +// Shrinking as needed. ArrayConstPolicy actually is the same as +// ArrayDefaultPolicy, but parametrized with constants. +// This struct is used only in order to reduce the template "matroska". +struct ArrayDefaultPolicy +{ + ArrayDefaultPolicy() : Capacity(0) {} + ArrayDefaultPolicy(const ArrayDefaultPolicy&) : Capacity(0) {} + + size_t GetMinCapacity() const { return 0; } + size_t GetGranularity() const { return 4; } + bool NeverShrinking() const { return 0; } + + size_t GetCapacity() const { return Capacity; } + void SetCapacity(size_t capacity) { Capacity = capacity; } +private: + size_t Capacity; +}; + + +//----------------------------------------------------------------------------------- +// ***** ArrayConstPolicy +// +// Statically parametrized resizing behavior: +// MinCapacity, Granularity, and Shrinking flag. +template +struct ArrayConstPolicy +{ + typedef ArrayConstPolicy SelfType; + + ArrayConstPolicy() : Capacity(0) {} + ArrayConstPolicy(const SelfType&) : Capacity(0) {} + + size_t GetMinCapacity() const { return MinCapacity; } + size_t GetGranularity() const { return Granularity; } + bool NeverShrinking() const { return NeverShrink; } + + size_t GetCapacity() const { return Capacity; } + void SetCapacity(size_t capacity) { Capacity = capacity; } +private: + size_t Capacity; +}; + +//----------------------------------------------------------------------------------- +// ***** ArrayDataBase +// +// Basic operations with array data: Reserve, Resize, Free, ArrayPolicy. +// For internal use only: ArrayData,ArrayDataCC and others. +template +struct ArrayDataBase +{ + typedef T ValueType; + typedef Allocator AllocatorType; + typedef SizePolicy SizePolicyType; + typedef ArrayDataBase SelfType; + + ArrayDataBase() + : Data(0), Size(0), Policy() {} + + ArrayDataBase(const SizePolicy& p) + : Data(0), Size(0), Policy(p) {} + + ~ArrayDataBase() + { + Allocator::DestructArray(Data, Size); + Allocator::Free(Data); + } + + size_t GetCapacity() const + { + return Policy.GetCapacity(); + } + + void ClearAndRelease() + { + Allocator::DestructArray(Data, Size); + Allocator::Free(Data); + Data = 0; + Size = 0; + Policy.SetCapacity(0); + } + + void Reserve(size_t newCapacity) + { + if (Policy.NeverShrinking() && newCapacity < GetCapacity()) + return; + + if (newCapacity < Policy.GetMinCapacity()) + newCapacity = Policy.GetMinCapacity(); + + // Resize the buffer. + if (newCapacity == 0) + { + if (Data) + { + Allocator::Free(Data); + Data = 0; + } + Policy.SetCapacity(0); + } + else + { + size_t gran = Policy.GetGranularity(); + newCapacity = (newCapacity + gran - 1) / gran * gran; + if (Data) + { + if (Allocator::IsMovable()) + { + Data = (T*)Allocator::Realloc(Data, sizeof(T) * newCapacity); + } + else + { + T* newData = (T*)Allocator::Alloc(sizeof(T) * newCapacity); + size_t i, s; + s = (Size < newCapacity) ? Size : newCapacity; + for (i = 0; i < s; ++i) + { + Allocator::Construct(&newData[i], Data[i]); + Allocator::Destruct(&Data[i]); + } + for (i = s; i < Size; ++i) + { + Allocator::Destruct(&Data[i]); + } + Allocator::Free(Data); + Data = newData; + } + } + else + { + Data = (T*)Allocator::Alloc(sizeof(T) * newCapacity); + //memset(Buffer, 0, (sizeof(ValueType) * newSize)); // Do we need this? + } + Policy.SetCapacity(newCapacity); + // OVR_ASSERT(Data); // need to throw (or something) on alloc failure! + } + } + + // This version of Resize DOES NOT construct the elements. + // It's done to optimize PushBack, which uses a copy constructor + // instead of the default constructor and assignment + void ResizeNoConstruct(size_t newSize) + { + size_t oldSize = Size; + + if (newSize < oldSize) + { + Allocator::DestructArray(Data + newSize, oldSize - newSize); + if (newSize < (Policy.GetCapacity() >> 1)) + { + Reserve(newSize); + } + } + else if(newSize >= Policy.GetCapacity()) + { + Reserve(newSize + (newSize >> 2)); + } + //! IMPORTANT to modify Size only after Reserve completes, because garbage collectable + // array may use this array and may traverse it during Reserve (in the case, if + // collection occurs because of heap limit exceeded). + Size = newSize; + } + + ValueType* Data; + size_t Size; + SizePolicy Policy; +}; + + + +//----------------------------------------------------------------------------------- +// ***** ArrayData +// +// General purpose array data. +// For internal use only in Array, ArrayLH, ArrayPOD and so on. +template +struct ArrayData : ArrayDataBase +{ + typedef T ValueType; + typedef Allocator AllocatorType; + typedef SizePolicy SizePolicyType; + typedef ArrayDataBase BaseType; + typedef ArrayData SelfType; + + ArrayData() + : BaseType() { } + + ArrayData(size_t size) + : BaseType() { Resize(size); } + + ArrayData(const SelfType& a) + : BaseType(a.Policy) { Append(a.Data, a.Size); } + + + void Resize(size_t newSize) + { + size_t oldSize = this->Size; + BaseType::ResizeNoConstruct(newSize); + if(newSize > oldSize) + Allocator::ConstructArray(this->Data + oldSize, newSize - oldSize); + } + + void PushBack(const ValueType& val) + { + BaseType::ResizeNoConstruct(this->Size + 1); + OVR_ASSERT(this->Data != NULL); + Allocator::Construct(this->Data + this->Size - 1, val); + } + + template + void PushBackAlt(const S& val) + { + BaseType::ResizeNoConstruct(this->Size + 1); + Allocator::ConstructAlt(this->Data + this->Size - 1, val); + } + + // Append the given data to the array. + void Append(const ValueType other[], size_t count) + { + if (count) + { + size_t oldSize = this->Size; + BaseType::ResizeNoConstruct(this->Size + count); + Allocator::ConstructArray(this->Data + oldSize, count, other); + } + } +}; + + + +//----------------------------------------------------------------------------------- +// ***** ArrayDataCC +// +// A modification of ArrayData that always copy-constructs new elements +// using a specified DefaultValue. For internal use only in ArrayCC. +template +struct ArrayDataCC : ArrayDataBase +{ + typedef T ValueType; + typedef Allocator AllocatorType; + typedef SizePolicy SizePolicyType; + typedef ArrayDataBase BaseType; + typedef ArrayDataCC SelfType; + + ArrayDataCC(const ValueType& defval) + : BaseType(), DefaultValue(defval) { } + + ArrayDataCC(const ValueType& defval, size_t size) + : BaseType(), DefaultValue(defval) { Resize(size); } + + ArrayDataCC(const SelfType& a) + : BaseType(a.Policy), DefaultValue(a.DefaultValue) { Append(a.Data, a.Size); } + + + void Resize(size_t newSize) + { + size_t oldSize = this->Size; + BaseType::ResizeNoConstruct(newSize); + if(newSize > oldSize) + Allocator::ConstructArray(this->Data + oldSize, newSize - oldSize, DefaultValue); + } + + void PushBack(const ValueType& val) + { + BaseType::ResizeNoConstruct(this->Size + 1); + Allocator::Construct(this->Data + this->Size - 1, val); + } + + template + void PushBackAlt(const S& val) + { + BaseType::ResizeNoConstruct(this->Size + 1); + Allocator::ConstructAlt(this->Data + this->Size - 1, val); + } + + // Append the given data to the array. + void Append(const ValueType other[], size_t count) + { + if (count) + { + size_t oldSize = this->Size; + BaseType::ResizeNoConstruct(this->Size + count); + Allocator::ConstructArray(this->Data + oldSize, count, other); + } + } + + ValueType DefaultValue; +}; + + + + + +//----------------------------------------------------------------------------------- +// ***** ArrayBase +// +// Resizable array. The behavior can be POD (suffix _POD) and +// Movable (no suffix) depending on the allocator policy. +// In case of _POD the constructors and destructors are not called. +// +// Arrays can't handle non-movable objects! Don't put anything in here +// that can't be moved around by bitwise copy. +// +// The addresses of elements are not persistent! Don't keep the address +// of an element; the array contents will move around as it gets resized. +template +class ArrayBase +{ +public: + typedef typename ArrayData::ValueType ValueType; + typedef typename ArrayData::AllocatorType AllocatorType; + typedef typename ArrayData::SizePolicyType SizePolicyType; + typedef ArrayBase SelfType; + + +#undef new + OVR_MEMORY_REDEFINE_NEW(ArrayBase) +// Redefine operator 'new' if necessary. +#if defined(OVR_DEFINE_NEW) +#define new OVR_DEFINE_NEW +#endif + + + ArrayBase() + : Data() {} + ArrayBase(size_t size) + : Data(size) {} + ArrayBase(const SelfType& a) + : Data(a.Data) {} + + ArrayBase(const ValueType& defval) + : Data(defval) {} + ArrayBase(const ValueType& defval, size_t size) + : Data(defval, size) {} + + SizePolicyType* GetSizePolicy() const { return Data.Policy; } + void SetSizePolicy(const SizePolicyType& p) { Data.Policy = p; } + + bool NeverShrinking()const { return Data.Policy.NeverShrinking(); } + size_t GetSize() const { return Data.Size; } + int GetSizeI() const { return (int)Data.Size; } + bool IsEmpty() const { return Data.Size == 0; } + size_t GetCapacity() const { return Data.GetCapacity(); } + size_t GetNumBytes() const { return Data.GetCapacity() * sizeof(ValueType); } + + void ClearAndRelease() { Data.ClearAndRelease(); } + void Clear() { Data.Resize(0); } + void Resize(size_t newSize) { Data.Resize(newSize); } + + // Reserve can only increase the capacity + void Reserve(size_t newCapacity) + { + if (newCapacity > Data.GetCapacity()) + Data.Reserve(newCapacity); + } + + // Basic access. + ValueType& At(size_t index) + { + OVR_ASSERT((Data.Data) && (index < Data.Size)); // Asserting that Data.Data is valid helps static analysis tools. + return Data.Data[index]; + } + const ValueType& At(size_t index) const + { + OVR_ASSERT((Data.Data) && (index < Data.Size)); + return Data.Data[index]; + } + + ValueType ValueAt(size_t index) const + { + OVR_ASSERT((Data.Data) && (index < Data.Size)); + return Data.Data[index]; + } + + // Basic access. + ValueType& operator [] (size_t index) + { + OVR_ASSERT((Data.Data) && (index < Data.Size)); + return Data.Data[index]; + } + const ValueType& operator [] (size_t index) const + { + OVR_ASSERT((Data.Data) && (index < Data.Size)); + return Data.Data[index]; + } + + // Raw pointer to the data. Use with caution! + const ValueType* GetDataPtr() const { return Data.Data; } + ValueType* GetDataPtr() { return Data.Data; } + + // Insert the given element at the end of the array. + void PushBack(const ValueType& val) + { + // DO NOT pass elements of your own vector into + // push_back()! Since we're using references, + // resize() may munge the element storage! + // OVR_ASSERT(&val < &Buffer[0] || &val > &Buffer[BufferSize]); + Data.PushBack(val); + } + + template + void PushBackAlt(const S& val) + { + Data.PushBackAlt(val); + } + + // Remove the last element. + void PopBack(size_t count = 1) + { + OVR_ASSERT(Data.Size >= count); + Data.Resize(Data.Size - count); + } + + ValueType& PushDefault() + { + Data.PushBack(ValueType()); + return Back(); + } + + ValueType Pop() + { + OVR_ASSERT((Data.Data) && (Data.Size > 0)); + ValueType t = Back(); + PopBack(); + return t; + } + + + // Access the first element. + ValueType& Front() { return At(0); } + const ValueType& Front() const { return At(0); } + + // Access the last element. + ValueType& Back() { return At(Data.Size - 1); } + const ValueType& Back() const { return At(Data.Size - 1); } + + // Array copy. Copies the contents of a into this array. + const SelfType& operator = (const SelfType& a) + { + Resize(a.GetSize()); + OVR_ASSERT((Data.Data != NULL) || (Data.Size == 0)); + for (size_t i = 0; i < Data.Size; i++) { + *(Data.Data + i) = a[i]; + } + return *this; + } + + // Removing multiple elements from the array. + void RemoveMultipleAt(size_t index, size_t num) + { + OVR_ASSERT(index + num <= Data.Size); + if (Data.Size == num) + { + Clear(); + } + else + { + AllocatorType::DestructArray(Data.Data + index, num); + AllocatorType::CopyArrayForward( + Data.Data + index, + Data.Data + index + num, + Data.Size - num - index); + Data.Size -= num; + } + } + + // Removing an element from the array is an expensive operation! + // It compacts only after removing the last element. + // If order of elements in the array is not important then use + // RemoveAtUnordered, that could be much faster than the regular + // RemoveAt. + void RemoveAt(size_t index) + { + OVR_ASSERT((Data.Data) && (index < Data.Size)); + if (Data.Size == 1) + { + Clear(); + } + else + { + AllocatorType::Destruct(Data.Data + index); + AllocatorType::CopyArrayForward( + Data.Data + index, + Data.Data + index + 1, + Data.Size - 1 - index); + --Data.Size; + } + } + + // Removes an element from the array without respecting of original order of + // elements for better performance. Do not use on array where order of elements + // is important, otherwise use it instead of regular RemoveAt(). + void RemoveAtUnordered(size_t index) + { + OVR_ASSERT((Data.Data) && (index < Data.Size)); + if (Data.Size == 1) + { + Clear(); + } + else + { + // copy the last element into the 'index' position + // and decrement the size (instead of moving all elements + // in [index + 1 .. size - 1] range). + const size_t lastElemIndex = Data.Size - 1; + if (index < lastElemIndex) + { + AllocatorType::Destruct(Data.Data + index); + AllocatorType::Construct(Data.Data + index, Data.Data[lastElemIndex]); + } + AllocatorType::Destruct(Data.Data + lastElemIndex); + --Data.Size; + } + } + + // Insert the given object at the given index shifting all the elements up. + void InsertAt(size_t index, const ValueType& val = ValueType()) + { + OVR_ASSERT(index <= Data.Size); + + Data.Resize(Data.Size + 1); + if (index < Data.Size - 1) + { + AllocatorType::CopyArrayBackward( + Data.Data + index + 1, + Data.Data + index, + Data.Size - 1 - index); + } + AllocatorType::Construct(Data.Data + index, val); + } + + // Insert the given object at the given index shifting all the elements up. + void InsertMultipleAt(size_t index, size_t num, const ValueType& val = ValueType()) + { + OVR_ASSERT(index <= Data.Size); + + Data.Resize(Data.Size + num); + if (index < Data.Size - num) + { + AllocatorType::CopyArrayBackward( + Data.Data + index + num, + Data.Data + index, + Data.Size - num - index); + } + for (size_t i = 0; i < num; ++i) + AllocatorType::Construct(Data.Data + index + i, val); + } + + // Append the given data to the array. + void Append(const SelfType& other) + { + Append(other.Data.Data, other.GetSize()); + } + + // Append the given data to the array. + void Append(const ValueType other[], size_t count) + { + Data.Append(other, count); + } + + class Iterator + { + SelfType* pArray; + intptr_t CurIndex; + + public: + Iterator() : pArray(0), CurIndex(-1) {} + Iterator(SelfType* parr, intptr_t idx = 0) : pArray(parr), CurIndex(idx) {} + + bool operator==(const Iterator& it) const { return pArray == it.pArray && CurIndex == it.CurIndex; } + bool operator!=(const Iterator& it) const { return pArray != it.pArray || CurIndex != it.CurIndex; } + + Iterator& operator++() + { + if (pArray) + { + if (CurIndex < (intptr_t)pArray->GetSize()) + ++CurIndex; + } + return *this; + } + Iterator operator++(int) + { + Iterator it(*this); + operator++(); + return it; + } + Iterator& operator--() + { + if (pArray) + { + if (CurIndex >= 0) + --CurIndex; + } + return *this; + } + Iterator operator--(int) + { + Iterator it(*this); + operator--(); + return it; + } + Iterator operator+(int delta) const + { + return Iterator(pArray, CurIndex + delta); + } + Iterator operator-(int delta) const + { + return Iterator(pArray, CurIndex - delta); + } + intptr_t operator-(const Iterator& right) const + { + OVR_ASSERT(pArray == right.pArray); + return CurIndex - right.CurIndex; + } + ValueType& operator*() const { OVR_ASSERT(pArray); return (*pArray)[CurIndex]; } + ValueType* operator->() const { OVR_ASSERT(pArray); return &(*pArray)[CurIndex]; } + ValueType* GetPtr() const { OVR_ASSERT(pArray); return &(*pArray)[CurIndex]; } + + bool IsFinished() const { return !pArray || CurIndex < 0 || CurIndex >= (int)pArray->GetSize(); } + + void Remove() + { + if (!IsFinished()) + pArray->RemoveAt(CurIndex); + } + + intptr_t GetIndex() const { return CurIndex; } + }; + + Iterator Begin() { return Iterator(this); } + Iterator End() { return Iterator(this, (intptr_t)GetSize()); } + Iterator Last() { return Iterator(this, (intptr_t)GetSize() - 1); } + + class ConstIterator + { + const SelfType* pArray; + intptr_t CurIndex; + + public: + ConstIterator() : pArray(0), CurIndex(-1) {} + ConstIterator(const SelfType* parr, intptr_t idx = 0) : pArray(parr), CurIndex(idx) {} + + bool operator==(const ConstIterator& it) const { return pArray == it.pArray && CurIndex == it.CurIndex; } + bool operator!=(const ConstIterator& it) const { return pArray != it.pArray || CurIndex != it.CurIndex; } + + ConstIterator& operator++() + { + if (pArray) + { + if (CurIndex < (int)pArray->GetSize()) + ++CurIndex; + } + return *this; + } + ConstIterator operator++(int) + { + ConstIterator it(*this); + operator++(); + return it; + } + ConstIterator& operator--() + { + if (pArray) + { + if (CurIndex >= 0) + --CurIndex; + } + return *this; + } + ConstIterator operator--(int) + { + ConstIterator it(*this); + operator--(); + return it; + } + ConstIterator operator+(int delta) const + { + return ConstIterator(pArray, CurIndex + delta); + } + ConstIterator operator-(int delta) const + { + return ConstIterator(pArray, CurIndex - delta); + } + intptr_t operator-(const ConstIterator& right) const + { + OVR_ASSERT(pArray == right.pArray); + return CurIndex - right.CurIndex; + } + const ValueType& operator*() const { OVR_ASSERT(pArray); return (*pArray)[CurIndex]; } + const ValueType* operator->() const { OVR_ASSERT(pArray); return &(*pArray)[CurIndex]; } + const ValueType* GetPtr() const { OVR_ASSERT(pArray); return &(*pArray)[CurIndex]; } + + bool IsFinished() const { return !pArray || CurIndex < 0 || CurIndex >= (int)pArray->GetSize(); } + + intptr_t GetIndex() const { return CurIndex; } + }; + ConstIterator Begin() const { return ConstIterator(this); } + ConstIterator End() const { return ConstIterator(this, (intptr_t)GetSize()); } + ConstIterator Last() const { return ConstIterator(this, (intptr_t)GetSize() - 1); } + +protected: + ArrayData Data; +}; + + + +//----------------------------------------------------------------------------------- +// ***** Array +// +// General purpose array for movable objects that require explicit +// construction/destruction. +template +class Array : public ArrayBase, SizePolicy> > +{ +public: + typedef T ValueType; + typedef ContainerAllocator AllocatorType; + typedef SizePolicy SizePolicyType; + typedef Array SelfType; + typedef ArrayBase, SizePolicy> > BaseType; + + Array() : BaseType() {} + Array(size_t size) : BaseType(size) {} + Array(const SizePolicyType& p) : BaseType() { SetSizePolicy(p); } + Array(const SelfType& a) : BaseType(a) {} + const SelfType& operator=(const SelfType& a) { BaseType::operator=(a); return *this; } +}; + +// ***** ArrayPOD +// +// General purpose array for movable objects that DOES NOT require +// construction/destruction. Constructors and destructors are not called! +// Global heap is in use. +template +class ArrayPOD : public ArrayBase, SizePolicy> > +{ +public: + typedef T ValueType; + typedef ContainerAllocator_POD AllocatorType; + typedef SizePolicy SizePolicyType; + typedef ArrayPOD SelfType; + typedef ArrayBase, SizePolicy> > BaseType; + + ArrayPOD() : BaseType() {} + ArrayPOD(size_t size) : BaseType(size) {} + ArrayPOD(const SizePolicyType& p) : BaseType() { SetSizePolicy(p); } + ArrayPOD(const SelfType& a) : BaseType(a) {} + const SelfType& operator=(const SelfType& a) { BaseType::operator=(a); return *this; } +}; + + +// ***** ArrayCPP +// +// General purpose, fully C++ compliant array. Can be used with non-movable data. +// Global heap is in use. +template +class ArrayCPP : public ArrayBase, SizePolicy> > +{ +public: + typedef T ValueType; + typedef ContainerAllocator_CPP AllocatorType; + typedef SizePolicy SizePolicyType; + typedef ArrayCPP SelfType; + typedef ArrayBase, SizePolicy> > BaseType; + + ArrayCPP() : BaseType() {} + ArrayCPP(size_t size) : BaseType(size) {} + ArrayCPP(const SizePolicyType& p) : BaseType() { SetSizePolicy(p); } + ArrayCPP(const SelfType& a) : BaseType(a) {} + const SelfType& operator=(const SelfType& a) { BaseType::operator=(a); return *this; } +}; + + +// ***** ArrayCC +// +// A modification of the array that uses the given default value to +// construct the elements. The constructors and destructors are +// properly called, the objects must be movable. + +template +class ArrayCC : public ArrayBase, SizePolicy> > +{ +public: + typedef T ValueType; + typedef ContainerAllocator AllocatorType; + typedef SizePolicy SizePolicyType; + typedef ArrayCC SelfType; + typedef ArrayBase, SizePolicy> > BaseType; + + ArrayCC(const ValueType& defval) : BaseType(defval) {} + ArrayCC(const ValueType& defval, size_t size) : BaseType(defval, size) {} + ArrayCC(const ValueType& defval, const SizePolicyType& p) : BaseType(defval) { SetSizePolicy(p); } + ArrayCC(const SelfType& a) : BaseType(a) {} + const SelfType& operator=(const SelfType& a) { BaseType::operator=(a); return *this; } +}; + +} // OVR + +#endif diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Kernel/OVR_Atomic.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Kernel/OVR_Atomic.cpp Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,139 @@ +/************************************************************************************ + +Filename : OVR_Atomic.cpp +Content : Contains atomic operations and inline fastest locking + functionality. Will contain #ifdefs for OS efficiency. + Have non-thread-safe implementation if not available. +Created : September 19, 2012 +Notes : + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#include "OVR_Atomic.h" +#include "OVR_Allocator.h" + +#ifdef OVR_ENABLE_THREADS + +// Include Windows 8-Metro compatible Synchronization API +#if defined(OVR_OS_MS) && defined(NTDDI_WIN8) && (NTDDI_VERSION >= NTDDI_WIN8) +#include +#endif + + +namespace OVR { + +// ***** Windows Lock implementation + +#if defined(OVR_OS_MS) + +// ***** Standard Win32 Lock implementation + +// Constructors +Lock::Lock(unsigned spinCount) +{ + #if defined(NTDDI_WIN8) && (NTDDI_VERSION >= NTDDI_WIN8) + // On Windows 8 we use InitializeCriticalSectionEx due to Metro-Compatibility + InitializeCriticalSectionEx(&cs, (DWORD)spinCount, + OVR_DEBUG_SELECT(NULL, CRITICAL_SECTION_NO_DEBUG_INFO)); + #else + ::InitializeCriticalSectionAndSpinCount(&cs, (DWORD)spinCount); // This is available with WindowsXP+. + #endif +} + + +Lock::~Lock() +{ + DeleteCriticalSection(&cs); +} + + +#endif + + +//------------------------------------------------------------------------------------- +// ***** SharedLock + +// This is a general purpose globally shared Lock implementation that should probably be +// moved to Kernel. +// May in theory busy spin-wait if we hit contention on first lock creation, +// but this shouldn't matter in practice since Lock* should be cached. + + +enum { LockInitMarker = 0xFFFFFFFF }; + +Lock* SharedLock::GetLockAddRef() +{ + int oldUseCount; + + do { + oldUseCount = UseCount; + if (oldUseCount == (int)LockInitMarker) + continue; + + if (oldUseCount == 0) + { + // Initialize marker + if (AtomicOps::CompareAndSet_Sync(&UseCount, 0, LockInitMarker)) + { + Construct(Buffer); + do { } + while (!AtomicOps::CompareAndSet_Sync(&UseCount, LockInitMarker, 1)); + return toLock(); + } + continue; + } + + } while (!AtomicOps::CompareAndSet_NoSync(&UseCount, oldUseCount, oldUseCount + 1)); + + return toLock(); +} + +void SharedLock::ReleaseLock(Lock* plock) +{ + OVR_UNUSED(plock); + OVR_ASSERT(plock == toLock()); + + int oldUseCount; + + do { + oldUseCount = UseCount; + OVR_ASSERT(oldUseCount != (int)LockInitMarker); + + if (oldUseCount == 1) + { + // Initialize marker + if (AtomicOps::CompareAndSet_Sync(&UseCount, 1, LockInitMarker)) + { + Destruct(toLock()); + + do { } + while (!AtomicOps::CompareAndSet_Sync(&UseCount, LockInitMarker, 0)); + + return; + } + continue; + } + + } while (!AtomicOps::CompareAndSet_NoSync(&UseCount, oldUseCount, oldUseCount - 1)); +} + +} // OVR + +#endif // OVR_ENABLE_THREADS diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Kernel/OVR_Atomic.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Kernel/OVR_Atomic.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,915 @@ +/************************************************************************************ + +PublicHeader: OVR_Kernel.h +Filename : OVR_Atomic.h +Content : Contains atomic operations and inline fastest locking + functionality. Will contain #ifdefs for OS efficiency. + Have non-thread-safe implementaion if not available. +Created : September 19, 2012 +Notes : + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#ifndef OVR_Atomic_h +#define OVR_Atomic_h + +#include "OVR_Types.h" + +// Include System thread functionality. +#if defined(OVR_OS_MS) && !defined(OVR_OS_MS_MOBILE) +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif +#include +#else +#include +#endif + +#ifdef OVR_CC_MSVC +#include +#pragma intrinsic(_ReadBarrier, _WriteBarrier, _ReadWriteBarrier) +#endif + +namespace OVR { + + +// ****** Declared classes + +// If there is NO thread support we implement AtomicOps and +// Lock objects as no-ops. The other classes are not defined. +template class AtomicOps; +template class AtomicInt; +template class AtomicPtr; + +class Lock; + + +//----------------------------------------------------------------------------------- +// ***** AtomicOps + +// Atomic operations are provided by the AtomicOps templates class, +// implemented through system-specific AtomicOpsRaw specializations. +// It provides several fundamental operations such as Exchange, ExchangeAdd +// CompareAndSet, and Store_Release. Each function includes several memory +// synchronization versions, important for multiprocessing CPUs with weak +// memory consistency. The following memory fencing strategies are supported: +// +// - NoSync. No memory synchronization is done for atomic op. +// - Release. All other memory writes are completed before atomic op +// writes its results. +// - Acquire. Further memory reads are forced to wait until atomic op +// executes, guaranteeing that the right values will be seen. +// - Sync. A combination of Release and Acquire. + + +// *** AtomicOpsRaw + +// AtomicOpsRaw is a specialized template that provides atomic operations +// used by AtomicOps. This class has two fundamental qualities: (1) it +// defines a type T of correct size, and (2) provides operations that work +// atomically, such as Exchange_Sync and CompareAndSet_Release. + +// AtomicOpsRawBase class contains shared constants/classes for AtomicOpsRaw. +// The primary thing is does is define sync class objects, whose destructor and +// constructor provide places to insert appropriate synchronization calls, on +// systems where such calls are necessary. So far, the breakdown is as follows: +// +// - X86 systems don't need custom syncs, since their exchange/atomic +// instructions are implicitly synchronized. +// - PowerPC requires lwsync/isync instructions that can use this mechanism. +// - If some other systems require a mechanism where syncing type is associated +// with a particular instruction, the default implementation (which implements +// all Sync, Acquire, and Release modes in terms of NoSync and fence) may not +// work. Ii that case it will need to be #ifdef-ed conditionally. + +struct AtomicOpsRawBase +{ +#if !defined(OVR_ENABLE_THREADS) || defined(OVR_CPU_X86) || defined(OVR_CPU_X86_64) + // Need to have empty constructor to avoid class 'unused' variable warning. + struct FullSync { inline FullSync() { } }; + struct AcquireSync { inline AcquireSync() { } }; + struct ReleaseSync { inline ReleaseSync() { } }; + +#elif defined(OVR_CPU_PPC64) || defined(OVR_CPU_PPC) + struct FullSync { inline FullSync() { asm volatile("sync\n"); } ~FullSync() { asm volatile("isync\n"); } }; + struct AcquireSync { inline AcquireSync() { } ~AcquireSync() { asm volatile("isync\n"); } }; + struct ReleaseSync { inline ReleaseSync() { asm volatile("sync\n"); } }; + +#elif defined(OVR_CPU_MIPS) + struct FullSync { inline FullSync() { asm volatile("sync\n"); } ~FullSync() { asm volatile("sync\n"); } }; + struct AcquireSync { inline AcquireSync() { } ~AcquireSync() { asm volatile("sync\n"); } }; + struct ReleaseSync { inline ReleaseSync() { asm volatile("sync\n"); } }; + +#elif defined(OVR_CPU_ARM) // Includes Android and iOS. + struct FullSync { inline FullSync() { asm volatile("dmb\n"); } ~FullSync() { asm volatile("dmb\n"); } }; + struct AcquireSync { inline AcquireSync() { } ~AcquireSync() { asm volatile("dmb\n"); } }; + struct ReleaseSync { inline ReleaseSync() { asm volatile("dmb\n"); } }; + +#elif defined(OVR_CC_GNU) && (__GNUC__ >= 4) + // __sync functions are already full sync + struct FullSync { inline FullSync() { } }; + struct AcquireSync { inline AcquireSync() { } }; + struct ReleaseSync { inline ReleaseSync() { } }; +#endif +}; + + +// 4-Byte raw data atomic op implementation class. +struct AtomicOpsRaw_4ByteImpl : public AtomicOpsRawBase +{ +#if !defined(OVR_ENABLE_THREADS) + + // Provide a type for no-thread-support cases. Used by AtomicOpsRaw_DefImpl. + typedef uint32_t T; + + // *** Thread - Safe Atomic Versions. + +#elif defined(OVR_OS_MS) + + // Use special defined for VC6, where volatile is not used and + // InterlockedCompareExchange is declared incorrectly. + typedef LONG T; +#if defined(OVR_CC_MSVC) && (OVR_CC_MSVC < 1300) + typedef T* InterlockTPtr; + typedef LPVOID ET; + typedef ET* InterlockETPtr; +#else + typedef volatile T* InterlockTPtr; + typedef T ET; + typedef InterlockTPtr InterlockETPtr; +#endif + inline static T Exchange_NoSync(volatile T* p, T val) { return InterlockedExchange((InterlockTPtr)p, val); } + inline static T ExchangeAdd_NoSync(volatile T* p, T val) { return InterlockedExchangeAdd((InterlockTPtr)p, val); } + inline static bool CompareAndSet_NoSync(volatile T* p, T c, T val) { return InterlockedCompareExchange((InterlockETPtr)p, (ET)val, (ET)c) == (ET)c; } + +#elif defined(OVR_CPU_PPC64) || defined(OVR_CPU_PPC) + typedef uint32_t T; + static inline uint32_t Exchange_NoSync(volatile uint32_t *i, uint32_t j) + { + uint32_t ret; + + asm volatile("1:\n\t" + "lwarx %[r],0,%[i]\n\t" + "stwcx. %[j],0,%[i]\n\t" + "bne- 1b\n" + : "+m" (*i), [r] "=&b" (ret) : [i] "b" (i), [j] "b" (j) : "cc", "memory"); + + return ret; + } + + static inline uint32_t ExchangeAdd_NoSync(volatile uint32_t *i, uint32_t j) + { + uint32_t dummy, ret; + + asm volatile("1:\n\t" + "lwarx %[r],0,%[i]\n\t" + "add %[o],%[r],%[j]\n\t" + "stwcx. %[o],0,%[i]\n\t" + "bne- 1b\n" + : "+m" (*i), [r] "=&b" (ret), [o] "=&r" (dummy) : [i] "b" (i), [j] "b" (j) : "cc", "memory"); + + return ret; + } + + static inline bool CompareAndSet_NoSync(volatile uint32_t *i, uint32_t c, uint32_t value) + { + uint32_t ret; + + asm volatile("1:\n\t" + "lwarx %[r],0,%[i]\n\t" + "cmpw 0,%[r],%[cmp]\n\t" + "mfcr %[r]\n\t" + "bne- 2f\n\t" + "stwcx. %[val],0,%[i]\n\t" + "bne- 1b\n\t" + "2:\n" + : "+m" (*i), [r] "=&b" (ret) : [i] "b" (i), [cmp] "b" (c), [val] "b" (value) : "cc", "memory"); + + return (ret & 0x20000000) ? 1 : 0; + } + +#elif defined(OVR_CPU_MIPS) + typedef uint32_t T; + + static inline uint32_t Exchange_NoSync(volatile uint32_t *i, uint32_t j) + { + uint32_t ret; + + asm volatile("1:\n\t" + "ll %[r],0(%[i])\n\t" + "sc %[j],0(%[i])\n\t" + "beq %[j],$0,1b\n\t" + "nop \n" + : "+m" (*i), [r] "=&d" (ret) : [i] "d" (i), [j] "d" (j) : "cc", "memory"); + + return ret; + } + + static inline uint32_t ExchangeAdd_NoSync(volatile uint32_t *i, uint32_t j) + { + uint32_t ret; + + asm volatile("1:\n\t" + "ll %[r],0(%[i])\n\t" + "addu %[j],%[r],%[j]\n\t" + "sc %[j],0(%[i])\n\t" + "beq %[j],$0,1b\n\t" + "nop \n" + : "+m" (*i), [r] "=&d" (ret) : [i] "d" (i), [j] "d" (j) : "cc", "memory"); + + return ret; + } + + static inline bool CompareAndSet_NoSync(volatile uint32_t *i, uint32_t c, uint32_t value) + { + uint32_t ret, dummy; + + asm volatile("1:\n\t" + "move %[r],$0\n\t" + "ll %[o],0(%[i])\n\t" + "bne %[o],%[c],2f\n\t" + "move %[r],%[v]\n\t" + "sc %[r],0(%[i])\n\t" + "beq %[r],$0,1b\n\t" + "nop \n\t" + "2:\n" + : "+m" (*i),[r] "=&d" (ret), [o] "=&d" (dummy) : [i] "d" (i), [c] "d" (c), [v] "d" (value) + : "cc", "memory"); + + return ret; + } + +#elif defined(OVR_CPU_ARM) && defined(OVR_CC_ARM) + typedef uint32_t T; + + static inline uint32_t Exchange_NoSync(volatile uint32_t *i, uint32_t j) + { + for(;;) + { + T r = __ldrex(i); + if (__strex(j, i) == 0) + return r; + } + } + static inline uint32_t ExchangeAdd_NoSync(volatile uint32_t *i, uint32_t j) + { + for(;;) + { + T r = __ldrex(i); + if (__strex(r + j, i) == 0) + return r; + } + } + + static inline bool CompareAndSet_NoSync(volatile uint32_t *i, uint32_t c, uint32_t value) + { + for(;;) + { + T r = __ldrex(i); + if (r != c) + return 0; + if (__strex(value, i) == 0) + return 1; + } + } + +#elif defined(OVR_CPU_ARM) + typedef uint32_t T; + + static inline uint32_t Exchange_NoSync(volatile uint32_t *i, uint32_t j) + { + uint32_t ret, dummy; + + asm volatile("1:\n\t" + "ldrex %[r],[%[i]]\n\t" + "strex %[t],%[j],[%[i]]\n\t" + "cmp %[t],#0\n\t" + "bne 1b\n\t" + : "+m" (*i), [r] "=&r" (ret), [t] "=&r" (dummy) : [i] "r" (i), [j] "r" (j) : "cc", "memory"); + + return ret; + } + + static inline uint32_t ExchangeAdd_NoSync(volatile uint32_t *i, uint32_t j) + { + uint32_t ret, dummy, test; + + asm volatile("1:\n\t" + "ldrex %[r],[%[i]]\n\t" + "add %[o],%[r],%[j]\n\t" + "strex %[t],%[o],[%[i]]\n\t" + "cmp %[t],#0\n\t" + "bne 1b\n\t" + : "+m" (*i), [r] "=&r" (ret), [o] "=&r" (dummy), [t] "=&r" (test) : [i] "r" (i), [j] "r" (j) : "cc", "memory"); + + return ret; + } + + static inline bool CompareAndSet_NoSync(volatile uint32_t *i, uint32_t c, uint32_t value) + { + uint32_t ret = 1, dummy, test; + + asm volatile("1:\n\t" + "ldrex %[o],[%[i]]\n\t" + "cmp %[o],%[c]\n\t" + "bne 2f\n\t" + "strex %[r],%[v],[%[i]]\n\t" + "cmp %[r],#0\n\t" + "bne 1b\n\t" + "2:\n" + : "+m" (*i),[r] "=&r" (ret), [o] "=&r" (dummy), [t] "=&r" (test) : [i] "r" (i), [c] "r" (c), [v] "r" (value) + : "cc", "memory"); + + return !ret; + } + +#elif defined(OVR_CPU_X86) + typedef uint32_t T; + + static inline uint32_t Exchange_NoSync(volatile uint32_t *i, uint32_t j) + { + asm volatile("xchgl %1,%[i]\n" + : "+m" (*i), "=q" (j) : [i] "m" (*i), "1" (j) : "cc", "memory"); + + return j; + } + + static inline uint32_t ExchangeAdd_NoSync(volatile uint32_t *i, uint32_t j) + { + asm volatile("lock; xaddl %1,%[i]\n" + : "+m" (*i), "+q" (j) : [i] "m" (*i) : "cc", "memory"); + + return j; + } + + static inline bool CompareAndSet_NoSync(volatile uint32_t *i, uint32_t c, uint32_t value) + { + uint32_t ret; + + asm volatile("lock; cmpxchgl %[v],%[i]\n" + : "+m" (*i), "=a" (ret) : [i] "m" (*i), "1" (c), [v] "q" (value) : "cc", "memory"); + + return (ret == c); + } + +#elif defined(OVR_CC_GNU) && (__GNUC__ >= 4 && __GNUC_MINOR__ >= 1) + + typedef uint32_t T; + + static inline T Exchange_NoSync(volatile T *i, T j) + { + T v; + do { + v = *i; + } while (!__sync_bool_compare_and_swap(i, v, j)); + return v; + } + + static inline T ExchangeAdd_NoSync(volatile T *i, T j) + { + return __sync_fetch_and_add(i, j); + } + + static inline bool CompareAndSet_NoSync(volatile T *i, T c, T value) + { + return __sync_bool_compare_and_swap(i, c, value); + } + +#endif // OS +}; + + +// 8-Byte raw data data atomic op implementation class. +// Currently implementation is provided only on systems with 64-bit pointers. +struct AtomicOpsRaw_8ByteImpl : public AtomicOpsRawBase +{ +#if !defined(OVR_64BIT_POINTERS) || !defined(OVR_ENABLE_THREADS) + + // Provide a type for no-thread-support cases. Used by AtomicOpsRaw_DefImpl. + typedef uint64_t T; + + // *** Thread - Safe OS specific versions. +#elif defined(OVR_OS_MS) + + // This is only for 64-bit systems. + typedef LONG64 T; + typedef volatile T* InterlockTPtr; + inline static T Exchange_NoSync(volatile T* p, T val) { return InterlockedExchange64((InterlockTPtr)p, val); } + inline static T ExchangeAdd_NoSync(volatile T* p, T val) { return InterlockedExchangeAdd64((InterlockTPtr)p, val); } + inline static bool CompareAndSet_NoSync(volatile T* p, T c, T val) { return InterlockedCompareExchange64((InterlockTPtr)p, val, c) == c; } + +#elif defined(OVR_CPU_PPC64) + + typedef uint64_t T; + + static inline uint64_t Exchange_NoSync(volatile uint64_t *i, uint64_t j) + { + uint64_t dummy, ret; + + asm volatile("1:\n\t" + "ldarx %[r],0,%[i]\n\t" + "mr %[o],%[j]\n\t" + "stdcx. %[o],0,%[i]\n\t" + "bne- 1b\n" + : "+m" (*i), [r] "=&b" (ret), [o] "=&r" (dummy) : [i] "b" (i), [j] "b" (j) : "cc"); + + return ret; + } + + static inline uint64_t ExchangeAdd_NoSync(volatile uint64_t *i, uint64_t j) + { + uint64_t dummy, ret; + + asm volatile("1:\n\t" + "ldarx %[r],0,%[i]\n\t" + "add %[o],%[r],%[j]\n\t" + "stdcx. %[o],0,%[i]\n\t" + "bne- 1b\n" + : "+m" (*i), [r] "=&b" (ret), [o] "=&r" (dummy) : [i] "b" (i), [j] "b" (j) : "cc"); + + return ret; + } + + static inline bool CompareAndSet_NoSync(volatile uint64_t *i, uint64_t c, uint64_t value) + { + uint64_t ret, dummy; + + asm volatile("1:\n\t" + "ldarx %[r],0,%[i]\n\t" + "cmpw 0,%[r],%[cmp]\n\t" + "mfcr %[r]\n\t" + "bne- 2f\n\t" + "stdcx. %[val],0,%[i]\n\t" + "bne- 1b\n\t" + "2:\n" + : "+m" (*i), [r] "=&b" (ret), [o] "=&r" (dummy) : [i] "b" (i), [cmp] "b" (c), [val] "b" (value) : "cc"); + + return (ret & 0x20000000) ? 1 : 0; + } + +#elif defined(OVR_CC_GNU) && (__GNUC__ >= 4 && __GNUC_MINOR__ >= 1) + + typedef uint64_t T; + + static inline T Exchange_NoSync(volatile T *i, T j) + { + T v; + do { + v = *i; + } while (!__sync_bool_compare_and_swap(i, v, j)); + return v; + } + + static inline T ExchangeAdd_NoSync(volatile T *i, T j) + { + return __sync_fetch_and_add(i, j); + } + + static inline bool CompareAndSet_NoSync(volatile T *i, T c, T value) + { + return __sync_bool_compare_and_swap(i, c, value); + } + +#endif // OS +}; + + +// Default implementation for AtomicOpsRaw; provides implementation of mem-fenced +// atomic operations where fencing is done with a sync object wrapped around a NoSync +// operation implemented in the base class. If such implementation is not possible +// on a given platform, #ifdefs can be used to disable it and then op functions can be +// implemented individually in the appropriate AtomicOpsRaw class. + +template +struct AtomicOpsRaw_DefImpl : public O +{ + typedef typename O::T O_T; + typedef typename O::FullSync O_FullSync; + typedef typename O::AcquireSync O_AcquireSync; + typedef typename O::ReleaseSync O_ReleaseSync; + + // If there is no thread support, provide the default implementation. In this case, + // the base class (0) must still provide the T declaration. +#ifndef OVR_ENABLE_THREADS + + // Atomic exchange of val with argument. Returns old val. + inline static O_T Exchange_NoSync(volatile O_T* p, O_T val) { O_T old = *p; *p = val; return old; } + // Adds a new val to argument; returns its old val. + inline static O_T ExchangeAdd_NoSync(volatile O_T* p, O_T val) { O_T old = *p; *p += val; return old; } + // Compares the argument data with 'c' val. + // If succeeded, stores val int '*p' and returns true; otherwise returns false. + inline static bool CompareAndSet_NoSync(volatile O_T* p, O_T c, O_T val) { if (*p==c) { *p = val; return 1; } return 0; } + +#endif + + // If NoSync wrapped implementation may not be possible, it this block should be + // replaced with per-function implementation in O. + // "AtomicOpsRaw_DefImpl::" prefix in calls below. + inline static O_T Exchange_Sync(volatile O_T* p, O_T val) { O_FullSync sync; OVR_UNUSED(sync); return AtomicOpsRaw_DefImpl::Exchange_NoSync(p, val); } + inline static O_T Exchange_Release(volatile O_T* p, O_T val) { O_ReleaseSync sync; OVR_UNUSED(sync); return AtomicOpsRaw_DefImpl::Exchange_NoSync(p, val); } + inline static O_T Exchange_Acquire(volatile O_T* p, O_T val) { O_AcquireSync sync; OVR_UNUSED(sync); return AtomicOpsRaw_DefImpl::Exchange_NoSync(p, val); } + inline static O_T ExchangeAdd_Sync(volatile O_T* p, O_T val) { O_FullSync sync; OVR_UNUSED(sync); return AtomicOpsRaw_DefImpl::ExchangeAdd_NoSync(p, val); } + inline static O_T ExchangeAdd_Release(volatile O_T* p, O_T val) { O_ReleaseSync sync; OVR_UNUSED(sync); return AtomicOpsRaw_DefImpl::ExchangeAdd_NoSync(p, val); } + inline static O_T ExchangeAdd_Acquire(volatile O_T* p, O_T val) { O_AcquireSync sync; OVR_UNUSED(sync); return AtomicOpsRaw_DefImpl::ExchangeAdd_NoSync(p, val); } + inline static bool CompareAndSet_Sync(volatile O_T* p, O_T c, O_T val) { O_FullSync sync; OVR_UNUSED(sync); return AtomicOpsRaw_DefImpl::CompareAndSet_NoSync(p,c,val); } + inline static bool CompareAndSet_Release(volatile O_T* p, O_T c, O_T val) { O_ReleaseSync sync; OVR_UNUSED(sync); return AtomicOpsRaw_DefImpl::CompareAndSet_NoSync(p,c,val); } + inline static bool CompareAndSet_Acquire(volatile O_T* p, O_T c, O_T val) { O_AcquireSync sync; OVR_UNUSED(sync); return AtomicOpsRaw_DefImpl::CompareAndSet_NoSync(p,c,val); } + + // Loads and stores with memory fence. These have only the relevant versions. +#ifdef OVR_CPU_X86 + // On X86, Store_Release is implemented as exchange. Note that we can also + // consider 'sfence' in the future, although it is not as compatible with older CPUs. + inline static void Store_Release(volatile O_T* p, O_T val) { Exchange_Release(p, val); } +#else + inline static void Store_Release(volatile O_T* p, O_T val) { O_ReleaseSync sync; OVR_UNUSED(sync); *p = val; } +#endif + inline static O_T Load_Acquire(const volatile O_T* p) + { + O_AcquireSync sync; + OVR_UNUSED(sync); + +#if defined(OVR_CC_MSVC) + _ReadBarrier(); // Compiler fence and load barrier +#elif defined(OVR_CC_INTEL) + __memory_barrier(); // Compiler fence +#else + // GCC-compatible: + asm volatile ("" : : : "memory"); // Compiler fence +#endif + + return *p; + } +}; + + +template +struct AtomicOpsRaw : public AtomicOpsRawBase { }; + +template<> +struct AtomicOpsRaw<4> : public AtomicOpsRaw_DefImpl +{ + // Ensure that assigned type size is correct. + AtomicOpsRaw() + { OVR_COMPILER_ASSERT(sizeof(AtomicOpsRaw_DefImpl::T) == 4); } +}; +template<> +struct AtomicOpsRaw<8> : public AtomicOpsRaw_DefImpl +{ + AtomicOpsRaw() + { OVR_COMPILER_ASSERT(sizeof(AtomicOpsRaw_DefImpl::T) == 8); } +}; + + +// *** AtomicOps - implementation of atomic Ops for specified class + +// Implements atomic ops on a class, provided that the object is either +// 4 or 8 bytes in size (depending on the AtomicOpsRaw specializations +// available). Relies on AtomicOpsRaw for much of implementation. + +template +class AtomicOps +{ + typedef AtomicOpsRaw Ops; + typedef typename Ops::T T; + typedef volatile typename Ops::T* PT; + // We cast through unions to (1) avoid pointer size compiler warnings + // and (2) ensure that there are no problems with strict pointer aliasing. + union C2T_union { C c; T t; }; + +public: + // General purpose implementation for standard syncs. + inline static C Exchange_Sync(volatile C* p, C val) { C2T_union u; u.c = val; u.t = Ops::Exchange_Sync((PT)p, u.t); return u.c; } + inline static C Exchange_Release(volatile C* p, C val) { C2T_union u; u.c = val; u.t = Ops::Exchange_Release((PT)p, u.t); return u.c; } + inline static C Exchange_Acquire(volatile C* p, C val) { C2T_union u; u.c = val; u.t = Ops::Exchange_Acquire((PT)p, u.t); return u.c; } + inline static C Exchange_NoSync(volatile C* p, C val) { C2T_union u; u.c = val; u.t = Ops::Exchange_NoSync((PT)p, u.t); return u.c; } + inline static C ExchangeAdd_Sync(volatile C* p, C val) { C2T_union u; u.c = val; u.t = Ops::ExchangeAdd_Sync((PT)p, u.t); return u.c; } + inline static C ExchangeAdd_Release(volatile C* p, C val) { C2T_union u; u.c = val; u.t = Ops::ExchangeAdd_Release((PT)p, u.t); return u.c; } + inline static C ExchangeAdd_Acquire(volatile C* p, C val) { C2T_union u; u.c = val; u.t = Ops::ExchangeAdd_Acquire((PT)p, u.t); return u.c; } + inline static C ExchangeAdd_NoSync(volatile C* p, C val) { C2T_union u; u.c = val; u.t = Ops::ExchangeAdd_NoSync((PT)p, u.t); return u.c; } + inline static bool CompareAndSet_Sync(volatile C* p, C c, C val) { C2T_union u,cu; u.c = val; cu.c = c; return Ops::CompareAndSet_Sync((PT)p, cu.t, u.t); } + inline static bool CompareAndSet_Release(volatile C* p, C c, C val){ C2T_union u,cu; u.c = val; cu.c = c; return Ops::CompareAndSet_Release((PT)p, cu.t, u.t); } + inline static bool CompareAndSet_Acquire(volatile C* p, C c, C val){ C2T_union u,cu; u.c = val; cu.c = c; return Ops::CompareAndSet_Acquire((PT)p, cu.t, u.t); } + inline static bool CompareAndSet_NoSync(volatile C* p, C c, C val) { C2T_union u,cu; u.c = val; cu.c = c; return Ops::CompareAndSet_NoSync((PT)p, cu.t, u.t); } + + // Loads and stores with memory fence. These have only the relevant versions. + inline static void Store_Release(volatile C* p, C val) { C2T_union u; u.c = val; Ops::Store_Release((PT)p, u.t); } + inline static C Load_Acquire(const volatile C* p) { C2T_union u; u.t = Ops::Load_Acquire((PT)p); return u.c; } + + // Deprecated typo error: + inline static bool CompareAndSet_Relse(volatile C* p, C c, C val){ C2T_union u,cu; u.c = val; cu.c = c; return Ops::CompareAndSet_Acquire((PT)p, cu.t, u.t); } +}; + + + +// Atomic value base class - implements operations shared for integers and pointers. +template +class AtomicValueBase +{ +protected: + typedef AtomicOps Ops; +public: + + volatile T Value; + + inline AtomicValueBase() { } + explicit inline AtomicValueBase(T val) { Ops::Store_Release(&Value, val); } + + // Most libraries (TBB and Joshua Scholar's) library do not do Load_Acquire + // here, since most algorithms do not require atomic loads. Needs some research. + inline operator T() const { return Value; } + + // *** Standard Atomic inlines + inline T Exchange_Sync(T val) { return Ops::Exchange_Sync(&Value, val); } + inline T Exchange_Release(T val) { return Ops::Exchange_Release(&Value, val); } + inline T Exchange_Acquire(T val) { return Ops::Exchange_Acquire(&Value, val); } + inline T Exchange_NoSync(T val) { return Ops::Exchange_NoSync(&Value, val); } + inline bool CompareAndSet_Sync(T c, T val) { return Ops::CompareAndSet_Sync(&Value, c, val); } + inline bool CompareAndSet_Release(T c, T val) { return Ops::CompareAndSet_Release(&Value, c, val); } + inline bool CompareAndSet_Acquire(T c, T val) { return Ops::CompareAndSet_Acquire(&Value, c, val); } + inline bool CompareAndSet_NoSync(T c, T val) { return Ops::CompareAndSet_NoSync(&Value, c, val); } + // Load & Store. + inline void Store_Release(T val) { Ops::Store_Release(&Value, val); } + inline T Load_Acquire() const { return Ops::Load_Acquire(&Value); } +}; + + +// ***** AtomicPtr - Atomic pointer template + +// This pointer class supports atomic assignments with release, +// increment / decrement operations, and conditional compare + set. + +template +class AtomicPtr : public AtomicValueBase +{ + typedef typename AtomicValueBase::Ops Ops; + +public: + // Initialize pointer value to 0 by default; use Store_Release only with explicit constructor. + inline AtomicPtr() : AtomicValueBase() { this->Value = 0; } + explicit inline AtomicPtr(T* val) : AtomicValueBase(val) { } + + // Pointer access. + inline T* operator -> () const { return this->Load_Acquire(); } + + // It looks like it is convenient to have Load_Acquire characteristics + // for this, since that is convenient for algorithms such as linked + // list traversals that can be added to bu another thread. + inline operator T* () const { return this->Load_Acquire(); } + + + // *** Standard Atomic inlines (applicable to pointers) + + // ExhangeAdd considers pointer size for pointers. + template + inline T* ExchangeAdd_Sync(I incr) { return Ops::ExchangeAdd_Sync(&this->Value, ((T*)0) + incr); } + template + inline T* ExchangeAdd_Release(I incr) { return Ops::ExchangeAdd_Release(&this->Value, ((T*)0) + incr); } + template + inline T* ExchangeAdd_Acquire(I incr) { return Ops::ExchangeAdd_Acquire(&this->Value, ((T*)0) + incr); } + template + inline T* ExchangeAdd_NoSync(I incr) { return Ops::ExchangeAdd_NoSync(&this->Value, ((T*)0) + incr); } + + // *** Atomic Operators + + inline T* operator = (T* val) { this->Store_Release(val); return val; } + + template + inline T* operator += (I val) { return ExchangeAdd_Sync(val) + val; } + template + inline T* operator -= (I val) { return operator += (-val); } + + inline T* operator ++ () { return ExchangeAdd_Sync(1) + 1; } + inline T* operator -- () { return ExchangeAdd_Sync(-1) - 1; } + inline T* operator ++ (int) { return ExchangeAdd_Sync(1); } + inline T* operator -- (int) { return ExchangeAdd_Sync(-1); } +}; + + +// ***** AtomicInt - Atomic integer template + +// Implements an atomic integer type; the exact type to use is provided +// as an argument. Supports atomic Acquire / Release semantics, atomic +// arithmetic operations, and atomic conditional compare + set. + +template +class AtomicInt : public AtomicValueBase +{ + typedef typename AtomicValueBase::Ops Ops; + +public: + inline AtomicInt() : AtomicValueBase() { } + explicit inline AtomicInt(T val) : AtomicValueBase(val) { } + + + // *** Standard Atomic inlines (applicable to int) + inline T ExchangeAdd_Sync(T val) { return Ops::ExchangeAdd_Sync(&this->Value, val); } + inline T ExchangeAdd_Release(T val) { return Ops::ExchangeAdd_Release(&this->Value, val); } + inline T ExchangeAdd_Acquire(T val) { return Ops::ExchangeAdd_Acquire(&this->Value, val); } + inline T ExchangeAdd_NoSync(T val) { return Ops::ExchangeAdd_NoSync(&this->Value, val); } + // These increments could be more efficient because they don't return a value. + inline void Increment_Sync() { ExchangeAdd_Sync((T)1); } + inline void Increment_Release() { ExchangeAdd_Release((T)1); } + inline void Increment_Acquire() { ExchangeAdd_Acquire((T)1); } + inline void Increment_NoSync() { ExchangeAdd_NoSync((T)1); } + + // *** Atomic Operators + + inline T operator = (T val) { this->Store_Release(val); return val; } + inline T operator += (T val) { return ExchangeAdd_Sync(val) + val; } + inline T operator -= (T val) { return ExchangeAdd_Sync(0 - val) - val; } + + inline T operator ++ () { return ExchangeAdd_Sync((T)1) + 1; } + inline T operator -- () { return ExchangeAdd_Sync(((T)0)-1) - 1; } + inline T operator ++ (int) { return ExchangeAdd_Sync((T)1); } + inline T operator -- (int) { return ExchangeAdd_Sync(((T)0)-1); } + + // More complex atomic operations. Leave it to compiler whether to optimize them or not. + T operator &= (T arg) + { + T comp, newVal; + do { + comp = this->Value; + newVal = comp & arg; + } while(!this->CompareAndSet_Sync(comp, newVal)); + return newVal; + } + + T operator |= (T arg) + { + T comp, newVal; + do { + comp = this->Value; + newVal = comp | arg; + } while(!this->CompareAndSet_Sync(comp, newVal)); + return newVal; + } + + T operator ^= (T arg) + { + T comp, newVal; + do { + comp = this->Value; + newVal = comp ^ arg; + } while(!this->CompareAndSet_Sync(comp, newVal)); + return newVal; + } + + T operator *= (T arg) + { + T comp, newVal; + do { + comp = this->Value; + newVal = comp * arg; + } while(!this->CompareAndSet_Sync(comp, newVal)); + return newVal; + } + + T operator /= (T arg) + { + T comp, newVal; + do { + comp = this->Value; + newVal = comp / arg; + } while(!CompareAndSet_Sync(comp, newVal)); + return newVal; + } + + T operator >>= (unsigned bits) + { + T comp, newVal; + do { + comp = this->Value; + newVal = comp >> bits; + } while(!CompareAndSet_Sync(comp, newVal)); + return newVal; + } + + T operator <<= (unsigned bits) + { + T comp, newVal; + do { + comp = this->Value; + newVal = comp << bits; + } while(!this->CompareAndSet_Sync(comp, newVal)); + return newVal; + } +}; + + +//----------------------------------------------------------------------------------- +// ***** Lock + +// Lock is a simplest and most efficient mutual-exclusion lock class. +// Unlike Mutex, it cannot be waited on. + +class Lock +{ + // NOTE: Locks are not allocatable and they themselves should not allocate + // memory by standard means. This is the case because StandardAllocator + // relies on this class. + // Make 'delete' private. Don't do this for 'new' since it can be redefined. + void operator delete(void*) {} + + + // *** Lock implementation for various platforms. + +#if !defined(OVR_ENABLE_THREADS) + +public: + // With no thread support, lock does nothing. + inline Lock() { } + inline Lock(unsigned) { } + inline ~Lock() { } + inline void DoLock() { } + inline void Unlock() { } + + // Windows. +#elif defined(OVR_OS_MS) + + CRITICAL_SECTION cs; +public: + Lock(unsigned spinCount = 10000); // Mutexes with non-zero spin counts usually result in better performance. + ~Lock(); + // Locking functions. + inline void DoLock() { ::EnterCriticalSection(&cs); } + inline void Unlock() { ::LeaveCriticalSection(&cs); } + +#else + pthread_mutex_t mutex; + +public: + static pthread_mutexattr_t RecursiveAttr; + static bool RecursiveAttrInit; + + Lock (unsigned spinCount = 0) // To do: Support spin count, probably via a custom lock implementation. + { + OVR_UNUSED(spinCount); + if (!RecursiveAttrInit) + { + pthread_mutexattr_init(&RecursiveAttr); + pthread_mutexattr_settype(&RecursiveAttr, PTHREAD_MUTEX_RECURSIVE); + RecursiveAttrInit = 1; + } + pthread_mutex_init(&mutex,&RecursiveAttr); + } + ~Lock () { pthread_mutex_destroy(&mutex); } + inline void DoLock() { pthread_mutex_lock(&mutex); } + inline void Unlock() { pthread_mutex_unlock(&mutex); } + +#endif // OVR_ENABLE_THREDS + + +public: + // Locker class, used for automatic locking + class Locker + { + public: + Lock *pLock; + inline Locker(Lock *plock) + { pLock = plock; pLock->DoLock(); } + inline ~Locker() + { pLock->Unlock(); } + }; +}; + + +//------------------------------------------------------------------------------------- +// Globally shared Lock implementation used for MessageHandlers, etc. + +class SharedLock +{ +public: + SharedLock() : UseCount(0) {} + + Lock* GetLockAddRef(); + void ReleaseLock(Lock* plock); + +private: + Lock* toLock() { return (Lock*)Buffer; } + + // UseCount and max alignment. + volatile int UseCount; + uint64_t Buffer[(sizeof(Lock)+sizeof(uint64_t)-1)/sizeof(uint64_t)]; +}; + + +} // OVR + +#endif diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Kernel/OVR_CRC32.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Kernel/OVR_CRC32.cpp Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,85 @@ +/************************************************************************************ + +Filename : OVR_CRC32.cpp +Content : CRC-32 with polynomial used for sensor devices +Created : June 20, 2014 +Author : Chris Taylor + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#include "OVR_CRC32.h" + +namespace OVR { + + +static const uint32_t CRC_Table[256] = { + 0x00000000, 0x04c11db7, 0x09823b6e, 0x0d4326d9, 0x130476dc, 0x17c56b6b, 0x1a864db2, 0x1e475005, + 0x2608edb8, 0x22c9f00f, 0x2f8ad6d6, 0x2b4bcb61, 0x350c9b64, 0x31cd86d3, 0x3c8ea00a, 0x384fbdbd, + 0x4c11db70, 0x48d0c6c7, 0x4593e01e, 0x4152fda9, 0x5f15adac, 0x5bd4b01b, 0x569796c2, 0x52568b75, + 0x6a1936c8, 0x6ed82b7f, 0x639b0da6, 0x675a1011, 0x791d4014, 0x7ddc5da3, 0x709f7b7a, 0x745e66cd, + 0x9823b6e0, 0x9ce2ab57, 0x91a18d8e, 0x95609039, 0x8b27c03c, 0x8fe6dd8b, 0x82a5fb52, 0x8664e6e5, + 0xbe2b5b58, 0xbaea46ef, 0xb7a96036, 0xb3687d81, 0xad2f2d84, 0xa9ee3033, 0xa4ad16ea, 0xa06c0b5d, + 0xd4326d90, 0xd0f37027, 0xddb056fe, 0xd9714b49, 0xc7361b4c, 0xc3f706fb, 0xceb42022, 0xca753d95, + 0xf23a8028, 0xf6fb9d9f, 0xfbb8bb46, 0xff79a6f1, 0xe13ef6f4, 0xe5ffeb43, 0xe8bccd9a, 0xec7dd02d, + 0x34867077, 0x30476dc0, 0x3d044b19, 0x39c556ae, 0x278206ab, 0x23431b1c, 0x2e003dc5, 0x2ac12072, + 0x128e9dcf, 0x164f8078, 0x1b0ca6a1, 0x1fcdbb16, 0x018aeb13, 0x054bf6a4, 0x0808d07d, 0x0cc9cdca, + 0x7897ab07, 0x7c56b6b0, 0x71159069, 0x75d48dde, 0x6b93dddb, 0x6f52c06c, 0x6211e6b5, 0x66d0fb02, + 0x5e9f46bf, 0x5a5e5b08, 0x571d7dd1, 0x53dc6066, 0x4d9b3063, 0x495a2dd4, 0x44190b0d, 0x40d816ba, + 0xaca5c697, 0xa864db20, 0xa527fdf9, 0xa1e6e04e, 0xbfa1b04b, 0xbb60adfc, 0xb6238b25, 0xb2e29692, + 0x8aad2b2f, 0x8e6c3698, 0x832f1041, 0x87ee0df6, 0x99a95df3, 0x9d684044, 0x902b669d, 0x94ea7b2a, + 0xe0b41de7, 0xe4750050, 0xe9362689, 0xedf73b3e, 0xf3b06b3b, 0xf771768c, 0xfa325055, 0xfef34de2, + 0xc6bcf05f, 0xc27dede8, 0xcf3ecb31, 0xcbffd686, 0xd5b88683, 0xd1799b34, 0xdc3abded, 0xd8fba05a, + 0x690ce0ee, 0x6dcdfd59, 0x608edb80, 0x644fc637, 0x7a089632, 0x7ec98b85, 0x738aad5c, 0x774bb0eb, + 0x4f040d56, 0x4bc510e1, 0x46863638, 0x42472b8f, 0x5c007b8a, 0x58c1663d, 0x558240e4, 0x51435d53, + 0x251d3b9e, 0x21dc2629, 0x2c9f00f0, 0x285e1d47, 0x36194d42, 0x32d850f5, 0x3f9b762c, 0x3b5a6b9b, + 0x0315d626, 0x07d4cb91, 0x0a97ed48, 0x0e56f0ff, 0x1011a0fa, 0x14d0bd4d, 0x19939b94, 0x1d528623, + 0xf12f560e, 0xf5ee4bb9, 0xf8ad6d60, 0xfc6c70d7, 0xe22b20d2, 0xe6ea3d65, 0xeba91bbc, 0xef68060b, + 0xd727bbb6, 0xd3e6a601, 0xdea580d8, 0xda649d6f, 0xc423cd6a, 0xc0e2d0dd, 0xcda1f604, 0xc960ebb3, + 0xbd3e8d7e, 0xb9ff90c9, 0xb4bcb610, 0xb07daba7, 0xae3afba2, 0xaafbe615, 0xa7b8c0cc, 0xa379dd7b, + 0x9b3660c6, 0x9ff77d71, 0x92b45ba8, 0x9675461f, 0x8832161a, 0x8cf30bad, 0x81b02d74, 0x857130c3, + 0x5d8a9099, 0x594b8d2e, 0x5408abf7, 0x50c9b640, 0x4e8ee645, 0x4a4ffbf2, 0x470cdd2b, 0x43cdc09c, + 0x7b827d21, 0x7f436096, 0x7200464f, 0x76c15bf8, 0x68860bfd, 0x6c47164a, 0x61043093, 0x65c52d24, + 0x119b4be9, 0x155a565e, 0x18197087, 0x1cd86d30, 0x029f3d35, 0x065e2082, 0x0b1d065b, 0x0fdc1bec, + 0x3793a651, 0x3352bbe6, 0x3e119d3f, 0x3ad08088, 0x2497d08d, 0x2056cd3a, 0x2d15ebe3, 0x29d4f654, + 0xc5a92679, 0xc1683bce, 0xcc2b1d17, 0xc8ea00a0, 0xd6ad50a5, 0xd26c4d12, 0xdf2f6bcb, 0xdbee767c, + 0xe3a1cbc1, 0xe760d676, 0xea23f0af, 0xeee2ed18, 0xf0a5bd1d, 0xf464a0aa, 0xf9278673, 0xfde69bc4, + 0x89b8fd09, 0x8d79e0be, 0x803ac667, 0x84fbdbd0, 0x9abc8bd5, 0x9e7d9662, 0x933eb0bb, 0x97ffad0c, + 0xafb010b1, 0xab710d06, 0xa6322bdf, 0xa2f33668, 0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4 +}; + + +//// CRC-32 + +uint32_t CRC32_Calculate(const void* data, int bytes, uint32_t accumulator) +{ + const uint8_t* inputBytes = reinterpret_cast( data ); + + for (int j = 0; j < bytes; ++j) + { + int i = ((uint32_t)(accumulator >> 24) ^ *inputBytes++) & 0xFF; + + accumulator = (accumulator << 8) ^ CRC_Table[i]; + } + + return ~accumulator; +} + + +} // OVR diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Kernel/OVR_CRC32.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Kernel/OVR_CRC32.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,45 @@ +/************************************************************************************ + +PublicHeader: OVR +Filename : OVR_CRC32.h +Content : CRC-32 with polynomial used for sensor devices +Created : June 20, 2014 +Author : Chris Taylor + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#ifndef OVR_CRC32_h +#define OVR_CRC32_h + +#include "OVR_Types.h" + +namespace OVR { + + +//----------------------------------------------------------------------------------- +// ***** CRC-32 + +// Polynomial used and algorithm details are proprietary to our sensor board +uint32_t CRC32_Calculate(const void* data, int bytes, uint32_t prevCRC = 0); + + +} // namespace OVR + +#endif diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Kernel/OVR_Color.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Kernel/OVR_Color.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,73 @@ +/************************************************************************************ + +PublicHeader: OVR_Kernel.h +Filename : OVR_Color.h +Content : Contains color struct. +Created : February 7, 2013 +Notes : + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ +#ifndef OVR_Color_h +#define OVR_Color_h + +#include "OVR_Types.h" + +namespace OVR { + + +struct Color +{ + uint8_t R,G,B,A; + + Color() + { + #if defined(OVR_BUILD_DEBUG) + R = G = B = A = 0; + #endif + } + + // Constructs color by channel. Alpha is set to 0xFF (fully visible) + // if not specified. + Color(unsigned char r,unsigned char g,unsigned char b, unsigned char a = 0xFF) + : R(r), G(g), B(b), A(a) { } + + // 0xAARRGGBB - Common HTML color Hex layout + Color(unsigned c) + : R((unsigned char)(c>>16)), G((unsigned char)(c>>8)), + B((unsigned char)c), A((unsigned char)(c>>24)) { } + + bool operator==(const Color& b) const + { + return R == b.R && G == b.G && B == b.B && A == b.A; + } + + void GetRGBA(float *r, float *g, float *b, float* a) const + { + *r = R / 255.0f; + *g = G / 255.0f; + *b = B / 255.0f; + *a = A / 255.0f; + } +}; + + +} // namespace OVR + +#endif diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Kernel/OVR_Compiler.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Kernel/OVR_Compiler.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,1524 @@ +/************************************************************************************ + +PublicHeader: OVR.h +Filename : OVR_Compiler.h +Content : Compiler-specific feature identification and utilities +Created : June 19, 2014 +Notes : + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + + +#ifndef OVR_Compiler_h +#define OVR_Compiler_h + +#pragma once + + +// References +// https://gcc.gnu.org/projects/cxx0x.html +// https://gcc.gnu.org/projects/cxx1y.html +// http://clang.llvm.org/cxx_status.html +// http://msdn.microsoft.com/en-us/library/hh567368.aspx +// https://docs.google.com/spreadsheet/pub?key=0AoBblDsbooe4dHZuVTRoSTFBejk5eFBfVk1GWlE5UlE&output=html +// http://nadeausoftware.com/articles/2012/10/c_c_tip_how_detect_compiler_name_and_version_using_compiler_predefined_macros + + +//----------------------------------------------------------------------------------- +// ***** Compiler +// +// The following compilers are defined: (OVR_CC_x) +// +// MSVC - Microsoft Visual C/C++ +// INTEL - Intel C++ for Linux / Windows +// GNU - GNU C++ +// ARM - ARM C/C++ + +#if defined(__INTEL_COMPILER) +// Intel 4.0 = 400 +// Intel 5.0 = 500 +// Intel 6.0 = 600 +// Intel 8.0 = 800 +// Intel 9.0 = 900 +# define OVR_CC_INTEL __INTEL_COMPILER + +#elif defined(_MSC_VER) +// MSVC 5.0 = 1100 +// MSVC 6.0 = 1200 +// MSVC 7.0 (VC2002) = 1300 +// MSVC 7.1 (VC2003) = 1310 +// MSVC 8.0 (VC2005) = 1400 +// MSVC 9.0 (VC2008) = 1500 +// MSVC 10.0 (VC2010) = 1600 +// MSVC 11.0 (VC2012) = 1700 +// MSVC 12.0 (VC2013) = 1800 +# define OVR_CC_MSVC _MSC_VER + +#if _MSC_VER == 0x1600 +# if _MSC_FULL_VER < 160040219 +# error "Oculus does not support VS2010 without SP1 installed." +# endif +#endif + +#elif defined(__GNUC__) +# define OVR_CC_GNU + +#elif defined(__clang__) +# define OVR_CC_CLANG + +#elif defined(__CC_ARM) +# define OVR_CC_ARM + +#else +# error "Oculus does not support this Compiler" +#endif + + +//----------------------------------------------------------------------------------- +// ***** OVR_CC_VERSION +// +// M = major version +// m = minor version +// p = patch release +// b = build number +// +// Compiler Format Example +// ---------------------------- +// OVR_CC_GNU Mmm 408 means GCC 4.8 +// OVR_CC_CLANG Mmm 305 means clang 3.5 +// OVR_CC_MSVC MMMM 1700 means VS2012 +// OVR_CC_ARM Mmpbbb 401677 means 4.0, patch 1, build 677 +// OVR_CC_INTEL MMmm 1210 means 12.10 +// OVR_CC_EDG Mmm 407 means EDG 4.7 +// +#if defined(OVR_CC_GNU) + #define OVR_CC_VERSION ((__GNUC__ * 100) + __GNUC_MINOR__) +#elif defined(OVR_CC_CLANG) + #define OVR_CC_VERSION ((__clang_major__ * 100) + __clang_minor__) +#elif defined(OVR_CC_MSVC) + #define OVR_CC_VERSION _MSC_VER // Question: Should we recognize _MSC_FULL_VER? +#elif defined(OVR_CC_ARM) + #define OVR_CC_VERSION __ARMCC_VERSION +#elif defined(OVR_CC_INTEL) + #if defined(__INTEL_COMPILER) + #define OVR_CC_VERSION __INTEL_COMPILER + #elif defined(__ICL) + #define OVR_CC_VERSION __ICL + #elif defined(__ICC) + #define OVR_CC_VERSION __ICC + #elif defined(__ECC) + #define OVR_CC_VERSION __ECC + #endif +#elif defined(OVR_CC_EDG) + #define OVR_CC_VERSION __EDG_VERSION__ // This is a generic fallback for EDG-based compilers which aren't specified above (e.g. as OVR_CC_ARM) +#endif + + + +// ----------------------------------------------------------------------------------- +// ***** OVR_DISABLE_OPTIMIZATION / OVR_RESTORE_OPTIMIZATION +// +// Allows for the dynamic disabling and restoring of compiler optimizations in code. +// This is useful for helping deal with potential compiler code generation problems. +// With VC++ the usage must be outside of function bodies. This can be used only to +// temporarily disable optimization for a block of code and not to temporarily enable +// optimization for a block of code. +// +// Clang doesn't support this as of June 2014, though function __attribute__((optimize(0)) +// is supposedly supported by clang in addition to GCC. To consider: Make a wrapper for +// this attribute-based functionality. +// +// Example usage: +// OVR_DISABLE_OPTIMIZATION() +// void Test() { ... } +// OVR_RESTORE_OPTIMIZATION() +// +#if !defined(OVR_DISABLE_OPTIMIZATION) + #if defined(OVR_CC_GNU) && (OVR_CC_VERSION > 404) && (defined(OVR_CPU_X86) || defined(OVR_CPU_X86_64)) + #define OVR_DISABLE_OPTIMIZATION() \ + _Pragma("GCC push_options") \ + _Pragma("GCC optimize 0") + #elif defined(OVR_CC_MSVC) + #define OVR_DISABLE_OPTIMIZATION() __pragma(optimize("", off)) + #else + #define OVR_DISABLE_OPTIMIZATION() + #endif +#endif + +#if !defined(OVR_RESTORE_OPTIMIZATION) + #if defined(OVR_CC_GNU) && (OVR_CC_VERSION > 404) && (defined(OVR_CPU_X86) || defined(OVR_CPU_X86_64)) + #define OVR_RESTORE_OPTIMIZATION() _Pragma("GCC pop_options") + #elif defined(OVR_CC_MSVC) + #define OVR_RESTORE_OPTIMIZATION() __pragma(optimize("", on)) + #else + #define OVR_RESTORE_OPTIMIZATION() + #endif +#endif + + +// ----------------------------------------------------------------------------------- +// ***** OVR_DISABLE_GNU_WARNING / OVR_RESTORE_GNU_WARNING +// +// Portable wrapper for disabling GCC compiler warnings, one at a time. See example +// usage for usage by example. +// +// Example usage: +// OVR_DISABLE_GNU_WARNING(-Wmissing-braces) // Only one warning per usage. +// OVR_DISABLE_GNU_WARNING(-Wunused-variable) +// +// OVR_RESTORE_GNU_WARNINGS() +// OVR_RESTORE_GNU_WARNINGS() // Must match each disable with a restore. +// +#if !defined(OVR_DISABLE_GNU_WARNING) + #if defined(OVR_CC_GNU) + #define ODGW1(x) #x + #define ODGW2(x) ODGW1(GCC diagnostic ignored x) + #define ODGW3(x) ODGW2(#x) + #endif + + #if defined(OVR_CC_GNU) && (OVR_CC_VERSION >= 406) + #define OVR_DISABLE_GNU_WARNING(w) \ + _Pragma("GCC diagnostic push") \ + _Pragma(ODGW3(w)) + #elif defined(OVR_CC_GNU) && (OVR_CC_VERSION >= 404) // GCC 4.4 doesn't support diagnostic push, but supports disabling warnings. + #define OVR_DISABLE_GNU_WARNING(w) \ + _Pragma(ODGW3(w)) + #else + #define OVR_DISABLE_GNU_WARNING(w) + #endif +#endif + +#if !defined(OVR_RESTORE_GNU_WARNING) + #if defined(OVR_CC_GNU) && (OVR_CC_VERSION >= 4006) + #define OVR_RESTORE_GNU_WARNINGS() \ + _Pragma("GCC diagnostic pop") + #else + #define OVR_RESTORE_GNU_WARNING() + #endif +#endif + + + +// ----------------------------------------------------------------------------------- +// ***** OVR_DISABLE_CLANG_WARNING / OVR_RESTORE_CLANG_WARNING +// +// Portable wrapper for disabling GCC compiler warnings, one at a time. See example +// usage for usage by example. +// +// Example usage: +// OVR_DISABLE_CLANG_WARNING(-Wmissing-braces) // Only one warning per usage. +// OVR_DISABLE_CLANG_WARNING(-Wunused-variable) +// +// OVR_RESTORE_CLANG_WARNINGS() +// OVR_RESTORE_CLANG_WARNINGS() // Must match each disable with a restore. +// +// +#if !defined(OVR_DISABLE_CLANG_WARNING) + #if defined(OVR_CC_CLANG) + #define ODCW1(x) #x + #define ODCW2(x) ODCW1(clang diagnostic ignored x) + #define ODCW3(x) ODCW2(#x) + + #define OVR_DISABLE_CLANG_WARNING(w) \ + _Pragma("clang diagnostic push") \ + _Pragma(ODCW3(w)) + #else + #define OVR_DISABLE_CLANG_WARNING(w) + #endif +#endif + +#if !defined(OVR_RESTORE_CLANG_WARNING) + #if defined(OVR_CC_CLANG) + #define OVR_RESTORE_CLANG_WARNING() \ + _Pragma("clang diagnostic pop") + #else + #define OVR_RESTORE_CLANG_WARNING() + #endif +#endif + + +// ----------------------------------------------------------------------------------- +// ***** OVR_DISABLE_MSVC_WARNING / OVR_RESTORE_MSVC_WARNING +// +// Portable wrapper for disabling VC++ compiler warnings. See example usage for usage +// by example. +// +// Example usage: +// OVR_DISABLE_MSVC_WARNING(4556 4782 4422) +// +// OVR_RESTORE_MSVC_WARNING() +// +#if !defined(OVR_DISABLE_MSVC_WARNING) + #if defined(OVR_CC_MSVC) + #define OVR_DISABLE_MSVC_WARNING(w) \ + __pragma(warning(push)) \ + __pragma(warning(disable:w)) + #else + #define OVR_DISABLE_MSVC_WARNING(w) + #endif +#endif + +#if !defined(OVR_RESTORE_MSVC_WARNING) + #if defined(OVR_CC_MSVC) + #define OVR_RESTORE_MSVC_WARNING() \ + __pragma(warning(pop)) + #else + #define OVR_RESTORE_MSVC_WARNING() + #endif +#endif + + +// ----------------------------------------------------------------------------------- +// ***** OVR_DISABLE_ALL_MSVC_WARNINGS / OVR_RESTORE_ALL_MSVC_WARNINGS +// +// Portable wrapper for disabling all VC++ compiler warnings. +// OVR_RESTORE_ALL_MSVC_WARNINGS restores warnings that were disabled by +// OVR_DISABLE_ALL_MSVC_WARNINGS. Any previously enabled warnings will still be +// enabled after OVR_RESTORE_ALL_MSVC_WARNINGS. +// +// Example usage: +// OVR_DISABLE_ALL_MSVC_WARNINGS() +// +// OVR_RESTORE_ALL_MSVC_WARNINGS() + +#if !defined(OVR_DISABLE_ALL_MSVC_WARNINGS) + #if defined(OVR_CC_MSVC) + #define OVR_DISABLE_ALL_MSVC_WARNINGS() \ + __pragma(warning(push, 0)) + #else + #define OVR_DISABLE_ALL_MSVC_WARNINGS() + #endif +#endif + +#if !defined(OVR_RESTORE_ALL_MSVC_WARNINGS) + #if defined(OVR_CC_MSVC) + #define OVR_RESTORE_ALL_MSVC_WARNINGS() \ + __pragma(warning(pop)) + #else + #define OVR_RESTORE_ALL_MSVC_WARNINGS() + #endif +#endif + + +//----------------------------------------------------------------------------------- +// ***** OVR_CC_HAS_FEATURE +// +// This is a portable way to use compile-time feature identification available +// with some compilers in a clean way. Direct usage of __has_feature in preprocessing +// statements of non-supporting compilers results in a preprocessing error. +// +// Example usage: +// #if OVR_CC_HAS_FEATURE(is_pod) +// if(__is_pod(T)) // If the type is plain data then we can safely memcpy it. +// memcpy(&destObject, &srcObject, sizeof(object)); +// #endif +// +#if !defined(OVR_CC_HAS_FEATURE) + #if defined(__clang__) // http://clang.llvm.org/docs/LanguageExtensions.html#id2 + #define OVR_CC_HAS_FEATURE(x) __has_feature(x) + #else + #define OVR_CC_HAS_FEATURE(x) 0 + #endif +#endif + + +//----------------------------------------------------------------------------------- +// ***** OVR_CC_HAS_BUILTIN +// +// +// This is a portable way to use compile-time builtin identification available +// with some compilers in a clean way. Direct usage of __has_builtin in preprocessing +// statements of non-supporting compilers results in a preprocessing error. +// +// Example usage: +// #if OVR_CC_HAS_BUILTIN(__builtin_trap) +// #define DEBUG_BREAK __builtin_trap +// #endif +// +#if !defined(OVR_CC_HAS_BUILTIN) + #if defined(__clang__) + #define OVR_CC_HAS_BUILTIN(x) __has_builtin(x) // http://clang.llvm.org/docs/LanguageExtensions.html#id2 + #else + #define OVR_CC_HAS_BUILTIN(x) 0 + #endif +#endif + + +//----------------------------------------------------------------------------------- +// ***** OVR_CPP11_ENABLED / OVR_CPP_CPP14_ENABLED +// +// Defined as 1 if the compiler has its available C++11 support enabled, else undefined. +// This does not mean that all of C++11 or any particular feature of C++11 is supported +// by the compiler. It means that whatever C++11 support the compiler has is enabled. +// This also includes existing and older compilers that still identify C++11 as C++0x. +// +#if !defined(OVR_CPP11_ENABLED) && defined(__cplusplus) + #if defined(__GNUC__) && defined(__GXX_EXPERIMENTAL_CXX0X__) + #define OVR_CPP11_ENABLED 1 + #elif defined(_MSC_VER) && (_MSC_VER >= 1500) // VS2010+, the first version with any significant C++11 support. + #define OVR_CPP11_ENABLED 1 + #elif (__cplusplus >= 201103L) // 201103 is the first C++11 version. + #define OVR_CPP11_ENABLED 1 + #else + // Leave undefined + #endif +#endif + +#if !defined(OVR_CPP_CPP14_ENABLED) && defined(__cplusplus) + #if defined(_MSC_VER) && (_MSC_VER >= 1800) // VS2013+, the first version with any significant C++14 support. + #define OVR_CPP_CPP14_ENABLED 1 + #elif (__cplusplus > 201103L) + #define OVR_CPP_CPP14_ENABLED 1 + #else + // Leave undefined + #endif +#endif + + +//----------------------------------------------------------------------------------- +// ***** OVR_CPP_NO_EXCEPTIONS / OVR_CPP_NO_UNWIND +// +// OVR_CPP_NO_EXCEPTIONS is defined as 1 if the compiler doesn't support C++ +// exceptions or is configured to disable support for them. Else not defined. +// If OVR_CPP_NO_EXCEPTIONS is defined then attempts to use try/catch +// related C++ statements result in a compilation error with many +// compilers. +// +// OVR_CPP_NO_UNWIND is defined as 1 if the compiler supports exceptions but +// doesn't support stack unwinding in the presence of an exception. Else not defined. +// For the Microsoft compiler, disabling exceptions means disabling stack unwinding +// and not disabling exceptions themselves. +// +// Example usage: +// void Test() { +// #if !defined(OVR_CPP_NO_EXCEPTIONS) +// try { +// #endif +// void* ptr = new Object; +// #if !defined(OVR_CPP_NO_EXCEPTIONS) +// catch(...) { ... } +// #endif + +#if !defined(OVR_CPP_NO_EXCEPTIONS) + #if defined(OVR_CPP_GNUC) && defined(_NO_EX) + #define OVR_CPP_NO_EXCEPTIONS 1 + #elif (defined(OVR_CC_GNU) || defined(OVR_CC_CLANG) || defined(OVR_CC_INTEL) || defined(OVR_CC_ARM)) && !defined(__EXCEPTIONS) + #define OVR_CPP_NO_EXCEPTIONS 1 + #elif defined(OVR_CC_MSVC) && !defined(_CPPUNWIND) + #define OVR_CPP_NO_UNWIND 1 + #endif +#endif + + +//----------------------------------------------------------------------------------- +// ***** OVR_CPP_NO_RTTI +// +// Defined as 1 if C++ run-time type information support is unavailable or disabled +// by the compiler. Else undefined. Allows you to write portable code in the face +// of the possibility that RTTI is disabled. +// +// Example usage: +// #if !OVR_CPP_NO_RTTI +// #include +// int x = std::dynamic_cast(3.4f); +// #endif + +#if defined(__clang__) && !OVR_CC_HAS_FEATURE(cxx_rtti) + #define OVR_CPP_NO_RTTI 1 +#elif defined(__GNUC__) && !defined(__GXX_RTTI) + #define OVR_CPP_NO_RTTI 1 +#elif defined(_MSC_VER) && !defined(_CPPRTTI) + #define OVR_CPP_NO_RTTI 1 +#elif defined(__CC_ARM) && defined(__TARGET_CPU_MPCORE) && !defined(__RTTI) + #define OVR_CPP_NO_RTTI 1 +#endif + + +//----------------------------------------------------------------------------------- +// ***** OVR_CPP_NO_STATIC_ASSERT +// +// Defined as 1 if C++ run-time type information support is available and enabled +// by the compiler. Else undefined. +// +// Example usage: +// #if OVR_CPP_NO_STATIC_ASSERT +// #define MY_ASSERT(x) { int zero = 0; switch(zero) {case 0: case (x):;} } +// #else +// #define MY_ASSERT(x) static_assert((x), #x) +// #endif + +#if !defined(OVR_CPP_NO_STATIC_ASSERT) + #if !(defined(__GNUC__) && (defined(__GXX_EXPERIMENTAL_CXX0X__) || (defined(__cplusplus) && (__cplusplus >= 201103L)))) && \ + !(defined(__clang__) && defined(__cplusplus) && OVR_CC_HAS_FEATURE(cxx_static_assert)) && \ + !(defined(_MSC_VER) && (_MSC_VER >= 1600) && defined(__cplusplus)) && /* VS2010+ */ \ + !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 401) && defined(OVR_CPP11_ENABLED)) /* EDG 4.1+ */ + #define OVR_CPP_NO_STATIC_ASSERT 1 + #endif +#endif + + +//----------------------------------------------------------------------------------- +// ***** OVR_CPP_NO_NULLPTR +// +// Defined as 1 if the compiler doesn't support C++11 nullptr built in type. +// Otherwise undefined. Does not identify if the standard library defines +// std::nullptr_t, as some standard libraries are further behind in standardization +// than the compilers using them (e.g. Apple clang with the supplied libstdc++). +// +// OVR_Nullptr.h provides a portable nullptr and std::nullptr_t for when the +// compiler or standard library do not. + +#if !defined(OVR_CPP_NO_NULLPTR) + #if !defined(OVR_CPP11_ENABLED) || \ + (!(defined(__clang__) && OVR_CC_HAS_FEATURE(cxx_nullptr)) /* clang */ && \ + !(defined(__GNUC__) && (OVR_CC_VERSION >= 406)) /* GCC 4.6+ */ && \ + !(defined(_MSC_VER) && (_MSC_VER >= 1600)) /* VS2010+ */ && \ + !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 403))) /* EDG 4.3+ */ + #define OVR_CPP_NO_NULLPTR 1 + #endif +#endif + + +//----------------------------------------------------------------------------------- +// ***** OVR_CPP_NO_RVALUE_REFERENCES +// +// Defined as 1 if the compiler doesn't support C++11 rvalue references and move semantics. +// Otherwise undefined. + +#if !defined(OVR_CPP_NO_RVALUE_REFERENCES) + #if !defined(OVR_CPP11_ENABLED) || \ + (!(defined(__clang__) && OVR_CC_HAS_FEATURE(cxx_rvalue_references)) /* clang */ && \ + !(defined(__GNUC__) && (OVR_CC_VERSION >= 405)) /* GCC 4.5+ */ && \ + !(defined(_MSC_VER) && (_MSC_VER >= 1600)) /* VS2010+ */ && \ + !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 403))) /* EDG 4.3+ */ + #define OVR_CPP_NO_RVALUE_REFERENCES 1 + #endif +#endif + + +//----------------------------------------------------------------------------------- +// ***** OVR_CPP_NO_AUTO +// +// Defined as 1 if the compiler doesn't support C++11 auto keyword. Otherwise undefined. + +#if !defined(OVR_CPP_NO_AUTO) + #if !defined(OVR_CPP11_ENABLED) || \ + (!(defined(__clang__) && OVR_CC_HAS_FEATURE(cxx_auto_type)) /* clang */ && \ + !(defined(__GNUC__) && (OVR_CC_VERSION >= 404)) /* GCC 4.4+ */ && \ + !(defined(_MSC_VER) && (_MSC_VER >= 1600)) /* VS2010+ */ && \ + !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 309))) /* EDG 3.9+ */ + #define OVR_CPP_NO_AUTO 1 + #endif +#endif + + +//----------------------------------------------------------------------------------- +// ***** OVR_CPP_NO_RANGE_BASED_FOR_LOOP +// +// Defined as 1 if the compiler doesn't support C++11 range-based for loops. +// Otherwise undefined. + +#if !defined(OVR_CPP_NO_RANGE_BASED_FOR_LOOP) + #if !defined(OVR_CPP11_ENABLED) || \ + (!(defined(__clang__) && OVR_CC_HAS_FEATURE(cxx_range_for)) /* clang */ && \ + !(defined(__GNUC__) && (OVR_CC_VERSION >= 406)) /* GCC 4.6+ */ && \ + !(defined(_MSC_VER) && (_MSC_VER >= 1700)) /* VS2012+ */ && \ + !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 405))) /* EDG 4.5+ */ + #define OVR_CPP_NO_RANGE_BASED_FOR_LOOP 1 + #endif +#endif + + +//----------------------------------------------------------------------------------- +// ***** OVR_CPP_NO_CONSTEXPR / OVR_CPP_NO_RELAXED_CONSTEXPR +// +// OVR_CPP_NO_CONSTEXPR is defined as 1 if the compiler doesn't support C++11 constexpr. +// OVR_CPP_NO_RELAXED_CONSTEXPR is defined as 1 if the compiler doesn't support C++14 constexpr. +// Otherwise undefined. +// See the OVR_CONSTEXPR / OVR_CONSTEXPR_OR_CONST macros for portable wrappers of this functionality. + +#if !defined(OVR_CPP_NO_CONSTEXPR) + #if !defined(OVR_CPP11_ENABLED) || \ + (!(defined(__clang__) && OVR_CC_HAS_FEATURE(cxx_constexpr)) /* clang */ && \ + !(defined(__GNUC__) && (OVR_CC_VERSION >= 406)) /* GCC 4.6+ */ && \ + !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 406))) /* EDG 4.6+ */ + // Not supported by VC++ through at least VS2013. + #define OVR_CPP_NO_CONSTEXPR 1 + #endif +#endif + +#if !defined(OVR_CPP_NO_RELAXED_CONSTEXPR) + #if !defined(OVR_CPP14_ENABLED) || \ + !(defined(__clang__) && OVR_CC_HAS_FEATURE(cxx_relaxed_constexpr)) /* clang */ + // Supported only by clang as of this writing. + #define OVR_CPP_NO_RELAXED_CONSTEXPR 1 + #endif +#endif + + +//----------------------------------------------------------------------------------- +// ***** OVR_CPP_NO_LAMBDA_EXPRESSIONS +// +// Defined as 1 if the compiler doesn't support C++11 lambda expressions. Otherwise undefined. +// Some compilers have slightly crippled versions of this. + +#if !defined(OVR_CPP_NO_LAMBDA_EXPRESSIONS) + #if !defined(OVR_CPP11_ENABLED) || \ + (!(defined(__clang__) && OVR_CC_HAS_FEATURE(cxx_lambdas)) /* clang */ && \ + !(defined(__GNUC__) && (OVR_CC_VERSION >= 404)) /* GCC 4.4+ */ && \ + !(defined(_MSC_VER) && (_MSC_VER >= 1600)) /* VS2010+ */ && \ + !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 401))) /* EDG 4.1+ */ + // Conversion of lambdas to function pointers is not supported until EDG 4.5. + #define OVR_CPP_NO_LAMBDA_EXPRESSIONS 1 + #endif +#endif + + +//----------------------------------------------------------------------------------- +// ***** OVR_CPP_NO_ALIGNOF +// +// Defined as 1 if the compiler supports C++11 alignof. Otherwise undefined. +// Some compilers support __alignof__ instead of alignof, so for portability you +// should use OVR_ALIGNOF instead of directly using C++11 alignof. + +#if !defined(OVR_CPP_NO_ALIGNOF) + #if !defined(OVR_CPP11_ENABLED) || \ + (!(defined(__clang__) && !defined(__APPLE__) && (__clang__ >= 209)) /* clang 2.9+ */ && \ + !(defined(__clang__) && defined(__APPLE__) && (__clang__ >= 300)) /* Apple clang 3.0+ */ && \ + !(defined(__GNUC__) && (OVR_CC_VERSION >= 401)) /* GCC 4.1+ */ && \ + !(defined(_MSC_VER) && (_MSC_VER >= 1900)) /* VS2014+ */ && \ + !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 400))) /* EDG 4.0+ */ + #define OVR_CPP_NO_ALIGNOF 1 + #endif +#endif + + +//----------------------------------------------------------------------------------- +// ***** OVR_CPP_NO_ALIGNAS +// +// Defined as 1 if the compiler supports C++11 alignas. Otherwise undefined. +// See the OVR_ALIGNAS for a portable wrapper for alignas functionality. + +#if !defined(OVR_CPP_NO_ALIGNAS) + #if !defined(OVR_CPP11_ENABLED) || \ + (!(defined(__clang__) && !defined(__APPLE__) && (__clang__ >= 300)) /* clang 3.0+ */ && \ + !(defined(__clang__) && defined(__APPLE__) && (__clang__ >= 401)) /* Apple clang 4.1+ */ && \ + !(defined(__GNUC__) && (OVR_CC_VERSION >= 408)) /* GCC 4.8+ */ && \ + !(defined(_MSC_VER) && (_MSC_VER >= 1900)) /* VS2014+ */ && \ + !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 408))) /* EDG 4.8+ */ + #define OVR_CPP_NO_ALIGNAS 1 + #endif +#endif + + +//----------------------------------------------------------------------------------- +// ***** OVR_CPP_NO_OVERRIDE +// +// Defined as 1 if the compiler doesn't support C++11 override. Otherwise undefined. +// See the OVR_OVERRIDE and OVR_FINALOVERRIDE macros for a portable wrapper. + +#if !defined(OOVR_CPP_NO_OVERRIDE) + #if !defined(OVR_CPP11_ENABLED) || \ + (!(defined(__clang__) && !defined(__APPLE__) && (__clang__ >= 209)) /* clang 2.9+ */ && \ + !(defined(__clang__) && defined(__APPLE__) && (__clang__ >= 400)) /* Apple clang 4.0+ */ && \ + !(defined(__GNUC__) && (OVR_CC_VERSION >= 407)) /* GCC 4.7+ */ && \ + !(defined(_MSC_VER) && (_MSC_VER >= 1500)) /* VS2008+ */ && \ + !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 408))) /* EDG 4.8+ */ + #define OVR_CPP_NO_OVERRIDE 1 + #endif +#endif + + +//----------------------------------------------------------------------------------- +// ***** OVR_CPP_NO_FINAL +// +// Defined as 1 if the compiler doesn't support C++11 final attribute. Otherwise undefined. +// See the OVR_FINAL and OVR_FINALOVERRIDE macros for a portable wrapper. + +#if !defined(OOVR_CPP_NO_FINAL) + #if !defined(OVR_CPP11_ENABLED) || \ + (!(defined(__clang__) && !defined(__APPLE__) && (__clang__ >= 209)) /* clang 2.9+ */ && \ + !(defined(__clang__) && defined(__APPLE__) && (__clang__ >= 400)) /* Apple clang 4.0+ */ && \ + !(defined(__GNUC__) && (OVR_CC_VERSION >= 407)) /* GCC 4.7+ */ && \ + !(defined(_MSC_VER) && (_MSC_VER >= 1500)) /* VS2008+ */ && \ + !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 408))) /* EDG 4.8+ */ + #define OVR_CPP_NO_FINAL 1 + #endif +#endif + + +//----------------------------------------------------------------------------------- +// ***** OVR_CPP_NO_EXTERN_TEMPLATE +// +// Defined as 1 if the compiler doesn't support C++11 extern template. +// Otherwise undefined. See OVR_EXTERN_TEMPLATE for wrapper macro. + +#if !defined(OVR_CPP_NO_EXTERN_TEMPLATE) + #if !defined(OVR_CPP11_ENABLED) || \ + (!(defined(__clang__) && !defined(__APPLE__) && (__clang__ >= 209)) /* clang 2.9+ */ && \ + !(defined(__clang__) && defined(__APPLE__) && (__clang__ >= 401)) /* Apple clang 4.1+ */ && \ + !(defined(__GNUC__) && (OVR_CC_VERSION >= 406)) /* GCC 4.6+ */ && \ + !(defined(_MSC_VER) && (_MSC_VER >= 1700)) /* VS2012+ */ && \ + !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 401))) /* EDG 4.1+ */ + #define OVR_CPP_NO_EXTERN_TEMPLATE 1 + #endif +#endif + + +//----------------------------------------------------------------------------------- +// ***** OVR_CPP_NO_VARIADIC_TEMPLATES +// +// Defined as 1 if the compiler doesn't support C++11 variadic templates. Otherwise undefined. + +#if !defined(OVR_CPP_NO_VARIADIC_TEMPLATES) + #if !defined(OVR_CPP11_ENABLED) || \ + (!(defined(__clang__) && OVR_CC_HAS_FEATURE(cxx_variadic_templates)) /* clang */ && \ + !(defined(__GNUC__) && (OVR_CC_VERSION >= 404)) /* GCC 4.4+ */ && \ + !(defined(_MSC_VER) && (_MSC_VER >= 1800)) /* VS2013+ */ && \ + !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 403))) /* EDG 4.3+ */ + #define OVR_CPP_NO_VARIADIC_TEMPLATES 1 + #endif +#endif + + +//----------------------------------------------------------------------------------- +// ***** OVR_CPP_NO_NOEXCEPT +// +// Defined as 1 if the compiler supports C++11 noexcept. Otherwise undefined. +// http://en.cppreference.com/w/cpp/language/noexcept +// See OVR_NOEXCEPT / OVR_NOEXCEPT_IF / OVR_NOEXCEPT_EXPR for a portable wrapper +// for noexcept functionality. + +#if !defined(OVR_CPP_NO_NOEXCEPT) + #if !defined(OVR_CPP11_ENABLED) || \ + (!(defined(__clang__) && OVR_CC_HAS_FEATURE(cxx_noexcept)) /* clang */ && \ + !(defined(__GNUC__) && (OVR_CC_VERSION >= 406)) /* GCC 4.6+ */ && \ + !(defined(_MSC_VER) && (_MSC_VER >= 1900)) /* VS2014+ */ && \ + !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 405))) /* EDG 4.5+ */ + #define OVR_CPP_NO_NOEXCEPT 1 + #endif +#endif + + +//----------------------------------------------------------------------------------- +// ***** OVR_CPP_NO_DECLTYPE +// +// Defined as 1 if the compiler doesn't support C++11 decltype. Otherwise undefined. +// Some compilers (e.g. VS2012) support most uses of decltype but don't support +// decltype with incomplete types (which is an uncommon usage seen usually in +// template metaprogramming). We don't include this support as a requirement for +// our definition of decltype support here. + +#if !defined(OVR_CPP_NO_DECLTYPE) + #if !defined(OVR_CPP11_ENABLED) || \ + (!(defined(__clang__) && OVR_CC_HAS_FEATURE(cxx_decltype)) /* clang */ && \ + !(defined(__GNUC__) && (OVR_CC_VERSION >= 403)) /* GCC 4.3+ */ && \ + !(defined(_MSC_VER) && (_MSC_VER >= 1600)) /* VS2010+ */ && \ + !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 402))) /* EDG 4.2+ */ + // VC++ fails to support decltype for incomplete types until VS2013. + // EDG fails to support decltype for incomplete types until v4.8. + #define OVR_CPP_NO_DECLTYPE 1 + #endif +#endif + + +//----------------------------------------------------------------------------------- +// ***** OVR_CPP_NO_DEFAULTED_FUNCTIONS +// +// Defined as 1 if the compiler doesn't support C++11 defaulted functions. Otherwise undefined. +// Some compilers have slightly crippled versions of this. + +#if !defined(OVR_CPP_NO_DEFAULTED_FUNCTIONS) + #if !defined(OVR_CPP11_ENABLED) || \ + (!(defined(__clang__) && OVR_CC_HAS_FEATURE(cxx_defaulted_functions))/* clang */ && \ + !(defined(__GNUC__) && (OVR_CC_VERSION >= 404)) /* GCC 4.4+ */ && \ + !(defined(_MSC_VER) && (_MSC_VER >= 1800)) /* VS2013+ */ && \ + !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 401))) /* EDG 4.1+ */ + // Up through at least VS2013 it's unsupported for defaulted move constructors and move assignment operators. + // Until EDG 4.8 it's unsupported for defaulted move constructors and move assigment operators. + #define OVR_CPP_NO_DEFAULTED_FUNCTIONS 1 + #endif +#endif + + +//----------------------------------------------------------------------------------- +// ***** OVR_CPP_NO_DELETED_FUNCTIONS +// +// Defined as 1 if the compiler doesn't support C++11 deleted functions. Otherwise undefined. +// Some compilers have slightly crippled versions of this. + +#if !defined(OVR_CPP_NO_DELETED_FUNCTIONS) + #if !defined(OVR_CPP11_ENABLED) || \ + (!(defined(__clang__) && OVR_CC_HAS_FEATURE(cxx_defaulted_functions)) /* clang */ && \ + !(defined(__GNUC__) && (OVR_CC_VERSION >= 404)) /* GCC 4.4+ */ && \ + !(defined(_MSC_VER) && (_MSC_VER >= 1800)) /* VS2013+ */ && \ + !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 401))) /* EDG 4.1+ */ + // Up through at least VS2013 it's unsupported for defaulted move constructors and move assignment operators. + // Until EDG 4.8 it's unsupported for defaulted move constructors and move assigment operators. + #define OVR_CPP_NO_DELETED_FUNCTIONS 1 + #endif +#endif + + +//----------------------------------------------------------------------------------- +// ***** OVR_CPP_NO_STANDARD_LAYOUT_TYPES +// +// Defined as 1 if the compiler doesn't support C++11 standard layout (relaxed POD). Otherwise undefined. +// http://en.cppreference.com/w/cpp/types/is_standard_layout + +#if !defined(OVR_CPP_NO_STANDARD_LAYOUT_TYPES) + #if !defined(OVR_CPP11_ENABLED) || \ + (!(defined(__clang__) && !defined(__APPLE__) && (__clang__ >= 300)) /* clang 3.0+ */ && \ + !(defined(__clang__) && defined(__APPLE__) && (__clang__ >= 401)) /* Apple clang 4.1+ */ && \ + !(defined(__GNUC__) && (OVR_CC_VERSION >= 405)) /* GCC 4.5+ */ && \ + !(defined(_MSC_VER) && (_MSC_VER >= 1700)) /* VS2013+ */ && \ + !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 406))) /* EDG 4.6+ */ + #define OVR_CPP_NO_STANDARD_LAYOUT_TYPES 1 + #endif +#endif + + +//----------------------------------------------------------------------------------- +// ***** OVR_CPP_NO_FORWARD_DECLARED_ENUMS +// +// Defined as 1 if the compiler doesn't support C++11 forward declared enums. Otherwise undefined. + +#if !defined(OVR_CPP_NO_FORWARD_DECLARED_ENUMS) + #if !defined(OVR_CPP11_ENABLED) || \ + (!(defined(__clang__) && !defined(__APPLE__) && (__clang__ >= 301)) /* clang 3.1+ */ && \ + !(defined(__clang__) && defined(__APPLE__) && (__clang__ >= 401)) /* Apple clang 4.1+ */ && \ + !(defined(__GNUC__) && (OVR_CC_VERSION >= 406)) /* GCC 4.6+ */ && \ + !(defined(_MSC_VER) && (_MSC_VER >= 1700)) /* VS2012+ */ && \ + !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 405))) /* EDG 4.5+ */ + #define OVR_CPP_NO_FORWARD_DECLARED_ENUMS 1 + #endif +#endif + + +//----------------------------------------------------------------------------------- +// ***** OVR_CPP_NO_STRONGLY_TYPED_ENUMS +// +// Defined as 1 if the compiler doesn't support C++11 strongly typed enums. Otherwise undefined. + +#if !defined(OVR_CPP_NO_STRONGLY_TYPED_ENUMS) + #if !defined(OVR_CPP11_ENABLED) || \ + (!(defined(__clang__) && OVR_CC_HAS_FEATURE(cxx_strong_enums)) /* clang */ && \ + !(defined(__GNUC__) && (OVR_CC_VERSION >= 404)) /* GCC 4.4+ */ && \ + !(defined(_MSC_VER) && (_MSC_VER >= 1700)) /* VS2012+ */ && \ + !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 400))) /* EDG 4.0+ */ + #define OVR_CPP_NO_STRONGLY_TYPED_ENUMS 1 + #endif +#endif + + +//----------------------------------------------------------------------------------- +// ***** OVR_CPP_NO_TRAILING_RETURN_TYPES +// +// Defined as 1 if the compiler doesn't support C++11 trailing return types. Otherwise undefined. +// http://en.wikipedia.org/wiki/C%2B%2B11#Alternative_function_syntax + +#if !defined(OVR_CPP_NO_TRAILING_RETURN_TYPES) + #if !defined(OVR_CPP11_ENABLED) || \ + (!(defined(__clang__) && OVR_CC_HAS_FEATURE(cxx_trailing_return)) /* clang */ && \ + !(defined(__GNUC__) && (OVR_CC_VERSION >= 404)) /* GCC 4.4+ */ && \ + !(defined(_MSC_VER) && (_MSC_VER >= 1600)) /* VS2010+ */ && \ + !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 401))) /* EDG 4.1+ */ + #define OVR_CPP_NO_TRAILING_RETURN_TYPES 1 + #endif +#endif + + +//----------------------------------------------------------------------------------- +// ***** OVR_CPP_NO_TEMPLATE_ALIASES +// +// Defined as 1 if the compiler doesn't support C++11 template aliases. Otherwise undefined. + +#if !defined(OVR_CPP_NO_TEMPLATE_ALIASES) + #if !defined(OVR_CPP11_ENABLED) || \ + (!(defined(__clang__) && OVR_CC_HAS_FEATURE(cxx_alias_templates)) /* clang */ && \ + !(defined(__GNUC__) && (OVR_CC_VERSION >= 407)) /* GCC 4.7+ */ && \ + !(defined(_MSC_VER) && (_MSC_VER >= 1800)) /* VS2013+ */ && \ + !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 402))) /* EDG 4.2+ */ + #define OVR_CPP_NO_TEMPLATE_ALIASES 1 + #endif +#endif + + +//----------------------------------------------------------------------------------- +// ***** OVR_CPP_NO_INITIALIZER_LISTS +// +// Defined as 1 if the compiler doesn't support C++11 initializer lists. Otherwise undefined. +// This refers to the compiler support for this and not the Standard Library support for std::initializer_list, +// as a new compiler with an old standard library (e.g. Apple clang with libstdc++) may not support std::initializer_list. + +#if !defined(OVR_CPP_NO_INITIALIZER_LISTS) + #if !defined(OVR_CPP11_ENABLED) || \ + (!(defined(__clang__) && OVR_CC_HAS_FEATURE(cxx_generalized_initializers)) /* clang */ && \ + !(defined(__GNUC__) && (OVR_CC_VERSION >= 404)) /* GCC 4.4+ */ && \ + !(defined(_MSC_VER) && (_MSC_VER >= 1800)) /* VS2013+ */ && \ + !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 405))) /* EDG 4.5+ */ + #define OVR_CPP_NO_INITIALIZER_LISTS 1 + #endif +#endif + + +//----------------------------------------------------------------------------------- +// ***** OVR_CPP_NO_NORETURN +// +// Defined as 1 if the compiler doesn't support the C++11 noreturn attribute. Otherwise undefined. +// http://en.cppreference.com/w/cpp/language/attributes +// +#if !defined(OVR_CPP_NO_NORETURN) + #if !defined(OVR_CPP11_ENABLED) || \ + (!(defined(__clang__) && !defined(__APPLE__) && (__clang__ >= 301)) /* clang 3.1+ */ && \ + !(defined(__clang__) && defined(__APPLE__) && (__clang__ >= 401)) /* Apple clang 4.1+ */ && \ + !(defined(__GNUC__) && (OVR_CC_VERSION >= 408)) /* GCC 4.8+ */ && \ + !(defined(_MSC_VER) && (_MSC_VER >= 1500)) /* VS2008+ */ && \ + !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 402))) /* EDG 4.2+ */ + // Supported with VC++ only via __declspec(noreturn) (see OVR_NORETURN). + #define OVR_CPP_NO_NORETURN 1 + #endif +#endif + + +//----------------------------------------------------------------------------------- +// ***** OVR_CPP_NO_NONSTATIC_MEMBER_INITIALIZERS +// +// Defined as 1 if the compiler doesn't support C++11 in-class non-static member initializers. Otherwise undefined. +// http://en.cppreference.com/w/cpp/language/data_members + +#if !defined(OVR_CPP_NO_NONSTATIC_MEMBER_INITIALIZERS) + #if !defined(OVR_CPP11_ENABLED) || \ + (!(defined(__clang__) && !defined(__APPLE__) && (__clang__ >= 301)) /* clang 3.1+ */ && \ + !(defined(__clang__) && defined(__APPLE__) && (__clang__ >= 401)) /* Apple clang 4.1+ */ && \ + !(defined(__GNUC__) && (OVR_CC_VERSION >= 407)) /* GCC 4.7+ */ && \ + !(defined(_MSC_VER) && (_MSC_VER >= 1800)) /* VS2013+ */ && \ + !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 406))) /* EDG 4.6+ */ + #define OVR_CPP_NO_NONSTATIC_MEMBER_INITIALIZERS 1 + #endif +#endif + + +//----------------------------------------------------------------------------------- +// ***** OVR_CPP_NO_DOUBLE_TEMPLATE_BRACKETS +// +// Defined as 1 if the compiler supports nested template declarations with >>, +// as supported by C++11. Otherwise undefined. + +#if !defined(OVR_CPP_NO_DOUBLE_TEMPLATE_ANGLE_BRACKETS) + #if !defined(OVR_CPP11_ENABLED) || \ + (!(defined(__clang__) && !defined(__APPLE__) && (__clang__ >= 209)) /* clang 2.9+ */ && \ + !(defined(__clang__) && defined(__APPLE__) && (__clang__ >= 400)) /* Apple clang 4.0+ */ && \ + !(defined(__GNUC__) && (OVR_CC_VERSION >= 403)) /* GCC 4.3+ */ && \ + !(defined(_MSC_VER) && (_MSC_VER >= 1600)) /* VS2010+ */ && \ + !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 401))) /* EDG 4.1+ */ + #define OVR_CPP_NO_DOUBLE_TEMPLATE_BRACKETS 1 + #endif +#endif + + + +//----------------------------------------------------------------------------------- +// ***** OVR_CPP_NO_INHERITING_CONSTRUCTORS +// +// Defined as 1 if the compiler supports C++11 inheriting constructors. Otherwise undefined. +// Example usage: +// struct A { explicit A(int x){} }; +// struct B : public A { using A::A; }; // As if B redeclared A::A(int). + +#if !defined(OVR_CPP_NO_INHERITING_CONSTRUCTORS) + #if !defined(OVR_CPP11_ENABLED) || \ + (!(defined(__clang__) && OVR_CC_HAS_FEATURE(cxx_inheriting_constructors)) /* clang */ && \ + !(defined(__GNUC__) && (OVR_CC_VERSION >= 408)) /* GCC 4.8+ */ && \ + !(defined(_MSC_VER) && (_MSC_VER >= 1900)) /* VS2014+ */ && \ + !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 408))) /* EDG 4.8+ */ + #define OVR_CPP_NO_INHERITING_CONSTRUCTORS 1 + #endif +#endif + + +//----------------------------------------------------------------------------------- +// ***** OVR_CPP_NO_DELEGATING_CONSTRUCTORS +// +// Defined as 1 if the compiler supports C++11 delegating constructors. Otherwise undefined. + +#if !defined(OVR_CPP_NO_DELEGATING_CONSTRUCTORS) + #if !defined(OVR_CPP11_ENABLED) || \ + (!(defined(__clang__) && !defined(__APPLE__) && (__clang__ >= 300)) /* clang 3.0+ */ && \ + !(defined(__clang__) && defined(__APPLE__) && (__clang__ >= 401)) /* Apple clang 4.1+ */ && \ + !(defined(__GNUC__) && (OVR_CC_VERSION >= 407)) /* GCC 4.7+ */ && \ + !(defined(_MSC_VER) && (_MSC_VER >= 1800)) /* VS2013+ */ && \ + !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 407))) /* EDG 4.7+ */ + #define OVR_CPP_NO_DELEGATING_CONSTRUCTORS 1 + #endif +#endif + + +//----------------------------------------------------------------------------------- +// ***** OVR_CPP_NO_FUNCTION_TEMPLATE_DEFAULT_ARGS +// +// Defined as 1 if the compiler supports C++11 function template default arguments. Otherwise undefined. + +#if !defined(OVR_CPP_NO_FUNCTION_TEMPLATE_DEFAULT_ARGS) + #if !defined(OVR_CPP11_ENABLED) || \ + (!(defined(__clang__) && !defined(__APPLE__) && (__clang__ >= 209)) /* clang 2.9+ */ && \ + !(defined(__clang__) && defined(__APPLE__) && (__clang__ >= 401)) /* Apple clang 4.0+ */ && \ + !(defined(__GNUC__) && (OVR_CC_VERSION >= 403)) /* GCC 4.3+ */ && \ + !(defined(_MSC_VER) && (_MSC_VER >= 1800)) /* VS2013+ */ && \ + !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 403))) /* EDG 4.3+ */ + #define OVR_CPP_NO_FUNCTION_TEMPLATE_DEFAULT_ARGS 1 + #endif +#endif + + +//----------------------------------------------------------------------------------- +// ***** OVR_CPP_NO_UNRESTRICTED_UNIONS +// +// Defined as 1 if the compiler supports C++11 unrestricted unions. Otherwise undefined. + +#if !defined(OVR_CPP_NO_UNRESTRICTED_UNIONS) + #if !defined(OVR_CPP11_ENABLED) || \ + (!(defined(__clang__) && !defined(__APPLE__) && (__clang__ >= 301)) /* clang 3.1+ */ && \ + !(defined(__clang__) && defined(__APPLE__) && (__clang__ >= 401)) /* Apple clang 4.1+ */ && \ + !(defined(__GNUC__) && (OVR_CC_VERSION >= 406)) /* GCC 4.6+ */ && \ + !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 406))) /* EDG 4.6+ */ + // Not supported by VC++ as of VS2013. + #define OVR_CPP_NO_UNRESTRICTED_UNIONS 1 + #endif +#endif + + + +//----------------------------------------------------------------------------------- +// ***** OVR_CPP_NO_EXTENDED_SIZEOF +// +// Defined as 1 if the compiler supports C++11 class sizeof extensions (e.g. sizeof SomeClass::someMember). +// Otherwise undefined. + +#if !defined(OVR_CPP_NO_EXTENDED_SIZEOF) + #if !defined(OVR_CPP11_ENABLED) || \ + (!(defined(__clang__) && !defined(__APPLE__) && (__clang__ >= 301)) /* clang 3.1+ */ && \ + !(defined(__clang__) && defined(__APPLE__) && (__clang__ >= 401)) /* Apple clang 4.1+ */ && \ + !(defined(__GNUC__) && (OVR_CC_VERSION >= 405)) /* GCC 4.5+ */ && \ + !(defined(_MSC_VER) && (_MSC_VER >= 1900)) /* VS2014+ */ && \ + !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 405))) /* EDG 4.5+ */ + #define OVR_CPP_NO_EXTENDED_SIZEOF 1 + #endif +#endif + + +//----------------------------------------------------------------------------------- +// ***** OVR_CPP_NO_INLINE_NAMESPACES +// +// Defined as 1 if the compiler supports C++11 inlined namespaces. Otherwise undefined. +// http://en.cppreference.com/w/cpp/language/namespace#Inline_namespaces + +#if !defined(OVR_CPP_NO_INLINE_NAMESPACES) + #if !defined(OVR_CPP11_ENABLED) || \ + (!(defined(__clang__) && !defined(__APPLE__) && (__clang__ >= 209)) /* clang 2.9+ */ && \ + !(defined(__clang__) && defined(__APPLE__) && (__clang__ >= 400)) /* Apple clang 4.0+ */ && \ + !(defined(__GNUC__) && (OVR_CC_VERSION >= 404)) /* GCC 4.4+ */ && \ + !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 405))) /* EDG 4.5+ */ + // Not supported by VC++ as of VS2013. + #define OVR_CPP_NO_INLINE_NAMESPACES 1 + #endif +#endif + + +//----------------------------------------------------------------------------------- +// ***** OVR_CPP_NO_EXPLICIT_CONVERSION_OPERATORS +// +// Defined as 1 if the compiler supports C++11 explicit conversion operators. Otherwise undefined. +// http://en.cppreference.com/w/cpp/language/explicit + +#if !defined(OVR_CPP_NO_EXPLICIT_CONVERSION_OPERATORS) + #if !defined(OVR_CPP11_ENABLED) || \ + (!(defined(__clang__) && OVR_CC_HAS_FEATURE(cxx_explicit_conversions)) /* clang */ && \ + !(defined(__GNUC__) && (OVR_CC_VERSION >= 405)) /* GCC 4.5+ */ && \ + !(defined(_MSC_VER) && (_MSC_VER >= 1800)) /* VS2013+ */ && \ + !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 404))) /* EDG 4.4+ */ + #define OVR_CPP_NO_EXPLICIT_CONVERSION_OPERATORS 1 + #endif +#endif + + +//----------------------------------------------------------------------------------- +// ***** OVR_CPP_NO_LOCAL_CLASS_TEMPLATE_PARAMETERS +// +// Defined as 1 if the compiler supports C++11 local class template parameters. Otherwise undefined. +// Example: +// void Test() { +// struct LocalClass{ }; +// SomeTemplateClass t; // Allowed only in C++11 +// } + +#if !defined(OVR_CPP_NO_LOCAL_CLASS_TEMPLATE_PARAMETERS) + #if !defined(OVR_CPP11_ENABLED) || \ + (!(defined(__clang__) && OVR_CC_HAS_FEATURE(cxx_local_type_template_args)) /* clang */ && \ + !(defined(__GNUC__) && (OVR_CC_VERSION >= 405)) /* GCC 4.5+ */ && \ + !(defined(_MSC_VER) && (_MSC_VER >= 1600)) /* VS2010+ */ && \ + !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 402))) /* EDG 4.2+ */ + #define OVR_CPP_NO_LOCAL_CLASS_TEMPLATE_PARAMETERS 1 + #endif +#endif + + +//----------------------------------------------------------------------------------- +// ***** OVR_CPP_NO_NEW_CHARACTER_TYPES +// +// Defined as 1 if the compiler natively supports C++11 char16_t and char32_t. Otherwise undefined. +// VC++ through at least VS2013 defines char16_t as unsigned short in its standard library, +// but it is not a native type or unique type, nor can you for a string literal with it. + +#if !defined(OVR_CPP_NO_NEW_CHARACTER_TYPES) + #if !defined(OVR_CPP11_ENABLED) || \ + (!(defined(__clang__) && OVR_CC_HAS_FEATURE(cxx_unicode_literals)) /* clang */ && \ + !(defined(__GNUC__) && (OVR_CC_VERSION >= 404)) /* GCC 4.4+ */ && \ + !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 407))) /* EDG 4.7+ */ + // Not supported by VC++ as of VS2013. + #define OVR_CPP_NO_NEW_CHARACTER_TYPES 1 + #endif +#endif + + +//----------------------------------------------------------------------------------- +// ***** OVR_CPP_NO_UNICODE_CHAR_NAME_LITERALS +// +// Defined as 1 if the compiler supports C++11 \u and \U character literals for +// native char16_t and char32_t types. +// +#if !defined(OVR_CPP_NO_UNICODE_CHAR_NAME_LITERALS) + #if !defined(OVR_CPP11_ENABLED) || \ + (!(defined(__clang__) && !defined(__APPLE__) && (__clang__ >= 301)) /* clang 3.1+ */ && \ + !(defined(__clang__) && defined(__APPLE__) && (__clang__ >= 401)) /* Apple clang 4.1+ */ && \ + !(defined(__GNUC__) && (OVR_CC_VERSION >= 405)) /* GCC 4.5+ */ && \ + !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 408))) /* EDG 4.8+ */ + // Not supported by VC++ as of VS2013. VC++'s existing \U and \u are non-conforming. + #define OVR_CPP_NO_UNICODE_CHAR_NAME_LITERALS 1 + #endif +#endif + + +//----------------------------------------------------------------------------------- +// ***** OVR_CPP_NO_USER_DEFINED_LITERALS +// +// Defined as 1 if the compiler supports C++11 user-defined literals. Otherwise undefined. + +#if !defined(OVR_CPP_NO_USER_DEFINED_LITERALS) + #if !defined(OVR_CPP11_ENABLED) || \ + (!(defined(__clang__) && !defined(__APPLE__) && (__clang__ >= 301)) /* clang 3.1+ */ && \ + !(defined(__clang__) && defined(__APPLE__) && (__clang__ >= 401)) /* Apple clang 4.1+ */ && \ + !(defined(__GNUC__) && (OVR_CC_VERSION >= 407)) /* GCC 4.7+ */ && \ + !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 408))) /* EDG 4.8+ */ + // Not supported by VC++ as of VS2013. + #define OVR_CPP_NO_USER_DEFINED_LITERALS 1 + #endif +#endif + + +//----------------------------------------------------------------------------------- +// ***** OVR_CPP_NO_UNICODE_STRING_LITERALS +// +// Defined as 1 if the compiler supports C++11 Unicode string literals. Otherwise undefined. +// http://en.wikipedia.org/wiki/C%2B%2B11#New_string_literals + +#if !defined(OVR_CPP_NO_UNICODE_STRING_LITERALS) + #if !defined(OVR_CPP11_ENABLED) || \ + (!(defined(__clang__) && OVR_CC_HAS_FEATURE(cxx_unicode_literals)) /* clang */ && \ + !(defined(__GNUC__) && (OVR_CC_VERSION >= 404)) /* GCC 4.4+ */ && \ + !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 407))) /* EDG 4.7+ */ + // Not supported by VC++ as of VS2013. + #define OVR_CPP_NO_UNICODE_STRING_LITERALS 1 + #endif +#endif + + +//----------------------------------------------------------------------------------- +// ***** OVR_CPP_NO_RAW_STRING_LITERALS +// +// Defined as 1 if the compiler supports C++11 raw literals. Otherwise undefined. +// http://en.wikipedia.org/wiki/C%2B%2B11#New_string_literals + +#if !defined(OVR_CPP_NO_RAW_STRING_LITERALS) + #if !defined(OVR_CPP11_ENABLED) || \ + (!(defined(__clang__) && OVR_CC_HAS_FEATURE(cxx_raw_string_literals)) /* clang */ && \ + !(defined(__GNUC__) && (OVR_CC_VERSION >= 405)) /* GCC 4.5+ */ && \ + !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 407))) /* EDG 4.7+ */ + // Not supported by VC++ as of VS2013. + #define OVR_CPP_NO_RAW_STRING_LITERALS 1 + #endif +#endif + + +//----------------------------------------------------------------------------------- +// ***** OVR_CPP_NO_UNIFIED_INITIALIZATION_SYNTAX +// +// Defined as 1 if the compiler supports C++11 unified initialization. +// http://en.wikipedia.org/wiki/C%2B%2B11#Uniform_initialization + +#if !defined(OVR_CPP_NO_UNIFIED_INITIALIZATION_SYNTAX) + #if !defined(OVR_CPP11_ENABLED) || \ + (!(defined(__clang__) && OVR_CC_HAS_FEATURE(cxx_generalized_initializers)) /* clang */ && \ + !(defined(__GNUC__) && (OVR_CC_VERSION >= 404)) /* GCC 4.4+ */ && \ + !(defined(_MSC_VER) && (_MSC_VER >= 1800)) /* VS2013+ */ && \ + !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 406))) /* EDG 4.6+ */ + #define OVR_CPP_NO_UNIFIED_INITIALIZATION_SYNTAX 1 + #endif +#endif + + +//----------------------------------------------------------------------------------- +// ***** OVR_CPP_NO_EXTENDED_FRIEND_DECLARATIONS +// +// Defined as 1 if the compiler supports C++11 extended friends. + +#if !defined(OVR_CPP_NO_EXTENDED_FRIEND_DECLARATIONS) + #if !defined(OVR_CPP11_ENABLED) || \ + (!(defined(__clang__) && !defined(__APPLE__) && (__clang__ >= 209)) /* clang 2.9+ */ && \ + !(defined(__clang__) && defined(__APPLE__) && (__clang__ >= 400)) /* Apple clang 4.0+ */ && \ + !(defined(__GNUC__) && (OVR_CC_VERSION >= 407)) /* GCC 4.7+ */ && \ + !(defined(_MSC_VER) && (_MSC_VER >= 1600)) /* VS2010+ */ && \ + !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 401))) /* EDG 4.1+ */ + #define OVR_CPP_NO_EXTENDED_FRIEND_DECLARATIONS 1 + #endif +#endif + + +//----------------------------------------------------------------------------------- +// ***** OVR_CPP_NO_THREAD_LOCAL +// +// Defined as 1 if the compiler supports C++11 thread_local. Else undefined. Does not +// indicate if the compiler supports C thread-local compiler extensions such as __thread +// and declspec(thread). Use OVR_THREAD_LOCAL if you want to declare a thread-local +// variable that supports C++11 thread_local when available but the C extension when +// it's available. The primary difference between C++11 thread_local and C extensions is +// that C++11 thread_local supports non-PODs and calls their constructors and destructors. +// +// Note that thread_local requires both compiler and linker support, and so it's possible +// that the compiler may support thread_local but the linker does not. + +#if !defined(OVR_CPP_NO_THREAD_LOCAL) + #if !defined(OVR_CPP11_ENABLED) || \ + (!(defined(__clang__) && OVR_CC_HAS_FEATURE(cxx_thread_local)) /* clang */ && \ + !(defined(__GNUC__) && (OVR_CC_VERSION >= 408)) /* GCC 4.8+ */ && \ + !(defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 408))) /* EDG 4.8+ */ + #define OVR_CPP_NO_THREAD_LOCAL 1 + #endif +#endif + + +// ----------------------------------------------------------------------------------- +// ***** OVR_ALIGNAS / OVR_ALIGNOF +// +// OVR_ALIGNAS(n) // Specifies a size_t power of two alignment for a type or instance. +// OVR_ALIGNOF(type) // Returns the size_t alignment of a type or instance. +// +// Example usage: +// OVR_ALIGNAS(8) char c = 'c'; // Specifies that the instance c be aligned to an 8 byte boundary. +// typedef OVR_ALIGNAS(8) char C; // Specifies that the type C be aligned to an 8 byte boundary. +// struct OVR_ALIGNAS(64) S{ char array[16]; }; // Specfies that the struct S have a natural alignment of 64. +// OVR_ALIGNAS(32) S s; // Specifies that the instance s of struct S be aligned to an 32 byte boundary. +// OVR_ALIGNAS(32) struct T{ char array[16]; } t; // Specfies that the instance t of struct T have a natural alignment of 32. +// struct OVR_ALIGNAS(T) U{}; // Specifes that U be aligned the same as T. Supported only by C++11 compilers (see OVR_CPP_NO_ALIGNAS). +// +// size_t a = OVR_ALIGNOF(double); // Returns the natural alignment of the double type. +// size_t a = OVR_ALIGNOF(S); // Returns the natural alignment of the struct S type. +// +// Note: If C++11 alignas is supported, then alignas/OVR_ALIGNAS may take a const expression in addition to a constant. +// Note: The C11 Standard species the _Alignas keyword and alignas as a macro for it in + +#if !defined(OVR_ALIGNAS) + #if defined(OVR_CC_GNU) && !defined(OVR_CPP_NO_ALIGNAS) // If C++11 alignas is supported... + #define OVR_ALIGNAS(n) alignas(n) + #elif defined(__clang__) && !defined(OVR_CPP_NO_ALIGNAS) + #define OVR_ALIGNAS(n) alignas(n) + #elif defined(OVR_CC_GNU) || defined(__clang__) + #define OVR_ALIGNAS(n) __attribute__((aligned(n))) + #elif defined(OVR_CC_MSVC) || defined(OVR_CC_INTEL) + #define OVR_ALIGNAS(n) __declspec(align(n)) // For Microsoft the alignment must be a literal integer. + #elif defined(OVR_CC_ARM) + #define OVR_ALIGNAS(n) __align(n) + #else + #error Need to define OVR_ALIGNAS + #endif +#endif + +#if !defined(OVR_ALIGNOF) + #if defined(OVR_CC_GNU) && !defined(OVR_CPP_NO_ALIGNOF) // If C++11 alignof is supported... + #define OVR_ALIGNOF(type) alignof(type) + #elif defined(__clang__) && !defined(OVR_CPP_NO_ALIGNOF) + #define OVR_ALIGNOF(type) alignof(type) + #elif defined(OVR_CC_GNU) || defined(__clang__) + #define OVR_ALIGNOF(type) ((size_t)__alignof__(type)) + #elif defined(OVR_CC_MSVC) || defined(OVR_CC_INTEL) + #define OVR_ALIGNOF(type) ((size_t)__alignof(type)) + #elif defined(OVR_CC_ARM) + #define OVR_ALIGNOF(type) ((size_t)__ALIGNOF__(type)) + #else + #error Need to define OVR_ALIGNOF + #endif +#endif + + +// ----------------------------------------------------------------------------------- +// ***** OVR_ASSUME / OVR_ANALYSIS_ASSUME +// +// This is a portable wrapper for VC++'s __assume and __analysis_assume. +// __analysis_assume is typically used to quell VC++ static analysis warnings. +// +// Example usage: +// void Test(char c){ +// switch(c){ +// case 'a': +// case 'b': +// case 'c': +// case 'd': +// break; +// default: +// OVR_ASSUME(0); // Unreachable code. +// } +// } +// +// size_t Test(char* str){ +// OVR_ANALYSIS_ASSUME(str != nullptr); +// return strlen(str); +// } + +#if !defined(OVR_ASSUME) + #if defined(OVR_CC_MSVC) + #define OVR_ASSUME(x) __assume(x) + #define OVR_ANALYSIS_ASSUME(x) __analysis_assume(!!(x)) + #else + #define OVR_ASSUME(x) + #define OVR_ANALYSIS_ASSUME(x) + #endif +#endif + + +// ----------------------------------------------------------------------------------- +// ***** OVR_RESTRICT +// +// Wraps the C99 restrict keyword in a portable way. +// C++11 and C++14 don't have restrict but this functionality is supported by +// all C++ compilers. +// +// Example usage: +// void* memcpy(void* OVR_RESTRICT s1, const void* OVR_RESTRICT s2, size_t n); + +#if !defined(OVR_RESTRICT) + #define OVR_RESTRICT __restrict // Currently supported by all compilers of significance to us. +#endif + + +// ----------------------------------------------------------------------------------- +// ***** OVR_NOEXCEPT / OVR_NOEXCEPT_IF(predicate) / OVR_NOEXCEPT_EXPR(expression) +// +// Implements a portable wrapper for C++11 noexcept. +// http://en.cppreference.com/w/cpp/language/noexcept +// +// Example usage: +// void Test() OVR_NOEXCEPT {} // This function doesn't throw. +// +// template +// void DoNothing() OVR_NOEXCEPT_IF(OVR_NOEXCEPT_EXPR(T())) // Throws an if and only if T::T(int) throws. +// { T t(3); } +// +#if !defined(OVR_NOEXCEPT) + #if defined(OVR_CPP_NOEXCEPT) + #define OVR_NOEXCEPT + #define OVR_NOEXCEPT_IF(predicate) + #define OVR_NOEXCEPT_EXPR(expression) false + #else + #define OVR_NOEXCEPT noexcept + #define OVR_NOEXCEPT_IF(predicate) noexcept((predicate)) + #define OVR_NOEXCEPT_EXPR(expression) noexcept((expression)) + #endif +#endif + + +// ----------------------------------------------------------------------------------- +// ***** OVR_FINAL +// +// Wraps the C++11 final keyword in a portable way. +// http://en.cppreference.com/w/cpp/language/final +// +// Example usage: +// struct Test { virtual int GetValue() OVR_FINAL; }; + +#if !defined(OVR_FINAL) + #if defined(OVR_CC_MSVC) && (OVR_CC_VERSION < 1700) // VC++ 2012 and earlier + #define OVR_FINAL sealed + #elif defined(OVR_CPP_INHERITANCE_FINAL) + #define OVR_FINAL + #else + #define OVR_FINAL final + #endif +#endif + + +// ----------------------------------------------------------------------------------- +// ***** OVR_OVERRIDE +// +// Wraps the C++11 override keyword in a portable way. +// http://en.cppreference.com/w/cpp/language/override +// +// Example usage: +// struct Parent { virtual void Func(int); }; +// struct Child : public Parent { void Func(int) OVR_OVERRIDE; }; + +#if !defined(OVR_CPP11_ENABLED) +#define OVR_OVERRIDE +#elif !defined(OVR_OVERRIDE) + #if defined(OVR_CPP_OVERRIDE) + #define OVR_OVERRIDE + #else + #if (defined(_MSC_VER) && (_MSC_VER <= 1600)) + #pragma warning(disable : 4481) + #endif + #define OVR_OVERRIDE override + #endif +#endif + + +// ----------------------------------------------------------------------------------- +// ***** OVR_FINAL_OVERRIDE +// +// Wraps the C++11 final+override keywords (a common combination) in a portable way. +// +// Example usage: +// struct Parent { virtual void Func(); }; +// struct Child : public Parent { virtual void Func() OVR_FINAL_OVERRIDE; }; + +#if !defined(OVR_FINAL_OVERRIDE) + #define OVR_FINAL_OVERRIDE OVR_FINAL OVR_OVERRIDE +#endif + + +// ----------------------------------------------------------------------------------- +// ***** OVR_EXTERN_TEMPLATE +// +// Portable wrapper for C++11 extern template. This tells the compiler to not instantiate +// the template in the current translation unit, which can significantly speed up +// compilation and avoid problems due to two translation units compiling code with +// different settings. +// +// Example usage: +// OVR_EXTERN_TEMPLATE(class basic_string); // Nothing to do for non-C++11 compilers. + +#if !defined(OVR_EXTERN_TEMPLATE) + #if defined(OVR_CPP_EXTERN_TEMPLATE) + #define OVR_EXTERN_TEMPLATE(decl) + #else + #define OVR_EXTERN_TEMPLATE(decl) extern template decl + #endif +#endif + + +// ----------------------------------------------------------------------------------- +// ***** OVR_CONSTEXPR / OVR_CONSTEXPR_OR_CONST +// +// Portable wrapper for C++11 constexpr. Doesn't include C++14 relaxed constexpr, +// for which a different wrapper name is reserved. +// +// Example usage: +// OVR_CONSTEXPR int Test() { return 15; } // This can be optimized better by a C++11 compiler that supports constexpr. +// OVR_CONSTEXPR_OR_CONST float x = 3.14159f; // This can be optimized better by a C++11 compiler, but if not then at least make it const. + +#if !defined(OVR_CONSTEXPR) + #if defined(OVR_CPP_NO_CONSTEXPR) + #define OVR_CONSTEXPR + #else + #define OVR_CONSTEXPR constexpr + #endif +#endif + +#if !defined(OVR_CONSTEXPR_OR_CONST) + #if defined(OVR_CPP_NO_CONSTEXPR) + #define OVR_CONSTEXPR_OR_CONST const + #else + #define OVR_CONSTEXPR_OR_CONST constexpr + #endif +#endif + + + +// ----------------------------------------------------------------------------------- +// ***** OVR_FUNCTION_DELETE / OVR_FUNCTION_DEFAULT +// +// Wraps the C++11 delete and default keywords in a way that allows for cleaner code +// while making for a better version of uncallable or default functions. +// +// Example usage: +// struct Test{ +// Test() OVR_FUNCTION_DEFAULT; // Non-C++11 compilers will require a separate definition for Test(). +// private: // Users should put OVR_FUNCTION_DELETE usage in a private +// void Uncallable() OVR_FUNCTION_DELETE; // area for compatibility with pre-C++11 compilers. +// }; + +#if defined(OVR_CPP_NO_DELETED_FUNCTIONS) + #define OVR_FUNCTION_DELETE +#else + #define OVR_FUNCTION_DELETE = delete +#endif + +#if defined(OVR_CPP_NO_DEFAULTED_FUNCTIONS) + #define OVR_FUNCTION_DEFAULT +#else + #define OVR_FUNCTION_DEFAULT = default +#endif + + + +// ----------------------------------------------------------------------------------- +// ***** OVR_NON_COPYABLE +// +// Allows you to specify a class as being neither copy-constructible nor assignable, +// which is a commonly needed pattern in C++ programming. Classes with this declaration +// are required to be default constructible (as are most classes). For pre-C++11 +// compilers this macro declares a private section for the class, which will be +// inherited by whatever code is directly below the macro invocation by default. +// +// Example usage: +// struct Test { +// Test(); +// ... +// OVR_NON_COPYABLE(Test) +// }; + +#if !defined(OVR_NON_COPYABLE) + #if defined(OVR_CPP_NO_DELETED_FUNCTIONS) + #define OVR_NON_COPYABLE(Type) \ + private: \ + Type(const Type&); \ + void operator=(const Type&); + #else + #define OVR_NON_COPYABLE(Type) \ + Type(const Type&) = delete; \ + void operator=(const Type&) = delete; + #endif +#endif + + + +#endif // header include guard + + + + diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Kernel/OVR_ContainerAllocator.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Kernel/OVR_ContainerAllocator.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,267 @@ +/************************************************************************************ + +PublicHeader: OVR_Kernel.h +Filename : OVR_ContainerAllocator.h +Content : Template allocators and constructors for containers. +Created : September 19, 2012 +Notes : + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#ifndef OVR_ContainerAllocator_h +#define OVR_ContainerAllocator_h + +#include "OVR_Allocator.h" +#include + + +namespace OVR { + + +//----------------------------------------------------------------------------------- +// ***** Container Allocator + +// ContainerAllocator serves as a template argument for allocations done by +// containers, such as Array and Hash; replacing it could allow allocator +// substitution in containers. + +class ContainerAllocatorBase +{ +public: + static void* Alloc(size_t size) { return OVR_ALLOC(size); } + static void* Realloc(void* p, size_t newSize) { return OVR_REALLOC(p, newSize); } + static void Free(void *p) { OVR_FREE(p); } +}; + + + +//----------------------------------------------------------------------------------- +// ***** Constructors, Destructors, Copiers + +// Plain Old Data - movable, no special constructors/destructor. +template +class ConstructorPOD +{ +public: + static void Construct(void *) {} + static void Construct(void *p, const T& source) + { + *(T*)p = source; + } + + // Same as above, but allows for a different type of constructor. + template + static void ConstructAlt(void *p, const S& source) + { + *(T*)p = source; + } + + static void ConstructArray(void*, size_t) {} + + static void ConstructArray(void* p, size_t count, const T& source) + { + uint8_t *pdata = (uint8_t*)p; + for (size_t i=0; i< count; ++i, pdata += sizeof(T)) + *(T*)pdata = source; + } + + static void ConstructArray(void* p, size_t count, const T* psource) + { + memcpy(p, psource, sizeof(T) * count); + } + + static void Destruct(T*) {} + static void DestructArray(T*, size_t) {} + + static void CopyArrayForward(T* dst, const T* src, size_t count) + { + memmove(dst, src, count * sizeof(T)); + } + + static void CopyArrayBackward(T* dst, const T* src, size_t count) + { + memmove(dst, src, count * sizeof(T)); + } + + static bool IsMovable() { return true; } +}; + + +//----------------------------------------------------------------------------------- +// ***** ConstructorMov +// +// Correct C++ construction and destruction for movable objects +template +class ConstructorMov +{ +public: + static void Construct(void* p) + { + OVR::Construct(p); + } + + static void Construct(void* p, const T& source) + { + OVR::Construct(p, source); + } + + // Same as above, but allows for a different type of constructor. + template + static void ConstructAlt(void* p, const S& source) + { + OVR::ConstructAlt(p, source); + } + + static void ConstructArray(void* p, size_t count) + { + uint8_t* pdata = (uint8_t*)p; + for (size_t i=0; i< count; ++i, pdata += sizeof(T)) + Construct(pdata); + } + + static void ConstructArray(void* p, size_t count, const T& source) + { + uint8_t* pdata = (uint8_t*)p; + for (size_t i=0; i< count; ++i, pdata += sizeof(T)) + Construct(pdata, source); + } + + static void ConstructArray(void* p, size_t count, const T* psource) + { + uint8_t* pdata = (uint8_t*)p; + for (size_t i=0; i< count; ++i, pdata += sizeof(T)) + Construct(pdata, *psource++); + } + + static void Destruct(T* p) + { + p->~T(); + OVR_UNUSED(p); // Suppress silly MSVC warning + } + + static void DestructArray(T* p, size_t count) + { + p += count - 1; + for (size_t i=0; i~T(); + } + + static void CopyArrayForward(T* dst, const T* src, size_t count) + { + memmove(dst, src, count * sizeof(T)); + } + + static void CopyArrayBackward(T* dst, const T* src, size_t count) + { + memmove(dst, src, count * sizeof(T)); + } + + static bool IsMovable() { return true; } +}; + + +//----------------------------------------------------------------------------------- +// ***** ConstructorCPP +// +// Correct C++ construction and destruction for movable objects +template +class ConstructorCPP +{ +public: + static void Construct(void* p) + { + OVR::Construct(p); + } + + static void Construct(void* p, const T& source) + { + OVR::Construct(p, source); + } + + // Same as above, but allows for a different type of constructor. + template + static void ConstructAlt(void* p, const S& source) + { + OVR::ConstructAlt(p, source); + } + + static void ConstructArray(void* p, size_t count) + { + uint8_t* pdata = (uint8_t*)p; + for (size_t i=0; i< count; ++i, pdata += sizeof(T)) + Construct(pdata); + } + + static void ConstructArray(void* p, size_t count, const T& source) + { + uint8_t* pdata = (uint8_t*)p; + for (size_t i=0; i< count; ++i, pdata += sizeof(T)) + Construct(pdata, source); + } + + static void ConstructArray(void* p, size_t count, const T* psource) + { + uint8_t* pdata = (uint8_t*)p; + for (size_t i=0; i< count; ++i, pdata += sizeof(T)) + Construct(pdata, *psource++); + } + + static void Destruct(T* p) + { + p->~T(); + OVR_UNUSED(p); // Suppress silly MSVC warning + } + + static void DestructArray(T* p, size_t count) + { + p += count - 1; + for (size_t i=0; i~T(); + } + + static void CopyArrayForward(T* dst, const T* src, size_t count) + { + for(size_t i = 0; i < count; ++i) + dst[i] = src[i]; + } + + static void CopyArrayBackward(T* dst, const T* src, size_t count) + { + for(size_t i = count; i; --i) + dst[i-1] = src[i-1]; + } + + static bool IsMovable() { return false; } +}; + + +//----------------------------------------------------------------------------------- +// ***** Container Allocator with movement policy +// +// Simple wraps as specialized allocators +template struct ContainerAllocator_POD : ContainerAllocatorBase, ConstructorPOD {}; +template struct ContainerAllocator : ContainerAllocatorBase, ConstructorMov {}; +template struct ContainerAllocator_CPP : ContainerAllocatorBase, ConstructorCPP {}; + + +} // OVR + + +#endif diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Kernel/OVR_DebugHelp.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Kernel/OVR_DebugHelp.cpp Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,3926 @@ +/************************************************************************************ + +Filename : ExceptionHandler.cpp +Content : Platform-independent exception handling interface +Created : October 6, 2014 + +Copyright : Copyright 2014 Oculus VR, LLC. All Rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + + +#include "OVR_DebugHelp.h" +#include "OVR_Types.h" +#include "OVR_UTF8Util.h" +#include "../OVR_CAPI.h" +#include "../OVR_CAPI_Keys.h" +#include "../CAPI/CAPI_HMDState.h" +#include + +#if defined(OVR_OS_WIN32) || defined(OVR_OS_WIN64) + #pragma warning(push, 0) + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #pragma warning(pop) + + #pragma comment(lib, "Psapi.lib") // To consider: It may be a problem to statically link to these libraries if the application at runtime intends to dynamically + #pragma comment(lib, "ole32.lib") // link to a different version of the same library, and we are statically linked into that application instead of being a DLL. + #pragma comment(lib, "shell32.lib") + + // NtQueryInformation and THREAD_BASIC_INFORMATION are undocumented but frequently needed for digging into thread information. + typedef LONG (WINAPI *NtQueryInformationThreadFunc)(HANDLE, int, PVOID, ULONG, PULONG); + + struct THREAD_BASIC_INFORMATION + { + LONG ExitStatus; + PVOID TebBaseAddress; + PVOID UniqueProcessId; + PVOID UniqueThreadId; + PVOID Priority; + PVOID BasePriority; + }; + + #ifndef UNW_FLAG_NHANDLER // Older Windows SDKs don't support this. + #define UNW_FLAG_NHANDLER 0 + #endif + +#elif defined(OVR_OS_MAC) + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include "OVR_mach_exc_OSX.h" + + #if defined(__LP64__) + typedef struct mach_header_64 MachHeader; + typedef struct segment_command_64 SegmentCommand; + typedef struct section_64 Section; + #define kLCSegment LC_SEGMENT_64 + #else + typedef struct mach_header MachHeader; + typedef struct segment_command SegmentCommand; + typedef struct section Section; + #define kLCSegment LC_SEGMENT + #endif + + extern "C" const struct dyld_all_image_infos* _dyld_get_all_image_infos(); // From libdyld.dylib + +#elif defined(OVR_OS_UNIX) + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + //#include // Can't use this until we can ensure that we have an installed version of it. +#endif + +#if !defined(MIN) + #define MIN(X,Y) ((X) < (Y) ? (X) : (Y)) + #define MAX(X,Y) ((X) > (Y) ? (X) : (Y)) +#endif + + +OVR_DISABLE_MSVC_WARNING(4351) // new behavior: elements of array will be default initialized +OVR_DISABLE_MSVC_WARNING(4996) // This function or variable may be unsafe + + + + +#if defined(OVR_OS_APPLE) + static OVR::ExceptionHandler* sExceptionHandler = nullptr; + const uint32_t sMachCancelMessageType = 0x0ca9ce11; // This is a made-up value of our own choice. + + extern "C" + { + kern_return_t catch_mach_exception_raise_OVR(mach_port_t /*exceptionPort*/, mach_port_t /*threadSysId*/, + mach_port_t /*machTask*/, exception_type_t /*machExceptionType*/, + mach_exception_data_t /*machExceptionData*/, mach_msg_type_number_t /*machExceptionDataCount*/) + { + return KERN_FAILURE; + } + + kern_return_t catch_mach_exception_raise_state_OVR(mach_port_t /*exceptionPort*/, exception_type_t /*exceptionType*/, + const mach_exception_data_t /*machExceptionData*/, mach_msg_type_number_t /*machExceptionDataCount*/, + int* /*pMachExceptionFlavor*/, const thread_state_t /*threadStatePrev*/, mach_msg_type_number_t /*threaStatePrevCount*/, + thread_state_t /*threadStateNew*/, mach_msg_type_number_t* /*pThreadStateNewCount*/) + { + return KERN_FAILURE; + } + + kern_return_t catch_mach_exception_raise_state_identity_OVR(mach_port_t exceptionPort, mach_port_t threadSysId, mach_port_t machTask, + exception_type_t exceptionType, mach_exception_data_type_t* machExceptionData, + mach_msg_type_number_t machExceptionDataCount, int* pMachExceptionFlavor, + thread_state_t threadStatePrev, mach_msg_type_number_t threadStatePrevCount, + thread_state_t threadStateNew, mach_msg_type_number_t* pThreadStateNewCount) + { + return sExceptionHandler->HandleMachException(exceptionPort, threadSysId, machTask, exceptionType, machExceptionData, + machExceptionDataCount, pMachExceptionFlavor, threadStatePrev, threadStatePrevCount, + threadStateNew, pThreadStateNewCount); + } + + void* MachHandlerThreadFunctionStatic(void* pExceptionHandlerVoid) + { + return static_cast(pExceptionHandlerVoid)->MachHandlerThreadFunction(); + } + + } // extern "C" +#endif + + + + +namespace OVR { + + +void GetInstructionPointer(void*& pInstruction) +{ + #if defined(OVR_CC_MSVC) + pInstruction = _ReturnAddress(); + #else // GCC, clang + pInstruction = __builtin_return_address(0); + #endif +} + + +static size_t SprintfAddress(char* threadHandleStr, size_t threadHandleStrCapacity, const void* pAddress) +{ + #if defined(OVR_CC_MSVC) + #if (OVR_PTR_SIZE >= 8) + return OVR_snprintf(threadHandleStr, threadHandleStrCapacity, "0x%016I64x", pAddress); // e.g. 0x0123456789abcdef + #else + return OVR_snprintf(threadHandleStr, threadHandleStrCapacity, "0x%08x", pAddress); // e.g. 0x89abcdef + #endif + #else + #if (OVR_PTR_SIZE >= 8) + return OVR_snprintf(threadHandleStr, threadHandleStrCapacity, "%016llx", pAddress); // e.g. 0x0123456789abcdef + #else + return OVR_snprintf(threadHandleStr, threadHandleStrCapacity, "%08x", pAddress); // e.g. 0x89abcdef + #endif + #endif +} + + +static size_t SprintfThreadHandle(char* threadHandleStr, size_t threadHandleStrCapacity, const ThreadHandle& threadHandle) +{ + return SprintfAddress(threadHandleStr, threadHandleStrCapacity, threadHandle); +} + + +static size_t SprintfThreadSysId(char* threadSysIdStr, size_t threadSysIdStrCapacity, const ThreadSysId& threadSysId) +{ + #if defined(OVR_CC_MSVC) // Somebody could conceivably use VC++ with a different standard library that supports %ll. And VS2012+ also support %ll. + return OVR_snprintf(threadSysIdStr, threadSysIdStrCapacity, "%I64u", (uint64_t)threadSysId); + #else + return OVR_snprintf(threadSysIdStr, threadSysIdStrCapacity, "%llu", (uint64_t)threadSysId); + #endif +} + + + + + +void GetThreadStackBounds(void*& pStackBase, void*& pStackLimit, ThreadHandle threadHandle) +{ + #if defined(OVR_OS_WIN64) || defined(OVR_OS_WIN32) || (defined(OVR_OS_MS) && defined(OVR_OS_CONSOLE)) + ThreadSysId threadSysIdCurrent = (ThreadSysId)GetCurrentThreadId(); + ThreadSysId threadSysId; + NT_TIB* pTIB = nullptr; + + if(threadHandle == OVR_THREADHANDLE_INVALID) + threadSysId = threadSysIdCurrent; + else + threadSysId = ConvertThreadHandleToThreadSysId(threadHandle); + + if(threadSysId == threadSysIdCurrent) + { + #if (OVR_PTR_SIZE == 4) + // Need to use __asm__("movl %%fs:0x18, %0" : "=r" (pTIB) : : ); under gcc/clang. + __asm { + mov eax, fs:[18h] + mov pTIB, eax + } + #else + pTIB = (NT_TIB*)NtCurrentTeb(); + #endif + } + else + { + #if (OVR_PTR_SIZE == 4) + // It turns out we don't need to suspend the thread when getting SegFs/SegGS, as that's + // constant per thread and doesn't require the thread to be suspended. + //SuspendThread((HANDLE)threadHandle); + CONTEXT context; + memset(&context, 0, sizeof(context)); + context.ContextFlags = CONTEXT_SEGMENTS; + GetThreadContext((HANDLE)threadHandle, &context); // Requires THREAD_QUERY_INFORMATION privileges. + + LDT_ENTRY ldtEntry; + if(GetThreadSelectorEntry(threadHandle, context.SegFs, &ldtEntry)) // Requires THREAD_QUERY_INFORMATION + pTIB = (NT_TIB*)((ldtEntry.HighWord.Bits.BaseHi << 24 ) | (ldtEntry.HighWord.Bits.BaseMid << 16) | ldtEntry.BaseLow); + + //ResumeThread((HANDLE)threadHandle); + #else + // We cannot use GetThreadSelectorEntry or Wow64GetThreadSelectorEntry on Win64. + // We need to read the SegGs qword at offset 0x30. We can't use pTIB = (NT_TIB*)__readgsqword(0x30) because that reads only the current setGs offset. + // mov rax, qword ptr gs:[30h] + // mov qword ptr [pTIB],rax + // In the meantime we rely on the NtQueryInformationThread function. + + static NtQueryInformationThreadFunc spNtQueryInformationThread = nullptr; + + if(!spNtQueryInformationThread) + { + HMODULE hNTDLL = GetModuleHandleA("ntdll.dll"); + spNtQueryInformationThread = (NtQueryInformationThreadFunc)(uintptr_t)GetProcAddress(hNTDLL, "NtQueryInformationThread"); + } + + if(spNtQueryInformationThread) + { + THREAD_BASIC_INFORMATION tbi; + + memset(&tbi, 0, sizeof(tbi)); + LONG result = spNtQueryInformationThread(threadHandle, 0, &tbi, sizeof(tbi), nullptr); // Requires THREAD_QUERY_INFORMATION privileges + if(result == 0) + pTIB = (NT_TIB*)tbi.TebBaseAddress; + } + #endif + } + + if(pTIB) + { + pStackBase = (void*)pTIB->StackBase; + pStackLimit = (void*)pTIB->StackLimit; + } + else + { + pStackBase = nullptr; + pStackLimit = nullptr; + } + + #elif defined(OVR_OS_APPLE) + if(!threadHandle) + threadHandle = pthread_self(); + + pStackBase = pthread_get_stackaddr_np((pthread_t)threadHandle); + size_t stackSize = pthread_get_stacksize_np((pthread_t)threadHandle); + pStackLimit = (void*)((size_t)pStackBase - stackSize); + + #elif defined(OVR_OS_UNIX) + pStackBase = nullptr; + pStackLimit = nullptr; + + pthread_attr_t threadAttr; + pthread_attr_init(&threadAttr); + + #if defined(OVR_OS_LINUX) + int result = pthread_getattr_np((pthread_t)threadHandle, &threadAttr); + #else + int result = pthread_attr_get_np((pthread_t)threadHandle, &threadAttr); + #endif + + if(result == 0) + { + size_t stackSize = 0; + result = pthread_attr_getstack(&threadAttr, &pStackLimit, &stackSize); + + if(result == 0) + pStackBase = (void*)((uintptr_t)pStackLimit + stackSize); // We assume the stack grows downward. + } + + #endif +} + + +bool OVRIsDebuggerPresent() +{ + #if defined(OVR_OS_MS) + return ::IsDebuggerPresent() != 0; + + #elif defined(OVR_OS_APPLE) + int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, getpid() }; + struct kinfo_proc info; + size_t size = sizeof(info); + + info.kp_proc.p_flag = 0; + sysctl(mib, sizeof(mib) / sizeof(*mib), &info, &size, nullptr, 0); + + return ((info.kp_proc.p_flag & P_TRACED) != 0); + + #elif (defined(OVR_OS_LINUX) || defined(OVR_OS_BSD)) && !defined(OVR_OS_ANDROID) + // This works better than the PT_TRACE_ME approach. + // However, it presents a problem: + // http://pubs.opengroup.org/onlinepubs/009695399/functions/fork.html + // When the application calls fork() from a signal handler and any of the + // fork handlers registered by pthread_atfork() calls a function that is + // not asynch-signal-safe, the behavior is undefined. + // We may need to provide two pathways within this function, one of which + // doesn't fork and instead uses PT_TRACE_ME. + int pid = fork(); + int status; + bool present = false; + + if (pid == -1) // If fork failed... + { + // perror("fork"); + } + else if (pid == 0) // If we are the child process... + { + int ppid = getppid(); + + #if defined(OVR_OS_LINUX) + if (ptrace(PTRACE_ATTACH, ppid, nullptr, nullptr) == 0) + #else + if (ptrace(PT_ATTACH, ppid, nullptr, nullptr) == 0) + #endif + { + waitpid(ppid, nullptr, 0); + + #if defined(OVR_OS_LINUX) + ptrace(PTRACE_CONT, getppid(), nullptr, nullptr); + ptrace(PTRACE_DETACH, getppid(), nullptr, nullptr); + #else + ptrace(PT_CONTINUE, getppid(), nullptr, nullptr); + ptrace(PT_DETACH, getppid(), nullptr, nullptr); + #endif + } + else + { + // ptrace failed so the debugger is present. + present = true; + } + + exit(present ? 1 : 0); // The WEXITSTATUS call below will read this exit value. + } + else // Else we are the original process. + { + waitpid(pid, &status, 0); + present = WEXITSTATUS(status) ? true : false; // Read the exit value from the child's call to exit. + } + + return present; + + #elif defined(PT_TRACE_ME) && !defined(OVR_OS_ANDROID) + return (ptrace(PT_TRACE_ME, 0, 1, 0) < 0); + + #else + return false; + #endif +} + + +// Exits the process with the given exit code. +void ExitProcess(intptr_t processReturnValue) +{ + exit((int)processReturnValue); +} + + +void* SafeMMapAlloc(size_t size) +{ + #if defined(OVR_OS_MS) + return VirtualAlloc(nullptr, size, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); // size is rounded up to a page. // Returned memory is 0-filled. + + #elif defined(OVR_OS_MAC) || defined(OVR_OS_UNIX) + #if !defined(MAP_FAILED) + #define MAP_FAILED ((void*)-1) + #endif + + void* result = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0); // Returned memory is 0-filled. + if(result == MAP_FAILED) // mmap returns MAP_FAILED (-1) upon failure. + result = nullptr; + return result; + #endif +} + + +void SafeMMapFree(const void* memory, size_t size) +{ + #if defined(OVR_OS_MS) + OVR_UNUSED(size); + VirtualFree(const_cast(memory), 0, MEM_RELEASE); + + #elif defined(OVR_OS_MAC) || defined(OVR_OS_UNIX) + size_t pageSize = getpagesize(); + size = (((size + (pageSize - 1)) / pageSize) * pageSize); + munmap(const_cast(memory), size); // Must supply the size to munmap. + #endif +} + + +// Note that we can't just return sizeof(void*) == 8, as we may have the case of a +// 32 bit app running on a 64 bit operating system. +static bool Is64BitOS() +{ + #if (OVR_PTR_SIZE >= 8) + return true; + + #elif defined(OVR_OS_WIN32) || defined(OVR_OS_WIN64) + BOOL is64BitOS = FALSE; + bool IsWow64ProcessPresent = (GetProcAddress(GetModuleHandleW(L"kernel32.dll"), "IsWow64Process") != nullptr); + return (IsWow64ProcessPresent && IsWow64Process(GetCurrentProcess(), &is64BitOS) && is64BitOS); + + #elif defined(OVR_OS_MAC) || defined(OVR_OS_UNIX) + utsname utsName; + memset(&utsName, 0, sizeof(utsName)); + return (uname(&utsName) == 0) && (strcmp(utsName.machine, "x86_64") == 0); + + #else + return false; + #endif +} + + +// The output will always be 0-terminated. +// Returns the required strlen of the output. +// Returns (size_t)-1 on failure. +size_t SpawnShellCommand(const char* shellCommand, char* output, size_t outputCapacity) +{ + #if defined(OVR_OS_UNIX) || defined(OVR_OS_APPLE) + FILE* pFile = popen(shellCommand, "r"); + + if(pFile) + { + size_t requiredLength = 0; + char buffer[256]; + + while(fgets(buffer, sizeof(buffer), pFile)) // fgets 0-terminates the buffer. + { + size_t length = OVR_strlen(buffer); + requiredLength += length; + + if(outputCapacity) + { + OVR_strlcpy(output, buffer, outputCapacity); + length = MIN(outputCapacity, length); + } + + output += length; + outputCapacity -= length; + } + + pclose(pFile); + return requiredLength; + } + #else + // To do. Properly solving this on Windows requires a bit of code. + OVR_UNUSED(shellCommand); + OVR_UNUSED(output); + OVR_UNUSED(outputCapacity); + #endif + + return (size_t)-1; +} + + +// Retrieves a directory path which ends with a path separator. +// Returns the required strlen of the path. +// Guarantees the presence of the directory upon returning true. +static size_t GetUserDocumentsDirectory(char* directoryPath, size_t directoryPathCapacity) +{ + #if defined(OVR_OS_MS) + wchar_t pathW[MAX_PATH + 1]; // +1 because we append a path separator. + HRESULT hr = SHGetFolderPathW(nullptr, CSIDL_APPDATA | CSIDL_FLAG_CREATE, nullptr, SHGFP_TYPE_CURRENT, pathW); + + if(SUCCEEDED(hr)) + { + OVR_UNUSED(directoryPathCapacity); + + intptr_t requiredUTF8Length = OVR::UTF8Util::GetEncodeStringSize(pathW); // Returns required strlen. + if(requiredUTF8Length < MAX_PATH) // We need space for a trailing path separator. + { + OVR::UTF8Util::EncodeString(directoryPath, pathW, -1); + OVR::OVR_strlcat(directoryPath, "\\", directoryPathCapacity); + } + + return (requiredUTF8Length + 1); + } + + #elif defined(OVR_OS_MAC) + // This is the same location that Apple puts its OS-generated .crash files. + const char* home = getenv("HOME"); + size_t requiredStrlen = OVR::OVR_snprintf(directoryPath, directoryPathCapacity, "%s/Library/Logs/DiagnosticReports/", home ? home : "/Users/Shared/Logs/DiagnosticReports/"); + // To do: create the directory if it doesn't already exist. + return requiredStrlen; + + #elif defined(OVR_OS_UNIX) || defined(OVR_OS_MAC) + const char* home = getenv("HOME"); + size_t requiredStrlen = OVR::OVR_snprintf(directoryPath, directoryPathCapacity, "%s/Library/", home ? home : "/Users/Shared/"); + // To do: create the directory if it doesn't already exist. + return requiredStrlen; + #endif + + return 0; +} + + +// Retrieves the name of the given thread. +// To do: Move this to OVR_Threads.h +bool GetThreadName(OVR::ThreadHandle threadHandle, char* threadName, size_t threadNameCapacity) +{ + #if defined(OVR_OS_APPLE) || defined(OVR_OS_LINUX) + int result = pthread_getname_np((pthread_t)threadHandle, threadName, threadNameCapacity); + if(result == 0) + return true; + #else + // This is not currently possible on Windows, as only the debugger stores the thread name. We could potentially use a vectored + // exception handler to catch all thread name exceptions (0x406d1388) and record them in a static list at runtime. To detect + // thread exit we could use WMI Win32_ThreadStopTrace. Maintain a list of thread names between these two events. + OVR_UNUSED(threadHandle); + OVR_UNUSED(threadNameCapacity); + #endif + + if(threadNameCapacity) + threadName[0] = 0; + + return false; +} + + +OVR::ThreadSysId ConvertThreadHandleToThreadSysId(OVR::ThreadHandle threadHandle) +{ + #if defined(OVR_OS_WIN64) + return (OVR::ThreadSysId)::GetThreadId(threadHandle); // Requires THREAD_QUERY_INFORMATION privileges. + + #elif defined(OVR_OS_WIN32) + typedef DWORD (WINAPI *GetThreadIdFunc)(HANDLE); + + static volatile bool sInitialized = false; + static GetThreadIdFunc spGetThreadIdFunc = nullptr; + static NtQueryInformationThreadFunc spNtQueryInformationThread = nullptr; + + if(!sInitialized) + { + HMODULE hKernel32 = GetModuleHandleA("kernel32.dll"); + if(hKernel32) + spGetThreadIdFunc = (GetThreadIdFunc)(uintptr_t)GetProcAddress(hKernel32, "GetThreadId"); + + if(!spGetThreadIdFunc) + { + HMODULE hNTDLL = GetModuleHandleA("ntdll.dll"); + + if(hNTDLL) + spNtQueryInformationThread = (NtQueryInformationThreadFunc)(uintptr_t)GetProcAddress(hNTDLL, "NtQueryInformationThread"); + } + + sInitialized = true; + } + + if(spGetThreadIdFunc) + return (OVR::ThreadSysId)spGetThreadIdFunc(threadHandle); + + if(spNtQueryInformationThread) + { + THREAD_BASIC_INFORMATION tbi; + + if(spNtQueryInformationThread(threadHandle, 0, &tbi, sizeof(tbi), nullptr) == 0) + return (OVR::ThreadSysId)tbi.UniqueThreadId; + } + + return OVR_THREADSYSID_INVALID; + + #elif defined(OVR_OS_APPLE) + mach_port_t threadSysId = pthread_mach_thread_np((pthread_t)threadHandle); // OS 10.4 and later. + return (ThreadSysId)threadSysId; + + #elif defined(OVR_OS_LINUX) + + // I believe we can usually (though not portably) intepret the pthread_t as a pointer to a struct whose first member is a lwp id. + OVR_UNUSED(threadHandle); + return OVR_THREADSYSID_INVALID; + + #else + OVR_UNUSED(threadHandle); + return OVR_THREADSYSID_INVALID; + #endif +} + + +OVR::ThreadHandle ConvertThreadSysIdToThreadHandle(OVR::ThreadSysId threadSysId) +{ + #if defined(OVR_OS_MS) + // We currently request the given rights because that's what users of this function typically need it for. Ideally there would + // be a way to specify the requested rights in order to avoid the problem if we need only a subset of them but can't get it. + // The solution we use below to try opening with successively reduced rights will work for our uses here but isn't a good general solution to this. + OVR::ThreadHandle threadHandle = ::OpenThread(THREAD_SUSPEND_RESUME | THREAD_GET_CONTEXT | THREAD_QUERY_INFORMATION, TRUE, (DWORD)threadSysId); + + if(threadHandle == OVR_THREADHANDLE_INVALID) + { + threadHandle = ::OpenThread(THREAD_GET_CONTEXT | THREAD_QUERY_INFORMATION, TRUE, (DWORD)threadSysId); + + if(threadHandle == OVR_THREADHANDLE_INVALID) + threadHandle = ::OpenThread(THREAD_QUERY_INFORMATION, TRUE, (DWORD)threadSysId); + } + + return threadHandle; + #elif defined(OVR_OS_MAC) + return (ThreadHandle)pthread_from_mach_thread_np((mach_port_t)threadSysId); + #else + return (ThreadHandle)threadSysId; + #endif +} + + +void FreeThreadHandle(OVR::ThreadHandle threadHandle) +{ + #if defined(OVR_OS_MS) + if(threadHandle != OVR_THREADHANDLE_INVALID) + ::CloseHandle(threadHandle); + #else + OVR_UNUSED(threadHandle); + #endif +} + + +OVR::ThreadSysId GetCurrentThreadSysId() +{ + #if defined(OVR_OS_MS) + return ::GetCurrentThreadId(); + #elif defined(OVR_OS_APPLE) + return (ThreadSysId)mach_thread_self(); + #else + return (ThreadSysId)pthread_self(); + #endif +} + + + +static void GetCurrentProcessFilePath(char* appPath, size_t appPathCapacity) +{ + appPath[0] = 0; + + #if defined(OVR_OS_MS) + wchar_t pathW[MAX_PATH]; + GetModuleFileNameW(0, pathW, (DWORD)OVR_ARRAY_COUNT(pathW)); + + size_t requiredUTF8Length = (size_t)OVR::UTF8Util::GetEncodeStringSize(pathW); // Returns required strlen. + + if(requiredUTF8Length < appPathCapacity) + { + OVR::UTF8Util::EncodeString(appPath, pathW, -1); + } + else + { + appPath[0] = 0; + } + + #elif defined(OVR_OS_APPLE) + struct BunderFolder + { + // Returns true if pStr ends with pFind, case insensitively. + // To do: Move OVR_striend to OVRKernel/Std.h + static bool OVR_striend(const char* pStr, const char* pFind, size_t strLength = (size_t)-1, size_t findLength = (size_t)-1) + { + if(strLength == (size_t)-1) + strLength = OVR_strlen(pStr); + if(findLength == (size_t)-1) + findLength = OVR_strlen(pFind); + if(strLength >= findLength) + return (OVR_stricmp(pStr + strLength - findLength, pFind) == 0); + return false; + } + + static bool IsBundleFolder(const char* filePath) + { + // https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/AboutBundles/AboutBundles.html#//apple_ref/doc/uid/10000123i-CH100-SW1 + static const char* extensionArray[] = { ".app", ".bundle", ".framework", ".plugin", ".kext" }; + + for(size_t i = 0; i < OVR_ARRAY_COUNT(extensionArray); i++) + { + if(OVR_striend(filePath, extensionArray[i])) + return true; + } + + return false; + } + }; + + char appPathTemp[PATH_MAX]; + uint32_t appPathTempCapacity32 = PATH_MAX; + size_t requiredStrlen = appPathCapacity; + + if(_NSGetExecutablePath(appPathTemp, &appPathTempCapacity32) == 0) + { + char appPathTempReal[PATH_MAX]; + + if(realpath(appPathTemp, appPathTempReal)) // If the path is a symbolic link, this converts it to the real path. + { + // To consider: Enable reading the internal bundle executable path. An application on Mac may in + // fact be within a file bundle, which is an private file system within a file. With Objective C + // we could use: [[NSWorkspace sharedWorkspace] isFilePackageAtPath:fullPath]; + bool shouldReadTheBunderPath = false; + + if(shouldReadTheBunderPath) + { + // We recursively call dirname() until we find .app/.bundle/.plugin as a directory name. + OVR_strlcpy(appPathTemp, appPathTempReal, OVR_ARRAY_COUNT(appPathTemp)); + bool found = BunderFolder::IsBundleFolder(appPathTemp); + + while(!found && OVR_strcmp(appPathTemp, ".") && OVR_strcmp(appPathTemp, "/")) + { + OVR_strlcpy(appPathTemp, dirname(appPathTemp), OVR_ARRAY_COUNT(appPathTemp)); + found = BunderFolder::IsBundleFolder(appPathTemp); + } + + if(found) // If somewhere above we found a parent bundle container... + requiredStrlen = OVR_strlcpy(appPath, appPathTemp, appPathCapacity); + else + requiredStrlen = OVR_strlcpy(appPath, appPathTempReal, appPathCapacity); + } + else + { + requiredStrlen = OVR_strlcpy(appPath, appPathTempReal, appPathCapacity); + } + } + } + + if(requiredStrlen >= appPathCapacity) + appPath[0] = '\0'; + + #elif defined(OVR_OS_LINUX) + ssize_t length = readlink("/proc/self/exe", appPath, appPathCapacity); + + if((length != -1) && ((size_t)length < (appPathCapacity - 1))) + { + appPath[length] = '\0'; + } + #endif +} + + +static const char* GetFileNameFromPath(const char* filePath) +{ + #if defined(OVR_OS_MS) + const char* lastPathSeparator = max(strrchr(filePath, '\\'), strrchr(filePath, '/')); // Microsoft APIs are inconsistent with respect to allowing / as a path separator. + #else + const char* lastPathSeparator = strrchr(filePath, '/'); + #endif + + if(lastPathSeparator) + return lastPathSeparator + 1; + + return filePath; +} + + + +static void FormatDateTime(char* buffer, size_t bufferCapacity, time_t timeValue, bool getDate, bool getTime, bool localDateTime, bool fileNameSafeCharacters = false) +{ + char temp[128]; + const tm* pTime = localDateTime ? localtime(&timeValue) : gmtime(&timeValue); + + if(bufferCapacity) + buffer[0] = 0; + + if(getDate) + { + const char* format = fileNameSafeCharacters ? "%Y-%m-%d" : "%Y/%m/%d"; + strftime(temp, OVR_ARRAY_COUNT(temp), format, pTime); + OVR::OVR_strlcpy(buffer, temp, bufferCapacity); + } + + if(getTime) + { + const char* format = fileNameSafeCharacters ? " %H.%M.%S" : " %H:%M:%S"; + strftime(temp, OVR_ARRAY_COUNT(temp), (getDate ? format : format + 1), pTime); + OVR::OVR_strlcat(buffer, temp, bufferCapacity); + } +} + + +static void GetOSVersionName(char* versionName, size_t versionNameCapacity) +{ + #if defined(OVR_OS_MS) + const char* name = "unknown"; + + OSVERSIONINFOEXW vi; + memset(&vi, 0, sizeof(vi)); + vi.dwOSVersionInfoSize = sizeof(vi); + + if(GetVersionExW((LPOSVERSIONINFOW)&vi)) + { + if(vi.dwMajorVersion >= 7) + { + // Unknown recent version. + } + if(vi.dwMajorVersion >= 6) + { + if(vi.dwMinorVersion >= 4) + name = "Windows 10"; + else if(vi.dwMinorVersion >= 3) + { + if(vi.wProductType == VER_NT_WORKSTATION) + name = "Windows 8.1"; + else + name = "Windows Server 2012 R2"; + } + else if(vi.dwMinorVersion >= 2) + { + if(vi.wProductType == VER_NT_WORKSTATION) + name = "Windows 8"; + else + name = "Windows Server 2012"; + } + else if(vi.dwMinorVersion >= 1) + { + if(vi.wProductType == VER_NT_WORKSTATION) + name = "Windows 7"; + else + name = "Windows Server 2008 R2"; + } + else + { + if(vi.wProductType == VER_NT_WORKSTATION) + name = "Windows Vista"; + else + name = "Windows Server 2008"; + } + } + else if(vi.dwMajorVersion >= 5) + { + if(vi.dwMinorVersion == 0) + name = "Windows 2000"; + else if(vi.dwMinorVersion == 1) + name = "Windows XP"; + else // vi.dwMinorVersion == 2 + { + if(GetSystemMetrics(SM_SERVERR2) != 0) + name = "Windows Server 2003 R2"; + else if(vi.wSuiteMask & VER_SUITE_WH_SERVER) + name = "Windows Home Server"; + if(GetSystemMetrics(SM_SERVERR2) == 0) + name = "Windows Server 2003"; + else + name = "Windows XP Professional x64 Edition"; + } + } + else + name = "Windows 98 or earlier"; + } + + OVR_strlcpy(versionName, name, versionNameCapacity); + + #elif defined(OVR_OS_UNIX) || defined(OVR_OS_APPLE) + utsname utsName; + memset(&utsName, 0, sizeof(utsName)); + + if(uname(&utsName) == 0) + OVR_snprintf(versionName, versionNameCapacity, "%s %s %s %s", utsName.sysname, utsName.release, utsName.version, utsName.machine); + else + OVR_snprintf(versionName, versionNameCapacity, "Unix"); + #endif +} + + + + +void CreateException(CreateExceptionType exceptionType) +{ + char buffer[1024] = {}; + + switch(exceptionType) + { + case kCETAccessViolation: + { + int* pNullPtr = reinterpret_cast((rand() / 2) / RAND_MAX); + pNullPtr[0] = 0; // This line should generate an exception. + sprintf(buffer, "%p", pNullPtr); + break; + } + + case kCETDivideByZero: + { + int smallValue = 1; + int largeValue = (1000 * exceptionType); + int divByZero = (smallValue / largeValue); // This line should generate a div/0 exception. + sprintf(buffer, "%d", divByZero); + break; + } + + case kCETIllegalInstruction: + { + #if defined(OVR_CPU_X86) || (defined(OVR_CPU_X86_64) && !defined(OVR_CC_MSVC)) // (if x86) or (if x64 and any computer but VC++)... + #if defined(OVR_CC_MSVC) + __asm ud2 + #else // e.g. GCC + asm volatile("ud2"); + #endif + + #elif defined(OVR_CPU_X86_64) && (defined(OVR_OS_MS) && defined(PAGE_EXECUTE_READWRITE)) + // VC++ for x64 doesn't support inline asm. + void* pVoid = _AddressOfReturnAddress(); + void** ppVoid = reinterpret_cast(pVoid); + void* pReturnAddress = *ppVoid; + DWORD dwProtectPrev = 0; + + if(VirtualProtect(pReturnAddress, 2, PAGE_EXECUTE_READWRITE, &dwProtectPrev)) // If we can set the memory to be executable... + { + // Modify the code we return to. + uint8_t asm_ud2[] = { 0x0f, 0x0b }; + memcpy(pReturnAddress, asm_ud2, sizeof(asm_ud2)); + VirtualProtect(pReturnAddress, 2, dwProtectPrev, &dwProtectPrev); + } + else + { + // To do: Fix this. + } + + #else + // To do: Fix this. + #endif + + break; + } + + case kCETStackCorruption: + { + size_t size = (sizeof(buffer) * 16) - (rand() % 16); + char* pOutsizeStack = buffer - ((sizeof(buffer) * 16) + (rand() % 16)); + + memset(buffer, 0, size); + memset(pOutsizeStack, 0, size); // This line should generate an exception, or an exception will be generated upon return from this function. + break; + } + + case kCETStackOverflow: + { + CreateException(exceptionType); // Call ourselves recursively. This line should generate a div/0 exception. + sprintf(buffer, "%d", exceptionType); + break; + } + + case kCETAlignment: + { + // Not all platforms generate alignment exceptions. Some internally handle it. + void* pAligned = malloc(16); + char* pMisaligned = (char*)pAligned + 1; + uint64_t* pMisaligned64 = reinterpret_cast(pMisaligned); + + *pMisaligned64 = 0; // This line should generate an exception. + free(pAligned); + break; + } + + case kCETFPU: + // Platforms usually have FPU exceptions disabled. In order to test FPU exceptions we will need to at least + // temporarily disable them before executing code here to generate such exceptions. + // To do. + break; + + case kCETTrap: + // To do. This is hardware-specific. + break; + } +} + + + + +#if defined(OVR_OS_MS) + typedef BOOL (WINAPI * StackWalk64Type)(DWORD MachineType, HANDLE hProcess, HANDLE hThread, LPSTACKFRAME64 StackFrame, PVOID ContextRecord, PREAD_PROCESS_MEMORY_ROUTINE64 ReadMemoryRoutine, PFUNCTION_TABLE_ACCESS_ROUTINE64 FunctionTableAccessRoutine, PGET_MODULE_BASE_ROUTINE64 GetModuleBaseRoutine, PTRANSLATE_ADDRESS_ROUTINE64 TranslateAddress); + typedef PVOID (WINAPI * SymFunctionTableAccess64Type)(HANDLE hProcess, DWORD64 dwAddr); + typedef DWORD64 (WINAPI * SymGetModuleBase64Type)(HANDLE hProcess, DWORD64 dwAddr); + typedef DWORD (WINAPI * SymSetOptionsType)(DWORD SymOptions); + typedef BOOL (WINAPI * SymInitializeWType)(HANDLE hProcess, PCWSTR UserSearchPath, BOOL fInvadeProcess); + typedef BOOL (WINAPI * SymCleanupType)(HANDLE hProcess); + typedef DWORD64 (WINAPI * SymLoadModule64Type)(HANDLE hProcess, HANDLE hFile, PCSTR ImageName, PCSTR ModuleName, DWORD64 BaseOfDll, DWORD SizeOfDll); + typedef BOOL (WINAPI * SymFromAddrType)(HANDLE hProcess, DWORD64 Address, PDWORD64 Displacement, PSYMBOL_INFO Symbol); + typedef BOOL (WINAPI * SymGetLineFromAddr64Type)(HANDLE hProcess, DWORD64 qwAddr, PDWORD pdwDisplacement, PIMAGEHLP_LINE64 Line64); + + StackWalk64Type pStackWalk64; + SymFunctionTableAccess64Type pSymFunctionTableAccess64; + SymGetModuleBase64Type pSymGetModuleBase64; + SymSetOptionsType pSymSetOptions; + SymInitializeWType pSymInitializeW; + SymCleanupType pSymCleanup; + SymLoadModule64Type pSymLoadModule64; + SymFromAddrType pSymFromAddr; + SymGetLineFromAddr64Type pSymGetLineFromAddr64; +#endif + + + +SymbolLookup::SymbolLookup() + : initialized(false), + allowMemoryAllocation(true), + moduleListUpdated(false), + moduleInfoArray(), + moduleInfoArraySize(0) +{ +} + +SymbolLookup::~SymbolLookup() +{ + Shutdown(); +} + +void SymbolLookup::AddSourceCodeDirectory(const char* pDirectory) +{ + OVR_UNUSED(pDirectory); +} + +bool SymbolLookup::Initialize() +{ + if(!initialized) + { + #if defined(OVR_OS_MS) + // http://msdn.microsoft.com/en-us/library/windows/desktop/ms679294%28v=vs.85%29.aspx + HANDLE hProcess = GetCurrentProcess(); + HMODULE hDbgHelp = LoadLibraryW(L"DbgHelp.dll"); // It's best if the application supplies a recent version of this. + + if(hDbgHelp) + { + pStackWalk64 = (StackWalk64Type)(uintptr_t)::GetProcAddress(hDbgHelp, "StackWalk64"); + pSymFunctionTableAccess64 = (SymFunctionTableAccess64Type)(uintptr_t)::GetProcAddress(hDbgHelp, "SymFunctionTableAccess64"); + pSymGetModuleBase64 = (SymGetModuleBase64Type)(uintptr_t)::GetProcAddress(hDbgHelp, "SymGetModuleBase64"); + pSymSetOptions = (SymSetOptionsType)(uintptr_t)::GetProcAddress(hDbgHelp, "SymSetOptions"); + pSymInitializeW = (SymInitializeWType)(uintptr_t)::GetProcAddress(hDbgHelp, "SymInitializeW"); + pSymCleanup = (SymCleanupType)(uintptr_t)::GetProcAddress(hDbgHelp, "SymCleanup"); + pSymLoadModule64 = (SymLoadModule64Type)(uintptr_t)::GetProcAddress(hDbgHelp, "SymLoadModule64"); + pSymFromAddr = (SymFromAddrType)(uintptr_t)::GetProcAddress(hDbgHelp, "SymFromAddr"); + pSymGetLineFromAddr64 = (SymGetLineFromAddr64Type)(uintptr_t)::GetProcAddress(hDbgHelp, "SymGetLineFromAddr64"); + } + + pSymSetOptions(SYMOPT_UNDNAME | SYMOPT_DEFERRED_LOADS); + + // To consider: Use a manually created search path: + // wchar_t searchPathW[4096]; // Semicolon-separated strings. + // The current working directory of the application. + // The directory of the application itself (GetModuleFileName). + // The _NT_SYMBOL_PATH environment variable. + // The _NT_ALTERNATE_SYMBOL_PATH environment variable. + + if(pSymInitializeW(hProcess, nullptr /*searchPathW*/, FALSE)) + { + initialized = true; + } + #endif + } + + return true; +} + +void SymbolLookup::Shutdown() +{ + if(initialized) + { + initialized = false; + + #if defined(OVR_OS_MS) + HANDLE hProcess = GetCurrentProcess(); + + // SymCleanup should handle this for us. + //if(moduleListUpdated) + //{ + // for(size_t i = 0; i < moduleInfoArraySize; i++) + // pSymUnloadModule64(hProcess, moduleInfoArray[i].baseAddress); + //} + + moduleInfoArraySize = 0; + + pSymCleanup(hProcess); + #endif + } +} + + +void SymbolLookup::EnableMemoryAllocation(bool enabled) +{ + allowMemoryAllocation = enabled; +} + + +OVR_DISABLE_MSVC_WARNING(4740) // flow in or out of inline asm code suppresses global optimization +OVR_DISABLE_MSVC_WARNING(4748) // /GS can not protect parameters and local variables from local buffer overrun because optimizations are disabled in function + + +size_t SymbolLookup::GetBacktrace(void* addressArray[], size_t addressArrayCapacity, size_t skipCount, void* platformThreadContext, OVR::ThreadSysId threadSysIdHelp) +{ + #if defined(OVR_OS_WIN64) || (defined(OVR_OS_MS) && defined(OVR_OS_CONSOLE)) + OVR_UNUSED(threadSysIdHelp); + + if(platformThreadContext == nullptr) + return RtlCaptureStackBackTrace(1, (ULONG)addressArrayCapacity, addressArray, nullptr); + + // We need to get the call stack of another thread. + size_t frameIndex = 0; + CONTEXT context; + PRUNTIME_FUNCTION pRuntimeFunction; + ULONG64 imageBase = 0; + ULONG64 imageBasePrev = 0; + + memcpy(&context, (CONTEXT*)platformThreadContext, sizeof(CONTEXT)); + context.ContextFlags = CONTEXT_CONTROL; + + if(context.Rip && (frameIndex < addressArrayCapacity)) + addressArray[frameIndex++] = (void*)(uintptr_t)context.Rip; + + while(context.Rip && (frameIndex < addressArrayCapacity)) + { + imageBasePrev = imageBase; + pRuntimeFunction = (PRUNTIME_FUNCTION)RtlLookupFunctionEntry(context.Rip, &imageBase, nullptr); + + if(pRuntimeFunction) + { + VOID* handlerData = nullptr; + ULONG64 establisherFramePointers[2] = { 0, 0 }; + RtlVirtualUnwind(UNW_FLAG_NHANDLER, imageBase, context.Rip, pRuntimeFunction, &context, &handlerData, establisherFramePointers, nullptr); + } + else + { + context.Rip = (ULONG64)(*(PULONG64)context.Rsp); + context.Rsp += 8; + } + + if(context.Rip && (frameIndex < addressArrayCapacity)) + { + if(skipCount) + --skipCount; + else + addressArray[frameIndex++] = (void*)(uintptr_t)context.Rip; + } + } + + return frameIndex; + + #elif defined(OVR_OS_WIN32) + OVR_UNUSED(threadSysIdHelp); + + size_t frameIndex = 0; + + if(pStackWalk64) + { + CONTEXT context; + + if(platformThreadContext) + { + memcpy(&context, platformThreadContext, sizeof(context)); + context.ContextFlags = CONTEXT_CONTROL; + } + else + { + memset(&context, 0, sizeof(context)); + context.ContextFlags = CONTEXT_CONTROL; + + __asm { + mov context.Ebp, EBP + mov context.Esp, ESP + call GetEIP + GetEIP: + pop context.Eip + } + } + + STACKFRAME64 sf; + memset(&sf, 0, sizeof(sf)); + sf.AddrPC.Offset = context.Eip; + sf.AddrPC.Mode = AddrModeFlat; + sf.AddrStack.Offset = context.Esp; + sf.AddrStack.Mode = AddrModeFlat; + sf.AddrFrame.Offset = context.Ebp; + sf.AddrFrame.Mode = AddrModeFlat; + + const HANDLE hCurrentProcess = ::GetCurrentProcess(); + const HANDLE hCurrentThread = ::GetCurrentThread(); + + if(!platformThreadContext) // If we are reading the current thread's call stack then we ignore this current function. + skipCount++; + + while(frameIndex < addressArrayCapacity) + { + if(!pStackWalk64(IMAGE_FILE_MACHINE_I386, hCurrentProcess, hCurrentThread, &sf, &context, nullptr, pSymFunctionTableAccess64, pSymGetModuleBase64, nullptr)) + break; + + if(sf.AddrFrame.Offset == 0) + break; + + if(skipCount) + --skipCount; + else + addressArray[frameIndex++] = ((void*)(uintptr_t)sf.AddrPC.Offset); + } + } + + return frameIndex; + + #elif defined(OVR_OS_APPLE) + struct StackFrame + { + StackFrame* pParentStackFrame; + void* pReturnPC; + }; + + void* pInstruction; + StackFrame* pStackFrame; + size_t frameIndex = 0; + + if(platformThreadContext) + { + #if defined(OVR_CPU_ARM) + arm_thread_state_t* pThreadState = (arm_thread_state_t*)platformThreadContext; + pStackFrame = (StackFrame*)pThreadState->__fp; + pInstruction = (void*) pThreadState->__pc; + #define FrameIsAligned(pStackFrame) ((((uintptr_t)pStackFrame) & 0x1) == 0) + #elif defined(OVR_CPU_X86_64) + x86_thread_state_t* pThreadState = (x86_thread_state_t*)platformThreadContext; + pInstruction = (void*) pThreadState->uts.ts64.__rip; + pStackFrame = (StackFrame*)pThreadState->uts.ts64.__rbp; + #define FrameIsAligned(pStackFrame) ((((uintptr_t)pStackFrame) & 0xf) == 0) + #elif defined(OVR_CPU_X86) + x86_thread_state_t* pThreadState = (x86_thread_state_t*)platformThreadContext; + pInstruction = (void*) pThreadState->uts.ts32.__eip; + pStackFrame = (StackFrame*)pThreadState->uts.ts32.__ebp; + #define FrameIsAligned(pStackFrame) ((((uintptr_t)pStackFrame) & 0xf) == 8) + #endif + + if(frameIndex < addressArrayCapacity) + addressArray[frameIndex++] = pInstruction; + } + else // Else get the current values... + { + pStackFrame = (StackFrame*)__builtin_frame_address(0); + GetInstructionPointer(pInstruction); + } + + pthread_t threadSelf = pthread_self(); + void* pCurrentStackBase = pthread_get_stackaddr_np(threadSelf); + void* pCurrentStackLimit = (void*)((uintptr_t)pCurrentStackBase - pthread_get_stacksize_np(threadSelf)); + bool threadIsCurrent = (platformThreadContext == nullptr) || (((void*)pStackFrame > pCurrentStackLimit) && ((void*)pStackFrame <= pCurrentStackBase)); + StackFrame* pStackBase; + StackFrame* pStackLimit; + + if(threadIsCurrent) + { + pStackBase = (StackFrame*)pCurrentStackBase; + pStackLimit = (StackFrame*)pCurrentStackLimit; + } + else if(threadSysIdHelp) + { + pthread_t threadHandle = pthread_from_mach_thread_np((mach_port_t)threadSysIdHelp); + pStackBase = (StackFrame*)pthread_get_stackaddr_np(threadHandle); + pStackLimit = (StackFrame*)((uintptr_t)pStackBase - pthread_get_stacksize_np(threadHandle)); + } + else + { // We guess what the limits are. + pStackBase = pStackFrame + ((384 * 1024) / sizeof(StackFrame)); + pStackLimit = pStackFrame - ((384 * 1024) / sizeof(StackFrame)); + } + + if((frameIndex < addressArrayCapacity) && pStackFrame && FrameIsAligned(pStackFrame)) + { + addressArray[frameIndex++] = pStackFrame->pReturnPC; + + while(pStackFrame && pStackFrame->pReturnPC && (frameIndex < addressArrayCapacity)) + { + pStackFrame = pStackFrame->pParentStackFrame; + + if(pStackFrame && FrameIsAligned(pStackFrame) && pStackFrame->pReturnPC && (pStackFrame > pStackLimit) && (pStackFrame < pStackBase)) + { + if(skipCount) + --skipCount; + else + addressArray[frameIndex++] = pStackFrame->pReturnPC; + } + else + break; + } + } + + return frameIndex; + + #elif defined(OVR_OS_LINUX) && (defined( __LIBUNWIND__) || defined(LIBUNWIND_AVAIL)) + // Libunwind-based solution. Requires installation of libunwind package. + // Libunwind isn't always safe for threads that are in signal handlers. + // An approach to get the callstack of another thread is to use signal injection into the target thread. + + OVR_UNUSED(platformThreadContext); + OVR_UNUSED(threadSysIdHelp); + + size_t frameIndex = 0; + unw_cursor_t cursor; + unw_context_t uc; + unw_word_t ip, sp; + + unw_getcontext(&uc); // This gets the current thread's context. We could alternatively initialize another thread's context with it. + unw_init_local(&cursor, &uc); + + while((unw_step(&cursor) > 0) && (frameIndex < addressArrayCapacity)) + { + // We can get the function name here too on some platforms with unw_get_proc_info() and unw_get_proc_name(). + + if(skipCount) + --skipCount; + else + { + unw_get_reg(&cursor, UNW_REG_IP, &ip); + addressArray[frameIndex++] = (void*)ip; + } + } + + return frameIndex; + #else + OVR_UNUSED(addressArray); + OVR_UNUSED(addressArrayCapacity); + OVR_UNUSED(skipCount); + OVR_UNUSED(platformThreadContext); + OVR_UNUSED(threadSysIdHelp); + + return 0; + #endif +} + + +size_t SymbolLookup::GetBacktraceFromThreadHandle(void* addressArray[], size_t addressArrayCapacity, size_t skipCount, OVR::ThreadHandle threadHandle) +{ + #if defined(OVR_OS_MS) + size_t count = 0; + DWORD threadSysId = (DWORD)ConvertThreadHandleToThreadSysId(threadHandle); + + // Compare to 0, compare to the self 'pseudohandle' and compare to the self id. + if((threadHandle == OVR_THREADHANDLE_INVALID) || (threadHandle == ::GetCurrentThread()) || (threadSysId == ::GetCurrentThreadId())) // If threadSysId refers to the current thread... + return GetBacktrace(addressArray, addressArrayCapacity, skipCount, nullptr); + + // We are working with another thread. We need to suspend it and get its CONTEXT. + // Suspending other threads is risky, as they may be in some state that cannot be safely blocked. + BOOL result = false; + DWORD suspendResult = ::SuspendThread(threadHandle); // Requires that the handle have THREAD_SUSPEND_RESUME rights. + + if(suspendResult != (DWORD)-1) // Returns previous suspend count, or -1 if failed. + { + CONTEXT context; + context.ContextFlags = CONTEXT_CONTROL | CONTEXT_INTEGER; // Requires that the handle have THREAD_GET_CONTEXT rights. + result = ::GetThreadContext(threadHandle, &context); + count = GetBacktrace(addressArray, addressArrayCapacity, skipCount, &context); + suspendResult = ::ResumeThread(threadHandle); + OVR_ASSERT_AND_UNUSED(suspendResult != (DWORD)-1, suspendResult); + } + + return count; + + #elif defined(OVR_OS_APPLE) + mach_port_t threadSysID = pthread_mach_thread_np((pthread_t)threadHandle); // Convert pthread_t to mach thread id. + return GetBacktraceFromThreadSysId(addressArray, addressArrayCapacity, skipCount, (OVR::ThreadSysId)threadSysID); + + #elif defined(OVR_OS_LINUX) + // To do. + OVR_UNUSED(addressArray); + OVR_UNUSED(addressArrayCapacity); + OVR_UNUSED(skipCount); + OVR_UNUSED(threadHandle); + return 0; + #endif +} + + +size_t SymbolLookup::GetBacktraceFromThreadSysId(void* addressArray[], size_t addressArrayCapacity, size_t skipCount, OVR::ThreadSysId threadSysId) +{ + #if defined(OVR_OS_MS) + OVR::ThreadHandle threadHandle = ConvertThreadSysIdToThreadHandle(threadSysId); + if(threadHandle) + { + size_t count = GetBacktraceFromThreadHandle(addressArray, addressArrayCapacity, skipCount, threadHandle); + FreeThreadHandle(threadHandle); + return count; + } + return 0; + + #elif defined(OVR_OS_APPLE) + mach_port_t threadCurrent = pthread_mach_thread_np(pthread_self()); + mach_port_t thread = (mach_port_t)threadSysId; + + if(thread == threadCurrent) + { + return GetBacktrace(addressArray, addressArrayCapacity, skipCount, nullptr); + } + else + { + kern_return_t result = thread_suspend(thread); // Do we need to do this if it's an thread who exception is being handled? + size_t count = 0; + + if(result == KERN_SUCCESS) + { + #if defined(OVR_CPU_X86) || defined(OVR_CPU_X86_64) + x86_thread_state_t threadState; + #elif defined(OVR_CPU_ARM) + arm_thread_state_t threadState; + #endif + mach_msg_type_number_t stateCount = MACHINE_THREAD_STATE_COUNT; + + result = thread_get_state(thread, MACHINE_THREAD_STATE, (natural_t*)(uintptr_t)&threadState, &stateCount); + + if(result == KERN_SUCCESS) + count = GetBacktrace(addressArray, addressArrayCapacity, skipCount, &threadState, threadSysId); + + thread_resume(thread); + + return count; + } + } + + return 0; + + #elif defined(OVR_OS_LINUX) + // To do. + OVR_UNUSED(addressArray); + OVR_UNUSED(addressArrayCapacity); + OVR_UNUSED(skipCount); + OVR_UNUSED(threadSysId); + return 0; + #endif +} + + +// We need to return the required moduleInfoArrayCapacity. +size_t SymbolLookup::GetModuleInfoArray(ModuleInfo* pModuleInfoArray, size_t moduleInfoArrayCapacity) +{ + #if defined(OVR_OS_MS) + size_t moduleCountRequired = 0; // The count we would copy to pModuleInfoArray if moduleInfoArrayCapacity was enough. + size_t moduleCount = 0; // The count we actually copy to pModuleInfoArray. Will be <= moduleInfoArrayCapacity. + HANDLE hProcess = GetCurrentProcess(); + HMODULE hModuleArray[200]; + DWORD cbNeeded = 0; + MODULEINFO mi; + + if(EnumProcessModules(hProcess, hModuleArray, sizeof(hModuleArray), &cbNeeded)) + { + moduleCountRequired = ((cbNeeded / sizeof(HMODULE)) < OVR_ARRAY_COUNT(hModuleArray)) ? (cbNeeded / sizeof(HMODULE)) : OVR_ARRAY_COUNT(hModuleArray); + moduleCount = MIN(moduleCountRequired, OVR_ARRAY_COUNT(hModuleArray)); + moduleCount = MIN(moduleCount, moduleInfoArrayCapacity); + + for(size_t i = 0; i < moduleCount; i++) + { + ModuleInfo& moduleInfo = pModuleInfoArray[i]; + + memset(&mi, 0, sizeof(mi)); + BOOL result = GetModuleInformation(hProcess, hModuleArray[i], &mi, sizeof(mi)); + + if(result) + { + wchar_t pathW[MAX_PATH]; + char pathA[MAX_PATH * 3]; // *3 to handle UTF8 multibyte encoding. + + moduleInfo.handle = hModuleArray[i]; + moduleInfo.baseAddress = (uintptr_t)mi.lpBaseOfDll; + moduleInfo.size = mi.SizeOfImage; + + GetModuleFileNameW(hModuleArray[i], pathW, OVR_ARRAY_COUNT(pathW)); + OVR::UTF8Util::EncodeString(pathA, pathW, -1); // Problem: DecodeString provides no way to specify the destination capacity. + OVR::OVR_strlcpy(moduleInfo.filePath, pathA, OVR_ARRAY_COUNT(moduleInfo.filePath)); + + const char* fileName = GetFileNameFromPath(pathA); + OVR::OVR_strlcpy(moduleInfo.name, fileName, OVR_ARRAY_COUNT(moduleInfo.name)); + } + else + { + moduleInfo.handle = 0; + moduleInfo.baseAddress = 0; + moduleInfo.size = 0; + moduleInfo.filePath[0] = 0; + moduleInfo.name[0] = 0; + } + } + } + + return moduleCountRequired; + + #elif defined(OVR_OS_MAC) + size_t moduleCountRequired = 0; + size_t moduleCount = 0; + + struct MacModuleInfo // This struct exists solely so we can have a local function within this function.. + { + static void AddMacModuleInfo(ModuleInfo* pModuleInfoArrayL, size_t& moduleCountRequiredL, size_t& moduleCountL, size_t moduleInfoArrayCapacityL, + const char* pTypeFilterL, const char* pModulePath, uintptr_t currentSegmentPos, const MachHeader* pMachHeader, uint64_t offset) + { + for(size_t i = 0; i < pMachHeader->ncmds; i++) + { + const SegmentCommand* pSegmentCommand = reinterpret_cast(currentSegmentPos); + + if(pSegmentCommand->cmd == kLCSegment) + { + const size_t segnameSize = (sizeof(pSegmentCommand->segname) + 1); // +1 so we can have a trailing '\0'. + char segname[segnameSize]; + + memcpy(segname, pSegmentCommand->segname, sizeof(pSegmentCommand->segname)); + segname[segnameSize - 1] = '\0'; + + if(!pTypeFilterL || OVR_strncmp(segname, pTypeFilterL, sizeof(segname))) + { + moduleCountRequiredL++; + + if(moduleCountL < moduleInfoArrayCapacityL) + { + ModuleInfo& info = pModuleInfoArrayL[moduleCountL++]; + + info.baseAddress = (uint64_t)(pSegmentCommand->vmaddr + offset); + info.handle = reinterpret_cast((uintptr_t)info.baseAddress); + info.size = (uint64_t)pSegmentCommand->vmsize; + OVR_strlcpy(info.filePath, pModulePath, OVR_ARRAY_COUNT(info.filePath)); + OVR_strlcpy(info.name, GetFileNameFromPath(pModulePath), OVR_ARRAY_COUNT(info.name)); + + info.permissions[0] = (pSegmentCommand->initprot & VM_PROT_READ) ? 'r' : '-'; + info.permissions[1] = (pSegmentCommand->initprot & VM_PROT_WRITE) ? 'w' : '-'; + info.permissions[2] = (pSegmentCommand->initprot & VM_PROT_EXECUTE) ? 'x' : '-'; + info.permissions[3] = '/'; + info.permissions[4] = (pSegmentCommand->maxprot & VM_PROT_READ) ? 'r' : '-'; + info.permissions[5] = (pSegmentCommand->maxprot & VM_PROT_WRITE) ? 'w' : '-'; + info.permissions[6] = (pSegmentCommand->maxprot & VM_PROT_EXECUTE) ? 'x' : '-'; + info.permissions[7] = '\0'; + + OVR_strlcpy(info.type, pSegmentCommand->segname, OVR_ARRAY_COUNT(info.type)); + } + } + } + + currentSegmentPos += pSegmentCommand->cmdsize; + } + } + }; + + // Iterate dyld_all_image_infos->infoArray + const struct dyld_all_image_infos* pAllImageInfos = _dyld_get_all_image_infos(); + + for(uint32_t i = 0; i < pAllImageInfos->infoArrayCount; i++) + { + const char* pModulePath = pAllImageInfos->infoArray[i].imageFilePath; + + if(pModulePath && *pModulePath) + { + uintptr_t currentSegmentPos = (uintptr_t)pAllImageInfos->infoArray[i].imageLoadAddress; + const MachHeader* pMachHeader = reinterpret_cast(currentSegmentPos); + uint64_t offset = (uint64_t)_dyld_get_image_vmaddr_slide(i); + + currentSegmentPos += sizeof(*pMachHeader); + + MacModuleInfo::AddMacModuleInfo(pModuleInfoArray, moduleCountRequired, moduleCount, moduleInfoArrayCapacity, + nullptr /*"__TEXT"*/, pModulePath, currentSegmentPos, pMachHeader, offset); + } + } + + // In addition to iterating dyld_all_image_infos->infoArray we need to also iterate /usr/lib/dyld entries. + const MachHeader* pMachHeader = (const MachHeader*)pAllImageInfos->dyldImageLoadAddress; + uintptr_t currentSegmentPos = (uintptr_t)pMachHeader + sizeof(*pMachHeader); + char modulePath[OVR_MAX_PATH] = ""; + pid_t pid = getpid(); + int filenameLen = proc_regionfilename((int)pid, currentSegmentPos, modulePath, (uint32_t)sizeof(modulePath)); + + if(filenameLen > 0) + MacModuleInfo::AddMacModuleInfo(pModuleInfoArray, moduleCountRequired, moduleCount, moduleInfoArrayCapacity, + "__TEXT", modulePath, currentSegmentPos, pMachHeader, 0); + + return moduleCountRequired; + + #elif defined(EA_PLATFORM_LINUX) + // One approach is to read /proc/self/maps, which is supported by Linux (though not BSD). + // Linux glibc dladdr() can tell us what module an arbitrary function address comes from, but can't tell us the list of modules. + OVR_UNUSED(pModuleInfoArray); + OVR_UNUSED(moduleInfoArrayCapacity); + return 0; + + #else + OVR_UNUSED(pModuleInfoArray); + OVR_UNUSED(moduleInfoArrayCapacity); + return 0; + #endif +} + + +size_t SymbolLookup::GetThreadList(ThreadHandle* threadHandleArray, ThreadSysId* threadSysIdArray, size_t threadArrayCapacity) +{ + size_t countRequired = 0; + size_t count = 0; + + #if defined(OVR_OS_MS) + // Print a list of threads. + DWORD currentProcessId = GetCurrentProcessId(); + HANDLE hThreadSnap = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, currentProcessId); // ICreateToolhelp32Snapshot actually ignores currentProcessId. + + if(hThreadSnap != INVALID_HANDLE_VALUE) + { + THREADENTRY32 te32; + te32.dwSize = sizeof(THREADENTRY32); + + if(Thread32First(hThreadSnap, &te32)) + { + do + { + if(te32.th32OwnerProcessID == currentProcessId) + { + HANDLE hThread = ConvertThreadSysIdToThreadHandle(te32.th32ThreadID); + + if(hThread) + { + ++countRequired; + + if((threadHandleArray || threadSysIdArray) && (count < threadArrayCapacity)) + { + if(threadHandleArray) + threadHandleArray[count] = hThread; // The caller must call CloseHandle on this thread, or call DoneThreadList on the returned array. + if(threadSysIdArray) + threadSysIdArray[count] = ConvertThreadHandleToThreadSysId(hThread); + ++count; + } + + if(!threadHandleArray) // If we aren't giving this back to the user... + FreeThreadHandle(hThread); + } + } + } while(Thread32Next(hThreadSnap, &te32)); + } + + CloseHandle(hThreadSnap); + } + + #elif defined(OVR_OS_APPLE) + mach_port_t taskSelf = mach_task_self(); + thread_act_port_array_t threadArray; + mach_msg_type_number_t threadCount; + + kern_return_t result = task_threads(taskSelf, &threadArray, &threadCount); + + if(result == KERN_SUCCESS) + { + for(mach_msg_type_number_t i = 0; i < threadCount; i++) + { + ++countRequired; + + if((threadHandleArray || threadSysIdArray) && (count < threadArrayCapacity)) + { + if(threadHandleArray) + threadHandleArray[count] = pthread_from_mach_thread_np(threadArray[i]); + if(threadSysIdArray) + threadSysIdArray[count] = threadArray[i]; + ++count; + } + } + + vm_deallocate(taskSelf, (vm_address_t)threadArray, threadCount * sizeof(thread_act_t)); + } + + #elif defined(OVR_OS_LINUX) + // To do. + OVR_UNUSED(count); + OVR_UNUSED(threadHandleArray); + OVR_UNUSED(threadSysIdArray); + OVR_UNUSED(threadArrayCapacity); + #endif + + return countRequired; +} + + +void SymbolLookup::DoneThreadList(ThreadHandle* threadHandleArray, ThreadSysId* threadSysIdArray, size_t threadArrayCount) +{ + #if defined(OVR_OS_MS) + for(size_t i = 0; i != threadArrayCount; ++i) + { + if(threadHandleArray[i]) + { + CloseHandle(threadHandleArray[i]); + threadHandleArray[i] = OVR_THREADHANDLE_INVALID; + } + } + + OVR_UNUSED(threadSysIdArray); + #else + OVR_UNUSED(threadHandleArray); + OVR_UNUSED(threadSysIdArray); + OVR_UNUSED(threadArrayCount); + #endif +} + + +// Writes a given thread's callstack wity symbols to the given output. +// It may not be safe to call this from an exception handler, as sOutput allocates memory. +bool SymbolLookup::ReportThreadCallstack(OVR::String& sOutput, size_t skipCount, ThreadSysId threadSysId) +{ + if(!threadSysId) + threadSysId = GetCurrentThreadSysId(); + + void* addressArray[64]; + size_t addressCount = GetBacktraceFromThreadSysId(addressArray, OVR_ARRAY_COUNT(addressArray), skipCount, threadSysId); + + // Print the header + char headerBuffer[256]; + char threadName[32]; + char threadHandleStr[24]; + char threadSysIdStr[24]; + char stackBaseStr[24]; + char stackLimitStr[24]; + void* pStackBase; + void* pStackLimit; + //void* pStackCurrent; // Current stack pointer. To do: support reporting this. + ThreadHandle threadHandle = ConvertThreadSysIdToThreadHandle(threadSysId); + OVR::GetThreadStackBounds(pStackBase, pStackLimit, threadHandle); + + Thread::GetThreadName(threadName, OVR_ARRAY_COUNT(threadName), threadName); + SprintfThreadHandle(threadHandleStr, OVR_ARRAY_COUNT(threadHandleStr), threadHandle); + SprintfThreadSysId(threadSysIdStr, OVR_ARRAY_COUNT(threadSysIdStr), threadSysId); + SprintfAddress(stackBaseStr, OVR_ARRAY_COUNT(stackBaseStr), pStackBase); + SprintfAddress(stackLimitStr, OVR_ARRAY_COUNT(stackLimitStr), pStackLimit); + + if(threadName[0]) + OVR_snprintf(headerBuffer, OVR_ARRAY_COUNT(headerBuffer), "Thread \"%s\" handle: %s, id: %s, stack base: %s, stack limit: %s\r\n", threadName, threadHandleStr, threadSysIdStr, stackBaseStr, stackLimitStr); + else + OVR_snprintf(headerBuffer, OVR_ARRAY_COUNT(headerBuffer), "Thread handle: %s, id: %s, stack base: %s, stack limit: %s\r\n", threadHandleStr, threadSysIdStr, stackBaseStr, stackLimitStr); + + sOutput += headerBuffer; + + // Print the backtrace info + char backtraceBuffer[1024]; // Sometimes function symbol names are very long. + SymbolInfo symbolInfo; + const char* pModuleName; + + if(addressCount == 0) + { + sOutput += "\r\n"; + } + else + { + for(size_t i = 0; i < addressCount; ++i) + { + LookupSymbol((uint64_t)addressArray[i], symbolInfo); + + if(symbolInfo.pModuleInfo && symbolInfo.pModuleInfo->name[0]) + pModuleName = symbolInfo.pModuleInfo->name; + else + pModuleName = "(unknown module)"; + + char addressStr[24]; + SprintfAddress(addressStr, OVR_ARRAY_COUNT(addressStr), addressArray[i]); + + if(symbolInfo.filePath[0]) + OVR_snprintf(backtraceBuffer, OVR_ARRAY_COUNT(backtraceBuffer), "%-2u %-24s %s %s+%d %s:%d\r\n", (unsigned)i, pModuleName, addressStr, symbolInfo.function, symbolInfo.functionOffset, symbolInfo.filePath, symbolInfo.fileLineNumber); + else + OVR_snprintf(backtraceBuffer, OVR_ARRAY_COUNT(backtraceBuffer), "%-2u %-24s %s %s+%d\r\n", (unsigned)i, pModuleName, addressStr, symbolInfo.function, symbolInfo.functionOffset); + + sOutput += backtraceBuffer; + } + } + + FreeThreadHandle(threadHandle); + + return (addressCount > 0); +} + + +// Writes all thread's callstacks with symbols to the given output. +// It may not be safe to call this from an exception handler, as sOutput allocates memory. +bool SymbolLookup::ReportThreadCallstacks(OVR::String& sOutput, size_t skipCount) +{ + ThreadSysId threadSysIdArray[64]; + size_t threadSysIdCount = GetThreadList(nullptr, threadSysIdArray, OVR_ARRAY_COUNT(threadSysIdArray)); + + if(threadSysIdCount > OVR_ARRAY_COUNT(threadSysIdArray)) + threadSysIdCount = OVR_ARRAY_COUNT(threadSysIdArray); + + for(size_t i = 0; i < threadSysIdCount; i++) + { + String sTemp; + ReportThreadCallstack(sTemp, skipCount, threadSysIdArray[i]); + if(i > 0) + sOutput += "\r\n"; + sOutput += sTemp; + } + + return (threadSysIdCount > 0); +} + + +bool SymbolLookup::RefreshModuleList() +{ + if(!moduleListUpdated) + { + #if defined(OVR_OS_MS) + // We can't rely on SymRefreshModuleList because it's present in DbgHelp 6.5, + // which doesn't distribute with Windows 7. + + // Currently we support only refreshing the list once ever. With a little effort we could revise this code to + // support re-refreshing the list at runtime to account for the possibility that modules have recently been + // added or removed. + if(pSymLoadModule64) + { + const size_t requiredCount = GetModuleInfoArray(moduleInfoArray, OVR_ARRAY_COUNT(moduleInfoArray)); + moduleInfoArraySize = MIN(requiredCount, OVR_ARRAY_COUNT(moduleInfoArray)); + + HANDLE hProcess = GetCurrentProcess(); + + for(size_t i = 0; i < moduleInfoArraySize; i++) + pSymLoadModule64(hProcess, nullptr, moduleInfoArray[i].filePath, nullptr, moduleInfoArray[i].baseAddress, (DWORD)moduleInfoArray[i].size); + + moduleListUpdated = true; + } + #else + const size_t requiredCount = GetModuleInfoArray(moduleInfoArray, OVR_ARRAY_COUNT(moduleInfoArray)); + moduleInfoArraySize = MIN(requiredCount, OVR_ARRAY_COUNT(moduleInfoArray)); + moduleListUpdated = true; + #endif + } + + return true; +} + + +bool SymbolLookup::LookupSymbol(uint64_t address, SymbolInfo& symbolInfo) +{ + return LookupSymbols(&address, &symbolInfo, 1); +} + + +bool SymbolLookup::LookupSymbols(uint64_t* addressArray, SymbolInfo* pSymbolInfoArray, size_t arraySize) +{ + if(!moduleListUpdated) + { + RefreshModuleList(); + } + + #if defined(OVR_OS_MS) + union SYMBOL_INFO_UNION + { + SYMBOL_INFO msSymbolInfo; + char suffixPadding[sizeof(SYMBOL_INFO) + 1024]; + }; + + for(size_t i = 0; i < arraySize; i++) + { + uint64_t& address = addressArray[i]; + SymbolInfo& symbolInfo = pSymbolInfoArray[i]; + + // Copy the address and ModuleInfo + symbolInfo.address = addressArray[i]; + symbolInfo.pModuleInfo = GetModuleInfoForAddress(address); // We could also use siu.msSymbolInfo.ModBase to get the module slightly faster. + + // Get the function/offset. + SYMBOL_INFO_UNION siu; + memset(&siu, 0, sizeof(siu)); + siu.msSymbolInfo.SizeOfStruct = sizeof(siu.msSymbolInfo); + siu.msSymbolInfo.MaxNameLen = sizeof(siu.suffixPadding) - sizeof(SYMBOL_INFO) + 1; // +1 because SYMBOL_INFO itself has Name[1]. + + HANDLE hProcess = GetCurrentProcess(); + DWORD64 displacement64 = 0; + bool bResult = (pSymFromAddr != nullptr) && (pSymFromAddr(hProcess, address, &displacement64, &siu.msSymbolInfo) != FALSE); + + if(bResult) + { + symbolInfo.size = siu.msSymbolInfo.Size; + OVR_strlcpy(symbolInfo.function, siu.msSymbolInfo.Name, OVR_ARRAY_COUNT(symbolInfo.function)); + symbolInfo.functionOffset = (int32_t)displacement64; + } + else + { + symbolInfo.size = kMISizeInvalid; + symbolInfo.function[0] = 0; + symbolInfo.functionOffset = kMIFunctionOffsetInvalid; + } + + // Get the file/line + IMAGEHLP_LINE64 iLine64; + DWORD displacement = 0; + memset(&iLine64, 0, sizeof(iLine64)); + iLine64.SizeOfStruct = sizeof(iLine64); + + bResult = (pSymGetLineFromAddr64 != nullptr) && (pSymGetLineFromAddr64(hProcess, address, &displacement, &iLine64) != FALSE); + + if(bResult) + { + OVR_strlcpy(symbolInfo.filePath, iLine64.FileName, OVR_ARRAY_COUNT(symbolInfo.filePath)); + symbolInfo.fileLineNumber = (int32_t)iLine64.LineNumber; + } + else + { + symbolInfo.filePath[0] = 0; + symbolInfo.fileLineNumber = kMILineNumberInvalid; + } + + // To do: get the source code when possible. We need to use the user-registered directory paths and the symbolInfo.filePath + // and find the given file in the tree(s), then open the file and find the symbolInfo.fileLineNumber line (and surrounding lines). + // symbolInfo.sourceCode[1024] + symbolInfo.sourceCode[0] = '\0'; + } + + #elif defined(OVR_OS_APPLE) + // Apple has an internal CoreSymbolication library which could help with this. + // Third party implementations of the CoreSymbolication header are available and could be used + // to get file/line info better than other means. It used Objective C, so we'll need a .m or .mm file. + + memset(pSymbolInfoArray, 0, arraySize * sizeof(SymbolInfo)); + + for(size_t i = 0; i < arraySize; i++) + { + pSymbolInfoArray[i].address = addressArray[i]; + pSymbolInfoArray[i].pModuleInfo = GetModuleInfoForAddress(addressArray[i]); + } + + // Problem: backtrace_symbols allocates memory from malloc. If you got into a SIGSEGV due to + // malloc arena corruption (quite common) you will likely fault in backtrace_symbols. + // To do: Use allowMemoryAllocation here. + + #if (OVR_PTR_SIZE == 4) + // backtrace_symbols takes a void* array, but we have a uint64_t array. So for 32 bit we + // need to convert the 64 bit array to 32 bit temporarily for the backtrace_symbols call. + void* ptr32Array[256]; // To do: Remove this limit. + for(size_t i = 0, iEnd = MIN(arraySize, OVR_ARRAY_COUNT(ptr32Array)); i < iEnd; i++) + ptr32Array[i] = reinterpret_cast(addressArray[i]); + char** symbolArray = backtrace_symbols(reinterpret_cast(ptr32Array), (int)arraySize); + #else + char** symbolArray = backtrace_symbols(reinterpret_cast(addressArray), (int)arraySize); + #endif + + if(symbolArray) + { + for(size_t i = 0; i < arraySize; i++) + { + + // Generates a string like this: "0 OculusWorldDemo 0x000000010000cfd5 _ZN18OculusWorldDemoApp9OnStartupEiPPKc + 213" + static_assert(OVR_ARRAY_COUNT(pSymbolInfoArray[i].function) == 128, "Need to change the string format size below"); + + sscanf(symbolArray[i], "%*d %*s %*x %128s + %d", pSymbolInfoArray[i].function, &pSymbolInfoArray[i].functionOffset); + + if(allowMemoryAllocation) + { + int status = 0; + char* strDemangled = abi::__cxa_demangle(pSymbolInfoArray[i].function, nullptr, nullptr, &status); + + if(strDemangled) + { + OVR_strlcpy(pSymbolInfoArray[i].function, strDemangled, OVR_ARRAY_COUNT(pSymbolInfoArray[i].function)); + free(strDemangled); + } + } + } + + free(symbolArray); + } + + // To consider: use CoreSybolication to get file/line info instead. atos is a bit slow and cumbersome. + // https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/atos.1.html + // atos -p ... + // atos -o -l ... + // Generates output like this: "OVR::CreateException(OVR::CreateExceptionType) (in OculusWorldDemo) (ExceptionHandler.cpp:598)" + for(size_t i = 0; i < arraySize; i++) + { + struct stat statStruct; + + if(pSymbolInfoArray[i].pModuleInfo && pSymbolInfoArray[i].pModuleInfo->filePath[0] && (stat(pSymbolInfoArray[i].pModuleInfo->filePath, &statStruct) == 0)) + { + char command[PATH_MAX * 2]; // Problem: We can't unilaterally use pSymbolInfoArray[0] for all addresses. We need to match addresses to the corresponding modules. + OVR_snprintf(command, OVR_ARRAY_COUNT(command), "atos -o %s -l 0x%llx 0x%llx", + pSymbolInfoArray[i].pModuleInfo->filePath, (int64_t)pSymbolInfoArray[i].pModuleInfo->baseAddress, (int64_t)pSymbolInfoArray[i].address); + + char output[512]; + if(SpawnShellCommand(command, output, OVR_ARRAY_COUNT(output)) != (size_t)-1) + { + char* pLastOpenParen = strrchr(output, '('); + char* pColon = strrchr(output, ':'); + + if(pLastOpenParen && (pColon > pLastOpenParen)) + { + *pColon = '\0'; + OVR_strlcpy(pSymbolInfoArray[i].filePath, pLastOpenParen + 1, OVR_ARRAY_COUNT(pSymbolInfoArray[i].filePath)); + } + } + } + } + + #elif defined(OVR_OS_LINUX) + // We can use libunwind's unw_get_proc_name to try to get function name info. It can work regardless of relocation. + // Use backtrace_symbols and addr2line. Need to watch out for module load-time relocation. + // Ned to pass the -rdynamic flag to the linker. It will cause the linker to out in the link + // tables the name of all the none static functions in your code, not just the exported ones. + OVR_UNUSED(addressArray); + OVR_UNUSED(pSymbolInfoArray); + OVR_UNUSED(arraySize); + #endif + + return true; // To do: Return true only if something was found. +} + + +const ModuleInfo* SymbolLookup::GetModuleInfoForAddress(uint64_t address) +{ + // This is a linear seach. To consider: it would be significantly faster to search by + // address if we ordered it by base address and did a binary search. + for(size_t i = 0; i < moduleInfoArraySize; ++i) + { + const ModuleInfo& mi = moduleInfoArray[i]; + + if((mi.baseAddress <= address) && (address < (mi.baseAddress + mi.size))) + return &mi; + } + + return nullptr; +} + + + + +ExceptionInfo::ExceptionInfo() + : time() + , timeVal(0) + , backtrace() + , backtraceCount(0) + , threadHandle(OVR_THREADHANDLE_INVALID) + , threadSysId(OVR_THREADSYSID_INVALID) + , threadName() + , pExceptionInstructionAddress(nullptr) + , pExceptionMemoryAddress(nullptr) + , cpuContext() + , exceptionDescription() + , symbolInfo() + #if defined(OVR_OS_MS) + , exceptionRecord() + #elif defined(OVR_OS_APPLE) + , exceptionType(0) + , cpuExceptionId(0) + , cpuExceptionIdError(0) + , machExceptionDetail() + , machExceptionDetailCount(0) + #endif +{ +} + + + +ExceptionHandler::ExceptionHandler() + : enabled(false) + , reportPrivacyEnabled(true) + , exceptionResponse(kERHandle) + , exceptionListener(nullptr) + , exceptionListenerUserValue(0) + , appDescription() + , codeBasePathArray() + , reportFilePath() + , miniDumpFlags(0) + , miniDumpFilePath() + , file(nullptr) + , scratchBuffer() + , exceptionOccurred(false) + , handlingBusy(0) + , reportFilePathActual() + , minidumpFilePathActual() + , terminateReturnValue(0) + , exceptionInfo() + #if defined(OVR_OS_MS) + , vectoredHandle(nullptr) + , previousFilter(nullptr) + , pExceptionPointers(nullptr) + #elif defined(OVR_OS_MAC) + , machHandlerInitialized(false) + , machExceptionPort(0) + , machExceptionPortsSaved() + , machThreadShouldContinue(false) + , machThreadExecuting(false) + , machThread((pthread_t)OVR_THREADHANDLE_INVALID) + #endif +{ + SetExceptionPaths("default", "default"); +} + + +ExceptionHandler::~ExceptionHandler() +{ + if(enabled) + { + Enable(false); + } +} + + +#if defined(OVR_OS_MS) + static ExceptionHandler* sExceptionHandler = nullptr; + + LONG WINAPI Win32ExceptionFilter(LPEXCEPTION_POINTERS pExceptionPointers) + { + if(sExceptionHandler) + return (LONG)sExceptionHandler->ExceptionFilter(pExceptionPointers); + return EXCEPTION_CONTINUE_SEARCH; + } + + LONG ExceptionHandler::ExceptionFilter(LPEXCEPTION_POINTERS pExceptionPointers) + { + // Exception codes < 0x80000000 are not true exceptions but rather are debugger notifications. They include DBG_TERMINATE_THREAD, + // DBG_TERMINATE_PROCESS, DBG_CONTROL_BREAK, DBG_COMMAND_EXCEPTION, DBG_CONTROL_C, DBG_PRINTEXCEPTION_C, DBG_RIPEXCEPTION, + // and 0x406d1388 (thread named, http://blogs.msdn.com/b/stevejs/archive/2005/12/19/505815.aspx). + + if(pExceptionPointers->ExceptionRecord->ExceptionCode < 0x80000000) + return EXCEPTION_CONTINUE_SEARCH; + + // VC++ C++ exceptions use code 0xe06d7363 ('Emsc') + // http://support.microsoft.com/kb/185294 + // http://blogs.msdn.com/b/oldnewthing/archive/2010/07/30/10044061.aspx + if(pExceptionPointers->ExceptionRecord->ExceptionCode == 0xe06d7363) + return EXCEPTION_CONTINUE_SEARCH; + + if(handlingBusy.CompareAndSet_Acquire(0, 1)) // If we can successfully change it from 0 to 1. + { + exceptionOccurred = true; + + this->pExceptionPointers = pExceptionPointers; + + // Disable the handler while we do this processing. + ULONG result = RemoveVectoredExceptionHandler(vectoredHandle); + OVR_ASSERT_AND_UNUSED(result != 0, result); + + // Time + exceptionInfo.timeVal = time(nullptr); + exceptionInfo.time = *gmtime(&exceptionInfo.timeVal); + + // Thread id + // This is the thread id of the current thread and not the exception thread. + if(!DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(), &exceptionInfo.threadHandle, 0, true, DUPLICATE_SAME_ACCESS)) + exceptionInfo.threadHandle = 0; + exceptionInfo.threadSysId = ConvertThreadHandleToThreadSysId(exceptionInfo.threadHandle); + + OVR::GetThreadName(exceptionInfo.threadHandle, exceptionInfo.threadName, OVR_ARRAY_COUNT(exceptionInfo.threadName)); + + // Backtraces + exceptionInfo.backtraceCount = symbolLookup.GetBacktrace(exceptionInfo.backtrace, OVR_ARRAY_COUNT(exceptionInfo.backtrace)); + + // Context + exceptionInfo.cpuContext = *pExceptionPointers->ContextRecord; + exceptionInfo.exceptionRecord = *pExceptionPointers->ExceptionRecord; + exceptionInfo.pExceptionInstructionAddress = exceptionInfo.exceptionRecord.ExceptionAddress; + if((exceptionInfo.exceptionRecord.ExceptionCode == EXCEPTION_ACCESS_VIOLATION) || (exceptionInfo.exceptionRecord.ExceptionCode == EXCEPTION_IN_PAGE_ERROR)) + exceptionInfo.pExceptionMemoryAddress = (void*)exceptionInfo.exceptionRecord.ExceptionInformation[1]; // ExceptionInformation[0] indicates if it was a read (0), write (1), or data execution attempt (8). + else + exceptionInfo.pExceptionMemoryAddress = pExceptionPointers->ExceptionRecord->ExceptionAddress; + + WriteExceptionDescription(); + + if(miniDumpFilePath[0]) + WriteMiniDump(); + + if(reportFilePath[0]) + WriteReport(); + + if(exceptionListener) + exceptionListener->HandleException(exceptionListenerUserValue, this, &exceptionInfo, reportFilePathActual); + + if(exceptionInfo.threadHandle) + { + CloseHandle(exceptionInfo.threadHandle); + exceptionInfo.threadHandle = 0; + } + + // Restore the handler that we temporarily disabled above. + vectoredHandle = AddVectoredExceptionHandler(1, Win32ExceptionFilter); + + handlingBusy.Store_Release(0); + } + + if(exceptionResponse == ExceptionHandler::kERTerminate) + { + TerminateProcess(GetCurrentProcess(), (UINT)terminateReturnValue); + return terminateReturnValue; + } + else if(exceptionResponse == ExceptionHandler::kERThrow) + return EXCEPTION_CONTINUE_SEARCH; + else if(exceptionResponse == ExceptionHandler::kERContinue) + return EXCEPTION_CONTINUE_EXECUTION; + return EXCEPTION_EXECUTE_HANDLER; + } + +#endif // defined(OVR_OS_MS) + + +#if defined(OVR_OS_APPLE) + // http://www.opensource.apple.com/source/xnu/xnu-2050.22.13/ + // http://www.opensource.apple.com/source/xnu/xnu-2050.22.13/osfmk/man/ + // http://www.opensource.apple.com/source/Libc/Libc-825.26/ + // https://mikeash.com/pyblog/friday-qa-2013-01-11-mach-exception-handlers.html + + void* ExceptionHandler::MachHandlerThreadFunction() + { + __Request__mach_exception_raise_state_identity_t msg; + __Reply__mach_exception_raise_state_identity_t reply; + mach_msg_return_t result; + + machThreadExecuting = true; + pthread_setname_np("ExceptionHandler"); + + while(machThreadShouldContinue) + { + mach_msg_option_t options = MACH_RCV_MSG | MACH_RCV_LARGE; + natural_t timeout = 0; // Would be better to support a non-zero time. + + if(timeout) + options |= MACH_RCV_TIMEOUT; + + result = mach_msg(&msg.Head, options, 0, sizeof(msg), machExceptionPort, timeout, MACH_PORT_NULL); + + if(msg.Head.msgh_id != sMachCancelMessageType) + { + if(result == MACH_MSG_SUCCESS) + { + if(mach_exc_server_OVR(&msg.Head, &reply.Head) == 0) //This will call our HandleMachException function. + result = ~MACH_MSG_SUCCESS; + } + + // Send the reply + if(result == MACH_MSG_SUCCESS) + { + result = mach_msg(&reply.Head, MACH_SEND_MSG, reply.Head.msgh_size, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + + if(result != MACH_MSG_SUCCESS) + { + // Failure. + } + } + } + } + + machThreadExecuting = false; + + return nullptr; + } + + + kern_return_t ExceptionHandler::HandleMachException(mach_port_t /*machPort*/, mach_port_t threadSysId, mach_port_t machTask, + exception_type_t machExceptionType, mach_exception_data_type_t* pExceptionDetail, + mach_msg_type_number_t exceptionDetailCount, int* /*pMachExceptionFlavor*/, thread_state_t threadStatePrev, + mach_msg_type_number_t /*threadStatePrevCount*/, thread_state_t /*threadStateNew*/, + mach_msg_type_number_t* /*pThreadStateNewCount*/) + { + // We don't want to handle exceptions for other processes. + if(machTask != mach_task_self()) + return ForwardMachException(threadSysId, machTask, machExceptionType, pExceptionDetail, exceptionDetailCount); + + if(handlingBusy.CompareAndSet_Acquire(0, 1)) // If we can successfully change it from 0 to 1. + { + exceptionOccurred = true; + + // Disable the handler while we do this processing. + // To do. + + // Time + exceptionInfo.timeVal = time(nullptr); + exceptionInfo.time = *gmtime(&exceptionInfo.timeVal); + + // Thread id + exceptionInfo.threadHandle = pthread_from_mach_thread_np(threadSysId); + exceptionInfo.threadSysId = threadSysId; + pthread_getname_np((pthread_t)exceptionInfo.threadHandle, exceptionInfo.threadName, sizeof(exceptionInfo.threadName)); + + // Backtraces + exceptionInfo.backtraceCount = symbolLookup.GetBacktraceFromThreadSysId(exceptionInfo.backtrace, OVR_ARRAY_COUNT(exceptionInfo.backtrace), 0, threadSysId); + + // Context + #if defined(OVR_CPU_X86) || defined(OVR_CPU_X86_64) + // We can read x86_THREAD_STATE directly fromk threadStatePrev. + exceptionInfo.cpuContext.threadState = *reinterpret_cast(threadStatePrev); + + mach_msg_type_number_t stateCount = x86_FLOAT_STATE_COUNT; + thread_get_state(threadSysId, x86_FLOAT_STATE, (natural_t*)&exceptionInfo.cpuContext.floatState, &stateCount); + + stateCount = x86_DEBUG_STATE_COUNT; + thread_get_state(threadSysId, x86_DEBUG_STATE, (natural_t*)&exceptionInfo.cpuContext.debugState, &stateCount); + + stateCount = x86_AVX_STATE_COUNT; + thread_get_state(threadSysId, x86_AVX_STATE, (natural_t*)&exceptionInfo.cpuContext.avxState, &stateCount); + + stateCount = x86_EXCEPTION_STATE_COUNT; + thread_get_state(threadSysId, x86_EXCEPTION_STATE, (natural_t*)&exceptionInfo.cpuContext.exceptionState, &stateCount); + + #if defined(OVR_CPU_X86) + exceptionInfo.pExceptionInstructionAddress = (void*)exceptionInfo.cpuContext.threadState.uts.ts32.__eip; + exceptionInfo.pExceptionMemoryAddress = (void*)exceptionInfo.cpuContext.exceptionState.ues.es32.__faultvaddr; + exceptionInfo.cpuExceptionId = exceptionInfo.cpuContext.exceptionState.ues.es32.__trapno; + exceptionInfo.cpuExceptionIdError = exceptionInfo.cpuContext.exceptionState.ues.es32.__err; + #else + exceptionInfo.pExceptionInstructionAddress = (void*)exceptionInfo.cpuContext.threadState.uts.ts64.__rip; + exceptionInfo.pExceptionMemoryAddress = (void*)exceptionInfo.cpuContext.exceptionState.ues.es64.__faultvaddr; + exceptionInfo.cpuExceptionId = exceptionInfo.cpuContext.exceptionState.ues.es64.__trapno; + exceptionInfo.cpuExceptionIdError = exceptionInfo.cpuContext.exceptionState.ues.es64.__err; + #endif + #endif + + exceptionInfo.exceptionType = machExceptionType; + + exceptionInfo.machExceptionDetailCount = MIN(exceptionDetailCount, OVR_ARRAY_COUNT(exceptionInfo.machExceptionDetail)); + for(int i = 0; i < exceptionInfo.machExceptionDetailCount; i++) + exceptionInfo.machExceptionDetail[i] = pExceptionDetail[i]; + + WriteExceptionDescription(); + + if(reportFilePath[0]) + WriteReport(); + + if(miniDumpFilePath[0]) + WriteMiniDump(); + + if(exceptionListener) + exceptionListener->HandleException(exceptionListenerUserValue, this, &exceptionInfo, reportFilePathActual); + + // Re-restore the handler. + // To do. + + handlingBusy.Store_Release(0); + } + + kern_return_t result = KERN_FAILURE; // By default pass on the exception to another handler after we are done here. + + if(exceptionResponse == ExceptionHandler::kERTerminate) + ::exit(terminateReturnValue); + else if(exceptionResponse == ExceptionHandler::kERThrow) + ForwardMachException(threadSysId, machTask, machExceptionType, pExceptionDetail, exceptionDetailCount); + else if(exceptionResponse == ExceptionHandler::kERDefault) + ::exit(terminateReturnValue); + else if(exceptionResponse == ExceptionHandler::kERContinue) + result = KERN_SUCCESS; // This will trigger a re-execution of the function. + + return result; + } + + + bool ExceptionHandler::InitMachExceptionHandler() + { + if(!machHandlerInitialized) + { + mach_port_t machTaskSelf = mach_task_self(); + kern_return_t result = MACH_MSG_SUCCESS; + exception_mask_t mask = EXC_MASK_BAD_ACCESS | EXC_MASK_BAD_INSTRUCTION | EXC_MASK_ARITHMETIC | EXC_MASK_CRASH; + + if(machExceptionPort == MACH_PORT_NULL) + { + result = mach_port_allocate(machTaskSelf, MACH_PORT_RIGHT_RECEIVE, &machExceptionPort); + + if(result == MACH_MSG_SUCCESS) + { + result = mach_port_insert_right(machTaskSelf, machExceptionPort, machExceptionPort, MACH_MSG_TYPE_MAKE_SEND); + + if(result == MACH_MSG_SUCCESS) + result = task_get_exception_ports(machTaskSelf, mask, machExceptionPortsSaved.masks, &machExceptionPortsSaved.count, + machExceptionPortsSaved.ports, machExceptionPortsSaved.behaviors, machExceptionPortsSaved.flavors); + } + } + + if(result == MACH_MSG_SUCCESS) + { + result = task_set_exception_ports(machTaskSelf, mask, machExceptionPort, EXCEPTION_STATE_IDENTITY | MACH_EXCEPTION_CODES, MACHINE_THREAD_STATE); + + if(result == MACH_MSG_SUCCESS) + { + machThreadShouldContinue = true; + + pthread_attr_t attr; + pthread_attr_init(&attr); + + result = pthread_create(&machThread, &attr, MachHandlerThreadFunctionStatic, (void*)this); + pthread_attr_destroy(&attr); + + machHandlerInitialized = (result == 0); + } + } + + if(!machHandlerInitialized) + ShutdownMachExceptionHandler(); + } + + return machHandlerInitialized; + } + + + void ExceptionHandler::ShutdownMachExceptionHandler() + { + if(machThreadExecuting) + { + machThreadShouldContinue = false; // Tell it to stop. + + // Cancel the current exception handler thread (which is probably blocking in a call to mach_msg) by sending it a cencel message. + struct CancelMessage + { + mach_msg_header_t msgHeader; + }; + + CancelMessage msg; + memset(&msg.msgHeader, 0, sizeof(CancelMessage)); + msg.msgHeader.msgh_id = sMachCancelMessageType; + msg.msgHeader.msgh_size = sizeof(CancelMessage); + msg.msgHeader.msgh_bits = MACH_MSGH_BITS_REMOTE(MACH_MSG_TYPE_MAKE_SEND); + msg.msgHeader.msgh_remote_port = machExceptionPort; + msg.msgHeader.msgh_local_port = MACH_PORT_NULL; + + mach_msg_return_t result = mach_msg(&msg.msgHeader, MACH_SEND_MSG, msg.msgHeader.msgh_size, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + + if(result == MACH_MSG_SUCCESS) + { + const double threeSecondsLater = ovr_GetTimeInSeconds() + 3.f; + + while(machThreadExecuting && (ovr_GetTimeInSeconds() < threeSecondsLater)) + { + timespec ts = { 0, 1000000000 }; + nanosleep(&ts, nullptr); + } + } + + void* joinResult = nullptr; + pthread_join(machThread, &joinResult); + machThread = 0; + } + + if(machExceptionPort != MACH_PORT_NULL) + { + // Restore the previous ports + kern_return_t result = KERN_SUCCESS; + mach_port_t machTaskSelf = mach_task_self(); + + for(unsigned i = 0; (i < machExceptionPortsSaved.count) && (result == KERN_SUCCESS); i++) + { + result = task_set_exception_ports(machTaskSelf, machExceptionPortsSaved.masks[i], machExceptionPortsSaved.ports[i], + machExceptionPortsSaved.behaviors[i], machExceptionPortsSaved.flavors[i]); + } + + mach_port_deallocate(machTaskSelf, machExceptionPort); + machExceptionPort = MACH_PORT_NULL; + } + + machHandlerInitialized = false; + } + + + kern_return_t ExceptionHandler::ForwardMachException(mach_port_t thread, mach_port_t task, exception_type_t exceptionType, + mach_exception_data_t pExceptionDetail, mach_msg_type_number_t exceptionDetailCount) + { + kern_return_t result = KERN_FAILURE; + mach_msg_type_number_t i; + + for(i = 0; i < machExceptionPortsSaved.count; i++) + { + if(machExceptionPortsSaved.masks[i] & (1 << exceptionType)) + break; + } + + if(i < machExceptionPortsSaved.count) + { + mach_port_t port = machExceptionPortsSaved.ports[i]; + exception_behavior_t behavior = machExceptionPortsSaved.behaviors[i]; + thread_state_flavor_t flavor = machExceptionPortsSaved.flavors[i]; + mach_msg_type_number_t threadStateCount = THREAD_STATE_MAX; + thread_state_data_t threadState; + + if(behavior != EXCEPTION_DEFAULT) + thread_get_state(thread, flavor, threadState, &threadStateCount); + + switch(behavior) + { + case EXCEPTION_DEFAULT: + result = mach_exception_raise_OVR(port, thread, task, exceptionType, pExceptionDetail, exceptionDetailCount); + break; + + case EXCEPTION_STATE: + result = mach_exception_raise_state_OVR(port, exceptionType, pExceptionDetail, exceptionDetailCount, + &flavor, threadState, threadStateCount, threadState, &threadStateCount); + break; + + case EXCEPTION_STATE_IDENTITY: + result = mach_exception_raise_state_identity_OVR(port, thread, task, exceptionType, pExceptionDetail, + exceptionDetailCount, &flavor, threadState, threadStateCount, threadState, &threadStateCount); + break; + + default: + result = KERN_FAILURE; + break; + } + + if(behavior != EXCEPTION_DEFAULT) + result = thread_set_state(thread, flavor, threadState, threadStateCount); + } + + return result; + } + + +#endif // OVR_OS_APPLE + + +bool ExceptionHandler::Enable(bool enable) +{ + #if defined(OVR_OS_MS) + if(enable && !enabled) + { + OVR_ASSERT(vectoredHandle == nullptr); + vectoredHandle = AddVectoredExceptionHandler(1, Win32ExceptionFilter); // Windows call. + enabled = (vectoredHandle != nullptr); + OVR_ASSERT(enabled); + sExceptionHandler = this; + return enabled; + } + else if(!enable && enabled) + { + if(sExceptionHandler == this) + sExceptionHandler = nullptr; + OVR_ASSERT(vectoredHandle != nullptr); + ULONG result = RemoveVectoredExceptionHandler(vectoredHandle); // Windows call. + OVR_ASSERT_AND_UNUSED(result != 0, result); + vectoredHandle = nullptr; + enabled = false; + return true; + } + + #elif defined(OVR_OS_APPLE) + + if(enable && !enabled) + { + enabled = InitMachExceptionHandler(); + OVR_ASSERT(enabled); + sExceptionHandler = this; + return enabled; + } + else if(!enable && enabled) + { + if(sExceptionHandler == this) + sExceptionHandler = nullptr; + ShutdownMachExceptionHandler(); + enabled = false; + return true; + } + #else + OVR_UNUSED(enable); + #endif + + return true; +} + + +void ExceptionHandler::EnableReportPrivacy(bool enable) +{ + reportPrivacyEnabled = enable; +} + +void ExceptionHandler::WriteExceptionDescription() +{ + #if defined(OVR_OS_MS) + // There is some extra information available for AV exception. + if(exceptionInfo.exceptionRecord.ExceptionCode == EXCEPTION_ACCESS_VIOLATION) + { + const char* error = (exceptionInfo.exceptionRecord.ExceptionInformation[0] == 0) ? "reading" : + ((exceptionInfo.exceptionRecord.ExceptionInformation[0] == 1) ? "writing" : "executing"); + + char addressStr[24]; + SprintfAddress(addressStr, OVR_ARRAY_COUNT(addressStr), exceptionInfo.pExceptionMemoryAddress); + OVR::OVR_snprintf(exceptionInfo.exceptionDescription, OVR_ARRAY_COUNT(exceptionInfo.exceptionDescription), "ACCESS_VIOLATION %s address %s", error, addressStr); + } + else + { + exceptionInfo.exceptionDescription[0] = 0; + + // Process "standard" exceptions, other than 'access violation' + #define FORMAT_EXCEPTION(x) \ + case EXCEPTION_##x: \ + OVR::OVR_strlcpy(exceptionInfo.exceptionDescription, #x, OVR_ARRAY_COUNT(exceptionInfo.exceptionDescription)); \ + break; + + switch(exceptionInfo.exceptionRecord.ExceptionCode) + { + //FORMAT_EXCEPTION(ACCESS_VIOLATION) Already handled above. + FORMAT_EXCEPTION(DATATYPE_MISALIGNMENT) + FORMAT_EXCEPTION(BREAKPOINT) + FORMAT_EXCEPTION(SINGLE_STEP) + FORMAT_EXCEPTION(ARRAY_BOUNDS_EXCEEDED) + FORMAT_EXCEPTION(FLT_DENORMAL_OPERAND) + FORMAT_EXCEPTION(FLT_DIVIDE_BY_ZERO) + FORMAT_EXCEPTION(FLT_INEXACT_RESULT) + FORMAT_EXCEPTION(FLT_INVALID_OPERATION) + FORMAT_EXCEPTION(FLT_OVERFLOW) + FORMAT_EXCEPTION(FLT_STACK_CHECK) + FORMAT_EXCEPTION(FLT_UNDERFLOW) + FORMAT_EXCEPTION(INT_DIVIDE_BY_ZERO) + FORMAT_EXCEPTION(INT_OVERFLOW) + FORMAT_EXCEPTION(PRIV_INSTRUCTION) + FORMAT_EXCEPTION(IN_PAGE_ERROR) + FORMAT_EXCEPTION(ILLEGAL_INSTRUCTION) + FORMAT_EXCEPTION(NONCONTINUABLE_EXCEPTION) + FORMAT_EXCEPTION(STACK_OVERFLOW) + FORMAT_EXCEPTION(INVALID_DISPOSITION) + FORMAT_EXCEPTION(GUARD_PAGE) + FORMAT_EXCEPTION(INVALID_HANDLE) + #if defined(EXCEPTION_POSSIBLE_DEADLOCK) && defined(STATUS_POSSIBLE_DEADLOCK) // This type seems to be non-existant in practice. + FORMAT_EXCEPTION(POSSIBLE_DEADLOCK) + #endif + } + + // If not one of the "known" exceptions, try to get the string from NTDLL.DLL's message table. + if(exceptionInfo.exceptionDescription[0] == 0) + { + char addressStr[24]; + SprintfAddress(addressStr, OVR_ARRAY_COUNT(addressStr), exceptionInfo.pExceptionMemoryAddress); + + #if !defined(OVR_OS_CONSOLE) // If FormatMessage is supported... + char buffer[384]; + DWORD capacity = OVR_ARRAY_COUNT(buffer); + + const size_t length = (size_t)FormatMessageA(FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_HMODULE, + GetModuleHandleW(L"NTDLL.DLL"), exceptionInfo.exceptionRecord.ExceptionCode, 0, buffer, capacity, nullptr); + if(length) + OVR::OVR_snprintf(exceptionInfo.exceptionDescription, OVR_ARRAY_COUNT(exceptionInfo.exceptionDescription), + "%s at instruction %s", buffer, addressStr); + #endif + + // If everything else failed just show the hex code. + if(exceptionInfo.exceptionDescription[0] == 0) + OVR::OVR_snprintf(exceptionInfo.exceptionDescription, OVR_ARRAY_COUNT(exceptionInfo.exceptionDescription), + "Unknown exception 0x%08x at instruction %s", exceptionInfo.exceptionRecord.ExceptionCode, addressStr); + } + } + + #elif defined(OVR_OS_APPLE) + struct MachExceptionInfo + { + static const char* GetCPUExceptionIdString(uint32_t cpuExceptionId) + { + const char* id; + + #if defined(OVR_CPU_X86) || defined(OVR_CPU_X86_64) + switch (cpuExceptionId) + { + case 0: id = "integer div/0"; break; + case 1: id = "breakpoint fault"; break; + case 2: id = "non-maskable interrupt"; break; + case 3: id = "int 3"; break; + case 4: id = "overflow"; break; + case 5: id = "bounds check failure"; break; + case 6: id = "invalid instruction"; break; + case 7: id = "coprocessor unavailable"; break; + case 8: id = "exception within exception"; break; + case 9: id = "coprocessor segment overrun"; break; + case 10: id = "invalid task switch"; break; + case 11: id = "segment not present"; break; + case 12: id = "stack exception"; break; + case 13: id = "general protection fault"; break; + case 14: id = "page fault"; break; + case 16: id = "coprocessor error"; break; + default: id = ""; break; + } + #else + // To do: Support ARM or others. + #endif + + return id; + } + + static const char* GetMachExceptionTypeString(uint64_t exceptionCause) + { + switch (exceptionCause) + { + case EXC_ARITHMETIC: return "EXC_ARITHMETIC"; + case EXC_BAD_ACCESS: return "EXC_BAD_ACCESS"; + case EXC_BAD_INSTRUCTION: return "EXC_BAD_INSTRUCTION"; + case EXC_BREAKPOINT: return "EXC_BREAKPOINT"; + case EXC_CRASH: return "EXC_CRASH"; + case EXC_EMULATION: return "EXC_EMULATION"; + case EXC_MACH_SYSCALL: return "EXC_MACH_SYSCALL"; + case EXC_RPC_ALERT: return "EXC_RPC_ALERT"; + case EXC_SOFTWARE: return "EXC_SOFTWARE"; + case EXC_SYSCALL: return "EXC_SYSCALL"; + }; + + return "EXC_"; + } + + static const char* GetMachExceptionIdString(uint64_t machExceptionId, uint64_t code0) + { + const char* id = ""; + + #if defined(OVR_CPU_X86) || defined(OVR_CPU_X86_64) + switch (machExceptionId) + { + case EXC_ARITHMETIC: + switch (code0) + { + case EXC_I386_BOUND: id = "EXC_I386_BOUND"; break; + case EXC_I386_DIV: id = "EXC_I386_DIV"; break; + case EXC_I386_EMERR: id = "EXC_I386_EMERR"; break; + case EXC_I386_EXTERR: id = "EXC_I386_EXTERR"; break; + case EXC_I386_EXTOVR: id = "EXC_I386_EXTOVR"; break; + case EXC_I386_INTO: id = "EXC_I386_INTO"; break; + case EXC_I386_NOEXT: id = "EXC_I386_NOEXT"; break; + case EXC_I386_SSEEXTERR: id = "EXC_I386_SSEEXTERR"; break; + } + break; + + case EXC_BAD_INSTRUCTION: + if(code0 == EXC_I386_INVOP) + id = "EXC_I386_INVOP"; + break; + + case EXC_BREAKPOINT: + if(code0 == EXC_I386_BPT) + id = "EXC_I386_BPT"; + else if(code0 == EXC_I386_SGL) + id = "EXC_I386_SGL"; + break; + }; + #else + // To do. + #endif + + return id; + } + }; + + OVR::OVR_snprintf(exceptionInfo.exceptionDescription, OVR_ARRAY_COUNT(exceptionInfo.exceptionDescription), + "Mach exception type: %llu (%s)\r\n", exceptionInfo.exceptionType, MachExceptionInfo::GetMachExceptionTypeString(exceptionInfo.exceptionType)); + + OVR::OVR_snprintf(scratchBuffer, OVR_ARRAY_COUNT(scratchBuffer), "CPU exception info: exception id: %u (%s), exception id error: %u, fault memory address: %p\r\n", + exceptionInfo.cpuExceptionId, MachExceptionInfo::GetCPUExceptionIdString(exceptionInfo.cpuExceptionId), exceptionInfo.cpuExceptionIdError, exceptionInfo.pExceptionMemoryAddress); + OVR::OVR_strlcat(exceptionInfo.exceptionDescription, scratchBuffer, OVR_ARRAY_COUNT(exceptionInfo.exceptionDescription)); + + + OVR::OVR_snprintf(scratchBuffer, OVR_ARRAY_COUNT(scratchBuffer), "Mach exception info: exception id: %llu (%s), 0x%llx (%llu)\r\n", (uint64_t)exceptionInfo.machExceptionDetail[0], + MachExceptionInfo::GetMachExceptionIdString(exceptionInfo.exceptionType, exceptionInfo.machExceptionDetail[0]), + (uint64_t)exceptionInfo.machExceptionDetail[1], (uint64_t)exceptionInfo.machExceptionDetail[1]); + OVR::OVR_strlcat(exceptionInfo.exceptionDescription, scratchBuffer, OVR_ARRAY_COUNT(exceptionInfo.exceptionDescription)); + #else + // To do. + exceptionInfo.exceptionDescription[0] = 0; + #endif +} + + +void ExceptionHandler::WriteReportLine(const char* pLine) +{ + fwrite(pLine, strlen(pLine), 1, file); +} + + +void ExceptionHandler::WriteReportLineF(const char* format, ...) +{ + va_list args; + va_start(args, format); + int length = OVR_vsnprintf(scratchBuffer, OVR_ARRAY_COUNT(scratchBuffer), format, args); + if(length >= (int)OVR_ARRAY_COUNT(scratchBuffer)) // If we didn't have enough space... + length = (OVR_ARRAY_COUNT(scratchBuffer) - 1); // ... use what we have. + va_end(args); + + fwrite(scratchBuffer, length, 1, file); +} + + +// Thread +// 0
: +// 1
: +// . . . +// +void ExceptionHandler::WriteThreadCallstack(ThreadHandle threadHandle, ThreadSysId threadSysId, const char* additionalInfo) +{ + // We intentionally do not directly use the SymbolInfo::ReportThreadCallstack function because that function allocates memory, + // which we cannot do due to possibly being within an exception handler. + + // Print the header + char threadName[32]; + char threadHandleStr[32]; + char threadSysIdStr[32]; + char stackBaseStr[24]; + char stackLimitStr[24]; + char stackCurrentStr[24]; + void* pStackBase; + void* pStackLimit; + bool isExceptionThread = (threadSysId == exceptionInfo.threadSysId); + + #if defined(OVR_OS_MS) && (OVR_PTR_SIZE == 8) + void* pStackCurrent = (threadSysId == exceptionInfo.threadSysId) ? (void*)exceptionInfo.cpuContext.Rsp : nullptr; // We would need to suspend the thread, get its context, resume it, then read the rsp register. It turns out we are already doing that suspend/resume below in the backtrace call. + #elif defined(OVR_OS_MS) + void* pStackCurrent = (threadSysId == exceptionInfo.threadSysId) ? (void*)exceptionInfo.cpuContext.Esp : nullptr; + #elif defined(OVR_OS_MAC) && (OVR_PTR_SIZE == 8) + void* pStackCurrent = (threadSysId == exceptionInfo.threadSysId) ? (void*)exceptionInfo.cpuContext.threadState.uts.ts64.__rsp : nullptr; + #elif defined(OVR_OS_MAC) + void* pStackCurrent = (threadSysId == exceptionInfo.threadSysId) ? (void*)exceptionInfo.cpuContext.threadState.uts.ts32.__esp : nullptr; + #elif defined(OVR_OS_LINUX) + void* pStackCurrent = nullptr; // To do. + #endif + + OVR::GetThreadStackBounds(pStackBase, pStackLimit, threadHandle); + + OVR::Thread::GetThreadName(threadName, OVR_ARRAY_COUNT(threadName), threadName); + SprintfThreadHandle(threadHandleStr, OVR_ARRAY_COUNT(threadHandleStr), threadHandle); + SprintfThreadSysId(threadSysIdStr, OVR_ARRAY_COUNT(threadSysIdStr), threadSysId); + SprintfAddress(stackBaseStr, OVR_ARRAY_COUNT(stackBaseStr), pStackBase); + SprintfAddress(stackLimitStr, OVR_ARRAY_COUNT(stackLimitStr), pStackLimit); + SprintfAddress(stackCurrentStr, OVR_ARRAY_COUNT(stackCurrentStr), pStackCurrent); + + if(threadName[0]) + WriteReportLineF("Thread \"%s\" handle: %s, id: %s, stack base: %s, stack limit: %s, stack current: %s, %s\r\n", threadName, threadHandleStr, threadSysIdStr, stackBaseStr, stackLimitStr, stackCurrentStr, additionalInfo ? additionalInfo : ""); + else + WriteReportLineF("Thread handle: %s, id: %s, stack base: %s, stack limit: %s, stack current: %s, %s\r\n", threadHandleStr, threadSysIdStr, stackBaseStr, stackLimitStr, stackCurrentStr, additionalInfo ? additionalInfo : ""); + + // Print the backtrace info + void* addressArray[64]; + size_t addressCount = symbolLookup.GetBacktraceFromThreadSysId(addressArray, OVR_ARRAY_COUNT(addressArray), 0, threadSysId); + SymbolInfo symbolInfo; + const char* pModuleName; + size_t backtraceSkipCount = 0; + + if(isExceptionThread) + { + // If this thread is the exception thread, skip some frames. + #if defined(OVR_OS_MS) + size_t i, iEnd = MIN(16, addressCount); + + for(i = 0; i < iEnd; i++) + { + symbolLookup.LookupSymbol((uint64_t)addressArray[i], symbolInfo); + if(strstr(symbolInfo.function, "UserExceptionDispatcher") != nullptr) + break; + } + + if(i < iEnd) // If found... + backtraceSkipCount = i; + else if(addressCount >= 9) // Else default to 9, which is coincidentally what works. + backtraceSkipCount = 9; + else + backtraceSkipCount = 0; + + addressArray[backtraceSkipCount] = exceptionInfo.pExceptionInstructionAddress; + #endif + } + + if(addressCount == 0) + { + WriteReportLine("\r\n\r\n"); + } + else + { + for(size_t i = backtraceSkipCount; i < addressCount; ++i) + { + symbolLookup.LookupSymbol((uint64_t)addressArray[i], symbolInfo); + + if(symbolInfo.pModuleInfo && symbolInfo.pModuleInfo->name[0]) + pModuleName = symbolInfo.pModuleInfo->name; + else + pModuleName = "(unknown module)"; + + char addressStr[24]; + SprintfAddress(addressStr, OVR_ARRAY_COUNT(addressStr), addressArray[i]); + + if(symbolInfo.filePath[0]) + WriteReportLineF("%-2u %-24s %s %s+%d %s:%d\r\n%s", (unsigned)i, pModuleName, addressStr, + symbolInfo.function, symbolInfo.functionOffset, symbolInfo.filePath, + symbolInfo.fileLineNumber, (i + 1) == addressCount ? "\r\n" : ""); + else + WriteReportLineF("%-2u %-24s %s %s+%d\r\n%s", (unsigned)i, pModuleName, addressStr, + symbolInfo.function, symbolInfo.functionOffset, (i + 1) == addressCount ? "\r\n" : ""); // If this is the last line, append another \r\n. + } + } +} + + +void ExceptionHandler::WriteReport() +{ + // It's important that we don't allocate any memory here if we can help it. + using namespace OVR; + + if(strstr(reportFilePath, "%s")) // If the user-specified file path includes a date/time component... + { + char dateTimeBuffer[64]; + FormatDateTime(dateTimeBuffer, OVR_ARRAY_COUNT(dateTimeBuffer), exceptionInfo.timeVal, true, true, false, true); + OVR_snprintf(reportFilePathActual, OVR_ARRAY_COUNT(reportFilePathActual), reportFilePath, dateTimeBuffer); + } + else + { + OVR_strlcpy(reportFilePathActual, reportFilePath, OVR_ARRAY_COUNT(reportFilePathActual)); + } + + file = fopen(reportFilePathActual, "w"); + OVR_ASSERT(file != nullptr); + if(!file) + return; + + symbolLookup.Initialize(); + + { + // Exception information + WriteReportLine("Exception Info\r\n"); + + WriteReportLineF("Exception report file: %s\r\n", reportFilePathActual); + + #if defined(OVR_OS_MS) + if(miniDumpFilePath[0]) + WriteReportLineF("Exception minidump file: %s\r\n", minidumpFilePathActual); + #endif + + char dateTimeBuffer[64]; + FormatDateTime(dateTimeBuffer, OVR_ARRAY_COUNT(dateTimeBuffer), exceptionInfo.timeVal, true, true, false, false); + WriteReportLineF("Time (GMT): %s\r\n", dateTimeBuffer); + + FormatDateTime(dateTimeBuffer, OVR_ARRAY_COUNT(scratchBuffer), exceptionInfo.timeVal, true, true, true, false); + WriteReportLineF("Time (local): %s\r\n", dateTimeBuffer); + WriteReportLineF("Thread name: %s\r\n", exceptionInfo.threadName[0] ? exceptionInfo.threadName : "(not available)"); // It's never possible on Windows to get thread names, as they are stored in the debugger at runtime. + + SprintfThreadHandle(scratchBuffer, OVR_ARRAY_COUNT(scratchBuffer), exceptionInfo.threadHandle); + OVR_strlcat(scratchBuffer, "\r\n", OVR_ARRAY_COUNT(scratchBuffer)); + WriteReportLine("Thread handle: "); + WriteReportLine(scratchBuffer); + + SprintfThreadSysId(scratchBuffer, OVR_ARRAY_COUNT(scratchBuffer), exceptionInfo.threadSysId); + OVR_strlcat(scratchBuffer, "\r\n", OVR_ARRAY_COUNT(scratchBuffer)); + WriteReportLine("Thread sys id: "); + WriteReportLine(scratchBuffer); + + char addressStr[24]; + SprintfAddress(addressStr, OVR_ARRAY_COUNT(addressStr), exceptionInfo.pExceptionInstructionAddress); + WriteReportLineF("Exception instruction address: %s (see callstack below)\r\n", addressStr); + WriteReportLineF("Exception description: %s\r\n", exceptionInfo.exceptionDescription); + + if(symbolLookup.LookupSymbol((uint64_t)exceptionInfo.pExceptionInstructionAddress, exceptionInfo.symbolInfo)) + { + if(exceptionInfo.symbolInfo.filePath[0]) + WriteReportLineF("Exception location: %s (%d)\r\n", exceptionInfo.symbolInfo.filePath, exceptionInfo.symbolInfo.fileLineNumber); + else + WriteReportLineF("Exception location: %s (%d)\r\n", exceptionInfo.symbolInfo.function, exceptionInfo.symbolInfo.functionOffset); + } + + // To consider: print exceptionInfo.cpuContext registers + } + + // OVR information + WriteReportLine("\r\nOVR Info\r\n"); + WriteReportLineF("OVR time: %f\r\n", ovr_GetTimeInSeconds()); + WriteReportLineF("OVR version: %s\r\n", ovr_GetVersionString()); + + // OVR util information + // The following would be useful to use if they didn't allocate memory, which we can't do. + // To do: see if we can have versions of the functions below which don't allocate memory + // or allocate it safely (e.g. use an alternative heap). + // String OVR::GetDisplayDriverVersion(); + // String OVR::GetCameraDriverVersion(); + + // OVR HMD information + WriteReportLine("\r\nOVR HMD Info\r\n"); + + const OVR::List& hmdStateList = OVR::CAPI::HMDState::GetHMDStateList(); + const OVR::CAPI::HMDState* pHMDState = hmdStateList.GetFirst(); + + if(hmdStateList.IsNull(pHMDState)) + { + WriteReportLine("No HMDs found.\r\n"); + } + + while(!hmdStateList.IsNull(pHMDState)) + { + if(pHMDState->pProfile) + { + const char* user = pHMDState->pProfile->GetValue(OVR_KEY_USER); + + if(user) + WriteReportLineF("Profile user: %s\r\n", reportPrivacyEnabled ? "" : user); + else + WriteReportLine("Null profile user\r\n"); + + float NeckEyeDistance[2]; + float EyeToNoseDistance[2]; + float MaxEyeToPlateDist[2]; + pHMDState->pProfile->GetFloatValues(OVR_KEY_NECK_TO_EYE_DISTANCE, NeckEyeDistance, 2); + pHMDState->pProfile->GetFloatValues(OVR_KEY_EYE_TO_NOSE_DISTANCE, EyeToNoseDistance, 2); + pHMDState->pProfile->GetFloatValues(OVR_KEY_MAX_EYE_TO_PLATE_DISTANCE, MaxEyeToPlateDist, 2); + + WriteReportLineF("Player height: %f, eye height: %f, IPD: %f, Neck eye distance: %f,%f, eye relief dial: %d, eye to nose distance: %f,%f, max eye to plate distance: %f,%f, custom eye render: %s\r\n", + pHMDState->pProfile->GetFloatValue(OVR_KEY_PLAYER_HEIGHT, 0.f), + pHMDState->pProfile->GetFloatValue(OVR_KEY_EYE_HEIGHT, 0.f), + pHMDState->pProfile->GetFloatValue(OVR_KEY_IPD, 0.f), + NeckEyeDistance[0], NeckEyeDistance[1], + pHMDState->pProfile->GetIntValue(OVR_KEY_EYE_RELIEF_DIAL, 0), + EyeToNoseDistance[0], EyeToNoseDistance[1], + MaxEyeToPlateDist[0], MaxEyeToPlateDist[1], + pHMDState->pProfile->GetBoolValue(OVR_KEY_CUSTOM_EYE_RENDER, false) ? "yes" : "no"); + + // Not currently used: + // OVR_KEY_NAME + // OVR_KEY_GENDER + // OVR_KEY_EYE_CUP + // OVR_KEY_CAMERA_POSITION + } + else + { + WriteReportLine("Null HMD profile\r\n"); + } + + if(pHMDState->pHmdDesc) // This should usually be true. + { + WriteReportLineF("HMD %d: Type: %u ProductName: %s, Manufacturer: %s VendorId: %d, ProductId: %d, SerialNumber: %s, FirmwareMajor: %d, FirmwareMinor: %d, Resolution: %dx%d, DisplayDeviceName: %s, DisplayId: %d\r\n", + 0, (unsigned)pHMDState->pHmdDesc->Type, pHMDState->pHmdDesc->ProductName, pHMDState->pHmdDesc->Manufacturer, pHMDState->pHmdDesc->VendorId, + pHMDState->pHmdDesc->ProductId, pHMDState->pHmdDesc->SerialNumber, pHMDState->pHmdDesc->FirmwareMajor, pHMDState->pHmdDesc->FirmwareMinor, + pHMDState->pHmdDesc->Resolution.w, pHMDState->pHmdDesc->Resolution.h, pHMDState->pHmdDesc->DisplayDeviceName, pHMDState->pHmdDesc->DisplayId); + + // HSW display state + ovrHSWDisplayState hswDS; + ovrHmd_GetHSWDisplayState(pHMDState->pHmdDesc, &hswDS); + WriteReportLineF("HSW displayed for hmd: %s\r\n", hswDS.Displayed ? "yes" : "no"); + } + + char threadIdStr[24]; + SprintfAddress(threadIdStr, OVR_ARRAY_COUNT(threadIdStr), pHMDState->BeginFrameThreadId); + + WriteReportLineF("Hmd Caps: %x, Hmd Service Caps: %x, Latency test active: %s, Last frame time: %f, Last get frame time: %f, Rendering configred: %s, Begin frame called: %s, Begin frame thread id: %s\r\n", + pHMDState->EnabledHmdCaps, pHMDState->EnabledServiceHmdCaps, pHMDState->LatencyTestActive ? "yes" : "no", pHMDState->LastFrameTimeSeconds, pHMDState->LastGetFrameTimeSeconds, pHMDState->RenderingConfigured ? "yes" : "no", + pHMDState->BeginFrameCalled ? "yes" : "no", threadIdStr); + + if(pHMDState->pLastError) + { + WriteReportLineF("OVR last error for hmd: %s\r\n", pHMDState->pLastError); + } + + pHMDState = hmdStateList.GetNext(pHMDState); + } + + #if defined(OVR_OS_WIN32) + { + WriteReportLine("\r\nApp Info\r\n"); + + // Print the app path. + char appPath[MAX_PATH]; + GetCurrentProcessFilePath(appPath, OVR_ARRAY_COUNT(appPath)); + WriteReportLineF("Process path: %s\r\n", appPath); + + #if (OVR_PTR_SIZE == 4) + WriteReportLine("App format: 32 bit\r\n"); + #else + WriteReportLine("App format: 64 bit\r\n"); + #endif + + // Print the app version + wchar_t pathW[MAX_PATH] = {}; + GetModuleFileNameW(0, pathW, (DWORD)OVR_ARRAY_COUNT(pathW)); + DWORD dwUnused; + DWORD dwSize = GetFileVersionInfoSizeW(pathW, &dwUnused); + scratchBuffer[0] = 0; + + if(dwSize > 0) + { + void* const pVersionData = SafeMMapAlloc(dwSize); + + if(pVersionData) + { + if(GetFileVersionInfoW(pathW, 0, dwSize, pVersionData)) + { + VS_FIXEDFILEINFO* pFFI; + UINT size; + + if(VerQueryValueA(pVersionData, "\\", (void**)&pFFI, &size)) + { + WriteReportLineF("App version: %u.%u.%u.%u\r\n", + HIWORD(pFFI->dwFileVersionMS), LOWORD(pFFI->dwFileVersionMS), + HIWORD(pFFI->dwFileVersionLS), LOWORD(pFFI->dwFileVersionLS)); + } + } + + SafeMMapFree(pVersionData, dwSize); + } + } + + if(!scratchBuffer[0]) // If version info couldn't be found or read... + WriteReportLine("App version info not present\r\n"); + } + + { + WriteReportLine("\r\nSystem Info\r\n"); + + OSVERSIONINFOEXW vi; + memset(&vi, 0, sizeof(vi)); + vi.dwOSVersionInfoSize = sizeof(vi); + GetVersionExW((LPOSVERSIONINFOW)&vi); // Cast to the older type. + + char osVersionName[256]; + GetOSVersionName(osVersionName, OVR_ARRAY_COUNT(osVersionName)); + WriteReportLineF("OS name: %s, version: %u.%u build %u, %s, platform id: %u, service pack: %ls\r\n", + osVersionName, vi.dwMajorVersion, vi.dwMinorVersion, vi.dwBuildNumber, Is64BitOS() ? "64 bit" : "32 bit", + vi.dwPlatformId, vi.szCSDVersion[0] ? vi.szCSDVersion : L""); + + WriteReportLineF("Debugger present: %s\r\n", OVRIsDebuggerPresent() ? "yes" : "no"); + + // System info + SYSTEM_INFO systemInfo; + GetNativeSystemInfo(&systemInfo); + + WriteReportLineF("Processor count: %u\r\n", systemInfo.dwNumberOfProcessors); + + // Windows Vista and later: + // BOOL WINAPI GetLogicalProcessorInformation(PSYSTEM_LOGICAL_PROCESSOR_INFORMATION Buffer, PDWORD ReturnLength); + + if(systemInfo.wProcessorArchitecture == 0) + WriteReportLineF("Processor type: x86\r\n"); + else if(systemInfo.wProcessorArchitecture == 9) + WriteReportLineF("Processor type: x86-64\r\n"); + else if(systemInfo.wProcessorArchitecture == 10) + WriteReportLineF("Processor type: x86 on x86-64\r\n"); + + WriteReportLineF("Processor level: %u\r\n", systemInfo.wProcessorLevel); + WriteReportLineF("Processor revision: %u\r\n", systemInfo.wProcessorRevision); + + // Memory information + MEMORYSTATUSEX memoryStatusEx; + memset(&memoryStatusEx, 0, sizeof(memoryStatusEx)); + memoryStatusEx.dwLength = sizeof(memoryStatusEx); + GlobalMemoryStatusEx(&memoryStatusEx); + + WriteReportLineF("Memory load: %d%%\r\n", memoryStatusEx.dwMemoryLoad); + WriteReportLineF("Total physical memory: %I64d MiB\r\n", memoryStatusEx.ullTotalPhys / (1024 * 1024)); // Or are Mebibytes equal to (1024 * 1000) + WriteReportLineF("Available physical memory: %I64d MiB\r\n", memoryStatusEx.ullAvailPhys / (1024 * 1024)); + WriteReportLineF("Total page file memory: %I64d MiB\r\n", memoryStatusEx.ullTotalPageFile / (1024 * 1024)); + WriteReportLineF("Available page file memory: %I64d MiB\r\n", memoryStatusEx.ullAvailPageFile / (1024 * 1024)); + WriteReportLineF("Total virtual memory: %I64d MiB\r\n", memoryStatusEx.ullTotalVirtual / (1024 * 1024)); + WriteReportLineF("Free virtual memory: %I64d MiB\r\n", memoryStatusEx.ullAvailVirtual / (1024 * 1024)); + + DISPLAY_DEVICE dd; + memset(&dd, 0, sizeof(DISPLAY_DEVICE)); + dd.cb = sizeof(DISPLAY_DEVICE); + + for(int i = 0; EnumDisplayDevicesW(nullptr, (DWORD)i, &dd, EDD_GET_DEVICE_INTERFACE_NAME); ++i) + { + WriteReportLineF("Display Device %d name: %ls, context: %ls, primary: %s, mirroring: %s\r\n", + i, dd.DeviceName, dd.DeviceString, (dd.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE) ? "yes" : "no", (dd.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER) ? "yes" : "no"); + } + } + + // Print video card information + // http://msdn.microsoft.com/en-us/library/aa394512%28v=vs.85%29.aspx + { + IWbemLocator* pIWbemLocator = nullptr; + BSTR bstrServer = nullptr; + IWbemServices* pIWbemServices = nullptr; + BSTR bstrWQL = nullptr; + BSTR bstrPath = nullptr; + IEnumWbemClassObject* pEnum = nullptr; + + CoInitializeEx(nullptr, COINIT_MULTITHREADED); + + HRESULT hr = CoCreateInstance(__uuidof(WbemLocator), nullptr, CLSCTX_INPROC_SERVER, __uuidof(IWbemLocator), (LPVOID*)&pIWbemLocator); + if(FAILED(hr)) + goto End; + + bstrServer = SysAllocString(L"\\\\.\\root\\cimv2"); + hr = pIWbemLocator->ConnectServer(bstrServer, nullptr, nullptr, 0L, 0L, nullptr, nullptr, &pIWbemServices); + if(FAILED(hr)) + goto End; + + hr = CoSetProxyBlanket(pIWbemServices, RPC_C_AUTHN_WINNT, RPC_C_AUTHZ_NONE, nullptr, RPC_C_AUTHN_LEVEL_CALL, + RPC_C_IMP_LEVEL_IMPERSONATE, nullptr, EOAC_DEFAULT); + if(FAILED(hr)) + goto End; + + bstrWQL = SysAllocString(L"WQL"); + bstrPath = SysAllocString(L"select * from Win32_VideoController"); + hr = pIWbemServices->ExecQuery(bstrWQL, bstrPath, WBEM_FLAG_FORWARD_ONLY, nullptr, &pEnum); + if(FAILED(hr)) + goto End; + + ULONG uReturned; + IWbemClassObject* pObj = nullptr; + hr = pEnum->Next(WBEM_INFINITE, 1, &pObj, &uReturned); + if(FAILED(hr)) + goto End; + + WriteReportLine("\r\nDisplay adapter list\r\n"); + + for(unsigned i = 0; SUCCEEDED(hr) && uReturned; i++) + { + char sString[256]; + VARIANT var; + + if(i > 0) + WriteReportLine("\r\n"); + + WriteReportLineF("Info for display adapter %u\r\n", i); + + hr = pObj->Get(L"Name", 0, &var, nullptr, nullptr); + if(SUCCEEDED(hr)) + { + WideCharToMultiByte(CP_ACP, 0, var.bstrVal, -1, sString, sizeof(sString), nullptr, nullptr); + WriteReportLineF("Display Adapter Name: %s\r\n", sString); + } + + hr = pObj->Get(L"AdapterRAM", 0, &var, nullptr, nullptr); + if(SUCCEEDED(hr)) + { + WriteReportLineF("Display Adapter RAM: %u %s\r\n", + ((uint32_t)var.lVal > (1024*1024*1024) ? (uint32_t)var.lVal/(1024*1024*1024) : (uint32_t)var.lVal/(1024*1024)), ((uint32_t)var.lVal > (1024*1024*1024) ? "GiB" : "MiB")); + } + + hr = pObj->Get(L"DeviceID", 0, &var, nullptr, nullptr); + if(SUCCEEDED(hr)) + { + WideCharToMultiByte(CP_ACP, 0, var.bstrVal, -1, sString, sizeof(sString), nullptr, nullptr); + WriteReportLineF("Display Adapter DeviceID: %s\r\n", sString); + } + + hr = pObj->Get(L"DriverVersion", 0, &var, nullptr, nullptr); + if(SUCCEEDED(hr)) + { + WideCharToMultiByte(CP_ACP, 0, var.bstrVal, -1, sString, sizeof(sString), nullptr, nullptr); + WriteReportLineF("Display Adapter DriverVersion: %s\r\n", sString); + } + + hr = pObj->Get(L"DriverDate", 0, &var, nullptr, nullptr); + if(SUCCEEDED(hr)) + { + // http://technet.microsoft.com/en-us/library/ee156576.aspx + wchar_t year[5] = { var.bstrVal[0], var.bstrVal[1], var.bstrVal[2], var.bstrVal[3], 0 }; + wchar_t month[3] = { var.bstrVal[4], var.bstrVal[5], 0 }; + wchar_t monthDay[3] = { var.bstrVal[6], var.bstrVal[7], 0 }; + + WriteReportLineF("Display Adapter DriverDate (US format): %ls/%ls/%ls\r\n", month, monthDay, year); + } + + // VideoProcessor + hr = pObj->Get(L"VideoProcessor", 0, &var, nullptr, nullptr); + if(SUCCEEDED(hr)) + { + WideCharToMultiByte(CP_ACP, 0, var.bstrVal, -1, sString, sizeof(sString), nullptr, nullptr); + WriteReportLineF("Display Adapter VideoProcessor %s\r\n", sString); + } + + hr = pObj->Get(L"VideoModeDescription", 0, &var, nullptr, nullptr); + if(SUCCEEDED(hr)) + { + WideCharToMultiByte(CP_ACP, 0, var.bstrVal, -1, sString, sizeof(sString), nullptr, nullptr); + WriteReportLineF("Display Adapter VideoModeDescription: %s\r\n", sString); + } + + pObj->Release(); + + hr = pEnum->Next(WBEM_INFINITE, 1, &pObj, &uReturned); + } + + End: + if(pEnum) + pEnum->Release(); + if(bstrPath) + SysFreeString(bstrPath); + if(bstrWQL) + SysFreeString(bstrWQL); + if(pIWbemServices) + pIWbemServices->Release(); + if(bstrServer) + SysFreeString(bstrServer); + if(pIWbemLocator) + pIWbemLocator->Release(); + + CoUninitialize(); + } + + { + // Print a list of threads. + DWORD currentProcessId = GetCurrentProcessId(); + HANDLE hThreadSnap = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, currentProcessId); // ICreateToolhelp32Snapshot actually ignores currentProcessId. + + if(hThreadSnap != INVALID_HANDLE_VALUE) + { + THREADENTRY32 te32; + te32.dwSize = sizeof(THREADENTRY32); + + if(Thread32First(hThreadSnap, &te32)) + { + WriteReportLine("\r\nThread list\r\n"); + + do { + if(te32.th32OwnerProcessID == currentProcessId) + { + HANDLE hThread = ConvertThreadSysIdToThreadHandle(te32.th32ThreadID); + + if(hThread) + { + char buffer[96]; // Can't use scratchBuffer, because it's used by WriteThreadCallstack. + OVR_snprintf(buffer, OVR_ARRAY_COUNT(buffer), "base priority: %ld, delta priority: %ld", te32.tpBasePri, te32.tpDeltaPri); + + bool threadIsExceptionThread = (te32.th32ThreadID == (DWORD)exceptionInfo.threadSysId); + if(threadIsExceptionThread) + OVR_strlcat(buffer, ", exception thread", OVR_ARRAY_COUNT(buffer)); + + WriteThreadCallstack(hThread, (OVR::ThreadSysId)te32.th32ThreadID, buffer); + FreeThreadHandle(hThread); + } + } + } while(Thread32Next(hThreadSnap, &te32)); + } + + CloseHandle(hThreadSnap); + } + } + + { + // Print a list of the current modules within this process. + // DbgHelp.dll also provides a EnumerateLoadedModules64 function. + // To do: Convert the code below to use the GetModuleInfoArray function which we now have. + #if defined(OVR_OS_CONSOLE) + struct MODULEINFO { + LPVOID lpBaseOfDll; + DWORD SizeOfImage; + LPVOID EntryPoint; + }; + HMODULE hModule = LoadLibraryW(L"toolhelpx.dll"); + #else + HMODULE hModule = LoadLibraryW(L"psapi.dll"); + #endif + + if(hModule) + { + typedef BOOL (WINAPI * ENUMPROCESSMODULES) (HANDLE hProcess, HMODULE* phModule, DWORD cb, LPDWORD lpcbNeeded); + typedef DWORD (WINAPI * GETMODULEBASENAME) (HANDLE hProcess, HMODULE hModule, LPWSTR lpFilename, DWORD nSize); + typedef DWORD (WINAPI * GETMODULEFILENAMEEX) (HANDLE hProcess, HMODULE hModule, LPWSTR lpFilename, DWORD nSize); + typedef BOOL (WINAPI * GETMODULEINFORMATION)(HANDLE hProcess, HMODULE hModule, MODULEINFO* pmi, DWORD nSize); + + #if defined(OVR_OS_CONSOLE) + ENUMPROCESSMODULES pEnumProcessModules = (ENUMPROCESSMODULES) (uintptr_t)GetProcAddress(hModule, "K32EnumProcessModules"); + GETMODULEBASENAME pGetModuleBaseName = (GETMODULEBASENAME) (uintptr_t)GetProcAddress(hModule, "K32GetModuleBaseNameW"); + GETMODULEFILENAMEEX pGetModuleFileNameEx = (GETMODULEFILENAMEEX) (uintptr_t)GetProcAddress(hModule, "K32GetModuleFileNameExW"); + GETMODULEINFORMATION pGetModuleInformation = (GETMODULEINFORMATION)(uintptr_t)GetProcAddress(hModule, "K32GetModuleInformation"); + #else + ENUMPROCESSMODULES pEnumProcessModules = (ENUMPROCESSMODULES) (uintptr_t)GetProcAddress(hModule, "EnumProcessModules"); + GETMODULEBASENAME pGetModuleBaseName = (GETMODULEBASENAME) (uintptr_t)GetProcAddress(hModule, "GetModuleBaseNameW"); + GETMODULEFILENAMEEX pGetModuleFileNameEx = (GETMODULEFILENAMEEX) (uintptr_t)GetProcAddress(hModule, "GetModuleFileNameExW"); + GETMODULEINFORMATION pGetModuleInformation = (GETMODULEINFORMATION)(uintptr_t)GetProcAddress(hModule, "GetModuleInformation"); + #endif + + HANDLE hProcess = GetCurrentProcess(); + HMODULE hModuleArray[200]; + DWORD cbNeeded; + + if(pEnumProcessModules(hProcess, hModuleArray, sizeof(hModuleArray), &cbNeeded)) + { + size_t actualModuleCount = (cbNeeded / sizeof(HMODULE)); + + if(actualModuleCount > OVR_ARRAY_COUNT(hModuleArray)) //If hModuleArray's capacity was not enough... + actualModuleCount = OVR_ARRAY_COUNT(hModuleArray); + + // Print a header + WriteReportLine("\r\nModule list\r\n"); + + #if (OVR_PTR_SIZE == 4) + WriteReportLine("Base Size Entrypoint Name Path\r\n"); + #else + WriteReportLine("Base Size Entrypoint Name Path\r\n"); + #endif + + // And go through the list one by one + for(size_t i = 0; i < actualModuleCount; i++) + { + MODULEINFO mi; + size_t length; + + if(!pGetModuleInformation(hProcess, hModuleArray[i], &mi, sizeof(mi))) + { + mi.EntryPoint = nullptr; + mi.lpBaseOfDll = nullptr; + mi.SizeOfImage = 0; + } + + // Write the base name. + wchar_t name[MAX_PATH + 3]; + name[0] = '"'; + if(pGetModuleBaseName(hProcess, hModuleArray[i], name + 1, MAX_PATH)) + length = wcslen(name); + else + { + wcscpy(name + 1, L"(unknown)"); + length = 10; + } + + name[length] = '"'; + name[length + 1] = '\0'; + + // Write the path + wchar_t path[MAX_PATH + 3]; + path[0] = '"'; + if(pGetModuleFileNameEx(hProcess, hModuleArray[i], path + 1, MAX_PATH)) + length = wcslen(path); + else + { + wcscpy(path + 1, L"(unknown)"); + length = 10; + } + path[length] = '"'; + path[length + 1] = '\0'; + + #if (OVR_PTR_SIZE == 4) + WriteReportLineF("0x%08x, 0x%08x 0x%08x %-24ls %ls\r\n", (uint32_t)mi.lpBaseOfDll, (uint32_t)mi.SizeOfImage, (uint32_t)mi.EntryPoint, name, path); + #else + WriteReportLineF("0x%016I64x 0x%016I64x 0x%016I64x %-24ls %ls\r\n", (uint64_t)mi.lpBaseOfDll, (uint64_t)mi.SizeOfImage, (uint64_t)mi.EntryPoint, name, path); + #endif + } + } + } + } + + { + // Print a list of processes. + // DbgHelp.dll provides a SymEnumProcesses function, but it's available with DbgHelp.dll v6.2 which doesn't ship with Windows until Windows 8. + WriteReportLine("\r\nProcess list\r\n"); + + if(reportPrivacyEnabled) + WriteReportLine("Disabled by report privacy settings\r\n"); + else + { + HANDLE hProcessSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); + + if(hProcessSnapshot != INVALID_HANDLE_VALUE) + { + PROCESSENTRY32W pe32; + memset(&pe32, 0, sizeof(pe32)); + pe32.dwSize = sizeof(pe32); + + if(Process32FirstW(hProcessSnapshot, &pe32)) + { + WriteReportLine("Process Id File\r\n"); + + do { + // Try to get the full path to the process, as pe32.szExeFile holds only the process file name. + // This will typically fail with a privilege error unless this process has debug privileges: http://support.microsoft.com/kb/131065/en-us + wchar_t filePathW[MAX_PATH]; + const wchar_t* pFilePathW = pe32.szExeFile; + HANDLE hProcess = ::OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pe32.th32ProcessID); // With Windows Vista+ we can use PROCESS_QUERY_LIMITED_INFORMATION. + if(hProcess) + { + if(GetProcessImageFileName(hProcess, filePathW, (DWORD)OVR_ARRAY_COUNT(filePathW))) + pFilePathW = filePathW; + } + + WriteReportLineF("0x%08x %ls\r\n", pe32.th32ProcessID, pFilePathW); + } while(Process32NextW(hProcessSnapshot, &pe32)); + } + + CloseHandle(hProcessSnapshot); + } + else + { + WriteReportLine("Unable to read process list\r\n"); + } + } + } + + #elif defined(OVR_OS_APPLE) + + WriteReportLine("\r\nApp Info\r\n"); + + // App path + const pid_t processId = getpid(); + WriteReportLineF("Process id: ", "%lld (0x%llx)\r\n", (int64_t)processId, (int64_t)processId); + + char appPath[PATH_MAX]; + GetCurrentProcessFilePath(appPath, OVR_ARRAY_COUNT(appPath)); + WriteReportLineF("Process path: %s\r\n", appPath); + + #if (OVR_PTR_SIZE == 4) + WriteReportLine("App format: 32 bit\r\n"); + #else + WriteReportLine("App format: 64 bit\r\n"); + #endif + + // App version + // To do. + + // System Info + WriteReportLine("\r\nSystem Info\r\n"); + + char osVersionName[256]; + GetOSVersionName(osVersionName, OVR_ARRAY_COUNT(osVersionName)); + WriteReportLineF("OS name: %s, %s\r\n", osVersionName, Is64BitOS() ? "64 bit" : "32 bit"); + + int name[2]; + int intValue; + size_t length; + char tempBuffer[256]; + + name[0] = CTL_KERN; + name[1] = KERN_OSTYPE; + length = sizeof(tempBuffer); + tempBuffer[0] = 0; + if(sysctl(name, 2, tempBuffer, &length, nullptr, 0) == 0) + { + WriteReportLineF("KERN_OSTYPE: %s\r\n", tempBuffer); + } + + name[0] = CTL_KERN; + name[1] = KERN_OSREV; + length = sizeof(intValue); + intValue = 0; + if(sysctl(name, 2, &intValue, &length, nullptr, 0) == 0) + { + WriteReportLineF("KERN_OSREV: %d\r\n", intValue); + } + + name[0] = CTL_KERN; + name[1] = KERN_OSRELEASE; + length = sizeof(tempBuffer); + tempBuffer[0] = 0; + if(sysctl(name, 2, tempBuffer, &length, nullptr, 0) == 0) + WriteReportLineF("KERN_OSRELEASE: %s\r\n", tempBuffer); + + name[0] = CTL_HW; + name[1] = HW_MACHINE; + length = sizeof(tempBuffer); + tempBuffer[0] = 0; + if(sysctl(name, 2, tempBuffer, &length, nullptr, 0) == 0) + WriteReportLineF("HW_MACHINE: %s\r\n", tempBuffer); + + name[0] = CTL_HW; + name[1] = HW_MODEL; + length = sizeof(tempBuffer); + tempBuffer[0] = 0; + if(sysctl(name, 2, tempBuffer, &length, nullptr, 0) == 0) + WriteReportLineF("sHW_MODEL: %s\r\n", tempBuffer); + + name[0] = CTL_HW; + name[1] = HW_NCPU; + length = sizeof(intValue); + intValue = 0; + if(sysctl(name, 2, &intValue, &length, nullptr, 0) == 0) + WriteReportLineF("HW_NCPU: %d\r\n", intValue); + + length = sizeof(tempBuffer); + tempBuffer[0] = 0; + if(sysctlbyname("machdep.cpu.brand_string", &tempBuffer, &length, nullptr, 0) == 0) + WriteReportLineF("machdep.cpu.brand_string: %s\r\n", tempBuffer); + + length = sizeof(tempBuffer); + tempBuffer[0] = 0; + if(sysctlbyname("hw.acpi.thermal.tz0.temperature", &tempBuffer, &length, nullptr, 0) == 0) + WriteReportLineF("hw.acpi.thermal.tz0.temperature: %s\r\n", tempBuffer); + + host_basic_info_data_t hostinfo; + mach_msg_type_number_t count = HOST_BASIC_INFO_COUNT; + kern_return_t kr = host_info(mach_host_self(), HOST_BASIC_INFO, (host_info_t)&hostinfo, &count); + + if(kr == KERN_SUCCESS) + { + const uint64_t memoryMib = (uint64_t)hostinfo.max_mem / (1024 * 1024); + WriteReportLineF("System memory: %lld Mib (%.1f Gib)\r\n", memoryMib, (double)memoryMib / 1024); + } + + // Video card info + // To do. + + // Thread list + mach_port_t taskSelf = mach_task_self(); + thread_act_port_array_t threadArray; + mach_msg_type_number_t threadCount; + + kern_return_t result = task_threads(taskSelf, &threadArray, &threadCount); + + if(result == KERN_SUCCESS) + { + WriteReportLine("\r\nThread list\r\n"); + + for(mach_msg_type_number_t i = 0; i < threadCount; i++) + { + union TBIUnion{ + natural_t words[THREAD_INFO_MAX]; + thread_basic_info tbi; + }; + + TBIUnion tbiUnion; + mach_port_t thread = threadArray[i]; + pthread_t pthread = pthread_from_mach_thread_np(thread); // We assume the thread was created through pthreads. + + char threadState[32] = "unknown"; + mach_msg_type_number_t threadInfoCount = THREAD_INFO_MAX; + result = thread_info(thread, THREAD_BASIC_INFO, (thread_info_t)&tbiUnion, &threadInfoCount); + + if(result == KERN_SUCCESS) + { + const char* state; + + switch (tbiUnion.tbi.run_state) + { + case TH_STATE_HALTED: state = "halted"; break; + case TH_STATE_RUNNING: state = "running"; break; + case TH_STATE_STOPPED: state = "stopped"; break; + case TH_STATE_UNINTERRUPTIBLE: state = "uninterruptible"; break; + case TH_STATE_WAITING: state = "waiting"; break; + default: state = ""; break; + } + + OVR_snprintf(threadState, OVR_ARRAY_COUNT(threadState), "%s", state); + if(tbiUnion.tbi.flags & TH_FLAGS_IDLE) + OVR_strlcat(threadState, ", idle", sizeof(threadState)); + if(tbiUnion.tbi.flags & TH_FLAGS_SWAPPED) + OVR_strlcat(threadState, ", swapped", sizeof(threadState)); + } + + thread_identifier_info threadIdentifierInfo; + memset(&threadIdentifierInfo, 0, sizeof(threadIdentifierInfo)); + + mach_msg_type_number_t threadIdentifierInfoCount = THREAD_IDENTIFIER_INFO_COUNT; + thread_info(thread, THREAD_IDENTIFIER_INFO, (thread_info_t)&threadIdentifierInfo, &threadIdentifierInfoCount); + + proc_threadinfo procThreadInfo; + memset(&procThreadInfo, 0, sizeof(procThreadInfo)); + result = proc_pidinfo(processId, PROC_PIDTHREADINFO, threadIdentifierInfo.thread_handle, &procThreadInfo, sizeof(procThreadInfo)); + OVR_UNUSED(result); + + char buffer[256]; // Can't use scratchBuffer, because it's used by WriteThreadCallstack. + OVR_snprintf(buffer, OVR_ARRAY_COUNT(buffer), "state: %s, suspend count: %d, kernel priority: %d", threadState, (int)tbiUnion.tbi.suspend_count, (int)procThreadInfo.pth_curpri); + + bool threadIsExceptionThread = (thread == exceptionInfo.threadSysId); + if(threadIsExceptionThread) + OVR_strlcat(buffer, ", exception thread", OVR_ARRAY_COUNT(buffer)); + + WriteThreadCallstack(pthread, thread, buffer); + } + + vm_deallocate(taskSelf, (vm_address_t)threadArray, threadCount * sizeof(thread_act_t)); + } + + + WriteReportLine("\r\nModule list\r\n"); + + const size_t mifCapacity = 256; + const size_t mifAllocSize = mifCapacity * sizeof(ModuleInfo); + ModuleInfo* moduleInfoArray = (ModuleInfo*)SafeMMapAlloc(mifAllocSize); + + if(moduleInfoArray) + { + #if (OVR_PTR_SIZE == 4) + WriteReportLine("Base Size Name Path\r\n"); + #else + WriteReportLine("Base Size Name Path\r\n"); + #endif + + size_t moduleCount = symbolLookup.GetModuleInfoArray(moduleInfoArray, mifCapacity); + if(moduleCount > mifCapacity) + moduleCount = mifCapacity; + + for(size_t i = 0; i < moduleCount; i++) + { + const ModuleInfo& mi = moduleInfoArray[i]; + + #if (OVR_PTR_SIZE == 4) + WriteReportLineF("0x%08x, 0x%08x %-24s %s\r\n", (uint32_t)mi.baseAddress, (uint32_t)mi.size, mi.name, mi.filePath); + #else + WriteReportLineF("0x%016llx 0x%016llx %-24s %s\r\n", (uint64_t)mi.baseAddress, (uint64_t)mi.size, mi.name, mi.filePath); + #endif + } + + SafeMMapFree(moduleInfoArray, mifAllocSize); + } + + + WriteReportLine("\r\nProcess list\r\n"); + + if(reportPrivacyEnabled) + WriteReportLine("Disabled by report privacy settings\r\n"); + else + { + WriteReportLine("Process Id File\r\n"); + + pid_t pidArray[1024]; + int processCount = proc_listpids(PROC_ALL_PIDS, 0, pidArray, sizeof(pidArray)); // Important that we use sizeof not OVR_ARRAY_COUNT. + char processFilePath[PATH_MAX]; + + for(int i = 0; i < processCount; i++) + { + if(proc_pidpath(pidArray[i], processFilePath, sizeof(processFilePath)) > 0) + WriteReportLineF("%-10d %s\r\n", pidArray[i], processFilePath); + } + + if(!processCount) + WriteReportLine("Unable to read process list\r\n"); + } + + #elif defined(OVR_OS_UNIX) + Is64BitOS(); + GetCurrentProcessFilePath(nullptr, 0); + GetFileNameFromPath(nullptr); + GetOSVersionName(nullptr, 0); + + #endif // OVR_OS_MS + + symbolLookup.Shutdown(); + + fclose(file); + file = nullptr; +} + + +void ExceptionHandler::WriteMiniDump() +{ + if(strstr(miniDumpFilePath, "%s")) // If the user-specified file path includes a date/time component... + { + char dateTimeBuffer[64]; + FormatDateTime(dateTimeBuffer, OVR_ARRAY_COUNT(dateTimeBuffer), exceptionInfo.timeVal, true, true, false, true); + OVR_snprintf(minidumpFilePathActual, OVR_ARRAY_COUNT(minidumpFilePathActual), miniDumpFilePath, dateTimeBuffer); + } + else + { + OVR_strlcpy(minidumpFilePathActual, miniDumpFilePath, OVR_ARRAY_COUNT(minidumpFilePathActual)); + } + + #if defined(OVR_OS_WIN32) || defined(OVR_OS_WIN64) || (defined(OVR_OS_MS) && defined(OVR_OS_CONSOLE)) + #if defined(OVR_OS_CONSOLE) + typedef BOOL (WINAPI * MINIDUMPWRITEDUMP)(HANDLE hProcess, DWORD ProcessId, HANDLE hFile, MINIDUMP_TYPE dumpType, CONST PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam, CONST PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam, CONST PVOID CallbackParam); + HMODULE hModuleDbgHelp = LoadLibraryW(L"toolhelpx.dll"); + #else + typedef BOOL (WINAPI * MINIDUMPWRITEDUMP)(HANDLE hProcess, DWORD ProcessId, HANDLE hFile, MINIDUMP_TYPE dumpType, CONST PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam, CONST PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam, CONST PMINIDUMP_CALLBACK_INFORMATION CallbackParam); + HMODULE hModuleDbgHelp = LoadLibraryW(L"DbgHelp.dll"); + #endif + + MINIDUMPWRITEDUMP pMiniDumpWriteDump = hModuleDbgHelp ? (MINIDUMPWRITEDUMP)(void*)GetProcAddress(hModuleDbgHelp, "MiniDumpWriteDump") : nullptr; + + if(pMiniDumpWriteDump) + { + wchar_t miniDumpFilePathW[OVR_MAX_PATH]; + OVR::UTF8Util::DecodeString(miniDumpFilePathW, minidumpFilePathActual, -1); // Problem: DecodeString provides no way to specify the destination capacity. + + HANDLE hFile = CreateFileW(miniDumpFilePathW, GENERIC_READ | GENERIC_WRITE, 0, 0, CREATE_ALWAYS, FILE_FLAG_WRITE_THROUGH, 0); + + if(hFile != INVALID_HANDLE_VALUE) + { + MINIDUMP_EXCEPTION_INFORMATION minidumpExceptionInfo = { ::GetCurrentThreadId(), pExceptionPointers, TRUE }; + + #if defined(OVR_OS_CONSOLE) + BOOL result = pMiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), hFile, + (MINIDUMP_TYPE)miniDumpType, &exceptionInfo, + (CONST PMINIDUMP_USER_STREAM_INFORMATION)nullptr, nullptr); + #else + BOOL result = pMiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), hFile, + (MINIDUMP_TYPE)miniDumpFlags, &minidumpExceptionInfo, + (CONST PMINIDUMP_USER_STREAM_INFORMATION)nullptr, (CONST PMINIDUMP_CALLBACK_INFORMATION)nullptr); + #endif + + OVR_ASSERT_AND_UNUSED(result, result); + CloseHandle(hFile); + hFile = 0; + } + else + { + OVR_ASSERT(pMiniDumpWriteDump); // OVR_FAIL_F(("ExceptionHandler::WriteMiniDump: Failed to create minidump file at %s", minidumpFilePathActual)); + } + } + + FreeLibrary(hModuleDbgHelp); + #else + // Some platforms support various forms or exception reports and core dumps which are automatically generated upon us + // returning from our own exception handling. We might want to put something here if we are using a custom version of + // this, such as Google Breakpad. + #endif +} + + +void ExceptionHandler::SetExceptionListener(ExceptionListener* pExceptionListener, uintptr_t userValue) +{ + exceptionListener = pExceptionListener; + exceptionListenerUserValue = userValue; +} + + +void ExceptionHandler::SetAppDescription(const char* pAppDescription) +{ + appDescription = pAppDescription; +} + + +void ExceptionHandler::SetExceptionPaths(const char* exceptionReportPath, const char* exceptionMiniDumpFilePath) +{ + char tempPath[OVR_MAX_PATH]; + + if(exceptionReportPath) + { + if(OVR_stricmp(exceptionReportPath, "default") == 0) + { + GetUserDocumentsDirectory(tempPath, OVR_ARRAY_COUNT(tempPath)); + OVR::OVR_strlcat(tempPath, "Exception Report (%s).txt", OVR_ARRAY_COUNT(tempPath)); + exceptionReportPath = tempPath; + } + + OVR_strlcpy(reportFilePath, exceptionReportPath, OVR_ARRAY_COUNT(reportFilePath)); + } + else + { + reportFilePath[0] = '\0'; + } + + if(exceptionMiniDumpFilePath) + { + if(OVR_stricmp(exceptionMiniDumpFilePath, "default") == 0) + { + GetUserDocumentsDirectory(tempPath, OVR_ARRAY_COUNT(tempPath)); + OVR::OVR_strlcat(tempPath, "Exception Minidump (%s).mdmp", OVR_ARRAY_COUNT(tempPath)); + exceptionMiniDumpFilePath = tempPath; + } + + OVR_strlcpy(miniDumpFilePath, exceptionMiniDumpFilePath, OVR_ARRAY_COUNT(miniDumpFilePath)); + } + else + { + miniDumpFilePath[0] = '\0'; + } +} + + +void ExceptionHandler::SetCodeBaseDirectoryPaths(const char* codeBaseDirectoryPathArray[], size_t codeBaseDirectoryPathCount) +{ + for(size_t i = 0, iCount = OVR::Alg::Min(codeBaseDirectoryPathCount, OVR_ARRAY_COUNT(codeBasePathArray)); i != iCount; ++i) + { + codeBasePathArray[i] = codeBaseDirectoryPathArray[i]; + } +} + +const char* ExceptionHandler::GetExceptionUIText(const char* exceptionReportPath) +{ + char* uiText = nullptr; + OVR::SysFile file(exceptionReportPath, SysFile::Open_Read, SysFile::Mode_ReadWrite); + + if(file.IsValid()) + { + size_t length = (size_t)file.GetLength(); + uiText = (char*)OVR::SafeMMapAlloc(length + 1); + + if(uiText) + { + file.Read((uint8_t*)uiText, (int)length); + uiText[length] = '\0'; + file.Close(); + + // Currently on Mac our message box implementation is unable to display arbitrarily large amounts of text. + // So we reduce its size to a more summary version before presenting. + #if defined(OVR_OS_MAC) + struct Find { static char* PreviousChar(char* p, char c){ while(*p != c) p--; return p; } }; // Assumes the given c is present prior to p. + + // Print that the full report is at + // Exception Info section + // Exception thread callstack. + char empty[] = ""; + char* pExceptionInfoBegin = strstr(uiText, "Exception Info") ? strstr(uiText, "Exception Info") : empty; + char* pExceptionInfoEnd = (pExceptionInfoBegin == empty) ? (empty + 1) : strstr(uiText, "\r\n\r\n"); + char* pExceptionThreadArea = strstr(uiText, ", exception thread"); + char* pExceptionThreadBegin = pExceptionThreadArea ? Find::PreviousChar(pExceptionThreadArea, '\n') + 1 : empty; + char* pExceptionThreadEnd = (pExceptionThreadBegin == empty) ? (empty + 1) : strstr(pExceptionThreadArea, "\r\n\r\n"); + + if(!pExceptionInfoEnd) + pExceptionInfoEnd = pExceptionInfoBegin; + *pExceptionInfoEnd = '\0'; + + if(!pExceptionThreadEnd) + pExceptionThreadEnd = pExceptionThreadBegin; + *pExceptionThreadEnd = '\0'; + + size_t uiTextBriefLength = OVR_snprintf(nullptr, 0, "Full report:%s\n\nSummary report:\n%s\n\n%s", exceptionReportPath, pExceptionInfoBegin, pExceptionThreadBegin); + char* uiTextBrief = (char*)OVR::SafeMMapAlloc(uiTextBriefLength + 1); + + if(uiTextBrief) + { + OVR_snprintf(uiTextBrief, uiTextBriefLength + 1, "Full report:%s\n\nSummary report:\n%s\n\n%s", exceptionReportPath, pExceptionInfoBegin, pExceptionThreadBegin); + OVR::SafeMMapFree(uiText, length); + uiText = uiTextBrief; + } + #endif + } + } + + return uiText; +} + +void ExceptionHandler::FreeExceptionUIText(const char* messageBoxText) +{ + OVR::SafeMMapFree(messageBoxText, OVR_strlen(messageBoxText)); +} + + +} // namespace OVR + + +OVR_RESTORE_MSVC_WARNING() + diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Kernel/OVR_DebugHelp.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Kernel/OVR_DebugHelp.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,461 @@ +/************************************************************************************ + +Filename : OVR_DebugHelp.h +Content : Platform-independent exception handling interface +Created : October 6, 2014 + +Copyright : Copyright 2014 Oculus VR, LLC. All Rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#ifndef OVR_ExceptionHandler_h +#define OVR_ExceptionHandler_h + + +#include "OVR_Types.h" +#include "OVR_String.h" +#include "OVR_Threads.h" +#include "OVR_Atomic.h" +#include "OVR_Nullptr.h" +#include +#include + +#if defined(OVR_OS_WIN32) || defined(OVR_OS_WIN64) + #include + +#elif defined(OVR_OS_APPLE) + #include + #include + #include + + extern "C" void* MachHandlerThreadFunctionStatic(void*); + extern "C" int catch_mach_exception_raise_state_identity_OVR(mach_port_t, mach_port_t, mach_port_t, exception_type_t, mach_exception_data_type_t*, + mach_msg_type_number_t, int*, thread_state_t, mach_msg_type_number_t, thread_state_t, mach_msg_type_number_t*); +#elif defined(OVR_OS_LINUX) + #include +#endif + + +OVR_DISABLE_MSVC_WARNING(4351) // new behavior: elements of array will be default initialized + + +namespace OVR { + + // Thread identifiers + //typedef void* ThreadHandle; // Already defined by OVR Threads. Same as Windows thread handle, Unix pthread_t. + //typedef void* ThreadId; // Already defined by OVR Threads. Used by Windows as DWORD thread id, by Unix as pthread_t. + typedef uintptr_t ThreadSysId; // System thread identifier. Used by Windows the same as ThreadId (DWORD), thread_act_t on Mac/BSD, lwp id on Linux. + + // Thread constants + // To do: Move to OVR Threads + #define OVR_THREADHANDLE_INVALID ((ThreadHandle*)nullptr) + #define OVR_THREADID_INVALID ((ThreadId*)nullptr) + #define OVR_THREADSYSID_INVALID ((uintptr_t)0) + + OVR::ThreadSysId ConvertThreadHandleToThreadSysId(OVR::ThreadHandle threadHandle); + OVR::ThreadHandle ConvertThreadSysIdToThreadHandle(OVR::ThreadSysId threadSysId); // The returned handle must be freed with FreeThreadHandle. + void FreeThreadHandle(OVR::ThreadHandle threadHandle); // Frees the handle returned by ConvertThreadSysIdToThreadHandle. + OVR::ThreadSysId GetCurrentThreadSysId(); + + // CPUContext + #if defined(OVR_OS_MS) + typedef CONTEXT CPUContext; + #elif defined(OVR_OS_MAC) + struct CPUContext + { + x86_thread_state_t threadState; // This works for both x86 and x64. + x86_float_state_t floatState; + x86_debug_state_t debugState; + x86_avx_state_t avxState; + x86_exception_state exceptionState; + + CPUContext() { memset(this, 0, sizeof(CPUContext)); } + }; + #elif defined(OVR_OS_LINUX) + typedef int CPUContext; // To do. + #endif + + + // Tells if the current process appears to be running under a debugger. Does not attempt to + // detect the case of sleath debuggers (malware-related for example). + bool OVRIsDebuggerPresent(); + + // Exits the process with the given exit code. + #if !defined(OVR_NORETURN) + #if defined(OVR_CC_MSVC) + #define OVR_NORETURN __declspec(noreturn) + #else + #define OVR_NORETURN __attribute__((noreturn)) + #endif + #endif + OVR_NORETURN void ExitProcess(intptr_t processReturnValue); + + // Returns the instruction pointer of the caller for the position right after the call. + OVR_NO_INLINE void GetInstructionPointer(void*& pInstruction); + + // Returns the stack base and limit addresses for the given thread, or for the current thread if the threadHandle is default. + // The stack limit is a value less than the stack base on most platforms, as stacks usually grow downward. + // Some platforms (e.g. Microsoft) have dynamically resizing stacks, in which case the stack limit reflects the current limit. + void GetThreadStackBounds(void*& pStackBase, void*& pStackLimit, ThreadHandle threadHandle = OVR_THREADHANDLE_INVALID); + + + // Equates to VirtualAlloc/VirtualFree on Windows, mmap/munmap on Unix. + // These are useful for when you need system-supplied memory pages. + // These are also useful for when you need to allocate memory in a way + // that doesn't affect the application heap. + void* SafeMMapAlloc(size_t size); + void SafeMMapFree(const void* memory, size_t size); + + + // OVR_MAX_PATH + // Max file path length (for most uses). + // To do: move this to OVR_File. + #if defined(OVR_OS_MS) // http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247%28v=vs.85%29.aspx + #define OVR_MAX_PATH 260 // Windows can use paths longer than this in some cases (network paths, UNC paths). + #else + #define OVR_MAX_PATH 1024 // This isn't a strict limit on all Unix-based platforms. + #endif + + + // ModuleHandle + #if defined(OVR_OS_MS) + typedef void* ModuleHandle; // from LoadLibrary() + #elif defined(OVR_OS_APPLE) || defined(OVR_OS_UNIX) + typedef void* ModuleHandle; // from dlopen() + #endif + + #define OVR_MODULEHANDLE_INVALID ((ModuleHandle*)nullptr) + + + + // Module info constants + static const ModuleHandle kMIHandleInvalid = OVR_MODULEHANDLE_INVALID; + static const uint64_t kMIAddressInvalid = 0xffffffffffffffffull; + static const uint64_t kMISizeInvalid = 0xffffffffffffffffull; + static const int32_t kMILineNumberInvalid = -1; + static const int32_t kMIFunctionOffsetInvalid = -1; + static const uint64_t kMIBaseAddressInvalid = 0xffffffffffffffffull; + static const uint64_t kMIBaseAddressUnspecified = 0xffffffffffffffffull; + + struct ModuleInfo + { + ModuleHandle handle; + uint64_t baseAddress; // The actual runtime base address of the module. May be different from the base address specified in the debug symbol file. + uint64_t size; + char filePath[OVR_MAX_PATH]; + char name[32]; + char type[8]; // Unix-specific. e.g. __TEXT + char permissions[8]; // Unix specific. e.g. "drwxr-xr-x" + + ModuleInfo() : handle(kMIHandleInvalid), baseAddress(kMIBaseAddressInvalid), size(0), filePath(), name(){} + }; + + + // Refers to symbol info for an instruction address. + // Info includes function name, source code file/line, and source code itself. + struct SymbolInfo + { + uint64_t address; + uint64_t size; + const ModuleInfo* pModuleInfo; + char filePath[OVR_MAX_PATH]; + int32_t fileLineNumber; + char function[128]; // This is a fixed size because we need to use it during application exceptions. + int32_t functionOffset; + char sourceCode[1024]; // This is a string representing the code itself and not a file path to the code. + + SymbolInfo() : address(kMIAddressInvalid), size(kMISizeInvalid), pModuleInfo(nullptr), filePath(), + fileLineNumber(kMILineNumberInvalid), function(), functionOffset(kMIFunctionOffsetInvalid), sourceCode() {} + }; + + + // Implements support for reading thread lists, module lists, backtraces, and backtrace symbols. + class SymbolLookup + { + public: + SymbolLookup(); + ~SymbolLookup(); + + void AddSourceCodeDirectory(const char* pDirectory); + + bool Initialize(); + void Shutdown(); + + // Should be disabled when within an exception handler. + void EnableMemoryAllocation(bool enabled); + + // Retrieves the backtrace (call stack) of the given thread. There may be some per-platform restrictions on this. + // Returns the number written, which will be <= addressArrayCapacity. + // This may not work on some platforms unless stack frames are enabled. + // For Microsoft platforms the platformThreadContext is CONTEXT*. + // For Apple platforms the platformThreadContext is x86_thread_state_t* or arm_thread_state_t*. + // If threadSysIdHelp is non-zero, it may be used by the implementation to help produce a better backtrace. + size_t GetBacktrace(void* addressArray[], size_t addressArrayCapacity, size_t skipCount = 0, void* platformThreadContext = nullptr, OVR::ThreadSysId threadSysIdHelp = OVR_THREADSYSID_INVALID); + + // Retrieves the backtrace for the given ThreadHandle. + // Returns the number written, which will be <= addressArrayCapacity. + size_t GetBacktraceFromThreadHandle(void* addressArray[], size_t addressArrayCapacity, size_t skipCount = 0, OVR::ThreadHandle threadHandle = OVR_THREADHANDLE_INVALID); + + // Retrieves the backtrace for the given ThreadSysId. + // Returns the number written, which will be <= addressArrayCapacity. + size_t GetBacktraceFromThreadSysId(void* addressArray[], size_t addressArrayCapacity, size_t skipCount = 0, OVR::ThreadSysId threadSysId = OVR_THREADSYSID_INVALID); + + // Gets a list of the modules (e.g. DLLs) present in the current process. + // Writes as many ModuleInfos as possible to pModuleInfoArray. + // Returns the required count of ModuleInfos, which will be > moduleInfoArrayCapacity if the capacity needs to be larger. + size_t GetModuleInfoArray(ModuleInfo* pModuleInfoArray, size_t moduleInfoArrayCapacity); + + // Retrieves a list of the current threads. Unless the process is paused the list is volatile. + // Returns the required capacity, which may be larger than threadArrayCapacity. + // Either array can be NULL to specify that it's not written to. + // For Windows the caller needs to CloseHandle the returned ThreadHandles. This can be done by calling DoneThreadList. + size_t GetThreadList(ThreadHandle* threadHandleArray, ThreadSysId* threadSysIdArray, size_t threadArrayCapacity); + + // Frees any references to thread handles or ids returned by GetThreadList; + void DoneThreadList(ThreadHandle* threadHandleArray, ThreadSysId* threadSysIdArray, size_t threadArrayCount); + + // Writes a given thread's callstack with symbols to the given output. + // It may not be safe to call this from an exception handler, as sOutput allocates memory. + bool ReportThreadCallstack(OVR::String& sOutput, size_t skipCount = 0, ThreadSysId threadSysId = OVR_THREADSYSID_INVALID); + + // Writes all thread's callstacks with symbols to the given output. + // It may not be safe to call this from an exception handler, as sOutput allocates memory. + bool ReportThreadCallstacks(OVR::String& sOutput, size_t skipCount = 0); + + // Retrieves symbol info for the given address. + bool LookupSymbol(uint64_t address, SymbolInfo& symbolInfo); + bool LookupSymbols(uint64_t* addressArray, SymbolInfo* pSymbolInfoArray, size_t arraySize); + + const ModuleInfo* GetModuleInfoForAddress(uint64_t address); // The returned ModuleInfo points to an internal structure. + + protected: + bool RefreshModuleList(); + + protected: + bool initialized; + bool allowMemoryAllocation; // True by default. If true then we allow allocating memory (and as a result provide less information). This is useful for when in an exception handler. + bool moduleListUpdated; + ModuleInfo moduleInfoArray[96]; // Cached list of modules we use. This is a fixed size because we need to use it during application exceptions. + size_t moduleInfoArraySize; + }; + + + + // ExceptionInfo + // We need to be careful to avoid data types that can allocate memory while we are + // handling an exception, as the memory system may be corrupted at that point in time. + struct ExceptionInfo + { + tm time; // GM time. + time_t timeVal; // GM time_t (seconds since 1970). + void* backtrace[64]; + size_t backtraceCount; + ThreadHandle threadHandle; // + ThreadSysId threadSysId; // + char threadName[32]; // Cannot be an allocating String object. + void* pExceptionInstructionAddress; + void* pExceptionMemoryAddress; + CPUContext cpuContext; + char exceptionDescription[1024]; // Cannot be an allocating String object. + SymbolInfo symbolInfo; // SymbolInfo for the exception location. + + #if defined(OVR_OS_MS) + EXCEPTION_RECORD exceptionRecord; // This is a Windows SDK struct. + #elif defined(OVR_OS_APPLE) + uint64_t exceptionType; // e.g. EXC_BAD_INSTRUCTION, EXC_BAD_ACCESS, etc. + uint32_t cpuExceptionId; // The x86/x64 CPU trap id. + uint32_t cpuExceptionIdError; // The x86/x64 CPU trap id extra info. + int64_t machExceptionDetail[4]; // Kernel exception code info. + int machExceptionDetailCount; // Count of valid entries. + #endif + + ExceptionInfo(); + }; + + + // Implments support for asynchronous exception handling and basic exception report generation. + // If you are implementing exception handling for a commercial application and want auto-uploading + // functionality you may want to consider using something like Google Breakpad. This exception handler + // is for in-application debug/diagnostic services, though it can write a report that has similar + // information to Breakpad or OS-provided reports such as Apple .crash files. + // + // Example usage: + // ExceptionHandler exceptionHandler; + // + // int main(int, char**) + // { + // exceptionHandler.Enable(true); + // exceptionHandler.SetExceptionListener(pSomeListener, 0); // Optional listener hook. + // } + // + class ExceptionHandler + { + public: + ExceptionHandler(); + ~ExceptionHandler(); + + bool Enable(bool enable); + + // Some report info can be considered private information of the user, such as the current process list, + // computer name, IP address or other identifying info, etc. We should not report this information for + // external users unless they agree to this. + void EnableReportPrivacy(bool enable); + + struct ExceptionListener + { + virtual ~ExceptionListener(){} + virtual int HandleException(uintptr_t userValue, ExceptionHandler* pExceptionHandler, ExceptionInfo* pExceptionInfo, const char* reportFilePath) = 0; + }; + + void SetExceptionListener(ExceptionListener* pExceptionListener, uintptr_t userValue); + + // What we do after handling the exception. + enum ExceptionResponse + { + kERContinue, // Continue execution. Will result in the exception being re-generated unless the application has fixed the cause. Similar to Windows EXCEPTION_CONTINUE_EXECUTION. + kERHandle, // Causes the OS to handle the exception as it normally would. Similar to Windows EXCEPTION_EXECUTE_HANDLER. + kERTerminate, // Exit the application. + kERThrow, // Re-throw the exception. Other handlers may catch it. Similar to Windows EXCEPTION_CONTINUE_SEARCH. + kERDefault // Usually set to kERTerminate. + }; + + void SetExceptionResponse(ExceptionResponse er) + { exceptionResponse = er; } + + // Allws you to add an arbitrary description of the current application, which will be added to exception reports. + void SetAppDescription(const char* appDescription); + + // If the report path has a "%s" in its name, then assume the path is a sprintf format and write it + // with the %s specified as a date/time string. + // The report path can be "default" to signify that you want to use the default user location. + // Example usage: + // handler.SetExceptionPaths("/Users/Current/Exceptions/Exception %s.txt"); + void SetExceptionPaths(const char* exceptionReportPath, const char* exceptionMinidumpPath = nullptr); + + // Allows you to specify base directories for code paths, which can be used to associate exception addresses to lines + // of code as opposed to just file names and line numbers, or function names plus binary offsets. + void SetCodeBaseDirectoryPaths(const char* codeBaseDirectoryPathArray[], size_t codeBaseDirectoryPathCount); + + // Given an exception report at a given file path, returns a string suitable for displaying in a message + // box or similar user interface during the handling of an exception. The returned string must be passed + // to FreeMessageBoxText when complete. + static const char* GetExceptionUIText(const char* exceptionReportPath); + static void FreeExceptionUIText(const char* messageBoxText); + + protected: + void WriteExceptionDescription(); + void WriteReport(); + void WriteReportLine(const char* pLine); + void WriteReportLineF(const char* format, ...); + void WriteThreadCallstack(ThreadHandle threadHandle, ThreadSysId threadSysId, const char* additionalInfo); + void WriteMiniDump(); + + // Runtime constants + bool enabled; + bool reportPrivacyEnabled; // Defaults to true. + ExceptionResponse exceptionResponse; // Defaults to kERHandle + ExceptionListener* exceptionListener; + uintptr_t exceptionListenerUserValue; + String appDescription; + String codeBasePathArray[6]; // 6 is arbitrary. + char reportFilePath[OVR_MAX_PATH];// May be an encoded path, in that it has "%s" in it or is named "default". See reporFiletPathActual for the runtime actual report path. + int miniDumpFlags; + char miniDumpFilePath[OVR_MAX_PATH]; + FILE* file; // Can/should we use OVR Files for this? + char scratchBuffer[4096]; + SymbolLookup symbolLookup; + + // Runtime variables + bool exceptionOccurred; + OVR::AtomicInt handlingBusy; + char reportFilePathActual[OVR_MAX_PATH]; + char minidumpFilePathActual[OVR_MAX_PATH]; + int terminateReturnValue; + ExceptionInfo exceptionInfo; + + #if defined(OVR_OS_MS) + void* vectoredHandle; + LPTOP_LEVEL_EXCEPTION_FILTER previousFilter; + LPEXCEPTION_POINTERS pExceptionPointers; + + friend LONG WINAPI Win32ExceptionFilter(LPEXCEPTION_POINTERS pExceptionPointers); + LONG ExceptionFilter(LPEXCEPTION_POINTERS pExceptionPointers); + + #elif defined(OVR_OS_APPLE) + struct SavedExceptionPorts + { + SavedExceptionPorts() : count(0) { memset(this, 0, sizeof(SavedExceptionPorts)); } + + mach_msg_type_number_t count; + exception_mask_t masks[6]; + exception_handler_t ports[6]; + exception_behavior_t behaviors[6]; + thread_state_flavor_t flavors[6]; + }; + + friend void* ::MachHandlerThreadFunctionStatic(void*); + friend int ::catch_mach_exception_raise_state_identity_OVR(mach_port_t, mach_port_t, mach_port_t, exception_type_t, + mach_exception_data_type_t*, mach_msg_type_number_t, int*, thread_state_t, + mach_msg_type_number_t, thread_state_t, mach_msg_type_number_t*); + + bool InitMachExceptionHandler(); + void ShutdownMachExceptionHandler(); + void* MachHandlerThreadFunction(); + kern_return_t HandleMachException(mach_port_t port, mach_port_t thread, mach_port_t task, exception_type_t exceptionType, + mach_exception_data_type_t* pExceptionDetail, mach_msg_type_number_t exceptionDetailCount, + int* pFlavor, thread_state_t pOldState, mach_msg_type_number_t oldStateCount, thread_state_t pNewState, + mach_msg_type_number_t* pNewStateCount); + kern_return_t ForwardMachException(mach_port_t thread, mach_port_t task, exception_type_t exceptionType, + mach_exception_data_t pExceptionDetail, mach_msg_type_number_t exceptionDetailCount); + + bool machHandlerInitialized; + mach_port_t machExceptionPort; + SavedExceptionPorts machExceptionPortsSaved; + volatile bool machThreadShouldContinue; + volatile bool machThreadExecuting; + pthread_t machThread; + + #elif defined(OVR_OS_LINUX) + // To do. + #endif + }; + + + // Identifies basic exception types for the CreateException function. + enum CreateExceptionType + { + kCETAccessViolation, // Read or write to inaccessable memory. + kCETAlignment, // Misaligned read or write. + kCETDivideByZero, // Integer divide by zero. + kCETFPU, // Floating point / VPU exception. + kCETIllegalInstruction, // Illegal opcode. + kCETStackCorruption, // Stack frame was corrupted. + kCETStackOverflow, // Stack ran out of space, often due to infinite recursion. + kCETTrap // System/OS trap (system call). + }; + + + // Creates an exception of the given type, primarily for testing. + void CreateException(CreateExceptionType exceptionType); + + + +} // namespace OVR + + +OVR_RESTORE_MSVC_WARNING() + + +#endif // Header include guard diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Kernel/OVR_Delegates.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Kernel/OVR_Delegates.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,541 @@ +/************************************************************************************ + +Filename : OVR_Delegates.h +Content : C++ Delegates +Created : June 15, 2014 +Authors : Chris Taylor + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +/* + Based on The Impossibly Fast C++ Delegates by Sergey Ryazanov from + http://www.codeproject.com/KB/cpp/ImpossiblyFastCppDelegate.aspx (2005) +*/ + +/* + Usage: + + Declare a delegate with a void (int) signature, also known as a + function that returns void and has one parameter that is an int: + typedef Delegate1 MyDelegate; + MyDelegate d; + + Point the delegate to a member function: + d.SetMember(&a); + d = MyDelegate::FromMember(&a); + + Point the delegate to a const member function: + d.SetConstMember(&c); + d = MyDelegate::FromConstMember(&c); + + Point the delegate to a free function: + d.SetFree<&FreeFunctionX>(); + d = MyDelegate::FromFree<&FreeFunctionX>(); + + Invoke the function via the delegate (works for all 3 cases): + d(1000); + + By default the delegates are uninitialized. + To clear an array of delegates quickly just zero the memory. + + This implementation is nicer than FastDelegates in my opinion + because it is simple and easy to read. It is a little slower + for virtual functions, but the size of the delegate is small, + and it will only get better as compilers improve. +*/ + +#ifndef OVR_Delegates_h +#define OVR_Delegates_h + +#include "OVR_Types.h" + +namespace OVR { + + +template +class Delegate0 +{ + typedef ret_type (*StubPointer)(void *); + typedef Delegate0 this_type; + + void *_object; + StubPointer _stub; + + OVR_FORCE_INLINE Delegate0(void *object, StubPointer stub) + { + _object = object; + _stub = stub; + } + + // Stubs + + template + static OVR_FORCE_INLINE ret_type FreeStub(void * /*object*/) + { + return (F)(); + } + + template + static OVR_FORCE_INLINE ret_type MemberStub(void *object) + { + T *p = static_cast(object); + return (p->*F)(); + } + + template + static OVR_FORCE_INLINE ret_type ConstMemberStub(void *object) + { + T *p = static_cast(object); + return (p->*F)(); + } + +public: + OVR_FORCE_INLINE Delegate0() : _object(0), _stub(0){} + + // Function invocation + + OVR_FORCE_INLINE ret_type operator()() const + { + return (*_stub)(_object); + } + + // Use stub pointer as a validity flag and equality checker + + OVR_FORCE_INLINE bool operator==(const this_type &rhs) const + { + return _object == rhs._object && _stub == rhs._stub; + } + + OVR_FORCE_INLINE bool operator!=(const this_type &rhs) const + { + return _object != rhs._object || _stub != rhs._stub; + } + + OVR_FORCE_INLINE bool IsValid() const + { + return _stub != 0; + } + + OVR_FORCE_INLINE bool operator!() const + { + return _stub == 0; + } + + OVR_FORCE_INLINE void Invalidate() + { + _stub = 0; + } + + // Delegate creation from a function + + template + static OVR_FORCE_INLINE this_type FromFree() + { + return this_type(0, &FreeStub); + } + + template + static OVR_FORCE_INLINE this_type FromMember(T *object) + { + return this_type(object, &MemberStub); + } + + template + static OVR_FORCE_INLINE this_type FromConstMember(T const *object) + { + return this_type(const_cast( object ), &ConstMemberStub); + } + + // In-place assignment to a different function + + template + OVR_FORCE_INLINE void SetFree() + { + *this = FromFree(); + } + + template + OVR_FORCE_INLINE void SetMember(T *object) + { + *this = FromMember(object); + } + + template + OVR_FORCE_INLINE void SetConstMember(T const *object) + { + *this = FromConstMember(object); + } +}; + + +template +class Delegate1 +{ + typedef ret_type (*StubPointer)(void *, arg1_type); + typedef Delegate1 this_type; + + void *_object; + StubPointer _stub; + + OVR_FORCE_INLINE Delegate1(void *object, StubPointer stub) + { + _object = object; + _stub = stub; + } + + // Stubs + + template + static OVR_FORCE_INLINE ret_type FreeStub(void * /*object*/, arg1_type a1) + { + return (F)(a1); + } + + template + static OVR_FORCE_INLINE ret_type MemberStub(void *object, arg1_type a1) + { + T *p = static_cast(object); + return (p->*F)(a1); + } + + template + static OVR_FORCE_INLINE ret_type ConstMemberStub(void *object, arg1_type a1) + { + T *p = static_cast(object); + return (p->*F)(a1); + } + +public: + OVR_FORCE_INLINE Delegate1() : _object(0), _stub(0){} + + // Function invocation + + OVR_FORCE_INLINE ret_type operator()(arg1_type a1) const + { + return (*_stub)(_object, a1); + } + + // Use stub pointer as a validity flag and equality checker + + OVR_FORCE_INLINE bool operator==(const this_type &rhs) const + { + return _object == rhs._object && _stub == rhs._stub; + } + + OVR_FORCE_INLINE bool operator!=(const this_type &rhs) const + { + return _object != rhs._object || _stub != rhs._stub; + } + + OVR_FORCE_INLINE bool IsValid() const + { + return _stub != 0; + } + + OVR_FORCE_INLINE bool operator!() const + { + return _stub == 0; + } + + OVR_FORCE_INLINE void Invalidate() + { + _stub = 0; + } + + // Delegate creation from a function + + template + static OVR_FORCE_INLINE this_type FromFree() + { + return this_type(0, &FreeStub); + } + + template + static OVR_FORCE_INLINE this_type FromMember(T *object) + { + return this_type(object, &MemberStub); + } + + template + static OVR_FORCE_INLINE this_type FromConstMember(T const *object) + { + return this_type(const_cast( object ), &ConstMemberStub); + } + + // In-place assignment to a different function + + template + OVR_FORCE_INLINE void SetFree() + { + *this = FromFree(); + } + + template + OVR_FORCE_INLINE void SetMember(T *object) + { + *this = FromMember(object); + } + + template + OVR_FORCE_INLINE void SetConstMember(T const *object) + { + *this = FromConstMember(object); + } +}; + + +template +class Delegate2 +{ + typedef ret_type (*StubPointer)(void *, arg1_type, arg2_type); + typedef Delegate2 this_type; + + void *_object; + StubPointer _stub; + + OVR_FORCE_INLINE Delegate2(void *object, StubPointer stub) + { + _object = object; + _stub = stub; + } + + // Stubs + + template + static OVR_FORCE_INLINE ret_type FreeStub(void * /*object*/, arg1_type a1, arg2_type a2) + { + return (F)(a1, a2); + } + + template + static OVR_FORCE_INLINE ret_type MemberStub(void *object, arg1_type a1, arg2_type a2) + { + T *p = static_cast(object); + return (p->*F)(a1, a2); + } + + template + static OVR_FORCE_INLINE ret_type ConstMemberStub(void *object, arg1_type a1, arg2_type a2) + { + T *p = static_cast(object); + return (p->*F)(a1, a2); + } + +public: + OVR_FORCE_INLINE Delegate2() : _object(0), _stub(0){} + + // Function invocation + + OVR_FORCE_INLINE ret_type operator()(arg1_type a1, arg2_type a2) const + { + return (*_stub)(_object, a1, a2); + } + + // Use stub pointer as a validity flag and equality checker + + OVR_FORCE_INLINE bool operator==(const this_type &rhs) const + { + return _object == rhs._object && _stub == rhs._stub; + } + + OVR_FORCE_INLINE bool operator!=(const this_type &rhs) const + { + return _object != rhs._object || _stub != rhs._stub; + } + + OVR_FORCE_INLINE bool IsValid() const + { + return _stub != 0; + } + + OVR_FORCE_INLINE bool operator!() const + { + return _stub == 0; + } + + OVR_FORCE_INLINE void Invalidate() + { + _stub = 0; + } + + // Delegate creation from a function + + template + static OVR_FORCE_INLINE this_type FromFree() + { + return this_type(0, &FreeStub); + } + + template + static OVR_FORCE_INLINE this_type FromMember(T *object) + { + return this_type(object, &MemberStub); + } + + template + static OVR_FORCE_INLINE this_type FromConstMember(T const *object) + { + return this_type(const_cast( object ), &ConstMemberStub); + } + + // In-place assignment to a different function + + template + OVR_FORCE_INLINE void SetFree() + { + *this = FromFree(); + } + + template + OVR_FORCE_INLINE void SetMember(T *object) + { + *this = FromMember(object); + } + + template + OVR_FORCE_INLINE void SetConstMember(T const *object) + { + *this = FromConstMember(object); + } +}; + + +template +class Delegate3 +{ + typedef ret_type (*StubPointer)(void *, arg1_type, arg2_type, arg3_type); + typedef Delegate3 this_type; + + void *_object; + StubPointer _stub; + + OVR_FORCE_INLINE Delegate3(void *object, StubPointer stub) + { + _object = object; + _stub = stub; + } + + // Stubs + + template + static OVR_FORCE_INLINE ret_type FreeStub(void * /*object*/, arg1_type a1, arg2_type a2, arg3_type a3) + { + return (F)(a1, a2, a3); + } + + template + static OVR_FORCE_INLINE ret_type MemberStub(void *object, arg1_type a1, arg2_type a2, arg3_type a3) + { + T *p = static_cast(object); + return (p->*F)(a1, a2, a3); + } + + template + static OVR_FORCE_INLINE ret_type ConstMemberStub(void *object, arg1_type a1, arg2_type a2, arg3_type a3) + { + T *p = static_cast(object); + return (p->*F)(a1, a2, a3); + } + +public: + OVR_FORCE_INLINE Delegate3() : _object(0), _stub(0){} + + // Function invocation + + OVR_FORCE_INLINE ret_type operator()(arg1_type a1, arg2_type a2, arg3_type a3) const + { + return (*_stub)(_object, a1, a2, a3); + } + + // Use stub pointer as a validity flag and equality checker + + OVR_FORCE_INLINE bool operator==(const this_type &rhs) const + { + return _object == rhs._object && _stub == rhs._stub; + } + + OVR_FORCE_INLINE bool operator!=(const this_type &rhs) const + { + return _object != rhs._object || _stub != rhs._stub; + } + + OVR_FORCE_INLINE bool IsValid() const + { + return _stub != 0; + } + + OVR_FORCE_INLINE bool operator!() const + { + return _stub == 0; + } + + OVR_FORCE_INLINE void Invalidate() + { + _stub = 0; + } + + // Delegate creation from a function + + template + static OVR_FORCE_INLINE this_type FromFree() + { + return this_type(0, &FreeStub); + } + + template + static OVR_FORCE_INLINE this_type FromMember(T *object) + { + return this_type(object, &MemberStub); + } + + template + static OVR_FORCE_INLINE this_type FromConstMember(T const *object) + { + return this_type(const_cast( object ), &ConstMemberStub); + } + + // In-place assignment to a different function + + template + OVR_FORCE_INLINE void SetFree() + { + *this = FromFree(); + } + + template + OVR_FORCE_INLINE void SetMember(T *object) + { + *this = FromMember(object); + } + + template + OVR_FORCE_INLINE void SetConstMember(T const *object) + { + *this = FromConstMember(object); + } +}; + +// Add more here if needed, but keep in mind that a short, simple interface +// is rewarded by making the delegates faster... + + +} // namespace OVR + +#endif // OVR_Delegates_h diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Kernel/OVR_Deque.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Kernel/OVR_Deque.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,316 @@ +/************************************************************************************ + +Filename : OVR_Deque.h +Content : Deque container +Created : Nov. 15, 2013 +Authors : Dov Katz + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +*************************************************************************************/ + +#ifndef OVR_Deque_h +#define OVR_Deque_h + +#include "OVR_ContainerAllocator.h" + +namespace OVR{ + +template > +class Deque +{ +public: + enum + { + DefaultCapacity = 500 + }; + + Deque(int capacity = DefaultCapacity); + virtual ~Deque(void); + + virtual void PushBack (const Elem &Item); // Adds Item to the end + virtual void PushFront (const Elem &Item); // Adds Item to the beginning + virtual Elem PopBack (void); // Removes Item from the end + virtual Elem PopFront (void); // Removes Item from the beginning + virtual const Elem& PeekBack (int count = 0) const; // Returns count-th Item from the end + virtual const Elem& PeekFront (int count = 0) const; // Returns count-th Item from the beginning + + virtual inline size_t GetSize (void) const; // Returns Number of Elements + OVR_FORCE_INLINE int GetSizeI (void) const + { + return (int)GetSize(); + } + virtual inline size_t GetCapacity(void) const; // Returns the maximum possible number of elements + virtual void Clear (void); // Remove all elements + virtual inline bool IsEmpty () const; + virtual inline bool IsFull () const; + +protected: + Elem *Data; // The actual Data array + const int Capacity; // Deque capacity + int Beginning; // Index of the first element + int End; // Index of the next after last element + + // Instead of calculating the number of elements, using this variable + // is much more convenient. + int ElemCount; + +private: + OVR_NON_COPYABLE(Deque); +}; + +template > +class InPlaceMutableDeque : public Deque +{ + typedef Deque BaseType; + +public: + InPlaceMutableDeque( int capacity = BaseType::DefaultCapacity ) : BaseType( capacity ) {} + virtual ~InPlaceMutableDeque() {}; + + using BaseType::PeekBack; + using BaseType::PeekFront; + virtual Elem& PeekBack (int count = 0); // Returns count-th Item from the end + virtual Elem& PeekFront (int count = 0); // Returns count-th Item from the beginning +}; + +// Same as Deque, but allows to write more elements than maximum capacity +// Old elements are lost as they are overwritten with the new ones +template > +class CircularBuffer : public InPlaceMutableDeque +{ + typedef InPlaceMutableDeque BaseType; + +public: + CircularBuffer(int MaxSize = BaseType::DefaultCapacity) : BaseType(MaxSize) { }; + virtual ~CircularBuffer(){} + + // The following methods are inline as a workaround for a VS bug causing erroneous C4505 warnings + // See: http://stackoverflow.com/questions/3051992/compiler-warning-at-c-template-base-class + inline virtual void PushBack (const Elem &Item); // Adds Item to the end, overwriting the oldest element at the beginning if necessary + inline virtual void PushFront (const Elem &Item); // Adds Item to the beginning, overwriting the oldest element at the end if necessary +}; + +//---------------------------------------------------------------------------------- + +// Deque Constructor function +template +Deque::Deque(int capacity) : +Capacity( capacity ), Beginning(0), End(0), ElemCount(0) +{ + Data = (Elem*) Allocator::Alloc(Capacity * sizeof(Elem)); +} + +// Deque Destructor function +template +Deque::~Deque(void) +{ + Clear(); + Allocator::Free(Data); +} + +template +void Deque::Clear() +{ + if (!IsEmpty()) + { + if (Beginning < End) + { + // no wrap-around + Allocator::DestructArray(Data + Beginning, End - Beginning); + } + else + { + // wrap-around + Allocator::DestructArray(Data + Beginning, Capacity - Beginning); + Allocator::DestructArray(Data, End); + } + } + + Beginning = 0; + End = 0; + ElemCount = 0; +} + +// Push functions +template +void Deque::PushBack(const Elem &Item) +{ + // Error Check: Make sure we aren't + // exceeding our maximum storage space + OVR_ASSERT( ElemCount < Capacity ); + + Allocator::Construct(Data + End, Item); + ++End; + ++ElemCount; + + // Check for wrap-around + if (End >= Capacity) + End -= Capacity; +} + +template +void Deque::PushFront(const Elem &Item) +{ + // Error Check: Make sure we aren't + // exceeding our maximum storage space + OVR_ASSERT( ElemCount < Capacity ); + + --Beginning; + // Check for wrap-around + if (Beginning < 0) + Beginning += Capacity; + + Allocator::Construct(Data + Beginning, Item); + ++ElemCount; +} + +// Pop functions +template +Elem Deque::PopFront(void) +{ + // Error Check: Make sure we aren't reading from an empty Deque + OVR_ASSERT( ElemCount > 0 ); + + Elem ReturnValue = Data[ Beginning ]; + Allocator::Destruct(Data + Beginning); + + ++Beginning; + --ElemCount; + + // Check for wrap-around + if (Beginning >= Capacity) + Beginning -= Capacity; + + return ReturnValue; +} + +template +Elem Deque::PopBack(void) +{ + // Error Check: Make sure we aren't reading from an empty Deque + OVR_ASSERT( ElemCount > 0 ); + + --End; + --ElemCount; + + // Check for wrap-around + if (End < 0) + End += Capacity; + + Elem ReturnValue = Data[ End ]; + Allocator::Destruct(Data + End); + + return ReturnValue; +} + +// Peek functions +template +const Elem& Deque::PeekFront(int count) const +{ + // Error Check: Make sure we aren't reading from an empty Deque + OVR_ASSERT( ElemCount > count ); + + int idx = Beginning + count; + if (idx >= Capacity) + idx -= Capacity; + return Data[ idx ]; +} + +template +const Elem& Deque::PeekBack(int count) const +{ + // Error Check: Make sure we aren't reading from an empty Deque + OVR_ASSERT( ElemCount > count ); + + int idx = End - count - 1; + if (idx < 0) + idx += Capacity; + return Data[ idx ]; +} + +// Mutable Peek functions +template +Elem& InPlaceMutableDeque::PeekFront(int count) +{ + // Error Check: Make sure we aren't reading from an empty Deque + OVR_ASSERT( BaseType::ElemCount > count ); + + int idx = BaseType::Beginning + count; + if (idx >= BaseType::Capacity) + idx -= BaseType::Capacity; + return BaseType::Data[ idx ]; +} + +template +Elem& InPlaceMutableDeque::PeekBack(int count) +{ + // Error Check: Make sure we aren't reading from an empty Deque + OVR_ASSERT( BaseType::ElemCount > count ); + + int idx = BaseType::End - count - 1; + if (idx < 0) + idx += BaseType::Capacity; + return BaseType::Data[ idx ]; +} + +template +inline size_t Deque::GetCapacity(void) const +{ + return Capacity; +} + +template +inline size_t Deque::GetSize(void) const +{ + return ElemCount; +} + +template +inline bool Deque::IsEmpty(void) const +{ + return ElemCount == 0; +} + +template +inline bool Deque::IsFull(void) const +{ + return ElemCount == Capacity; +} + +// ******* CircularBuffer ******* +// Push functions +template +void CircularBuffer::PushBack(const Elem &Item) +{ + if (this->IsFull()) + this->PopFront(); + BaseType::PushBack(Item); +} + +template +void CircularBuffer::PushFront(const Elem &Item) +{ + if (this->IsFull()) + this->PopBack(); + BaseType::PushFront(Item); +} + +}; + +#endif diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Kernel/OVR_File.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Kernel/OVR_File.cpp Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,585 @@ +/************************************************************************** + +Filename : OVR_File.cpp +Content : File wrapper class implementation (Win32) + +Created : April 5, 1999 +Authors : Michael Antonov + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +**************************************************************************/ + +#define GFILE_CXX + +// Standard C library (Captain Obvious guarantees!) +#include + +#include "OVR_File.h" + +namespace OVR { + +// Buffered file adds buffering to an existing file +// FILEBUFFER_SIZE defines the size of internal buffer, while +// FILEBUFFER_TOLERANCE controls the amount of data we'll effectively try to buffer +#define FILEBUFFER_SIZE (8192-8) +#define FILEBUFFER_TOLERANCE 4096 + +// ** Constructor/Destructor + +// Hidden constructor +// Not supposed to be used +BufferedFile::BufferedFile() : DelegatedFile(0) +{ + pBuffer = (uint8_t*)OVR_ALLOC(FILEBUFFER_SIZE); + BufferMode = NoBuffer; + FilePos = 0; + Pos = 0; + DataSize = 0; +} + +// Takes another file as source +BufferedFile::BufferedFile(File *pfile) : DelegatedFile(pfile) +{ + pBuffer = (uint8_t*)OVR_ALLOC(FILEBUFFER_SIZE); + BufferMode = NoBuffer; + FilePos = pfile->LTell(); + Pos = 0; + DataSize = 0; +} + + +// Destructor +BufferedFile::~BufferedFile() +{ + // Flush in case there's data + if (pFile) + FlushBuffer(); + // Get rid of buffer + if (pBuffer) + OVR_FREE(pBuffer); +} + +/* +bool BufferedFile::VCopy(const Object &source) +{ + if (!DelegatedFile::VCopy(source)) + return 0; + + // Data members + BufferedFile *psource = (BufferedFile*)&source; + + // Buffer & the mode it's in + pBuffer = psource->pBuffer; + BufferMode = psource->BufferMode; + Pos = psource->Pos; + DataSize = psource->DataSize; + return 1; +} +*/ + +// Initializes buffering to a certain mode +bool BufferedFile::SetBufferMode(BufferModeType mode) +{ + if (!pBuffer) + return false; + if (mode == BufferMode) + return true; + + FlushBuffer(); + + // Can't set write mode if we can't write + if ((mode==WriteBuffer) && (!pFile || !pFile->IsWritable()) ) + return 0; + + // And SetMode + BufferMode = mode; + Pos = 0; + DataSize = 0; + return 1; +} + +// Flushes buffer +void BufferedFile::FlushBuffer() +{ + switch(BufferMode) + { + case WriteBuffer: + // Write data in buffer + FilePos += pFile->Write(pBuffer,Pos); + Pos = 0; + break; + + case ReadBuffer: + // Seek back & reset buffer data + if ((DataSize-Pos)>0) + FilePos = pFile->LSeek(-(int)(DataSize-Pos), Seek_Cur); + DataSize = 0; + Pos = 0; + break; + default: + // not handled! + break; + } +} + +// Reloads data for ReadBuffer +void BufferedFile::LoadBuffer() +{ + if (BufferMode == ReadBuffer) + { + // We should only reload once all of pre-loaded buffer is consumed. + OVR_ASSERT(Pos == DataSize); + + // WARNING: Right now LoadBuffer() assumes the buffer's empty + int sz = pFile->Read(pBuffer,FILEBUFFER_SIZE); + DataSize = sz<0 ? 0 : (unsigned)sz; + Pos = 0; + FilePos += DataSize; + } +} + + +// ** Overridden functions + +// We override all the functions that can possibly +// require buffer mode switch, flush, or extra calculations + +// Tell() requires buffer adjustment +int BufferedFile::Tell() +{ + if (BufferMode == ReadBuffer) + return int (FilePos - DataSize + Pos); + + int pos = pFile->Tell(); + // Adjust position based on buffer mode & data + if (pos!=-1) + { + OVR_ASSERT(BufferMode != ReadBuffer); + if (BufferMode == WriteBuffer) + pos += Pos; + } + return pos; +} + +int64_t BufferedFile::LTell() +{ + if (BufferMode == ReadBuffer) + return FilePos - DataSize + Pos; + + int64_t pos = pFile->LTell(); + if (pos!=-1) + { + OVR_ASSERT(BufferMode != ReadBuffer); + if (BufferMode == WriteBuffer) + pos += Pos; + } + return pos; +} + +int BufferedFile::GetLength() +{ + int len = pFile->GetLength(); + // If writing through buffer, file length may actually be bigger + if ((len!=-1) && (BufferMode==WriteBuffer)) + { + int currPos = pFile->Tell() + Pos; + if (currPos>len) + len = currPos; + } + return len; +} +int64_t BufferedFile::LGetLength() +{ + int64_t len = pFile->LGetLength(); + // If writing through buffer, file length may actually be bigger + if ((len!=-1) && (BufferMode==WriteBuffer)) + { + int64_t currPos = pFile->LTell() + Pos; + if (currPos>len) + len = currPos; + } + return len; +} + +/* +bool BufferedFile::Stat(FileStats *pfs) +{ + // Have to fix up length is stat + if (pFile->Stat(pfs)) + { + if (BufferMode==WriteBuffer) + { + int64_t currPos = pFile->LTell() + Pos; + if (currPos > pfs->Size) + { + pfs->Size = currPos; + // ?? + pfs->Blocks = (pfs->Size+511) >> 9; + } + } + return 1; + } + return 0; +} +*/ + +int BufferedFile::Write(const uint8_t *psourceBuffer, int numBytes) +{ + if ( (BufferMode==WriteBuffer) || SetBufferMode(WriteBuffer)) + { + // If not data space in buffer, flush + if ((FILEBUFFER_SIZE-(int)Pos)FILEBUFFER_TOLERANCE) + { + int sz = pFile->Write(psourceBuffer,numBytes); + if (sz > 0) + FilePos += sz; + return sz; + } + } + + // Enough space in buffer.. so copy to it + memcpy(pBuffer+Pos, psourceBuffer, numBytes); + Pos += numBytes; + return numBytes; + } + int sz = pFile->Write(psourceBuffer,numBytes); + if (sz > 0) + FilePos += sz; + return sz; +} + +int BufferedFile::Read(uint8_t *pdestBuffer, int numBytes) +{ + if ( (BufferMode==ReadBuffer) || SetBufferMode(ReadBuffer)) + { + // Data in buffer... copy it + if ((int)(DataSize-Pos) >= numBytes) + { + memcpy(pdestBuffer, pBuffer+Pos, numBytes); + Pos += numBytes; + return numBytes; + } + + // Not enough data in buffer, copy buffer + int readBytes = DataSize-Pos; + memcpy(pdestBuffer, pBuffer+Pos, readBytes); + numBytes -= readBytes; + pdestBuffer += readBytes; + Pos = DataSize; + + // Don't reload buffer if more then tolerance + // (No major advantage, and we don't want to write a loop) + if (numBytes>FILEBUFFER_TOLERANCE) + { + numBytes = pFile->Read(pdestBuffer,numBytes); + if (numBytes > 0) + { + FilePos += numBytes; + Pos = DataSize = 0; + } + return readBytes + ((numBytes==-1) ? 0 : numBytes); + } + + // Reload the buffer + // WARNING: Right now LoadBuffer() assumes the buffer's empty + LoadBuffer(); + if ((int)(DataSize-Pos) < numBytes) + numBytes = (int)DataSize-Pos; + + memcpy(pdestBuffer, pBuffer+Pos, numBytes); + Pos += numBytes; + return numBytes + readBytes; + + /* + // Alternative Read implementation. The one above is probably better + // due to FILEBUFFER_TOLERANCE. + int total = 0; + + do { + int bufferBytes = (int)(DataSize-Pos); + int copyBytes = (bufferBytes > numBytes) ? numBytes : bufferBytes; + + memcpy(pdestBuffer, pBuffer+Pos, copyBytes); + numBytes -= copyBytes; + pdestBuffer += copyBytes; + Pos += copyBytes; + total += copyBytes; + + if (numBytes == 0) + break; + LoadBuffer(); + + } while (DataSize > 0); + + return total; + */ + } + int sz = pFile->Read(pdestBuffer,numBytes); + if (sz > 0) + FilePos += sz; + return sz; +} + + +int BufferedFile::SkipBytes(int numBytes) +{ + int skippedBytes = 0; + + // Special case for skipping a little data in read buffer + if (BufferMode==ReadBuffer) + { + skippedBytes = (((int)DataSize-(int)Pos) >= numBytes) ? numBytes : (DataSize-Pos); + Pos += skippedBytes; + numBytes -= skippedBytes; + } + + if (numBytes) + { + numBytes = pFile->SkipBytes(numBytes); + // Make sure we return the actual number skipped, or error + if (numBytes!=-1) + { + skippedBytes += numBytes; + FilePos += numBytes; + Pos = DataSize = 0; + } + else if (skippedBytes <= 0) + skippedBytes = -1; + } + return skippedBytes; +} + +int BufferedFile::BytesAvailable() +{ + int available = pFile->BytesAvailable(); + // Adjust available size based on buffers + switch(BufferMode) + { + case ReadBuffer: + available += DataSize-Pos; + break; + case WriteBuffer: + available -= Pos; + if (available<0) + available= 0; + break; + default: + break; + } + return available; +} + +bool BufferedFile::Flush() +{ + FlushBuffer(); + return pFile->Flush(); +} + +// Seeking could be optimized better.. +int BufferedFile::Seek(int offset, int origin) +{ + if (BufferMode == ReadBuffer) + { + if (origin == Seek_Cur) + { + // Seek can fall either before or after Pos in the buffer, + // but it must be within bounds. + if (((unsigned(offset) + Pos)) <= DataSize) + { + Pos += offset; + return int (FilePos - DataSize + Pos); + } + + // Lightweight buffer "Flush". We do this to avoid an extra seek + // back operation which would take place if we called FlushBuffer directly. + origin = Seek_Set; + OVR_ASSERT(((FilePos - DataSize + Pos) + (uint64_t)offset) < ~(uint64_t)0); + offset = (int)(FilePos - DataSize + Pos) + offset; + Pos = DataSize = 0; + } + else if (origin == Seek_Set) + { + if (((unsigned)offset - (FilePos-DataSize)) <= DataSize) + { + OVR_ASSERT((FilePos-DataSize) < ~(uint64_t)0); + Pos = (unsigned)offset - (unsigned)(FilePos-DataSize); + return offset; + } + Pos = DataSize = 0; + } + else + { + FlushBuffer(); + } + } + else + { + FlushBuffer(); + } + + /* + // Old Seek Logic + if (origin == Seek_Cur && offset + Pos < DataSize) + { + //OVR_ASSERT((FilePos - DataSize) >= (FilePos - DataSize + Pos + offset)); + Pos += offset; + OVR_ASSERT(int (Pos) >= 0); + return int (FilePos - DataSize + Pos); + } + else if (origin == Seek_Set && unsigned(offset) >= FilePos - DataSize && unsigned(offset) < FilePos) + { + Pos = unsigned(offset - FilePos + DataSize); + OVR_ASSERT(int (Pos) >= 0); + return int (FilePos - DataSize + Pos); + } + + FlushBuffer(); + */ + + + FilePos = pFile->Seek(offset,origin); + return int (FilePos); +} + +int64_t BufferedFile::LSeek(int64_t offset, int origin) +{ + if (BufferMode == ReadBuffer) + { + if (origin == Seek_Cur) + { + // Seek can fall either before or after Pos in the buffer, + // but it must be within bounds. + if (((unsigned(offset) + Pos)) <= DataSize) + { + Pos += (unsigned)offset; + return int64_t(FilePos - DataSize + Pos); + } + + // Lightweight buffer "Flush". We do this to avoid an extra seek + // back operation which would take place if we called FlushBuffer directly. + origin = Seek_Set; + offset = (int64_t)(FilePos - DataSize + Pos) + offset; + Pos = DataSize = 0; + } + else if (origin == Seek_Set) + { + if (((uint64_t)offset - (FilePos-DataSize)) <= DataSize) + { + Pos = (unsigned)((uint64_t)offset - (FilePos-DataSize)); + return offset; + } + Pos = DataSize = 0; + } + else + { + FlushBuffer(); + } + } + else + { + FlushBuffer(); + } + +/* + OVR_ASSERT(BufferMode != NoBuffer); + + if (origin == Seek_Cur && offset + Pos < DataSize) + { + Pos += int (offset); + return FilePos - DataSize + Pos; + } + else if (origin == Seek_Set && offset >= int64_t(FilePos - DataSize) && offset < int64_t(FilePos)) + { + Pos = unsigned(offset - FilePos + DataSize); + return FilePos - DataSize + Pos; + } + + FlushBuffer(); + */ + + FilePos = pFile->LSeek(offset,origin); + return FilePos; +} + +int BufferedFile::CopyFromStream(File *pstream, int byteSize) +{ + // We can't rely on overridden Write() + // because delegation doesn't override virtual pointers + // So, just re-implement + uint8_t* buff = new uint8_t[0x4000]; + int count = 0; + int szRequest, szRead, szWritten; + + while(byteSize) + { + szRequest = (byteSize > int(sizeof(buff))) ? int(sizeof(buff)) : byteSize; + + szRead = pstream->Read(buff,szRequest); + szWritten = 0; + if (szRead > 0) + szWritten = Write(buff,szRead); + + count +=szWritten; + byteSize-=szWritten; + if (szWritten < szRequest) + break; + } + + delete[] buff; + + return count; +} + +// Closing files +bool BufferedFile::Close() +{ + switch(BufferMode) + { + case WriteBuffer: + FlushBuffer(); + break; + case ReadBuffer: + // No need to seek back on close + BufferMode = NoBuffer; + break; + default: + break; + } + return pFile->Close(); +} + + +// ***** Global path helpers + +// Find trailing short filename in a path. +const char* OVR_CDECL GetShortFilename(const char* purl) +{ + size_t len = OVR_strlen(purl); + for (size_t i=len; i>0; i--) + if (purl[i]=='\\' || purl[i]=='/') + return purl+i+1; + return purl; +} + +} // OVR + diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Kernel/OVR_File.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Kernel/OVR_File.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,530 @@ +/************************************************************************************ + +PublicHeader: Kernel +Filename : OVR_File.h +Content : Header for all internal file management - functions and structures + to be inherited by OS specific subclasses. +Created : September 19, 2012 +Notes : + +Notes : errno may not be preserved across use of BaseFile member functions + : Directories cannot be deleted while files opened from them are in use + (For the GetFullName function) + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#ifndef OVR_File_h +#define OVR_File_h + +#include "OVR_RefCount.h" +#include "OVR_Std.h" +#include "OVR_Alg.h" + +#include +#include "OVR_String.h" + +namespace OVR { + +// ***** Declared classes +class FileConstants; +class File; +class DelegatedFile; +class BufferedFile; + + +// ***** Flags for File & Directory accesses + +class FileConstants +{ +public: + + // *** File open flags + enum OpenFlags + { + Open_Read = 1, + Open_Write = 2, + Open_ReadWrite = 3, + + // Opens file and truncates it to zero length + // - file must have write permission + // - when used with Create, it opens an existing + // file and empties it or creates a new file + Open_Truncate = 4, + + // Creates and opens new file + // - does not erase contents if file already + // exists unless combined with Truncate + Open_Create = 8, + + // Returns an error value if the file already exists + Open_CreateOnly = 24, + + // Open file with buffering + Open_Buffered = 32 + }; + + // *** File Mode flags + enum Modes + { + Mode_Read = 0444, + Mode_Write = 0222, + Mode_Execute = 0111, + + Mode_ReadWrite = 0666 + }; + + // *** Seek operations + enum SeekOps + { + Seek_Set = 0, + Seek_Cur = 1, + Seek_End = 2 + }; + + // *** Errors + enum Errors + { + Error_FileNotFound = 0x1001, + Error_Access = 0x1002, + Error_IOError = 0x1003, + Error_DiskFull = 0x1004 + }; +}; + + +//----------------------------------------------------------------------------------- +// ***** File Class + +// The pure virtual base random-access file +// This is a base class to all files + +class File : public RefCountBase, public FileConstants +{ +public: + File() { } + // ** Location Information + + // Returns a file name path relative to the 'reference' directory + // This is often a path that was used to create a file + // (this is not a global path, global path can be obtained with help of directory) + virtual const char* GetFilePath() = 0; + + + // ** File Information + + // Return 1 if file's usable (open) + virtual bool IsValid() = 0; + // Return 1 if file's writable, otherwise 0 + virtual bool IsWritable() = 0; + + // Return position + virtual int Tell() = 0; + virtual int64_t LTell() = 0; + + // File size + virtual int GetLength() = 0; + virtual int64_t LGetLength() = 0; + + // Returns file stats + // 0 for failure + //virtual bool Stat(FileStats *pfs) = 0; + + // Return errno-based error code + // Useful if any other function failed + virtual int GetErrorCode() = 0; + + + // ** Stream implementation & I/O + + // Blocking write, will write in the given number of bytes to the stream + // Returns : -1 for error + // Otherwise number of bytes read + virtual int Write(const uint8_t *pbufer, int numBytes) = 0; + // Blocking read, will read in the given number of bytes or less from the stream + // Returns : -1 for error + // Otherwise number of bytes read, + // if 0 or < numBytes, no more bytes available; end of file or the other side of stream is closed + virtual int Read(uint8_t *pbufer, int numBytes) = 0; + + // Skips (ignores) a given # of bytes + // Same return values as Read + virtual int SkipBytes(int numBytes) = 0; + + // Returns the number of bytes available to read from a stream without blocking + // For a file, this should generally be number of bytes to the end + virtual int BytesAvailable() = 0; + + // Causes any implementation's buffered data to be delivered to destination + // Return 0 for error + virtual bool Flush() = 0; + + + // Need to provide a more optimized implementation that doe snot necessarily involve a lot of seeking + inline bool IsEOF() { return !BytesAvailable(); } + + + // Seeking + // Returns new position, -1 for error + virtual int Seek(int offset, int origin=Seek_Set) = 0; + virtual int64_t LSeek(int64_t offset, int origin=Seek_Set) = 0; + // Seek simplification + int SeekToBegin() {return Seek(0); } + int SeekToEnd() {return Seek(0,Seek_End); } + int Skip(int numBytes) {return Seek(numBytes,Seek_Cur); } + + + // Appends other file data from a stream + // Return -1 for error, else # of bytes written + virtual int CopyFromStream(File *pstream, int byteSize) = 0; + + // Closes the file + // After close, file cannot be accessed + virtual bool Close() = 0; + + + // ***** Inlines for convenient primitive type serialization + + // Read/Write helpers +private: + uint64_t PRead64() { uint64_t v = 0; Read((uint8_t*)&v, 8); return v; } + uint32_t PRead32() { uint32_t v = 0; Read((uint8_t*)&v, 4); return v; } + uint16_t PRead16() { uint16_t v = 0; Read((uint8_t*)&v, 2); return v; } + uint8_t PRead8() { uint8_t v = 0; Read((uint8_t*)&v, 1); return v; } + void PWrite64(uint64_t v) { Write((uint8_t*)&v, 8); } + void PWrite32(uint32_t v) { Write((uint8_t*)&v, 4); } + void PWrite16(uint16_t v) { Write((uint8_t*)&v, 2); } + void PWrite8(uint8_t v) { Write((uint8_t*)&v, 1); } + +public: + + // Writing primitive types - Little Endian + inline void WriteUByte(uint8_t v) { PWrite8((uint8_t)Alg::ByteUtil::SystemToLE(v)); } + inline void WriteSByte(int8_t v) { PWrite8((uint8_t)Alg::ByteUtil::SystemToLE(v)); } + inline void WriteUInt8(uint8_t v) { PWrite8((uint8_t)Alg::ByteUtil::SystemToLE(v)); } + inline void WriteSInt8(int8_t v) { PWrite8((uint8_t)Alg::ByteUtil::SystemToLE(v)); } + inline void WriteUInt16(uint16_t v) { PWrite16((uint16_t)Alg::ByteUtil::SystemToLE(v)); } + inline void WriteSInt16(int16_t v) { PWrite16((uint16_t)Alg::ByteUtil::SystemToLE(v)); } + inline void WriteUInt32(uint32_t v) { PWrite32((uint32_t)Alg::ByteUtil::SystemToLE(v)); } + inline void WriteSInt32(int32_t v) { PWrite32((uint32_t)Alg::ByteUtil::SystemToLE(v)); } + inline void WriteUInt64(uint64_t v) { PWrite64((uint64_t)Alg::ByteUtil::SystemToLE(v)); } + inline void WriteSInt64(int64_t v) { PWrite64((uint64_t)Alg::ByteUtil::SystemToLE(v)); } + inline void WriteFloat(float v) { v = Alg::ByteUtil::SystemToLE(v); Write((uint8_t*)&v, 4); } + inline void WriteDouble(double v) { v = Alg::ByteUtil::SystemToLE(v); Write((uint8_t*)&v, 8); } + // Writing primitive types - Big Endian + inline void WriteUByteBE(uint8_t v) { PWrite8((uint8_t)Alg::ByteUtil::SystemToBE(v)); } + inline void WriteSByteBE(int8_t v) { PWrite8((uint8_t)Alg::ByteUtil::SystemToBE(v)); } + inline void WriteUInt8BE(uint16_t v) { PWrite8((uint8_t)Alg::ByteUtil::SystemToBE(v)); } + inline void WriteSInt8BE(int16_t v) { PWrite8((uint8_t)Alg::ByteUtil::SystemToBE(v)); } + inline void WriteUInt16BE(uint16_t v) { PWrite16((uint16_t)Alg::ByteUtil::SystemToBE(v)); } + inline void WriteSInt16BE(uint16_t v) { PWrite16((uint16_t)Alg::ByteUtil::SystemToBE(v)); } + inline void WriteUInt32BE(uint32_t v) { PWrite32((uint32_t)Alg::ByteUtil::SystemToBE(v)); } + inline void WriteSInt32BE(uint32_t v) { PWrite32((uint32_t)Alg::ByteUtil::SystemToBE(v)); } + inline void WriteUInt64BE(uint64_t v) { PWrite64((uint64_t)Alg::ByteUtil::SystemToBE(v)); } + inline void WriteSInt64BE(uint64_t v) { PWrite64((uint64_t)Alg::ByteUtil::SystemToBE(v)); } + inline void WriteFloatBE(float v) { v = Alg::ByteUtil::SystemToBE(v); Write((uint8_t*)&v, 4); } + inline void WriteDoubleBE(double v) { v = Alg::ByteUtil::SystemToBE(v); Write((uint8_t*)&v, 8); } + + // Reading primitive types - Little Endian + inline uint8_t ReadUByte() { return (uint8_t)Alg::ByteUtil::LEToSystem(PRead8()); } + inline int8_t ReadSByte() { return (int8_t)Alg::ByteUtil::LEToSystem(PRead8()); } + inline uint8_t ReadUInt8() { return (uint8_t)Alg::ByteUtil::LEToSystem(PRead8()); } + inline int8_t ReadSInt8() { return (int8_t)Alg::ByteUtil::LEToSystem(PRead8()); } + inline uint16_t ReadUInt16() { return (uint16_t)Alg::ByteUtil::LEToSystem(PRead16()); } + inline int16_t ReadSInt16() { return (int16_t)Alg::ByteUtil::LEToSystem(PRead16()); } + inline uint32_t ReadUInt32() { return (uint32_t)Alg::ByteUtil::LEToSystem(PRead32()); } + inline int32_t ReadSInt32() { return (int32_t)Alg::ByteUtil::LEToSystem(PRead32()); } + inline uint64_t ReadUInt64() { return (uint64_t)Alg::ByteUtil::LEToSystem(PRead64()); } + inline int64_t ReadSInt64() { return (int64_t)Alg::ByteUtil::LEToSystem(PRead64()); } + inline float ReadFloat() { float v = 0.0f; Read((uint8_t*)&v, 4); return Alg::ByteUtil::LEToSystem(v); } + inline double ReadDouble() { double v = 0.0; Read((uint8_t*)&v, 8); return Alg::ByteUtil::LEToSystem(v); } + // Reading primitive types - Big Endian + inline uint8_t ReadUByteBE() { return (uint8_t)Alg::ByteUtil::BEToSystem(PRead8()); } + inline int8_t ReadSByteBE() { return (int8_t)Alg::ByteUtil::BEToSystem(PRead8()); } + inline uint8_t ReadUInt8BE() { return (uint8_t)Alg::ByteUtil::BEToSystem(PRead8()); } + inline int8_t ReadSInt8BE() { return (int8_t)Alg::ByteUtil::BEToSystem(PRead8()); } + inline uint16_t ReadUInt16BE() { return (uint16_t)Alg::ByteUtil::BEToSystem(PRead16()); } + inline int16_t ReadSInt16BE() { return (int16_t)Alg::ByteUtil::BEToSystem(PRead16()); } + inline uint32_t ReadUInt32BE() { return (uint32_t)Alg::ByteUtil::BEToSystem(PRead32()); } + inline int32_t ReadSInt32BE() { return (int32_t)Alg::ByteUtil::BEToSystem(PRead32()); } + inline uint64_t ReadUInt64BE() { return (uint64_t)Alg::ByteUtil::BEToSystem(PRead64()); } + inline int64_t ReadSInt64BE() { return (int64_t)Alg::ByteUtil::BEToSystem(PRead64()); } + inline float ReadFloatBE() { float v = 0.0f; Read((uint8_t*)&v, 4); return Alg::ByteUtil::BEToSystem(v); } + inline double ReadDoubleBE() { double v = 0.0; Read((uint8_t*)&v, 8); return Alg::ByteUtil::BEToSystem(v); } +}; + + +// *** Delegated File + +class DelegatedFile : public File +{ +protected: + // Delegating file pointer + Ptr pFile; + + // Hidden default constructor + DelegatedFile() : pFile(0) { } + DelegatedFile(const DelegatedFile &source) : File() { OVR_UNUSED(source); } +public: + // Constructors + DelegatedFile(File *pfile) : pFile(pfile) { } + + // ** Location Information + virtual const char* GetFilePath() { return pFile->GetFilePath(); } + + // ** File Information + virtual bool IsValid() { return pFile && pFile->IsValid(); } + virtual bool IsWritable() { return pFile->IsWritable(); } +// virtual bool IsRecoverable() { return pFile->IsRecoverable(); } + + virtual int Tell() { return pFile->Tell(); } + virtual int64_t LTell() { return pFile->LTell(); } + + virtual int GetLength() { return pFile->GetLength(); } + virtual int64_t LGetLength() { return pFile->LGetLength(); } + + //virtual bool Stat(FileStats *pfs) { return pFile->Stat(pfs); } + + virtual int GetErrorCode() { return pFile->GetErrorCode(); } + + // ** Stream implementation & I/O + virtual int Write(const uint8_t *pbuffer, int numBytes) { return pFile->Write(pbuffer,numBytes); } + virtual int Read(uint8_t *pbuffer, int numBytes) { return pFile->Read(pbuffer,numBytes); } + + virtual int SkipBytes(int numBytes) { return pFile->SkipBytes(numBytes); } + + virtual int BytesAvailable() { return pFile->BytesAvailable(); } + + virtual bool Flush() { return pFile->Flush(); } + + // Seeking + virtual int Seek(int offset, int origin=Seek_Set) { return pFile->Seek(offset,origin); } + virtual int64_t LSeek(int64_t offset, int origin=Seek_Set) { return pFile->LSeek(offset,origin); } + + virtual int CopyFromStream(File *pstream, int byteSize) { return pFile->CopyFromStream(pstream,byteSize); } + + // Closing the file + virtual bool Close() { return pFile->Close(); } +}; + + +//----------------------------------------------------------------------------------- +// ***** Buffered File + +// This file class adds buffering to an existing file +// Buffered file never fails by itself; if there's not +// enough memory for buffer, no buffer's used + +class BufferedFile : public DelegatedFile +{ +protected: + enum BufferModeType + { + NoBuffer, + ReadBuffer, + WriteBuffer + }; + + // Buffer & the mode it's in + uint8_t* pBuffer; + BufferModeType BufferMode; + // Position in buffer + unsigned Pos; + // Data in buffer if reading + unsigned DataSize; + // Underlying file position + uint64_t FilePos; + + // Initializes buffering to a certain mode + bool SetBufferMode(BufferModeType mode); + // Flushes buffer + // WriteBuffer - write data to disk, ReadBuffer - reset buffer & fix file position + void FlushBuffer(); + // Loads data into ReadBuffer + // WARNING: Right now LoadBuffer() assumes the buffer's empty + void LoadBuffer(); + + // Hidden constructor + BufferedFile(); + BufferedFile(const BufferedFile &) : DelegatedFile(), pBuffer(NULL), BufferMode(NoBuffer), Pos(0), DataSize(0), FilePos(0) { } + +public: + + // Constructor + // - takes another file as source + BufferedFile(File *pfile); + ~BufferedFile(); + + + // ** Overridden functions + + // We override all the functions that can possibly + // require buffer mode switch, flush, or extra calculations + virtual int Tell(); + virtual int64_t LTell(); + + virtual int GetLength(); + virtual int64_t LGetLength(); + +// virtual bool Stat(GFileStats *pfs); + + virtual int Write(const uint8_t *pbufer, int numBytes); + virtual int Read(uint8_t *pbufer, int numBytes); + + virtual int SkipBytes(int numBytes); + + virtual int BytesAvailable(); + + virtual bool Flush(); + + virtual int Seek(int offset, int origin=Seek_Set); + virtual int64_t LSeek(int64_t offset, int origin=Seek_Set); + + virtual int CopyFromStream(File *pstream, int byteSize); + + virtual bool Close(); +}; + + +//----------------------------------------------------------------------------------- +// ***** Memory File + +class MemoryFile : public File +{ +public: + + const char* GetFilePath() { return FilePath.ToCStr(); } + + bool IsValid() { return Valid; } + bool IsWritable() { return false; } + + bool Flush() { return true; } + int GetErrorCode() { return 0; } + + int Tell() { return FileIndex; } + int64_t LTell() { return (int64_t) FileIndex; } + + int GetLength() { return FileSize; } + int64_t LGetLength() { return (int64_t) FileSize; } + + bool Close() + { + Valid = false; + return false; + } + + int CopyFromStream(File *pstream, int byteSize) + { OVR_UNUSED2(pstream, byteSize); + return 0; + } + + int Write(const uint8_t *pbuffer, int numBytes) + { OVR_UNUSED2(pbuffer, numBytes); + return 0; + } + + int Read(uint8_t *pbufer, int numBytes) + { + if (FileIndex + numBytes > FileSize) + { + numBytes = FileSize - FileIndex; + } + + if (numBytes > 0) + { + ::memcpy (pbufer, &FileData [FileIndex], numBytes); + + FileIndex += numBytes; + } + + return numBytes; + } + + int SkipBytes(int numBytes) + { + if (FileIndex + numBytes > FileSize) + { + numBytes = FileSize - FileIndex; + } + + FileIndex += numBytes; + + return numBytes; + } + + int BytesAvailable() + { + return (FileSize - FileIndex); + } + + int Seek(int offset, int origin = Seek_Set) + { + switch (origin) + { + case Seek_Set : FileIndex = offset; break; + case Seek_Cur : FileIndex += offset; break; + case Seek_End : FileIndex = FileSize - offset; break; + } + + return FileIndex; + } + + int64_t LSeek(int64_t offset, int origin = Seek_Set) + { + return (int64_t) Seek((int) offset, origin); + } + +public: + + MemoryFile (const String& fileName, const uint8_t *pBuffer, int buffSize) + : FilePath(fileName) + { + FileData = pBuffer; + FileSize = buffSize; + FileIndex = 0; + Valid = (!fileName.IsEmpty() && pBuffer && buffSize > 0) ? true : false; + } + + // pfileName should be encoded as UTF-8 to support international file names. + MemoryFile (const char* pfileName, const uint8_t *pBuffer, int buffSize) + : FilePath(pfileName) + { + FileData = pBuffer; + FileSize = buffSize; + FileIndex = 0; + Valid = (pfileName && pBuffer && buffSize > 0) ? true : false; + } +private: + + String FilePath; + const uint8_t *FileData; + int FileSize; + int FileIndex; + bool Valid; +}; + + +// ***** Global path helpers + +// Find trailing short filename in a path. +const char* OVR_CDECL GetShortFilename(const char* purl); + +} // OVR + +#endif diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Kernel/OVR_FileFILE.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Kernel/OVR_FileFILE.cpp Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,609 @@ +/************************************************************************** + +Filename : OVR_FileFILE.cpp +Content : File wrapper class implementation (Win32) + +Created : April 5, 1999 +Authors : Michael Antonov + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +**************************************************************************/ + +#define GFILE_CXX + +#include "OVR_Types.h" +#include "OVR_Log.h" + +// Standard C library (Captain Obvious guarantees!) +#include +#ifndef OVR_OS_WINCE +#include +#endif + +#include "OVR_SysFile.h" + +#ifndef OVR_OS_WINCE +#include +#endif + +namespace OVR { + +// ***** File interface + +// ***** FILEFile - C streams file + +static int SFerror () +{ + if (errno == ENOENT) + return FileConstants::Error_FileNotFound; + else if (errno == EACCES || errno == EPERM) + return FileConstants::Error_Access; + else if (errno == ENOSPC) + return FileConstants::Error_DiskFull; + else + return FileConstants::Error_IOError; +}; + +#if defined(OVR_OS_WIN32) +#define WIN32_LEAN_AND_MEAN +#include "windows.h" +// A simple helper class to disable/enable system error mode, if necessary +// Disabling happens conditionally only if a drive name is involved +class SysErrorModeDisabler +{ + BOOL Disabled; + UINT OldMode; +public: + SysErrorModeDisabler(const char* pfileName) + { + if (pfileName && (pfileName[0]!=0) && pfileName[1]==':') + { + Disabled = TRUE; + OldMode = ::SetErrorMode(SEM_FAILCRITICALERRORS); + } + else + { + Disabled = 0; + OldMode = 0; + } + } + + ~SysErrorModeDisabler() + { + if (Disabled) + ::SetErrorMode(OldMode); + } +}; +#else +class SysErrorModeDisabler +{ +public: + SysErrorModeDisabler(const char* pfileName) { OVR_UNUSED(pfileName); } +}; +#endif // OVR_OS_WIN32 + + +// This macro enables verification of I/O results after seeks against a pre-loaded +// full file buffer copy. This is generally not necessary, but can been used to debug +// memory corruptions; we've seen this fail due to EAX2/DirectSound corrupting memory +// under FMOD with XP64 (32-bit) and Realtek HA Audio driver. +//#define GFILE_VERIFY_SEEK_ERRORS + + +// This is the simplest possible file implementation, it wraps around the descriptor +// This file is delegated to by SysFile. + +class FILEFile : public File +{ +protected: + + // Allocated filename + String FileName; + + // File handle & open mode + bool Opened; + FILE* fs; + int OpenFlags; + // Error code for last request + int ErrorCode; + + int LastOp; + +#ifdef OVR_FILE_VERIFY_SEEK_ERRORS + uint8_t* pFileTestBuffer; + unsigned FileTestLength; + unsigned TestPos; // File pointer position during tests. +#endif + +public: + + FILEFile() : + FileName(), + Opened(false), + fs(NULL), + OpenFlags(0), + ErrorCode(0), + LastOp(0) + #ifdef OVR_FILE_VERIFY_SEEK_ERRORS + ,pFileTestBuffer(NULL) + ,FileTestLength(0) + ,TestPos(0) + #endif + { + } + + // Initialize file by opening it + FILEFile(const String& fileName, int flags, int Mode); + + // The 'pfileName' should be encoded as UTF-8 to support international file names. + FILEFile(const char* pfileName, int flags, int Mode); + + ~FILEFile() + { + if (Opened) + Close(); + } + + virtual const char* GetFilePath(); + + // ** File Information + virtual bool IsValid(); + virtual bool IsWritable(); + + // Return position / file size + virtual int Tell(); + virtual int64_t LTell(); + virtual int GetLength(); + virtual int64_t LGetLength(); + +// virtual bool Stat(FileStats *pfs); + virtual int GetErrorCode(); + + // ** Stream implementation & I/O + virtual int Write(const uint8_t *pbuffer, int numBytes); + virtual int Read(uint8_t *pbuffer, int numBytes); + virtual int SkipBytes(int numBytes); + virtual int BytesAvailable(); + virtual bool Flush(); + virtual int Seek(int offset, int origin); + virtual int64_t LSeek(int64_t offset, int origin); + + virtual int CopyFromStream(File *pStream, int byteSize); + virtual bool Close(); +private: + void init(); +}; + + +// Initialize file by opening it +FILEFile::FILEFile(const String& fileName, int flags, int mode) + : FileName(fileName), OpenFlags(flags) +{ + OVR_UNUSED(mode); + init(); +} + +// The 'pfileName' should be encoded as UTF-8 to support international file names. +FILEFile::FILEFile(const char* pfileName, int flags, int mode) + : FileName(pfileName), OpenFlags(flags) +{ + OVR_UNUSED(mode); + init(); +} + +void FILEFile::init() +{ + // Open mode for file's open + const char *omode = "rb"; + + if (OpenFlags & Open_Truncate) + { + if (OpenFlags & Open_Read) + omode = "w+b"; + else + omode = "wb"; + } + else if (OpenFlags & Open_Create) + { + if (OpenFlags & Open_Read) + omode = "a+b"; + else + omode = "ab"; + } + else if (OpenFlags & Open_Write) + omode = "r+b"; + +#if defined(OVR_OS_MS) + SysErrorModeDisabler disabler(FileName.ToCStr()); +#endif + +#if defined(OVR_CC_MSVC) && (OVR_CC_MSVC >= 1400) + wchar_t womode[16]; + wchar_t *pwFileName = (wchar_t*)OVR_ALLOC((UTF8Util::GetLength(FileName.ToCStr())+1) * sizeof(wchar_t)); + UTF8Util::DecodeString(pwFileName, FileName.ToCStr()); + OVR_ASSERT(strlen(omode) < sizeof(womode)/sizeof(womode[0])); + UTF8Util::DecodeString(womode, omode); + _wfopen_s(&fs, pwFileName, womode); + OVR_FREE(pwFileName); +#else + fs = fopen(FileName.ToCStr(), omode); +#endif + if (fs) + rewind (fs); + Opened = (fs != NULL); + // Set error code + if (!Opened) + ErrorCode = SFerror(); + else + { + // If we are testing file seek correctness, pre-load the entire file so + // that we can do comparison tests later. +#ifdef OVR_FILE_VERIFY_SEEK_ERRORS + TestPos = 0; + fseek(fs, 0, SEEK_END); + FileTestLength = ftell(fs); + fseek(fs, 0, SEEK_SET); + pFileTestBuffer = (uint8_t*)OVR_ALLOC(FileTestLength); + if (pFileTestBuffer) + { + OVR_ASSERT(FileTestLength == (unsigned)Read(pFileTestBuffer, FileTestLength)); + Seek(0, Seek_Set); + } +#endif + + ErrorCode = 0; + } + LastOp = 0; +} + + +const char* FILEFile::GetFilePath() +{ + return FileName.ToCStr(); +} + + +// ** File Information +bool FILEFile::IsValid() +{ + return Opened; +} +bool FILEFile::IsWritable() +{ + return IsValid() && (OpenFlags&Open_Write); +} +/* +bool FILEFile::IsRecoverable() +{ + return IsValid() && ((OpenFlags&OVR_FO_SAFETRUNC) == OVR_FO_SAFETRUNC); +} +*/ + +// Return position / file size +int FILEFile::Tell() +{ + int pos = (int)ftell (fs); + if (pos < 0) + ErrorCode = SFerror(); + return pos; +} + +int64_t FILEFile::LTell() +{ + int64_t pos = ftell(fs); + if (pos < 0) + ErrorCode = SFerror(); + return pos; +} + +int FILEFile::GetLength() +{ + int pos = Tell(); + if (pos >= 0) + { + Seek (0, Seek_End); + int size = Tell(); + Seek (pos, Seek_Set); + return size; + } + return -1; +} +int64_t FILEFile::LGetLength() +{ + int64_t pos = LTell(); + if (pos >= 0) + { + LSeek (0, Seek_End); + int64_t size = LTell(); + LSeek (pos, Seek_Set); + return size; + } + return -1; +} + +int FILEFile::GetErrorCode() +{ + return ErrorCode; +} + +// ** Stream implementation & I/O +int FILEFile::Write(const uint8_t *pbuffer, int numBytes) +{ + if (LastOp && LastOp != Open_Write) + fflush(fs); + LastOp = Open_Write; + int written = (int) fwrite(pbuffer, 1, numBytes, fs); + if (written < numBytes) + ErrorCode = SFerror(); + +#ifdef OVR_FILE_VERIFY_SEEK_ERRORS + if (written > 0) + TestPos += written; +#endif + + return written; +} + +int FILEFile::Read(uint8_t *pbuffer, int numBytes) +{ + if (LastOp && LastOp != Open_Read) + fflush(fs); + LastOp = Open_Read; + int read = (int) fread(pbuffer, 1, numBytes, fs); + if (read < numBytes) + ErrorCode = SFerror(); + +#ifdef OVR_FILE_VERIFY_SEEK_ERRORS + if (read > 0) + { + // Read-in data must match our pre-loaded buffer data! + uint8_t* pcompareBuffer = pFileTestBuffer + TestPos; + for (int i=0; i< read; i++) + { + OVR_ASSERT(pcompareBuffer[i] == pbuffer[i]); + } + + //OVR_ASSERT(!memcmp(pFileTestBuffer + TestPos, pbuffer, read)); + TestPos += read; + OVR_ASSERT(ftell(fs) == (int)TestPos); + } +#endif + + return read; +} + +// Seeks ahead to skip bytes +int FILEFile::SkipBytes(int numBytes) +{ + int64_t pos = LTell(); + int64_t newPos = LSeek(numBytes, Seek_Cur); + + // Return -1 for major error + if ((pos==-1) || (newPos==-1)) + { + return -1; + } + //ErrorCode = ((NewPos-Pos) int(sizeof(buff))) ? int(sizeof(buff)) : byteSize; + + szRead = pstream->Read(buff, szRequest); + szWritten = 0; + if (szRead > 0) + szWritten = Write(buff, szRead); + + count += szWritten; + byteSize -= szWritten; + if (szWritten < szRequest) + break; + } + + delete[] buff; + + return count; +} + + +bool FILEFile::Close() +{ +#ifdef OVR_FILE_VERIFY_SEEK_ERRORS + if (pFileTestBuffer) + { + OVR_FREE(pFileTestBuffer); + pFileTestBuffer = 0; + FileTestLength = 0; + } +#endif + + bool closeRet = !fclose(fs); + + if (!closeRet) + { + ErrorCode = SFerror(); + return 0; + } + else + { + Opened = 0; + fs = 0; + ErrorCode = 0; + } + + // Handle safe truncate + /* + if ((OpenFlags & OVR_FO_SAFETRUNC) == OVR_FO_SAFETRUNC) + { + // Delete original file (if it existed) + DWORD oldAttributes = FileUtilWin32::GetFileAttributes(FileName); + if (oldAttributes!=0xFFFFFFFF) + if (!FileUtilWin32::DeleteFile(FileName)) + { + // Try to remove the readonly attribute + FileUtilWin32::SetFileAttributes(FileName, oldAttributes & (~FILE_ATTRIBUTE_READONLY) ); + // And delete the file again + if (!FileUtilWin32::DeleteFile(FileName)) + return 0; + } + + // Rename temp file to real filename + if (!FileUtilWin32::MoveFile(TempName, FileName)) + { + //ErrorCode = errno; + return 0; + } + } + */ + return 1; +} + +/* +bool FILEFile::CloseCancel() +{ + bool closeRet = (bool)::CloseHandle(fd); + + if (!closeRet) + { + //ErrorCode = errno; + return 0; + } + else + { + Opened = 0; + fd = INVALID_HANDLE_VALUE; + ErrorCode = 0; + } + + // Handle safe truncate (delete tmp file, leave original unchanged) + if ((OpenFlags&OVR_FO_SAFETRUNC) == OVR_FO_SAFETRUNC) + if (!FileUtilWin32::DeleteFile(TempName)) + { + //ErrorCode = errno; + return 0; + } + return 1; +} +*/ + +Ptr FileFILEOpen(const String& path, int flags, int mode) +{ + Ptr result = *new FILEFile(path, flags, mode); + return result; +} + +// Helper function: obtain file information time. +bool SysFile::GetFileStat(FileStat* pfileStat, const String& path) +{ +#if defined(OVR_OS_MS) + // 64-bit implementation on Windows. + struct __stat64 fileStat; + // Stat returns 0 for success. + wchar_t *pwpath = (wchar_t*)OVR_ALLOC((UTF8Util::GetLength(path.ToCStr())+1)*sizeof(wchar_t)); + UTF8Util::DecodeString(pwpath, path.ToCStr()); + + int ret = _wstat64(pwpath, &fileStat); + OVR_FREE(pwpath); + if (ret) return false; +#else + struct stat fileStat; + // Stat returns 0 for success. + if (stat(path, &fileStat) != 0) + return false; +#endif + pfileStat->AccessTime = fileStat.st_atime; + pfileStat->ModifyTime = fileStat.st_mtime; + pfileStat->FileSize = fileStat.st_size; + return true; +} + +} // Namespace OVR diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Kernel/OVR_Hash.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Kernel/OVR_Hash.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,1305 @@ +/************************************************************************************ + +PublicHeader: None +Filename : OVR_Hash.h +Content : Template hash-table/set implementation +Created : September 19, 2012 +Notes : + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#ifndef OVR_Hash_h +#define OVR_Hash_h + +#include "OVR_ContainerAllocator.h" +#include "OVR_Alg.h" + +// 'new' operator is redefined/used in this file. +#undef new + +namespace OVR { + +//----------------------------------------------------------------------------------- +// ***** Hash Table Implementation + +// HastSet and Hash. +// +// Hash table, linear probing, internal chaining. One interesting/nice thing +// about this implementation is that the table itself is a flat chunk of memory +// containing no pointers, only relative indices. If the key and value types +// of the Hash contain no pointers, then the Hash can be serialized using raw IO. +// +// Never shrinks, unless you explicitly Clear() it. Expands on +// demand, though. For best results, if you know roughly how big your +// table will be, default it to that size when you create it. +// +// Key usability feature: +// +// 1. Allows node hash values to either be cached or not. +// +// 2. Allows for alternative keys with methods such as GetAlt(). Handy +// if you need to search nodes by their components; no need to create +// temporary nodes. +// + + +// *** Hash functors: +// +// IdentityHash - use when the key is already a good hash +// HFixedSizeHash - general hash based on object's in-memory representation. + + +// Hash is just the input value; can use this for integer-indexed hash tables. +template +class IdentityHash +{ +public: + size_t operator()(const C& data) const + { return (size_t) data; } +}; + +// Computes a hash of an object's representation. +template +class FixedSizeHash +{ +public: + // Alternative: "sdbm" hash function, suggested at same web page + // above, http::/www.cs.yorku.ca/~oz/hash.html + // This is somewhat slower then Bernstein, but it works way better than the above + // hash function for hashing large numbers of 32-bit ints. + static OVR_FORCE_INLINE size_t SDBM_Hash(const void* data_in, size_t size, size_t seed = 5381) + { + const uint8_t* data = (const uint8_t*) data_in; + size_t h = seed; + while (size-- > 0) + { + #ifndef __clang_analyzer__ // It mistakenly thinks data is garbage. + h = (h << 16) + (h << 6) - h + (size_t)data[size]; + #endif + } + return h; + } + + size_t operator()(const C& data) const + { + const unsigned char* p = (const unsigned char*) &data; + const size_t size = sizeof(C); + + return SDBM_Hash(p, size); + } +}; + + + +// *** HashsetEntry Entry types. + +// Compact hash table Entry type that re-computes hash keys during hash traversal. +// Good to use if the hash function is cheap or the hash value is already cached in C. +template +class HashsetEntry +{ +public: + // Internal chaining for collisions. + intptr_t NextInChain; + C Value; + + HashsetEntry() + : NextInChain(-2) { } + HashsetEntry(const HashsetEntry& e) + : NextInChain(e.NextInChain), Value(e.Value) { } + HashsetEntry(const C& key, intptr_t next) + : NextInChain(next), Value(key) { } + + bool IsEmpty() const { return NextInChain == -2; } + bool IsEndOfChain() const { return NextInChain == -1; } + + // Cached hash value access - can be optimized bu storing hash locally. + // Mask value only needs to be used if SetCachedHash is not implemented. + size_t GetCachedHash(size_t maskValue) const { return HashF()(Value) & maskValue; } + void SetCachedHash(size_t) {} + + void Clear() + { + Value.~C(); // placement delete + NextInChain = -2; + } + // Free is only used from dtor of hash; Clear is used during regular operations: + // assignment, hash reallocations, value reassignments, so on. + void Free() { Clear(); } +}; + +// Hash table Entry type that caches the Entry hash value for nodes, so that it +// does not need to be re-computed during access. +template +class HashsetCachedEntry +{ +public: + // Internal chaining for collisions. + intptr_t NextInChain; + size_t HashValue; + C Value; + + HashsetCachedEntry() + : NextInChain(-2) { } + HashsetCachedEntry(const HashsetCachedEntry& e) + : NextInChain(e.NextInChain), HashValue(e.HashValue), Value(e.Value) { } + HashsetCachedEntry(const C& key, intptr_t next) + : NextInChain(next), Value(key) { } + + bool IsEmpty() const { return NextInChain == -2; } + bool IsEndOfChain() const { return NextInChain == -1; } + + // Cached hash value access - can be optimized bu storing hash locally. + // Mask value only needs to be used if SetCachedHash is not implemented. + size_t GetCachedHash(size_t maskValue) const { OVR_UNUSED(maskValue); return HashValue; } + void SetCachedHash(size_t hashValue) { HashValue = hashValue; } + + void Clear() + { + Value.~C(); + NextInChain = -2; + } + // Free is only used from dtor of hash; Clear is used during regular operations: + // assignment, hash reallocations, value reassignments, so on. + void Free() { Clear(); } +}; + + +//----------------------------------------------------------------------------------- +// *** HashSet implementation - relies on either cached or regular entries. +// +// Use: Entry = HashsetCachedEntry if hashes are expensive to +// compute and thus need caching in entries. +// Entry = HashsetEntry if hashes are already externally cached. +// +template, + class AltHashF = HashF, + class Allocator = ContainerAllocator, + class Entry = HashsetCachedEntry > +class HashSetBase +{ + enum { HashMinSize = 8 }; + +public: + OVR_MEMORY_REDEFINE_NEW(HashSetBase) + + typedef HashSetBase SelfType; + + HashSetBase() : pTable(NULL) { } + HashSetBase(int sizeHint) : pTable(NULL) { SetCapacity(this, sizeHint); } + HashSetBase(const SelfType& src) : pTable(NULL) { Assign(this, src); } + + ~HashSetBase() + { + if (pTable) + { + // Delete the entries. + for (size_t i = 0, n = pTable->SizeMask; i <= n; i++) + { + Entry* e = &E(i); + if (!e->IsEmpty()) + e->Free(); + } + + Allocator::Free(pTable); + pTable = NULL; + } + } + + + void Assign(const SelfType& src) + { + Clear(); + if (src.IsEmpty() == false) + { + SetCapacity(src.GetSize()); + + for (ConstIterator it = src.Begin(); it != src.End(); ++it) + { + Add(*it); + } + } + } + + + // Remove all entries from the HashSet table. + void Clear() + { + if (pTable) + { + // Delete the entries. + for (size_t i = 0, n = pTable->SizeMask; i <= n; i++) + { + Entry* e = &E(i); + if (!e->IsEmpty()) + e->Clear(); + } + + Allocator::Free(pTable); + pTable = NULL; + } + } + + // Returns true if the HashSet is empty. + bool IsEmpty() const + { + return pTable == NULL || pTable->EntryCount == 0; + } + + + // Set a new or existing value under the key, to the value. + // Pass a different class of 'key' so that assignment reference object + // can be passed instead of the actual object. + template + void Set(const CRef& key) + { + size_t hashValue = HashF()(key); + intptr_t index = (intptr_t)-1; + + if (pTable != NULL) + index = findIndexCore(key, hashValue & pTable->SizeMask); + + if (index >= 0) + { + E(index).Value = key; + } + else + { + // Entry under key doesn't exist. + add(key, hashValue); + } + } + + template + inline void Add(const CRef& key) + { + size_t hashValue = HashF()(key); + add(key, hashValue); + } + + // Remove by alternative key. + template + void RemoveAlt(const K& key) + { + if (pTable == NULL) + return; + + size_t hashValue = AltHashF()(key); + intptr_t index = hashValue & pTable->SizeMask; + + Entry* e = &E(index); + + // If empty node or occupied by collider, we have nothing to remove. + if (e->IsEmpty() || (e->GetCachedHash(pTable->SizeMask) != (size_t)index)) + return; + + // Save index + intptr_t naturalIndex = index; + intptr_t prevIndex = -1; + + while ((e->GetCachedHash(pTable->SizeMask) != (size_t)naturalIndex) || !(e->Value == key)) + { + // Keep looking through the chain. + prevIndex = index; + index = e->NextInChain; + if (index == -1) + return; // End of chain, item not found + e = &E(index); + } + + // Found it - our item is at index + if (naturalIndex == index) + { + // If we have a follower, move it to us + if (!e->IsEndOfChain()) + { + Entry* enext = &E(e->NextInChain); + e->Clear(); + new (e) Entry(*enext); + // Point us to the follower's cell that will be cleared + e = enext; + } + } + else + { + // We are not at natural index, so deal with the prev items next index + E(prevIndex).NextInChain = e->NextInChain; + } + + // Clear us, of the follower cell that was moved. + e->Clear(); + pTable->EntryCount --; + // Should we check the size to condense hash? ... + } + + // Remove by main key. + template + void Remove(const CRef& key) + { + RemoveAlt(key); + } + + // Retrieve the pointer to a value under the given key. + // - If there's no value under the key, then return NULL. + // - If there is a value, return the pointer. + template + C* Get(const K& key) + { + intptr_t index = findIndex(key); + if (index >= 0) + return &E(index).Value; + return 0; + } + + template + const C* Get(const K& key) const + { + intptr_t index = findIndex(key); + if (index >= 0) + return &E(index).Value; + return 0; + } + + // Alternative key versions of Get. Used by Hash. + template + const C* GetAlt(const K& key) const + { + intptr_t index = findIndexAlt(key); + if (index >= 0) + return &E(index).Value; + return 0; + } + + template + C* GetAlt(const K& key) + { + intptr_t index = findIndexAlt(key); + if (index >= 0) + return &E(index).Value; + return 0; + } + + template + bool GetAlt(const K& key, C* pval) const + { + intptr_t index = findIndexAlt(key); + if (index >= 0) + { + if (pval) + *pval = E(index).Value; + return true; + } + return false; + } + + + size_t GetSize() const + { + return pTable == NULL ? 0 : (size_t)pTable->EntryCount; + } + int GetSizeI() const { return (int)GetSize(); } + + + // Resize the HashSet table to fit one more Entry. Often this + // doesn't involve any action. + void CheckExpand() + { + if (pTable == NULL) + { + // Initial creation of table. Make a minimum-sized table. + setRawCapacity(HashMinSize); + } + else if (pTable->EntryCount * 5 > (pTable->SizeMask + 1) * 4) + { + // pTable is more than 5/4 ths full. Expand. + setRawCapacity((pTable->SizeMask + 1) * 2); + } + } + + // Hint the bucket count to >= n. + void Resize(size_t n) + { + // Not really sure what this means in relation to + // STLport's hash_map... they say they "increase the + // bucket count to at least n" -- but does that mean + // their real capacity after Resize(n) is more like + // n*2 (since they do linked-list chaining within + // buckets?). + SetCapacity(n); + } + + // Size the HashSet so that it can comfortably contain the given + // number of elements. If the HashSet already contains more + // elements than newSize, then this may be a no-op. + void SetCapacity(size_t newSize) + { + size_t newRawSize = (newSize * 5) / 4; + if (newRawSize <= GetSize()) + return; + setRawCapacity(newRawSize); + } + + // Disable inappropriate 'operator ->' warning on MSVC6. +#ifdef OVR_CC_MSVC +#if (OVR_CC_MSVC < 1300) +# pragma warning(disable : 4284) +#endif +#endif + + // Iterator API, like STL. + struct ConstIterator + { + const C& operator * () const + { + OVR_ASSERT(Index >= 0 && Index <= (intptr_t)pHash->pTable->SizeMask); + return pHash->E(Index).Value; + } + + const C* operator -> () const + { + OVR_ASSERT(Index >= 0 && Index <= (intptr_t)pHash->pTable->SizeMask); + return &pHash->E(Index).Value; + } + + void operator ++ () + { + // Find next non-empty Entry. + if (Index <= (intptr_t)pHash->pTable->SizeMask) + { + Index++; + while ((size_t)Index <= pHash->pTable->SizeMask && + pHash->E(Index).IsEmpty()) + { + Index++; + } + } + } + + bool operator == (const ConstIterator& it) const + { + if (IsEnd() && it.IsEnd()) + { + return true; + } + else + { + return (pHash == it.pHash) && (Index == it.Index); + } + } + + bool operator != (const ConstIterator& it) const + { + return ! (*this == it); + } + + + bool IsEnd() const + { + return (pHash == NULL) || + (pHash->pTable == NULL) || + (Index > (intptr_t)pHash->pTable->SizeMask); + } + + ConstIterator() + : pHash(NULL), Index(0) + { } + + public: + // Constructor was intentionally made public to allow create + // iterator with arbitrary index. + ConstIterator(const SelfType* h, intptr_t index) + : pHash(h), Index(index) + { } + + const SelfType* GetContainer() const + { + return pHash; + } + intptr_t GetIndex() const + { + return Index; + } + + protected: + friend class HashSetBase; + + const SelfType* pHash; + intptr_t Index; + }; + + friend struct ConstIterator; + + + // Non-const Iterator; Get most of it from ConstIterator. + struct Iterator : public ConstIterator + { + // Allow non-const access to entries. + C& operator*() const + { + OVR_ASSERT((ConstIterator::pHash) && ConstIterator::pHash->pTable && (ConstIterator::Index >= 0) && (ConstIterator::Index <= (intptr_t)ConstIterator::pHash->pTable->SizeMask)); + return const_cast(ConstIterator::pHash)->E(ConstIterator::Index).Value; + } + + C* operator->() const + { + return &(operator*()); + } + + Iterator() + : ConstIterator(NULL, 0) + { } + + // Removes current element from Hash + void Remove() + { + RemoveAlt(operator*()); + } + + template + void RemoveAlt(const K& key) + { + SelfType* phash = const_cast(ConstIterator::pHash); + //Entry* ee = &phash->E(ConstIterator::Index); + //const C& key = ee->Value; + + size_t hashValue = AltHashF()(key); + intptr_t index = hashValue & phash->pTable->SizeMask; + + Entry* e = &phash->E(index); + + // If empty node or occupied by collider, we have nothing to remove. + if (e->IsEmpty() || (e->GetCachedHash(phash->pTable->SizeMask) != (size_t)index)) + return; + + // Save index + intptr_t naturalIndex = index; + intptr_t prevIndex = -1; + + while ((e->GetCachedHash(phash->pTable->SizeMask) != (size_t)naturalIndex) || !(e->Value == key)) + { + // Keep looking through the chain. + prevIndex = index; + index = e->NextInChain; + if (index == -1) + return; // End of chain, item not found + e = &phash->E(index); + } + + if (index == (intptr_t)ConstIterator::Index) + { + // Found it - our item is at index + if (naturalIndex == index) + { + // If we have a follower, move it to us + if (!e->IsEndOfChain()) + { + Entry* enext = &phash->E(e->NextInChain); + e->Clear(); + new (e) Entry(*enext); + // Point us to the follower's cell that will be cleared + e = enext; + --ConstIterator::Index; + } + } + else + { + // We are not at natural index, so deal with the prev items next index + phash->E(prevIndex).NextInChain = e->NextInChain; + } + + // Clear us, of the follower cell that was moved. + e->Clear(); + phash->pTable->EntryCount --; + } + else + OVR_ASSERT(0); //? + } + + private: + friend class HashSetBase; + + Iterator(SelfType* h, intptr_t i0) + : ConstIterator(h, i0) + { } + }; + + friend struct Iterator; + + Iterator Begin() + { + if (pTable == 0) + return Iterator(NULL, 0); + + // Scan till we hit the First valid Entry. + size_t i0 = 0; + while (i0 <= pTable->SizeMask && E(i0).IsEmpty()) + { + i0++; + } + return Iterator(this, i0); + } + Iterator End() { return Iterator(NULL, 0); } + + ConstIterator Begin() const { return const_cast(this)->Begin(); } + ConstIterator End() const { return const_cast(this)->End(); } + + template + Iterator Find(const K& key) + { + intptr_t index = findIndex(key); + if (index >= 0) + return Iterator(this, index); + return Iterator(NULL, 0); + } + + template + Iterator FindAlt(const K& key) + { + intptr_t index = findIndexAlt(key); + if (index >= 0) + return Iterator(this, index); + return Iterator(NULL, 0); + } + + template + ConstIterator Find(const K& key) const { return const_cast(this)->Find(key); } + + template + ConstIterator FindAlt(const K& key) const { return const_cast(this)->FindAlt(key); } + +private: + // Find the index of the matching Entry. If no match, then return -1. + template + intptr_t findIndex(const K& key) const + { + if (pTable == NULL) + return -1; + size_t hashValue = HashF()(key) & pTable->SizeMask; + return findIndexCore(key, hashValue); + } + + template + intptr_t findIndexAlt(const K& key) const + { + if (pTable == NULL) + return -1; + size_t hashValue = AltHashF()(key) & pTable->SizeMask; + return findIndexCore(key, hashValue); + } + + // Find the index of the matching Entry. If no match, then return -1. + template + intptr_t findIndexCore(const K& key, size_t hashValue) const + { + // Table must exist. + OVR_ASSERT(pTable != 0); + // Hash key must be 'and-ed' by the caller. + OVR_ASSERT((hashValue & ~pTable->SizeMask) == 0); + + size_t index = hashValue; + const Entry* e = &E(index); + + // If empty or occupied by a collider, not found. + if (e->IsEmpty() || (e->GetCachedHash(pTable->SizeMask) != index)) + return -1; + + while(1) + { + OVR_ASSERT(e->GetCachedHash(pTable->SizeMask) == hashValue); + + if (e->GetCachedHash(pTable->SizeMask) == hashValue && e->Value == key) + { + // Found it. + return index; + } + // Values can not be equal at this point. + // That would mean that the hash key for the same value differs. + OVR_ASSERT(!(e->Value == key)); + + // Keep looking through the chain. + index = e->NextInChain; + if (index == (size_t)-1) + break; // end of chain + + e = &E(index); + OVR_ASSERT(!e->IsEmpty()); + } + return -1; + } + + + // Add a new value to the HashSet table, under the specified key. + template + void add(const CRef& key, size_t hashValue) + { + CheckExpand(); + hashValue &= pTable->SizeMask; + + pTable->EntryCount++; + + intptr_t index = hashValue; + Entry* naturalEntry = &(E(index)); + + if (naturalEntry->IsEmpty()) + { + // Put the new Entry in. + new (naturalEntry) Entry(key, -1); + } + else + { + // Find a blank spot. + intptr_t blankIndex = index; + do { + blankIndex = (blankIndex + 1) & pTable->SizeMask; + } while(!E(blankIndex).IsEmpty()); + + Entry* blankEntry = &E(blankIndex); + + if (naturalEntry->GetCachedHash(pTable->SizeMask) == (size_t)index) + { + // Collision. Link into this chain. + + // Move existing list head. + new (blankEntry) Entry(*naturalEntry); // placement new, copy ctor + + // Put the new info in the natural Entry. + naturalEntry->Value = key; + naturalEntry->NextInChain = blankIndex; + } + else + { + // Existing Entry does not naturally + // belong in this slot. Existing + // Entry must be moved. + + // Find natural location of collided element (i.e. root of chain) + intptr_t collidedIndex = naturalEntry->GetCachedHash(pTable->SizeMask); + OVR_ASSERT(collidedIndex >= 0 && collidedIndex <= (intptr_t)pTable->SizeMask); + for (;;) + { + Entry* e = &E(collidedIndex); + if (e->NextInChain == index) + { + // Here's where we need to splice. + new (blankEntry) Entry(*naturalEntry); + e->NextInChain = blankIndex; + break; + } + collidedIndex = e->NextInChain; + OVR_ASSERT(collidedIndex >= 0 && collidedIndex <= (intptr_t)pTable->SizeMask); + } + + // Put the new data in the natural Entry. + naturalEntry->Value = key; + naturalEntry->NextInChain = -1; + } + } + + // Record hash value: has effect only if cached node is used. + naturalEntry->SetCachedHash(hashValue); + } + + // Index access helpers. + Entry& E(size_t index) + { + // Must have pTable and access needs to be within bounds. + OVR_ASSERT(index <= pTable->SizeMask); + return *(((Entry*) (pTable + 1)) + index); + } + const Entry& E(size_t index) const + { + OVR_ASSERT(index <= pTable->SizeMask); + return *(((Entry*) (pTable + 1)) + index); + } + + + // Resize the HashSet table to the given size (Rehash the + // contents of the current table). The arg is the number of + // HashSet table entries, not the number of elements we should + // actually contain (which will be less than this). + void setRawCapacity(size_t newSize) + { + if (newSize == 0) + { + // Special case. + Clear(); + return; + } + + // Minimum size; don't incur rehashing cost when expanding + // very small tables. Not that we perform this check before + // 'log2f' call to avoid fp exception with newSize == 1. + if (newSize < HashMinSize) + newSize = HashMinSize; + else + { + // Force newSize to be a power of two. + int bits = Alg::UpperBit(newSize-1) + 1; // Chop( Log2f((float)(newSize-1)) + 1); + OVR_ASSERT((size_t(1) << bits) >= newSize); + newSize = size_t(1) << bits; + } + + SelfType newHash; + newHash.pTable = (TableType*) + Allocator::Alloc( + sizeof(TableType) + sizeof(Entry) * newSize); + // Need to do something on alloc failure! + OVR_ASSERT(newHash.pTable); + + newHash.pTable->EntryCount = 0; + newHash.pTable->SizeMask = newSize - 1; + size_t i, n; + + // Mark all entries as empty. + for (i = 0; i < newSize; i++) + newHash.E(i).NextInChain = -2; + + // Copy stuff to newHash + if (pTable) + { + for (i = 0, n = pTable->SizeMask; i <= n; i++) + { + Entry* e = &E(i); + if (e->IsEmpty() == false) + { + // Insert old Entry into new HashSet. + newHash.Add(e->Value); + // placement delete of old element + e->Clear(); + } + } + + // Delete our old data buffer. + Allocator::Free(pTable); + } + + // Steal newHash's data. + pTable = newHash.pTable; + newHash.pTable = NULL; + } + + struct TableType + { + size_t EntryCount; + size_t SizeMask; + // Entry array follows this structure + // in memory. + }; + TableType* pTable; +}; + + + +//----------------------------------------------------------------------------------- +template, + class AltHashF = HashF, + class Allocator = ContainerAllocator, + class Entry = HashsetCachedEntry > +class HashSet : public HashSetBase +{ +public: + typedef HashSetBase BaseType; + typedef HashSet SelfType; + + HashSet() { } + HashSet(int sizeHint) : BaseType(sizeHint) { } + HashSet(const SelfType& src) : BaseType(src) { } + ~HashSet() { } + + void operator = (const SelfType& src) { BaseType::Assign(src); } + + // Set a new or existing value under the key, to the value. + // Pass a different class of 'key' so that assignment reference object + // can be passed instead of the actual object. + template + void Set(const CRef& key) + { + BaseType::Set(key); + } + + template + inline void Add(const CRef& key) + { + BaseType::Add(key); + } + + // Hint the bucket count to >= n. + void Resize(size_t n) + { + BaseType::SetCapacity(n); + } + + // Size the HashSet so that it can comfortably contain the given + // number of elements. If the HashSet already contains more + // elements than newSize, then this may be a no-op. + void SetCapacity(size_t newSize) + { + BaseType::SetCapacity(newSize); + } + +}; + +// HashSet with uncached hash code; declared for convenience. +template, + class AltHashF = HashF, + class Allocator = ContainerAllocator > +class HashSetUncached : public HashSet > +{ +public: + + typedef HashSetUncached SelfType; + typedef HashSet > BaseType; + + // Delegated constructors. + HashSetUncached() { } + HashSetUncached(int sizeHint) : BaseType(sizeHint) { } + HashSetUncached(const SelfType& src) : BaseType(src) { } + ~HashSetUncached() { } + + void operator = (const SelfType& src) + { + BaseType::operator = (src); + } +}; + + +//----------------------------------------------------------------------------------- +// ***** Hash hash table implementation + +// Node for Hash - necessary so that Hash can delegate its implementation +// to HashSet. +template +struct HashNode +{ + typedef HashNode SelfType; + typedef C FirstType; + typedef U SecondType; + + C First; + U Second; + + // NodeRef is used to allow passing of elements into HashSet + // without using a temporary object. + struct NodeRef + { + const C* pFirst; + const U* pSecond; + + NodeRef(const C& f, const U& s) : pFirst(&f), pSecond(&s) { } + NodeRef(const NodeRef& src) : pFirst(src.pFirst), pSecond(src.pSecond) { } + + // Enable computation of ghash_node_hashf. + inline size_t GetHash() const { return HashF()(*pFirst); } + // Necessary conversion to allow HashNode::operator == to work. + operator const C& () const { return *pFirst; } + }; + + // Note: No default constructor is necessary. + HashNode(const HashNode& src) : First(src.First), Second(src.Second) { } + HashNode(const NodeRef& src) : First(*src.pFirst), Second(*src.pSecond) { } + void operator = (const NodeRef& src) { First = *src.pFirst; Second = *src.pSecond; } + + template + bool operator == (const K& src) const { return (First == src); } + + template + static size_t CalcHash(const K& data) { return HashF()(data); } + inline size_t GetHash() const { return HashF()(First); } + + // Hash functors used with this node. A separate functor is used for alternative + // key lookup so that it does not need to access the '.First' element. + struct NodeHashF + { + template + size_t operator()(const K& data) const { return data.GetHash(); } + }; + struct NodeAltHashF + { + template + size_t operator()(const K& data) const { return HashNode::CalcHash(data); } + }; +}; + + + +// **** Extra hashset_entry types to allow NodeRef construction. + +// The big difference between the below types and the ones used in hash_set is that +// these allow initializing the node with 'typename C::NodeRef& keyRef', which +// is critical to avoid temporary node allocation on stack when using placement new. + +// Compact hash table Entry type that re-computes hash keys during hash traversal. +// Good to use if the hash function is cheap or the hash value is already cached in C. +template +class HashsetNodeEntry +{ +public: + // Internal chaining for collisions. + intptr_t NextInChain; + C Value; + + HashsetNodeEntry() + : NextInChain(-2) { } + HashsetNodeEntry(const HashsetNodeEntry& e) + : NextInChain(e.NextInChain), Value(e.Value) { } + HashsetNodeEntry(const C& key, intptr_t next) + : NextInChain(next), Value(key) { } + HashsetNodeEntry(const typename C::NodeRef& keyRef, intptr_t next) + : NextInChain(next), Value(keyRef) { } + + bool IsEmpty() const { return NextInChain == -2; } + bool IsEndOfChain() const { return NextInChain == -1; } + size_t GetCachedHash(size_t maskValue) const { return HashF()(Value) & maskValue; } + void SetCachedHash(size_t hashValue) { OVR_UNUSED(hashValue); } + + void Clear() + { + Value.~C(); // placement delete + NextInChain = -2; + } + // Free is only used from dtor of hash; Clear is used during regular operations: + // assignment, hash reallocations, value reassignments, so on. + void Free() { Clear(); } +}; + +// Hash table Entry type that caches the Entry hash value for nodes, so that it +// does not need to be re-computed during access. +template +class HashsetCachedNodeEntry +{ +public: + // Internal chaining for collisions. + intptr_t NextInChain; + size_t HashValue; + C Value; + + HashsetCachedNodeEntry() + : NextInChain(-2) { } + HashsetCachedNodeEntry(const HashsetCachedNodeEntry& e) + : NextInChain(e.NextInChain), HashValue(e.HashValue), Value(e.Value) { } + HashsetCachedNodeEntry(const C& key, intptr_t next) + : NextInChain(next), Value(key) { } + HashsetCachedNodeEntry(const typename C::NodeRef& keyRef, intptr_t next) + : NextInChain(next), Value(keyRef) { } + + bool IsEmpty() const { return NextInChain == -2; } + bool IsEndOfChain() const { return NextInChain == -1; } + size_t GetCachedHash(size_t maskValue) const { OVR_UNUSED(maskValue); return HashValue; } + void SetCachedHash(size_t hashValue) { HashValue = hashValue; } + + void Clear() + { + Value.~C(); + NextInChain = -2; + } + // Free is only used from dtor of hash; Clear is used during regular operations: + // assignment, hash reallocations, value reassignments, so on. + void Free() { Clear(); } +}; + + +//----------------------------------------------------------------------------------- +template, + class Allocator = ContainerAllocator, + class HashNode = OVR::HashNode, + class Entry = HashsetCachedNodeEntry, + class Container = HashSet > +class Hash +{ +public: + OVR_MEMORY_REDEFINE_NEW(Hash) + + // Types used for hash_set. + typedef U ValueType; + typedef Hash SelfType; + + // Actual hash table itself, implemented as hash_set. + Container mHash; + +public: + Hash() { } + Hash(int sizeHint) : mHash(sizeHint) { } + Hash(const SelfType& src) : mHash(src.mHash) { } + ~Hash() { } + + void operator = (const SelfType& src) { mHash = src.mHash; } + + // Remove all entries from the Hash table. + inline void Clear() { mHash.Clear(); } + // Returns true if the Hash is empty. + inline bool IsEmpty() const { return mHash.IsEmpty(); } + + // Access (set). + inline void Set(const C& key, const U& value) + { + typename HashNode::NodeRef e(key, value); + mHash.Set(e); + } + inline void Add(const C& key, const U& value) + { + typename HashNode::NodeRef e(key, value); + mHash.Add(e); + } + + // Removes an element by clearing its Entry. + inline void Remove(const C& key) + { + mHash.RemoveAlt(key); + } + template + inline void RemoveAlt(const K& key) + { + mHash.RemoveAlt(key); + } + + // Retrieve the value under the given key. + // - If there's no value under the key, then return false and leave *pvalue alone. + // - If there is a value, return true, and Set *Pvalue to the Entry's value. + // - If value == NULL, return true or false according to the presence of the key. + bool Get(const C& key, U* pvalue) const + { + const HashNode* p = mHash.GetAlt(key); + if (p) + { + if (pvalue) + *pvalue = p->Second; + return true; + } + return false; + } + + template + bool GetAlt(const K& key, U* pvalue) const + { + const HashNode* p = mHash.GetAlt(key); + if (p) + { + if (pvalue) + *pvalue = p->Second; + return true; + } + return false; + } + + // Retrieve the pointer to a value under the given key. + // - If there's no value under the key, then return NULL. + // - If there is a value, return the pointer. + inline U* Get(const C& key) + { + HashNode* p = mHash.GetAlt(key); + return p ? &p->Second : 0; + } + inline const U* Get(const C& key) const + { + const HashNode* p = mHash.GetAlt(key); + return p ? &p->Second : 0; + } + + template + inline U* GetAlt(const K& key) + { + HashNode* p = mHash.GetAlt(key); + return p ? &p->Second : 0; + } + template + inline const U* GetAlt(const K& key) const + { + const HashNode* p = mHash.GetAlt(key); + return p ? &p->Second : 0; + } + + // Sizing methods - delegate to Hash. + inline size_t GetSize() const { return mHash.GetSize(); } + inline int GetSizeI() const { return (int)GetSize(); } + inline void Resize(size_t n) { mHash.Resize(n); } + inline void SetCapacity(size_t newSize) { mHash.SetCapacity(newSize); } + + // Iterator API, like STL. + typedef typename Container::ConstIterator ConstIterator; + typedef typename Container::Iterator Iterator; + + inline Iterator Begin() { return mHash.Begin(); } + inline Iterator End() { return mHash.End(); } + inline ConstIterator Begin() const { return mHash.Begin(); } + inline ConstIterator End() const { return mHash.End(); } + + Iterator Find(const C& key) { return mHash.FindAlt(key); } + ConstIterator Find(const C& key) const { return mHash.FindAlt(key); } + + template + Iterator FindAlt(const K& key) { return mHash.FindAlt(key); } + template + ConstIterator FindAlt(const K& key) const { return mHash.FindAlt(key); } +}; + + + +// Hash with uncached hash code; declared for convenience. +template, class Allocator = ContainerAllocator > +class HashUncached + : public Hash, + HashsetNodeEntry, typename HashNode::NodeHashF> > +{ +public: + typedef HashUncached SelfType; + typedef Hash, + HashsetNodeEntry, + typename HashNode::NodeHashF> > BaseType; + + // Delegated constructors. + HashUncached() { } + HashUncached(int sizeHint) : BaseType(sizeHint) { } + HashUncached(const SelfType& src) : BaseType(src) { } + ~HashUncached() { } + void operator = (const SelfType& src) { BaseType::operator = (src); } +}; + + + +// And identity hash in which keys serve as hash value. Can be uncached, +// since hash computation is assumed cheap. +template, class HashF = IdentityHash > +class HashIdentity + : public HashUncached +{ +public: + typedef HashIdentity SelfType; + typedef HashUncached BaseType; + + // Delegated constructors. + HashIdentity() { } + HashIdentity(int sizeHint) : BaseType(sizeHint) { } + HashIdentity(const SelfType& src) : BaseType(src) { } + ~HashIdentity() { } + void operator = (const SelfType& src) { BaseType::operator = (src); } +}; + + +} // OVR + + +#ifdef OVR_DEFINE_NEW +#define new OVR_DEFINE_NEW +#endif + +#endif diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Kernel/OVR_KeyCodes.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Kernel/OVR_KeyCodes.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,251 @@ +/************************************************************************************ + +PublicHeader: OVR_Kernel.h +Filename : OVR_KeyCodes.h +Content : Common keyboard constants +Created : September 19, 2012 + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#ifndef OVR_KeyCodes_h +#define OVR_KeyCodes_h + +namespace OVR { + +//----------------------------------------------------------------------------------- +// ***** KeyCode + +// KeyCode enumeration defines platform-independent keyboard key constants. +// Note that Key_A through Key_Z are mapped to capital ascii constants. + +enum KeyCode +{ + // Key_None indicates that no key was specified. + Key_None = 0, + + // A through Z and numbers 0 through 9. + Key_A = 65, + Key_B, + Key_C, + Key_D, + Key_E, + Key_F, + Key_G, + Key_H, + Key_I, + Key_J, + Key_K, + Key_L, + Key_M, + Key_N, + Key_O, + Key_P, + Key_Q, + Key_R, + Key_S, + Key_T, + Key_U, + Key_V, + Key_W, + Key_X, + Key_Y, + Key_Z, + Key_Num0 = 48, + Key_Num1, + Key_Num2, + Key_Num3, + Key_Num4, + Key_Num5, + Key_Num6, + Key_Num7, + Key_Num8, + Key_Num9, + + // Numeric keypad. + Key_KP_0 = 0xa0, + Key_KP_1, + Key_KP_2, + Key_KP_3, + Key_KP_4, + Key_KP_5, + Key_KP_6, + Key_KP_7, + Key_KP_8, + Key_KP_9, + Key_KP_Multiply, + Key_KP_Add, + Key_KP_Enter, + Key_KP_Subtract, + Key_KP_Decimal, + Key_KP_Divide, + + // Function keys. + Key_F1 = 0xb0, + Key_F2, + Key_F3, + Key_F4, + Key_F5, + Key_F6, + Key_F7, + Key_F8, + Key_F9, + Key_F10, + Key_F11, + Key_F12, + Key_F13, + Key_F14, + Key_F15, + + // Other keys. + Key_Backspace = 8, + Key_Tab, + Key_Clear = 12, + Key_Return, + Key_Shift = 16, + Key_Control, + Key_Alt, + Key_Pause, + Key_CapsLock = 20, // Toggle + Key_Escape = 27, + Key_Space = 32, + Key_Quote = 39, + Key_PageUp = 0xc0, + Key_PageDown, + Key_End, + Key_Home, + Key_Left, + Key_Up, + Key_Right, + Key_Down, + Key_Insert, + Key_Delete, + Key_Help, + + Key_Comma = 44, + Key_Minus, + Key_Slash = 47, + Key_Period, + Key_NumLock = 144, // Toggle + Key_ScrollLock = 145, // Toggle + + Key_Semicolon = 59, + Key_Equal = 61, + Key_Backtick = 96, // ` and tilda~ when shifted (US keyboard) + Key_BracketLeft = 91, + Key_Backslash, + Key_BracketRight, + + Key_OEM_AX = 0xE1, // 'AX' key on Japanese AX keyboard + Key_OEM_102 = 0xE2, // "<>" or "\|" on RT 102-key keyboard. + Key_ICO_HELP = 0xE3, // Help key on ICO + Key_ICO_00 = 0xE4, // 00 key on ICO + + Key_Meta, + + // Total number of keys. + Key_CodeCount +}; + + +//----------------------------------------------------------------------------------- + +class KeyModifiers +{ +public: + enum + { + Key_ShiftPressed = 0x01, + Key_CtrlPressed = 0x02, + Key_AltPressed = 0x04, + Key_MetaPressed = 0x08, + Key_CapsToggled = 0x10, + Key_NumToggled = 0x20, + Key_ScrollToggled = 0x40, + + Initialized_Bit = 0x80, + Initialized_Mask = 0xFF + }; + unsigned char States; + + KeyModifiers() : States(0) { } + KeyModifiers(unsigned char st) : States((unsigned char)(st | Initialized_Bit)) { } + + void Reset() { States = 0; } + + bool IsShiftPressed() const { return (States & Key_ShiftPressed) != 0; } + bool IsCtrlPressed() const { return (States & Key_CtrlPressed) != 0; } + bool IsAltPressed() const { return (States & Key_AltPressed) != 0; } + bool IsMetaPressed() const { return (States & Key_MetaPressed) != 0; } + bool IsCapsToggled() const { return (States & Key_CapsToggled) != 0; } + bool IsNumToggled() const { return (States & Key_NumToggled) != 0; } + bool IsScrollToggled() const{ return (States & Key_ScrollToggled) != 0; } + + void SetShiftPressed(bool v = true) { (v) ? States |= Key_ShiftPressed : States &= ~Key_ShiftPressed; } + void SetCtrlPressed(bool v = true) { (v) ? States |= Key_CtrlPressed : States &= ~Key_CtrlPressed; } + void SetAltPressed(bool v = true) { (v) ? States |= Key_AltPressed : States &= ~Key_AltPressed; } + void SetMetaPressed(bool v = true) { (v) ? States |= Key_MetaPressed : States &= ~Key_MetaPressed; } + void SetCapsToggled(bool v = true) { (v) ? States |= Key_CapsToggled : States &= ~Key_CapsToggled; } + void SetNumToggled(bool v = true) { (v) ? States |= Key_NumToggled : States &= ~Key_NumToggled; } + void SetScrollToggled(bool v = true) { (v) ? States |= Key_ScrollToggled: States &= ~Key_ScrollToggled; } + + bool IsInitialized() const { return (States & Initialized_Mask) != 0; } +}; + + +//----------------------------------------------------------------------------------- + +/* +enum PadKeyCode +{ + Pad_None, // Indicates absence of key code. + Pad_Back, + Pad_Start, + Pad_A, + Pad_B, + Pad_X, + Pad_Y, + Pad_R1, // RightShoulder; + Pad_L1, // LeftShoulder; + Pad_R2, // RightTrigger; + Pad_L2, // LeftTrigger; + Pad_Up, + Pad_Down, + Pad_Right, + Pad_Left, + Pad_Plus, + Pad_Minus, + Pad_1, + Pad_2, + Pad_H, + Pad_C, + Pad_Z, + Pad_O, + Pad_T, + Pad_S, + Pad_Select, + Pad_Home, + Pad_RT, // RightThumb; + Pad_LT // LeftThumb; +}; +*/ + +} // OVR + +#endif diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Kernel/OVR_List.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Kernel/OVR_List.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,342 @@ +/************************************************************************************ + +PublicHeader: OVR +Filename : OVR_List.h +Content : Template implementation for doubly-connected linked List +Created : September 19, 2012 +Notes : + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#ifndef OVR_List_h +#define OVR_List_h + +#include "OVR_Types.h" + +namespace OVR { + +//----------------------------------------------------------------------------------- +// ***** ListNode +// +// Base class for the elements of the intrusive linked list. +// To store elements in the List do: +// +// struct MyData : ListNode +// { +// . . . +// }; + +template +struct ListNode +{ + union { + T* pPrev; + void* pVoidPrev; + }; + union { + T* pNext; + void* pVoidNext; + }; + + ListNode() + { + pPrev = NULL; + pNext = NULL; + } + + void RemoveNode() + { + pPrev->pNext = pNext; + pNext->pPrev = pPrev; + } + + // Removes us from the list and inserts pnew there instead. + void ReplaceNodeWith(T* pnew) + { + pPrev->pNext = pnew; + pNext->pPrev = pnew; + pnew->pPrev = pPrev; + pnew->pNext = pNext; + } + + // Inserts the argument linked list node after us in the list. + void InsertNodeAfter(T* p) + { + p->pPrev = pNext->pPrev; // this + p->pNext = pNext; + pNext->pPrev = p; + pNext = p; + } + // Inserts the argument linked list node before us in the list. + void InsertNodeBefore(T* p) + { + p->pNext = pNext->pPrev; // this + p->pPrev = pPrev; + pPrev->pNext = p; + pPrev = p; + } + + void Alloc_MoveTo(ListNode* pdest) + { + pdest->pNext = pNext; + pdest->pPrev = pPrev; + pPrev->pNext = (T*)pdest; + pNext->pPrev = (T*)pdest; + } +}; + + +//------------------------------------------------------------------------ +// ***** List +// +// Doubly linked intrusive list. +// The data type must be derived from ListNode. +// +// Adding: PushFront(), PushBack(). +// Removing: Remove() - the element must be in the list! +// Moving: BringToFront(), SendToBack() - the element must be in the list! +// +// Iterating: +// MyData* data = MyList.GetFirst(); +// while (!MyList.IsNull(data)) +// { +// . . . +// data = MyList.GetNext(data); +// } +// +// Removing: +// MyData* data = MyList.GetFirst(); +// while (!MyList.IsNull(data)) +// { +// MyData* next = MyList.GetNext(data); +// if (ToBeRemoved(data)) +// MyList.Remove(data); +// data = next; +// } +// + +// List<> represents a doubly-linked list of T, where each T must derive +// from ListNode. B specifies the base class that was directly +// derived from ListNode, and is only necessary if there is an intermediate +// inheritance chain. + +template class List +{ +public: + typedef T ValueType; + + List() + { + Root.pNext = Root.pPrev = (ValueType*)&Root; + } + + void Clear() + { + Root.pNext = Root.pPrev = (ValueType*)&Root; + } + + const ValueType* GetFirst() const { return (const ValueType*)Root.pNext; } + const ValueType* GetLast () const { return (const ValueType*)Root.pPrev; } + ValueType* GetFirst() { return (ValueType*)Root.pNext; } + ValueType* GetLast () { return (ValueType*)Root.pPrev; } + + // Determine if list is empty (i.e.) points to itself. + // Go through void* access to avoid issues with strict-aliasing optimizing out the + // access after RemoveNode(), etc. + bool IsEmpty() const { return Root.pVoidNext == (const T*)(const B*)&Root; } + bool IsFirst(const ValueType* p) const { return p == Root.pNext; } + bool IsLast (const ValueType* p) const { return p == Root.pPrev; } + bool IsNull (const ValueType* p) const { return p == (const T*)(const B*)&Root; } + + inline static const ValueType* GetPrev(const ValueType* p) { return (const ValueType*)p->pPrev; } + inline static const ValueType* GetNext(const ValueType* p) { return (const ValueType*)p->pNext; } + inline static ValueType* GetPrev( ValueType* p) { return (ValueType*)p->pPrev; } + inline static ValueType* GetNext( ValueType* p) { return (ValueType*)p->pNext; } + + void PushFront(ValueType* p) + { + p->pNext = Root.pNext; + p->pPrev = (ValueType*)&Root; + Root.pNext->pPrev = p; + Root.pNext = p; + } + + void PushBack(ValueType* p) + { + p->pPrev = Root.pPrev; + p->pNext = (ValueType*)&Root; + Root.pPrev->pNext = p; + Root.pPrev = p; + } + + static void Remove(ValueType* p) + { + p->pPrev->pNext = p->pNext; + p->pNext->pPrev = p->pPrev; + } + + void BringToFront(ValueType* p) + { + Remove(p); + PushFront(p); + } + + void SendToBack(ValueType* p) + { + Remove(p); + PushBack(p); + } + + // Appends the contents of the argument list to the front of this list; + // items are removed from the argument list. + void PushListToFront(List& src) + { + if (!src.IsEmpty()) + { + ValueType* pfirst = src.GetFirst(); + ValueType* plast = src.GetLast(); + src.Clear(); + plast->pNext = Root.pNext; + pfirst->pPrev = (ValueType*)&Root; + Root.pNext->pPrev = plast; + Root.pNext = pfirst; + } + } + + void PushListToBack(List& src) + { + if (!src.IsEmpty()) + { + ValueType* pfirst = src.GetFirst(); + ValueType* plast = src.GetLast(); + src.Clear(); + plast->pNext = (ValueType*)&Root; + pfirst->pPrev = Root.pPrev; + Root.pPrev->pNext = pfirst; + Root.pPrev = plast; + } + } + + // Removes all source list items after (and including) the 'pfirst' node from the + // source list and adds them to out list. + void PushFollowingListItemsToFront(List& src, ValueType *pfirst) + { + if (pfirst != &src.Root) + { + ValueType *plast = src.Root.pPrev; + + // Remove list remainder from source. + pfirst->pPrev->pNext = (ValueType*)&src.Root; + src.Root.pPrev = pfirst->pPrev; + // Add the rest of the items to list. + plast->pNext = Root.pNext; + pfirst->pPrev = (ValueType*)&Root; + Root.pNext->pPrev = plast; + Root.pNext = pfirst; + } + } + + // Removes all source list items up to but NOT including the 'pend' node from the + // source list and adds them to out list. + void PushPrecedingListItemsToFront(List& src, ValueType *ptail) + { + if (src.GetFirst() != ptail) + { + ValueType *pfirst = src.Root.pNext; + ValueType *plast = ptail->pPrev; + + // Remove list remainder from source. + ptail->pPrev = (ValueType*)&src.Root; + src.Root.pNext = ptail; + + // Add the rest of the items to list. + plast->pNext = Root.pNext; + pfirst->pPrev = (ValueType*)&Root; + Root.pNext->pPrev = plast; + Root.pNext = pfirst; + } + } + + + // Removes a range of source list items starting at 'pfirst' and up to, but not including 'pend', + // and adds them to out list. Note that source items MUST already be in the list. + void PushListItemsToFront(ValueType *pfirst, ValueType *pend) + { + if (pfirst != pend) + { + ValueType *plast = pend->pPrev; + + // Remove list remainder from source. + pfirst->pPrev->pNext = pend; + pend->pPrev = pfirst->pPrev; + // Add the rest of the items to list. + plast->pNext = Root.pNext; + pfirst->pPrev = (ValueType*)&Root; + Root.pNext->pPrev = plast; + Root.pNext = pfirst; + } + } + + + void Alloc_MoveTo(List* pdest) + { + if (IsEmpty()) + pdest->Clear(); + else + { + pdest->Root.pNext = Root.pNext; + pdest->Root.pPrev = Root.pPrev; + + Root.pNext->pPrev = (ValueType*)&pdest->Root; + Root.pPrev->pNext = (ValueType*)&pdest->Root; + } + } + + +private: + // Copying is prohibited + List(const List&); + const List& operator = (const List&); + + ListNode Root; +}; + + +//------------------------------------------------------------------------ +// ***** FreeListElements +// +// Remove all elements in the list and free them in the allocator + +template +void FreeListElements(List& list, Allocator& allocator) +{ + typename List::ValueType* self = list.GetFirst(); + while(!list.IsNull(self)) + { + typename List::ValueType* next = list.GetNext(self); + allocator.Free(self); + self = next; + } + list.Clear(); +} + +} // OVR + +#endif diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Kernel/OVR_Lockless.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Kernel/OVR_Lockless.cpp Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,225 @@ +/************************************************************************************ + +Filename : OVR_Lockless.cpp +Content : Test logic for lock-less classes +Created : December 27, 2013 +Authors : Michael Antonov + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +*************************************************************************************/ + +#include "OVR_Lockless.h" + +#ifdef OVR_LOCKLESS_TEST + +#include "OVR_Threads.h" +#include "OVR_Timer.h" +#include "OVR_Log.h" + +namespace OVR { namespace LocklessTest { + + +const int TestIterations = 10000000; + +// Use volatile dummies to force compiler to do spinning. +volatile int Dummy1; +int Unused1[32]; +volatile int Dummy2; +int Unused2[32]; +volatile int Dummy3; +int Unused3[32]; + + +// Data block out of 20 consecutive integers, should be internally consistent. +struct TestData +{ + enum { ItemCount = 20 }; + + int Data[ItemCount]; + + + void Set(int val) + { + for (int i=0; i TestDataUpdater; + +// Use this lock to verify that testing algorithm is otherwise correct... +Lock TestLock; + + +//------------------------------------------------------------------------------------- + +// Consumer thread reads values from TestDataUpdater and +// ensures that each one is internally consistent. + +class Consumer : public Thread +{ + virtual int Run() + { + LogText("LocklessTest::Consumer::Run started.\n"); + + while (!FirstItemWritten) + { + // spin until producer wrote first value... + } + + TestData d; + int oldValue = 0; + int newValue; + + do + { + { + //Lock::Locker scope(&TestLock); + d = TestDataUpdater.GetState(); + } + + newValue = d.ReadAndCheckConsistency(oldValue); + + // Values should increase or stay the same! + if (newValue < oldValue) + { + LogText("LocklessTest Fail - %d after %d; delta = %d\n", + newValue, oldValue, newValue - oldValue); + // OVR_ASSERT(0); + } + + + if (oldValue != newValue) + { + oldValue = newValue; + + if (oldValue % (TestIterations/30) == 0) + { + LogText("LocklessTest::Consumer - %5.2f%% done\n", + 100.0f * (float)oldValue/(float)TestIterations); + } + } + + // Spin a while + for (int j = 0; j< 300; j++) + { + Dummy3 = j; + } + + + } while (oldValue < (TestIterations * 99 / 100)); + + LogText("LocklessTest::Consumer::Run exiting.\n"); + return 0; + } + +}; + + +//------------------------------------------------------------------------------------- + +class Producer : public Thread +{ + + virtual int Run() + { + LogText("LocklessTest::Producer::Run started.\n"); + + for (int testVal = 0; testVal < TestIterations; testVal++) + { + TestData d; + d.Set(testVal); + + { + //Lock::Locker scope(&TestLock); + TestDataUpdater.SetState(d); + } + + FirstItemWritten = true; + + // Spin a bit + for(int j = 0; j < 1000; j++) + { + Dummy2 = j; + } + + if (testVal % (TestIterations/30) == 0) + { + LogText("LocklessTest::Producer - %5.2f%% done\n", + 100.0f * (float)testVal/(float)TestIterations); + } + } + + LogText("LocklessTest::Producer::Run exiting.\n"); + return 0; + } +}; + + +} // namespace LocklessTest + + + +void StartLocklessTest() +{ + // These threads will release themselves once done + Ptr producerThread = *new LocklessTest::Producer; + Ptr consumerThread = *new LocklessTest::Consumer; + + producerThread->Start(); + consumerThread->Start(); + + while (!producerThread->IsFinished() && consumerThread->IsFinished()) + { + Thread::MSleep(500); + } +} + + +} // namespace OVR + +#endif // OVR_LOCKLESS_TEST diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Kernel/OVR_Lockless.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Kernel/OVR_Lockless.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,117 @@ +/************************************************************************************ + +PublicHeader: OVR_Kernel.h +Filename : OVR_Lockless.h +Content : Lock-less classes for producer/consumer communication +Created : November 9, 2013 +Authors : John Carmack + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +*************************************************************************************/ + +#ifndef OVR_Lockless_h +#define OVR_Lockless_h + +#include "OVR_Atomic.h" + +// Define this to compile-in Lockless test logic +//#define OVR_LOCKLESS_TEST + +namespace OVR { + + +// ***** LocklessUpdater + +// For single producer cases where you only care about the most recent update, not +// necessarily getting every one that happens (vsync timing, SensorFusion updates). +// +// This is multiple consumer safe, but is currently only used with a single consumer. +// +// The SlotType can be the same as T, but should probably be a larger fixed size. +// This allows for forward compatibility when the updater is shared between processes. + +// FIXME: ExchangeAdd_Sync() should be replaced with a portable read-only primitive, +// so that the lockless pose state can be read-only on remote processes and to reduce +// false sharing between processes and improve performance. + +template +class LocklessUpdater +{ +public: + LocklessUpdater() : UpdateBegin( 0 ), UpdateEnd( 0 ) + { + OVR_COMPILER_ASSERT(sizeof(T) <= sizeof(SlotType)); + } + + T GetState() const + { + // Copy the state out, then retry with the alternate slot + // if we determine that our copy may have been partially + // stepped on by a new update. + T state; + int begin, end, final; + + for(;;) + { + // We are adding 0, only using these as atomic memory barriers, so it + // is ok to cast off the const, allowing GetState() to remain const. + end = UpdateEnd.Load_Acquire(); + state = Slots[ end & 1 ]; + begin = UpdateBegin.Load_Acquire(); + if ( begin == end ) { + break; + } + + // The producer is potentially blocked while only having partially + // written the update, so copy out the other slot. + state = Slots[ (begin & 1) ^ 1 ]; + final = UpdateBegin.Load_Acquire(); + if ( final == begin ) { + break; + } + + // The producer completed the last update and started a new one before + // we got it copied out, so try fetching the current buffer again. + } + return state; + } + + void SetState( const T& state ) + { + const int slot = UpdateBegin.ExchangeAdd_Sync(1) & 1; + // Write to (slot ^ 1) because ExchangeAdd returns 'previous' value before add. + Slots[slot ^ 1] = state; + UpdateEnd.ExchangeAdd_Sync(1); + } + + AtomicInt UpdateBegin; + AtomicInt UpdateEnd; + SlotType Slots[2]; +}; + + +#ifdef OVR_LOCKLESS_TEST +void StartLocklessTest(); +#endif + + +} // namespace OVR + +#endif // OVR_Lockless_h + diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Kernel/OVR_Log.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Kernel/OVR_Log.cpp Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,432 @@ +/************************************************************************************ + +Filename : OVR_Log.cpp +Content : Logging support +Created : September 19, 2012 +Notes : + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#include "OVR_Log.h" +#include "OVR_Std.h" +#include +#include +#include +#include "../Kernel/OVR_System.h" +#include "../Kernel/OVR_DebugHelp.h" +#include "../Util/Util_SystemGUI.h" + +#if defined(OVR_OS_MS) && !defined(OVR_OS_MS_MOBILE) +#define WIN32_LEAN_AND_MEAN +#include +#elif defined(OVR_OS_ANDROID) +#include +#elif defined(OVR_OS_LINUX) || defined(OVR_OS_MAC) || defined(OVR_OS_UNIX) +#include +#endif + + +class LogSubject : public OVR::SystemSingletonBase +{ + static bool isShuttingDown; + +public: + + LogSubject(){ + isShuttingDown = false; + // Must be at end of function + PushDestroyCallbacks(); + } + + virtual ~LogSubject(){} // Required because we use delete this below. + + virtual void OnThreadDestroy() + { + isShuttingDown = true; + } + + virtual void OnSystemDestroy() + { + delete this; + } + + static bool IsValid() { + return isShuttingDown == false; + } + + OVR::Lock logSubjectLock; + OVR::ObserverScope logSubject; +}; + +bool LogSubject::isShuttingDown; + +OVR_DEFINE_SINGLETON(LogSubject); + +namespace OVR { + + // Global Log pointer. + Log* volatile OVR_GlobalLog = 0; + +//----------------------------------------------------------------------------------- +// ***** Log Implementation + +Log::Log(unsigned logMask) : + LoggingMask(logMask) +{ +#ifdef OVR_OS_WIN32 + hEventSource = RegisterEventSourceA(NULL, "OculusVR"); + OVR_ASSERT(hEventSource != NULL); +#endif +} + +Log::~Log() +{ +#ifdef OVR_OS_WIN32 + if (hEventSource) + { + DeregisterEventSource(hEventSource); + } +#endif + + // Clear out global log + if (this == OVR_GlobalLog) + { + // TBD: perhaps we should ASSERT if this happens before system shutdown? + OVR_GlobalLog = 0; + } +} +void Log::AddLogObserver(ObserverScope *logObserver) +{ + if (OVR::System::IsInitialized() && LogSubject::GetInstance()->IsValid()) + { + Lock::Locker locker(&LogSubject::GetInstance()->logSubjectLock); + logObserver->GetPtr()->Observe(LogSubject::GetInstance()->logSubject); + } +} +void Log::LogMessageVargInt(LogMessageType messageType, const char* fmt, va_list argList) +{ + if (OVR::System::IsInitialized() && LogSubject::GetInstance()->IsValid()) + { + // Invoke subject + char buffer[MaxLogBufferMessageSize]; + char* pBuffer = buffer; + char* pAllocated = NULL; + + #if !defined(OVR_CC_MSVC) // Non-Microsoft compilers require you to save a copy of the va_list. + va_list argListSaved; + va_copy(argListSaved, argList); + #endif + + int result = FormatLog(pBuffer, MaxLogBufferMessageSize, Log_Text, fmt, argList); + + if(result >= MaxLogBufferMessageSize) // If there was insufficient capacity... + { + pAllocated = (char*)OVR_ALLOC(result + 1); // We assume C++ exceptions are disabled. FormatLog will handle the case that pAllocated is NULL. + pBuffer = pAllocated; + + #if !defined(OVR_CC_MSVC) + va_end(argList); // The caller owns argList and will call va_end on it. + va_copy(argList, argListSaved); + #endif + + FormatLog(pBuffer, (size_t)result + 1, Log_Text, fmt, argList); + } + + Lock::Locker locker(&LogSubject::GetInstance()->logSubjectLock); + LogSubject::GetInstance()->logSubject.GetPtr()->Call(pBuffer, messageType); + + delete[] pAllocated; + } +} + +void Log::LogMessageVarg(LogMessageType messageType, const char* fmt, va_list argList) +{ + if ((messageType & LoggingMask) == 0) + return; +#ifndef OVR_BUILD_DEBUG + if (IsDebugMessage(messageType)) + return; +#endif + + char buffer[MaxLogBufferMessageSize]; + char* pBuffer = buffer; + char* pAllocated = NULL; + + #if !defined(OVR_CC_MSVC) // Non-Microsoft compilers require you to save a copy of the va_list. + va_list argListSaved; + va_copy(argListSaved, argList); + #endif + + int result = FormatLog(pBuffer, MaxLogBufferMessageSize, messageType, fmt, argList); + + if(result >= MaxLogBufferMessageSize) // If there was insufficient capacity... + { + pAllocated = (char*)OVR_ALLOC(result + 1); // We assume C++ exceptions are disabled. FormatLog will handle the case that pAllocated is NULL. + pBuffer = pAllocated; + + #if !defined(OVR_CC_MSVC) + va_end(argList); // The caller owns argList and will call va_end on it. + va_copy(argList, argListSaved); + #endif + + FormatLog(pBuffer, (size_t)result + 1, messageType, fmt, argList); + } + + DefaultLogOutput(pBuffer, messageType, result); + delete[] pAllocated; +} + +void OVR::Log::LogMessage(LogMessageType messageType, const char* pfmt, ...) +{ + va_list argList; + va_start(argList, pfmt); + LogMessageVarg(messageType, pfmt, argList); + va_end(argList); +} + + +// Return behavior is the same as ISO C vsnprintf: returns the required strlen of buffer (which will +// be >= bufferSize if bufferSize is insufficient) or returns a negative value because the input was bad. +int Log::FormatLog(char* buffer, size_t bufferSize, LogMessageType messageType, + const char* fmt, va_list argList) +{ + OVR_ASSERT(buffer && (bufferSize >= 10)); // Need to be able to at least print "Assert: \n" to it. + if(!buffer || (bufferSize < 10)) + return -1; + + int addNewline = 1; + int prefixLength = 0; + + switch(messageType) + { + case Log_Error: OVR_strcpy(buffer, bufferSize, "Error: "); prefixLength = 7; break; + case Log_Debug: OVR_strcpy(buffer, bufferSize, "Debug: "); prefixLength = 7; break; + case Log_Assert: OVR_strcpy(buffer, bufferSize, "Assert: "); prefixLength = 8; break; + case Log_Text: buffer[0] = 0; addNewline = 0; break; + case Log_DebugText: buffer[0] = 0; addNewline = 0; break; + default: buffer[0] = 0; addNewline = 0; break; + } + + char* buffer2 = buffer + prefixLength; + size_t size2 = bufferSize - (size_t)prefixLength; + int messageLength = OVR_vsnprintf(buffer2, size2, fmt, argList); + + if (addNewline) + { + if (messageLength < 0) // If there was a format error... + { + // To consider: append to the buffer here. + buffer2[0] = '\n'; // We are guaranteed to have capacity for this. + buffer2[1] = '\0'; + } + else + { + // If the printed string used all of the capacity or required more than the capacity, + // Chop the output by one character so we can append the \n safely. + int messageEnd = (messageLength >= (int)(size2 - 1)) ? (int)(size2 - 2) : messageLength; + buffer2[messageEnd + 0] = '\n'; + buffer2[messageEnd + 1] = '\0'; + } + } + + if (messageLength >= 0) // If the format was OK... + return prefixLength + messageLength + addNewline; // Return the required strlen of buffer. + + return messageLength; // Else we cannot know what the required strlen is and return the error to the caller. +} + +void Log::DefaultLogOutput(const char* formattedText, LogMessageType messageType, int bufferSize) +{ + bool debug = IsDebugMessage(messageType); + OVR_UNUSED(bufferSize); + +#if defined(OVR_OS_WIN32) + // Under Win32, output regular messages to console if it exists; debug window otherwise. + static DWORD dummyMode; + static bool hasConsole = (GetStdHandle(STD_OUTPUT_HANDLE) != INVALID_HANDLE_VALUE) && + (GetConsoleMode(GetStdHandle(STD_OUTPUT_HANDLE), &dummyMode)); + + if (!hasConsole || debug) + { + ::OutputDebugStringA(formattedText); + } + + fputs(formattedText, stdout); + +#elif defined(OVR_OS_MS) // Any other Microsoft OSs + + ::OutputDebugStringA(formattedText); + +#elif defined(OVR_OS_ANDROID) + // To do: use bufferSize to deal with the case that Android has a limited output length. + __android_log_write(ANDROID_LOG_INFO, "OVR", formattedText); + +#else + fputs(formattedText, stdout); + +#endif + + if (messageType == Log_Error) + { +#if defined(OVR_OS_WIN32) + if (!ReportEventA(hEventSource, EVENTLOG_ERROR_TYPE, 0, 0, NULL, 1, 0, &formattedText, NULL)) + { + OVR_ASSERT(false); + } +#elif defined(OVR_OS_MS) // Any other Microsoft OSs + // TBD +#elif defined(OVR_OS_ANDROID) + // TBD +#elif defined(OVR_OS_MAC) || defined(OVR_OS_LINUX) + syslog(LOG_ERR, "%s", formattedText); +#else + // TBD +#endif + } + + // Just in case. + OVR_UNUSED2(formattedText, debug); +} + + +//static +void Log::SetGlobalLog(Log *log) +{ + OVR_GlobalLog = log; +} +//static +Log* Log::GetGlobalLog() +{ +// No global log by default? +// if (!OVR_GlobalLog) +// OVR_GlobalLog = GetDefaultLog(); + return OVR_GlobalLog; +} + +//static +Log* Log::GetDefaultLog() +{ + // Create default log pointer statically so that it can be used + // even during startup. + static Log defaultLog; + return &defaultLog; +} + + +//----------------------------------------------------------------------------------- +// ***** Global Logging functions + +#if !defined(OVR_CC_MSVC) +// The reason for va_copy is because you can't use va_start twice on Linux +#define OVR_LOG_FUNCTION_IMPL(Name) \ + void Log##Name(const char* fmt, ...) \ + { \ + if (OVR_GlobalLog) \ + { \ + va_list argList1; \ + va_start(argList1, fmt); \ + va_list argList2; \ + va_copy(argList2, argList1); \ + OVR_GlobalLog->LogMessageVargInt(Log_##Name, fmt, argList2); \ + va_end(argList2); \ + OVR_GlobalLog->LogMessageVarg(Log_##Name, fmt, argList1); \ + va_end(argList1); \ + } \ + } +#else +#define OVR_LOG_FUNCTION_IMPL(Name) \ + void Log##Name(const char* fmt, ...) \ + { \ + if (OVR_GlobalLog) \ + { \ + va_list argList1; \ + va_start(argList1, fmt); \ + OVR_GlobalLog->LogMessageVargInt(Log_##Name, fmt, argList1); \ + OVR_GlobalLog->LogMessageVarg(Log_##Name, fmt, argList1); \ + va_end(argList1); \ + } \ + } +#endif // #if !defined(OVR_OS_WIN32) + +OVR_LOG_FUNCTION_IMPL(Text) +OVR_LOG_FUNCTION_IMPL(Error) + +#ifdef OVR_BUILD_DEBUG +OVR_LOG_FUNCTION_IMPL(DebugText) +OVR_LOG_FUNCTION_IMPL(Debug) +OVR_LOG_FUNCTION_IMPL(Assert) +#endif + + + +// Assertion handler support +// To consider: Move this to an OVR_Types.cpp or OVR_Assert.cpp source file. + +static OVRAssertionHandler sOVRAssertionHandler = OVR::DefaultAssertionHandler; +static intptr_t sOVRAssertionHandlerUserParameter = 0; + +OVRAssertionHandler GetAssertionHandler(intptr_t* userParameter) +{ + if(userParameter) + *userParameter = sOVRAssertionHandlerUserParameter; + return sOVRAssertionHandler; +} + +void SetAssertionHandler(OVRAssertionHandler assertionHandler, intptr_t userParameter) +{ + sOVRAssertionHandler = assertionHandler; + sOVRAssertionHandlerUserParameter = userParameter; +} + +intptr_t DefaultAssertionHandler(intptr_t /*userParameter*/, const char* title, const char* message) +{ + if(OVRIsDebuggerPresent()) + { + OVR_DEBUG_BREAK; + } + else + { + #if defined(OVR_BUILD_DEBUG) + // Print a stack trace of all threads. + OVR::String s; + OVR::String threadListOutput; + static OVR::SymbolLookup symbolLookup; + + s = "Failure: "; + s += message; + + if(symbolLookup.Initialize() && symbolLookup.ReportThreadCallstack(threadListOutput, 4)) // This '4' is there to skip our internal handling and retrieve starting at the assertion location (our caller) only. + { + s += "\r\n\r\n"; + s += threadListOutput; + } + + OVR::Util::DisplayMessageBox(title, s.ToCStr()); + #else + OVR::Util::DisplayMessageBox(title, message); + #endif + } + + return 0; +} + + + +} // OVR diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Kernel/OVR_Log.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Kernel/OVR_Log.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,227 @@ +/************************************************************************************ + +PublicHeader: OVR +Filename : OVR_Log.h +Content : Logging support +Created : September 19, 2012 +Notes : + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#ifndef OVR_Log_h +#define OVR_Log_h + +#include "OVR_Types.h" +#include "../Kernel/OVR_Delegates.h" +#include "../Kernel//OVR_Observer.h" +#include + +namespace OVR { + +//----------------------------------------------------------------------------------- +// ***** Logging Constants + +// LogMaskConstants defined bit mask constants that describe what log messages +// should be displayed. +enum LogMaskConstants +{ + LogMask_Regular = 0x100, + LogMask_Debug = 0x200, + LogMask_None = 0, + LogMask_All = LogMask_Regular|LogMask_Debug +}; + + +// LogMessageType describes the type of the log message, controls when it is +// displayed and what prefix/suffix is given to it. Messages are subdivided into +// regular and debug logging types. Debug logging is only generated in debug builds. +// +// Log_Text - General output text displayed without prefix or new-line. +// Used in OVR libraries for general log flow messages +// such as "Device Initialized". +// +// Log_Error - Error message output with "Error: %s\n", intended for +// application/sample-level use only, in cases where an expected +// operation failed. OVR libraries should not use this internally, +// reporting status codes instead. +// +// Log_DebugText - Message without prefix or new lines; output in Debug build only. +// +// Log_Debug - Debug-build only message, formatted with "Debug: %s\n". +// Intended to comment on incorrect API usage that doesn't lead +// to crashes but can be avoided with proper use. +// There is no Debug Error on purpose, since real errors should +// be handled by API user. +// +// Log_Assert - Debug-build only message, formatted with "Assert: %s\n". +// Intended for severe unrecoverable conditions in library +// source code. Generated though OVR_ASSERT_MSG(c, "Text"). + +enum LogMessageType +{ + // General Logging + Log_Text = LogMask_Regular | 0, + Log_Error = LogMask_Regular | 1, // "Error: %s\n". + + // Debug-only messages (not generated in release build) + Log_DebugText = LogMask_Debug | 0, + Log_Debug = LogMask_Debug | 1, // "Debug: %s\n". + Log_Assert = LogMask_Debug | 2, // "Assert: %s\n". +}; + + +// LOG_VAARG_ATTRIBUTE macro, enforces printf-style fromatting for message types +#ifdef __GNUC__ +# define OVR_LOG_VAARG_ATTRIBUTE(a,b) __attribute__((format (printf, a, b))) +#else +# define OVR_LOG_VAARG_ATTRIBUTE(a,b) +#endif + +//----------------------------------------------------------------------------------- +// ***** Log + +// Log defines a base class interface that can be implemented to catch both +// debug and runtime messages. +// Debug logging can be overridden by calling Log::SetGlobalLog. + +class Log +{ + friend class System; + +#ifdef OVR_OS_WIN32 + void* hEventSource; +#endif + +public: + Log(unsigned logMask = LogMask_Debug); + virtual ~Log(); + + typedef Delegate2 LogHandler; + + // The following is deprecated, as there is no longer a max log buffer message size. + enum { MaxLogBufferMessageSize = 4096 }; + + unsigned GetLoggingMask() const { return LoggingMask; } + void SetLoggingMask(unsigned logMask) { LoggingMask = logMask; } + + // Internal + // Invokes observers, then calls LogMessageVarg() + static void LogMessageVargInt(LogMessageType messageType, const char* fmt, va_list argList); + + // This virtual function receives all the messages, + // developers should override this function in order to do custom logging + virtual void LogMessageVarg(LogMessageType messageType, const char* fmt, va_list argList); + + static void AddLogObserver(ObserverScope *logObserver); + + // Call the logging function with specific message type, with no type filtering. + void LogMessage(LogMessageType messageType, + const char* fmt, ...) OVR_LOG_VAARG_ATTRIBUTE(3,4); + + + // Helper used by LogMessageVarg to format the log message, writing the resulting + // string into buffer. It formats text based on fmt and appends prefix/new line + // based on LogMessageType. Return behavior is the same as ISO C vsnprintf: returns the + // required strlen of buffer (which will be >= bufferSize if bufferSize is insufficient) + // or returns a negative value because the input was bad. + static int FormatLog(char* buffer, size_t bufferSize, LogMessageType messageType, + const char* fmt, va_list argList); + + // Default log output implementation used by by LogMessageVarg. + // Debug flag may be used to re-direct output on some platforms, but doesn't + // necessarily disable it in release builds; that is the job of the called. + void DefaultLogOutput(const char* textBuffer, LogMessageType messageType, int bufferSize = -1); + + // Determines if the specified message type is for debugging only. + static bool IsDebugMessage(LogMessageType messageType) + { + return (messageType & LogMask_Debug) != 0; + } + + // *** Global APIs + + // Global Log registration APIs. + // - Global log is used for OVR_DEBUG messages. Set global log to null (0) + // to disable all logging. + static void SetGlobalLog(Log *log); + static Log* GetGlobalLog(); + + // Returns default log singleton instance. + static Log* GetDefaultLog(); + + // Applies logMask to the default log and returns a pointer to it. + // By default, only Debug logging is enabled, so to avoid SDK generating console + // messages in user app (those are always disabled in release build, + // even if the flag is set). This function is useful in System constructor. + static Log* ConfigureDefaultLog(unsigned logMask = LogMask_Debug) + { + Log* log = GetDefaultLog(); + log->SetLoggingMask(logMask); + return log; + } + +private: + // Logging mask described by LogMaskConstants. + unsigned LoggingMask; +}; + + +//----------------------------------------------------------------------------------- +// ***** Global Logging Functions and Debug Macros + +// These functions will output text to global log with semantics described by +// their LogMessageType. +void LogText(const char* fmt, ...) OVR_LOG_VAARG_ATTRIBUTE(1,2); +void LogError(const char* fmt, ...) OVR_LOG_VAARG_ATTRIBUTE(1,2); + +#ifdef OVR_BUILD_DEBUG + + // Debug build only logging. + void LogDebugText(const char* fmt, ...) OVR_LOG_VAARG_ATTRIBUTE(1,2); + void LogDebug(const char* fmt, ...) OVR_LOG_VAARG_ATTRIBUTE(1,2); + void LogAssert(const char* fmt, ...) OVR_LOG_VAARG_ATTRIBUTE(1,2); + + // Macro to do debug logging, printf-style. + // An extra set of set of parenthesis must be used around arguments, + // as in: OVR_DEBUG_LOG(("Value %d", 2)). + #define OVR_DEBUG_LOG(args) do { OVR::LogDebug args; } while(0) + #define OVR_DEBUG_LOG_TEXT(args) do { OVR::LogDebugText args; } while(0) + + // Conditional logging. It logs when the condition 'c' is true. + #define OVR_DEBUG_LOG_COND(c, args) do { if ((c)) { OVR::LogDebug args; } } while(0) + #define OVR_DEBUG_LOG_TEXT_COND(c, args) do { if ((c)) { OVR::LogDebugText args; } } while(0) + + // Conditional logging & asserting. It asserts/logs when the condition 'c' is NOT true. + #define OVR_ASSERT_LOG(c, args) do { if (!(c)) { OVR::LogAssert args; OVR_DEBUG_BREAK; } } while(0) + +#else + + // If not in debug build, macros do nothing. + #define OVR_DEBUG_LOG(args) ((void)0) + #define OVR_DEBUG_LOG_TEXT(args) ((void)0) + #define OVR_DEBUG_LOG_COND(c, args) ((void)0) + #define OVR_DEBUG_LOG_TEXT_COND(args) ((void)0) + #define OVR_ASSERT_LOG(c, args) ((void)0) + +#endif + +} // OVR + +#endif diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Kernel/OVR_Math.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Kernel/OVR_Math.cpp Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,58 @@ +/************************************************************************************ + +Filename : OVR_Math.h +Content : Implementation of 3D primitives such as vectors, matrices. +Created : September 4, 2012 +Authors : Andrew Reisse, Michael Antonov, Anna Yershova + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +*************************************************************************************/ + +#include "OVR_Math.h" +#include "OVR_Log.h" + +#include + + +namespace OVR { + + +//------------------------------------------------------------------------------------- +// ***** Constants + +template<> +const Vector3 Vector3::ZERO = Vector3(); + +template<> +const Vector3 Vector3::ZERO = Vector3(); + +template<> +const Matrix4 Matrix4::IdentityValue = Matrix4(1.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 1.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 1.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 1.0f); + +template<> +const Matrix4 Matrix4::IdentityValue = Matrix4(1.0, 0.0, 0.0, 0.0, + 0.0, 1.0, 0.0, 0.0, + 0.0, 0.0, 1.0, 0.0, + 0.0, 0.0, 0.0, 1.0); + + +} // Namespace OVR diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Kernel/OVR_Math.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Kernel/OVR_Math.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,2791 @@ +/************************************************************************************ + +PublicHeader: OVR_Kernel.h +Filename : OVR_Math.h +Content : Implementation of 3D primitives such as vectors, matrices. +Created : September 4, 2012 +Authors : Andrew Reisse, Michael Antonov, Steve LaValle, + Anna Yershova, Max Katsev, Dov Katz + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +*************************************************************************************/ + +#ifndef OVR_Math_h +#define OVR_Math_h + +#include +#include +#include + +#include "OVR_Types.h" +#include "OVR_RefCount.h" +#include "OVR_Std.h" +#include "OVR_Alg.h" + + +namespace OVR { + +//------------------------------------------------------------------------------------- +// ***** Constants for 3D world/axis definitions. + +// Definitions of axes for coordinate and rotation conversions. +enum Axis +{ + Axis_X = 0, Axis_Y = 1, Axis_Z = 2 +}; + +// RotateDirection describes the rotation direction around an axis, interpreted as follows: +// CW - Clockwise while looking "down" from positive axis towards the origin. +// CCW - Counter-clockwise while looking from the positive axis towards the origin, +// which is in the negative axis direction. +// CCW is the default for the RHS coordinate system. Oculus standard RHS coordinate +// system defines Y up, X right, and Z back (pointing out from the screen). In this +// system Rotate_CCW around Z will specifies counter-clockwise rotation in XY plane. +enum RotateDirection +{ + Rotate_CCW = 1, + Rotate_CW = -1 +}; + +// Constants for right handed and left handed coordinate systems +enum HandedSystem +{ + Handed_R = 1, Handed_L = -1 +}; + +// AxisDirection describes which way the coordinate axis points. Used by WorldAxes. +enum AxisDirection +{ + Axis_Up = 2, + Axis_Down = -2, + Axis_Right = 1, + Axis_Left = -1, + Axis_In = 3, + Axis_Out = -3 +}; + +struct WorldAxes +{ + AxisDirection XAxis, YAxis, ZAxis; + + WorldAxes(AxisDirection x, AxisDirection y, AxisDirection z) + : XAxis(x), YAxis(y), ZAxis(z) + { OVR_ASSERT(abs(x) != abs(y) && abs(y) != abs(z) && abs(z) != abs(x));} +}; + +} // namespace OVR + + +//------------------------------------------------------------------------------------// +// ***** C Compatibility Types + +// These declarations are used to support conversion between C types used in +// LibOVR C interfaces and their C++ versions. As an example, they allow passing +// Vector3f into a function that expects ovrVector3f. + +typedef struct ovrQuatf_ ovrQuatf; +typedef struct ovrQuatd_ ovrQuatd; +typedef struct ovrSizei_ ovrSizei; +typedef struct ovrSizef_ ovrSizef; +typedef struct ovrRecti_ ovrRecti; +typedef struct ovrVector2i_ ovrVector2i; +typedef struct ovrVector2f_ ovrVector2f; +typedef struct ovrVector3f_ ovrVector3f; +typedef struct ovrVector3d_ ovrVector3d; +typedef struct ovrMatrix3d_ ovrMatrix3d; +typedef struct ovrMatrix4f_ ovrMatrix4f; +typedef struct ovrPosef_ ovrPosef; +typedef struct ovrPosed_ ovrPosed; +typedef struct ovrPoseStatef_ ovrPoseStatef; +typedef struct ovrPoseStated_ ovrPoseStated; + +namespace OVR { + +// Forward-declare our templates. +template class Quat; +template class Size; +template class Rect; +template class Vector2; +template class Vector3; +template class Matrix3; +template class Matrix4; +template class Pose; +template class PoseState; + +// CompatibleTypes::Type is used to lookup a compatible C-version of a C++ class. +template +struct CompatibleTypes +{ + // Declaration here seems necessary for MSVC; specializations are + // used instead. + typedef struct {} Type; +}; + +// Specializations providing CompatibleTypes::Type value. +template<> struct CompatibleTypes > { typedef ovrQuatf Type; }; +template<> struct CompatibleTypes > { typedef ovrQuatd Type; }; +template<> struct CompatibleTypes > { typedef ovrMatrix3d Type; }; +template<> struct CompatibleTypes > { typedef ovrMatrix4f Type; }; +template<> struct CompatibleTypes > { typedef ovrSizei Type; }; +template<> struct CompatibleTypes > { typedef ovrSizef Type; }; +template<> struct CompatibleTypes > { typedef ovrRecti Type; }; +template<> struct CompatibleTypes > { typedef ovrVector2i Type; }; +template<> struct CompatibleTypes > { typedef ovrVector2f Type; }; +template<> struct CompatibleTypes > { typedef ovrVector3f Type; }; +template<> struct CompatibleTypes > { typedef ovrVector3d Type; }; + +template<> struct CompatibleTypes > { typedef ovrPosef Type; }; +template<> struct CompatibleTypes > { typedef ovrPosed Type; }; + +//------------------------------------------------------------------------------------// +// ***** Math +// +// Math class contains constants and functions. This class is a template specialized +// per type, with Math and Math being distinct. +template +class Math +{ +public: + // By default, support explicit conversion to float. This allows Vector2 to + // compile, for example. + typedef float OtherFloatType; +}; + + +#define MATH_FLOAT_PI (3.1415926f) +#define MATH_FLOAT_TWOPI (2.0f *MATH_FLOAT_PI) +#define MATH_FLOAT_PIOVER2 (0.5f *MATH_FLOAT_PI) +#define MATH_FLOAT_PIOVER4 (0.25f*MATH_FLOAT_PI) +#define MATH_FLOAT_E (2.7182818f) +#define MATH_FLOAT_MAXVALUE (FLT_MAX) +#define MATH_FLOAT MINPOSITIVEVALUE (FLT_MIN) +#define MATH_FLOAT_RADTODEGREEFACTOR (360.0f / MATH_FLOAT_TWOPI) +#define MATH_FLOAT_DEGREETORADFACTOR (MATH_FLOAT_TWOPI / 360.0f) +#define MATH_FLOAT_TOLERANCE (0.00001f) +#define MATH_FLOAT_SINGULARITYRADIUS (0.0000001f) // Use for Gimbal lock numerical problems + +#define MATH_DOUBLE_PI (3.14159265358979) +#define MATH_DOUBLE_TWOPI (2.0f *MATH_DOUBLE_PI) +#define MATH_DOUBLE_PIOVER2 (0.5f *MATH_DOUBLE_PI) +#define MATH_DOUBLE_PIOVER4 (0.25f*MATH_DOUBLE_PI) +#define MATH_DOUBLE_E (2.71828182845905) +#define MATH_DOUBLE_MAXVALUE (DBL_MAX) +#define MATH_DOUBLE MINPOSITIVEVALUE (DBL_MIN) +#define MATH_DOUBLE_RADTODEGREEFACTOR (360.0f / MATH_DOUBLE_TWOPI) +#define MATH_DOUBLE_DEGREETORADFACTOR (MATH_DOUBLE_TWOPI / 360.0f) +#define MATH_DOUBLE_TOLERANCE (0.00001) +#define MATH_DOUBLE_SINGULARITYRADIUS (0.000000000001) // Use for Gimbal lock numerical problems + + + + +// Single-precision Math constants class. +template<> +class Math +{ +public: + typedef double OtherFloatType; +}; + +// Double-precision Math constants class. +template<> +class Math +{ +public: + typedef float OtherFloatType; +}; + + +typedef Math Mathf; +typedef Math Mathd; + +// Conversion functions between degrees and radians +template +T RadToDegree(T rads) { return rads * ((T)MATH_DOUBLE_RADTODEGREEFACTOR); } +template +T DegreeToRad(T rads) { return rads * ((T)MATH_DOUBLE_DEGREETORADFACTOR); } + +// Numerically stable acos function +template +T Acos(T val) { + if (val > T(1)) return T(0); + else if (val < T(-1)) return ((T)MATH_DOUBLE_PI); + else return acos(val); +}; + +// Numerically stable asin function +template +T Asin(T val) { + if (val > T(1)) return ((T)MATH_DOUBLE_PIOVER2); + else if (val < T(-1)) return ((T)MATH_DOUBLE_PIOVER2) * T(3); + else return asin(val); +}; + +#ifdef OVR_CC_MSVC +inline int isnan(double x) { return _isnan(x); }; +#endif + +template +class Quat; + + +//------------------------------------------------------------------------------------- +// ***** Vector2<> + +// Vector2f (Vector2d) represents a 2-dimensional vector or point in space, +// consisting of coordinates x and y + +template +class Vector2 +{ +public: + T x, y; + + Vector2() : x(0), y(0) { } + Vector2(T x_, T y_) : x(x_), y(y_) { } + explicit Vector2(T s) : x(s), y(s) { } + explicit Vector2(const Vector2::OtherFloatType> &src) + : x((T)src.x), y((T)src.y) { } + + + // C-interop support. + typedef typename CompatibleTypes >::Type CompatibleType; + + Vector2(const CompatibleType& s) : x(s.x), y(s.y) { } + + operator const CompatibleType& () const + { + static_assert(sizeof(Vector2) == sizeof(CompatibleType), "sizeof(Vector2) failure"); + return reinterpret_cast(*this); + } + + + bool operator== (const Vector2& b) const { return x == b.x && y == b.y; } + bool operator!= (const Vector2& b) const { return x != b.x || y != b.y; } + + Vector2 operator+ (const Vector2& b) const { return Vector2(x + b.x, y + b.y); } + Vector2& operator+= (const Vector2& b) { x += b.x; y += b.y; return *this; } + Vector2 operator- (const Vector2& b) const { return Vector2(x - b.x, y - b.y); } + Vector2& operator-= (const Vector2& b) { x -= b.x; y -= b.y; return *this; } + Vector2 operator- () const { return Vector2(-x, -y); } + + // Scalar multiplication/division scales vector. + Vector2 operator* (T s) const { return Vector2(x*s, y*s); } + Vector2& operator*= (T s) { x *= s; y *= s; return *this; } + + Vector2 operator/ (T s) const { T rcp = T(1)/s; + return Vector2(x*rcp, y*rcp); } + Vector2& operator/= (T s) { T rcp = T(1)/s; + x *= rcp; y *= rcp; + return *this; } + + static Vector2 Min(const Vector2& a, const Vector2& b) { return Vector2((a.x < b.x) ? a.x : b.x, + (a.y < b.y) ? a.y : b.y); } + static Vector2 Max(const Vector2& a, const Vector2& b) { return Vector2((a.x > b.x) ? a.x : b.x, + (a.y > b.y) ? a.y : b.y); } + + // Compare two vectors for equality with tolerance. Returns true if vectors match withing tolerance. + bool Compare(const Vector2&b, T tolerance = ((T)MATH_DOUBLE_TOLERANCE)) + { + return (fabs(b.x-x) < tolerance) && (fabs(b.y-y) < tolerance); + } + + // Access element by index + T& operator[] (int idx) + { + OVR_ASSERT(0 <= idx && idx < 2); + return *(&x + idx); + } + const T& operator[] (int idx) const + { + OVR_ASSERT(0 <= idx && idx < 2); + return *(&x + idx); + } + + // Entry-wise product of two vectors + Vector2 EntrywiseMultiply(const Vector2& b) const { return Vector2(x * b.x, y * b.y);} + + + // Multiply and divide operators do entry-wise math. Used Dot() for dot product. + Vector2 operator* (const Vector2& b) const { return Vector2(x * b.x, y * b.y); } + Vector2 operator/ (const Vector2& b) const { return Vector2(x / b.x, y / b.y); } + + // Dot product + // Used to calculate angle q between two vectors among other things, + // as (A dot B) = |a||b|cos(q). + T Dot(const Vector2& b) const { return x*b.x + y*b.y; } + + // Returns the angle from this vector to b, in radians. + T Angle(const Vector2& b) const + { + T div = LengthSq()*b.LengthSq(); + OVR_ASSERT(div != T(0)); + T result = Acos((this->Dot(b))/sqrt(div)); + return result; + } + + // Return Length of the vector squared. + T LengthSq() const { return (x * x + y * y); } + + // Return vector length. + T Length() const { return sqrt(LengthSq()); } + + // Returns squared distance between two points represented by vectors. + T DistanceSq(const Vector2& b) const { return (*this - b).LengthSq(); } + + // Returns distance between two points represented by vectors. + T Distance(const Vector2& b) const { return (*this - b).Length(); } + + // Determine if this a unit vector. + bool IsNormalized() const { return fabs(LengthSq() - T(1)) < ((T)MATH_DOUBLE_TOLERANCE); } + + // Normalize, convention vector length to 1. + void Normalize() + { + T l = Length(); + OVR_ASSERT(l != T(0)); + *this /= l; + } + // Returns normalized (unit) version of the vector without modifying itself. + Vector2 Normalized() const + { + T l = Length(); + OVR_ASSERT(l != T(0)); + return *this / l; + } + + // Linearly interpolates from this vector to another. + // Factor should be between 0.0 and 1.0, with 0 giving full value to this. + Vector2 Lerp(const Vector2& b, T f) const { return *this*(T(1) - f) + b*f; } + + // Projects this vector onto the argument; in other words, + // A.Project(B) returns projection of vector A onto B. + Vector2 ProjectTo(const Vector2& b) const + { + T l2 = b.LengthSq(); + OVR_ASSERT(l2 != T(0)); + return b * ( Dot(b) / l2 ); + } +}; + + +typedef Vector2 Vector2f; +typedef Vector2 Vector2d; +typedef Vector2 Vector2i; + +typedef Vector2 Point2f; +typedef Vector2 Point2d; +typedef Vector2 Point2i; + +//------------------------------------------------------------------------------------- +// ***** Vector3<> - 3D vector of {x, y, z} + +// +// Vector3f (Vector3d) represents a 3-dimensional vector or point in space, +// consisting of coordinates x, y and z. + +template +class Vector3 +{ +public: + T x, y, z; + + // FIXME: default initialization of a vector class can be very expensive in a full-blown + // application. A few hundred thousand vector constructions is not unlikely and can add + // up to milliseconds of time on processors like the PS3 PPU. + Vector3() : x(0), y(0), z(0) { } + Vector3(T x_, T y_, T z_ = 0) : x(x_), y(y_), z(z_) { } + explicit Vector3(T s) : x(s), y(s), z(s) { } + explicit Vector3(const Vector3::OtherFloatType> &src) + : x((T)src.x), y((T)src.y), z((T)src.z) { } + + static const Vector3 ZERO; + + // C-interop support. + typedef typename CompatibleTypes >::Type CompatibleType; + + Vector3(const CompatibleType& s) : x(s.x), y(s.y), z(s.z) { } + + operator const CompatibleType& () const + { + static_assert(sizeof(Vector3) == sizeof(CompatibleType), "sizeof(Vector3) failure"); + return reinterpret_cast(*this); + } + + bool operator== (const Vector3& b) const { return x == b.x && y == b.y && z == b.z; } + bool operator!= (const Vector3& b) const { return x != b.x || y != b.y || z != b.z; } + + Vector3 operator+ (const Vector3& b) const { return Vector3(x + b.x, y + b.y, z + b.z); } + Vector3& operator+= (const Vector3& b) { x += b.x; y += b.y; z += b.z; return *this; } + Vector3 operator- (const Vector3& b) const { return Vector3(x - b.x, y - b.y, z - b.z); } + Vector3& operator-= (const Vector3& b) { x -= b.x; y -= b.y; z -= b.z; return *this; } + Vector3 operator- () const { return Vector3(-x, -y, -z); } + + // Scalar multiplication/division scales vector. + Vector3 operator* (T s) const { return Vector3(x*s, y*s, z*s); } + Vector3& operator*= (T s) { x *= s; y *= s; z *= s; return *this; } + + Vector3 operator/ (T s) const { T rcp = T(1)/s; + return Vector3(x*rcp, y*rcp, z*rcp); } + Vector3& operator/= (T s) { T rcp = T(1)/s; + x *= rcp; y *= rcp; z *= rcp; + return *this; } + + static Vector3 Min(const Vector3& a, const Vector3& b) + { + return Vector3((a.x < b.x) ? a.x : b.x, + (a.y < b.y) ? a.y : b.y, + (a.z < b.z) ? a.z : b.z); + } + static Vector3 Max(const Vector3& a, const Vector3& b) + { + return Vector3((a.x > b.x) ? a.x : b.x, + (a.y > b.y) ? a.y : b.y, + (a.z > b.z) ? a.z : b.z); + } + + // Compare two vectors for equality with tolerance. Returns true if vectors match withing tolerance. + bool Compare(const Vector3&b, T tolerance = ((T)MATH_DOUBLE_TOLERANCE)) + { + return (fabs(b.x-x) < tolerance) && + (fabs(b.y-y) < tolerance) && + (fabs(b.z-z) < tolerance); + } + + T& operator[] (int idx) + { + OVR_ASSERT(0 <= idx && idx < 3); + return *(&x + idx); + } + + const T& operator[] (int idx) const + { + OVR_ASSERT(0 <= idx && idx < 3); + return *(&x + idx); + } + + // Entrywise product of two vectors + Vector3 EntrywiseMultiply(const Vector3& b) const { return Vector3(x * b.x, + y * b.y, + z * b.z);} + + // Multiply and divide operators do entry-wise math + Vector3 operator* (const Vector3& b) const { return Vector3(x * b.x, + y * b.y, + z * b.z); } + + Vector3 operator/ (const Vector3& b) const { return Vector3(x / b.x, + y / b.y, + z / b.z); } + + + // Dot product + // Used to calculate angle q between two vectors among other things, + // as (A dot B) = |a||b|cos(q). + T Dot(const Vector3& b) const { return x*b.x + y*b.y + z*b.z; } + + // Compute cross product, which generates a normal vector. + // Direction vector can be determined by right-hand rule: Pointing index finder in + // direction a and middle finger in direction b, thumb will point in a.Cross(b). + Vector3 Cross(const Vector3& b) const { return Vector3(y*b.z - z*b.y, + z*b.x - x*b.z, + x*b.y - y*b.x); } + + // Returns the angle from this vector to b, in radians. + T Angle(const Vector3& b) const + { + T div = LengthSq()*b.LengthSq(); + OVR_ASSERT(div != T(0)); + T result = Acos((this->Dot(b))/sqrt(div)); + return result; + } + + // Return Length of the vector squared. + T LengthSq() const { return (x * x + y * y + z * z); } + + // Return vector length. + T Length() const { return sqrt(LengthSq()); } + + // Returns squared distance between two points represented by vectors. + T DistanceSq(Vector3 const& b) const { return (*this - b).LengthSq(); } + + // Returns distance between two points represented by vectors. + T Distance(Vector3 const& b) const { return (*this - b).Length(); } + + // Determine if this a unit vector. + bool IsNormalized() const { return fabs(LengthSq() - T(1)) < ((T)MATH_DOUBLE_TOLERANCE); } + + // Normalize, convention vector length to 1. + void Normalize() + { + T l = Length(); + OVR_ASSERT(l != T(0)); + *this /= l; + } + + // Returns normalized (unit) version of the vector without modifying itself. + Vector3 Normalized() const + { + T l = Length(); + OVR_ASSERT(l != T(0)); + return *this / l; + } + + // Linearly interpolates from this vector to another. + // Factor should be between 0.0 and 1.0, with 0 giving full value to this. + Vector3 Lerp(const Vector3& b, T f) const { return *this*(T(1) - f) + b*f; } + + // Projects this vector onto the argument; in other words, + // A.Project(B) returns projection of vector A onto B. + Vector3 ProjectTo(const Vector3& b) const + { + T l2 = b.LengthSq(); + OVR_ASSERT(l2 != T(0)); + return b * ( Dot(b) / l2 ); + } + + // Projects this vector onto a plane defined by a normal vector + Vector3 ProjectToPlane(const Vector3& normal) const { return *this - this->ProjectTo(normal); } +}; + +typedef Vector3 Vector3f; +typedef Vector3 Vector3d; +typedef Vector3 Vector3i; + +static_assert((sizeof(Vector3f) == 3*sizeof(float)), "sizeof(Vector3f) failure"); +static_assert((sizeof(Vector3d) == 3*sizeof(double)), "sizeof(Vector3d) failure"); +static_assert((sizeof(Vector3i) == 3*sizeof(int32_t)), "sizeof(Vector3i) failure"); + +typedef Vector3 Point3f; +typedef Vector3 Point3d; +typedef Vector3 Point3i; + + +//------------------------------------------------------------------------------------- +// ***** Vector4<> - 4D vector of {x, y, z, w} + +// +// Vector4f (Vector4d) represents a 3-dimensional vector or point in space, +// consisting of coordinates x, y, z and w. + +template +class Vector4 +{ +public: + T x, y, z, w; + + // FIXME: default initialization of a vector class can be very expensive in a full-blown + // application. A few hundred thousand vector constructions is not unlikely and can add + // up to milliseconds of time on processors like the PS3 PPU. + Vector4() : x(0), y(0), z(0), w(0) { } + Vector4(T x_, T y_, T z_, T w_) : x(x_), y(y_), z(z_), w(w_) { } + explicit Vector4(T s) : x(s), y(s), z(s), w(s) { } + explicit Vector4(const Vector3& v, const float w_=1) : x(v.x), y(v.y), z(v.z), w(w_) { } + explicit Vector4(const Vector4::OtherFloatType> &src) + : x((T)src.x), y((T)src.y), z((T)src.z), w((T)src.w) { } + + static const Vector4 ZERO; + + // C-interop support. + typedef typename CompatibleTypes< Vector4 >::Type CompatibleType; + + Vector4(const CompatibleType& s) : x(s.x), y(s.y), z(s.z), w(s.w) { } + + operator const CompatibleType& () const + { + static_assert(sizeof(Vector4) == sizeof(CompatibleType), "sizeof(Vector4) failure"); + return reinterpret_cast(*this); + } + + Vector4& operator= (const Vector3& other) { x=other.x; y=other.y; z=other.z; w=1; return *this; } + bool operator== (const Vector4& b) const { return x == b.x && y == b.y && z == b.z && w == b.w; } + bool operator!= (const Vector4& b) const { return x != b.x || y != b.y || z != b.z || w != b.w; } + + Vector4 operator+ (const Vector4& b) const { return Vector4(x + b.x, y + b.y, z + b.z, w + b.w); } + Vector4& operator+= (const Vector4& b) { x += b.x; y += b.y; z += b.z; w += b.w; return *this; } + Vector4 operator- (const Vector4& b) const { return Vector4(x - b.x, y - b.y, z - b.z, w - b.w); } + Vector4& operator-= (const Vector4& b) { x -= b.x; y -= b.y; z -= b.z; w -= b.w; return *this; } + Vector4 operator- () const { return Vector4(-x, -y, -z, -w); } + + // Scalar multiplication/division scales vector. + Vector4 operator* (T s) const { return Vector4(x*s, y*s, z*s, w*s); } + Vector4& operator*= (T s) { x *= s; y *= s; z *= s; w *= s;return *this; } + + Vector4 operator/ (T s) const { T rcp = T(1)/s; + return Vector4(x*rcp, y*rcp, z*rcp, w*rcp); } + Vector4& operator/= (T s) { T rcp = T(1)/s; + x *= rcp; y *= rcp; z *= rcp; w *= rcp; + return *this; } + + static Vector4 Min(const Vector4& a, const Vector4& b) + { + return Vector4((a.x < b.x) ? a.x : b.x, + (a.y < b.y) ? a.y : b.y, + (a.z < b.z) ? a.z : b.z, + (a.w < b.w) ? a.w : b.w); + } + static Vector4 Max(const Vector4& a, const Vector4& b) + { + return Vector4((a.x > b.x) ? a.x : b.x, + (a.y > b.y) ? a.y : b.y, + (a.z > b.z) ? a.z : b.z, + (a.w > b.w) ? a.w : b.w); + } + + // Compare two vectors for equality with tolerance. Returns true if vectors match withing tolerance. + bool Compare(const Vector4&b, T tolerance = ((T)MATH_DOUBLE_TOLERANCE)) + { + return (fabs(b.x-x) < tolerance) && + (fabs(b.y-y) < tolerance) && + (fabs(b.z-z) < tolerance) && + (fabs(b.w-w) < tolerance); + } + + T& operator[] (int idx) + { + OVR_ASSERT(0 <= idx && idx < 4); + return *(&x + idx); + } + + const T& operator[] (int idx) const + { + OVR_ASSERT(0 <= idx && idx < 4); + return *(&x + idx); + } + + // Entry wise product of two vectors + Vector4 EntrywiseMultiply(const Vector4& b) const { return Vector4(x * b.x, + y * b.y, + z * b.z);} + + // Multiply and divide operators do entry-wise math + Vector4 operator* (const Vector4& b) const { return Vector4(x * b.x, + y * b.y, + z * b.z, + w * b.w); } + + Vector4 operator/ (const Vector4& b) const { return Vector4(x / b.x, + y / b.y, + z / b.z, + w / b.w); } + + + // Dot product + T Dot(const Vector4& b) const { return x*b.x + y*b.y + z*b.z + w*b.w; } + + // Return Length of the vector squared. + T LengthSq() const { return (x * x + y * y + z * z + w * w); } + + // Return vector length. + T Length() const { return sqrt(LengthSq()); } + + // Determine if this a unit vector. + bool IsNormalized() const { return fabs(LengthSq() - T(1)) < Math::Tolerance; } + + // Normalize, convention vector length to 1. + void Normalize() + { + T l = Length(); + OVR_ASSERT(l != T(0)); + *this /= l; + } + + // Returns normalized (unit) version of the vector without modifying itself. + Vector4 Normalized() const + { + T l = Length(); + OVR_ASSERT(l != T(0)); + return *this / l; + } +}; + +typedef Vector4 Vector4f; +typedef Vector4 Vector4d; +typedef Vector4 Vector4i; + + +//------------------------------------------------------------------------------------- +// ***** Bounds3 + +// Bounds class used to describe a 3D axis aligned bounding box. + +template +class Bounds3 +{ +public: + Vector3 b[2]; + + Bounds3() + { + } + + Bounds3( const Vector3 & mins, const Vector3 & maxs ) +{ + b[0] = mins; + b[1] = maxs; + } + + void Clear() + { + b[0].x = b[0].y = b[0].z = Math::MaxValue; + b[1].x = b[1].y = b[1].z = -Math::MaxValue; + } + + void AddPoint( const Vector3 & v ) + { + b[0].x = Alg::Min( b[0].x, v.x ); + b[0].y = Alg::Min( b[0].y, v.y ); + b[0].z = Alg::Min( b[0].z, v.z ); + b[1].x = Alg::Max( b[1].x, v.x ); + b[1].y = Alg::Max( b[1].y, v.y ); + b[1].z = Alg::Max( b[1].z, v.z ); + } + + const Vector3 & GetMins() const { return b[0]; } + const Vector3 & GetMaxs() const { return b[1]; } + + Vector3 & GetMins() { return b[0]; } + Vector3 & GetMaxs() { return b[1]; } +}; + +typedef Bounds3 Bounds3f; +typedef Bounds3 Bounds3d; + + +//------------------------------------------------------------------------------------- +// ***** Size + +// Size class represents 2D size with Width, Height components. +// Used to describe distentions of render targets, etc. + +template +class Size +{ +public: + T w, h; + + Size() : w(0), h(0) { } + Size(T w_, T h_) : w(w_), h(h_) { } + explicit Size(T s) : w(s), h(s) { } + explicit Size(const Size::OtherFloatType> &src) + : w((T)src.w), h((T)src.h) { } + + // C-interop support. + typedef typename CompatibleTypes >::Type CompatibleType; + + Size(const CompatibleType& s) : w(s.w), h(s.h) { } + + operator const CompatibleType& () const + { + static_assert(sizeof(Size) == sizeof(CompatibleType), "sizeof(Size) failure"); + return reinterpret_cast(*this); + } + + bool operator== (const Size& b) const { return w == b.w && h == b.h; } + bool operator!= (const Size& b) const { return w != b.w || h != b.h; } + + Size operator+ (const Size& b) const { return Size(w + b.w, h + b.h); } + Size& operator+= (const Size& b) { w += b.w; h += b.h; return *this; } + Size operator- (const Size& b) const { return Size(w - b.w, h - b.h); } + Size& operator-= (const Size& b) { w -= b.w; h -= b.h; return *this; } + Size operator- () const { return Size(-w, -h); } + Size operator* (const Size& b) const { return Size(w * b.w, h * b.h); } + Size& operator*= (const Size& b) { w *= b.w; h *= b.h; return *this; } + Size operator/ (const Size& b) const { return Size(w / b.w, h / b.h); } + Size& operator/= (const Size& b) { w /= b.w; h /= b.h; return *this; } + + // Scalar multiplication/division scales both components. + Size operator* (T s) const { return Size(w*s, h*s); } + Size& operator*= (T s) { w *= s; h *= s; return *this; } + Size operator/ (T s) const { return Size(w/s, h/s); } + Size& operator/= (T s) { w /= s; h /= s; return *this; } + + static Size Min(const Size& a, const Size& b) { return Size((a.w < b.w) ? a.w : b.w, + (a.h < b.h) ? a.h : b.h); } + static Size Max(const Size& a, const Size& b) { return Size((a.w > b.w) ? a.w : b.w, + (a.h > b.h) ? a.h : b.h); } + + T Area() const { return w * h; } + + inline Vector2 ToVector() const { return Vector2(w, h); } +}; + + +typedef Size Sizei; +typedef Size Sizeu; +typedef Size Sizef; +typedef Size Sized; + + + +//----------------------------------------------------------------------------------- +// ***** Rect + +// Rect describes a rectangular area for rendering, that includes position and size. +template +class Rect +{ +public: + T x, y; + T w, h; + + Rect() { } + Rect(T x1, T y1, T w1, T h1) : x(x1), y(y1), w(w1), h(h1) { } + Rect(const Vector2& pos, const Size& sz) : x(pos.x), y(pos.y), w(sz.w), h(sz.h) { } + Rect(const Size& sz) : x(0), y(0), w(sz.w), h(sz.h) { } + + // C-interop support. + typedef typename CompatibleTypes >::Type CompatibleType; + + Rect(const CompatibleType& s) : x(s.Pos.x), y(s.Pos.y), w(s.Size.w), h(s.Size.h) { } + + operator const CompatibleType& () const + { + static_assert(sizeof(Rect) == sizeof(CompatibleType), "sizeof(Rect) failure"); + return reinterpret_cast(*this); + } + + Vector2 GetPos() const { return Vector2(x, y); } + Size GetSize() const { return Size(w, h); } + void SetPos(const Vector2& pos) { x = pos.x; y = pos.y; } + void SetSize(const Size& sz) { w = sz.w; h = sz.h; } + + bool operator == (const Rect& vp) const + { return (x == vp.x) && (y == vp.y) && (w == vp.w) && (h == vp.h); } + bool operator != (const Rect& vp) const + { return !operator == (vp); } +}; + +typedef Rect Recti; + + +//-------------------------------------------------------------------------------------// +// ***** Quat +// +// Quatf represents a quaternion class used for rotations. +// +// Quaternion multiplications are done in right-to-left order, to match the +// behavior of matrices. + + +template +class Quat +{ +public: + // w + Xi + Yj + Zk + T x, y, z, w; + + Quat() : x(0), y(0), z(0), w(1) { } + Quat(T x_, T y_, T z_, T w_) : x(x_), y(y_), z(z_), w(w_) { } + explicit Quat(const Quat::OtherFloatType> &src) + : x((T)src.x), y((T)src.y), z((T)src.z), w((T)src.w) { } + + typedef typename CompatibleTypes >::Type CompatibleType; + + // C-interop support. + Quat(const CompatibleType& s) : x(s.x), y(s.y), z(s.z), w(s.w) { } + + operator CompatibleType () const + { + CompatibleType result; + result.x = x; + result.y = y; + result.z = z; + result.w = w; + return result; + } + + // Constructs quaternion for rotation around the axis by an angle. + Quat(const Vector3& axis, T angle) + { + // Make sure we don't divide by zero. + if (axis.LengthSq() == 0) + { + // Assert if the axis is zero, but the angle isn't + OVR_ASSERT(angle == 0); + x = 0; y = 0; z = 0; w = 1; + return; + } + + Vector3 unitAxis = axis.Normalized(); + T sinHalfAngle = sin(angle * T(0.5)); + + w = cos(angle * T(0.5)); + x = unitAxis.x * sinHalfAngle; + y = unitAxis.y * sinHalfAngle; + z = unitAxis.z * sinHalfAngle; + } + + // Constructs quaternion for rotation around one of the coordinate axis by an angle. + Quat(Axis A, T angle, RotateDirection d = Rotate_CCW, HandedSystem s = Handed_R) + { + T sinHalfAngle = s * d *sin(angle * T(0.5)); + T v[3]; + v[0] = v[1] = v[2] = T(0); + v[A] = sinHalfAngle; + + w = cos(angle * T(0.5)); + x = v[0]; + y = v[1]; + z = v[2]; + } + + // Compute axis and angle from quaternion + void GetAxisAngle(Vector3* axis, T* angle) const + { + if ( x*x + y*y + z*z > ((T)MATH_DOUBLE_TOLERANCE) * ((T)MATH_DOUBLE_TOLERANCE) ) { + *axis = Vector3(x, y, z).Normalized(); + *angle = 2 * Acos(w); + if (*angle > ((T)MATH_DOUBLE_PI)) // Reduce the magnitude of the angle, if necessary + { + *angle = ((T)MATH_DOUBLE_TWOPI) - *angle; + *axis = *axis * (-1); + } + } + else + { + *axis = Vector3(1, 0, 0); + *angle= 0; + } + } + + // Constructs the quaternion from a rotation matrix + explicit Quat(const Matrix4& m) + { + T trace = m.M[0][0] + m.M[1][1] + m.M[2][2]; + + // In almost all cases, the first part is executed. + // However, if the trace is not positive, the other + // cases arise. + if (trace > T(0)) + { + T s = sqrt(trace + T(1)) * T(2); // s=4*qw + w = T(0.25) * s; + x = (m.M[2][1] - m.M[1][2]) / s; + y = (m.M[0][2] - m.M[2][0]) / s; + z = (m.M[1][0] - m.M[0][1]) / s; + } + else if ((m.M[0][0] > m.M[1][1])&&(m.M[0][0] > m.M[2][2])) + { + T s = sqrt(T(1) + m.M[0][0] - m.M[1][1] - m.M[2][2]) * T(2); + w = (m.M[2][1] - m.M[1][2]) / s; + x = T(0.25) * s; + y = (m.M[0][1] + m.M[1][0]) / s; + z = (m.M[2][0] + m.M[0][2]) / s; + } + else if (m.M[1][1] > m.M[2][2]) + { + T s = sqrt(T(1) + m.M[1][1] - m.M[0][0] - m.M[2][2]) * T(2); // S=4*qy + w = (m.M[0][2] - m.M[2][0]) / s; + x = (m.M[0][1] + m.M[1][0]) / s; + y = T(0.25) * s; + z = (m.M[1][2] + m.M[2][1]) / s; + } + else + { + T s = sqrt(T(1) + m.M[2][2] - m.M[0][0] - m.M[1][1]) * T(2); // S=4*qz + w = (m.M[1][0] - m.M[0][1]) / s; + x = (m.M[0][2] + m.M[2][0]) / s; + y = (m.M[1][2] + m.M[2][1]) / s; + z = T(0.25) * s; + } + } + + // Constructs the quaternion from a rotation matrix + explicit Quat(const Matrix3& m) + { + T trace = m.M[0][0] + m.M[1][1] + m.M[2][2]; + + // In almost all cases, the first part is executed. + // However, if the trace is not positive, the other + // cases arise. + if (trace > T(0)) + { + T s = sqrt(trace + T(1)) * T(2); // s=4*qw + w = T(0.25) * s; + x = (m.M[2][1] - m.M[1][2]) / s; + y = (m.M[0][2] - m.M[2][0]) / s; + z = (m.M[1][0] - m.M[0][1]) / s; + } + else if ((m.M[0][0] > m.M[1][1])&&(m.M[0][0] > m.M[2][2])) + { + T s = sqrt(T(1) + m.M[0][0] - m.M[1][1] - m.M[2][2]) * T(2); + w = (m.M[2][1] - m.M[1][2]) / s; + x = T(0.25) * s; + y = (m.M[0][1] + m.M[1][0]) / s; + z = (m.M[2][0] + m.M[0][2]) / s; + } + else if (m.M[1][1] > m.M[2][2]) + { + T s = sqrt(T(1) + m.M[1][1] - m.M[0][0] - m.M[2][2]) * T(2); // S=4*qy + w = (m.M[0][2] - m.M[2][0]) / s; + x = (m.M[0][1] + m.M[1][0]) / s; + y = T(0.25) * s; + z = (m.M[1][2] + m.M[2][1]) / s; + } + else + { + T s = sqrt(T(1) + m.M[2][2] - m.M[0][0] - m.M[1][1]) * T(2); // S=4*qz + w = (m.M[1][0] - m.M[0][1]) / s; + x = (m.M[0][2] + m.M[2][0]) / s; + y = (m.M[1][2] + m.M[2][1]) / s; + z = T(0.25) * s; + } + } + + bool operator== (const Quat& b) const { return x == b.x && y == b.y && z == b.z && w == b.w; } + bool operator!= (const Quat& b) const { return x != b.x || y != b.y || z != b.z || w != b.w; } + + Quat operator+ (const Quat& b) const { return Quat(x + b.x, y + b.y, z + b.z, w + b.w); } + Quat& operator+= (const Quat& b) { w += b.w; x += b.x; y += b.y; z += b.z; return *this; } + Quat operator- (const Quat& b) const { return Quat(x - b.x, y - b.y, z - b.z, w - b.w); } + Quat& operator-= (const Quat& b) { w -= b.w; x -= b.x; y -= b.y; z -= b.z; return *this; } + + Quat operator* (T s) const { return Quat(x * s, y * s, z * s, w * s); } + Quat& operator*= (T s) { w *= s; x *= s; y *= s; z *= s; return *this; } + Quat operator/ (T s) const { T rcp = T(1)/s; return Quat(x * rcp, y * rcp, z * rcp, w *rcp); } + Quat& operator/= (T s) { T rcp = T(1)/s; w *= rcp; x *= rcp; y *= rcp; z *= rcp; return *this; } + + + // Get Imaginary part vector + Vector3 Imag() const { return Vector3(x,y,z); } + + // Get quaternion length. + T Length() const { return sqrt(LengthSq()); } + + // Get quaternion length squared. + T LengthSq() const { return (x * x + y * y + z * z + w * w); } + + // Simple Euclidean distance in R^4 (not SLERP distance, but at least respects Haar measure) + T Distance(const Quat& q) const + { + T d1 = (*this - q).Length(); + T d2 = (*this + q).Length(); // Antipodal point check + return (d1 < d2) ? d1 : d2; + } + + T DistanceSq(const Quat& q) const + { + T d1 = (*this - q).LengthSq(); + T d2 = (*this + q).LengthSq(); // Antipodal point check + return (d1 < d2) ? d1 : d2; + } + + T Dot(const Quat& q) const + { + return x * q.x + y * q.y + z * q.z + w * q.w; + } + + // Angle between two quaternions in radians + T Angle(const Quat& q) const + { + return 2 * Acos(Alg::Abs(Dot(q))); + } + + // Normalize + bool IsNormalized() const { return fabs(LengthSq() - T(1)) < ((T)MATH_DOUBLE_TOLERANCE); } + + void Normalize() + { + T l = Length(); + OVR_ASSERT(l != T(0)); + *this /= l; + } + + Quat Normalized() const + { + T l = Length(); + OVR_ASSERT(l != T(0)); + return *this / l; + } + + // Returns conjugate of the quaternion. Produces inverse rotation if quaternion is normalized. + Quat Conj() const { return Quat(-x, -y, -z, w); } + + // Quaternion multiplication. Combines quaternion rotations, performing the one on the + // right hand side first. + Quat operator* (const Quat& b) const { return Quat(w * b.x + x * b.w + y * b.z - z * b.y, + w * b.y - x * b.z + y * b.w + z * b.x, + w * b.z + x * b.y - y * b.x + z * b.w, + w * b.w - x * b.x - y * b.y - z * b.z); } + + // + // this^p normalized; same as rotating by this p times. + Quat PowNormalized(T p) const + { + Vector3 v; + T a; + GetAxisAngle(&v, &a); + return Quat(v, a * p); + } + + // Normalized linear interpolation of quaternions + Quat Nlerp(const Quat& other, T a) + { + T sign = (Dot(other) >= 0) ? 1 : -1; + return (*this * sign * a + other * (1-a)).Normalized(); + } + + // Rotate transforms vector in a manner that matches Matrix rotations (counter-clockwise, + // assuming negative direction of the axis). Standard formula: q(t) * V * q(t)^-1. + Vector3 Rotate(const Vector3& v) const + { + return ((*this * Quat(v.x, v.y, v.z, T(0))) * Inverted()).Imag(); + } + + // Inversed quaternion rotates in the opposite direction. + Quat Inverted() const + { + return Quat(-x, -y, -z, w); + } + + // Sets this quaternion to the one rotates in the opposite direction. + void Invert() + { + *this = Quat(-x, -y, -z, w); + } + + // GetEulerAngles extracts Euler angles from the quaternion, in the specified order of + // axis rotations and the specified coordinate system. Right-handed coordinate system + // is the default, with CCW rotations while looking in the negative axis direction. + // Here a,b,c, are the Yaw/Pitch/Roll angles to be returned. + // rotation a around axis A1 + // is followed by rotation b around axis A2 + // is followed by rotation c around axis A3 + // rotations are CCW or CW (D) in LH or RH coordinate system (S) + template + void GetEulerAngles(T *a, T *b, T *c) const + { + static_assert((A1 != A2) && (A2 != A3) && (A1 != A3), "(A1 != A2) && (A2 != A3) && (A1 != A3)"); + + T Q[3] = { x, y, z }; //Quaternion components x,y,z + + T ww = w*w; + T Q11 = Q[A1]*Q[A1]; + T Q22 = Q[A2]*Q[A2]; + T Q33 = Q[A3]*Q[A3]; + + T psign = T(-1); + // Determine whether even permutation + if (((A1 + 1) % 3 == A2) && ((A2 + 1) % 3 == A3)) + psign = T(1); + + T s2 = psign * T(2) * (psign*w*Q[A2] + Q[A1]*Q[A3]); + + if (s2 < T(-1) + ((T)MATH_DOUBLE_SINGULARITYRADIUS)) + { // South pole singularity + *a = T(0); + *b = -S*D*((T)MATH_DOUBLE_PIOVER2); + *c = S*D*atan2(T(2)*(psign*Q[A1]*Q[A2] + w*Q[A3]), + ww + Q22 - Q11 - Q33 ); + } + else if (s2 > T(1) - ((T)MATH_DOUBLE_SINGULARITYRADIUS)) + { // North pole singularity + *a = T(0); + *b = S*D*((T)MATH_DOUBLE_PIOVER2); + *c = S*D*atan2(T(2)*(psign*Q[A1]*Q[A2] + w*Q[A3]), + ww + Q22 - Q11 - Q33); + } + else + { + *a = -S*D*atan2(T(-2)*(w*Q[A1] - psign*Q[A2]*Q[A3]), + ww + Q33 - Q11 - Q22); + *b = S*D*asin(s2); + *c = S*D*atan2(T(2)*(w*Q[A3] - psign*Q[A1]*Q[A2]), + ww + Q11 - Q22 - Q33); + } + return; + } + + template + void GetEulerAngles(T *a, T *b, T *c) const + { GetEulerAngles(a, b, c); } + + template + void GetEulerAngles(T *a, T *b, T *c) const + { GetEulerAngles(a, b, c); } + + // GetEulerAnglesABA extracts Euler angles from the quaternion, in the specified order of + // axis rotations and the specified coordinate system. Right-handed coordinate system + // is the default, with CCW rotations while looking in the negative axis direction. + // Here a,b,c, are the Yaw/Pitch/Roll angles to be returned. + // rotation a around axis A1 + // is followed by rotation b around axis A2 + // is followed by rotation c around axis A1 + // Rotations are CCW or CW (D) in LH or RH coordinate system (S) + template + void GetEulerAnglesABA(T *a, T *b, T *c) const + { + static_assert(A1 != A2, "A1 != A2"); + + T Q[3] = {x, y, z}; // Quaternion components + + // Determine the missing axis that was not supplied + int m = 3 - A1 - A2; + + T ww = w*w; + T Q11 = Q[A1]*Q[A1]; + T Q22 = Q[A2]*Q[A2]; + T Qmm = Q[m]*Q[m]; + + T psign = T(-1); + if ((A1 + 1) % 3 == A2) // Determine whether even permutation + { + psign = T(1); + } + + T c2 = ww + Q11 - Q22 - Qmm; + if (c2 < T(-1) + Math::SingularityRadius) + { // South pole singularity + *a = T(0); + *b = S*D*((T)MATH_DOUBLE_PI); + *c = S*D*atan2( T(2)*(w*Q[A1] - psign*Q[A2]*Q[m]), + ww + Q22 - Q11 - Qmm); + } + else if (c2 > T(1) - Math::SingularityRadius) + { // North pole singularity + *a = T(0); + *b = T(0); + *c = S*D*atan2( T(2)*(w*Q[A1] - psign*Q[A2]*Q[m]), + ww + Q22 - Q11 - Qmm); + } + else + { + *a = S*D*atan2( psign*w*Q[m] + Q[A1]*Q[A2], + w*Q[A2] -psign*Q[A1]*Q[m]); + *b = S*D*acos(c2); + *c = S*D*atan2( -psign*w*Q[m] + Q[A1]*Q[A2], + w*Q[A2] + psign*Q[A1]*Q[m]); + } + return; + } +}; + +typedef Quat Quatf; +typedef Quat Quatd; + +static_assert((sizeof(Quatf) == 4*sizeof(float)), "sizeof(Quatf) failure"); +static_assert((sizeof(Quatd) == 4*sizeof(double)), "sizeof(Quatd) failure"); + +//------------------------------------------------------------------------------------- +// ***** Pose + +// Position and orientation combined. + +template +class Pose +{ +public: + typedef typename CompatibleTypes >::Type CompatibleType; + + Pose() { } + Pose(const Quat& orientation, const Vector3& pos) + : Rotation(orientation), Translation(pos) { } + Pose(const Pose& s) + : Rotation(s.Rotation), Translation(s.Translation) { } + Pose(const CompatibleType& s) + : Rotation(s.Orientation), Translation(s.Position) { } + explicit Pose(const Pose::OtherFloatType> &s) + : Rotation(s.Rotation), Translation(s.Translation) { } + + operator typename CompatibleTypes >::Type () const + { + typename CompatibleTypes >::Type result; + result.Orientation = Rotation; + result.Position = Translation; + return result; + } + + Quat Rotation; + Vector3 Translation; + + static_assert((sizeof(T) == sizeof(double) || sizeof(T) == sizeof(float)), "(sizeof(T) == sizeof(double) || sizeof(T) == sizeof(float))"); + + void ToArray(T* arr) const + { + T temp[7] = { Rotation.x, Rotation.y, Rotation.z, Rotation.w, Translation.x, Translation.y, Translation.z }; + for (int i = 0; i < 7; i++) arr[i] = temp[i]; + } + + static Pose FromArray(const T* v) + { + Quat rotation(v[0], v[1], v[2], v[3]); + Vector3 translation(v[4], v[5], v[6]); + return Pose(rotation, translation); + } + + Vector3 Rotate(const Vector3& v) const + { + return Rotation.Rotate(v); + } + + Vector3 Translate(const Vector3& v) const + { + return v + Translation; + } + + Vector3 Apply(const Vector3& v) const + { + return Translate(Rotate(v)); + } + + Pose operator*(const Pose& other) const + { + return Pose(Rotation * other.Rotation, Apply(other.Translation)); + } + + Pose Inverted() const + { + Quat inv = Rotation.Inverted(); + return Pose(inv, inv.Rotate(-Translation)); + } +}; + +typedef Pose Posef; +typedef Pose Posed; + +static_assert((sizeof(Posed) == sizeof(Quatd) + sizeof(Vector3d)), "sizeof(Posed) failure"); +static_assert((sizeof(Posef) == sizeof(Quatf) + sizeof(Vector3f)), "sizeof(Posef) failure"); + + +//------------------------------------------------------------------------------------- +// ***** Matrix4 +// +// Matrix4 is a 4x4 matrix used for 3d transformations and projections. +// Translation stored in the last column. +// The matrix is stored in row-major order in memory, meaning that values +// of the first row are stored before the next one. +// +// The arrangement of the matrix is chosen to be in Right-Handed +// coordinate system and counterclockwise rotations when looking down +// the axis +// +// Transformation Order: +// - Transformations are applied from right to left, so the expression +// M1 * M2 * M3 * V means that the vector V is transformed by M3 first, +// followed by M2 and M1. +// +// Coordinate system: Right Handed +// +// Rotations: Counterclockwise when looking down the axis. All angles are in radians. +// +// | sx 01 02 tx | // First column (sx, 10, 20): Axis X basis vector. +// | 10 sy 12 ty | // Second column (01, sy, 21): Axis Y basis vector. +// | 20 21 sz tz | // Third columnt (02, 12, sz): Axis Z basis vector. +// | 30 31 32 33 | +// +// The basis vectors are first three columns. + +template +class Matrix4 +{ + static const Matrix4 IdentityValue; + +public: + T M[4][4]; + + enum NoInitType { NoInit }; + + // Construct with no memory initialization. + Matrix4(NoInitType) { } + + // By default, we construct identity matrix. + Matrix4() + { + SetIdentity(); + } + + Matrix4(T m11, T m12, T m13, T m14, + T m21, T m22, T m23, T m24, + T m31, T m32, T m33, T m34, + T m41, T m42, T m43, T m44) + { + M[0][0] = m11; M[0][1] = m12; M[0][2] = m13; M[0][3] = m14; + M[1][0] = m21; M[1][1] = m22; M[1][2] = m23; M[1][3] = m24; + M[2][0] = m31; M[2][1] = m32; M[2][2] = m33; M[2][3] = m34; + M[3][0] = m41; M[3][1] = m42; M[3][2] = m43; M[3][3] = m44; + } + + Matrix4(T m11, T m12, T m13, + T m21, T m22, T m23, + T m31, T m32, T m33) + { + M[0][0] = m11; M[0][1] = m12; M[0][2] = m13; M[0][3] = 0; + M[1][0] = m21; M[1][1] = m22; M[1][2] = m23; M[1][3] = 0; + M[2][0] = m31; M[2][1] = m32; M[2][2] = m33; M[2][3] = 0; + M[3][0] = 0; M[3][1] = 0; M[3][2] = 0; M[3][3] = 1; + } + + explicit Matrix4(const Quat& q) + { + T ww = q.w*q.w; + T xx = q.x*q.x; + T yy = q.y*q.y; + T zz = q.z*q.z; + + M[0][0] = ww + xx - yy - zz; M[0][1] = 2 * (q.x*q.y - q.w*q.z); M[0][2] = 2 * (q.x*q.z + q.w*q.y); M[0][3] = 0; + M[1][0] = 2 * (q.x*q.y + q.w*q.z); M[1][1] = ww - xx + yy - zz; M[1][2] = 2 * (q.y*q.z - q.w*q.x); M[1][3] = 0; + M[2][0] = 2 * (q.x*q.z - q.w*q.y); M[2][1] = 2 * (q.y*q.z + q.w*q.x); M[2][2] = ww - xx - yy + zz; M[2][3] = 0; + M[3][0] = 0; M[3][1] = 0; M[3][2] = 0; M[3][3] = 1; + } + + explicit Matrix4(const Pose& p) + { + Matrix4 result(p.Rotation); + result.SetTranslation(p.Translation); + *this = result; + } + + // C-interop support + explicit Matrix4(const Matrix4::OtherFloatType> &src) + { + for (int i = 0; i < 4; i++) + for (int j = 0; j < 4; j++) + M[i][j] = (T)src.M[i][j]; + } + + // C-interop support. + Matrix4(const typename CompatibleTypes >::Type& s) + { + static_assert(sizeof(s) == sizeof(Matrix4), "sizeof(s) == sizeof(Matrix4)"); + memcpy(M, s.M, sizeof(M)); + } + + operator typename CompatibleTypes >::Type () const + { + typename CompatibleTypes >::Type result; + static_assert(sizeof(result) == sizeof(Matrix4), "sizeof(result) == sizeof(Matrix4)"); + memcpy(result.M, M, sizeof(M)); + return result; + } + + void ToString(char* dest, size_t destsize) const + { + size_t pos = 0; + for (int r=0; r<4; r++) + for (int c=0; c<4; c++) + pos += OVR_sprintf(dest+pos, destsize-pos, "%g ", M[r][c]); + } + + static Matrix4 FromString(const char* src) + { + Matrix4 result; + if (src) + { + for (int r=0; r<4; r++) + { + for (int c=0; c<4; c++) + { + result.M[r][c] = (T)atof(src); + while (src && *src != ' ') + { + src++; + } + while (src && *src == ' ') + { + src++; + } + } + } + } + return result; + } + + static const Matrix4& Identity() { return IdentityValue; } + + void SetIdentity() + { + M[0][0] = M[1][1] = M[2][2] = M[3][3] = 1; + M[0][1] = M[1][0] = M[2][3] = M[3][1] = 0; + M[0][2] = M[1][2] = M[2][0] = M[3][2] = 0; + M[0][3] = M[1][3] = M[2][1] = M[3][0] = 0; + } + + void SetXBasis(const Vector3f & v) + { + M[0][0] = v.x; + M[1][0] = v.y; + M[2][0] = v.z; + } + Vector3f GetXBasis() const + { + return Vector3f(M[0][0], M[1][0], M[2][0]); + } + + void SetYBasis(const Vector3f & v) + { + M[0][1] = v.x; + M[1][1] = v.y; + M[2][1] = v.z; + } + Vector3f GetYBasis() const + { + return Vector3f(M[0][1], M[1][1], M[2][1]); + } + + void SetZBasis(const Vector3f & v) + { + M[0][2] = v.x; + M[1][2] = v.y; + M[2][2] = v.z; + } + Vector3f GetZBasis() const + { + return Vector3f(M[0][2], M[1][2], M[2][2]); + } + + bool operator== (const Matrix4& b) const + { + bool isEqual = true; + for (int i = 0; i < 4; i++) + for (int j = 0; j < 4; j++) + isEqual &= (M[i][j] == b.M[i][j]); + + return isEqual; + } + + Matrix4 operator+ (const Matrix4& b) const + { + Matrix4 result(*this); + result += b; + return result; + } + + Matrix4& operator+= (const Matrix4& b) + { + for (int i = 0; i < 4; i++) + for (int j = 0; j < 4; j++) + M[i][j] += b.M[i][j]; + return *this; + } + + Matrix4 operator- (const Matrix4& b) const + { + Matrix4 result(*this); + result -= b; + return result; + } + + Matrix4& operator-= (const Matrix4& b) + { + for (int i = 0; i < 4; i++) + for (int j = 0; j < 4; j++) + M[i][j] -= b.M[i][j]; + return *this; + } + + // Multiplies two matrices into destination with minimum copying. + static Matrix4& Multiply(Matrix4* d, const Matrix4& a, const Matrix4& b) + { + OVR_ASSERT((d != &a) && (d != &b)); + int i = 0; + do { + d->M[i][0] = a.M[i][0] * b.M[0][0] + a.M[i][1] * b.M[1][0] + a.M[i][2] * b.M[2][0] + a.M[i][3] * b.M[3][0]; + d->M[i][1] = a.M[i][0] * b.M[0][1] + a.M[i][1] * b.M[1][1] + a.M[i][2] * b.M[2][1] + a.M[i][3] * b.M[3][1]; + d->M[i][2] = a.M[i][0] * b.M[0][2] + a.M[i][1] * b.M[1][2] + a.M[i][2] * b.M[2][2] + a.M[i][3] * b.M[3][2]; + d->M[i][3] = a.M[i][0] * b.M[0][3] + a.M[i][1] * b.M[1][3] + a.M[i][2] * b.M[2][3] + a.M[i][3] * b.M[3][3]; + } while((++i) < 4); + + return *d; + } + + Matrix4 operator* (const Matrix4& b) const + { + Matrix4 result(Matrix4::NoInit); + Multiply(&result, *this, b); + return result; + } + + Matrix4& operator*= (const Matrix4& b) + { + return Multiply(this, Matrix4(*this), b); + } + + Matrix4 operator* (T s) const + { + Matrix4 result(*this); + result *= s; + return result; + } + + Matrix4& operator*= (T s) + { + for (int i = 0; i < 4; i++) + for (int j = 0; j < 4; j++) + M[i][j] *= s; + return *this; + } + + + Matrix4 operator/ (T s) const + { + Matrix4 result(*this); + result /= s; + return result; + } + + Matrix4& operator/= (T s) + { + for (int i = 0; i < 4; i++) + for (int j = 0; j < 4; j++) + M[i][j] /= s; + return *this; + } + + Vector3 Transform(const Vector3& v) const + { + const T rcpW = 1.0f / (M[3][0] * v.x + M[3][1] * v.y + M[3][2] * v.z + M[3][3]); + return Vector3((M[0][0] * v.x + M[0][1] * v.y + M[0][2] * v.z + M[0][3]) * rcpW, + (M[1][0] * v.x + M[1][1] * v.y + M[1][2] * v.z + M[1][3]) * rcpW, + (M[2][0] * v.x + M[2][1] * v.y + M[2][2] * v.z + M[2][3]) * rcpW); + } + + Vector4 Transform(const Vector4& v) const + { + return Vector4(M[0][0] * v.x + M[0][1] * v.y + M[0][2] * v.z + M[0][3] * v.w, + M[1][0] * v.x + M[1][1] * v.y + M[1][2] * v.z + M[1][3] * v.w, + M[2][0] * v.x + M[2][1] * v.y + M[2][2] * v.z + M[2][3] * v.w, + M[3][0] * v.x + M[3][1] * v.y + M[3][2] * v.z + M[3][3] * v.w); + } + + Matrix4 Transposed() const + { + return Matrix4(M[0][0], M[1][0], M[2][0], M[3][0], + M[0][1], M[1][1], M[2][1], M[3][1], + M[0][2], M[1][2], M[2][2], M[3][2], + M[0][3], M[1][3], M[2][3], M[3][3]); + } + + void Transpose() + { + *this = Transposed(); + } + + + T SubDet (const size_t* rows, const size_t* cols) const + { + return M[rows[0]][cols[0]] * (M[rows[1]][cols[1]] * M[rows[2]][cols[2]] - M[rows[1]][cols[2]] * M[rows[2]][cols[1]]) + - M[rows[0]][cols[1]] * (M[rows[1]][cols[0]] * M[rows[2]][cols[2]] - M[rows[1]][cols[2]] * M[rows[2]][cols[0]]) + + M[rows[0]][cols[2]] * (M[rows[1]][cols[0]] * M[rows[2]][cols[1]] - M[rows[1]][cols[1]] * M[rows[2]][cols[0]]); + } + + T Cofactor(size_t I, size_t J) const + { + const size_t indices[4][3] = {{1,2,3},{0,2,3},{0,1,3},{0,1,2}}; + return ((I+J)&1) ? -SubDet(indices[I],indices[J]) : SubDet(indices[I],indices[J]); + } + + T Determinant() const + { + return M[0][0] * Cofactor(0,0) + M[0][1] * Cofactor(0,1) + M[0][2] * Cofactor(0,2) + M[0][3] * Cofactor(0,3); + } + + Matrix4 Adjugated() const + { + return Matrix4(Cofactor(0,0), Cofactor(1,0), Cofactor(2,0), Cofactor(3,0), + Cofactor(0,1), Cofactor(1,1), Cofactor(2,1), Cofactor(3,1), + Cofactor(0,2), Cofactor(1,2), Cofactor(2,2), Cofactor(3,2), + Cofactor(0,3), Cofactor(1,3), Cofactor(2,3), Cofactor(3,3)); + } + + Matrix4 Inverted() const + { + T det = Determinant(); + assert(det != 0); + return Adjugated() * (1.0f/det); + } + + void Invert() + { + *this = Inverted(); + } + + // This is more efficient than general inverse, but ONLY works + // correctly if it is a homogeneous transform matrix (rot + trans) + Matrix4 InvertedHomogeneousTransform() const + { + // Make the inverse rotation matrix + Matrix4 rinv = this->Transposed(); + rinv.M[3][0] = rinv.M[3][1] = rinv.M[3][2] = 0.0f; + // Make the inverse translation matrix + Vector3 tvinv(-M[0][3],-M[1][3],-M[2][3]); + Matrix4 tinv = Matrix4::Translation(tvinv); + return rinv * tinv; // "untranslate", then "unrotate" + } + + // This is more efficient than general inverse, but ONLY works + // correctly if it is a homogeneous transform matrix (rot + trans) + void InvertHomogeneousTransform() + { + *this = InvertedHomogeneousTransform(); + } + + // Matrix to Euler Angles conversion + // a,b,c, are the YawPitchRoll angles to be returned + // rotation a around axis A1 + // is followed by rotation b around axis A2 + // is followed by rotation c around axis A3 + // rotations are CCW or CW (D) in LH or RH coordinate system (S) + template + void ToEulerAngles(T *a, T *b, T *c) const + { + static_assert((A1 != A2) && (A2 != A3) && (A1 != A3), "(A1 != A2) && (A2 != A3) && (A1 != A3)"); + + T psign = -1; + if (((A1 + 1) % 3 == A2) && ((A2 + 1) % 3 == A3)) // Determine whether even permutation + psign = 1; + + T pm = psign*M[A1][A3]; + if (pm < -1.0f + Math::SingularityRadius) + { // South pole singularity + *a = 0; + *b = -S*D*((T)MATH_DOUBLE_PIOVER2); + *c = S*D*atan2( psign*M[A2][A1], M[A2][A2] ); + } + else if (pm > 1.0f - Math::SingularityRadius) + { // North pole singularity + *a = 0; + *b = S*D*((T)MATH_DOUBLE_PIOVER2); + *c = S*D*atan2( psign*M[A2][A1], M[A2][A2] ); + } + else + { // Normal case (nonsingular) + *a = S*D*atan2( -psign*M[A2][A3], M[A3][A3] ); + *b = S*D*asin(pm); + *c = S*D*atan2( -psign*M[A1][A2], M[A1][A1] ); + } + + return; + } + + // Matrix to Euler Angles conversion + // a,b,c, are the YawPitchRoll angles to be returned + // rotation a around axis A1 + // is followed by rotation b around axis A2 + // is followed by rotation c around axis A1 + // rotations are CCW or CW (D) in LH or RH coordinate system (S) + template + void ToEulerAnglesABA(T *a, T *b, T *c) const + { + static_assert(A1 != A2, "A1 != A2"); + + // Determine the axis that was not supplied + int m = 3 - A1 - A2; + + T psign = -1; + if ((A1 + 1) % 3 == A2) // Determine whether even permutation + psign = 1.0f; + + T c2 = M[A1][A1]; + if (c2 < -1 + Math::SingularityRadius) + { // South pole singularity + *a = 0; + *b = S*D*((T)MATH_DOUBLE_PI); + *c = S*D*atan2( -psign*M[A2][m],M[A2][A2]); + } + else if (c2 > 1.0f - Math::SingularityRadius) + { // North pole singularity + *a = 0; + *b = 0; + *c = S*D*atan2( -psign*M[A2][m],M[A2][A2]); + } + else + { // Normal case (nonsingular) + *a = S*D*atan2( M[A2][A1],-psign*M[m][A1]); + *b = S*D*acos(c2); + *c = S*D*atan2( M[A1][A2],psign*M[A1][m]); + } + return; + } + + // Creates a matrix that converts the vertices from one coordinate system + // to another. + static Matrix4 AxisConversion(const WorldAxes& to, const WorldAxes& from) + { + // Holds axis values from the 'to' structure + int toArray[3] = { to.XAxis, to.YAxis, to.ZAxis }; + + // The inverse of the toArray + int inv[4]; + inv[0] = inv[abs(to.XAxis)] = 0; + inv[abs(to.YAxis)] = 1; + inv[abs(to.ZAxis)] = 2; + + Matrix4 m(0, 0, 0, + 0, 0, 0, + 0, 0, 0); + + // Only three values in the matrix need to be changed to 1 or -1. + m.M[inv[abs(from.XAxis)]][0] = T(from.XAxis/toArray[inv[abs(from.XAxis)]]); + m.M[inv[abs(from.YAxis)]][1] = T(from.YAxis/toArray[inv[abs(from.YAxis)]]); + m.M[inv[abs(from.ZAxis)]][2] = T(from.ZAxis/toArray[inv[abs(from.ZAxis)]]); + return m; + } + + + // Creates a matrix for translation by vector + static Matrix4 Translation(const Vector3& v) + { + Matrix4 t; + t.M[0][3] = v.x; + t.M[1][3] = v.y; + t.M[2][3] = v.z; + return t; + } + + // Creates a matrix for translation by vector + static Matrix4 Translation(T x, T y, T z = 0.0f) + { + Matrix4 t; + t.M[0][3] = x; + t.M[1][3] = y; + t.M[2][3] = z; + return t; + } + + // Sets the translation part + void SetTranslation(const Vector3& v) + { + M[0][3] = v.x; + M[1][3] = v.y; + M[2][3] = v.z; + } + + Vector3 GetTranslation() const + { + return Vector3( M[0][3], M[1][3], M[2][3] ); + } + + // Creates a matrix for scaling by vector + static Matrix4 Scaling(const Vector3& v) + { + Matrix4 t; + t.M[0][0] = v.x; + t.M[1][1] = v.y; + t.M[2][2] = v.z; + return t; + } + + // Creates a matrix for scaling by vector + static Matrix4 Scaling(T x, T y, T z) + { + Matrix4 t; + t.M[0][0] = x; + t.M[1][1] = y; + t.M[2][2] = z; + return t; + } + + // Creates a matrix for scaling by constant + static Matrix4 Scaling(T s) + { + Matrix4 t; + t.M[0][0] = s; + t.M[1][1] = s; + t.M[2][2] = s; + return t; + } + + // Simple L1 distance in R^12 + T Distance(const Matrix4& m2) const + { + T d = fabs(M[0][0] - m2.M[0][0]) + fabs(M[0][1] - m2.M[0][1]); + d += fabs(M[0][2] - m2.M[0][2]) + fabs(M[0][3] - m2.M[0][3]); + d += fabs(M[1][0] - m2.M[1][0]) + fabs(M[1][1] - m2.M[1][1]); + d += fabs(M[1][2] - m2.M[1][2]) + fabs(M[1][3] - m2.M[1][3]); + d += fabs(M[2][0] - m2.M[2][0]) + fabs(M[2][1] - m2.M[2][1]); + d += fabs(M[2][2] - m2.M[2][2]) + fabs(M[2][3] - m2.M[2][3]); + d += fabs(M[3][0] - m2.M[3][0]) + fabs(M[3][1] - m2.M[3][1]); + d += fabs(M[3][2] - m2.M[3][2]) + fabs(M[3][3] - m2.M[3][3]); + return d; + } + + // Creates a rotation matrix rotating around the X axis by 'angle' radians. + // Just for quick testing. Not for final API. Need to remove case. + static Matrix4 RotationAxis(Axis A, T angle, RotateDirection d, HandedSystem s) + { + T sina = s * d *sin(angle); + T cosa = cos(angle); + + switch(A) + { + case Axis_X: + return Matrix4(1, 0, 0, + 0, cosa, -sina, + 0, sina, cosa); + case Axis_Y: + return Matrix4(cosa, 0, sina, + 0, 1, 0, + -sina, 0, cosa); + case Axis_Z: + return Matrix4(cosa, -sina, 0, + sina, cosa, 0, + 0, 0, 1); + } + } + + + // Creates a rotation matrix rotating around the X axis by 'angle' radians. + // Rotation direction is depends on the coordinate system: + // RHS (Oculus default): Positive angle values rotate Counter-clockwise (CCW), + // while looking in the negative axis direction. This is the + // same as looking down from positive axis values towards origin. + // LHS: Positive angle values rotate clock-wise (CW), while looking in the + // negative axis direction. + static Matrix4 RotationX(T angle) + { + T sina = sin(angle); + T cosa = cos(angle); + return Matrix4(1, 0, 0, + 0, cosa, -sina, + 0, sina, cosa); + } + + // Creates a rotation matrix rotating around the Y axis by 'angle' radians. + // Rotation direction is depends on the coordinate system: + // RHS (Oculus default): Positive angle values rotate Counter-clockwise (CCW), + // while looking in the negative axis direction. This is the + // same as looking down from positive axis values towards origin. + // LHS: Positive angle values rotate clock-wise (CW), while looking in the + // negative axis direction. + static Matrix4 RotationY(T angle) + { + T sina = sin(angle); + T cosa = cos(angle); + return Matrix4(cosa, 0, sina, + 0, 1, 0, + -sina, 0, cosa); + } + + // Creates a rotation matrix rotating around the Z axis by 'angle' radians. + // Rotation direction is depends on the coordinate system: + // RHS (Oculus default): Positive angle values rotate Counter-clockwise (CCW), + // while looking in the negative axis direction. This is the + // same as looking down from positive axis values towards origin. + // LHS: Positive angle values rotate clock-wise (CW), while looking in the + // negative axis direction. + static Matrix4 RotationZ(T angle) + { + T sina = sin(angle); + T cosa = cos(angle); + return Matrix4(cosa, -sina, 0, + sina, cosa, 0, + 0, 0, 1); + } + + // LookAtRH creates a View transformation matrix for right-handed coordinate system. + // The resulting matrix points camera from 'eye' towards 'at' direction, with 'up' + // specifying the up vector. The resulting matrix should be used with PerspectiveRH + // projection. + static Matrix4 LookAtRH(const Vector3& eye, const Vector3& at, const Vector3& up) + { + Vector3 z = (eye - at).Normalized(); // Forward + Vector3 x = up.Cross(z).Normalized(); // Right + Vector3 y = z.Cross(x); + + Matrix4 m(x.x, x.y, x.z, -(x.Dot(eye)), + y.x, y.y, y.z, -(y.Dot(eye)), + z.x, z.y, z.z, -(z.Dot(eye)), + 0, 0, 0, 1 ); + return m; + } + + // LookAtLH creates a View transformation matrix for left-handed coordinate system. + // The resulting matrix points camera from 'eye' towards 'at' direction, with 'up' + // specifying the up vector. + static Matrix4 LookAtLH(const Vector3& eye, const Vector3& at, const Vector3& up) + { + Vector3 z = (at - eye).Normalized(); // Forward + Vector3 x = up.Cross(z).Normalized(); // Right + Vector3 y = z.Cross(x); + + Matrix4 m(x.x, x.y, x.z, -(x.Dot(eye)), + y.x, y.y, y.z, -(y.Dot(eye)), + z.x, z.y, z.z, -(z.Dot(eye)), + 0, 0, 0, 1 ); + return m; + } + + // PerspectiveRH creates a right-handed perspective projection matrix that can be + // used with the Oculus sample renderer. + // yfov - Specifies vertical field of view in radians. + // aspect - Screen aspect ration, which is usually width/height for square pixels. + // Note that xfov = yfov * aspect. + // znear - Absolute value of near Z clipping clipping range. + // zfar - Absolute value of far Z clipping clipping range (larger then near). + // Even though RHS usually looks in the direction of negative Z, positive values + // are expected for znear and zfar. + static Matrix4 PerspectiveRH(T yfov, T aspect, T znear, T zfar) + { + Matrix4 m; + T tanHalfFov = tan(yfov * 0.5f); + + m.M[0][0] = 1. / (aspect * tanHalfFov); + m.M[1][1] = 1. / tanHalfFov; + m.M[2][2] = zfar / (znear - zfar); + m.M[3][2] = -1.; + m.M[2][3] = (zfar * znear) / (znear - zfar); + m.M[3][3] = 0.; + + // Note: Post-projection matrix result assumes Left-Handed coordinate system, + // with Y up, X right and Z forward. This supports positive z-buffer values. + // This is the case even for RHS coordinate input. + return m; + } + + // PerspectiveLH creates a left-handed perspective projection matrix that can be + // used with the Oculus sample renderer. + // yfov - Specifies vertical field of view in radians. + // aspect - Screen aspect ration, which is usually width/height for square pixels. + // Note that xfov = yfov * aspect. + // znear - Absolute value of near Z clipping clipping range. + // zfar - Absolute value of far Z clipping clipping range (larger then near). + static Matrix4 PerspectiveLH(T yfov, T aspect, T znear, T zfar) + { + Matrix4 m; + T tanHalfFov = tan(yfov * 0.5f); + + m.M[0][0] = 1. / (aspect * tanHalfFov); + m.M[1][1] = 1. / tanHalfFov; + //m.M[2][2] = zfar / (znear - zfar); + m.M[2][2] = zfar / (zfar - znear); + m.M[3][2] = -1.; + m.M[2][3] = (zfar * znear) / (znear - zfar); + m.M[3][3] = 0.; + + // Note: Post-projection matrix result assumes Left-Handed coordinate system, + // with Y up, X right and Z forward. This supports positive z-buffer values. + // This is the case even for RHS coordinate input. + return m; + } + + static Matrix4 Ortho2D(T w, T h) + { + Matrix4 m; + m.M[0][0] = 2.0/w; + m.M[1][1] = -2.0/h; + m.M[0][3] = -1.0; + m.M[1][3] = 1.0; + m.M[2][2] = 0; + return m; + } +}; + +typedef Matrix4 Matrix4f; +typedef Matrix4 Matrix4d; + +//------------------------------------------------------------------------------------- +// ***** Matrix3 +// +// Matrix3 is a 3x3 matrix used for representing a rotation matrix. +// The matrix is stored in row-major order in memory, meaning that values +// of the first row are stored before the next one. +// +// The arrangement of the matrix is chosen to be in Right-Handed +// coordinate system and counterclockwise rotations when looking down +// the axis +// +// Transformation Order: +// - Transformations are applied from right to left, so the expression +// M1 * M2 * M3 * V means that the vector V is transformed by M3 first, +// followed by M2 and M1. +// +// Coordinate system: Right Handed +// +// Rotations: Counterclockwise when looking down the axis. All angles are in radians. + +template +class SymMat3; + +template +class Matrix3 +{ + static const Matrix3 IdentityValue; + +public: + T M[3][3]; + + enum NoInitType { NoInit }; + + // Construct with no memory initialization. + Matrix3(NoInitType) { } + + // By default, we construct identity matrix. + Matrix3() + { + SetIdentity(); + } + + Matrix3(T m11, T m12, T m13, + T m21, T m22, T m23, + T m31, T m32, T m33) + { + M[0][0] = m11; M[0][1] = m12; M[0][2] = m13; + M[1][0] = m21; M[1][1] = m22; M[1][2] = m23; + M[2][0] = m31; M[2][1] = m32; M[2][2] = m33; + } + + /* + explicit Matrix3(const Quat& q) + { + T ww = q.w*q.w; + T xx = q.x*q.x; + T yy = q.y*q.y; + T zz = q.z*q.z; + + M[0][0] = ww + xx - yy - zz; M[0][1] = 2 * (q.x*q.y - q.w*q.z); M[0][2] = 2 * (q.x*q.z + q.w*q.y); + M[1][0] = 2 * (q.x*q.y + q.w*q.z); M[1][1] = ww - xx + yy - zz; M[1][2] = 2 * (q.y*q.z - q.w*q.x); + M[2][0] = 2 * (q.x*q.z - q.w*q.y); M[2][1] = 2 * (q.y*q.z + q.w*q.x); M[2][2] = ww - xx - yy + zz; + } + */ + + explicit Matrix3(const Quat& q) + { + const T tx = q.x+q.x, ty = q.y+q.y, tz = q.z+q.z; + const T twx = q.w*tx, twy = q.w*ty, twz = q.w*tz; + const T txx = q.x*tx, txy = q.x*ty, txz = q.x*tz; + const T tyy = q.y*ty, tyz = q.y*tz, tzz = q.z*tz; + M[0][0] = T(1) - (tyy + tzz); M[0][1] = txy - twz; M[0][2] = txz + twy; + M[1][0] = txy + twz; M[1][1] = T(1) - (txx + tzz); M[1][2] = tyz - twx; + M[2][0] = txz - twy; M[2][1] = tyz + twx; M[2][2] = T(1) - (txx + tyy); + } + + inline explicit Matrix3(T s) + { + M[0][0] = M[1][1] = M[2][2] = s; + M[0][1] = M[0][2] = M[1][0] = M[1][2] = M[2][0] = M[2][1] = 0; + } + + explicit Matrix3(const Pose& p) + { + Matrix3 result(p.Rotation); + result.SetTranslation(p.Translation); + *this = result; + } + + // C-interop support + explicit Matrix3(const Matrix4::OtherFloatType> &src) + { + for (int i = 0; i < 3; i++) + for (int j = 0; j < 3; j++) + M[i][j] = (T)src.M[i][j]; + } + + // C-interop support. + Matrix3(const typename CompatibleTypes >::Type& s) + { + static_assert(sizeof(s) == sizeof(Matrix3), "sizeof(s) == sizeof(Matrix3)"); + memcpy(M, s.M, sizeof(M)); + } + + operator const typename CompatibleTypes >::Type () const + { + typename CompatibleTypes >::Type result; + static_assert(sizeof(result) == sizeof(Matrix3), "sizeof(result) == sizeof(Matrix3)"); + memcpy(result.M, M, sizeof(M)); + return result; + } + + void ToString(char* dest, size_t destsize) const + { + size_t pos = 0; + for (int r=0; r<3; r++) + for (int c=0; c<3; c++) + pos += OVR_sprintf(dest+pos, destsize-pos, "%g ", M[r][c]); + } + + static Matrix3 FromString(const char* src) + { + Matrix3 result; + for (int r=0; r<3; r++) + for (int c=0; c<3; c++) + { + result.M[r][c] = (T)atof(src); + while (src && *src != ' ') + src++; + while (src && *src == ' ') + src++; + } + return result; + } + + static const Matrix3& Identity() { return IdentityValue; } + + void SetIdentity() + { + M[0][0] = M[1][1] = M[2][2] = 1; + M[0][1] = M[1][0] = M[2][0] = 0; + M[0][2] = M[1][2] = M[2][1] = 0; + } + + bool operator== (const Matrix3& b) const + { + bool isEqual = true; + for (int i = 0; i < 3; i++) + for (int j = 0; j < 3; j++) + isEqual &= (M[i][j] == b.M[i][j]); + + return isEqual; + } + + Matrix3 operator+ (const Matrix3& b) const + { + Matrix4 result(*this); + result += b; + return result; + } + + Matrix3& operator+= (const Matrix3& b) + { + for (int i = 0; i < 3; i++) + for (int j = 0; j < 3; j++) + M[i][j] += b.M[i][j]; + return *this; + } + + void operator= (const Matrix3& b) + { + for (int i = 0; i < 3; i++) + for (int j = 0; j < 3; j++) + M[i][j] = b.M[i][j]; + return; + } + + void operator= (const SymMat3& b) + { + for (int i = 0; i < 3; i++) + for (int j = 0; j < 3; j++) + M[i][j] = 0; + + M[0][0] = b.v[0]; + M[0][1] = b.v[1]; + M[0][2] = b.v[2]; + M[1][1] = b.v[3]; + M[1][2] = b.v[4]; + M[2][2] = b.v[5]; + + return; + } + + Matrix3 operator- (const Matrix3& b) const + { + Matrix3 result(*this); + result -= b; + return result; + } + + Matrix3& operator-= (const Matrix3& b) + { + for (int i = 0; i < 3; i++) + for (int j = 0; j < 3; j++) + M[i][j] -= b.M[i][j]; + return *this; + } + + // Multiplies two matrices into destination with minimum copying. + static Matrix3& Multiply(Matrix3* d, const Matrix3& a, const Matrix3& b) + { + OVR_ASSERT((d != &a) && (d != &b)); + int i = 0; + do { + d->M[i][0] = a.M[i][0] * b.M[0][0] + a.M[i][1] * b.M[1][0] + a.M[i][2] * b.M[2][0]; + d->M[i][1] = a.M[i][0] * b.M[0][1] + a.M[i][1] * b.M[1][1] + a.M[i][2] * b.M[2][1]; + d->M[i][2] = a.M[i][0] * b.M[0][2] + a.M[i][1] * b.M[1][2] + a.M[i][2] * b.M[2][2]; + } while((++i) < 3); + + return *d; + } + + Matrix3 operator* (const Matrix3& b) const + { + Matrix3 result(Matrix3::NoInit); + Multiply(&result, *this, b); + return result; + } + + Matrix3& operator*= (const Matrix3& b) + { + return Multiply(this, Matrix3(*this), b); + } + + Matrix3 operator* (T s) const + { + Matrix3 result(*this); + result *= s; + return result; + } + + Matrix3& operator*= (T s) + { + for (int i = 0; i < 3; i++) + for (int j = 0; j < 3; j++) + M[i][j] *= s; + return *this; + } + + Vector3 operator* (const Vector3 &b) const + { + Vector3 result; + result.x = M[0][0]*b.x + M[0][1]*b.y + M[0][2]*b.z; + result.y = M[1][0]*b.x + M[1][1]*b.y + M[1][2]*b.z; + result.z = M[2][0]*b.x + M[2][1]*b.y + M[2][2]*b.z; + + return result; + } + + Matrix3 operator/ (T s) const + { + Matrix3 result(*this); + result /= s; + return result; + } + + Matrix3& operator/= (T s) + { + for (int i = 0; i < 3; i++) + for (int j = 0; j < 3; j++) + M[i][j] /= s; + return *this; + } + + Vector2 Transform(const Vector2& v) const + { + const float rcpZ = 1.0f / (M[2][0] * v.x + M[2][1] * v.y + M[2][2]); + return Vector2((M[0][0] * v.x + M[0][1] * v.y + M[0][2]) * rcpZ, + (M[1][0] * v.x + M[1][1] * v.y + M[1][2]) * rcpZ); + } + + Vector3 Transform(const Vector3& v) const + { + return Vector3(M[0][0] * v.x + M[0][1] * v.y + M[0][2] * v.z, + M[1][0] * v.x + M[1][1] * v.y + M[1][2] * v.z, + M[2][0] * v.x + M[2][1] * v.y + M[2][2] * v.z); + } + + Matrix3 Transposed() const + { + return Matrix3(M[0][0], M[1][0], M[2][0], + M[0][1], M[1][1], M[2][1], + M[0][2], M[1][2], M[2][2]); + } + + void Transpose() + { + *this = Transposed(); + } + + + T SubDet (const size_t* rows, const size_t* cols) const + { + return M[rows[0]][cols[0]] * (M[rows[1]][cols[1]] * M[rows[2]][cols[2]] - M[rows[1]][cols[2]] * M[rows[2]][cols[1]]) + - M[rows[0]][cols[1]] * (M[rows[1]][cols[0]] * M[rows[2]][cols[2]] - M[rows[1]][cols[2]] * M[rows[2]][cols[0]]) + + M[rows[0]][cols[2]] * (M[rows[1]][cols[0]] * M[rows[2]][cols[1]] - M[rows[1]][cols[1]] * M[rows[2]][cols[0]]); + } + + // M += a*b.t() + inline void Rank1Add(const Vector3 &a, const Vector3 &b) + { + M[0][0] += a.x*b.x; M[0][1] += a.x*b.y; M[0][2] += a.x*b.z; + M[1][0] += a.y*b.x; M[1][1] += a.y*b.y; M[1][2] += a.y*b.z; + M[2][0] += a.z*b.x; M[2][1] += a.z*b.y; M[2][2] += a.z*b.z; + } + + // M -= a*b.t() + inline void Rank1Sub(const Vector3 &a, const Vector3 &b) + { + M[0][0] -= a.x*b.x; M[0][1] -= a.x*b.y; M[0][2] -= a.x*b.z; + M[1][0] -= a.y*b.x; M[1][1] -= a.y*b.y; M[1][2] -= a.y*b.z; + M[2][0] -= a.z*b.x; M[2][1] -= a.z*b.y; M[2][2] -= a.z*b.z; + } + + inline Vector3 Col(int c) const + { + return Vector3(M[0][c], M[1][c], M[2][c]); + } + + inline Vector3 Row(int r) const + { + return Vector3(M[r][0], M[r][1], M[r][2]); + } + + inline T Determinant() const + { + const Matrix3& m = *this; + T d; + + d = m.M[0][0] * (m.M[1][1]*m.M[2][2] - m.M[1][2] * m.M[2][1]); + d -= m.M[0][1] * (m.M[1][0]*m.M[2][2] - m.M[1][2] * m.M[2][0]); + d += m.M[0][2] * (m.M[1][0]*m.M[2][1] - m.M[1][1] * m.M[2][0]); + + return d; + } + + inline Matrix3 Inverse() const + { + Matrix3 a; + const Matrix3& m = *this; + T d = Determinant(); + + assert(d != 0); + T s = T(1)/d; + + a.M[0][0] = s * (m.M[1][1] * m.M[2][2] - m.M[1][2] * m.M[2][1]); + a.M[1][0] = s * (m.M[1][2] * m.M[2][0] - m.M[1][0] * m.M[2][2]); + a.M[2][0] = s * (m.M[1][0] * m.M[2][1] - m.M[1][1] * m.M[2][0]); + + a.M[0][1] = s * (m.M[0][2] * m.M[2][1] - m.M[0][1] * m.M[2][2]); + a.M[1][1] = s * (m.M[0][0] * m.M[2][2] - m.M[0][2] * m.M[2][0]); + a.M[2][1] = s * (m.M[0][1] * m.M[2][0] - m.M[0][0] * m.M[2][1]); + + a.M[0][2] = s * (m.M[0][1] * m.M[1][2] - m.M[0][2] * m.M[1][1]); + a.M[1][2] = s * (m.M[0][2] * m.M[1][0] - m.M[0][0] * m.M[1][2]); + a.M[2][2] = s * (m.M[0][0] * m.M[1][1] - m.M[0][1] * m.M[1][0]); + + return a; + } + +}; + +typedef Matrix3 Matrix3f; +typedef Matrix3 Matrix3d; + +//------------------------------------------------------------------------------------- + +template +class SymMat3 +{ +private: + typedef SymMat3 this_type; + +public: + typedef T Value_t; + // Upper symmetric + T v[6]; // _00 _01 _02 _11 _12 _22 + + inline SymMat3() {} + + inline explicit SymMat3(T s) + { + v[0] = v[3] = v[5] = s; + v[1] = v[2] = v[4] = 0; + } + + inline explicit SymMat3(T a00, T a01, T a02, T a11, T a12, T a22) + { + v[0] = a00; v[1] = a01; v[2] = a02; + v[3] = a11; v[4] = a12; + v[5] = a22; + } + + static inline int Index(unsigned int i, unsigned int j) + { + return (i <= j) ? (3*i - i*(i+1)/2 + j) : (3*j - j*(j+1)/2 + i); + } + + inline T operator()(int i, int j) const { return v[Index(i,j)]; } + + inline T &operator()(int i, int j) { return v[Index(i,j)]; } + + template + inline SymMat3 CastTo() const + { + return SymMat3(static_cast(v[0]), static_cast(v[1]), static_cast(v[2]), + static_cast(v[3]), static_cast(v[4]), static_cast(v[5])); + } + + inline this_type& operator+=(const this_type& b) + { + v[0]+=b.v[0]; + v[1]+=b.v[1]; + v[2]+=b.v[2]; + v[3]+=b.v[3]; + v[4]+=b.v[4]; + v[5]+=b.v[5]; + return *this; + } + + inline this_type& operator-=(const this_type& b) + { + v[0]-=b.v[0]; + v[1]-=b.v[1]; + v[2]-=b.v[2]; + v[3]-=b.v[3]; + v[4]-=b.v[4]; + v[5]-=b.v[5]; + + return *this; + } + + inline this_type& operator*=(T s) + { + v[0]*=s; + v[1]*=s; + v[2]*=s; + v[3]*=s; + v[4]*=s; + v[5]*=s; + + return *this; + } + + inline SymMat3 operator*(T s) const + { + SymMat3 d; + d.v[0] = v[0]*s; + d.v[1] = v[1]*s; + d.v[2] = v[2]*s; + d.v[3] = v[3]*s; + d.v[4] = v[4]*s; + d.v[5] = v[5]*s; + + return d; + } + + // Multiplies two matrices into destination with minimum copying. + static SymMat3& Multiply(SymMat3* d, const SymMat3& a, const SymMat3& b) + { + // _00 _01 _02 _11 _12 _22 + + d->v[0] = a.v[0] * b.v[0]; + d->v[1] = a.v[0] * b.v[1] + a.v[1] * b.v[3]; + d->v[2] = a.v[0] * b.v[2] + a.v[1] * b.v[4]; + + d->v[3] = a.v[3] * b.v[3]; + d->v[4] = a.v[3] * b.v[4] + a.v[4] * b.v[5]; + + d->v[5] = a.v[5] * b.v[5]; + + return *d; + } + + inline T Determinant() const + { + const this_type& m = *this; + T d; + + d = m(0,0) * (m(1,1)*m(2,2) - m(1,2) * m(2,1)); + d -= m(0,1) * (m(1,0)*m(2,2) - m(1,2) * m(2,0)); + d += m(0,2) * (m(1,0)*m(2,1) - m(1,1) * m(2,0)); + + return d; + } + + inline this_type Inverse() const + { + this_type a; + const this_type& m = *this; + T d = Determinant(); + + assert(d != 0); + T s = T(1)/d; + + a(0,0) = s * (m(1,1) * m(2,2) - m(1,2) * m(2,1)); + + a(0,1) = s * (m(0,2) * m(2,1) - m(0,1) * m(2,2)); + a(1,1) = s * (m(0,0) * m(2,2) - m(0,2) * m(2,0)); + + a(0,2) = s * (m(0,1) * m(1,2) - m(0,2) * m(1,1)); + a(1,2) = s * (m(0,2) * m(1,0) - m(0,0) * m(1,2)); + a(2,2) = s * (m(0,0) * m(1,1) - m(0,1) * m(1,0)); + + return a; + } + + inline T Trace() const { return v[0] + v[3] + v[5]; } + + // M = a*a.t() + inline void Rank1(const Vector3 &a) + { + v[0] = a.x*a.x; v[1] = a.x*a.y; v[2] = a.x*a.z; + v[3] = a.y*a.y; v[4] = a.y*a.z; + v[5] = a.z*a.z; + } + + // M += a*a.t() + inline void Rank1Add(const Vector3 &a) + { + v[0] += a.x*a.x; v[1] += a.x*a.y; v[2] += a.x*a.z; + v[3] += a.y*a.y; v[4] += a.y*a.z; + v[5] += a.z*a.z; + } + + // M -= a*a.t() + inline void Rank1Sub(const Vector3 &a) + { + v[0] -= a.x*a.x; v[1] -= a.x*a.y; v[2] -= a.x*a.z; + v[3] -= a.y*a.y; v[4] -= a.y*a.z; + v[5] -= a.z*a.z; + } +}; + +typedef SymMat3 SymMat3f; +typedef SymMat3 SymMat3d; + +template +inline Matrix3 operator*(const SymMat3& a, const SymMat3& b) +{ + #define AJB_ARBC(r,c) (a(r,0)*b(0,c)+a(r,1)*b(1,c)+a(r,2)*b(2,c)) + return Matrix3( + AJB_ARBC(0,0), AJB_ARBC(0,1), AJB_ARBC(0,2), + AJB_ARBC(1,0), AJB_ARBC(1,1), AJB_ARBC(1,2), + AJB_ARBC(2,0), AJB_ARBC(2,1), AJB_ARBC(2,2)); + #undef AJB_ARBC +} + +template +inline Matrix3 operator*(const Matrix3& a, const SymMat3& b) +{ + #define AJB_ARBC(r,c) (a(r,0)*b(0,c)+a(r,1)*b(1,c)+a(r,2)*b(2,c)) + return Matrix3( + AJB_ARBC(0,0), AJB_ARBC(0,1), AJB_ARBC(0,2), + AJB_ARBC(1,0), AJB_ARBC(1,1), AJB_ARBC(1,2), + AJB_ARBC(2,0), AJB_ARBC(2,1), AJB_ARBC(2,2)); + #undef AJB_ARBC +} + +//------------------------------------------------------------------------------------- +// ***** Angle + +// Cleanly representing the algebra of 2D rotations. +// The operations maintain the angle between -Pi and Pi, the same range as atan2. + +template +class Angle +{ +public: + enum AngularUnits + { + Radians = 0, + Degrees = 1 + }; + + Angle() : a(0) {} + + // Fix the range to be between -Pi and Pi + Angle(T a_, AngularUnits u = Radians) : a((u == Radians) ? a_ : a_*((T)MATH_DOUBLE_DEGREETORADFACTOR)) { FixRange(); } + + T Get(AngularUnits u = Radians) const { return (u == Radians) ? a : a*((T)MATH_DOUBLE_RADTODEGREEFACTOR); } + void Set(const T& x, AngularUnits u = Radians) { a = (u == Radians) ? x : x*((T)MATH_DOUBLE_DEGREETORADFACTOR); FixRange(); } + int Sign() const { if (a == 0) return 0; else return (a > 0) ? 1 : -1; } + T Abs() const { return (a > 0) ? a : -a; } + + bool operator== (const Angle& b) const { return a == b.a; } + bool operator!= (const Angle& b) const { return a != b.a; } +// bool operator< (const Angle& b) const { return a < a.b; } +// bool operator> (const Angle& b) const { return a > a.b; } +// bool operator<= (const Angle& b) const { return a <= a.b; } +// bool operator>= (const Angle& b) const { return a >= a.b; } +// bool operator= (const T& x) { a = x; FixRange(); } + + // These operations assume a is already between -Pi and Pi. + Angle& operator+= (const Angle& b) { a = a + b.a; FastFixRange(); return *this; } + Angle& operator+= (const T& x) { a = a + x; FixRange(); return *this; } + Angle operator+ (const Angle& b) const { Angle res = *this; res += b; return res; } + Angle operator+ (const T& x) const { Angle res = *this; res += x; return res; } + Angle& operator-= (const Angle& b) { a = a - b.a; FastFixRange(); return *this; } + Angle& operator-= (const T& x) { a = a - x; FixRange(); return *this; } + Angle operator- (const Angle& b) const { Angle res = *this; res -= b; return res; } + Angle operator- (const T& x) const { Angle res = *this; res -= x; return res; } + + T Distance(const Angle& b) { T c = fabs(a - b.a); return (c <= ((T)MATH_DOUBLE_PI)) ? c : ((T)MATH_DOUBLE_TWOPI) - c; } + +private: + + // The stored angle, which should be maintained between -Pi and Pi + T a; + + // Fixes the angle range to [-Pi,Pi], but assumes no more than 2Pi away on either side + inline void FastFixRange() + { + if (a < -((T)MATH_DOUBLE_PI)) + a += ((T)MATH_DOUBLE_TWOPI); + else if (a > ((T)MATH_DOUBLE_PI)) + a -= ((T)MATH_DOUBLE_TWOPI); + } + + // Fixes the angle range to [-Pi,Pi] for any given range, but slower then the fast method + inline void FixRange() + { + // do nothing if the value is already in the correct range, since fmod call is expensive + if (a >= -((T)MATH_DOUBLE_PI) && a <= ((T)MATH_DOUBLE_PI)) + return; + a = fmod(a,((T)MATH_DOUBLE_TWOPI)); + if (a < -((T)MATH_DOUBLE_PI)) + a += ((T)MATH_DOUBLE_TWOPI); + else if (a > ((T)MATH_DOUBLE_PI)) + a -= ((T)MATH_DOUBLE_TWOPI); + } +}; + + +typedef Angle Anglef; +typedef Angle Angled; + + +//------------------------------------------------------------------------------------- +// ***** Plane + +// Consists of a normal vector and distance from the origin where the plane is located. + +template +class Plane +{ +public: + Vector3 N; + T D; + + Plane() : D(0) {} + + // Normals must already be normalized + Plane(const Vector3& n, T d) : N(n), D(d) {} + Plane(T x, T y, T z, T d) : N(x,y,z), D(d) {} + + // construct from a point on the plane and the normal + Plane(const Vector3& p, const Vector3& n) : N(n), D(-(p * n)) {} + + // Find the point to plane distance. The sign indicates what side of the plane the point is on (0 = point on plane). + T TestSide(const Vector3& p) const + { + return (N.Dot(p)) + D; + } + + Plane Flipped() const + { + return Plane(-N, -D); + } + + void Flip() + { + N = -N; + D = -D; + } + + bool operator==(const Plane& rhs) const + { + return (this->D == rhs.D && this->N == rhs.N); + } +}; + +typedef Plane Planef; +typedef Plane Planed; + + +} // Namespace OVR + +#endif diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Kernel/OVR_Nullptr.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Kernel/OVR_Nullptr.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,150 @@ +/************************************************************************************ + +PublicHeader: OVR_Kernel.h +Filename : OVR_Nullptr.h +Content : Implements C++11 nullptr for the case that the compiler doesn't. +Created : June 19, 2014 +Notes : + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#ifndef OVR_Nullptr_h +#define OVR_Nullptr_h + +#pragma once + +#include "OVR_Types.h" + + +//----------------------------------------------------------------------------------- +// ***** OVR_HAVE_std_nullptr_t +// +// Identifies if includes std::nullptr_t. +// +#if !defined(OVR_HAVE_std_nullptr_t) && defined(OVR_CPP11_ENABLED) + #if defined(OVR_STDLIB_LIBCPP) + #define OVR_HAVE_std_nullptr_t 1 + #elif defined(OVR_STDLIB_LIBSTDCPP) + #if (__GLIBCXX__ >= 20110325) && (__GLIBCXX__ != 20110428) && (__GLIBCXX__ != 20120702) + #define OVR_HAVE_std_nullptr_t 1 + #endif + #elif defined(_MSC_VER) && (_MSC_VER >= 1600) // VS2010+ + #define OVR_HAVE_std_nullptr_t 1 + #elif defined(__clang__) + #define OVR_HAVE_std_nullptr_t 1 + #elif defined(OVR_CPP_GNUC) && (OVR_CC_VERSION >= 406) // GCC 4.6+ + #define OVR_HAVE_std_nullptr_t 1 + #endif +#endif + + +//----------------------------------------------------------------------------------- +// ***** nullptr / std::nullptr_t +// +// Declares and defines nullptr and related types. +// +#if defined(OVR_CPP_NO_NULLPTR) + namespace std + { + class nullptr_t + { + public: + template + operator T*() const + { return 0; } + + template + operator T C::*() const + { return 0; } + + #if OVR_CPP_NO_EXPLICIT_CONVERSION_OPERATORS + typedef void* (nullptr_t::*bool_)() const; // 4.12,p1. We can't portably use operator bool(){ return false; } because bool + operator bool_() const // is convertable to int which breaks other required functionality. + { return false; } + #else + operator bool() const + { return false; } + #endif + + private: + void operator&() const; // 5.2.10,p9 + }; + + inline nullptr_t nullptr_get() + { + nullptr_t n = { }; + return n; + } + + #if !defined(nullptr) + #define nullptr nullptr_get() + #endif + + } // namespace std + + + // 5.9,p2 p4 + // 13.6, p13 + template + inline bool operator==(T* pT, const std::nullptr_t) + { return pT == 0; } + + template + inline bool operator==(const std::nullptr_t, T* pT) + { return pT == 0; } + + template + inline bool operator==(const std::nullptr_t, T U::* pU) + { return pU == 0; } + + template + inline bool operator==(T U::* pTU, const std::nullptr_t) + { return pTU == 0; } + + inline bool operator==(const std::nullptr_t, const std::nullptr_t) + { return true; } + + inline bool operator!=(const std::nullptr_t, const std::nullptr_t) + { return false; } + + inline bool operator<(const std::nullptr_t, const std::nullptr_t) + { return false; } + + inline bool operator<=(const std::nullptr_t, const std::nullptr_t) + { return true; } + + inline bool operator>(const std::nullptr_t, const std::nullptr_t) + { return false; } + + inline bool operator>=(const std::nullptr_t, const std::nullptr_t) + { return true; } + + using std::nullptr_t; + using std::nullptr_get; + +// Some compilers natively support C++11 nullptr but the standard library being used +// doesn't declare std::nullptr_t, in which case we provide one ourselves. +#elif !defined(OVR_HAVE_std_nullptr_t) && !defined(OVR_CPP_NO_DECLTYPE) + namespace std { typedef decltype(nullptr) nullptr_t; } +#endif + + +#endif + diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Kernel/OVR_Observer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Kernel/OVR_Observer.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,457 @@ +/************************************************************************************ + +PublicHeader: Kernel +Filename : OVR_Observer.h +Content : Observer pattern +Created : June 20, 2014 +Author : Chris Taylor + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#ifndef OVR_Observer_h +#define OVR_Observer_h + +#include "OVR_Types.h" +#include "OVR_Atomic.h" +#include "OVR_RefCount.h" +#include "OVR_Delegates.h" +#include "OVR_Array.h" +#include "OVR_String.h" +#include "OVR_Hash.h" + +namespace OVR { + +template class Observer; +template class ObserverScope; +template class ObserverHash; + + +//----------------------------------------------------------------------------- +// Observer pattern + +// An Observer will observe a Subject. The Subject can emit callbacks that get +// serviced by the Observers. + +// The trickiest part of this is the shutdown code. +// To simplify shutdown, the Observer is a reference-counted object divorced +// from the handler that is called. To avoid misuse, the ObserverScope object +// is provided to ensure that the Shutdown() method is called when it goes out +// of scope. + +// The Observer<> class doubles as the subject class. +// To avoid misuse, assertions are added if a subject tries to observe, or if +// an observer tries to be watched. + +/* + Usage example: + + Say we want to invoke a handler with the signature: + + void MyHandler(int i, bool b); + + The corresponding delegate type is: + + typedef Delegate2 Handler; + + Note: The return value will be ignored for the Observer pattern. + + For this example there are two classes, one that emits events and another + that listens for events: +*/ + +/* + Event emitter example: + + class MyEmitter + { + ObserverScope TheSubject; + + public: + void ClearAllListeners() + { + TheSubject.ReleaseAll(); + } + + void CallListeners(int x, bool y) + { + TheSubject->Call(x, y); + } + + Observer* GetSubject() + { + return TheSubject; + } + }; +*/ + +/* + Event listener example: + + class MyListener + { + ObserverScope TheObserver; + + void OnEvent(int x, bool y) + { + // Handle event here + } + + public: + MyListener() + { + TheObserver.SetHandler( + Handler::FromMember(this) + ); + } + + void ClearListener() + { + TheObserver.ReleaseAll(); + } + + void ListenTo(Observer* emitter) + { + TheObserver->Observe(emitter); + } + }; +*/ + +/* + Usage example: + + MyListener listener; + MyEmitter emitter; + + // To listen to an emitter, + listener.ListenTo(emitter.GetSubject()); + + // To call the listeners, + emitter.CallListeners(22, true); +*/ + +template +class Observer : public RefCountBase< Observer > +{ + friend class ObserverScope; + friend class ObserverHash; + +public: + typedef Observer ThisType; + typedef DelegateT Handler; + +protected: + bool IsShutdown; // Flag to indicate that the object went out of scope + mutable Lock TheLock; // Lock to synchronize calls and shutdown + Array< Ptr< ThisType > > References; // List of observed or observing objects + Handler TheHandler; // Observer-only: Handler for callbacks + + Observer() : + IsShutdown(false) + { + TheHandler.Invalidate(); + } + Observer(Handler handler) : + IsShutdown(false), + TheHandler(handler) + { + } + ~Observer() + { + OVR_ASSERT(References.GetSizeI() == 0); + } + +public: + void SetHandler(Handler handler) + { + OVR_ASSERT(References.GetSizeI() == 0); + TheHandler = handler; + } + + // Release references and prevent further actions + void Shutdown() + { + Lock::Locker locker(&TheLock); + IsShutdown = true; + References.ClearAndRelease(); + } + + // Get count of references held + int GetSizeI() const + { + Lock::Locker locker(&TheLock); + return References.GetSizeI(); + } + + // Observe a subject + bool Observe(ThisType *subject) + { + OVR_ASSERT(TheHandler.IsValid()); + + if (!subject) + { + return false; + } + + Lock::Locker locker(&TheLock); + + if (IsShutdown) + { + return false; + } + + if (!subject->SubjectAddObserver(this)) + { + return false; + } + + References.PushBack(subject); + return true; + } + +protected: + // Subject function: AddObserver() + // Returns true if the observer was added + bool SubjectAddObserver(ThisType* observer) + { + OVR_ASSERT(!TheHandler.IsValid()); + + if (!observer) + { + return true; + } + + Lock::Locker locker(&TheLock); + + if (IsShutdown) + { + return false; + } + + const int count = References.GetSizeI(); + for (int i = 0; i < count; ++i) + { + if (References[i] == observer) + { + // Already watched + return true; + } + } + + References.PushBack(observer); + + return true; + } + +public: + // Subject function: Call() +#define OVR_OBSERVER_CALL_BODY(params) \ + bool callSuccess = false; \ + Lock::Locker locker(&TheLock); \ + int count = References.GetSizeI(); \ + for (int i = 0; i < count; ++i) \ + { \ + if (!References[i]->IsShutdown) \ + { \ + OVR_ASSERT(References[i]->TheHandler.IsValid()); \ + References[i]->TheHandler params; \ + callSuccess = true; \ + } \ + if (References[i]->IsShutdown) \ + { \ + References.RemoveAt(i); \ + --i; --count; \ + } \ + } \ + return callSuccess; + + // Call: Various parameter counts + // Returns true if a call was made + bool Call() + { + OVR_OBSERVER_CALL_BODY(()) + } + template + bool Call(Param1& p1) + { + OVR_OBSERVER_CALL_BODY((p1)) + } + template + bool Call(Param1* p1) + { + OVR_OBSERVER_CALL_BODY((p1)) + } + template + bool Call(Param1& p1, Param2& p2) + { + OVR_OBSERVER_CALL_BODY((p1, p2)) + } + template + bool Call(Param1* p1, Param2* p2) + { + OVR_OBSERVER_CALL_BODY((p1, p2)) + } + template + bool Call(Param1& p1, Param2& p2, Param3& p3) + { + OVR_OBSERVER_CALL_BODY((p1, p2, p3)) + } + template + bool Call(Param1* p1, Param2* p2, Param3* p3) + { + OVR_OBSERVER_CALL_BODY((p1, p2, p3)) + } + +#undef OVR_OBSERVER_CALL_BODY +}; + + +//----------------------------------------------------------------------------- +// ObserverScope + +// Scoped shutdown of the Observer object +template +class ObserverScope : public NewOverrideBase +{ + Ptr< Observer > TheObserver; + DelegateT TheHandler; + + void Shutdown() + { + if (TheObserver) + { + TheObserver->Shutdown(); + TheObserver.Clear(); + } + } + +public: + ObserverScope() + { + TheObserver = *new Observer; + } + ~ObserverScope() + { + Shutdown(); + } + + // Release all references and recreate it + void ReleaseAll() + { + Shutdown(); + TheObserver = *new Observer; + if (TheHandler.IsValid()) + { + TheObserver->SetHandler(TheHandler); + } + } + + void SetHandler(DelegateT handler) + { + TheHandler = handler; + TheObserver->SetHandler(handler); + } + + Observer* GetPtr() + { + return TheObserver.GetPtr(); + } + Observer* operator->() + { + return TheObserver.GetPtr(); + } + const Observer* operator->() const + { + return TheObserver.GetPtr(); + } + operator Observer*() + { + return TheObserver.GetPtr(); + } +}; + + +//----------------------------------------------------------------------------- +// ObserverHash + +// A hash containing Observers +template +class ObserverHash : public NewOverrideBase +{ +public: + ObserverHash() {} + ~ObserverHash() {Clear();} + void Clear() + { + Lock::Locker locker(&TheLock); + typename OVR::Hash< String, Ptr >, OVR::String::HashFunctor >::Iterator it = _Hash.Begin(); + for( it = _Hash.Begin(); it != _Hash.End(); ++it ) + { + Ptr > o = it->Second; + o->Shutdown(); + } + } + + Ptr > GetSubject(OVR::String key) + { + Lock::Locker locker(&TheLock); + Ptr > *o = _Hash.Get(key); + if (o) + return (*o); + return NULL; + } + + // Add handler to new observer with implicit creation of subject. + void AddObserverToSubject(OVR::String key, Observer *observer) + { + Lock::Locker locker(&TheLock); + Ptr > *subjectPtr = _Hash.Get(key); + + if (subjectPtr==NULL) + { + Ptr > subject = *new Observer(); + _Hash.Add(key, subject); + observer->Observe(subject); + } + else + { + observer->Observe(*subjectPtr); + } + } + + void RemoveSubject(OVR::String key) + { + Lock::Locker locker(&TheLock); + Ptr > *subjectPtr = _Hash.Get(key); + if (subjectPtr!=NULL) + { + (*subjectPtr)->Shutdown(); + _Hash.Remove(key); + } + } + +protected: + OVR::Hash< OVR::String, Ptr >, OVR::String::HashFunctor > _Hash; + Lock TheLock; // Lock to synchronize calls and shutdown +}; + + +} // namespace OVR + +#endif // OVR_Observer_h diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Kernel/OVR_RefCount.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Kernel/OVR_RefCount.cpp Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,111 @@ +/************************************************************************************ + +Filename : OVR_RefCount.cpp +Content : Reference counting implementation +Created : September 19, 2012 +Notes : + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#include "OVR_RefCount.h" +#include "OVR_Atomic.h" +#include "OVR_Log.h" + +namespace OVR { + +#ifdef OVR_CC_ARM +void* ReturnArg0(void* p) +{ + return p; +} +#endif + +// ***** Reference Count Base implementation + +RefCountImplCore::~RefCountImplCore() +{ + // RefCount can be either 1 or 0 here. + // 0 if Release() was properly called. + // 1 if the object was declared on stack or as an aggregate. + OVR_ASSERT(RefCount <= 1); +} + +#ifdef OVR_BUILD_DEBUG +void RefCountImplCore::reportInvalidDelete(void *pmem) +{ + OVR_DEBUG_LOG( + ("Invalid delete call on ref-counted object at %p. Please use Release()", pmem)); + OVR_ASSERT(0); +} +#endif + +RefCountNTSImplCore::~RefCountNTSImplCore() +{ + // RefCount can be either 1 or 0 here. + // 0 if Release() was properly called. + // 1 if the object was declared on stack or as an aggregate. + OVR_ASSERT(RefCount <= 1); +} + +#ifdef OVR_BUILD_DEBUG +void RefCountNTSImplCore::reportInvalidDelete(void *pmem) +{ + OVR_DEBUG_LOG( + ("Invalid delete call on ref-counted object at %p. Please use Release()", pmem)); + OVR_ASSERT(0); +} +#endif + + +// *** Thread-Safe RefCountImpl + +void RefCountImpl::AddRef() +{ + AtomicOps::ExchangeAdd_NoSync(&RefCount, 1); +} +void RefCountImpl::Release() +{ + if ((AtomicOps::ExchangeAdd_NoSync(&RefCount, -1) - 1) == 0) + delete this; +} + +// *** Thread-Safe RefCountVImpl w/virtual AddRef/Release + +void RefCountVImpl::AddRef() +{ + AtomicOps::ExchangeAdd_NoSync(&RefCount, 1); +} +void RefCountVImpl::Release() +{ + if ((AtomicOps::ExchangeAdd_NoSync(&RefCount, -1) - 1) == 0) + delete this; +} + +// *** NON-Thread-Safe RefCountImpl + +void RefCountNTSImpl::Release() const +{ + RefCount--; + if (RefCount == 0) + delete this; +} + + +} // OVR diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Kernel/OVR_RefCount.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Kernel/OVR_RefCount.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,565 @@ +/************************************************************************************ + +PublicHeader: Kernel +Filename : OVR_RefCount.h +Content : Reference counting implementation headers +Created : September 19, 2012 +Notes : + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#ifndef OVR_RefCount_h +#define OVR_RefCount_h + +#include "OVR_Types.h" +#include "OVR_Allocator.h" + +namespace OVR { + +//----------------------------------------------------------------------------------- +// ***** Reference Counting + +// There are three types of reference counting base classes: +// +// RefCountBase - Provides thread-safe reference counting (Default). +// RefCountBaseNTS - Non Thread Safe version of reference counting. + + +// ***** Declared classes + +template +class RefCountBase; +template +class RefCountBaseNTS; + +class RefCountImpl; +class RefCountNTSImpl; + + +//----------------------------------------------------------------------------------- +// ***** Implementation For Reference Counting + +// RefCountImplCore holds RefCount value and defines a few utility +// functions shared by all implementations. + +class RefCountImplCore +{ +protected: + volatile int RefCount; + +public: + // RefCountImpl constructor always initializes RefCount to 1 by default. + OVR_FORCE_INLINE RefCountImplCore() : RefCount(1) { } + + // Need virtual destructor + // This: 1. Makes sure the right destructor's called. + // 2. Makes us have VTable, necessary if we are going to have format needed by InitNewMem() + virtual ~RefCountImplCore(); + + // Debug method only. + int GetRefCount() const { return RefCount; } + + // This logic is used to detect invalid 'delete' calls of reference counted + // objects. Direct delete calls are not allowed on them unless they come in + // internally from Release. +#ifdef OVR_BUILD_DEBUG + static void OVR_CDECL reportInvalidDelete(void *pmem); + inline static void checkInvalidDelete(RefCountImplCore *pmem) + { + if (pmem->RefCount != 0) + reportInvalidDelete(pmem); + } +#else + inline static void checkInvalidDelete(RefCountImplCore *) { } +#endif + + // Base class ref-count content should not be copied. + void operator = (const RefCountImplCore &) { } +}; + +class RefCountNTSImplCore +{ +protected: + mutable int RefCount; + +public: + // RefCountImpl constructor always initializes RefCount to 1 by default. + OVR_FORCE_INLINE RefCountNTSImplCore() : RefCount(1) { } + + // Need virtual destructor + // This: 1. Makes sure the right destructor's called. + // 2. Makes us have VTable, necessary if we are going to have format needed by InitNewMem() + virtual ~RefCountNTSImplCore(); + + // Debug method only. + int GetRefCount() const { return RefCount; } + + // This logic is used to detect invalid 'delete' calls of reference counted + // objects. Direct delete calls are not allowed on them unless they come in + // internally from Release. +#ifdef OVR_BUILD_DEBUG + static void OVR_CDECL reportInvalidDelete(void *pmem); + OVR_FORCE_INLINE static void checkInvalidDelete(RefCountNTSImplCore *pmem) + { + if (pmem->RefCount != 0) + reportInvalidDelete(pmem); + } +#else + OVR_FORCE_INLINE static void checkInvalidDelete(RefCountNTSImplCore *) { } +#endif + + // Base class ref-count content should not be copied. + void operator = (const RefCountNTSImplCore &) { } +}; + + + +// RefCountImpl provides Thread-Safe implementation of reference counting, so +// it should be used by default in most places. + +class RefCountImpl : public RefCountImplCore +{ +public: + // Thread-Safe Ref-Count Implementation. + void AddRef(); + void Release(); +}; + +// RefCountVImpl provides Thread-Safe implementation of reference counting, plus, +// virtual AddRef and Release. + +class RefCountVImpl : virtual public RefCountImplCore +{ +public: + // Thread-Safe Ref-Count Implementation. + virtual void AddRef(); + virtual void Release(); +}; + + +// RefCountImplNTS provides Non-Thread-Safe implementation of reference counting, +// which is slightly more efficient since it doesn't use atomics. + +class RefCountNTSImpl : public RefCountNTSImplCore +{ +public: + OVR_FORCE_INLINE void AddRef() const { RefCount++; } + void Release() const; +}; + + + +// RefCountBaseStatImpl<> is a common class that adds new/delete override with Stat tracking +// to the reference counting implementation. Base must be one of the RefCountImpl classes. + +template +class RefCountBaseStatImpl : public Base +{ +public: + RefCountBaseStatImpl() { } + + // *** Override New and Delete + + // DOM-IGNORE-BEGIN + // Undef new temporarily if it is being redefined +#ifdef OVR_DEFINE_NEW +#undef new +#endif + +#ifdef OVR_BUILD_DEBUG + // Custom check used to detect incorrect calls of 'delete' on ref-counted objects. + #define OVR_REFCOUNTALLOC_CHECK_DELETE(class_name, p) \ + do {if (p) Base::checkInvalidDelete((class_name*)p); } while(0) +#else + #define OVR_REFCOUNTALLOC_CHECK_DELETE(class_name, p) +#endif + + // Redefine all new & delete operators. + OVR_MEMORY_REDEFINE_NEW_IMPL(Base, OVR_REFCOUNTALLOC_CHECK_DELETE) + +#undef OVR_REFCOUNTALLOC_CHECK_DELETE + +#ifdef OVR_DEFINE_NEW +#define new OVR_DEFINE_NEW +#endif + // OVR_BUILD_DEFINE_NEW + // DOM-IGNORE-END +}; + + +template +class RefCountBaseStatVImpl : virtual public Base +{ +public: + RefCountBaseStatVImpl() { } + + // *** Override New and Delete + + // DOM-IGNORE-BEGIN + // Undef new temporarily if it is being redefined +#ifdef OVR_DEFINE_NEW +#undef new +#endif + +#define OVR_REFCOUNTALLOC_CHECK_DELETE(class_name, p) + + // Redefine all new & delete operators. + OVR_MEMORY_REDEFINE_NEW_IMPL(Base, OVR_REFCOUNTALLOC_CHECK_DELETE) + +#undef OVR_REFCOUNTALLOC_CHECK_DELETE + +#ifdef OVR_DEFINE_NEW +#define new OVR_DEFINE_NEW +#endif + // OVR_BUILD_DEFINE_NEW + // DOM-IGNORE-END +}; + + + +//----------------------------------------------------------------------------------- +// *** End user RefCountBase<> classes + + +// RefCountBase is a base class for classes that require thread-safe reference +// counting; it also overrides the new and delete operators to use MemoryHeap. +// +// Reference counted objects start out with RefCount value of 1. Further lifetime +// management is done through the AddRef() and Release() methods, typically +// hidden by Ptr<>. + +template +class RefCountBase : public RefCountBaseStatImpl +{ +public: + // Constructor. + OVR_FORCE_INLINE RefCountBase() : RefCountBaseStatImpl() { } +}; + +// RefCountBaseV is the same as RefCountBase but with virtual AddRef/Release + +template +class RefCountBaseV : virtual public RefCountBaseStatVImpl +{ +public: + // Constructor. + OVR_FORCE_INLINE RefCountBaseV() : RefCountBaseStatVImpl() { } +}; + + +// RefCountBaseNTS is a base class for classes that require Non-Thread-Safe reference +// counting; it also overrides the new and delete operators to use MemoryHeap. +// This class should only be used if all pointers to it are known to be assigned, +// destroyed and manipulated within one thread. +// +// Reference counted objects start out with RefCount value of 1. Further lifetime +// management is done through the AddRef() and Release() methods, typically +// hidden by Ptr<>. + +template +class RefCountBaseNTS : public RefCountBaseStatImpl +{ +public: + // Constructor. + OVR_FORCE_INLINE RefCountBaseNTS() : RefCountBaseStatImpl() { } +}; + +//----------------------------------------------------------------------------------- +// ***** Pickable template pointer +enum PickType { PickValue }; + +template +class Pickable +{ +public: + Pickable() : pV(NULL) {} + explicit Pickable(T* p) : pV(p) {} + Pickable(T* p, PickType) : pV(p) + { + OVR_ASSERT(pV); + if (pV) + pV->AddRef(); + } + template + Pickable(const Pickable& other) : pV(other.GetPtr()) {} + +public: + Pickable& operator =(const Pickable& other) + { + OVR_ASSERT(pV == NULL); + pV = other.pV; + // Extra check. + //other.pV = NULL; + return *this; + } + +public: + T* GetPtr() const { return pV; } + T* operator->() const + { + return pV; + } + T& operator*() const + { + OVR_ASSERT(pV); + return *pV; + } + +private: + T* pV; +}; + +template +OVR_FORCE_INLINE +Pickable MakePickable(T* p) +{ + return Pickable(p); +} + +//----------------------------------------------------------------------------------- +// ***** Ref-Counted template pointer + +// Automatically AddRefs and Releases interfaces + +void* ReturnArg0(void* p); + +template +class Ptr +{ +#ifdef OVR_CC_ARM + static C* ReturnArg(void* p) { return (C*)ReturnArg0(p); } +#endif + +protected: + C *pObject; + +public: + + // Constructors + OVR_FORCE_INLINE Ptr() : pObject(0) + { } +#ifdef OVR_CC_ARM + OVR_FORCE_INLINE Ptr(C &robj) : pObject(ReturnArg(&robj)) +#else + OVR_FORCE_INLINE Ptr(C &robj) : pObject(&robj) +#endif + { } + OVR_FORCE_INLINE Ptr(Pickable v) : pObject(v.GetPtr()) + { + // No AddRef() on purpose. + } + OVR_FORCE_INLINE Ptr(Ptr& other, PickType) : pObject(other.pObject) + { + other.pObject = NULL; + // No AddRef() on purpose. + } + OVR_FORCE_INLINE Ptr(C *pobj) + { + if (pobj) pobj->AddRef(); + pObject = pobj; + } + OVR_FORCE_INLINE Ptr(const Ptr &src) + { + if (src.pObject) src.pObject->AddRef(); + pObject = src.pObject; + } + + template + OVR_FORCE_INLINE Ptr(Ptr &src) + { + if (src) src->AddRef(); + pObject = src; + } + template + OVR_FORCE_INLINE Ptr(Pickable v) : pObject(v.GetPtr()) + { + // No AddRef() on purpose. + } + + // Destructor + OVR_FORCE_INLINE ~Ptr() + { + if (pObject) pObject->Release(); + } + + // Compares + OVR_FORCE_INLINE bool operator == (const Ptr &other) const { return pObject == other.pObject; } + OVR_FORCE_INLINE bool operator != (const Ptr &other) const { return pObject != other.pObject; } + + OVR_FORCE_INLINE bool operator == (C *pother) const { return pObject == pother; } + OVR_FORCE_INLINE bool operator != (C *pother) const { return pObject != pother; } + + + OVR_FORCE_INLINE bool operator < (const Ptr &other) const { return pObject < other.pObject; } + + // Assignment + template + OVR_FORCE_INLINE const Ptr& operator = (const Ptr &src) + { + // By design we don't check for src == pObject, as we don't expect that to be the case the large majority of the time. + if (src) src->AddRef(); + if (pObject) pObject->Release(); + pObject = src; + return *this; + } + // Specialization + OVR_FORCE_INLINE const Ptr& operator = (const Ptr &src) + { + if (src) src->AddRef(); + if (pObject) pObject->Release(); + pObject = src; + return *this; + } + + OVR_FORCE_INLINE const Ptr& operator = (C *psrc) + { + if (psrc) psrc->AddRef(); + if (pObject) pObject->Release(); + pObject = psrc; + return *this; + } + OVR_FORCE_INLINE const Ptr& operator = (C &src) + { + if (pObject) pObject->Release(); + pObject = &src; + return *this; + } + OVR_FORCE_INLINE Ptr& operator = (Pickable src) + { + return Pick(src); + } + template + OVR_FORCE_INLINE Ptr& operator = (Pickable src) + { + return Pick(src); + } + + // Set Assignment + template + OVR_FORCE_INLINE Ptr& SetPtr(const Ptr &src) + { + if (src) src->AddRef(); + if (pObject) pObject->Release(); + pObject = src; + return *this; + } + // Specialization + OVR_FORCE_INLINE Ptr& SetPtr(const Ptr &src) + { + if (src) src->AddRef(); + if (pObject) pObject->Release(); + pObject = src; + return *this; + } + + OVR_FORCE_INLINE Ptr& SetPtr(C *psrc) + { + if (psrc) psrc->AddRef(); + if (pObject) pObject->Release(); + pObject = psrc; + return *this; + } + OVR_FORCE_INLINE Ptr& SetPtr(C &src) + { + if (pObject) pObject->Release(); + pObject = &src; + return *this; + } + OVR_FORCE_INLINE Ptr& SetPtr(Pickable src) + { + return Pick(src); + } + + // Nulls ref-counted pointer without decrement + OVR_FORCE_INLINE void NullWithoutRelease() + { + pObject = 0; + } + + // Clears the pointer to the object + OVR_FORCE_INLINE void Clear() + { + if (pObject) pObject->Release(); + pObject = 0; + } + + // Obtain pointer reference directly, for D3D interfaces + OVR_FORCE_INLINE C*& GetRawRef() { return pObject; } + + // Access Operators + OVR_FORCE_INLINE C* GetPtr() const { return pObject; } + OVR_FORCE_INLINE C& operator * () const { return *pObject; } + OVR_FORCE_INLINE C* operator -> () const { return pObject; } + // Conversion + OVR_FORCE_INLINE operator C* () const { return pObject; } + + // Pickers. + + // Pick a value. + OVR_FORCE_INLINE Ptr& Pick(Ptr& other) + { + if (&other != this) + { + if (pObject) pObject->Release(); + pObject = other.pObject; + other.pObject = 0; + } + + return *this; + } + + OVR_FORCE_INLINE Ptr& Pick(Pickable v) + { + if (v.GetPtr() != pObject) + { + if (pObject) pObject->Release(); + pObject = v.GetPtr(); + } + + return *this; + } + + template + OVR_FORCE_INLINE Ptr& Pick(Pickable v) + { + if (v.GetPtr() != pObject) + { + if (pObject) pObject->Release(); + pObject = v.GetPtr(); + } + + return *this; + } + + OVR_FORCE_INLINE Ptr& Pick(C* p) + { + if (p != pObject) + { + if (pObject) pObject->Release(); + pObject = p; + } + + return *this; + } +}; + +} // OVR + +#endif diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Kernel/OVR_SharedMemory.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Kernel/OVR_SharedMemory.cpp Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,691 @@ +/************************************************************************************ + +Filename : OVR_SharedMemory.cpp +Content : Inter-process shared memory subsystem +Created : June 1, 2014 +Notes : + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#include "OVR_SharedMemory.h" +#include "OVR_Atomic.h" +#include "OVR_Log.h" +#include "OVR_String.h" +#include "OVR_Array.h" + +#if defined(OVR_OS_WIN32) && !defined(OVR_FAKE_SHAREDMEMORY) +#include // ConvertStringSecurityDescriptorToSecurityDescriptor +#endif // OVR_OS_WIN32 + +#if (defined(OVR_OS_LINUX) || defined(OVR_OS_MAC)) && !defined(OVR_FAKE_SHAREDMEMORY) +#include // shm_open(), mmap() +#include // error results for mmap +#include // mode constants +#include // O_ constants +#include // close() +#endif // OVR_OS_LINUX + +OVR_DEFINE_SINGLETON(OVR::SharedMemoryFactory); + +namespace OVR { + + + //// Fake version + +#if defined(OVR_FAKE_SHAREDMEMORY) + + class FakeMemoryBlock : public RefCountBase + { + String Name; + char* Data; + int SizeBytes; + int References; + + public: + FakeMemoryBlock(const String& name, int size) : + Name(name), + Data(NULL), + SizeBytes(size), + References(1) + { + Data = new char[SizeBytes]; + } + ~FakeMemoryBlock() + { + delete[] Data; + } + + bool IsNamed(const String& name) + { + return Name.CompareNoCase(name) == 0; + } + void* GetData() + { + return Data; + } + int GetSizeI() + { + return SizeBytes; + } + void IncrementReferences() + { + ++References; + } + bool DecrementReferences() + { + return --References <= 0; + } + }; + + class SharedMemoryInternal : public NewOverrideBase + { + public: + void* FileView; + Ptr Block; + + void Close(); + + SharedMemoryInternal(FakeMemoryBlock* block) : + Block(block) + { + FileView = Block->GetData(); + } + ~SharedMemoryInternal() + { + Close(); + } + + static SharedMemoryInternal* CreateSharedMemory(const SharedMemory::OpenParameters& params); + }; + + + //// FakeMemoryManager + + class FakeMemoryManager : public NewOverrideBase, public SystemSingletonBase + { + OVR_DECLARE_SINGLETON(FakeMemoryManager); + + Lock FakeLock; + Array< Ptr > FakeArray; + + public: + SharedMemoryInternal* Open(const char *name, int bytes, bool openOnly) + { + Lock::Locker locker(&FakeLock); + + const int count = FakeArray.GetSizeI(); + for (int ii = 0; ii < count; ++ii) + { + if (FakeArray[ii]->IsNamed(name)) + { + FakeArray[ii]->IncrementReferences(); + return new SharedMemoryInternal(FakeArray[ii]); + } + } + + if (openOnly) + { + return NULL; + } + + Ptr data = *new FakeMemoryBlock(name, bytes); + FakeArray.PushBack(data); + return new SharedMemoryInternal(data); + } + + void Free(FakeMemoryBlock* block) + { + Lock::Locker locker(&FakeLock); + + const int count = FakeArray.GetSizeI(); + for (int ii = 0; ii < count; ++ii) + { + if (FakeArray[ii].GetPtr() == block) + { + // If the reference count hit zero, + if (FakeArray[ii]->DecrementReferences()) + { + // Toast + FakeArray.RemoveAtUnordered(ii); + } + break; + } + } + } + }; + + FakeMemoryManager::FakeMemoryManager() + { + PushDestroyCallbacks(); + } + + FakeMemoryManager::~FakeMemoryManager() + { + OVR_ASSERT(FakeArray.GetSizeI() == 0); + } + + void FakeMemoryManager::OnSystemDestroy() + { + delete this; + } + + +} // namespace OVR + +OVR_DEFINE_SINGLETON(FakeMemoryManager); + +namespace OVR { + + +void SharedMemoryInternal::Close() +{ + FakeMemoryManager::GetInstance()->Free(Block); + Block.Clear(); +} + +SharedMemoryInternal* SharedMemoryInternal::CreateSharedMemory(const SharedMemory::OpenParameters& params) +{ + return FakeMemoryManager::GetInstance()->Open(params.globalName, params.minSizeBytes, params.openMode == SharedMemory::OpenMode_OpenOnly); +} + +#endif + + +//// Windows version + +#if defined(OVR_OS_WIN32) && !defined(OVR_FAKE_SHAREDMEMORY) + +#pragma comment(lib, "advapi32.lib") + +// Hidden implementation class for OS-specific behavior +class SharedMemoryInternal : public NewOverrideBase +{ +public: + HANDLE FileMapping; + void* FileView; + + SharedMemoryInternal(HANDLE fileMapping, void* fileView) : + FileMapping(fileMapping), + FileView(fileView) + { + } + + ~SharedMemoryInternal() + { + // If file view is set, + if (FileView) + { + UnmapViewOfFile(FileView); + FileView = NULL; + } + + // If file mapping is set, + if (FileMapping != NULL) + { + CloseHandle(FileMapping); + FileMapping = NULL; + } + } + + static SharedMemoryInternal* DoFileMap(HANDLE hFileMapping, const char* fileName, bool openReadOnly, int minSize); + static SharedMemoryInternal* AttemptOpenSharedMemory(const char* fileName, int minSize, bool openReadOnly); + static SharedMemoryInternal* AttemptCreateSharedMemory(const char* fileName, int minSize, bool openReadOnly, bool allowRemoteWrite); + static SharedMemoryInternal* CreateSharedMemory(const SharedMemory::OpenParameters& params); +}; + +SharedMemoryInternal* SharedMemoryInternal::DoFileMap(HANDLE hFileMapping, const char* fileName, bool openReadOnly, int minSize) +{ + // Interpret the access mode as a map desired access code + DWORD mapDesiredAccess = openReadOnly ? FILE_MAP_READ : FILE_MAP_WRITE; + + // Map view of the file to this process + void* pFileView = MapViewOfFile(hFileMapping, mapDesiredAccess, 0, 0, minSize); + + // If mapping could not be created, + if (!pFileView) + { + CloseHandle(hFileMapping); + + OVR_DEBUG_LOG(("[SharedMemory] FAILURE: Unable to map view of file for %s error code = %d", fileName, GetLastError())); + OVR_UNUSED(fileName); + return NULL; + } + + // Create internal representation + SharedMemoryInternal* pimple = new SharedMemoryInternal(hFileMapping, pFileView); + + // If memory allocation fails, + if (!pimple) + { + UnmapViewOfFile(pFileView); + CloseHandle(hFileMapping); + + OVR_DEBUG_LOG(("[SharedMemory] FAILURE: Out of memory")); + return NULL; + } + + return pimple; +} + +SharedMemoryInternal* SharedMemoryInternal::AttemptOpenSharedMemory(const char* fileName, int minSize, bool openReadOnly) +{ + // Interpret the access mode as a map desired access code + DWORD mapDesiredAccess = openReadOnly ? FILE_MAP_READ : FILE_MAP_WRITE; + + // Open file mapping + HANDLE hFileMapping = OpenFileMappingA(mapDesiredAccess, TRUE, fileName); + + // If file was mapped unsuccessfully, + if (NULL == hFileMapping) + { + OVR_DEBUG_LOG(("[SharedMemory] WARNING: Unable to open file mapping for %s error code = %d (not necessarily bad)", fileName, GetLastError())); + return NULL; + } + + // Map the file + return DoFileMap(hFileMapping, fileName, openReadOnly, minSize); +} + +SharedMemoryInternal* SharedMemoryInternal::AttemptCreateSharedMemory(const char* fileName, int minSize, bool openReadOnly, bool allowRemoteWrite) +{ + // Prepare a SECURITY_ATTRIBUTES object + SECURITY_ATTRIBUTES security; + ZeroMemory(&security, sizeof(security)); + security.nLength = sizeof(security); + + // Security descriptor by DACL strings: + // ACE strings grant Allow(A), Object/Contains Inheritance (OICI) of: + // + Grant All (GA) to System (SY) + // + Grant All (GA) to Built-in Administrators (BA) + // + Grant Read-Only (GR) or Read-Write (GWGR) to Interactive Users (IU) - ie. games + static const char* DACLString_ReadOnly = "D:P(A;OICI;GA;;;SY)(A;OICI;GA;;;BA)(A;OICI;GR;;;IU)"; + static const char* DACLString_ReadWrite = "D:P(A;OICI;GA;;;SY)(A;OICI;GA;;;BA)(A;OICI;GWGR;;;IU)"; + + // Select the remote process access mode + const char* remoteAccessString = + allowRemoteWrite ? DACLString_ReadWrite : DACLString_ReadOnly; + + // Attempt to convert access string to security attributes + // Note: This will allocate the security descriptor with LocalAlloc() and must be freed later + BOOL bConvertOkay = ConvertStringSecurityDescriptorToSecurityDescriptorA( + remoteAccessString, SDDL_REVISION_1, &security.lpSecurityDescriptor, NULL); + + // If conversion fails, + if (!bConvertOkay) + { + OVR_DEBUG_LOG(("[SharedMemory] FAILURE: Unable to convert access string, error code = %d", GetLastError())); + return NULL; + } + + // Interpret the access mode as a page protection code + int pageProtectCode = openReadOnly ? PAGE_READONLY : PAGE_READWRITE; + + // Attempt to create a file mapping + HANDLE hFileMapping = CreateFileMappingA(INVALID_HANDLE_VALUE, // From page file + &security, // Security attributes + pageProtectCode, // Read-only? + 0, // High word for size = 0 + minSize, // Low word for size + fileName); // Name of global shared memory file + + // Free the security descriptor buffer + LocalFree(security.lpSecurityDescriptor); + + // If mapping could not be created, + if (NULL == hFileMapping) + { + OVR_DEBUG_LOG(("[SharedMemory] FAILURE: Unable to create file mapping for %s error code = %d", fileName, GetLastError())); + return NULL; + } + +#ifndef OVR_ALLOW_CREATE_FILE_MAPPING_IF_EXISTS + // If the file mapping already exists, + if (GetLastError() == ERROR_ALREADY_EXISTS) + { + CloseHandle(hFileMapping); + + OVR_DEBUG_LOG(("[SharedMemory] FAILURE: File mapping at %s already exists", fileName)); + return NULL; + } +#endif + + // Map the file + return DoFileMap(hFileMapping, fileName, openReadOnly, minSize); +} + +SharedMemoryInternal* SharedMemoryInternal::CreateSharedMemory(const SharedMemory::OpenParameters& params) +{ + SharedMemoryInternal* retval = NULL; + + // Construct the file mapping name in a Windows-specific way + OVR::String fileMappingName = params.globalName; + const char *fileName = fileMappingName.ToCStr(); + + // Is being opened read-only? + const bool openReadOnly = (params.accessMode == SharedMemory::AccessMode_ReadOnly); + + // Try up to 3 times to reduce low-probability failures: + static const int ATTEMPTS_MAX = 3; + for (int attempts = 0; attempts < ATTEMPTS_MAX; ++attempts) + { + // If opening should be attempted first, + if (params.openMode != SharedMemory::OpenMode_CreateOnly) + { + // Attempt to open a shared memory map + retval = AttemptOpenSharedMemory(fileName, params.minSizeBytes, openReadOnly); + + // If successful, + if (retval) + { + // Done! + break; + } + } + + // If creating the shared memory is also acceptable, + if (params.openMode != SharedMemory::OpenMode_OpenOnly) + { + // Interpret create mode + const bool allowRemoteWrite = (params.remoteMode == SharedMemory::RemoteMode_ReadWrite); + + // Attempt to create a shared memory map + retval = AttemptCreateSharedMemory(fileName, params.minSizeBytes, openReadOnly, allowRemoteWrite); + + // If successful, + if (retval) + { + // Done! + break; + } + } + } // Re-attempt create/open + + // Note: On Windows the initial contents of the region are guaranteed to be zero. + return retval; +} + +#endif // OVR_OS_WIN32 + + +#if (defined(OVR_OS_LINUX) || defined(OVR_OS_MAC)) && !defined(OVR_FAKE_SHAREDMEMORY) + +// Hidden implementation class for OS-specific behavior +class SharedMemoryInternal +{ +public: + int FileMapping; + void* FileView; + int FileSize; + + SharedMemoryInternal(int fileMapping, void* fileView, int fileSize) : + FileMapping(fileMapping), + FileView(fileView), + FileSize(fileSize) + { + } + + ~SharedMemoryInternal() + { + // If file view is set, + if (FileView) + { + munmap(FileView, FileSize); + FileView = MAP_FAILED; + } + + // If file mapping is set, + if (FileMapping >= 0) + { + close(FileMapping); + FileMapping = -1; + } + } + + static SharedMemoryInternal* DoFileMap(int hFileMapping, const char* fileName, bool openReadOnly, int minSize); + static SharedMemoryInternal* AttemptOpenSharedMemory(const char* fileName, int minSize, bool openReadOnly); + static SharedMemoryInternal* AttemptCreateSharedMemory(const char* fileName, int minSize, bool openReadOnly, bool allowRemoteWrite); + static SharedMemoryInternal* CreateSharedMemory(const SharedMemory::OpenParameters& params); +}; + +SharedMemoryInternal* SharedMemoryInternal::DoFileMap(int hFileMapping, const char* fileName, bool openReadOnly, int minSize) +{ + // Calculate the required flags based on read/write mode + int prot = openReadOnly ? PROT_READ : (PROT_READ|PROT_WRITE); + + // Map the file view + void* pFileView = mmap(NULL, minSize, prot, MAP_SHARED, hFileMapping, 0); + + if (pFileView == MAP_FAILED) + { + close(hFileMapping); + + OVR_DEBUG_LOG(("[SharedMemory] FAILURE: Unable to map view of file for %s error code = %d", fileName, errno)); + OVR_UNUSED(fileName); + return NULL; + } + + // Create internal representation + SharedMemoryInternal* pimple = new SharedMemoryInternal(hFileMapping, pFileView, minSize); + + // If memory allocation fails, + if (!pimple) + { + munmap(pFileView, minSize); + close(hFileMapping); + + OVR_DEBUG_LOG(("[SharedMemory] FAILURE: Out of memory")); + return NULL; + } + + return pimple; +} + +SharedMemoryInternal* SharedMemoryInternal::AttemptOpenSharedMemory(const char* fileName, int minSize, bool openReadOnly) +{ + // Calculate permissions and flags based on read/write mode + int flags = openReadOnly ? O_RDONLY : O_RDWR; + int perms = openReadOnly ? S_IRUSR : (S_IRUSR | S_IWUSR); + + // Attempt to open the shared memory file + int hFileMapping = shm_open(fileName, flags, perms); + + // If file was not opened successfully, + if (hFileMapping < 0) + { + OVR_DEBUG_LOG(("[SharedMemory] WARNING: Unable to open file mapping for %s error code = %d (not necessarily bad)", fileName, errno)); + return NULL; + } + + // Map the file + return DoFileMap(hFileMapping, fileName, openReadOnly, minSize); +} + +SharedMemoryInternal* SharedMemoryInternal::AttemptCreateSharedMemory(const char* fileName, int minSize, bool openReadOnly, bool allowRemoteWrite) +{ + // Create mode + // Note: Cannot create the shared memory file read-only because then ftruncate() will fail. + int flags = O_CREAT | O_RDWR; + +#ifndef OVR_ALLOW_CREATE_FILE_MAPPING_IF_EXISTS + // Require exclusive access when creating (seems like a good idea without trying it yet..) + if (shm_unlink(fileName) < 0) + { + OVR_DEBUG_LOG(("[SharedMemory] WARNING: Unable to unlink shared memory file %s error code = %d", fileName, errno)); + } + flags |= O_EXCL; +#endif + + // Set own read/write permissions + int perms = openReadOnly ? S_IRUSR : (S_IRUSR|S_IWUSR); + + // Allow other users to read/write the shared memory file + perms |= allowRemoteWrite ? (S_IWGRP|S_IWOTH|S_IRGRP|S_IROTH) : (S_IRGRP|S_IROTH); + + // Attempt to open the shared memory file + int hFileMapping = shm_open(fileName, flags, perms); + + // If file was not opened successfully, + if (hFileMapping < 0) + { + OVR_DEBUG_LOG(("[SharedMemory] FAILURE: Unable to create file mapping for %s error code = %d", fileName, errno)); + return NULL; + } + + int truncRes = ftruncate(hFileMapping, minSize); + + // If file was not opened successfully, + if (truncRes < 0) + { + close(hFileMapping); + OVR_DEBUG_LOG(("[SharedMemory] FAILURE: Unable to truncate file for %s to %d error code = %d", fileName, minSize, errno)); + return NULL; + } + + // Map the file + return DoFileMap(hFileMapping, fileName, openReadOnly, minSize); +} + +SharedMemoryInternal* SharedMemoryInternal::CreateSharedMemory(const SharedMemory::OpenParameters& params) +{ + SharedMemoryInternal* retval = NULL; + + // Construct the file mapping name in a Linux-specific way + OVR::String fileMappingName = "/"; + fileMappingName += params.globalName; + const char *fileName = fileMappingName.ToCStr(); + + // Is being opened read-only? + const bool openReadOnly = (params.accessMode == SharedMemory::AccessMode_ReadOnly); + + // Try up to 3 times to reduce low-probability failures: + static const int ATTEMPTS_MAX = 3; + for (int attempts = 0; attempts < ATTEMPTS_MAX; ++attempts) + { + // If opening should be attempted first, + if (params.openMode != SharedMemory::OpenMode_CreateOnly) + { + // Attempt to open a shared memory map + retval = AttemptOpenSharedMemory(fileName, params.minSizeBytes, openReadOnly); + + // If successful, + if (retval) + { + // Done! + break; + } + } + + // If creating the shared memory is also acceptable, + if (params.openMode != SharedMemory::OpenMode_OpenOnly) + { + // Interpret create mode + const bool allowRemoteWrite = (params.remoteMode == SharedMemory::RemoteMode_ReadWrite); + + // Attempt to create a shared memory map + retval = AttemptCreateSharedMemory(fileName, params.minSizeBytes, openReadOnly, allowRemoteWrite); + + // If successful, + if (retval) + { + // Done! + break; + } + } + } // Re-attempt create/open + + // Note: On Windows the initial contents of the region are guaranteed to be zero. + return retval; +} + +#endif // OVR_OS_LINUX + + +//// SharedMemory + +SharedMemory::SharedMemory(int size, void* data, SharedMemoryInternal* pInternal) : + Size(size), + Data(data), + Internal(pInternal) +{ +} +// Call close when it goes out of scope +SharedMemory::~SharedMemory() +{ + Close(); + delete Internal; +} + +void SharedMemory::Close() +{ + if (Internal) + { + delete Internal; + Internal = NULL; + } +} + + +//// SharedMemoryFactory + +Ptr SharedMemoryFactory::Open(const SharedMemory::OpenParameters& params) +{ + Ptr retval; + + // If no name specified or no size requested, + if (!params.globalName || (params.minSizeBytes <= 0)) + { + OVR_DEBUG_LOG(("[SharedMemory] FAILURE: Invalid parameters to Create()")); + return NULL; + } + + OVR_DEBUG_LOG(("[SharedMemory] Creating shared memory region: %s > %d bytes", + params.globalName, params.minSizeBytes)); + + // Attempt to create a shared memory region from the parameters + SharedMemoryInternal* pInternal = SharedMemoryInternal::CreateSharedMemory(params); + + if (pInternal) + { + // Create the wrapper object + retval = *new SharedMemory(params.minSizeBytes, pInternal->FileView, pInternal); + } + + return retval; +} + +SharedMemoryFactory::SharedMemoryFactory() +{ + OVR_DEBUG_LOG(("[SharedMemory] Creating factory")); + + PushDestroyCallbacks(); +} + +SharedMemoryFactory::~SharedMemoryFactory() +{ + OVR_DEBUG_LOG(("[SharedMemory] Destroying factory")); +} + +void SharedMemoryFactory::OnSystemDestroy() +{ + delete this; +} + + +} // namespace OVR diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Kernel/OVR_SharedMemory.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Kernel/OVR_SharedMemory.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,240 @@ +/************************************************************************************ + +PublicHeader: OVR +Filename : OVR_SharedMemory.h +Content : Inter-process shared memory subsystem +Created : June 1, 2014 +Notes : + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#ifndef OVR_SharedMemory_h +#define OVR_SharedMemory_h + +#include "OVR_Types.h" +#include "OVR_RefCount.h" +#include "OVR_Allocator.h" +#include "OVR_System.h" + +#ifdef OVR_SINGLE_PROCESS /* Everything running in one process usually for debugging */ +#define OVR_FAKE_SHAREDMEMORY /* Single-process version to avoid admin privs */ +#endif + +namespace OVR { + +class SharedMemoryInternal; // Opaque + + +// SharedMemory +// Note: Safe when used between 32-bit and 64-bit processes +class SharedMemory : public RefCountBase +{ + friend class SharedMemoryFactory; + + OVR_NON_COPYABLE(SharedMemory); + +public: + // Only constructed by the SharedMemory Factory + SharedMemory(int size, void* data, SharedMemoryInternal* pInternal); + // Call close when it goes out of scope + ~SharedMemory(); + + // Modes for opening a new shared memory region + enum OpenMode + { + // Note: On Windows, Create* requires Administrator priviledges or running as a Service. + OpenMode_CreateOnly, // Must not already exist + OpenMode_OpenOnly, // Must already exist + OpenMode_CreateOrOpen // May exist or not + }; + + // Local access restrictions + enum AccessMode + { + AccessMode_ReadOnly, // Acquire read-only access + AccessMode_ReadWrite, // Acquire read or write access + }; + + // Remote access restrictions + enum RemoteMode + { + RemoteMode_ReadOnly, // Other processes will need to open in read-only mode + RemoteMode_ReadWrite // Other processes can open in read-write mode + }; + + // Modes for opening a new shared memory region + struct OpenParameters + { + OpenParameters() : + globalName(NULL), + minSizeBytes(0), + openMode(SharedMemory::OpenMode_CreateOrOpen), + remoteMode(SharedMemory::RemoteMode_ReadWrite), + accessMode(SharedMemory::AccessMode_ReadWrite) + { + } + + // Creation parameters + const char* globalName; // Name of the shared memory region + int minSizeBytes; // Minimum number of bytes to request + SharedMemory::OpenMode openMode; // Creating the file or opening the file? + SharedMemory::RemoteMode remoteMode; // When creating, what access should other processes get? + SharedMemory::AccessMode accessMode; // When opening/creating, what access should this process get? + }; + +public: + // Returns the size of the shared memory region + int GetSizeI() const + { + return Size; + } + + // Returns the process-local pointer to the shared memory region + // Note: This may be different on different processes + void* GetData() const + { + return Data; + } + +protected: + int Size; // How many shared bytes are shared at the pointer address? + void* Data; // Pointer to the shared memory region. + + // Hidden implementation class for OS-specific behavior + SharedMemoryInternal* Internal; + + // Close and cleanup the shared memory region + // Note: This is called on destruction + void Close(); +}; + + +// SharedMemoryFactory +class SharedMemoryFactory : public NewOverrideBase, public SystemSingletonBase +{ + OVR_DECLARE_SINGLETON(SharedMemoryFactory); + +public: + // Construct a SharedMemory object. + // Note: The new object is reference-counted so it should be stored with Ptr<>. Initial reference count is 1. + Ptr Open(const SharedMemory::OpenParameters&); +}; + + +// A shared object +// Its constructor will be called when creating a writer +// Its destructor will not be called +template +class ISharedObject : public NewOverrideBase +{ +public: + static const int RegionSize = (int)sizeof(SharedType); + +protected: + Ptr pSharedMemory; + + bool Open(const char* name, bool readOnly) + { + // Configure open parameters based on read-only mode + SharedMemory::OpenParameters params; + + // FIXME: This is a hack. We currently need to allow clients to open this for read-write even + // though they only need read-only access. This is because in the first 0.4 release the + // LocklessUpdater class technically writes to it (increments by 0) to read from the space. + // This was quickly corrected in 0.4.1 and we are waiting for the right time to disallow write + // access when everyone upgrades to 0.4.1+. + //params.remoteMode = SharedMemory::RemoteMode_ReadOnly; + params.remoteMode = SharedMemory::RemoteMode_ReadWrite; + + params.globalName = name; + params.accessMode = readOnly ? SharedMemory::AccessMode_ReadOnly : SharedMemory::AccessMode_ReadWrite; + params.minSizeBytes = RegionSize; + params.openMode = readOnly ? SharedMemory::OpenMode_OpenOnly : SharedMemory::OpenMode_CreateOrOpen; + + // Attempt to open the shared memory file + pSharedMemory = SharedMemoryFactory::GetInstance()->Open(params); + + // If it was not able to be opened, + if (pSharedMemory && pSharedMemory->GetSizeI() >= RegionSize && pSharedMemory->GetData()) + { + // If writing, + if (!readOnly) + { + // Construct the object also + Construct(pSharedMemory->GetData()); + } + + return true; + } + + return false; + } + + SharedType* Get() const + { + if (!pSharedMemory) + { + return NULL; + } + + void* data = pSharedMemory->GetData(); + if (!data) + { + return NULL; + } + + return reinterpret_cast(data); + } +}; + +// Writer specialized shared object: Ctor will be called on Open() +template +class SharedObjectWriter : public ISharedObject +{ +public: + OVR_FORCE_INLINE bool Open(const char* name) + { + return ISharedObject::Open(name, false); + } + OVR_FORCE_INLINE SharedType* Get() + { + return ISharedObject::Get(); + } +}; + +// Reader specialized shared object: Ctor will not be called +template +class SharedObjectReader : public ISharedObject +{ +public: + OVR_FORCE_INLINE bool Open(const char* name) + { + return ISharedObject::Open(name, true); + } + OVR_FORCE_INLINE const SharedType* Get() const + { + return ISharedObject::Get(); + } +}; + + +} // namespace OVR + +#endif // OVR_SharedMemory_h diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Kernel/OVR_Std.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Kernel/OVR_Std.cpp Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,1097 @@ +/************************************************************************************ + +Filename : OVR_Std.cpp +Content : Standard C function implementation +Created : September 19, 2012 +Notes : + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#include "OVR_Std.h" +#include "OVR_Alg.h" + +// localeconv() call in OVR_strtod() +#include + +namespace OVR { + +// Source for functions not available on all platforms is included here. + +size_t OVR_CDECL OVR_strlcpy(char* dest, const char* src, size_t destsize) +{ + const char* s = src; + size_t n = destsize; + + if(n && --n) + { + do{ + if((*dest++ = *s++) == 0) + break; + } while(--n); + } + + if(!n) + { + if(destsize) + *dest = 0; + while(*s++) + { } + } + + return (size_t)((s - src) - 1); +} + + +size_t OVR_CDECL OVR_strlcat(char* dest, const char* src, size_t destsize) +{ + const size_t d = destsize ? OVR_strlen(dest) : 0; + const size_t s = OVR_strlen(src); + const size_t t = s + d; + + OVR_ASSERT((destsize == 0) || (d < destsize)); + + if(t < destsize) + memcpy(dest + d, src, (s + 1) * sizeof(*src)); + else + { + if(destsize) + { + memcpy(dest + d, src, ((destsize - d) - 1) * sizeof(*src)); + dest[destsize - 1] = 0; + } + } + + return t; +} + + +// Case insensitive compare implemented in platform-specific way. +int OVR_CDECL OVR_stricmp(const char* a, const char* b) +{ +#if defined(OVR_OS_MS) + #if defined(OVR_CC_MSVC) && (OVR_CC_MSVC >= 1400) + return ::_stricmp(a, b); + #else + return ::stricmp(a, b); + #endif + +#else + return strcasecmp(a, b); +#endif +} + +int OVR_CDECL OVR_strnicmp(const char* a, const char* b, size_t count) +{ +#if defined(OVR_OS_MS) + #if defined(OVR_CC_MSVC) && (OVR_CC_MSVC >= 1400) + return ::_strnicmp(a, b, count); + #else + return ::strnicmp(a, b, count); + #endif + +#else + return strncasecmp(a, b, count); +#endif +} + +wchar_t* OVR_CDECL OVR_wcscpy(wchar_t* dest, size_t destsize, const wchar_t* src) +{ +#if defined(OVR_MSVC_SAFESTRING) + wcscpy_s(dest, destsize, src); + return dest; +#elif defined(OVR_OS_MS) + OVR_UNUSED(destsize); + wcscpy(dest, src); + return dest; +#else + size_t l = OVR_wcslen(src) + 1; // incl term null + l = (l < destsize) ? l : destsize; + memcpy(dest, src, l * sizeof(wchar_t)); + return dest; +#endif +} + +wchar_t* OVR_CDECL OVR_wcsncpy(wchar_t* dest, size_t destsize, const wchar_t* src, size_t count) +{ +#if defined(OVR_MSVC_SAFESTRING) + wcsncpy_s(dest, destsize, src, count); + return dest; +#else + size_t srclen = OVR_wcslen(src); + size_t l = Alg::Min(srclen, count); + l = (l < destsize) ? l : destsize; + memcpy(dest, src, l * sizeof(wchar_t)); + if (count > srclen) + { + size_t remLen = Alg::Min(destsize - l, (count - srclen)); + memset(&dest[l], 0, sizeof(wchar_t)*remLen); + } + else if (l < destsize) + dest[l] = 0; + return dest; +#endif +} + + +wchar_t* OVR_CDECL OVR_wcscat(wchar_t* dest, size_t destsize, const wchar_t* src) +{ +#if defined(OVR_MSVC_SAFESTRING) + wcscat_s(dest, destsize, src); + return dest; +#elif defined(OVR_OS_MS) + OVR_UNUSED(destsize); + wcscat(dest, src); + return dest; +#else + size_t dstlen = OVR_wcslen(dest); // do not incl term null + size_t srclen = OVR_wcslen(src) + 1; // incl term null + size_t copylen = (dstlen + srclen < destsize) ? srclen : destsize - dstlen; + memcpy(dest + dstlen, src, copylen * sizeof(wchar_t)); + return dest; +#endif +} + +size_t OVR_CDECL OVR_wcslen(const wchar_t* str) +{ +#if defined(OVR_OS_MS) + return wcslen(str); +#else + size_t i = 0; + while(str[i] != '\0') + ++i; + return i; +#endif +} + +int OVR_CDECL OVR_wcscmp(const wchar_t* a, const wchar_t* b) +{ +#if defined(OVR_OS_MS) || defined(OVR_OS_LINUX) + return wcscmp(a, b); +#else + // not supported, use custom implementation + const wchar_t *pa = a, *pb = b; + while (*pa && *pb) + { + wchar_t ca = *pa; + wchar_t cb = *pb; + if (ca < cb) + return -1; + else if (ca > cb) + return 1; + pa++; + pb++; + } + if (*pa) + return 1; + else if (*pb) + return -1; + else + return 0; +#endif +} + +int OVR_CDECL OVR_wcsicmp(const wchar_t* a, const wchar_t* b) +{ +#if defined(OVR_OS_MS) + #if defined(OVR_CC_MSVC) && (OVR_CC_MSVC >= 1400) + return ::_wcsicmp(a, b); + #else + return ::wcsicmp(a, b); + #endif +#elif defined(OVR_OS_MAC) || defined(__CYGWIN__) || defined(OVR_OS_ANDROID) || defined(OVR_OS_IPHONE) + // not supported, use custom implementation + const wchar_t *pa = a, *pb = b; + while (*pa && *pb) + { + wchar_t ca = OVR_towlower(*pa); + wchar_t cb = OVR_towlower(*pb); + if (ca < cb) + return -1; + else if (ca > cb) + return 1; + pa++; + pb++; + } + if (*pa) + return 1; + else if (*pb) + return -1; + else + return 0; +#else + return wcscasecmp(a, b); +#endif +} + +// This function is not inline because of dependency on +double OVR_CDECL OVR_strtod(const char* str, char** tailptr) +{ +#if !defined(OVR_OS_ANDROID) // The Android C library doesn't have localeconv. + const char s = *localeconv()->decimal_point; + + if (s != '.') // If the C library is using a locale that is not using '.' as a decimal point, we convert the input str's '.' chars to the char that the C library expects (e.g. ',' or ' '). + { + char buffer[347 + 1]; + + OVR_strcpy(buffer, sizeof(buffer), str); + + // Ensure null-termination of string + buffer[sizeof(buffer)-1] = '\0'; + + for (char* c = buffer; *c != '\0'; ++c) + { + if (*c == '.') + { + *c = s; + break; + } + } + + char *nextPtr = NULL; + double retval = strtod(buffer, &nextPtr); + + // If a tail pointer is requested, + if (tailptr) + { + // Return a tail pointer that points to the same offset as nextPtr, in the orig string + *tailptr = !nextPtr ? NULL : (char*)str + (int)(nextPtr - buffer); + } + + return retval; + } +#endif + + return strtod(str, tailptr); +} + + +#ifndef OVR_NO_WCTYPE + +//// Use this class to generate Unicode bitsets. For example: +//// +//// UnicodeBitSet bitSet; +//// for(unsigned i = 0; i < 65536; ++i) +//// { +//// if (iswalpha(i)) +//// bitSet.Set(i); +//// } +//// bitSet.Dump(); +//// +////--------------------------------------------------------------- +//class UnicodeBitSet +//{ +//public: +// UnicodeBitSet() +// { +// memset(Offsets, 0, sizeof(Offsets)); +// memset(Bits, 0, sizeof(Bits)); +// } +// +// void Set(unsigned bit) { Bits[bit >> 8][(bit >> 4) & 15] |= 1 << (bit & 15); } +// +// void Dump() +// { +// unsigned i, j; +// unsigned offsetCount = 0; +// for(i = 0; i < 256; ++i) +// { +// if (isNull(i)) Offsets[i] = 0; +// else +// if (isFull(i)) Offsets[i] = 1; +// else Offsets[i] = uint16_t(offsetCount++ * 16 + 256); +// } +// for(i = 0; i < 16; ++i) +// { +// for(j = 0; j < 16; ++j) +// { +// printf("%5u,", Offsets[i*16+j]); +// } +// printf("\n"); +// } +// for(i = 0; i < 256; ++i) +// { +// if (Offsets[i] > 255) +// { +// for(j = 0; j < 16; j++) +// { +// printf("%5u,", Bits[i][j]); +// } +// printf("\n"); +// } +// } +// } +// +//private: +// bool isNull(unsigned n) const +// { +// const uint16_t* p = Bits[n]; +// for(unsigned i = 0; i < 16; ++i) +// if (p[i] != 0) return false; +// return true; +// } +// +// bool isFull(unsigned n) const +// { +// const uint16_t* p = Bits[n]; +// for(unsigned i = 0; i < 16; ++i) +// if (p[i] != 0xFFFF) return false; +// return true; +// } +// +// uint16_t Offsets[256]; +// uint16_t Bits[256][16]; +//}; + + +const uint16_t UnicodeAlnumBits[] = { + 256, 1, 272, 288, 304, 320, 336, 352, 0, 368, 384, 400, 416, 432, 448, 464, + 480, 496, 512, 528, 544, 1, 560, 576, 592, 0, 0, 0, 0, 0, 608, 624, + 640, 656, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 672, 688, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 704, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 720, + 1, 1, 1, 1, 736, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 752, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 768, 784, 1, 800, 816, 832, + 0, 0, 0, 1023,65534, 2047,65534, 2047, 0, 0, 0, 524,65535,65407,65535,65407, +65535,65535,65532, 15, 0,65535,65535,65535,65535,65535,16383,63999, 3, 0,16415, 0, + 0, 0, 0, 0, 32, 0, 0, 1024,55104,65535,65531,65535,32767,64767,65535, 15, +65535,65535,65535,65535,65535,65535,65535,65535,61443,65535,65535,65535, 6559,65535,65535, 831, + 0, 0, 0,65534,65535, 639,65534,65535, 255, 0, 0, 0, 0,65535, 2047, 7, + 0, 0,65534, 2047,65534, 63, 1023,65535,65535,65535,65535,65535,65535, 8175, 8702, 8191, + 0,65535, 8191,65535, 0, 0, 0, 0,65535,65535,65535, 1, 0, 0, 0, 0, +65518,65535,65535,58367, 8191,65281,65487, 0,40942,65529,65023,50117, 6559,45184,65487, 3, +34788,65529,65023,50029, 6535,24064,65472, 31,45038,65531,65023,58349, 7103, 1,65473, 0, +40942,65529,65023,58317, 6543,45248,65475, 0,51180,54845,50968,50111, 7623, 128,65408, 0, +57326,65533,65023,50159, 7647, 96,65475, 0,57324,65533,65023,50159, 7647,16480,65475, 0, +57324,65533,65023,50175, 7631, 128,65475, 0,65516,64639,65535,12283,32895,65375, 0, 12, +65534,65535,65535, 2047,32767, 1023, 0, 0, 9622,65264,60590,15359, 8223,13311, 0, 0, + 1, 0, 1023, 0,65279,65535, 2047,65534, 3843,65279,65535, 8191, 0, 0, 0, 0, +65535,65535,63227, 327, 1023, 1023, 0, 0, 0, 0,65535,65535, 63,65535,65535, 127, +65535,65535,65535,65535,65535,33791,65535,65535,65535,65535,65287,65535,65535,65535,65535, 1023, +65407,65535,65535,65535,15743,15743,65535,65535,15743,65535,32767,32573,32573,65407,32767,65535, +32767,32573,65535,65535,65407, 2047,65024, 3, 0, 0,65535,65535,65535,65535,65535, 31, +65534,65535,65535,65535,65535,65535,65535,65535,65535,65535,65535,65535,65535,65535,65535,65535, +65535,65535,65535,65535,65535,65535,40959, 127,65534, 2047,65535,65535,65535,65535, 2047, 0, + 0, 0, 0, 0, 0, 0, 0, 0,65535,65535,65535,65535, 511, 0, 1023, 0, + 0, 1023,65535,65535,65527,65535,65535, 255,65535,65535, 1023, 0, 0, 0, 0, 0, +65535,65535,65535,65535,65535,65535,65535,65535,65535, 4095,65535,65535,65535,65535,65535, 1023, +65535,16191,65535,65535,16191,43775,65535,16383,65535,65535,65535,24543, 8156, 4047, 8191, 8156, + 0, 0, 0, 0, 0, 0, 0,32768, 0, 0, 0, 0, 0, 0, 0, 0, +64644,15919,48464, 1019, 0, 0,65535,65535, 15, 0, 0, 0, 0, 0, 0, 0, + 192, 0, 1022, 1792,65534,65535,65535,65535,65535, 31,65534,65535,65535,65535,65535, 2047, +65504,65535, 8191,65534,65535,65535,65535,65535,32767, 0,65535, 255, 0, 0, 0, 0, +65535,65535,65535,65535,65535,65535,65535,65535,65535,65535,65535, 63, 0, 0, 0, 0, +65535,65535,65535,65535,65535,65535,65535,65535,65535,65535, 63, 0, 0, 0, 0, 0, +65535,65535,65535,65535,65535,65535,65535,65535, 8191, 0, 0, 0, 0, 0, 0, 0, +65535,65535,65535,65535,65535,65535,65535,65535,65535,65535, 15, 0, 0, 0, 0, 0, +65535,65535,16383, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 127,41208,65023,24447,65499,65535,65535,65535,65535,65535,65535, 3, 0,65528,65535,65535, +65535,65535,65535,16383, 0,65535,65535,65535,65535,65532,65535,65535, 255, 0, 0, 4095, + 0, 0, 0, 0, 0, 0, 0,65495,65535,65535,65535,65535,65535,65535,65535, 8191, + 0, 1023,65534, 2047,65534, 2047,65472,65534,65535,16383,65535,32767,64764, 7420, 0, 0}; + +const uint16_t UnicodeAlphaBits[] = { + 256, 1, 272, 288, 304, 320, 336, 352, 0, 368, 384, 400, 416, 432, 448, 464, + 480, 496, 512, 528, 544, 1, 560, 576, 592, 0, 0, 0, 0, 0, 608, 624, + 640, 656, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 672, 688, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 704, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 720, + 1, 1, 1, 1, 736, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 752, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 768, 784, 1, 800, 816, 832, + 0, 0, 0, 0,65534, 2047,65534, 2047, 0, 0, 0, 0,65535,65407,65535,65407, +65535,65535,65532, 15, 0,65535,65535,65535,65535,65535,16383,63999, 3, 0,16415, 0, + 0, 0, 0, 0, 32, 0, 0, 1024,55104,65535,65531,65535,32767,64767,65535, 15, +65535,65535,65535,65535,65535,65535,65535,65535,61443,65535,65535,65535, 6559,65535,65535, 831, + 0, 0, 0,65534,65535, 639,65534,65535, 255, 0, 0, 0, 0,65535, 2047, 7, + 0, 0,65534, 2047,65534, 63, 0,65535,65535,65535,65535,65535,65535, 8175, 8702, 7168, + 0,65535, 8191,65535, 0, 0, 0, 0,65535,65535,65535, 1, 0, 0, 0, 0, +65518,65535,65535,58367, 8191,65281, 15, 0,40942,65529,65023,50117, 6559,45184, 15, 3, +34788,65529,65023,50029, 6535,24064, 0, 31,45038,65531,65023,58349, 7103, 1, 1, 0, +40942,65529,65023,58317, 6543,45248, 3, 0,51180,54845,50968,50111, 7623, 128, 0, 0, +57326,65533,65023,50159, 7647, 96, 3, 0,57324,65533,65023,50159, 7647,16480, 3, 0, +57324,65533,65023,50175, 7631, 128, 3, 0,65516,64639,65535,12283,32895,65375, 0, 12, +65534,65535,65535, 2047,32767, 0, 0, 0, 9622,65264,60590,15359, 8223,12288, 0, 0, + 1, 0, 0, 0,65279,65535, 2047,65534, 3843,65279,65535, 8191, 0, 0, 0, 0, +65535,65535,63227, 327, 0, 1023, 0, 0, 0, 0,65535,65535, 63,65535,65535, 127, +65535,65535,65535,65535,65535,33791,65535,65535,65535,65535,65287,65535,65535,65535,65535, 1023, +65407,65535,65535,65535,15743,15743,65535,65535,15743,65535,32767,32573,32573,65407,32767,65535, +32767,32573,65535,65535,65407, 2047, 0, 0, 0, 0,65535,65535,65535,65535,65535, 31, +65534,65535,65535,65535,65535,65535,65535,65535,65535,65535,65535,65535,65535,65535,65535,65535, +65535,65535,65535,65535,65535,65535,40959, 127,65534, 2047,65535,65535,65535,65535, 2047, 0, + 0, 0, 0, 0, 0, 0, 0, 0,65535,65535,65535,65535, 511, 0, 0, 0, + 0, 0,65535,65535,65527,65535,65535, 255,65535,65535, 1023, 0, 0, 0, 0, 0, +65535,65535,65535,65535,65535,65535,65535,65535,65535, 4095,65535,65535,65535,65535,65535, 1023, +65535,16191,65535,65535,16191,43775,65535,16383,65535,65535,65535,24543, 8156, 4047, 8191, 8156, + 0, 0, 0, 0, 0, 0, 0,32768, 0, 0, 0, 0, 0, 0, 0, 0, +64644,15919,48464, 1019, 0, 0,65535,65535, 15, 0, 0, 0, 0, 0, 0, 0, + 192, 0, 1022, 1792,65534,65535,65535,65535,65535, 31,65534,65535,65535,65535,65535, 2047, +65504,65535, 8191,65534,65535,65535,65535,65535,32767, 0,65535, 255, 0, 0, 0, 0, +65535,65535,65535,65535,65535,65535,65535,65535,65535,65535,65535, 63, 0, 0, 0, 0, +65535,65535,65535,65535,65535,65535,65535,65535,65535,65535, 63, 0, 0, 0, 0, 0, +65535,65535,65535,65535,65535,65535,65535,65535, 8191, 0, 0, 0, 0, 0, 0, 0, +65535,65535,65535,65535,65535,65535,65535,65535,65535,65535, 15, 0, 0, 0, 0, 0, +65535,65535,16383, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 127,41208,65023,24447,65499,65535,65535,65535,65535,65535,65535, 3, 0,65528,65535,65535, +65535,65535,65535,16383, 0,65535,65535,65535,65535,65532,65535,65535, 255, 0, 0, 4095, + 0, 0, 0, 0, 0, 0, 0,65495,65535,65535,65535,65535,65535,65535,65535, 8191, + 0, 0,65534, 2047,65534, 2047,65472,65534,65535,16383,65535,32767,64764, 7420, 0, 0}; + +const uint16_t UnicodeDigitBits[] = { + 256, 0, 0, 0, 0, 0, 272, 0, 0, 288, 304, 320, 336, 352, 368, 384, + 400, 0, 0, 416, 0, 0, 0, 432, 448, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 464, + 0, 0, 0, 1023, 0, 0, 0, 0, 0, 0, 0, 524, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1023, 0, 0, 0, 0, 0, 0, 0, 0, 1023, + 0, 0, 0, 0, 0, 0,65472, 0, 0, 0, 0, 0, 0, 0,65472, 0, + 0, 0, 0, 0, 0, 0,65472, 0, 0, 0, 0, 0, 0, 0,65472, 0, + 0, 0, 0, 0, 0, 0,65472, 0, 0, 0, 0, 0, 0, 0,65408, 0, + 0, 0, 0, 0, 0, 0,65472, 0, 0, 0, 0, 0, 0, 0,65472, 0, + 0, 0, 0, 0, 0, 0,65472, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1023, 0, 0, 0, 0, 0, 0, 0, 1023, 0, 0, + 0, 0, 1023, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1023, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0,65024, 3, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1023, 0, + 0, 1023, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1023, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + +const uint16_t UnicodeSpaceBits[] = { + 256, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 272, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 288, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 304, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +15872, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, + 4095, 0,33536, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + +const uint16_t UnicodeXDigitBits[] = { + 256, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 272, + 0, 0, 0, 1023, 126, 0, 126, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1023, 126, 0, 126, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + +// Uncomment if necessary +//const uint16_t UnicodeCntrlBits[] = { +// 256, 0, 0, 0, 0, 0, 0, 272, 0, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0, 0, 0, 0, 0, 0, 288, 0, 0, 0, 0, 0, 0, 0, +// 304, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 320, 336, +//65535,65535, 0, 0, 0, 0, 0,32768,65535,65535, 0, 0, 0, 0, 0, 0, +//32768, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +//30720, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +//61440, 0,31744, 0, 0, 0,64512, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,32768, +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3584}; +// +//const uint16_t UnicodeGraphBits[] = { +// 256, 1, 272, 288, 304, 320, 336, 352, 0, 368, 384, 400, 416, 432, 448, 464, +// 480, 496, 512, 528, 544, 1, 560, 576, 592, 0, 0, 0, 0, 0, 608, 624, +// 640, 656, 0, 672, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 688, 704, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, +// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 720, 1, 1, +// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, +// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, +// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, +// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, +// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 736, +// 1, 1, 1, 1, 752, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, +// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, +// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, +// 1, 1, 1, 1, 1, 1, 1, 768, 0, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 784, 800, 1, 816, 832, 848, +// 0, 0,65534,65535,65535,65535,65535,32767, 0, 0,65534,65535,65535,65535,65535,65535, +//65535,65535,65532, 15, 0,65535,65535,65535,65535,65535,16383,63999, 3, 0,16415, 0, +// 0, 0, 0, 0, 32, 0, 0,17408,55232,65535,65531,65535,32767,64767,65535, 15, +//65535,65535,65535,65535,65535,65535,65535,65535,61443,65535,65535,65535, 6559,65535,65535, 831, +// 0, 0, 0,65534,65535,65151,65534,65535, 1791, 0, 0,16384, 9,65535, 2047, 31, +// 4096,34816,65534, 2047,65534, 63,16383,65535,65535,65535,65535,65535,65535, 8191, 8702, 8191, +//16383,65535, 8191,65535, 0, 0, 0, 0,65535,65535,65535, 1, 0, 0, 0, 0, +//65518,65535,65535,58367, 8191,65281,65535, 1,40942,65529,65023,50117, 6559,45184,65487, 3, +//34788,65529,65023,50029, 6535,24064,65472, 31,45038,65531,65023,58349, 7103, 1,65473, 0, +//40942,65529,65023,58317, 6543,45248,65475, 0,51180,54845,50968,50111, 7623, 128,65408, 0, +//57326,65533,65023,50159, 7647, 96,65475, 0,57324,65533,65023,50159, 7647,16480,65475, 0, +//57324,65533,65023,50175, 7631, 128,65475, 0,65516,64639,65535,12283,32895,65375, 0, 28, +//65534,65535,65535, 2047,65535, 4095, 0, 0, 9622,65264,60590,15359, 8223,13311, 0, 0, +//65521, 7, 1023,15360,65279,65535, 2047,65534, 3875,65279,65535, 8191, 0, 0, 0, 0, +//65535,65535,63227, 327,65535, 1023, 0, 0, 0, 0,65535,65535, 63,65535,65535, 2175, +//65535,65535,65535,65535,65535,33791,65535,65535,65535,65535,65287,65535,65535,65535,65535, 1023, +//65407,65535,65535,65535,15743,15743,65535,65535,15743,65535,32767,32573,32573,65407,32767,65535, +//32767,32573,65535,65535,65407, 2047,65534, 3, 0, 0,65535,65535,65535,65535,65535, 31, +//65534,65535,65535,65535,65535,65535,65535,65535,65535,65535,65535,65535,65535,65535,65535,65535, +//65535,65535,65535,65535,65535,65535,65535, 127,65534, 8191,65535,65535,65535,65535,16383, 0, +// 0, 0, 0, 0, 0, 0, 0, 0,65535,65535,65535,65535, 511, 6128, 1023, 0, +// 2047, 1023,65535,65535,65527,65535,65535, 255,65535,65535, 1023, 0, 0, 0, 0, 0, +//65535,65535,65535,65535,65535,65535,65535,65535,65535, 4095,65535,65535,65535,65535,65535, 1023, +//65535,16191,65535,65535,16191,43775,65535,16383,65535,65535,65535,24543, 8156, 4047, 8191, 8156, +// 0,65535, 255,65535,16239, 0, 0,57344,24576, 0, 0, 0, 0, 0, 0, 0, +//64644,15919,48464, 1019, 0, 0,65535,65535, 15, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 1536, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +//65486,65523, 1022, 1793,65534,65535,65535,65535,65535, 31,65534,65535,65535,65535,65535, 4095, +//65504,65535, 8191,65534,65535,65535,65535,65535,32767, 0,65535, 255, 0, 0, 0, 0, +//65535,65535,65535,65535,65535,65535,65535,65535,65535,65535,65535, 63, 0, 0, 0, 0, +//65535,65535,65535,65535,65535,65535,65535,65535,65535,65535, 63, 0, 0, 0, 0, 0, +//65535,65535,65535,65535,65535,65535,65535,65535, 8191, 0, 0, 0, 0, 0, 0, 0, +//65535,65535,65535,65535,65535,65535,65535,65535,65535,65535, 15, 0, 0, 0, 0, 0, +//65535,65535,16383, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 127,41208,65023,24447,65499,65535,65535,65535,65535,65535,65535, 3, 0,65528,65535,65535, +//65535,65535,65535,65535, 0,65535,65535,65535,65535,65532,65535,65535, 255, 0, 0, 4095, +// 0, 0, 0,65535,65055,65527, 3339,65495,65535,65535,65535,65535,65535,65535,65535, 8191, +//63470,36863,65535,49151,65534,12287,65534,65534,65535,16383,65535,32767,64764, 7420, 0, 0}; +// +//const uint16_t UnicodePrintBits[] = { +// 256, 1, 272, 288, 304, 320, 336, 352, 0, 368, 384, 400, 416, 432, 448, 464, +// 480, 496, 512, 528, 544, 1, 560, 576, 592, 0, 0, 0, 0, 0, 608, 624, +// 640, 656, 0, 672, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 688, 704, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, +// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 720, 1, 1, +// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, +// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, +// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, +// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, +// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 736, +// 1, 1, 1, 1, 752, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, +// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, +// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, +// 1, 1, 1, 1, 1, 1, 1, 768, 0, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 784, 800, 1, 816, 832, 848, +// 512, 0,65535,65535,65535,65535,65535,32767, 0, 0,65535,65535,65535,65535,65535,65535, +//65535,65535,65532, 15, 0,65535,65535,65535,65535,65535,16383,63999, 3, 0,16415, 0, +// 0, 0, 0, 0, 32, 0, 0,17408,55232,65535,65531,65535,32767,64767,65535, 15, +//65535,65535,65535,65535,65535,65535,65535,65535,61443,65535,65535,65535, 6559,65535,65535, 831, +// 0, 0, 0,65534,65535,65151,65534,65535, 1791, 0, 0,16384, 9,65535, 2047, 31, +// 4096,34816,65534, 2047,65534, 63,16383,65535,65535,65535,65535,65535,65535, 8191, 8702, 8191, +//16383,65535, 8191,65535, 0, 0, 0, 0,65535,65535,65535, 1, 0, 0, 0, 0, +//65518,65535,65535,58367, 8191,65281,65535, 1,40942,65529,65023,50117, 6559,45184,65487, 3, +//34788,65529,65023,50029, 6535,24064,65472, 31,45038,65531,65023,58349, 7103, 1,65473, 0, +//40942,65529,65023,58317, 6543,45248,65475, 0,51180,54845,50968,50111, 7623, 128,65408, 0, +//57326,65533,65023,50159, 7647, 96,65475, 0,57324,65533,65023,50159, 7647,16480,65475, 0, +//57324,65533,65023,50175, 7631, 128,65475, 0,65516,64639,65535,12283,32895,65375, 0, 28, +//65534,65535,65535, 2047,65535, 4095, 0, 0, 9622,65264,60590,15359, 8223,13311, 0, 0, +//65521, 7, 1023,15360,65279,65535, 2047,65534, 3875,65279,65535, 8191, 0, 0, 0, 0, +//65535,65535,63227, 327,65535, 1023, 0, 0, 0, 0,65535,65535, 63,65535,65535, 2175, +//65535,65535,65535,65535,65535,33791,65535,65535,65535,65535,65287,65535,65535,65535,65535, 1023, +//65407,65535,65535,65535,15743,15743,65535,65535,15743,65535,32767,32573,32573,65407,32767,65535, +//32767,32573,65535,65535,65407, 2047,65534, 3, 0, 0,65535,65535,65535,65535,65535, 31, +//65534,65535,65535,65535,65535,65535,65535,65535,65535,65535,65535,65535,65535,65535,65535,65535, +//65535,65535,65535,65535,65535,65535,65535, 127,65534, 8191,65535,65535,65535,65535,16383, 0, +// 0, 0, 0, 0, 0, 0, 0, 0,65535,65535,65535,65535, 511, 6128, 1023, 0, +// 2047, 1023,65535,65535,65527,65535,65535, 255,65535,65535, 1023, 0, 0, 0, 0, 0, +//65535,65535,65535,65535,65535,65535,65535,65535,65535, 4095,65535,65535,65535,65535,65535, 1023, +//65535,16191,65535,65535,16191,43775,65535,16383,65535,65535,65535,24543, 8156, 4047, 8191, 8156, +// 0,65535, 255,65535,16239, 0, 0,57344,24576, 0, 0, 0, 0, 0, 0, 0, +//64644,15919,48464, 1019, 0, 0,65535,65535, 15, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 1536, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +//65487,65523, 1022, 1793,65534,65535,65535,65535,65535, 31,65534,65535,65535,65535,65535, 4095, +//65504,65535, 8191,65534,65535,65535,65535,65535,32767, 0,65535, 255, 0, 0, 0, 0, +//65535,65535,65535,65535,65535,65535,65535,65535,65535,65535,65535, 63, 0, 0, 0, 0, +//65535,65535,65535,65535,65535,65535,65535,65535,65535,65535, 63, 0, 0, 0, 0, 0, +//65535,65535,65535,65535,65535,65535,65535,65535, 8191, 0, 0, 0, 0, 0, 0, 0, +//65535,65535,65535,65535,65535,65535,65535,65535,65535,65535, 15, 0, 0, 0, 0, 0, +//65535,65535,16383, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 127,41208,65023,24447,65499,65535,65535,65535,65535,65535,65535, 3, 0,65528,65535,65535, +//65535,65535,65535,65535, 0,65535,65535,65535,65535,65532,65535,65535, 255, 0, 0, 4095, +// 0, 0, 0,65535,65055,65527, 3339,65495,65535,65535,65535,65535,65535,65535,65535,40959, +//63470,36863,65535,49151,65534,12287,65534,65534,65535,16383,65535,32767,64764, 7420, 0, 0}; +// +//const uint16_t UnicodePunctBits[] = { +// 256, 0, 0, 272, 0, 288, 304, 320, 0, 336, 0, 0, 0, 352, 368, 384, +// 400, 0, 0, 416, 0, 0, 432, 448, 464, 0, 0, 0, 0, 0, 0, 0, +// 480, 0, 0, 496, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 512, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 528, 544, 560, +// 0, 0,65534,64512, 1,63488, 1,30720, 0, 0,65534,65535, 0, 128, 0, 128, +// 0, 0, 0, 0, 0, 0, 0,16384, 128, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0, 0, 0,64512, 0, 0, 1536, 0, 0,16384, 9, 0, 0, 24, +// 4096,34816, 0, 0, 0, 0,15360, 0, 0, 0, 0, 0, 0, 16, 0, 0, +//16383, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0, 0, 0, 0, 48, 1, 0, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, +// 0, 0, 0, 0,32768, 3072, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +//65520, 7, 0,15360, 0, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0, 0,64512, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2048, +// 0, 0, 0, 0, 0, 0, 510, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0, 0, 0, 0,24576, 0, 0, 6144, 0, 0, 0, 0,14336, 0, +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6128, 0, 0, +// 2047, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 0,65535, 255,65535,16239, 0, 0,24576,24576, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 1536, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +//65294,65523, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2048, +// 0, 0, 0,49152, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0,65535,65055,65527, 3339, 0, 0, 0, 0, 0, 0, 0, 0, 0, +//63470,35840, 1,47104, 0,10240, 62, 0, 0, 0, 0, 0, 0, 0, 0, 0}; +// +//const uint16_t UnicodeLowerBits[] = { +// 256, 272, 288, 304, 320, 336, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 352, 368, +// 384, 400, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 416, 0, 0, 0, 432, +// 0, 0, 0, 0, 0, 0,65534, 2047, 0, 0, 0, 0, 0,32768,65535,65407, +//43690,43690,43690,21930,43861,43690,43690,54442,12585,20004,11562,58961,23392,46421,43690,43565, +//43690,43690,43688, 10, 0,65535,65535,65535,65535,65535,16383, 0, 0, 0, 0, 0, +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,61440,65535,32767,43235,43690, 15, +// 0, 0, 0,65535,65535,65535,43690,43690,40962,43690,43690,43690, 4372,43690,43690, 554, +// 0, 0, 0, 0, 0, 0,65534,65535, 255, 0, 0, 0, 0, 0, 0, 0, +//43690,43690,43690,43690,43690,43690,43690,43690,43690, 4074,43690,43690,43690,43690,43690, 682, +// 255, 63, 255, 255, 63, 255, 255,16383,65535,65535,65535,20703, 4316, 207, 255, 4316, +// 0, 0, 0, 0, 0, 0, 0,32768, 0, 0, 0, 0, 0, 0, 0, 0, +//50176, 8,32768, 528, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 127, 248, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0, 0,65534, 2047, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; +// +//const uint16_t UnicodeUpperBits[] = { +// 256, 272, 288, 304, 320, 336, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 352, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 368, 384, +// 0, 400, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 416, +// 0, 0, 0, 0,65534, 2047, 0, 0, 0, 0, 0, 0,65535,32639, 0, 0, +//21845,21845,21845,43605,21674,21845,21845,11093,52950,45531,53973, 4526,44464,19114,21845,21974, +//21845,21845,21844, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0, 0, 0, 0, 0, 0,55104,65534, 4091, 0, 0,21532,21845, 0, +//65535,65535,65535, 0, 0, 0,21845,21845,20481,21845,21845,21845, 2187,21845,21845, 277, +// 0, 0, 0,65534,65535, 127, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,65535,65535, 63, 0, 0, 0, +//21845,21845,21845,21845,21845,21845,21845,21845,21845, 21,21845,21845,21845,21845,21845, 341, +//65280,16128,65280,65280,16128,43520,65280, 0,65280,65280,65280, 7936, 7936, 3840, 7936, 7936, +//14468,15911,15696, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// 0, 0,65534, 2047, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + + +// MA: March 19, 2010 +// Modified ToUpper and ToLower tables to match values expected by AS3 tests. +// ToLower modifications: +// 304 -> 105 +// 1024 -> 1104 * +// 1037 -> 1117 * +// UoUpper modifications: +// 255 -> 376 +// 305 -> 73 +// 383 -> 83 +// 1104 -> 1024 * +// 1117 -> 1037 * +// Entries marked with a '*' don't make complete sense based on Unicode manual, although +// they match AS3. + + +static const uint16_t UnicodeToUpperBits[] = { + 256, 272, 288, 304, 320, 336, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 352, 368, + 0, 384, 0, 0, 400, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 416, + 0, 0, 0, 0, 0, 0,65534, 2047, 0, 0, 0, 0, 0, 0,65535,65407, +43690,43690,43690,21674,43349,43690,43690,54442, 4392, 516, 8490, 8785,21056,46421,43690,43048, // MA: Modified for AS3. +43690, 170, 0, 0, 0, 2776,33545, 36, 3336, 4, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,61440,65534,32767, 0,43688, 0, + 0, 0, 0,65535,65535,65535,43690,43690, 2,43690,43690,43690, 4372,43690,35498, 554, // MA: Modified for AS3. + 0, 0, 0, 0, 0, 0,65534,65535, 127, 0, 0, 0, 0, 0, 0, 0, +43690,43690,43690,43690,43690,43690,43690,43690,43690, 42,43690,43690,43690,43690,43690, 682, + 255, 63, 255, 255, 63, 170, 255,16383, 0, 0, 0, 3, 0, 3, 35, 0, + 0, 0, 0, 0, 0, 0, 0,65535, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,65535, 1023, 0, + 0, 0, 0, 0,65534, 2047, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + +static const uint16_t UnicodeToLowerBits[] = { + 256, 272, 288, 304, 320, 336, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 352, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 368, 384, + 0, 400, 0, 0, 416, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 432, + 0, 0, 0, 0,65534, 2047, 0, 0, 0, 0, 0, 0,65535,32639, 0, 0, +21845,21845,21845,43605,21674,21845,21845,11093,52950,45531,53909, 4526,42128,19114,21845,21522,// MA: Modidied for AS3. +21845, 85, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0,55104,65534, 4091, 0, 0, 0,21844, 0, +65535,65535,65535, 0, 0, 0,21845,21845, 1,21845,21845,21845, 2186,21845,17749, 277, + 0, 0, 0,65534,65535, 127, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,65535,65535, 63, 0, 0, 0, +21845,21845,21845,21845,21845,21845,21845,21845,21845, 21,21845,21845,21845,21845,21845, 341, +65280,16128,65280,65280,16128,43520,65280, 0, 0, 0, 0, 3840, 3840, 3840, 7936, 3840, + 0, 0, 0, 0, 0, 0,65535, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,65472,65535, 0, 0, 0, + 0, 0,65534, 2047, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + +struct GUnicodePairType +{ + uint16_t Key, Value; +}; + +static inline bool CmpUnicodeKey(const GUnicodePairType& a, uint16_t key) +{ + return a.Key < key; +} + +static const GUnicodePairType UnicodeToUpperTable[] = { +{ 97, 65}, { 98, 66}, { 99, 67}, { 100, 68}, { 101, 69}, { 102, 70}, { 103, 71}, +{ 104, 72}, { 105, 73}, { 106, 74}, { 107, 75}, { 108, 76}, { 109, 77}, { 110, 78}, +{ 111, 79}, { 112, 80}, { 113, 81}, { 114, 82}, { 115, 83}, { 116, 84}, { 117, 85}, +{ 118, 86}, { 119, 87}, { 120, 88}, { 121, 89}, { 122, 90}, { 224, 192}, { 225, 193}, +{ 226, 194}, { 227, 195}, { 228, 196}, { 229, 197}, { 230, 198}, { 231, 199}, { 232, 200}, +{ 233, 201}, { 234, 202}, { 235, 203}, { 236, 204}, { 237, 205}, { 238, 206}, { 239, 207}, +{ 240, 208}, { 241, 209}, { 242, 210}, { 243, 211}, { 244, 212}, { 245, 213}, { 246, 214}, +{ 248, 216}, { 249, 217}, { 250, 218}, { 251, 219}, { 252, 220}, { 253, 221}, { 254, 222}, +{ 255, 376}, { 257, 256}, { 259, 258}, { 261, 260}, { 263, 262}, { 265, 264}, { 267, 266}, +{ 269, 268}, { 271, 270}, { 273, 272}, { 275, 274}, { 277, 276}, { 279, 278}, { 281, 280}, +{ 283, 282}, { 285, 284}, { 287, 286}, { 289, 288}, { 291, 290}, { 293, 292}, { 295, 294}, +{ 297, 296}, { 299, 298}, { 301, 300}, { 303, 302}, { 305, 73}, { 307, 306}, { 309, 308}, { 311, 310}, +{ 314, 313}, { 316, 315}, { 318, 317}, { 320, 319}, { 322, 321}, { 324, 323}, { 326, 325}, +{ 328, 327}, { 331, 330}, { 333, 332}, { 335, 334}, { 337, 336}, { 339, 338}, { 341, 340}, +{ 343, 342}, { 345, 344}, { 347, 346}, { 349, 348}, { 351, 350}, { 353, 352}, { 355, 354}, +{ 357, 356}, { 359, 358}, { 361, 360}, { 363, 362}, { 365, 364}, { 367, 366}, { 369, 368}, +{ 371, 370}, { 373, 372}, { 375, 374}, { 378, 377}, { 380, 379}, { 382, 381}, { 383, 83}, { 387, 386}, +{ 389, 388}, { 392, 391}, { 396, 395}, { 402, 401}, { 409, 408}, { 417, 416}, { 419, 418}, +{ 421, 420}, { 424, 423}, { 429, 428}, { 432, 431}, { 436, 435}, { 438, 437}, { 441, 440}, +{ 445, 444}, { 454, 452}, { 457, 455}, { 460, 458}, { 462, 461}, { 464, 463}, { 466, 465}, +{ 468, 467}, { 470, 469}, { 472, 471}, { 474, 473}, { 476, 475}, { 477, 398}, { 479, 478}, +{ 481, 480}, { 483, 482}, { 485, 484}, { 487, 486}, { 489, 488}, { 491, 490}, { 493, 492}, +{ 495, 494}, { 499, 497}, { 501, 500}, { 507, 506}, { 509, 508}, { 511, 510}, { 513, 512}, +{ 515, 514}, { 517, 516}, { 519, 518}, { 521, 520}, { 523, 522}, { 525, 524}, { 527, 526}, +{ 529, 528}, { 531, 530}, { 533, 532}, { 535, 534}, { 595, 385}, { 596, 390}, { 598, 393}, +{ 599, 394}, { 601, 399}, { 603, 400}, { 608, 403}, { 611, 404}, { 616, 407}, { 617, 406}, +{ 623, 412}, { 626, 413}, { 629, 415}, { 643, 425}, { 648, 430}, { 650, 433}, { 651, 434}, +{ 658, 439}, { 940, 902}, { 941, 904}, { 942, 905}, { 943, 906}, { 945, 913}, { 946, 914}, +{ 947, 915}, { 948, 916}, { 949, 917}, { 950, 918}, { 951, 919}, { 952, 920}, { 953, 921}, +{ 954, 922}, { 955, 923}, { 956, 924}, { 957, 925}, { 958, 926}, { 959, 927}, { 960, 928}, +{ 961, 929}, { 962, 931}, { 963, 931}, { 964, 932}, { 965, 933}, { 966, 934}, { 967, 935}, +{ 968, 936}, { 969, 937}, { 970, 938}, { 971, 939}, { 972, 908}, { 973, 910}, { 974, 911}, +{ 995, 994}, { 997, 996}, { 999, 998}, { 1001, 1000}, { 1003, 1002}, { 1005, 1004}, { 1007, 1006}, +{ 1072, 1040}, { 1073, 1041}, { 1074, 1042}, { 1075, 1043}, { 1076, 1044}, { 1077, 1045}, { 1078, 1046}, +{ 1079, 1047}, { 1080, 1048}, { 1081, 1049}, { 1082, 1050}, { 1083, 1051}, { 1084, 1052}, { 1085, 1053}, +{ 1086, 1054}, { 1087, 1055}, { 1088, 1056}, { 1089, 1057}, { 1090, 1058}, { 1091, 1059}, { 1092, 1060}, +{ 1093, 1061}, { 1094, 1062}, { 1095, 1063}, { 1096, 1064}, { 1097, 1065}, { 1098, 1066}, { 1099, 1067}, +{ 1100, 1068}, { 1101, 1069}, { 1102, 1070}, { 1103, 1071}, { 1104, 1024}, { 1105, 1025}, { 1106, 1026}, { 1107, 1027}, +{ 1108, 1028}, { 1109, 1029}, { 1110, 1030}, { 1111, 1031}, { 1112, 1032}, { 1113, 1033}, { 1114, 1034}, +{ 1115, 1035}, { 1116, 1036}, { 1117, 1037}, { 1118, 1038}, { 1119, 1039}, { 1121, 1120}, { 1123, 1122}, { 1125, 1124}, +{ 1127, 1126}, { 1129, 1128}, { 1131, 1130}, { 1133, 1132}, { 1135, 1134}, { 1137, 1136}, { 1139, 1138}, +{ 1141, 1140}, { 1143, 1142}, { 1145, 1144}, { 1147, 1146}, { 1149, 1148}, { 1151, 1150}, { 1153, 1152}, +{ 1169, 1168}, { 1171, 1170}, { 1173, 1172}, { 1175, 1174}, { 1177, 1176}, { 1179, 1178}, { 1181, 1180}, +{ 1183, 1182}, { 1185, 1184}, { 1187, 1186}, { 1189, 1188}, { 1191, 1190}, { 1193, 1192}, { 1195, 1194}, +{ 1197, 1196}, { 1199, 1198}, { 1201, 1200}, { 1203, 1202}, { 1205, 1204}, { 1207, 1206}, { 1209, 1208}, +{ 1211, 1210}, { 1213, 1212}, { 1215, 1214}, { 1218, 1217}, { 1220, 1219}, { 1224, 1223}, { 1228, 1227}, +{ 1233, 1232}, { 1235, 1234}, { 1237, 1236}, { 1239, 1238}, { 1241, 1240}, { 1243, 1242}, { 1245, 1244}, +{ 1247, 1246}, { 1249, 1248}, { 1251, 1250}, { 1253, 1252}, { 1255, 1254}, { 1257, 1256}, { 1259, 1258}, +{ 1263, 1262}, { 1265, 1264}, { 1267, 1266}, { 1269, 1268}, { 1273, 1272}, { 1377, 1329}, { 1378, 1330}, +{ 1379, 1331}, { 1380, 1332}, { 1381, 1333}, { 1382, 1334}, { 1383, 1335}, { 1384, 1336}, { 1385, 1337}, +{ 1386, 1338}, { 1387, 1339}, { 1388, 1340}, { 1389, 1341}, { 1390, 1342}, { 1391, 1343}, { 1392, 1344}, +{ 1393, 1345}, { 1394, 1346}, { 1395, 1347}, { 1396, 1348}, { 1397, 1349}, { 1398, 1350}, { 1399, 1351}, +{ 1400, 1352}, { 1401, 1353}, { 1402, 1354}, { 1403, 1355}, { 1404, 1356}, { 1405, 1357}, { 1406, 1358}, +{ 1407, 1359}, { 1408, 1360}, { 1409, 1361}, { 1410, 1362}, { 1411, 1363}, { 1412, 1364}, { 1413, 1365}, +{ 1414, 1366}, { 7681, 7680}, { 7683, 7682}, { 7685, 7684}, { 7687, 7686}, { 7689, 7688}, { 7691, 7690}, +{ 7693, 7692}, { 7695, 7694}, { 7697, 7696}, { 7699, 7698}, { 7701, 7700}, { 7703, 7702}, { 7705, 7704}, +{ 7707, 7706}, { 7709, 7708}, { 7711, 7710}, { 7713, 7712}, { 7715, 7714}, { 7717, 7716}, { 7719, 7718}, +{ 7721, 7720}, { 7723, 7722}, { 7725, 7724}, { 7727, 7726}, { 7729, 7728}, { 7731, 7730}, { 7733, 7732}, +{ 7735, 7734}, { 7737, 7736}, { 7739, 7738}, { 7741, 7740}, { 7743, 7742}, { 7745, 7744}, { 7747, 7746}, +{ 7749, 7748}, { 7751, 7750}, { 7753, 7752}, { 7755, 7754}, { 7757, 7756}, { 7759, 7758}, { 7761, 7760}, +{ 7763, 7762}, { 7765, 7764}, { 7767, 7766}, { 7769, 7768}, { 7771, 7770}, { 7773, 7772}, { 7775, 7774}, +{ 7777, 7776}, { 7779, 7778}, { 7781, 7780}, { 7783, 7782}, { 7785, 7784}, { 7787, 7786}, { 7789, 7788}, +{ 7791, 7790}, { 7793, 7792}, { 7795, 7794}, { 7797, 7796}, { 7799, 7798}, { 7801, 7800}, { 7803, 7802}, +{ 7805, 7804}, { 7807, 7806}, { 7809, 7808}, { 7811, 7810}, { 7813, 7812}, { 7815, 7814}, { 7817, 7816}, +{ 7819, 7818}, { 7821, 7820}, { 7823, 7822}, { 7825, 7824}, { 7827, 7826}, { 7829, 7828}, { 7841, 7840}, +{ 7843, 7842}, { 7845, 7844}, { 7847, 7846}, { 7849, 7848}, { 7851, 7850}, { 7853, 7852}, { 7855, 7854}, +{ 7857, 7856}, { 7859, 7858}, { 7861, 7860}, { 7863, 7862}, { 7865, 7864}, { 7867, 7866}, { 7869, 7868}, +{ 7871, 7870}, { 7873, 7872}, { 7875, 7874}, { 7877, 7876}, { 7879, 7878}, { 7881, 7880}, { 7883, 7882}, +{ 7885, 7884}, { 7887, 7886}, { 7889, 7888}, { 7891, 7890}, { 7893, 7892}, { 7895, 7894}, { 7897, 7896}, +{ 7899, 7898}, { 7901, 7900}, { 7903, 7902}, { 7905, 7904}, { 7907, 7906}, { 7909, 7908}, { 7911, 7910}, +{ 7913, 7912}, { 7915, 7914}, { 7917, 7916}, { 7919, 7918}, { 7921, 7920}, { 7923, 7922}, { 7925, 7924}, +{ 7927, 7926}, { 7929, 7928}, { 7936, 7944}, { 7937, 7945}, { 7938, 7946}, { 7939, 7947}, { 7940, 7948}, +{ 7941, 7949}, { 7942, 7950}, { 7943, 7951}, { 7952, 7960}, { 7953, 7961}, { 7954, 7962}, { 7955, 7963}, +{ 7956, 7964}, { 7957, 7965}, { 7968, 7976}, { 7969, 7977}, { 7970, 7978}, { 7971, 7979}, { 7972, 7980}, +{ 7973, 7981}, { 7974, 7982}, { 7975, 7983}, { 7984, 7992}, { 7985, 7993}, { 7986, 7994}, { 7987, 7995}, +{ 7988, 7996}, { 7989, 7997}, { 7990, 7998}, { 7991, 7999}, { 8000, 8008}, { 8001, 8009}, { 8002, 8010}, +{ 8003, 8011}, { 8004, 8012}, { 8005, 8013}, { 8017, 8025}, { 8019, 8027}, { 8021, 8029}, { 8023, 8031}, +{ 8032, 8040}, { 8033, 8041}, { 8034, 8042}, { 8035, 8043}, { 8036, 8044}, { 8037, 8045}, { 8038, 8046}, +{ 8039, 8047}, { 8048, 8122}, { 8049, 8123}, { 8050, 8136}, { 8051, 8137}, { 8052, 8138}, { 8053, 8139}, +{ 8054, 8154}, { 8055, 8155}, { 8056, 8184}, { 8057, 8185}, { 8058, 8170}, { 8059, 8171}, { 8060, 8186}, +{ 8061, 8187}, { 8112, 8120}, { 8113, 8121}, { 8144, 8152}, { 8145, 8153}, { 8160, 8168}, { 8161, 8169}, +{ 8165, 8172}, { 8560, 8544}, { 8561, 8545}, { 8562, 8546}, { 8563, 8547}, { 8564, 8548}, { 8565, 8549}, +{ 8566, 8550}, { 8567, 8551}, { 8568, 8552}, { 8569, 8553}, { 8570, 8554}, { 8571, 8555}, { 8572, 8556}, +{ 8573, 8557}, { 8574, 8558}, { 8575, 8559}, { 9424, 9398}, { 9425, 9399}, { 9426, 9400}, { 9427, 9401}, +{ 9428, 9402}, { 9429, 9403}, { 9430, 9404}, { 9431, 9405}, { 9432, 9406}, { 9433, 9407}, { 9434, 9408}, +{ 9435, 9409}, { 9436, 9410}, { 9437, 9411}, { 9438, 9412}, { 9439, 9413}, { 9440, 9414}, { 9441, 9415}, +{ 9442, 9416}, { 9443, 9417}, { 9444, 9418}, { 9445, 9419}, { 9446, 9420}, { 9447, 9421}, { 9448, 9422}, +{ 9449, 9423}, {65345,65313}, {65346,65314}, {65347,65315}, {65348,65316}, {65349,65317}, {65350,65318}, +{65351,65319}, {65352,65320}, {65353,65321}, {65354,65322}, {65355,65323}, {65356,65324}, {65357,65325}, +{65358,65326}, {65359,65327}, {65360,65328}, {65361,65329}, {65362,65330}, {65363,65331}, {65364,65332}, +{65365,65333}, {65366,65334}, {65367,65335}, {65368,65336}, {65369,65337}, {65370,65338}, {65535, 0}}; + +static const GUnicodePairType UnicodeToLowerTable[] = { +{ 65, 97}, { 66, 98}, { 67, 99}, { 68, 100}, { 69, 101}, { 70, 102}, { 71, 103}, +{ 72, 104}, { 73, 105}, { 74, 106}, { 75, 107}, { 76, 108}, { 77, 109}, { 78, 110}, +{ 79, 111}, { 80, 112}, { 81, 113}, { 82, 114}, { 83, 115}, { 84, 116}, { 85, 117}, +{ 86, 118}, { 87, 119}, { 88, 120}, { 89, 121}, { 90, 122}, { 192, 224}, { 193, 225}, +{ 194, 226}, { 195, 227}, { 196, 228}, { 197, 229}, { 198, 230}, { 199, 231}, { 200, 232}, +{ 201, 233}, { 202, 234}, { 203, 235}, { 204, 236}, { 205, 237}, { 206, 238}, { 207, 239}, +{ 208, 240}, { 209, 241}, { 210, 242}, { 211, 243}, { 212, 244}, { 213, 245}, { 214, 246}, +{ 216, 248}, { 217, 249}, { 218, 250}, { 219, 251}, { 220, 252}, { 221, 253}, { 222, 254}, +{ 256, 257}, { 258, 259}, { 260, 261}, { 262, 263}, { 264, 265}, { 266, 267}, { 268, 269}, +{ 270, 271}, { 272, 273}, { 274, 275}, { 276, 277}, { 278, 279}, { 280, 281}, { 282, 283}, +{ 284, 285}, { 286, 287}, { 288, 289}, { 290, 291}, { 292, 293}, { 294, 295}, { 296, 297}, +{ 298, 299}, { 300, 301}, { 302, 303}, { 304, 105}, { 306, 307}, { 308, 309}, { 310, 311}, { 313, 314}, +{ 315, 316}, { 317, 318}, { 319, 320}, { 321, 322}, { 323, 324}, { 325, 326}, { 327, 328}, +{ 330, 331}, { 332, 333}, { 334, 335}, { 336, 337}, { 338, 339}, { 340, 341}, { 342, 343}, +{ 344, 345}, { 346, 347}, { 348, 349}, { 350, 351}, { 352, 353}, { 354, 355}, { 356, 357}, +{ 358, 359}, { 360, 361}, { 362, 363}, { 364, 365}, { 366, 367}, { 368, 369}, { 370, 371}, +{ 372, 373}, { 374, 375}, { 376, 255}, { 377, 378}, { 379, 380}, { 381, 382}, { 385, 595}, +{ 386, 387}, { 388, 389}, { 390, 596}, { 391, 392}, { 393, 598}, { 394, 599}, { 395, 396}, +{ 398, 477}, { 399, 601}, { 400, 603}, { 401, 402}, { 403, 608}, { 404, 611}, { 406, 617}, +{ 407, 616}, { 408, 409}, { 412, 623}, { 413, 626}, { 415, 629}, { 416, 417}, { 418, 419}, +{ 420, 421}, { 423, 424}, { 425, 643}, { 428, 429}, { 430, 648}, { 431, 432}, { 433, 650}, +{ 434, 651}, { 435, 436}, { 437, 438}, { 439, 658}, { 440, 441}, { 444, 445}, { 452, 454}, +{ 455, 457}, { 458, 460}, { 461, 462}, { 463, 464}, { 465, 466}, { 467, 468}, { 469, 470}, +{ 471, 472}, { 473, 474}, { 475, 476}, { 478, 479}, { 480, 481}, { 482, 483}, { 484, 485}, +{ 486, 487}, { 488, 489}, { 490, 491}, { 492, 493}, { 494, 495}, { 497, 499}, { 500, 501}, +{ 506, 507}, { 508, 509}, { 510, 511}, { 512, 513}, { 514, 515}, { 516, 517}, { 518, 519}, +{ 520, 521}, { 522, 523}, { 524, 525}, { 526, 527}, { 528, 529}, { 530, 531}, { 532, 533}, +{ 534, 535}, { 902, 940}, { 904, 941}, { 905, 942}, { 906, 943}, { 908, 972}, { 910, 973}, +{ 911, 974}, { 913, 945}, { 914, 946}, { 915, 947}, { 916, 948}, { 917, 949}, { 918, 950}, +{ 919, 951}, { 920, 952}, { 921, 953}, { 922, 954}, { 923, 955}, { 924, 956}, { 925, 957}, +{ 926, 958}, { 927, 959}, { 928, 960}, { 929, 961}, { 931, 963}, { 932, 964}, { 933, 965}, +{ 934, 966}, { 935, 967}, { 936, 968}, { 937, 969}, { 938, 970}, { 939, 971}, { 994, 995}, +{ 996, 997}, { 998, 999}, { 1000, 1001}, { 1002, 1003}, { 1004, 1005}, { 1006, 1007}, { 1024, 1104}, { 1025, 1105}, +{ 1026, 1106}, { 1027, 1107}, { 1028, 1108}, { 1029, 1109}, { 1030, 1110}, { 1031, 1111}, { 1032, 1112}, +{ 1033, 1113}, { 1034, 1114}, { 1035, 1115}, { 1036, 1116}, { 1037, 1117}, { 1038, 1118}, { 1039, 1119}, { 1040, 1072}, +{ 1041, 1073}, { 1042, 1074}, { 1043, 1075}, { 1044, 1076}, { 1045, 1077}, { 1046, 1078}, { 1047, 1079}, +{ 1048, 1080}, { 1049, 1081}, { 1050, 1082}, { 1051, 1083}, { 1052, 1084}, { 1053, 1085}, { 1054, 1086}, +{ 1055, 1087}, { 1056, 1088}, { 1057, 1089}, { 1058, 1090}, { 1059, 1091}, { 1060, 1092}, { 1061, 1093}, +{ 1062, 1094}, { 1063, 1095}, { 1064, 1096}, { 1065, 1097}, { 1066, 1098}, { 1067, 1099}, { 1068, 1100}, +{ 1069, 1101}, { 1070, 1102}, { 1071, 1103}, { 1120, 1121}, { 1122, 1123}, { 1124, 1125}, { 1126, 1127}, +{ 1128, 1129}, { 1130, 1131}, { 1132, 1133}, { 1134, 1135}, { 1136, 1137}, { 1138, 1139}, { 1140, 1141}, +{ 1142, 1143}, { 1144, 1145}, { 1146, 1147}, { 1148, 1149}, { 1150, 1151}, { 1152, 1153}, { 1168, 1169}, +{ 1170, 1171}, { 1172, 1173}, { 1174, 1175}, { 1176, 1177}, { 1178, 1179}, { 1180, 1181}, { 1182, 1183}, +{ 1184, 1185}, { 1186, 1187}, { 1188, 1189}, { 1190, 1191}, { 1192, 1193}, { 1194, 1195}, { 1196, 1197}, +{ 1198, 1199}, { 1200, 1201}, { 1202, 1203}, { 1204, 1205}, { 1206, 1207}, { 1208, 1209}, { 1210, 1211}, +{ 1212, 1213}, { 1214, 1215}, { 1217, 1218}, { 1219, 1220}, { 1223, 1224}, { 1227, 1228}, { 1232, 1233}, +{ 1234, 1235}, { 1236, 1237}, { 1238, 1239}, { 1240, 1241}, { 1242, 1243}, { 1244, 1245}, { 1246, 1247}, +{ 1248, 1249}, { 1250, 1251}, { 1252, 1253}, { 1254, 1255}, { 1256, 1257}, { 1258, 1259}, { 1262, 1263}, +{ 1264, 1265}, { 1266, 1267}, { 1268, 1269}, { 1272, 1273}, { 1329, 1377}, { 1330, 1378}, { 1331, 1379}, +{ 1332, 1380}, { 1333, 1381}, { 1334, 1382}, { 1335, 1383}, { 1336, 1384}, { 1337, 1385}, { 1338, 1386}, +{ 1339, 1387}, { 1340, 1388}, { 1341, 1389}, { 1342, 1390}, { 1343, 1391}, { 1344, 1392}, { 1345, 1393}, +{ 1346, 1394}, { 1347, 1395}, { 1348, 1396}, { 1349, 1397}, { 1350, 1398}, { 1351, 1399}, { 1352, 1400}, +{ 1353, 1401}, { 1354, 1402}, { 1355, 1403}, { 1356, 1404}, { 1357, 1405}, { 1358, 1406}, { 1359, 1407}, +{ 1360, 1408}, { 1361, 1409}, { 1362, 1410}, { 1363, 1411}, { 1364, 1412}, { 1365, 1413}, { 1366, 1414}, +{ 4256, 4304}, { 4257, 4305}, { 4258, 4306}, { 4259, 4307}, { 4260, 4308}, { 4261, 4309}, { 4262, 4310}, +{ 4263, 4311}, { 4264, 4312}, { 4265, 4313}, { 4266, 4314}, { 4267, 4315}, { 4268, 4316}, { 4269, 4317}, +{ 4270, 4318}, { 4271, 4319}, { 4272, 4320}, { 4273, 4321}, { 4274, 4322}, { 4275, 4323}, { 4276, 4324}, +{ 4277, 4325}, { 4278, 4326}, { 4279, 4327}, { 4280, 4328}, { 4281, 4329}, { 4282, 4330}, { 4283, 4331}, +{ 4284, 4332}, { 4285, 4333}, { 4286, 4334}, { 4287, 4335}, { 4288, 4336}, { 4289, 4337}, { 4290, 4338}, +{ 4291, 4339}, { 4292, 4340}, { 4293, 4341}, { 7680, 7681}, { 7682, 7683}, { 7684, 7685}, { 7686, 7687}, +{ 7688, 7689}, { 7690, 7691}, { 7692, 7693}, { 7694, 7695}, { 7696, 7697}, { 7698, 7699}, { 7700, 7701}, +{ 7702, 7703}, { 7704, 7705}, { 7706, 7707}, { 7708, 7709}, { 7710, 7711}, { 7712, 7713}, { 7714, 7715}, +{ 7716, 7717}, { 7718, 7719}, { 7720, 7721}, { 7722, 7723}, { 7724, 7725}, { 7726, 7727}, { 7728, 7729}, +{ 7730, 7731}, { 7732, 7733}, { 7734, 7735}, { 7736, 7737}, { 7738, 7739}, { 7740, 7741}, { 7742, 7743}, +{ 7744, 7745}, { 7746, 7747}, { 7748, 7749}, { 7750, 7751}, { 7752, 7753}, { 7754, 7755}, { 7756, 7757}, +{ 7758, 7759}, { 7760, 7761}, { 7762, 7763}, { 7764, 7765}, { 7766, 7767}, { 7768, 7769}, { 7770, 7771}, +{ 7772, 7773}, { 7774, 7775}, { 7776, 7777}, { 7778, 7779}, { 7780, 7781}, { 7782, 7783}, { 7784, 7785}, +{ 7786, 7787}, { 7788, 7789}, { 7790, 7791}, { 7792, 7793}, { 7794, 7795}, { 7796, 7797}, { 7798, 7799}, +{ 7800, 7801}, { 7802, 7803}, { 7804, 7805}, { 7806, 7807}, { 7808, 7809}, { 7810, 7811}, { 7812, 7813}, +{ 7814, 7815}, { 7816, 7817}, { 7818, 7819}, { 7820, 7821}, { 7822, 7823}, { 7824, 7825}, { 7826, 7827}, +{ 7828, 7829}, { 7840, 7841}, { 7842, 7843}, { 7844, 7845}, { 7846, 7847}, { 7848, 7849}, { 7850, 7851}, +{ 7852, 7853}, { 7854, 7855}, { 7856, 7857}, { 7858, 7859}, { 7860, 7861}, { 7862, 7863}, { 7864, 7865}, +{ 7866, 7867}, { 7868, 7869}, { 7870, 7871}, { 7872, 7873}, { 7874, 7875}, { 7876, 7877}, { 7878, 7879}, +{ 7880, 7881}, { 7882, 7883}, { 7884, 7885}, { 7886, 7887}, { 7888, 7889}, { 7890, 7891}, { 7892, 7893}, +{ 7894, 7895}, { 7896, 7897}, { 7898, 7899}, { 7900, 7901}, { 7902, 7903}, { 7904, 7905}, { 7906, 7907}, +{ 7908, 7909}, { 7910, 7911}, { 7912, 7913}, { 7914, 7915}, { 7916, 7917}, { 7918, 7919}, { 7920, 7921}, +{ 7922, 7923}, { 7924, 7925}, { 7926, 7927}, { 7928, 7929}, { 7944, 7936}, { 7945, 7937}, { 7946, 7938}, +{ 7947, 7939}, { 7948, 7940}, { 7949, 7941}, { 7950, 7942}, { 7951, 7943}, { 7960, 7952}, { 7961, 7953}, +{ 7962, 7954}, { 7963, 7955}, { 7964, 7956}, { 7965, 7957}, { 7976, 7968}, { 7977, 7969}, { 7978, 7970}, +{ 7979, 7971}, { 7980, 7972}, { 7981, 7973}, { 7982, 7974}, { 7983, 7975}, { 7992, 7984}, { 7993, 7985}, +{ 7994, 7986}, { 7995, 7987}, { 7996, 7988}, { 7997, 7989}, { 7998, 7990}, { 7999, 7991}, { 8008, 8000}, +{ 8009, 8001}, { 8010, 8002}, { 8011, 8003}, { 8012, 8004}, { 8013, 8005}, { 8025, 8017}, { 8027, 8019}, +{ 8029, 8021}, { 8031, 8023}, { 8040, 8032}, { 8041, 8033}, { 8042, 8034}, { 8043, 8035}, { 8044, 8036}, +{ 8045, 8037}, { 8046, 8038}, { 8047, 8039}, { 8120, 8112}, { 8121, 8113}, { 8122, 8048}, { 8123, 8049}, +{ 8136, 8050}, { 8137, 8051}, { 8138, 8052}, { 8139, 8053}, { 8152, 8144}, { 8153, 8145}, { 8154, 8054}, +{ 8155, 8055}, { 8168, 8160}, { 8169, 8161}, { 8170, 8058}, { 8171, 8059}, { 8172, 8165}, { 8184, 8056}, +{ 8185, 8057}, { 8186, 8060}, { 8187, 8061}, { 8544, 8560}, { 8545, 8561}, { 8546, 8562}, { 8547, 8563}, +{ 8548, 8564}, { 8549, 8565}, { 8550, 8566}, { 8551, 8567}, { 8552, 8568}, { 8553, 8569}, { 8554, 8570}, +{ 8555, 8571}, { 8556, 8572}, { 8557, 8573}, { 8558, 8574}, { 8559, 8575}, { 9398, 9424}, { 9399, 9425}, +{ 9400, 9426}, { 9401, 9427}, { 9402, 9428}, { 9403, 9429}, { 9404, 9430}, { 9405, 9431}, { 9406, 9432}, +{ 9407, 9433}, { 9408, 9434}, { 9409, 9435}, { 9410, 9436}, { 9411, 9437}, { 9412, 9438}, { 9413, 9439}, +{ 9414, 9440}, { 9415, 9441}, { 9416, 9442}, { 9417, 9443}, { 9418, 9444}, { 9419, 9445}, { 9420, 9446}, +{ 9421, 9447}, { 9422, 9448}, { 9423, 9449}, {65313,65345}, {65314,65346}, {65315,65347}, {65316,65348}, +{65317,65349}, {65318,65350}, {65319,65351}, {65320,65352}, {65321,65353}, {65322,65354}, {65323,65355}, +{65324,65356}, {65325,65357}, {65326,65358}, {65327,65359}, {65328,65360}, {65329,65361}, {65330,65362}, +{65331,65363}, {65332,65364}, {65333,65365}, {65334,65366}, {65335,65367}, {65336,65368}, {65337,65369}, +{65338,65370}, {65535, 0}}; + +int OVR_CDECL OVR_towupper(wchar_t charCode) +{ + // Don't use UnicodeUpperBits! It differs from UnicodeToUpperBits. + if (UnicodeCharIs(UnicodeToUpperBits, charCode)) + { + // To protect from memory overrun in case the character is not found + // we use one extra fake element in the table {65536, 0}. + size_t idx = Alg::LowerBoundSliced( + UnicodeToUpperTable, + 0, + sizeof(UnicodeToUpperTable) / sizeof(UnicodeToUpperTable[0]) - 1, + (uint16_t)charCode, + CmpUnicodeKey); + return UnicodeToUpperTable[idx].Value; + } + return charCode; +} + +int OVR_CDECL OVR_towlower(wchar_t charCode) +{ + // Don't use UnicodeLowerBits! It differs from UnicodeToLowerBits. + if (UnicodeCharIs(UnicodeToLowerBits, charCode)) + { + // To protect from memory overrun in case the character is not found + // we use one extra fake element in the table {65536, 0}. + size_t idx = Alg::LowerBoundSliced( + UnicodeToLowerTable, + 0, + sizeof(UnicodeToLowerTable) / sizeof(UnicodeToLowerTable[0]) - 1, + (uint16_t)charCode, + CmpUnicodeKey); + return UnicodeToLowerTable[idx].Value; + } + return charCode; +} + +#endif //OVR_NO_WCTYPE + +} // OVR diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Kernel/OVR_Std.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Kernel/OVR_Std.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,638 @@ +/************************************************************************************ + +PublicHeader: OVR_Kernel.h +Filename : OVR_Std.h +Content : Standard C function interface +Created : September 19, 2012 +Notes : + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#ifndef OVR_Std_h +#define OVR_Std_h + +#include "OVR_Types.h" +#include // for va_list args +#include +#include +#include +#include + +#if defined(OVR_CC_MSVC) && (OVR_CC_MSVC >= 1400) +#define OVR_MSVC_SAFESTRING +#include +#endif + +// Wide-char funcs +#include +#include + +namespace OVR { + +// Has the same behavior as itoa aside from also having a dest size argument. +// Return value: Pointer to the resulting null-terminated string, same as parameter str. +#if defined(OVR_OS_MS) +inline char* OVR_CDECL OVR_itoa(int val, char *dest, size_t destsize, int radix) +{ +#if defined(OVR_MSVC_SAFESTRING) + _itoa_s(val, dest, destsize, radix); + return dest; +#else + OVR_UNUSED(destsize); + return itoa(val, dest, radix); +#endif +} +#else // OVR_OS_MS +inline char* OVR_itoa(int val, char* dest, size_t len, int radix) +{ + if (val == 0) + { + if (len > 1) + { + dest[0] = '0'; + dest[1] = '\0'; + } + else if(len > 0) + dest[0] = '\0'; + return dest; + } + + // FIXME: Fix the following code to avoid memory write overruns when len is in sufficient. + int cur = val; + size_t i = 0; + size_t sign = 0; + + if (val < 0) + { + val = -val; + sign = 1; + } + + while ((val != 0) && (i < (len - 1 - sign))) + { + cur = val % radix; + val /= radix; + + if (radix == 16) + { + switch(cur) + { + case 10: + dest[i] = 'a'; + break; + case 11: + dest[i] = 'b'; + break; + case 12: + dest[i] = 'c'; + break; + case 13: + dest[i] = 'd'; + break; + case 14: + dest[i] = 'e'; + break; + case 15: + dest[i] = 'f'; + break; + default: + dest[i] = (char)('0' + cur); + break; + } + } + else + { + dest[i] = (char)('0' + cur); + } + ++i; + } + + if (sign) + { + dest[i++] = '-'; + } + + for (size_t j = 0; j < i / 2; ++j) + { + char tmp = dest[j]; + dest[j] = dest[i - 1 - j]; + dest[i - 1 - j] = tmp; + } + dest[i] = '\0'; + + return dest; +} + +#endif + + +// String functions + +inline size_t OVR_CDECL OVR_strlen(const char* str) +{ + return strlen(str); +} + +inline char* OVR_CDECL OVR_strcpy(char* dest, size_t destsize, const char* src) +{ +#if defined(OVR_MSVC_SAFESTRING) + strcpy_s(dest, destsize, src); + return dest; +#else + // FIXME: This should be a safer implementation + OVR_UNUSED(destsize); + return strcpy(dest, src); +#endif +} + + +// Acts the same as the strlcpy function. +// Copies src to dest, 0-terminating even if it involves truncating the write. +// Returns the required strlen of dest (which is one less than the required size of dest). +// strlcpy is a safer alternative to strcpy and strncpy and provides size information. +// However, it still may result in an incomplete copy. +// +// Example usage: +// char buffer[256]; +// if(OVR_strlcpy(buffer, "hello world", sizeof(buffer)) < sizeof(buffer)) +// { there was enough space } +// else +// { need a larger buffer } +// +size_t OVR_CDECL OVR_strlcpy(char* dest, const char* src, size_t destsize); + +// Acts the same as the strlcat function. +// Appends src to dest, 0-terminating even if it involves an incomplete write. +// Doesn't 0-terminate in the case that destsize is 0. +// Returns the required strlen of dest (which is one less than the required size of dest). +// The terminating 0 char of dest is overwritten by the first +// character of src, and a new 0 char is appended to dest. The required capacity +// of the destination is (strlen(src) + strlen(dest) + 1). +// strlcat is a safer alternative to strcat and provides size information. +// However, it still may result in an incomplete copy. +// +// Example usage: +// char buffer[256] = "hello "; +// if(OVR_strlcat(buffer, "world", sizeof(buffer)) < sizeof(buffer)) +// { there was enough space } +// else +// { need a larger buffer } +// +size_t OVR_CDECL OVR_strlcat(char* dest, const char* src, size_t destsize); + + +inline char* OVR_CDECL OVR_strncpy(char* dest, size_t destsize, const char* src, size_t count) +{ +#if defined(OVR_MSVC_SAFESTRING) + strncpy_s(dest, destsize, src, count); + return dest; +#else + // FIXME: This should be a safer implementation + OVR_UNUSED(destsize); + return strncpy(dest, src, count); +#endif +} + +inline char * OVR_CDECL OVR_strcat(char* dest, size_t destsize, const char* src) +{ +#if defined(OVR_MSVC_SAFESTRING) + strcat_s(dest, destsize, src); + return dest; +#else + // FIXME: This should be a safer implementation + OVR_UNUSED(destsize); + return strcat(dest, src); +#endif +} + +inline int OVR_CDECL OVR_strcmp(const char* dest, const char* src) +{ + return strcmp(dest, src); +} + +inline const char* OVR_CDECL OVR_strchr(const char* str, char c) +{ + return strchr(str, c); +} + +inline char* OVR_CDECL OVR_strchr(char* str, char c) +{ + return strchr(str, c); +} + +inline const char* OVR_strrchr(const char* str, char c) +{ + size_t len = OVR_strlen(str); + for (size_t i=len; i>0; i--) + if (str[i]==c) + return str+i; + return 0; +} + +inline const uint8_t* OVR_CDECL OVR_memrchr(const uint8_t* str, size_t size, uint8_t c) +{ + for (intptr_t i = (intptr_t)size - 1; i >= 0; i--) + { + if (str[i] == c) + return str + i; + } + return 0; +} + +inline char* OVR_CDECL OVR_strrchr(char* str, char c) +{ + size_t len = OVR_strlen(str); + for (size_t i=len; i>0; i--) + if (str[i]==c) + return str+i; + return 0; +} + + +double OVR_CDECL OVR_strtod(const char* string, char** tailptr); + +inline long OVR_CDECL OVR_strtol(const char* string, char** tailptr, int radix) +{ + return strtol(string, tailptr, radix); +} + +inline long OVR_CDECL OVR_strtoul(const char* string, char** tailptr, int radix) +{ + return strtoul(string, tailptr, radix); +} + +inline int OVR_CDECL OVR_strncmp(const char* ws1, const char* ws2, size_t size) +{ + return strncmp(ws1, ws2, size); +} + +inline uint64_t OVR_CDECL OVR_strtouq(const char *nptr, char **endptr, int base) +{ +#if defined(OVR_CC_MSVC) + return _strtoui64(nptr, endptr, base); +#else + return strtoull(nptr, endptr, base); +#endif +} + +inline int64_t OVR_CDECL OVR_strtoq(const char *nptr, char **endptr, int base) +{ +#if defined(OVR_CC_MSVC) + return _strtoi64(nptr, endptr, base); +#else + return strtoll(nptr, endptr, base); +#endif +} + + +inline int64_t OVR_CDECL OVR_atoq(const char* string) +{ +#if defined(OVR_CC_MSVC) + return _atoi64(string); +#else + return atoll(string); +#endif +} + +inline uint64_t OVR_CDECL OVR_atouq(const char* string) +{ + return OVR_strtouq(string, NULL, 10); +} + + +// Implemented in OVR_Std.cpp in platform-specific manner. +int OVR_CDECL OVR_stricmp(const char* dest, const char* src); +int OVR_CDECL OVR_strnicmp(const char* dest, const char* src, size_t count); + + +// This is like sprintf but with a destination buffer size argument. However, the behavior is different +// from vsnprintf in that the return value semantics are like sprintf (which returns -1 on capacity overflow) and +// not like snprintf (which returns intended strlen on capacity overflow). +inline size_t OVR_CDECL OVR_sprintf(char *dest, size_t destsize, const char* format, ...) +{ + va_list argList; + va_start(argList,format); + size_t ret; +#if defined(OVR_CC_MSVC) + #if defined(OVR_MSVC_SAFESTRING) + ret = _vsnprintf_s(dest, destsize, _TRUNCATE, format, argList); + OVR_ASSERT(ret != -1); + #else + OVR_UNUSED(destsize); + ret = _vsnprintf(dest, destsize - 1, format, argList); // -1 for space for the null character + OVR_ASSERT(ret != -1); + dest[destsize-1] = 0; + #endif +#else + OVR_UNUSED(destsize); + ret = vsprintf(dest, format, argList); + OVR_ASSERT(ret < destsize); +#endif + va_end(argList); + return ret; +} + + +// This is like vsprintf but with a destination buffer size argument. However, the behavior is different +// from vsnprintf in that the return value semantics are like vsprintf (which returns -1 on capacity overflow) and +// not like vsnprintf (which returns intended strlen on capacity overflow). +// Return value: +// On success, the total number of characters written is returned. +// On failure, a negative number is returned. +inline size_t OVR_CDECL OVR_vsprintf(char *dest, size_t destsize, const char * format, va_list argList) +{ + size_t ret; +#if defined(OVR_CC_MSVC) + #if defined(OVR_MSVC_SAFESTRING) + dest[0] = '\0'; + int rv = vsnprintf_s(dest, destsize, _TRUNCATE, format, argList); + if (rv == -1) + { + dest[destsize - 1] = '\0'; + ret = destsize - 1; + } + else + ret = (size_t)rv; + #else + OVR_UNUSED(destsize); + int rv = _vsnprintf(dest, destsize - 1, format, argList); + OVR_ASSERT(rv != -1); + ret = (size_t)rv; + dest[destsize-1] = 0; + #endif +#else + // FIXME: This should be a safer implementation + OVR_UNUSED(destsize); + ret = (size_t)vsprintf(dest, format, argList); + OVR_ASSERT(ret < destsize); +#endif + return ret; +} + +// Same behavior as ISO C99 vsnprintf. +// Returns the strlen of the resulting formatted string, or a negative value if the format is invalid. +// destsize specifies the capacity of the input buffer. +// +// Example usage: +// void Log(char *dest, size_t destsize, const char * format, ...) +// { +// char buffer[1024]; +// va_list argList; +// va_start(argList,format); +// int result = OVR_vsnprintf(dest, destsize, format, argList); +// assert(result < destsize); // Else we'd have to retry with a dynamically allocated buffer (of size=result+1) and new argList copy. +// va_end(argList); +// } + +inline int OVR_CDECL OVR_vsnprintf(char *dest, size_t destsize, const char * format, va_list argList) +{ + int ret; +#if defined(OVR_CC_MSVC) + OVR_DISABLE_MSVC_WARNING(4996) // 'vsnprintf': This function or variable may be unsafe. + ret = vsnprintf(dest, destsize, format, argList); // Microsoft vsnprintf is non-conforming; it returns -1 if destsize is insufficient. + if (ret < 0) // If there was a format error or if destsize was insufficient... + { + ret = _vscprintf(format, argList); // Get the expected dest strlen. If the return value is still -1 then there was a format error. + + if (destsize) // If we can 0-terminate the output... + { + if (ret < 0) + dest[0] = 0; + else + dest[destsize-1] = 0; + } + } + // Else the string was written OK and ret is its strlen. + OVR_RESTORE_MSVC_WARNING() +#else + ret = vsnprintf(dest, destsize, format, argList); +#endif + return ret; +} + + +// Same behavior as ISO C99 snprintf. +// Returns the strlen of the resulting formatted string, or a negative value if the format is invalid. +// destsize specifies the capacity of the input buffer. +// +// Example usage: +// char buffer[16]; +// int result = OVR_snprintf(buffer, sizeof(buffer), "%d", 37); +// if (result >= sizeof(buffer)) // If there was insufficient capacity... +// { +// char* p = new char[result + 1]; // Or char* p = (char*)OVR_ALLOC(result + 1); +// OVR_snprintf(p, (size_t)result, "%d", 37); +// delete[] p; +// } +// +inline int OVR_CDECL OVR_snprintf(char *dest, size_t destsize, const char * format, ...) +{ + va_list argList; + va_start(argList,format); + int ret = OVR_vsnprintf(dest, destsize, format, argList); + va_end(argList); + return ret; +} + + +// Returns the strlen of the resulting formatted string, or a negative value if the format is invalid. +// Note: If you are planning on printing a string then it's more efficient to just use OVR_vsnprintf and +// look at the return value and handle the uncommon case that there wasn't enough space. +inline int OVR_CDECL OVR_vscprintf(const char * format, va_list argList) +{ + int ret; +#if defined(OVR_CC_MSVC) + ret = _vscprintf(format, argList); +#else + ret = vsnprintf(NULL, 0, format, argList); +#endif + return ret; +} + + +wchar_t* OVR_CDECL OVR_wcscpy(wchar_t* dest, size_t destsize, const wchar_t* src); +wchar_t* OVR_CDECL OVR_wcsncpy(wchar_t* dest, size_t destsize, const wchar_t* src, size_t count); +wchar_t* OVR_CDECL OVR_wcscat(wchar_t* dest, size_t destsize, const wchar_t* src); +size_t OVR_CDECL OVR_wcslen(const wchar_t* str); +int OVR_CDECL OVR_wcscmp(const wchar_t* a, const wchar_t* b); +int OVR_CDECL OVR_wcsicmp(const wchar_t* a, const wchar_t* b); + +inline int OVR_CDECL OVR_wcsicoll(const wchar_t* a, const wchar_t* b) +{ +#if defined(OVR_OS_MS) + #if defined(OVR_CC_MSVC) && (OVR_CC_MSVC >= 1400) + return ::_wcsicoll(a, b); + #else + return ::wcsicoll(a, b); + #endif +#else + // not supported, use regular wcsicmp + return OVR_wcsicmp(a, b); +#endif +} + +inline int OVR_CDECL OVR_wcscoll(const wchar_t* a, const wchar_t* b) +{ +#if defined(OVR_OS_MS) || defined(OVR_OS_LINUX) + return wcscoll(a, b); +#else + // not supported, use regular wcscmp + return OVR_wcscmp(a, b); +#endif +} + +#ifndef OVR_NO_WCTYPE + +inline int OVR_CDECL UnicodeCharIs(const uint16_t* table, wchar_t charCode) +{ + unsigned offset = table[charCode >> 8]; + if (offset == 0) return 0; + if (offset == 1) return 1; + return (table[offset + ((charCode >> 4) & 15)] & (1 << (charCode & 15))) != 0; +} + +extern const uint16_t UnicodeAlnumBits[]; +extern const uint16_t UnicodeAlphaBits[]; +extern const uint16_t UnicodeDigitBits[]; +extern const uint16_t UnicodeSpaceBits[]; +extern const uint16_t UnicodeXDigitBits[]; + +// Uncomment if necessary +//extern const uint16_t UnicodeCntrlBits[]; +//extern const uint16_t UnicodeGraphBits[]; +//extern const uint16_t UnicodeLowerBits[]; +//extern const uint16_t UnicodePrintBits[]; +//extern const uint16_t UnicodePunctBits[]; +//extern const uint16_t UnicodeUpperBits[]; + +inline int OVR_CDECL OVR_iswalnum (wchar_t charCode) { return UnicodeCharIs(UnicodeAlnumBits, charCode); } +inline int OVR_CDECL OVR_iswalpha (wchar_t charCode) { return UnicodeCharIs(UnicodeAlphaBits, charCode); } +inline int OVR_CDECL OVR_iswdigit (wchar_t charCode) { return UnicodeCharIs(UnicodeDigitBits, charCode); } +inline int OVR_CDECL OVR_iswspace (wchar_t charCode) { return UnicodeCharIs(UnicodeSpaceBits, charCode); } +inline int OVR_CDECL OVR_iswxdigit(wchar_t charCode) { return UnicodeCharIs(UnicodeXDigitBits, charCode); } + +// Uncomment if necessary +//inline int OVR_CDECL OVR_iswcntrl (wchar_t charCode) { return UnicodeCharIs(UnicodeCntrlBits, charCode); } +//inline int OVR_CDECL OVR_iswgraph (wchar_t charCode) { return UnicodeCharIs(UnicodeGraphBits, charCode); } +//inline int OVR_CDECL OVR_iswlower (wchar_t charCode) { return UnicodeCharIs(UnicodeLowerBits, charCode); } +//inline int OVR_CDECL OVR_iswprint (wchar_t charCode) { return UnicodeCharIs(UnicodePrintBits, charCode); } +//inline int OVR_CDECL OVR_iswpunct (wchar_t charCode) { return UnicodeCharIs(UnicodePunctBits, charCode); } +//inline int OVR_CDECL OVR_iswupper (wchar_t charCode) { return UnicodeCharIs(UnicodeUpperBits, charCode); } + +int OVR_CDECL OVR_towupper(wchar_t charCode); +int OVR_CDECL OVR_towlower(wchar_t charCode); + +#else // OVR_NO_WCTYPE + +inline int OVR_CDECL OVR_iswspace(wchar_t c) +{ + return iswspace(c); +} + +inline int OVR_CDECL OVR_iswdigit(wchar_t c) +{ + return iswdigit(c); +} + +inline int OVR_CDECL OVR_iswxdigit(wchar_t c) +{ + return iswxdigit(c); +} + +inline int OVR_CDECL OVR_iswalpha(wchar_t c) +{ + return iswalpha(c); +} + +inline int OVR_CDECL OVR_iswalnum(wchar_t c) +{ + return iswalnum(c); +} + +inline wchar_t OVR_CDECL OVR_towlower(wchar_t c) +{ + return (wchar_t)towlower(c); +} + +inline wchar_t OVR_towupper(wchar_t c) +{ + return (wchar_t)towupper(c); +} + +#endif // OVR_NO_WCTYPE + +// ASCII versions of tolower and toupper. Don't use "char" +inline int OVR_CDECL OVR_tolower(int c) +{ + return (c >= 'A' && c <= 'Z') ? c - 'A' + 'a' : c; +} + +inline int OVR_CDECL OVR_toupper(int c) +{ + return (c >= 'a' && c <= 'z') ? c - 'a' + 'A' : c; +} + + + +inline double OVR_CDECL OVR_wcstod(const wchar_t* string, wchar_t** tailptr) +{ +#if defined(OVR_OS_OTHER) + OVR_UNUSED(tailptr); + char buffer[64]; + char* tp = NULL; + size_t max = OVR_wcslen(string); + if (max > 63) max = 63; + unsigned char c = 0; + for (size_t i=0; i < max; i++) + { + c = (unsigned char)string[i]; + buffer[i] = ((c) < 128 ? (char)c : '!'); + } + buffer[max] = 0; + return OVR_strtod(buffer, &tp); +#else + return wcstod(string, tailptr); +#endif +} + +inline long OVR_CDECL OVR_wcstol(const wchar_t* string, wchar_t** tailptr, int radix) +{ +#if defined(OVR_OS_OTHER) + OVR_UNUSED(tailptr); + char buffer[64]; + char* tp = NULL; + size_t max = OVR_wcslen(string); + if (max > 63) max = 63; + unsigned char c = 0; + for (size_t i=0; i < max; i++) + { + c = (unsigned char)string[i]; + buffer[i] = ((c) < 128 ? (char)c : '!'); + } + buffer[max] = 0; + return strtol(buffer, &tp, radix); +#else + return wcstol(string, tailptr, radix); +#endif +} + +} // OVR + +#endif // OVR_Std_h diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Kernel/OVR_String.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Kernel/OVR_String.cpp Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,779 @@ +/************************************************************************************ + +Filename : OVR_String.cpp +Content : String UTF8 string implementation with copy-on-write semantics + (thread-safe for assignment but not modification). +Created : September 19, 2012 +Notes : + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#include "OVR_String.h" + +#include +#include + +#ifdef OVR_OS_QNX +# include +#endif + +namespace OVR { + +#define String_LengthIsSize (size_t(1) << String::Flag_LengthIsSizeShift) + +String::DataDesc String::NullData = {String_LengthIsSize, 1, {0} }; + + +String::String() +{ + pData = &NullData; + pData->AddRef(); +}; + +String::String(const char* pdata) +{ + // Obtain length in bytes; it doesn't matter if _data is UTF8. + size_t size = pdata ? OVR_strlen(pdata) : 0; + pData = AllocDataCopy1(size, 0, pdata, size); +}; + +String::String(const char* pdata1, const char* pdata2, const char* pdata3) +{ + // Obtain length in bytes; it doesn't matter if _data is UTF8. + size_t size1 = pdata1 ? OVR_strlen(pdata1) : 0; + size_t size2 = pdata2 ? OVR_strlen(pdata2) : 0; + size_t size3 = pdata3 ? OVR_strlen(pdata3) : 0; + + DataDesc *pdataDesc = AllocDataCopy2(size1 + size2 + size3, 0, + pdata1, size1, pdata2, size2); + memcpy(pdataDesc->Data + size1 + size2, pdata3, size3); + pData = pdataDesc; +} + +String::String(const char* pdata, size_t size) +{ + OVR_ASSERT((size == 0) || (pdata != 0)); + pData = AllocDataCopy1(size, 0, pdata, size); +}; + + +String::String(const InitStruct& src, size_t size) +{ + pData = AllocData(size, 0); + src.InitString(GetData()->Data, size); +} + +String::String(const String& src) +{ + pData = src.GetData(); + pData->AddRef(); +} + +String::String(const StringBuffer& src) +{ + pData = AllocDataCopy1(src.GetSize(), 0, src.ToCStr(), src.GetSize()); +} + +String::String(const wchar_t* data) +{ + pData = &NullData; + pData->AddRef(); + // Simplified logic for wchar_t constructor. + if (data) + *this = data; +} + + +String::DataDesc* String::AllocData(size_t size, size_t lengthIsSize) +{ + String::DataDesc* pdesc; + + if (size == 0) + { + pdesc = &NullData; + pdesc->AddRef(); + return pdesc; + } + + pdesc = (DataDesc*)OVR_ALLOC(sizeof(DataDesc)+ size); + pdesc->Data[size] = 0; + pdesc->RefCount = 1; + pdesc->Size = size | lengthIsSize; + return pdesc; +} + + +String::DataDesc* String::AllocDataCopy1(size_t size, size_t lengthIsSize, + const char* pdata, size_t copySize) +{ + String::DataDesc* pdesc = AllocData(size, lengthIsSize); + memcpy(pdesc->Data, pdata, copySize); + return pdesc; +} + +String::DataDesc* String::AllocDataCopy2(size_t size, size_t lengthIsSize, + const char* pdata1, size_t copySize1, + const char* pdata2, size_t copySize2) +{ + String::DataDesc* pdesc = AllocData(size, lengthIsSize); + memcpy(pdesc->Data, pdata1, copySize1); + memcpy(pdesc->Data + copySize1, pdata2, copySize2); + return pdesc; +} + + +size_t String::GetLength() const +{ + // Optimize length accesses for non-UTF8 character strings. + DataDesc* pdata = GetData(); + size_t length, size = pdata->GetSize(); + + if (pdata->LengthIsSize()) + return size; + + length = (size_t)UTF8Util::GetLength(pdata->Data, (size_t)size); + + if (length == size) + pdata->Size |= String_LengthIsSize; + + return length; +} + + +//static uint32_t String_CharSearch(const char* buf, ) + + +uint32_t String::GetCharAt(size_t index) const +{ + intptr_t i = (intptr_t) index; + DataDesc* pdata = GetData(); + const char* buf = pdata->Data; + uint32_t c; + + if (pdata->LengthIsSize()) + { + OVR_ASSERT(index < pdata->GetSize()); + buf += i; + return UTF8Util::DecodeNextChar_Advance0(&buf); + } + + c = UTF8Util::GetCharAt(index, buf, pdata->GetSize()); + return c; +} + +uint32_t String::GetFirstCharAt(size_t index, const char** offset) const +{ + DataDesc* pdata = GetData(); + intptr_t i = (intptr_t) index; + const char* buf = pdata->Data; + const char* end = buf + pdata->GetSize(); + uint32_t c; + + do + { + c = UTF8Util::DecodeNextChar_Advance0(&buf); + i--; + + if (buf >= end) + { + // We've hit the end of the string; don't go further. + OVR_ASSERT(i == 0); + return c; + } + } while (i >= 0); + + *offset = buf; + + return c; +} + +uint32_t String::GetNextChar(const char** offset) const +{ + return UTF8Util::DecodeNextChar(offset); +} + + + +void String::AppendChar(uint32_t ch) +{ + DataDesc* pdata = GetData(); + size_t size = pdata->GetSize(); + char buff[8]; + intptr_t encodeSize = 0; + + // Converts ch into UTF8 string and fills it into buff. + UTF8Util::EncodeChar(buff, &encodeSize, ch); + OVR_ASSERT(encodeSize >= 0); + + SetData(AllocDataCopy2(size + (size_t)encodeSize, 0, + pdata->Data, size, buff, (size_t)encodeSize)); + pdata->Release(); +} + + +void String::AppendString(const wchar_t* pstr, intptr_t len) +{ + if (!pstr) + return; + + DataDesc* pdata = GetData(); + size_t oldSize = pdata->GetSize(); + size_t encodeSize = (size_t)UTF8Util::GetEncodeStringSize(pstr, len); + + DataDesc* pnewData = AllocDataCopy1(oldSize + (size_t)encodeSize, 0, + pdata->Data, oldSize); + UTF8Util::EncodeString(pnewData->Data + oldSize, pstr, len); + + SetData(pnewData); + pdata->Release(); +} + + +void String::AppendString(const char* putf8str, intptr_t utf8StrSz) +{ + if (!putf8str || !utf8StrSz) + return; + if (utf8StrSz == -1) + utf8StrSz = (intptr_t)OVR_strlen(putf8str); + + DataDesc* pdata = GetData(); + size_t oldSize = pdata->GetSize(); + + SetData(AllocDataCopy2(oldSize + (size_t)utf8StrSz, 0, + pdata->Data, oldSize, putf8str, (size_t)utf8StrSz)); + pdata->Release(); +} + +void String::AssignString(const InitStruct& src, size_t size) +{ + DataDesc* poldData = GetData(); + DataDesc* pnewData = AllocData(size, 0); + src.InitString(pnewData->Data, size); + SetData(pnewData); + poldData->Release(); +} + +void String::AssignString(const char* putf8str, size_t size) +{ + DataDesc* poldData = GetData(); + SetData(AllocDataCopy1(size, 0, putf8str, size)); + poldData->Release(); +} + +void String::operator = (const char* pstr) +{ + AssignString(pstr, pstr ? OVR_strlen(pstr) : 0); +} + +void String::operator = (const wchar_t* pwstr) +{ + pwstr = pwstr ? pwstr : L""; + + DataDesc* poldData = GetData(); + size_t size = (size_t)UTF8Util::GetEncodeStringSize(pwstr); + + DataDesc* pnewData = AllocData(size, 0); + UTF8Util::EncodeString(pnewData->Data, pwstr); + SetData(pnewData); + poldData->Release(); +} + + +void String::operator = (const String& src) +{ + DataDesc* psdata = src.GetData(); + DataDesc* pdata = GetData(); + + SetData(psdata); + psdata->AddRef(); + pdata->Release(); +} + + +void String::operator = (const StringBuffer& src) +{ + DataDesc* polddata = GetData(); + SetData(AllocDataCopy1(src.GetSize(), 0, src.ToCStr(), src.GetSize())); + polddata->Release(); +} + +void String::operator += (const String& src) +{ + DataDesc *pourData = GetData(), + *psrcData = src.GetData(); + size_t ourSize = pourData->GetSize(), + srcSize = psrcData->GetSize(); + size_t lflag = pourData->GetLengthFlag() & psrcData->GetLengthFlag(); + + SetData(AllocDataCopy2(ourSize + srcSize, lflag, + pourData->Data, ourSize, psrcData->Data, srcSize)); + pourData->Release(); +} + + +String String::operator + (const char* str) const +{ + String tmp1(*this); + tmp1 += (str ? str : ""); + return tmp1; +} + +String String::operator + (const String& src) const +{ + String tmp1(*this); + tmp1 += src; + return tmp1; +} + +void String::Remove(size_t posAt, intptr_t removeLength) +{ + DataDesc* pdata = GetData(); + size_t oldSize = pdata->GetSize(); + // Length indicates the number of characters to remove. + size_t length = GetLength(); + + // If index is past the string, nothing to remove. + if (posAt >= length) + return; + // Otherwise, cap removeLength to the length of the string. + if ((posAt + removeLength) > length) + removeLength = length - posAt; + + // Get the byte position of the UTF8 char at position posAt. + intptr_t bytePos = UTF8Util::GetByteIndex(posAt, pdata->Data, oldSize); + intptr_t removeSize = UTF8Util::GetByteIndex(removeLength, pdata->Data + bytePos, oldSize-bytePos); + + SetData(AllocDataCopy2(oldSize - removeSize, pdata->GetLengthFlag(), + pdata->Data, bytePos, + pData->Data + bytePos + removeSize, (oldSize - bytePos - removeSize))); + pdata->Release(); +} + + +String String::Substring(size_t start, size_t end) const +{ + size_t length = GetLength(); + if ((start >= length) || (start >= end)) + return String(); + + DataDesc* pdata = GetData(); + + // If size matches, we know the exact index range. + if (pdata->LengthIsSize()) + return String(pdata->Data + start, end - start); + + // Get position of starting character. + intptr_t byteStart = UTF8Util::GetByteIndex(start, pdata->Data, pdata->GetSize()); + intptr_t byteSize = UTF8Util::GetByteIndex(end - start, pdata->Data + byteStart, pdata->GetSize()-byteStart); + return String(pdata->Data + byteStart, (size_t)byteSize); +} + +void String::Clear() +{ + NullData.AddRef(); + GetData()->Release(); + SetData(&NullData); +} + + +String String::ToUpper() const +{ + uint32_t c; + const char* psource = GetData()->Data; + const char* pend = psource + GetData()->GetSize(); + String str; + intptr_t bufferOffset = 0; + char buffer[512]; + + while(psource < pend) + { + do { + c = UTF8Util::DecodeNextChar_Advance0(&psource); + UTF8Util::EncodeChar(buffer, &bufferOffset, OVR_towupper(wchar_t(c))); + } while ((psource < pend) && (bufferOffset < intptr_t(sizeof(buffer)-8))); + + // Append string a piece at a time. + str.AppendString(buffer, bufferOffset); + bufferOffset = 0; + } + + return str; +} + +String String::ToLower() const +{ + uint32_t c; + const char* psource = GetData()->Data; + const char* pend = psource + GetData()->GetSize(); + String str; + intptr_t bufferOffset = 0; + char buffer[512]; + + while(psource < pend) + { + do { + c = UTF8Util::DecodeNextChar_Advance0(&psource); + UTF8Util::EncodeChar(buffer, &bufferOffset, OVR_towlower(wchar_t(c))); + } while ((psource < pend) && (bufferOffset < intptr_t(sizeof(buffer)-8))); + + // Append string a piece at a time. + str.AppendString(buffer, bufferOffset); + bufferOffset = 0; + } + + return str; +} + + + +String& String::Insert(const char* substr, size_t posAt, intptr_t strSize) +{ + DataDesc* poldData = GetData(); + size_t oldSize = poldData->GetSize(); + size_t insertSize = (strSize < 0) ? OVR_strlen(substr) : (size_t)strSize; + size_t byteIndex = (poldData->LengthIsSize()) ? + posAt : (size_t)UTF8Util::GetByteIndex(posAt, poldData->Data, oldSize); + + OVR_ASSERT(byteIndex <= oldSize); + + DataDesc* pnewData = AllocDataCopy2(oldSize + insertSize, 0, + poldData->Data, byteIndex, substr, insertSize); + memcpy(pnewData->Data + byteIndex + insertSize, + poldData->Data + byteIndex, oldSize - byteIndex); + SetData(pnewData); + poldData->Release(); + return *this; +} + +/* +String& String::Insert(const uint32_t* substr, size_t posAt, intptr_t len) +{ + for (intptr_t i = 0; i < len; ++i) + { + size_t charw = InsertCharAt(substr[i], posAt); + posAt += charw; + } + return *this; +} +*/ + +size_t String::InsertCharAt(uint32_t c, size_t posAt) +{ + char buf[8]; + intptr_t index = 0; + UTF8Util::EncodeChar(buf, &index, c); + OVR_ASSERT(index >= 0); + buf[(size_t)index] = 0; + + Insert(buf, posAt, index); + return (size_t)index; +} + + +int String::CompareNoCase(const char* a, const char* b) +{ + return OVR_stricmp(a, b); +} + +int String::CompareNoCase(const char* a, const char* b, intptr_t len) +{ + if (len) + { + intptr_t f,l; + intptr_t slen = len; + const char *s = b; + do { + f = (intptr_t)OVR_tolower((int)(*(a++))); + l = (intptr_t)OVR_tolower((int)(*(b++))); + } while (--len && f && (f == l) && *b != 0); + + if (f == l && (len != 0 || *b != 0)) + { + f = (intptr_t)slen; + l = (intptr_t)OVR_strlen(s); + return int(f - l); + } + + return int(f - l); + } + else + return (0-(int)OVR_strlen(b)); +} + +// ***** Implement hash static functions + +// Hash function +size_t String::BernsteinHashFunction(const void* pdataIn, size_t size, size_t seed) +{ + const uint8_t* pdata = (const uint8_t*) pdataIn; + size_t h = seed; + while (size > 0) + { + size--; + h = ((h << 5) + h) ^ (unsigned) pdata[size]; + } + + return h; +} + +// Hash function, case-insensitive +size_t String::BernsteinHashFunctionCIS(const void* pdataIn, size_t size, size_t seed) +{ + const uint8_t* pdata = (const uint8_t*) pdataIn; + size_t h = seed; + while (size > 0) + { + size--; + h = ((h << 5) + h) ^ OVR_tolower(pdata[size]); + } + + // Alternative: "sdbm" hash function, suggested at same web page above. + // h = 0; + // for bytes { h = (h << 16) + (h << 6) - hash + *p; } + return h; +} + + + +// ***** String Buffer used for Building Strings + + +#define OVR_SBUFF_DEFAULT_GROW_SIZE 512 +// Constructors / Destructor. +StringBuffer::StringBuffer() + : pData(NULL), Size(0), BufferSize(0), GrowSize(OVR_SBUFF_DEFAULT_GROW_SIZE), LengthIsSize(false) +{ +} + +StringBuffer::StringBuffer(size_t growSize) + : pData(NULL), Size(0), BufferSize(0), GrowSize(OVR_SBUFF_DEFAULT_GROW_SIZE), LengthIsSize(false) +{ + SetGrowSize(growSize); +} + +StringBuffer::StringBuffer(const char* data) + : pData(NULL), Size(0), BufferSize(0), GrowSize(OVR_SBUFF_DEFAULT_GROW_SIZE), LengthIsSize(false) +{ + AppendString(data); +} + +StringBuffer::StringBuffer(const char* data, size_t dataSize) + : pData(NULL), Size(0), BufferSize(0), GrowSize(OVR_SBUFF_DEFAULT_GROW_SIZE), LengthIsSize(false) +{ + AppendString(data, dataSize); +} + +StringBuffer::StringBuffer(const String& src) + : pData(NULL), Size(0), BufferSize(0), GrowSize(OVR_SBUFF_DEFAULT_GROW_SIZE), LengthIsSize(false) +{ + AppendString(src.ToCStr(), src.GetSize()); +} + +StringBuffer::StringBuffer(const StringBuffer& src) + : pData(NULL), Size(0), BufferSize(0), GrowSize(OVR_SBUFF_DEFAULT_GROW_SIZE), LengthIsSize(false) +{ + AppendString(src.ToCStr(), src.GetSize()); +} + +StringBuffer::StringBuffer(const wchar_t* data) + : pData(NULL), Size(0), BufferSize(0), GrowSize(OVR_SBUFF_DEFAULT_GROW_SIZE), LengthIsSize(false) +{ + *this = data; +} + +StringBuffer::~StringBuffer() +{ + if (pData) + OVR_FREE(pData); +} +void StringBuffer::SetGrowSize(size_t growSize) +{ + if (growSize <= 16) + GrowSize = 16; + else + { + uint8_t bits = Alg::UpperBit(uint32_t(growSize-1)); + size_t size = (size_t)1 << bits; + GrowSize = size == growSize ? growSize : size; + } +} + +size_t StringBuffer::GetLength() const +{ + size_t length, size = GetSize(); + if (LengthIsSize) + return size; + + length = (size_t)UTF8Util::GetLength(pData, (size_t)GetSize()); + + if (length == GetSize()) + LengthIsSize = true; + return length; +} + +void StringBuffer::Reserve(size_t _size) +{ + if (_size >= BufferSize) // >= because of trailing zero! (!AB) + { + BufferSize = (_size + 1 + GrowSize - 1)& ~(GrowSize-1); + if (!pData) + pData = (char*)OVR_ALLOC(BufferSize); + else + pData = (char*)OVR_REALLOC(pData, BufferSize); + } +} +void StringBuffer::Resize(size_t _size) +{ + Reserve(_size); + LengthIsSize = false; + Size = _size; + if (pData) + pData[Size] = 0; +} + +void StringBuffer::Clear() +{ + Resize(0); + /* + if (pData != pEmptyNullData) + { + OVR_FREE(pHeap, pData); + pData = pEmptyNullData; + Size = BufferSize = 0; + LengthIsSize = false; + } + */ +} +// Appends a character +void StringBuffer::AppendChar(uint32_t ch) +{ + char buff[8]; + size_t origSize = GetSize(); + + // Converts ch into UTF8 string and fills it into buff. Also increments index according to the number of bytes + // in the UTF8 string. + intptr_t srcSize = 0; + UTF8Util::EncodeChar(buff, &srcSize, ch); + OVR_ASSERT(srcSize >= 0); + + size_t size = origSize + srcSize; + Resize(size); + OVR_ASSERT(pData != NULL); + memcpy(pData + origSize, buff, srcSize); +} + +// Append a string +void StringBuffer::AppendString(const wchar_t* pstr, intptr_t len) +{ + if (!pstr || !len) + return; + + intptr_t srcSize = UTF8Util::GetEncodeStringSize(pstr, len); + size_t origSize = GetSize(); + size_t size = srcSize + origSize; + + Resize(size); + OVR_ASSERT(pData != NULL); + UTF8Util::EncodeString(pData + origSize, pstr, len); +} + +void StringBuffer::AppendString(const char* putf8str, intptr_t utf8StrSz) +{ + if (!putf8str || !utf8StrSz) + return; + if (utf8StrSz == -1) + utf8StrSz = (intptr_t)OVR_strlen(putf8str); + + size_t origSize = GetSize(); + size_t size = utf8StrSz + origSize; + + Resize(size); + OVR_ASSERT(pData != NULL); + memcpy(pData + origSize, putf8str, utf8StrSz); +} + +// If pstr is NULL then the StringBuffer is cleared. +void StringBuffer::operator = (const char* pstr) +{ + pstr = pstr ? pstr : ""; + size_t size = OVR_strlen(pstr); + Resize(size); + OVR_ASSERT((pData != NULL) || (size == 0)); + memcpy(pData, pstr, size); +} + +// If pstr is NULL then the StringBuffer is cleared. +void StringBuffer::operator = (const wchar_t* pstr) +{ + pstr = pstr ? pstr : L""; + size_t size = (size_t)UTF8Util::GetEncodeStringSize(pstr); + Resize(size); + OVR_ASSERT((pData != NULL) || (size == 0)); + UTF8Util::EncodeString(pData, pstr); +} + +void StringBuffer::operator = (const String& src) +{ + const size_t size = src.GetSize(); + Resize(size); + OVR_ASSERT((pData != NULL) || (size == 0)); + memcpy(pData, src.ToCStr(), size); +} + +void StringBuffer::operator = (const StringBuffer& src) +{ + Clear(); + AppendString(src.ToCStr(), src.GetSize()); +} + + +// Inserts substr at posAt +void StringBuffer::Insert(const char* substr, size_t posAt, intptr_t len) +{ + size_t oldSize = Size; + size_t insertSize = (len < 0) ? OVR_strlen(substr) : (size_t)len; + size_t byteIndex = LengthIsSize ? posAt : + (size_t)UTF8Util::GetByteIndex(posAt, pData, (intptr_t)Size); + + OVR_ASSERT(byteIndex <= oldSize); + Reserve(oldSize + insertSize); + + OVR_ASSERT(pData != NULL); // pData is unilaterally written to below. + memmove(pData + byteIndex + insertSize, pData + byteIndex, oldSize - byteIndex + 1); + memcpy (pData + byteIndex, substr, insertSize); + LengthIsSize = false; + Size = oldSize + insertSize; + pData[Size] = 0; +} + +// Inserts character at posAt +size_t StringBuffer::InsertCharAt(uint32_t c, size_t posAt) +{ + char buf[8]; + intptr_t len = 0; + UTF8Util::EncodeChar(buf, &len, c); + OVR_ASSERT(len >= 0); + buf[(size_t)len] = 0; + + Insert(buf, posAt, len); + return (size_t)len; +} + +} // OVR diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Kernel/OVR_String.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Kernel/OVR_String.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,658 @@ +/************************************************************************************ + +PublicHeader: OVR_Kernel.h +Filename : OVR_String.h +Content : String UTF8 string implementation with copy-on-write semantics + (thread-safe for assignment but not modification). +Created : September 19, 2012 +Notes : + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#ifndef OVR_String_h +#define OVR_String_h + +#include "OVR_Types.h" +#include "OVR_Allocator.h" +#include "OVR_UTF8Util.h" +#include "OVR_Atomic.h" +#include "OVR_Std.h" +#include "OVR_Alg.h" + +namespace OVR { + +// ***** Classes + +class String; +class StringBuffer; + + +//----------------------------------------------------------------------------------- +// ***** String Class + +// String is UTF8 based string class with copy-on-write implementation +// for assignment. + +class String +{ +protected: + + enum FlagConstants + { + //Flag_GetLength = 0x7FFFFFFF, + // This flag is set if GetLength() == GetSize() for a string. + // Avoid extra scanning is Substring and indexing logic. + Flag_LengthIsSizeShift = (sizeof(size_t)*8 - 1) + }; + + + // Internal structure to hold string data + struct DataDesc + { + // Number of bytes. Will be the same as the number of chars if the characters + // are ascii, may not be equal to number of chars in case string data is UTF8. + size_t Size; + volatile int32_t RefCount; + char Data[1]; + + void AddRef() + { + AtomicOps::ExchangeAdd_NoSync(&RefCount, 1); + } + // Decrement ref count. This needs to be thread-safe, since + // a different thread could have also decremented the ref count. + // For example, if u start off with a ref count = 2. Now if u + // decrement the ref count and check against 0 in different + // statements, a different thread can also decrement the ref count + // in between our decrement and checking against 0 and will find + // the ref count = 0 and delete the object. This will lead to a crash + // when context switches to our thread and we'll be trying to delete + // an already deleted object. Hence decrementing the ref count and + // checking against 0 needs to made an atomic operation. + void Release() + { + if ((AtomicOps::ExchangeAdd_NoSync(&RefCount, -1) - 1) == 0) + OVR_FREE(this); + } + + static size_t GetLengthFlagBit() { return size_t(1) << Flag_LengthIsSizeShift; } + size_t GetSize() const { return Size & ~GetLengthFlagBit() ; } + size_t GetLengthFlag() const { return Size & GetLengthFlagBit(); } + bool LengthIsSize() const { return GetLengthFlag() != 0; } + }; + + // Heap type of the string is encoded in the lower bits. + enum HeapType + { + HT_Global = 0, // Heap is global. + HT_Local = 1, // SF::String_loc: Heap is determined based on string's address. + HT_Dynamic = 2, // SF::String_temp: Heap is stored as a part of the class. + HT_Mask = 3 + }; + + union { + DataDesc* pData; + size_t HeapTypeBits; + }; + typedef union { + DataDesc* pData; + size_t HeapTypeBits; + } DataDescUnion; + + inline HeapType GetHeapType() const { return (HeapType) (HeapTypeBits & HT_Mask); } + + inline DataDesc* GetData() const + { + DataDescUnion u; + u.pData = pData; + u.HeapTypeBits = (u.HeapTypeBits & ~(size_t)HT_Mask); + return u.pData; + } + + inline void SetData(DataDesc* pdesc) + { + HeapType ht = GetHeapType(); + pData = pdesc; + OVR_ASSERT((HeapTypeBits & HT_Mask) == 0); + HeapTypeBits |= ht; + } + + + DataDesc* AllocData(size_t size, size_t lengthIsSize); + DataDesc* AllocDataCopy1(size_t size, size_t lengthIsSize, + const char* pdata, size_t copySize); + DataDesc* AllocDataCopy2(size_t size, size_t lengthIsSize, + const char* pdata1, size_t copySize1, + const char* pdata2, size_t copySize2); + + // Special constructor to avoid data initalization when used in derived class. + struct NoConstructor { }; + String(const NoConstructor&) { } + +public: + + // For initializing string with dynamic buffer + struct InitStruct + { + virtual ~InitStruct() { } + virtual void InitString(char* pbuffer, size_t size) const = 0; + }; + + + // Constructors / Destructors. + String(); + String(const char* data); + String(const char* data1, const char* pdata2, const char* pdata3 = 0); + String(const char* data, size_t buflen); + String(const String& src); + String(const StringBuffer& src); + String(const InitStruct& src, size_t size); + explicit String(const wchar_t* data); + + // Destructor (Captain Obvious guarantees!) + ~String() + { + GetData()->Release(); + } + + // Declaration of NullString + static DataDesc NullData; + + + // *** General Functions + + void Clear(); + + // For casting to a pointer to char. + operator const char*() const { return GetData()->Data; } + // Pointer to raw buffer. + const char* ToCStr() const { return GetData()->Data; } + + // Returns number of bytes + size_t GetSize() const { return GetData()->GetSize() ; } + // Tells whether or not the string is empty + bool IsEmpty() const { return GetSize() == 0; } + + // Returns number of characters + size_t GetLength() const; + int GetLengthI() const { return (int)GetLength(); } + + // Returns character at the specified index + uint32_t GetCharAt(size_t index) const; + uint32_t GetFirstCharAt(size_t index, const char** offset) const; + uint32_t GetNextChar(const char** offset) const; + + // Appends a character + void AppendChar(uint32_t ch); + + // Append a string + void AppendString(const wchar_t* pstr, intptr_t len = -1); + void AppendString(const char* putf8str, intptr_t utf8StrSz = -1); + + // Assigned a string with dynamic data (copied through initializer). + void AssignString(const InitStruct& src, size_t size); + // Assigns string with known size. + void AssignString(const char* putf8str, size_t size); + + // Resize the string to the new size +// void Resize(size_t _size); + + // Removes the character at posAt + void Remove(size_t posAt, intptr_t len = 1); + + // Returns a String that's a substring of this. + // -start is the index of the first UTF8 character you want to include. + // -end is the index one past the last UTF8 character you want to include. + String Substring(size_t start, size_t end) const; + + // Case-conversion + String ToUpper() const; + String ToLower() const; + + // Inserts substr at posAt + String& Insert (const char* substr, size_t posAt, intptr_t len = -1); + + // Inserts character at posAt + size_t InsertCharAt(uint32_t c, size_t posAt); + + // Inserts substr at posAt, which is an index of a character (not byte). + // Of size is specified, it is in bytes. +// String& Insert(const uint32_t* substr, size_t posAt, intptr_t size = -1); + + // Get Byte index of the character at position = index + size_t GetByteIndex(size_t index) const { return (size_t)UTF8Util::GetByteIndex(index, GetData()->Data); } + + // Utility: case-insensitive string compare. stricmp() & strnicmp() are not + // ANSI or POSIX, do not seem to appear in Linux. + static int OVR_STDCALL CompareNoCase(const char* a, const char* b); + static int OVR_STDCALL CompareNoCase(const char* a, const char* b, intptr_t len); + + // Hash function, case-insensitive + static size_t OVR_STDCALL BernsteinHashFunctionCIS(const void* pdataIn, size_t size, size_t seed = 5381); + + // Hash function, case-sensitive + static size_t OVR_STDCALL BernsteinHashFunction(const void* pdataIn, size_t size, size_t seed = 5381); + + + // ***** File path parsing helper functions. + // Implemented in OVR_String_FilePath.cpp. + + // Absolute paths can star with: + // - protocols: 'file://', 'http://' + // - windows drive: 'c:\' + // - UNC share name: '\\share' + // - unix root '/' + static bool HasAbsolutePath(const char* path); + static bool HasExtension(const char* path); + static bool HasProtocol(const char* path); + + bool HasAbsolutePath() const { return HasAbsolutePath(ToCStr()); } + bool HasExtension() const { return HasExtension(ToCStr()); } + bool HasProtocol() const { return HasProtocol(ToCStr()); } + + String GetProtocol() const; // Returns protocol, if any, with trailing '://'. + String GetPath() const; // Returns path with trailing '/'. + String GetFilename() const; // Returns filename, including extension. + String GetExtension() const; // Returns extension with a dot. + + void StripProtocol(); // Strips front protocol, if any, from the string. + void StripExtension(); // Strips off trailing extension. + + + // Operators + // Assignment + void operator = (const char* str); + void operator = (const wchar_t* str); + void operator = (const String& src); + void operator = (const StringBuffer& src); + + // Addition + void operator += (const String& src); + void operator += (const char* psrc) { AppendString(psrc); } + void operator += (const wchar_t* psrc) { AppendString(psrc); } + void operator += (char ch) { AppendChar(ch); } + String operator + (const char* str) const; + String operator + (const String& src) const; + + // Comparison + bool operator == (const String& str) const + { + return (OVR_strcmp(GetData()->Data, str.GetData()->Data)== 0); + } + + bool operator != (const String& str) const + { + return !operator == (str); + } + + bool operator == (const char* str) const + { + return OVR_strcmp(GetData()->Data, str) == 0; + } + + bool operator != (const char* str) const + { + return !operator == (str); + } + + bool operator < (const char* pstr) const + { + return OVR_strcmp(GetData()->Data, pstr) < 0; + } + + bool operator < (const String& str) const + { + return *this < str.GetData()->Data; + } + + bool operator > (const char* pstr) const + { + return OVR_strcmp(GetData()->Data, pstr) > 0; + } + + bool operator > (const String& str) const + { + return *this > str.GetData()->Data; + } + + int CompareNoCase(const char* pstr) const + { + return CompareNoCase(GetData()->Data, pstr); + } + int CompareNoCase(const String& str) const + { + return CompareNoCase(GetData()->Data, str.ToCStr()); + } + + // Accesses raw bytes + const char& operator [] (int index) const + { + OVR_ASSERT(index >= 0 && (size_t)index < GetSize()); + return GetData()->Data[index]; + } + const char& operator [] (size_t index) const + { + OVR_ASSERT(index < GetSize()); + return GetData()->Data[index]; + } + + + // Case insensitive keys are used to look up insensitive string in hash tables + // for SWF files with version before SWF 7. + struct NoCaseKey + { + const String* pStr; + NoCaseKey(const String &str) : pStr(&str){}; + }; + + bool operator == (const NoCaseKey& strKey) const + { + return (CompareNoCase(ToCStr(), strKey.pStr->ToCStr()) == 0); + } + bool operator != (const NoCaseKey& strKey) const + { + return !(CompareNoCase(ToCStr(), strKey.pStr->ToCStr()) == 0); + } + + // Hash functor used for strings. + struct HashFunctor + { + size_t operator()(const String& data) const + { + size_t size = data.GetSize(); + return String::BernsteinHashFunction((const char*)data, size); + } + }; + // Case-insensitive hash functor used for strings. Supports additional + // lookup based on NoCaseKey. + struct NoCaseHashFunctor + { + size_t operator()(const String& data) const + { + size_t size = data.GetSize(); + return String::BernsteinHashFunctionCIS((const char*)data, size); + } + size_t operator()(const NoCaseKey& data) const + { + size_t size = data.pStr->GetSize(); + return String::BernsteinHashFunctionCIS((const char*)data.pStr->ToCStr(), size); + } + }; + +}; + + +//----------------------------------------------------------------------------------- +// ***** String Buffer used for Building Strings + +class StringBuffer +{ + char* pData; + size_t Size; + size_t BufferSize; + size_t GrowSize; + mutable bool LengthIsSize; + +public: + + // Constructors / Destructor. + StringBuffer(); + explicit StringBuffer(size_t growSize); + StringBuffer(const char* data); + StringBuffer(const char* data, size_t buflen); + StringBuffer(const String& src); + StringBuffer(const StringBuffer& src); + explicit StringBuffer(const wchar_t* data); + ~StringBuffer(); + + + // Modify grow size used for growing/shrinking the buffer. + size_t GetGrowSize() const { return GrowSize; } + void SetGrowSize(size_t growSize); + + + // *** General Functions + // Does not release memory, just sets Size to 0 + void Clear(); + + // For casting to a pointer to char. + operator const char*() const { return (pData) ? pData : ""; } + // Pointer to raw buffer. + const char* ToCStr() const { return (pData) ? pData : ""; } + + // Returns number of bytes. + size_t GetSize() const { return Size ; } + // Tells whether or not the string is empty. + bool IsEmpty() const { return GetSize() == 0; } + + // Returns number of characters + size_t GetLength() const; + + // Returns character at the specified index + uint32_t GetCharAt(size_t index) const; + uint32_t GetFirstCharAt(size_t index, const char** offset) const; + uint32_t GetNextChar(const char** offset) const; + + + // Resize the string to the new size + void Resize(size_t _size); + void Reserve(size_t _size); + + // Appends a character + void AppendChar(uint32_t ch); + + // Append a string + void AppendString(const wchar_t* pstr, intptr_t len = -1); + void AppendString(const char* putf8str, intptr_t utf8StrSz = -1); + void AppendFormat(const char* format, ...); + + // Assigned a string with dynamic data (copied through initializer). + //void AssignString(const InitStruct& src, size_t size); + + // Inserts substr at posAt + void Insert (const char* substr, size_t posAt, intptr_t len = -1); + // Inserts character at posAt + size_t InsertCharAt(uint32_t c, size_t posAt); + + // Assignment + void operator = (const char* str); + void operator = (const wchar_t* str); + void operator = (const String& src); + void operator = (const StringBuffer& src); + + // Addition + void operator += (const String& src) { AppendString(src.ToCStr(),src.GetSize()); } + void operator += (const char* psrc) { AppendString(psrc); } + void operator += (const wchar_t* psrc) { AppendString(psrc); } + void operator += (char ch) { AppendChar(ch); } + //String operator + (const char* str) const ; + //String operator + (const String& src) const ; + + // Accesses raw bytes + char& operator [] (int index) + { + OVR_ASSERT(((size_t)index) < GetSize()); + return pData[index]; + } + char& operator [] (size_t index) + { + OVR_ASSERT(index < GetSize()); + return pData[index]; + } + + const char& operator [] (int index) const + { + OVR_ASSERT(((size_t)index) < GetSize()); + return pData[index]; + } + const char& operator [] (size_t index) const + { + OVR_ASSERT(index < GetSize()); + return pData[index]; + } +}; + + +// +// Wrapper for string data. The data must have a guaranteed +// lifespan throughout the usage of the wrapper. Not intended for +// cached usage. Not thread safe. +// +class StringDataPtr +{ +public: + StringDataPtr() : pStr(NULL), Size(0) {} + StringDataPtr(const StringDataPtr& p) + : pStr(p.pStr), Size(p.Size) {} + StringDataPtr(const char* pstr, size_t sz) + : pStr(pstr), Size(sz) {} + StringDataPtr(const char* pstr) + : pStr(pstr), Size((pstr != NULL) ? OVR_strlen(pstr) : 0) {} + explicit StringDataPtr(const String& str) + : pStr(str.ToCStr()), Size(str.GetSize()) {} + template + StringDataPtr(const T (&v)[N]) + : pStr(v), Size(N) {} + +public: + const char* ToCStr() const { return pStr; } + size_t GetSize() const { return Size; } + bool IsEmpty() const { return GetSize() == 0; } + + // value is a prefix of this string + // Character's values are not compared. + bool IsPrefix(const StringDataPtr& value) const + { + return ToCStr() == value.ToCStr() && GetSize() >= value.GetSize(); + } + // value is a suffix of this string + // Character's values are not compared. + bool IsSuffix(const StringDataPtr& value) const + { + return ToCStr() <= value.ToCStr() && (End()) == (value.End()); + } + + // Find first character. + // init_ind - initial index. + intptr_t FindChar(char c, size_t init_ind = 0) const + { + for (size_t i = init_ind; i < GetSize(); ++i) + if (pStr[i] == c) + return static_cast(i); + + return -1; + } + + // Find last character. + // init_ind - initial index. + intptr_t FindLastChar(char c, size_t init_ind = ~0) const + { + if (init_ind == (size_t)~0 || init_ind > GetSize()) + init_ind = GetSize(); + else + ++init_ind; + + for (size_t i = init_ind; i > 0; --i) + if (pStr[i - 1] == c) + return static_cast(i - 1); + + return -1; + } + + // Create new object and trim size bytes from the left. + StringDataPtr GetTrimLeft(size_t size) const + { + // Limit trim size to the size of the string. + size = Alg::PMin(GetSize(), size); + + return StringDataPtr(ToCStr() + size, GetSize() - size); + } + // Create new object and trim size bytes from the right. + StringDataPtr GetTrimRight(size_t size) const + { + // Limit trim to the size of the string. + size = Alg::PMin(GetSize(), size); + + return StringDataPtr(ToCStr(), GetSize() - size); + } + + // Create new object, which contains next token. + // Useful for parsing. + StringDataPtr GetNextToken(char separator = ':') const + { + size_t cur_pos = 0; + const char* cur_str = ToCStr(); + + for (; cur_pos < GetSize() && cur_str[cur_pos]; ++cur_pos) + { + if (cur_str[cur_pos] == separator) + { + break; + } + } + + return StringDataPtr(ToCStr(), cur_pos); + } + + // Trim size bytes from the left. + StringDataPtr& TrimLeft(size_t size) + { + // Limit trim size to the size of the string. + size = Alg::PMin(GetSize(), size); + pStr += size; + Size -= size; + + return *this; + } + // Trim size bytes from the right. + StringDataPtr& TrimRight(size_t size) + { + // Limit trim to the size of the string. + size = Alg::PMin(GetSize(), size); + Size -= size; + + return *this; + } + + const char* Begin() const { return ToCStr(); } + const char* End() const { return ToCStr() + GetSize(); } + + // Hash functor used string data pointers + struct HashFunctor + { + size_t operator()(const StringDataPtr& data) const + { + return String::BernsteinHashFunction(data.ToCStr(), data.GetSize()); + } + }; + + bool operator== (const StringDataPtr& data) const + { + return (OVR_strncmp(pStr, data.pStr, data.Size) == 0); + } + +protected: + const char* pStr; + size_t Size; +}; + +} // OVR + +#endif diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Kernel/OVR_StringHash.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Kernel/OVR_StringHash.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,100 @@ +/************************************************************************************ + +PublicHeader: None +Filename : OVR_StringHash.h +Content : String hash table used when optional case-insensitive + lookup is required. +Created : September 19, 2012 +Notes : + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#ifndef OVR_StringHash_h +#define OVR_StringHash_h + +#include "OVR_String.h" +#include "OVR_Hash.h" + +namespace OVR { + +//----------------------------------------------------------------------------------- +// *** StringHash + +// This is a custom string hash table that supports case-insensitive +// searches through special functions such as GetCaseInsensitive, etc. +// This class is used for Flash labels, exports and other case-insensitive tables. + +template > +class StringHash : public Hash +{ +public: + typedef U ValueType; + typedef StringHash SelfType; + typedef Hash BaseType; + +public: + + void operator = (const SelfType& src) { BaseType::operator = (src); } + + bool GetCaseInsensitive(const String& key, U* pvalue) const + { + String::NoCaseKey ikey(key); + return BaseType::GetAlt(ikey, pvalue); + } + // Pointer-returning get variety. + const U* GetCaseInsensitive(const String& key) const + { + String::NoCaseKey ikey(key); + return BaseType::GetAlt(ikey); + } + U* GetCaseInsensitive(const String& key) + { + String::NoCaseKey ikey(key); + return BaseType::GetAlt(ikey); + } + + + typedef typename BaseType::Iterator base_iterator; + + base_iterator FindCaseInsensitive(const String& key) + { + String::NoCaseKey ikey(key); + return BaseType::FindAlt(ikey); + } + + // Set just uses a find and assigns value if found. The key is not modified; + // this behavior is identical to Flash string variable assignment. + void SetCaseInsensitive(const String& key, const U& value) + { + base_iterator it = FindCaseInsensitive(key); + if (it != BaseType::End()) + { + it->Second = value; + } + else + { + BaseType::Add(key, value); + } + } +}; + +} // OVR + +#endif diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Kernel/OVR_String_FormatUtil.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Kernel/OVR_String_FormatUtil.cpp Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,76 @@ +/************************************************************************************ + +Filename : OVR_String_FormatUtil.cpp +Content : String format functions. +Created : February 27, 2013 +Notes : + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#include "OVR_String.h" +#include "OVR_Log.h" + +namespace OVR { + +void StringBuffer::AppendFormat(const char* format, ...) +{ + va_list argList; + char buffer[512]; + char* bufferUsed = buffer; + char* bufferAllocated = NULL; + + va_start(argList, format); + + #if !defined(OVR_CC_MSVC) // Non-Microsoft compilers require you to save a copy of the va_list. + va_list argListSaved; + va_copy(argListSaved, argList); + #endif + + int requiredStrlen = OVR_vsnprintf(bufferUsed, OVR_ARRAY_COUNT(buffer), format, argList); // The large majority of the time this will succeed. + + if(requiredStrlen >= (int)sizeof(buffer)) // If the initial capacity wasn't enough... + { + bufferAllocated = (char*)OVR_ALLOC(sizeof(char) * (requiredStrlen + 1)); + bufferUsed = bufferAllocated; + if(bufferAllocated) + { + #if !defined(OVR_CC_MSVC) + va_end(argList); + va_copy(argList, argListSaved); + #endif + requiredStrlen = OVR_vsnprintf(bufferAllocated, (requiredStrlen + 1), format, argList); + } + } + + if(requiredStrlen < 0) // If there was a printf format error... + { + bufferUsed = NULL; + } + + va_end(argList); + + if(bufferUsed) + AppendString(bufferUsed); + + if(bufferAllocated) + OVR_FREE(bufferAllocated); +} + +} // OVR diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Kernel/OVR_String_PathUtil.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Kernel/OVR_String_PathUtil.cpp Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,211 @@ +/************************************************************************************ + +Filename : OVR_String_PathUtil.cpp +Content : String filename/url helper function +Created : September 19, 2012 +Notes : + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#include "OVR_String.h" +#include "OVR_UTF8Util.h" + +namespace OVR { + +//-------------------------------------------------------------------- +// ***** Path-Scanner helper function + +// Scans file path finding filename start and extension start, fills in their addess. +void ScanFilePath(const char* url, const char** pfilename, const char** pext) +{ + const char* urlStart = url; + const char *filename = 0; + const char *lastDot = 0; + + uint32_t charVal = UTF8Util::DecodeNextChar(&url); + + while (charVal != 0) + { + if ((charVal == '/') || (charVal == '\\')) + { + filename = url; + lastDot = 0; + } + else if (charVal == '.') + { + lastDot = url - 1; + } + + charVal = UTF8Util::DecodeNextChar(&url); + } + + if (pfilename) + { + // It was a naked filename + if (urlStart && (*urlStart != '.') && *urlStart) + *pfilename = urlStart; + else + *pfilename = filename; + } + + if (pext) + { + *pext = lastDot; + } +} + +// Scans till the end of protocol. Returns first character past protocol, +// 0 if not found. +// - protocol: 'file://', 'http://' +const char* ScanPathProtocol(const char* url) +{ + uint32_t charVal = UTF8Util::DecodeNextChar(&url); + uint32_t charVal2; + + while (charVal != 0) + { + // Treat a colon followed by a slash as absolute. + if (charVal == ':') + { + charVal2 = UTF8Util::DecodeNextChar(&url); + charVal = UTF8Util::DecodeNextChar(&url); + if ((charVal == '/') && (charVal2 == '\\')) + return url; + } + charVal = UTF8Util::DecodeNextChar(&url); + } + return 0; +} + + +//-------------------------------------------------------------------- +// ***** String Path API implementation + +bool String::HasAbsolutePath(const char* url) +{ + // Absolute paths can star with: + // - protocols: 'file://', 'http://' + // - windows drive: 'c:\' + // - UNC share name: '\\share' + // - unix root '/' + + // On the other hand, relative paths are: + // - directory: 'directory/file' + // - this directory: './file' + // - parent directory: '../file' + // + // For now, we don't parse '.' or '..' out, but instead let it be concatenated + // to string and let the OS figure it out. This, however, is not good for file + // name matching in library/etc, so it should be improved. + + if (!url || !*url) + return true; // Treat empty strings as absolute. + + uint32_t charVal = UTF8Util::DecodeNextChar(&url); + + // Fist character of '/' or '\\' means absolute url. + if ((charVal == '/') || (charVal == '\\')) + return true; + + while (charVal != 0) + { + // Treat a colon followed by a slash as absolute. + if (charVal == ':') + { + charVal = UTF8Util::DecodeNextChar(&url); + // Protocol or windows drive. Absolute. + if ((charVal == '/') || (charVal == '\\')) + return true; + } + else if ((charVal == '/') || (charVal == '\\')) + { + // Not a first character (else 'if' above the loop would have caught it). + // Must be a relative url. + break; + } + + charVal = UTF8Util::DecodeNextChar(&url); + } + + // We get here for relative paths. + return false; +} + + +bool String::HasExtension(const char* path) +{ + const char* ext = 0; + ScanFilePath(path, 0, &ext); + return ext != 0; +} +bool String::HasProtocol(const char* path) +{ + return ScanPathProtocol(path) != 0; +} + + +String String::GetPath() const +{ + const char* filename = 0; + ScanFilePath(ToCStr(), &filename, 0); + + // Technically we can have extra logic somewhere for paths, + // such as enforcing protocol and '/' only based on flags, + // but we keep it simple for now. + return String(ToCStr(), filename ? (filename-ToCStr()) : GetSize()); +} + +String String::GetProtocol() const +{ + const char* protocolEnd = ScanPathProtocol(ToCStr()); + return String(ToCStr(), protocolEnd ? (protocolEnd-ToCStr()) : 0); +} + +String String::GetFilename() const +{ + const char* filename = 0; + ScanFilePath(ToCStr(), &filename, 0); + return String(filename); +} +String String::GetExtension() const +{ + const char* ext = 0; + ScanFilePath(ToCStr(), 0, &ext); + return String(ext); +} + +void String::StripExtension() +{ + const char* ext = 0; + ScanFilePath(ToCStr(), 0, &ext); + if (ext) + { + *this = String(ToCStr(), ext-ToCStr()); + } +} + +void String::StripProtocol() +{ + const char* protocol = ScanPathProtocol(ToCStr()); + if (protocol) + AssignString(protocol, OVR_strlen(protocol)); +} + +} // OVR diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Kernel/OVR_SysFile.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Kernel/OVR_SysFile.cpp Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,138 @@ +/************************************************************************** + +Filename : OVR_SysFile.cpp +Content : File wrapper class implementation (Win32) + +Created : April 5, 1999 +Authors : Michael Antonov + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +**************************************************************************/ + +#define GFILE_CXX + +// Standard C library (Captain Obvious guarantees!) +#include + +#include "OVR_SysFile.h" +#include "OVR_Log.h" + +namespace OVR { + +// This is - a dummy file that fails on all calls. + +class UnopenedFile : public File +{ +public: + UnopenedFile() { } + ~UnopenedFile() { } + + virtual const char* GetFilePath() { return 0; } + + // ** File Information + virtual bool IsValid() { return 0; } + virtual bool IsWritable() { return 0; } + + // Return position / file size + virtual int Tell() { return 0; } + virtual int64_t LTell() { return 0; } + virtual int GetLength() { return 0; } + virtual int64_t LGetLength() { return 0; } + +// virtual bool Stat(FileStats *pfs) { return 0; } + virtual int GetErrorCode() { return Error_FileNotFound; } + + // ** Stream implementation & I/O + virtual int Write(const uint8_t * /*pbuffer*/, int /*numBytes*/) { return -1; } + virtual int Read(uint8_t * /*pbuffer*/, int /*numBytes*/) { return -1; } + virtual int SkipBytes(int /*numBytes*/) { return 0; } + virtual int BytesAvailable() { return 0; } + virtual bool Flush() { return 0; } + virtual int Seek(int /*offset*/, int /*origin*/) { return -1; } + virtual int64_t LSeek(int64_t /*offset*/, int /*origin*/) { return -1; } + + virtual int CopyFromStream(File * /*pstream*/, int /*byteSize*/) { return -1; } + virtual bool Close() { return 0; } +}; + + + +// ***** System File + +// System file is created to access objects on file system directly +// This file can refer directly to path + +// ** Constructor +SysFile::SysFile() : DelegatedFile(0) +{ + pFile = *new UnopenedFile; +} + +Ptr FileFILEOpen(const String& path, int flags, int mode); + +// Opens a file +SysFile::SysFile(const String& path, int flags, int mode) : DelegatedFile(0) +{ + Open(path, flags, mode); +} + + +// ** Open & management +// Will fail if file's already open +bool SysFile::Open(const String& path, int flags, int mode) +{ + pFile = FileFILEOpen(path, flags, mode); + if ((!pFile) || (!pFile->IsValid())) + { + pFile = *new UnopenedFile; + OVR_DEBUG_LOG(("Failed to open file: %s", path.ToCStr())); + return 0; + } + //pFile = *OVR_NEW DelegatedFile(pFile); // MA Testing + if (flags & Open_Buffered) + pFile = *new BufferedFile(pFile); + return 1; +} + + +// ** Overrides + +int SysFile::GetErrorCode() +{ + return pFile ? pFile->GetErrorCode() : Error_FileNotFound; +} + + +// Overrides to provide re-open support +bool SysFile::IsValid() +{ + return pFile && pFile->IsValid(); +} +bool SysFile::Close() +{ + if (IsValid()) + { + DelegatedFile::Close(); + pFile = *new UnopenedFile; + return 1; + } + return 0; +} + +} // OVR diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Kernel/OVR_SysFile.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Kernel/OVR_SysFile.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,104 @@ +/************************************************************************************ + +PublicHeader: Kernel +Filename : OVR_SysFile.h +Content : Header for all internal file management - functions and structures + to be inherited by OS specific subclasses. +Created : September 19, 2012 +Notes : + +Notes : errno may not be preserved across use of GBaseFile member functions + : Directories cannot be deleted while files opened from them are in use + (For the GetFullName function) + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#ifndef OVR_SysFile_h +#define OVR_SysFile_h + +#include "OVR_File.h" + +namespace OVR { + +// ***** Declared classes +class SysFile; + +//----------------------------------------------------------------------------------- +// *** File Statistics + +// This class contents are similar to _stat, providing +// creation, modify and other information about the file. +struct FileStat +{ + // No change or create time because they are not available on most systems + int64_t ModifyTime; + int64_t AccessTime; + int64_t FileSize; + + bool operator== (const FileStat& stat) const + { + return ( (ModifyTime == stat.ModifyTime) && + (AccessTime == stat.AccessTime) && + (FileSize == stat.FileSize) ); + } +}; + +//----------------------------------------------------------------------------------- +// *** System File + +// System file is created to access objects on file system directly +// This file can refer directly to path. +// System file can be open & closed several times; however, such use is not recommended +// This class is realy a wrapper around an implementation of File interface for a +// particular platform. + +class SysFile : public DelegatedFile +{ +protected: + SysFile(const SysFile &source) : DelegatedFile () { OVR_UNUSED(source); } +public: + + // ** Constructor + SysFile(); + // Opens a file + SysFile(const String& path, int flags = Open_Read|Open_Buffered, int mode = Mode_ReadWrite); + + // ** Open & management + bool Open(const String& path, int flags = Open_Read|Open_Buffered, int mode = Mode_ReadWrite); + + OVR_FORCE_INLINE bool Create(const String& path, int mode = Mode_ReadWrite) + { return Open(path, Open_ReadWrite|Open_Create, mode); } + + // Helper function: obtain file statistics information. In OVR, this is used to detect file changes. + // Return 0 if function failed, most likely because the file doesn't exist. + static bool OVR_CDECL GetFileStat(FileStat* pfileStats, const String& path); + + // ** Overrides + // Overridden to provide re-open support + virtual int GetErrorCode(); + + virtual bool IsValid(); + + virtual bool Close(); +}; + +} // Namespace OVR + +#endif diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Kernel/OVR_System.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Kernel/OVR_System.cpp Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,149 @@ +/************************************************************************************ + +Filename : OVR_System.cpp +Content : General kernel initialization/cleanup, including that + of the memory allocator. +Created : September 19, 2012 +Notes : + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#include "OVR_System.h" +#include "OVR_Threads.h" +#include "OVR_Timer.h" +#include "../Displays/OVR_Display.h" +#ifdef OVR_OS_WIN32 +#include "../Displays/OVR_Win32_ShimFunctions.h" +#endif + +namespace OVR { + +#ifdef OVR_OS_WIN32 +extern bool anyRiftsInExtendedMode(); +#endif + +// Stack of destroy listeners (push/pop semantics) +static SystemSingletonInternal *SystemShutdownListenerStack = 0; +static Lock stackLock; +static bool DisplayShimInitialized = false; + +void SystemSingletonInternal::PushDestroyCallbacks() +{ + Lock::Locker locker(&stackLock); + + // Push listener onto the stack + NextSingleton = SystemShutdownListenerStack; + SystemShutdownListenerStack = this; +} + +void System::DirectDisplayInitialize() +{ +#ifdef OVR_OS_WIN32 + // Set up display code for Windows + Win32::DisplayShim::GetInstance(); + + // This code will look for the first display. If it's a display + // that's extending the destkop, the code will assume we're in + // compatibility mode. Compatibility mode prevents shim loading + // and renders only to extended Rifts. + // If we find a display and it's application exclusive, + // we load the shim so we can render to it. + // If no display is available, we revert to whatever the + // driver tells us we're in + + bool anyExtendedRifts = anyRiftsInExtendedMode() || Display::InCompatibilityMode( false ); + + DisplayShimInitialized = Win32::DisplayShim::GetInstance().Initialize(anyExtendedRifts); +#endif +} + +bool System::DirectDisplayEnabled() +{ + return DisplayShimInitialized; +} + +// Initializes System core, installing allocator. +void System::Init(Log* log, Allocator *palloc) +{ + if (!Allocator::GetInstance()) + { + Log::SetGlobalLog(log); + Timer::initializeTimerSystem(); + Allocator::setInstance(palloc); + Display::Initialize(); + DirectDisplayInitialize(); + } + else + { + OVR_DEBUG_LOG(("System::Init failed - duplicate call.")); + } +} + +void System::Destroy() +{ + if (Allocator::GetInstance()) + { +#ifdef OVR_OS_WIN32 + Win32::DisplayShim::GetInstance().Shutdown(); +#endif + + // Invoke all of the post-finish callbacks (normal case) + for (SystemSingletonInternal *listener = SystemShutdownListenerStack; listener; listener = listener->NextSingleton) + { + listener->OnThreadDestroy(); + } + +#ifdef OVR_ENABLE_THREADS + // Wait for all threads to finish; this must be done so that memory + // allocator and all destructors finalize correctly. + Thread::FinishAllThreads(); +#endif + + // Invoke all of the post-finish callbacks (normal case) + for (SystemSingletonInternal *next, *listener = SystemShutdownListenerStack; listener; listener = next) + { + next = listener->NextSingleton; + + listener->OnSystemDestroy(); + } + + SystemShutdownListenerStack = 0; + + // Shutdown heap and destroy SysAlloc singleton, if any. + Allocator::GetInstance()->onSystemShutdown(); + Allocator::setInstance(0); + + Timer::shutdownTimerSystem(); + Log::SetGlobalLog(Log::GetDefaultLog()); + } + else + { + OVR_DEBUG_LOG(("System::Destroy failed - System not initialized.")); + } +} + +// Returns 'true' if system was properly initialized. +bool System::IsInitialized() +{ + return Allocator::GetInstance() != 0; +} + + +} // namespace OVR diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Kernel/OVR_System.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Kernel/OVR_System.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,174 @@ +/************************************************************************************ + +PublicHeader: OVR +Filename : OVR_System.h +Content : General kernel initialization/cleanup, including that + of the memory allocator. +Created : September 19, 2012 +Notes : + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#ifndef OVR_System_h +#define OVR_System_h + +#include "OVR_Allocator.h" +#include "OVR_Log.h" +#include "OVR_Atomic.h" + +namespace OVR { + + +//----------------------------------------------------------------------------- +// SystemSingleton + +// Subsystems are implemented using the Singleton pattern. +// To avoid code duplication in all the places where Singletons are defined, +// The pattern is defined once here and used everywhere. + +class SystemSingletonInternal +{ + friend class System; + + SystemSingletonInternal* NextSingleton; + + // No copying allowed + OVR_NON_COPYABLE(SystemSingletonInternal); + +protected: + SystemSingletonInternal() : + NextSingleton(0) + { + } + + virtual ~SystemSingletonInternal(){} + + // Call this to register the destroy events + // Destroy callbacks will be called in the reverse order they were registered + // Note: As a rule of thumb, call this at the end of the singleton class constructor. + void PushDestroyCallbacks(); + + // Required: Invoked when the System object is shutting down + // Called after threads are stopped + // Called before Log, Allocator, and Timer subsystems are stopped + // Listeners are called in the opposite order they were registered + virtual void OnSystemDestroy() = 0; + + // Called just before waiting for threads to die + // Listeners are called in the opposite order they were registered + // Useful to start terminating threads at the right time + // Note: The singleton must not delete itself here. + virtual void OnThreadDestroy() {} +}; + +// Singletons derive from this class +template +class SystemSingletonBase : public SystemSingletonInternal +{ + static AtomicPtr SingletonInstance; + static T* SlowGetInstance(); + +protected: + ~SystemSingletonBase() + { + // Make sure the instance gets set to zero on dtor + if (SingletonInstance == this) + SingletonInstance = 0; + } + +public: + static OVR_FORCE_INLINE T* GetInstance() + { + // Fast version + // Note: The singleton instance is stored in an AtomicPtr<> to allow it to be accessed + // atomically from multiple threads without locks. + T* instance = SingletonInstance; + return instance ? instance : SlowGetInstance(); + } +}; + +// For reference, see N3337 14.5.1.3 (Static data members of class templates): +template OVR::AtomicPtr OVR::SystemSingletonBase::SingletonInstance; + +// Place this in the singleton class in the header file +#define OVR_DECLARE_SINGLETON(T) \ + friend class OVR::SystemSingletonBase; \ +private: \ + T(); \ + virtual ~T(); \ + virtual void OnSystemDestroy(); + +// Place this in the singleton class source file +#define OVR_DEFINE_SINGLETON(T) \ + namespace OVR { \ + template<> T* SystemSingletonBase::SlowGetInstance() \ + { \ + static OVR::Lock lock; \ + OVR::Lock::Locker locker(&lock); \ + if (!SingletonInstance) SingletonInstance = new T; \ + return SingletonInstance; \ + } \ + } + + +// ***** System Core Initialization class + +// System initialization must take place before any other OVR_Kernel objects are used; +// this is done my calling System::Init(). Among other things, this is necessary to +// initialize the memory allocator. Similarly, System::Destroy must be +// called before program exist for proper cleanup. Both of these tasks can be achieved by +// simply creating System object first, allowing its constructor/destructor do the work. + +// TBD: Require additional System class for Oculus Rift API? + +class System +{ +public: + // System constructor expects allocator to be specified, if it is being substituted. + System(Log* log = Log::ConfigureDefaultLog(LogMask_Debug), + Allocator* palloc = DefaultAllocator::InitSystemSingleton()) + { + Init(log, palloc); + } + ~System() + { + Destroy(); + } + + static void OVR_CDECL DirectDisplayInitialize(); + static bool OVR_CDECL DirectDisplayEnabled(); + + // Returns 'true' if system was properly initialized. + static bool OVR_CDECL IsInitialized(); + + // Initializes System core. Users can override memory implementation by passing + // a different Allocator here. + static void OVR_CDECL Init(Log* log = Log::ConfigureDefaultLog(LogMask_Debug), + Allocator *palloc = DefaultAllocator::InitSystemSingleton()); + + // De-initializes System more, finalizing the threading system and destroying + // the global memory allocator. + static void OVR_CDECL Destroy(); +}; + + +} // namespace OVR + +#endif diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Kernel/OVR_ThreadCommandQueue.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Kernel/OVR_ThreadCommandQueue.cpp Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,401 @@ +/************************************************************************************ + +PublicHeader: None +Filename : OVR_ThreadCommandQueue.cpp +Content : Command queue for operations executed on a thread +Created : October 29, 2012 + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#include "OVR_ThreadCommandQueue.h" + +namespace OVR { + + +//------------------------------------------------------------------------ +// ***** CircularBuffer + +// CircularBuffer is a FIFO buffer implemented in a single block of memory, +// which allows writing and reading variable-size data chucks. Write fails +// if buffer is full. + +class CircularBuffer +{ + enum { + AlignSize = 16, + AlignMask = AlignSize - 1 + }; + + uint8_t* pBuffer; + size_t Size; + size_t Tail; // Byte offset of next item to be popped. + size_t Head; // Byte offset of where next push will take place. + size_t End; // When Head < Tail, this is used instead of Size. + + inline size_t roundUpSize(size_t size) + { return (size + AlignMask) & ~(size_t)AlignMask; } + +public: + + CircularBuffer(size_t size) + : Size(size), Tail(0), Head(0), End(0) + { + pBuffer = (uint8_t*)OVR_ALLOC_ALIGNED(roundUpSize(size), AlignSize); + } + ~CircularBuffer() + { + // For ThreadCommands, we must consume everything before shutdown. + OVR_ASSERT(IsEmpty()); + OVR_FREE_ALIGNED(pBuffer); + } + + bool IsEmpty() const { return (Head == Tail); } + + // Allocates a state block of specified size and advances pointers, + // returning 0 if buffer is full. + uint8_t* Write(size_t size); + + // Returns a pointer to next available data block; 0 if none available. + uint8_t* ReadBegin() + { return (Head != Tail) ? (pBuffer + Tail) : 0; } + // Consumes data of specified size; this must match size passed to Write. + void ReadEnd(size_t size); +}; + + +// Allocates a state block of specified size and advances pointers, +// returning 0 if buffer is full. +uint8_t* CircularBuffer::Write(size_t size) +{ + uint8_t* p = 0; + + size = roundUpSize(size); + // Since this is circular buffer, always allow at least one item. + OVR_ASSERT(size < Size/2); + + if (Head >= Tail) + { + OVR_ASSERT(End == 0); + + if (size <= (Size - Head)) + { + p = pBuffer + Head; + Head += size; + } + else if (size < Tail) + { + p = pBuffer; + End = Head; + Head = size; + OVR_ASSERT(Head != Tail); + } + } + else + { + OVR_ASSERT(End != 0); + + if ((Tail - Head) > size) + { + p = pBuffer + Head; + Head += size; + OVR_ASSERT(Head != Tail); + } + } + + return p; +} + +void CircularBuffer::ReadEnd(size_t size) +{ + OVR_ASSERT(Head != Tail); + size = roundUpSize(size); + + Tail += size; + if (Tail == End) + { + Tail = End = 0; + } + else if (Tail == Head) + { + OVR_ASSERT(End == 0); + Tail = Head = 0; + } +} + + +//------------------------------------------------------------------------------------- +// ***** ThreadCommand + +ThreadCommand::PopBuffer::~PopBuffer() +{ + if (Size) { + Destruct(toCommand()); + } +} + +void ThreadCommand::PopBuffer::InitFromBuffer(void* data) +{ + ThreadCommand* cmd = (ThreadCommand*)data; + OVR_ASSERT(cmd->Size <= MaxSize); + + if (Size) { + Destruct(toCommand()); + } + Size = cmd->Size; + memcpy(Buffer, (void*)cmd, Size); +} + +void ThreadCommand::PopBuffer::Execute() +{ + ThreadCommand* command = toCommand(); + OVR_ASSERT(command); + command->Execute(); + if (NeedsWait()) { + GetEvent()->PulseEvent(); + } +} + +//------------------------------------------------------------------------------------- + +class ThreadCommandQueueImpl : public NewOverrideBase +{ + typedef ThreadCommand::NotifyEvent NotifyEvent; + friend class ThreadCommandQueue; + +public: + + ThreadCommandQueueImpl(ThreadCommandQueue* queue) : + pQueue(queue), + ExitEnqueued(false), + ExitProcessed(false), + CommandBuffer(2048), + PullThreadId(0) + { + } + ~ThreadCommandQueueImpl(); + + + bool PushCommand(const ThreadCommand& command); + bool PopCommand(ThreadCommand::PopBuffer* popBuffer); + + + // ExitCommand is used by notify us that Thread is shutting down. + struct ExitCommand : public ThreadCommand + { + ThreadCommandQueueImpl* pImpl; + + ExitCommand(ThreadCommandQueueImpl* impl, bool wait) + : ThreadCommand(sizeof(ExitCommand), wait, true), pImpl(impl) { } + + virtual void Execute() const + { + Lock::Locker lock(&pImpl->QueueLock); + pImpl->ExitProcessed = true; + } + virtual ThreadCommand* CopyConstruct(void* p) const + { return Construct(p, *this); } + }; + + + NotifyEvent* AllocNotifyEvent_NTS() + { + NotifyEvent* p = AvailableEvents.GetFirst(); + + if (!AvailableEvents.IsNull(p)) + p->RemoveNode(); + else + p = new NotifyEvent; + return p; + } + + void FreeNotifyEvent_NTS(NotifyEvent* p) + { + AvailableEvents.PushBack(p); + } + + void FreeNotifyEvents_NTS() + { + while(!AvailableEvents.IsEmpty()) + { + NotifyEvent* p = AvailableEvents.GetFirst(); + p->RemoveNode(); + delete p; + } + } + + ThreadCommandQueue* pQueue; + Lock QueueLock; + volatile bool ExitEnqueued; + volatile bool ExitProcessed; + List AvailableEvents; + List BlockedProducers; + CircularBuffer CommandBuffer; + + // The pull thread id is set to the last thread that pulled commands. + // Since this thread command queue is designed for a single thread, + // reentrant behavior that would cause a dead-lock for messages that + // wait for completion can be avoided by simply comparing the + // thread id of the last pull. + OVR::ThreadId PullThreadId; +}; + +ThreadCommandQueueImpl::~ThreadCommandQueueImpl() +{ + Lock::Locker lock(&QueueLock); + OVR_ASSERT(BlockedProducers.IsEmpty()); + FreeNotifyEvents_NTS(); +} + +bool ThreadCommandQueueImpl::PushCommand(const ThreadCommand& command) +{ + if (command.NeedsWait() && PullThreadId == OVR::GetCurrentThreadId()) + { + command.Execute(); + return true; + } + + ThreadCommand::NotifyEvent* completeEvent = 0; + ThreadCommand::NotifyEvent* queueAvailableEvent = 0; + + // Repeat writing command into buffer until it is available. + for (;;) { + { // Lock Scope + Lock::Locker lock(&QueueLock); + + if (queueAvailableEvent) { + FreeNotifyEvent_NTS(queueAvailableEvent); + queueAvailableEvent = 0; + } + + // Don't allow any commands after PushExitCommand() is called. + if (ExitEnqueued && !command.ExitFlag) { + return false; + } + + bool bufferWasEmpty = CommandBuffer.IsEmpty(); + uint8_t* buffer = CommandBuffer.Write(command.GetSize()); + + if (buffer) { + ThreadCommand* c = command.CopyConstruct(buffer); + + if (c->NeedsWait()) { + completeEvent = c->pEvent = AllocNotifyEvent_NTS(); + } + + // Signal-waker consumer when we add data to buffer. + if (bufferWasEmpty) { + pQueue->OnPushNonEmpty_Locked(); + } + + break; + } + + queueAvailableEvent = AllocNotifyEvent_NTS(); + BlockedProducers.PushBack(queueAvailableEvent); + } // Lock Scope + + queueAvailableEvent->Wait(); + } // Intentional infinite loop + + // Command was enqueued, wait if necessary. + if (completeEvent) { + completeEvent->Wait(); + Lock::Locker lock(&QueueLock); + FreeNotifyEvent_NTS(completeEvent); + } + + return true; +} + + +// Pops the next command from the thread queue, if any is available. +bool ThreadCommandQueueImpl::PopCommand(ThreadCommand::PopBuffer* popBuffer) +{ + PullThreadId = OVR::GetCurrentThreadId(); + + Lock::Locker lock(&QueueLock); + + uint8_t* buffer = CommandBuffer.ReadBegin(); + if (!buffer) + { + // Notify thread while in lock scope, enabling initialization of wait. + pQueue->OnPopEmpty_Locked(); + return false; + } + + popBuffer->InitFromBuffer(buffer); + CommandBuffer.ReadEnd(popBuffer->GetSize()); + + if (!BlockedProducers.IsEmpty()) + { + ThreadCommand::NotifyEvent* queueAvailableEvent = BlockedProducers.GetFirst(); + queueAvailableEvent->RemoveNode(); + queueAvailableEvent->PulseEvent(); + // Event is freed later by waiter. + } + return true; +} + + +//------------------------------------------------------------------------------------- + +ThreadCommandQueue::ThreadCommandQueue() +{ + pImpl = new ThreadCommandQueueImpl(this); +} +ThreadCommandQueue::~ThreadCommandQueue() +{ + delete pImpl; +} + +bool ThreadCommandQueue::PushCommand(const ThreadCommand& command) +{ + return pImpl->PushCommand(command); +} + +bool ThreadCommandQueue::PopCommand(ThreadCommand::PopBuffer* popBuffer) +{ + return pImpl->PopCommand(popBuffer); +} + +void ThreadCommandQueue::PushExitCommand(bool wait) +{ + // Exit is processed in two stages: + // - First, ExitEnqueued flag is set to block further commands from queuing up. + // - Second, the actual exit call is processed on the consumer thread, flushing + // any prior commands. + // IsExiting() only returns true after exit has flushed. + { + Lock::Locker lock(&pImpl->QueueLock); + if (pImpl->ExitEnqueued) + return; + pImpl->ExitEnqueued = true; + } + + PushCommand(ThreadCommandQueueImpl::ExitCommand(pImpl, wait)); +} + +bool ThreadCommandQueue::IsExiting() const +{ + return pImpl->ExitProcessed; +} + + +} // namespace OVR diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Kernel/OVR_ThreadCommandQueue.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Kernel/OVR_ThreadCommandQueue.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,318 @@ +/************************************************************************************ + +PublicHeader: None +Filename : OVR_ThreadCommandQueue.h +Content : Command queue for operations executed on a thread +Created : October 29, 2012 +Author : Michael Antonov + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#ifndef OVR_ThreadCommandQueue_h +#define OVR_ThreadCommandQueue_h + +#include "../Kernel/OVR_Types.h" +#include "../Kernel/OVR_List.h" +#include "../Kernel/OVR_Atomic.h" +#include "../Kernel/OVR_Threads.h" + +namespace OVR { + +class ThreadCommand; +class ThreadCommandQueue; + + +//------------------------------------------------------------------------------------- +// ***** ThreadCommand + +// ThreadCommand is a base class implementation for commands stored in ThreadCommandQueue. +class ThreadCommand +{ +public: + // NotifyEvent is used by ThreadCommandQueue::PushCallAndWait to notify the + // calling (producer) thread when command is completed or queue slot is available. + class NotifyEvent : public ListNode, public NewOverrideBase + { + Event E; + public: + NotifyEvent() { } + + void Wait() { E.Wait(); } + void PulseEvent() { E.PulseEvent(); } + }; + + // ThreadCommand::PopBuffer is temporary storage for a command popped off + // by ThreadCommandQueue::PopCommand. + class PopBuffer + { + enum { MaxSize = 256 }; + + size_t Size; + union { + uint8_t Buffer[MaxSize]; + size_t Align; + }; + + ThreadCommand* toCommand() const { return (ThreadCommand*)Buffer; } + + public: + PopBuffer() : Size(0) { } + ~PopBuffer(); + + void InitFromBuffer(void* data); + + bool HasCommand() const { return Size != 0; } + size_t GetSize() const { return Size; } + bool NeedsWait() const { return toCommand()->NeedsWait(); } + NotifyEvent* GetEvent() const { return toCommand()->pEvent; } + + // Execute the command and also notifies caller to finish waiting, + // if necessary. + void Execute(); + }; + + uint16_t Size; + bool WaitFlag; + bool ExitFlag; // Marks the last exit command. + NotifyEvent* pEvent; + + ThreadCommand(size_t size, bool waitFlag, bool exitFlag = false) + : Size((uint16_t)size), WaitFlag(waitFlag), ExitFlag(exitFlag), pEvent(0) { } + virtual ~ThreadCommand() { } + + bool NeedsWait() const { return WaitFlag; } + size_t GetSize() const { return Size; } + + virtual void Execute() const = 0; + // Copy constructor used for serializing this to memory buffer. + virtual ThreadCommand* CopyConstruct(void* p) const = 0; +}; + + +//------------------------------------------------------------------------------------- + +// CleanType is a template that strips 'const' and '&' modifiers from the argument type; +// for example, typename CleanType::Type is equivalent to A. +template struct CleanType { typedef T Type; }; +template struct CleanType { typedef T Type; }; +template struct CleanType { typedef T Type; }; +template struct CleanType { typedef T Type; }; + +// SelfType is a template that yields the argument type. This helps avoid conflicts with +// automatic template argument deduction for function calls when identical argument +// is already defined. +template struct SelfType { typedef T Type; }; + + + +//------------------------------------------------------------------------------------- +// ThreadCommand specializations for member functions with different number of +// arguments and argument types. + +// Used to return nothing from a ThreadCommand, to avoid problems with 'void'. +struct Void +{ + Void() {} + Void(int) {} +}; + +// ThreadCommand for member function with 0 arguments. +template +class ThreadCommandMF0 : public ThreadCommand +{ + typedef R (C::*FnPtr)(); + C* pClass; + FnPtr pFn; + R* pRet; + + void executeImpl() const + { + pRet ? (void)(*pRet = (pClass->*pFn)()) : + (void)(pClass->*pFn)(); + } + +public: + ThreadCommandMF0(C* pclass, FnPtr fn, R* ret, bool needsWait) + : ThreadCommand(sizeof(ThreadCommandMF0), needsWait), + pClass(pclass), pFn(fn), pRet(ret) { } + + virtual void Execute() const { executeImpl(); } + virtual ThreadCommand* CopyConstruct(void* p) const + { return Construct(p, *this); } +}; + + +// ThreadCommand for member function with 1 argument. +template +class ThreadCommandMF1 : public ThreadCommand +{ + typedef R (C::*FnPtr)(A0); + C* pClass; + FnPtr pFn; + R* pRet; + typename CleanType::Type AVal0; + + void executeImpl() const + { + pRet ? (void)(*pRet = (pClass->*pFn)(AVal0)) : + (void)(pClass->*pFn)(AVal0); + } + +public: + ThreadCommandMF1(C* pclass, FnPtr fn, R* ret, A0 a0, bool needsWait) + : ThreadCommand(sizeof(ThreadCommandMF1), needsWait), + pClass(pclass), pFn(fn), pRet(ret), AVal0(a0) { } + + virtual void Execute() const { executeImpl(); } + virtual ThreadCommand* CopyConstruct(void* p) const + { return Construct(p, *this); } +}; + +// ThreadCommand for member function with 2 arguments. +template +class ThreadCommandMF2 : public ThreadCommand +{ + typedef R (C::*FnPtr)(A0, A1); + C* pClass; + FnPtr pFn; + R* pRet; + typename CleanType::Type AVal0; + typename CleanType::Type AVal1; + + void executeImpl() const + { + pRet ? (void)(*pRet = (pClass->*pFn)(AVal0, AVal1)) : + (void)(pClass->*pFn)(AVal0, AVal1); + } + +public: + ThreadCommandMF2(C* pclass, FnPtr fn, R* ret, A0 a0, A1 a1, bool needsWait) + : ThreadCommand(sizeof(ThreadCommandMF2), needsWait), + pClass(pclass), pFn(fn), pRet(ret), AVal0(a0), AVal1(a1) { } + + virtual void Execute() const { executeImpl(); } + virtual ThreadCommand* CopyConstruct(void* p) const + { return Construct(p, *this); } +}; + + +//------------------------------------------------------------------------------------- +// ***** ThreadCommandQueue + +// ThreadCommandQueue is a queue of executable function-call commands intended to be +// serviced by a single consumer thread. Commands are added to the queue with PushCall +// and removed with PopCall; they are processed in FIFO order. Multiple producer threads +// are supported and will be blocked if internal data buffer is full. + +class ThreadCommandQueue +{ +public: + + ThreadCommandQueue(); + virtual ~ThreadCommandQueue(); + + + // Pops the next command from the thread queue, if any is available. + // The command should be executed by calling popBuffer->Execute(). + // Returns 'false' if no command is available at the time of the call. + bool PopCommand(ThreadCommand::PopBuffer* popBuffer); + + // Generic implementaion of PushCommand; enqueues a command for execution. + // Returns 'false' if push failed, usually indicating thread shutdown. + bool PushCommand(const ThreadCommand& command); + + // + void PushExitCommand(bool wait); + + // Returns 'true' once ExitCommand has been processed, so the thread can shut down. + bool IsExiting() const; + + + // These two virtual functions serve as notifications for derived + // thread waiting. + virtual void OnPushNonEmpty_Locked() { } + virtual void OnPopEmpty_Locked() { } + + + // *** PushCall with no result + + // Enqueue a member function of 'this' class to be called on consumer thread. + // By default the function returns immediately; set 'wait' argument to 'true' to + // wait for completion. + template + bool PushCall(R (C::*fn)(), bool wait = false) + { return PushCommand(ThreadCommandMF0(static_cast(this), fn, 0, wait)); } + template + bool PushCall(R (C::*fn)(A0), typename SelfType::Type a0, bool wait = false) + { return PushCommand(ThreadCommandMF1(static_cast(this), fn, 0, a0, wait)); } + template + bool PushCall(R (C::*fn)(A0, A1), + typename SelfType::Type a0, typename SelfType::Type a1, bool wait = false) + { return PushCommand(ThreadCommandMF2(static_cast(this), fn, 0, a0, a1, wait)); } + // Enqueue a specified member function call of class C. + // By default the function returns immediately; set 'wait' argument to 'true' to + // wait for completion. + template + bool PushCall(C* p, R (C::*fn)(), bool wait = false) + { return PushCommand(ThreadCommandMF0(p, fn, 0, wait)); } + template + bool PushCall(C* p, R (C::*fn)(A0), typename SelfType::Type a0, bool wait = false) + { return PushCommand(ThreadCommandMF1(p, fn, 0, a0, wait)); } + template + bool PushCall(C* p, R (C::*fn)(A0, A1), + typename SelfType::Type a0, typename SelfType::Type a1, bool wait = false) + { return PushCommand(ThreadCommandMF2(p, fn, 0, a0, a1, wait)); } + + + // *** PushCall with Result + + // Enqueue a member function of 'this' class call and wait for call to complete + // on consumer thread before returning. + template + bool PushCallAndWaitResult(R (C::*fn)(), R* ret) + { return PushCommand(ThreadCommandMF0(static_cast(this), fn, ret, true)); } + template + bool PushCallAndWaitResult(R (C::*fn)(A0), R* ret, typename SelfType::Type a0) + { return PushCommand(ThreadCommandMF1(static_cast(this), fn, ret, a0, true)); } + template + bool PushCallAndWaitResult(R (C::*fn)(A0, A1), R* ret, + typename SelfType::Type a0, typename SelfType::Type a1) + { return PushCommand(ThreadCommandMF2(static_cast(this), fn, ret, a0, a1, true)); } + // Enqueue a member function call for class C and wait for the call to complete + // on consumer thread before returning. + template + bool PushCallAndWaitResult(C* p, R (C::*fn)(), R* ret) + { return PushCommand(ThreadCommandMF0(p, fn, ret, true)); } + template + bool PushCallAndWaitResult(C* p, R (C::*fn)(A0), R* ret, typename SelfType::Type a0) + { return PushCommand(ThreadCommandMF1(p, fn, ret, a0, true)); } + template + bool PushCallAndWaitResult(C* p, R (C::*fn)(A0, A1), R* ret, + typename SelfType::Type a0, typename SelfType::Type a1) + { return PushCommand(ThreadCommandMF2(p, fn, ret, a0, a1, true)); } + +private: + class ThreadCommandQueueImpl* pImpl; +}; + + +} // namespace OVR + +#endif // OVR_ThreadCommandQueue_h diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Kernel/OVR_Threads.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Kernel/OVR_Threads.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,434 @@ +/************************************************************************************ + +PublicHeader: None +Filename : OVR_Threads.h +Content : Contains thread-related (safe) functionality +Created : September 19, 2012 +Notes : + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ +#ifndef OVR_Threads_h +#define OVR_Threads_h + +#include "OVR_Types.h" +#include "OVR_Atomic.h" +#include "OVR_RefCount.h" +#include "OVR_Array.h" + +// Defines the infinite wait delay timeout +#define OVR_WAIT_INFINITE 0xFFFFFFFF + +// To be defined in the project configuration options +#ifdef OVR_ENABLE_THREADS + + +namespace OVR { + +//----------------------------------------------------------------------------------- +// ****** Declared classes + +// Declared with thread support only +class Mutex; +class WaitCondition; +class Event; +// Implementation forward declarations +class MutexImpl; +class WaitConditionImpl; + + + +//----------------------------------------------------------------------------------- +// ***** Mutex + +// Mutex class represents a system Mutex synchronization object that provides access +// serialization between different threads, allowing one thread mutually exclusive access +// to a resource. Mutex is more heavy-weight then Lock, but supports WaitCondition. + +class Mutex +{ + friend class WaitConditionImpl; + friend class MutexImpl; + + MutexImpl *pImpl; + +public: + // Constructor/destructor + Mutex(bool recursive = 1); + ~Mutex(); + + // Locking functions + void DoLock(); + bool TryLock(); + void Unlock(); + + // Returns 1 if the mutes is currently locked by another thread + // Returns 0 if the mutex is not locked by another thread, and can therefore be acquired. + bool IsLockedByAnotherThread(); + + // Locker class; Used for automatic locking of a mutex withing scope + class Locker + { + public: + Mutex *pMutex; + Locker(Mutex *pmutex) + { pMutex = pmutex; pMutex->DoLock(); } + ~Locker() + { pMutex->Unlock(); } + }; +}; + + +//----------------------------------------------------------------------------------- +// ***** WaitCondition + +/* + WaitCondition is a synchronization primitive that can be used to implement what is known as a monitor. + Dependent threads wait on a wait condition by calling Wait(), and get woken up by other threads that + call Notify() or NotifyAll(). + + The unique feature of this class is that it provides an atomic way of first releasing a Mutex, and then + starting a wait on a wait condition. If both the mutex and the wait condition are associated with the same + resource, this ensures that any condition checked for while the mutex was locked does not change before + the wait on the condition is actually initiated. +*/ + +class WaitCondition +{ + friend class WaitConditionImpl; + // Internal implementation structure + WaitConditionImpl *pImpl; + +public: + // Constructor/destructor + WaitCondition(); + ~WaitCondition(); + + // Release mutex and wait for condition. The mutex is re-aquired after the wait. + // Delay is specified in milliseconds (1/1000 of a second). + bool Wait(Mutex *pmutex, unsigned delay = OVR_WAIT_INFINITE); + + // Notify a condition, releasing at one object waiting + void Notify(); + // Notify a condition, releasing all objects waiting + void NotifyAll(); +}; + + +//----------------------------------------------------------------------------------- +// ***** Event + +// Event is a wait-able synchronization object similar to Windows event. +// Event can be waited on until it's signaled by another thread calling +// either SetEvent or PulseEvent. + +class Event +{ + // Event state, its mutex and the wait condition + volatile bool State; + volatile bool Temporary; + mutable Mutex StateMutex; + WaitCondition StateWaitCondition; + + void updateState(bool newState, bool newTemp, bool mustNotify); + +public: + Event(bool setInitially = 0) : State(setInitially), Temporary(false) { } + ~Event() { } + + // Wait on an event condition until it is set + // Delay is specified in milliseconds (1/1000 of a second). + bool Wait(unsigned delay = OVR_WAIT_INFINITE); + + // Set an event, releasing objects waiting on it + void SetEvent() + { updateState(true, false, true); } + + // Reset an event, un-signaling it + void ResetEvent() + { updateState(false, false, false); } + + // Set and then reset an event once a waiter is released. + // If threads are already waiting, they will be notified and released + // If threads are not waiting, the event is set until the first thread comes in + void PulseEvent() + { updateState(true, true, true); } +}; + + +//----------------------------------------------------------------------------------- +// ***** Thread class + +// ThreadHandle is a handle to a thread, which on some platforms (e.g. Windows) is +// different from ThreadId. On Unix platforms, a ThreadHandle is the same as a +// ThreadId and is pthread_t. +typedef void* ThreadHandle; + +// ThreadId uniquely identifies a thread; returned by Windows GetCurrentThreadId(), +// Unix pthread_self() and Thread::GetThreadId. +typedef void* ThreadId; + + +// *** Thread flags + +// Indicates that the thread is has been started, i.e. Start method has been called, and threads +// OnExit() method has not yet been called/returned. +#define OVR_THREAD_STARTED 0x01 +// This flag is set once the thread has ran, and finished. +#define OVR_THREAD_FINISHED 0x02 +// This flag is set temporarily if this thread was started suspended. It is used internally. +#define OVR_THREAD_START_SUSPENDED 0x08 +// This flag is used to ask a thread to exit. Message driven threads will usually check this flag +// and finish once it is set. +#define OVR_THREAD_EXIT 0x10 + + +class Thread : public RefCountBase +{ // NOTE: Waitable must be the first base since it implements RefCountImpl. +public: + // *** Callback functions, can be used instead of overriding Run + + // Run function prototypes. + // Thread function and user handle passed to it, executed by the default + // Thread::Run implementation if not null. + typedef int (*ThreadFn)(Thread *pthread, void* h); + + // Thread ThreadFunction1 is executed if not 0, otherwise ThreadFunction2 is tried + ThreadFn ThreadFunction; + // User handle passes to a thread + void* UserHandle; + + // Thread state to start a thread with + enum ThreadState + { + NotRunning = 0, + Running = 1, + Suspended = 2 + }; + + // Thread priority + enum ThreadPriority + { + CriticalPriority, + HighestPriority, + AboveNormalPriority, + NormalPriority, + BelowNormalPriority, + LowestPriority, + IdlePriority, + }; + + // Thread constructor parameters + struct CreateParams + { + CreateParams(ThreadFn func = 0, void* hand = 0, size_t ssize = 128 * 1024, + int proc = -1, ThreadState state = NotRunning, ThreadPriority prior = NormalPriority) + : threadFunction(func), userHandle(hand), stackSize(ssize), + processor(proc), initialState(state), priority(prior) {} + ThreadFn threadFunction; // Thread function + void* userHandle; // User handle passes to a thread + size_t stackSize; // Thread stack size + int processor; // Thread hardware processor + ThreadState initialState; // + ThreadPriority priority; // Thread priority + }; + + + // *** Constructors + + // A default constructor always creates a thread in NotRunning state, because + // the derived class has not yet been initialized. The derived class can call Start explicitly. + // "processor" parameter specifies which hardware processor this thread will be run on. + // -1 means OS decides this. Implemented only on Win32 + Thread(size_t stackSize = 128 * 1024, int processor = -1); + // Constructors that initialize the thread with a pointer to function. + // An option to start a thread is available, but it should not be used if classes are derived from Thread. + // "processor" parameter specifies which hardware processor this thread will be run on. + // -1 means OS decides this. Implemented only on Win32 + Thread(ThreadFn threadFunction, void* userHandle = 0, size_t stackSize = 128 * 1024, + int processor = -1, ThreadState initialState = NotRunning); + // Constructors that initialize the thread with a create parameters structure. + explicit Thread(const CreateParams& params); + + // Destructor. + virtual ~Thread(); + + // Waits for all Threads to finish; should be called only from the root + // application thread. Once this function returns, we know that all other + // thread's references to Thread object have been released. + static void OVR_CDECL FinishAllThreads(); + + + // *** Overridable Run function for thread processing + + // - returning from this method will end the execution of the thread + // - return value is usually 0 for success + virtual int Run(); + // Called after return/exit function + virtual void OnExit(); + + + // *** Thread management + + // Starts the thread if its not already running + // - internally sets up the threading and calls Run() + // - initial state can either be Running or Suspended, NotRunning will just fail and do nothing + // - returns the exit code + virtual bool Start(ThreadState initialState = Running); + + // Quits with an exit code + virtual void Exit(int exitCode=0); + + // Suspend the thread until resumed + // Returns 1 for success, 0 for failure. + bool Suspend(); + // Resumes currently suspended thread + // Returns 1 for success, 0 for failure. + bool Resume(); + + // Static function to return a pointer to the current thread + //static Thread* GetThread(); + + + // *** Thread status query functions + + bool GetExitFlag() const; + void SetExitFlag(bool exitFlag); + + // Determines whether the thread was running and is now finished + bool IsFinished() const; + // Determines if the thread is currently suspended + bool IsSuspended() const; + // Returns current thread state + ThreadState GetThreadState() const; + + // Wait for thread to finish for a maxmimum number of milliseconds + // For maxWaitMs = 0 it simply polls and then returns if the thread is not finished + // For maxWaitMs < 0 it will wait forever + bool Join(int maxWaitMs = -1) const; + + // Returns the number of available CPUs on the system + static int GetCPUCount(); + + // Returns the thread exit code. Exit code is initialized to 0, + // and set to the return value if Run function after the thread is finished. + inline int GetExitCode() const { return ExitCode; } + // Returns an OS handle +#if defined(OVR_OS_MS) + void* GetOSHandle() const { return ThreadHandle; } +#else + pthread_t GetOSHandle() const { return ThreadHandle; } +#endif + +#if defined(OVR_OS_MS) + ThreadId GetThreadId() const { return IdValue; } +#else + ThreadId GetThreadId() const { return (ThreadId)GetOSHandle(); } +#endif + + // Returns the platform-specific equivalent const that corresponds to the given ThreadPriority. + static int GetOSPriority(ThreadPriority); + static ThreadPriority GetOVRPriority(int osPriority); // May return a value outside the ThreadPriority enum range in unusual cases. + + // Gets this instance's priority. + ThreadPriority GetPriority(); + + // Gets the current thread's priority. + static ThreadPriority GetCurrentPriority(); + + // Sets this instance's thread's priority. + // Some platforms (e.g. Unix) don't let you set thread priorities unless you have root privileges/ + bool SetPriority(ThreadPriority); + + // Sets the current thread's priority. + static bool SetCurrentPriority(ThreadPriority); + + // *** Sleep + + // Sleep secs seconds + static bool Sleep(unsigned secs); + // Sleep msecs milliseconds + static bool MSleep(unsigned msecs); + + + // *** Debugging functionality + virtual void SetThreadName(const char* name); + static void SetThreadName(const char* name, ThreadId threadId); + static void SetCurrentThreadName(const char* name); + + static void GetThreadName(char* name, size_t nameCapacity, ThreadId threadId); + static void GetCurrentThreadName(char* name, size_t nameCapacity); + +private: +#if defined(OVR_OS_WIN32) + friend unsigned WINAPI Thread_Win32StartFn(void *phandle); +#elif defined(OVR_OS_MS) // Any other Microsoft OS... + friend DWORD WINAPI Thread_Win32StartFn(void *phandle); +#else + friend void *Thread_PthreadStartFn(void * phandle); + + static int InitAttr; + static pthread_attr_t Attr; +#endif + +protected: + // Thread state flags + AtomicInt ThreadFlags; + AtomicInt SuspendCount; + size_t StackSize; + + // Hardware processor which this thread is running on. + int Processor; + ThreadPriority Priority; + +#if defined(OVR_OS_MS) + void* ThreadHandle; + volatile ThreadId IdValue; + + // System-specific cleanup function called from destructor + void CleanupSystemThread(); + +#else + pthread_t ThreadHandle; +#endif + + // Exit code of the thread, as returned by Run. + int ExitCode; + + // Internal run function. + int PRun(); + // Finishes the thread and releases internal reference to it. + void FinishAndRelease(); + + void Init(const CreateParams& params); + + // Protected copy constructor + Thread(const Thread &source) : RefCountBase() { OVR_UNUSED(source); } + +}; + +// Returns the unique Id of a thread it is called on, intended for +// comparison purposes. +ThreadId GetCurrentThreadId(); + + +} // OVR + +#endif // OVR_ENABLE_THREADS +#endif // OVR_Threads_h diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Kernel/OVR_ThreadsPthread.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Kernel/OVR_ThreadsPthread.cpp Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,984 @@ +/************************************************************************************ + +Filename : OVR_ThreadsPthread.cpp +Content : +Created : +Notes : + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#include "OVR_Threads.h" +#include "OVR_Hash.h" + +#ifdef OVR_ENABLE_THREADS + +#include "OVR_Timer.h" +#include "OVR_Log.h" + +#include +#include +#include +#include +#include +#include + +#if defined(OVR_OS_MAC) || defined(OVR_OS_BSD) + #include + #include + #if !defined(OVR_OS_MAC) + #include + #endif +#endif + + + +namespace OVR { + +// ***** Mutex implementation + + +// *** Internal Mutex implementation structure + +class MutexImpl : public NewOverrideBase +{ + // System mutex or semaphore + pthread_mutex_t SMutex; + bool Recursive; + unsigned LockCount; + pthread_t LockedBy; + + friend class WaitConditionImpl; + +public: + // Constructor/destructor + MutexImpl(Mutex* pmutex, bool recursive = 1); + ~MutexImpl(); + + // Locking functions + void DoLock(); + bool TryLock(); + void Unlock(Mutex* pmutex); + // Returns 1 if the mutes is currently locked + bool IsLockedByAnotherThread(Mutex* pmutex); + bool IsSignaled() const; +}; + +pthread_mutexattr_t Lock::RecursiveAttr; +bool Lock::RecursiveAttrInit = 0; + +// *** Constructor/destructor +MutexImpl::MutexImpl(Mutex* pmutex, bool recursive) +{ + OVR_UNUSED(pmutex); + Recursive = recursive; + LockCount = 0; + + if (Recursive) + { + if (!Lock::RecursiveAttrInit) + { + pthread_mutexattr_init(&Lock::RecursiveAttr); + pthread_mutexattr_settype(&Lock::RecursiveAttr, PTHREAD_MUTEX_RECURSIVE); + Lock::RecursiveAttrInit = 1; + } + + pthread_mutex_init(&SMutex, &Lock::RecursiveAttr); + } + else + pthread_mutex_init(&SMutex, 0); +} + +MutexImpl::~MutexImpl() +{ + pthread_mutex_destroy(&SMutex); +} + + +// Lock and try lock +void MutexImpl::DoLock() +{ + while (pthread_mutex_lock(&SMutex)) + ; + LockCount++; + LockedBy = pthread_self(); +} + +bool MutexImpl::TryLock() +{ + if (!pthread_mutex_trylock(&SMutex)) + { + LockCount++; + LockedBy = pthread_self(); + return 1; + } + + return 0; +} + +void MutexImpl::Unlock(Mutex* pmutex) +{ + OVR_UNUSED(pmutex); + OVR_ASSERT(pthread_self() == LockedBy && LockCount > 0); + + //unsigned lockCount; + LockCount--; + //lockCount = LockCount; + + pthread_mutex_unlock(&SMutex); +} + +bool MutexImpl::IsLockedByAnotherThread(Mutex* pmutex) +{ + OVR_UNUSED(pmutex); + // There could be multiple interpretations of IsLocked with respect to current thread + if (LockCount == 0) + return 0; + if (pthread_self() != LockedBy) + return 1; + return 0; +} + +bool MutexImpl::IsSignaled() const +{ + // An mutex is signaled if it is not locked ANYWHERE + // Note that this is different from IsLockedByAnotherThread function, + // that takes current thread into account + return LockCount == 0; +} + + +// *** Actual Mutex class implementation + +Mutex::Mutex(bool recursive) +{ + // NOTE: RefCount mode already thread-safe for all waitables. + pImpl = new MutexImpl(this, recursive); +} + +Mutex::~Mutex() +{ + delete pImpl; +} + +// Lock and try lock +void Mutex::DoLock() +{ + pImpl->DoLock(); +} +bool Mutex::TryLock() +{ + return pImpl->TryLock(); +} +void Mutex::Unlock() +{ + pImpl->Unlock(this); +} +bool Mutex::IsLockedByAnotherThread() +{ + return pImpl->IsLockedByAnotherThread(this); +} + + + +//----------------------------------------------------------------------------------- +// ***** Event + +bool Event::Wait(unsigned delay) +{ + Mutex::Locker lock(&StateMutex); + + // Do the correct amount of waiting + if (delay == OVR_WAIT_INFINITE) + { + while(!State) + StateWaitCondition.Wait(&StateMutex); + } + else if (delay) + { + if (!State) + StateWaitCondition.Wait(&StateMutex, delay); + } + + bool state = State; + // Take care of temporary 'pulsing' of a state + if (Temporary) + { + Temporary = false; + State = false; + } + return state; +} + +void Event::updateState(bool newState, bool newTemp, bool mustNotify) +{ + Mutex::Locker lock(&StateMutex); + State = newState; + Temporary = newTemp; + if (mustNotify) + StateWaitCondition.NotifyAll(); +} + + + +// ***** Wait Condition Implementation + +// Internal implementation class +class WaitConditionImpl : public NewOverrideBase +{ + pthread_mutex_t SMutex; + pthread_cond_t Condv; + +public: + + // Constructor/destructor + WaitConditionImpl(); + ~WaitConditionImpl(); + + // Release mutex and wait for condition. The mutex is re-aqured after the wait. + bool Wait(Mutex *pmutex, unsigned delay = OVR_WAIT_INFINITE); + + // Notify a condition, releasing at one object waiting + void Notify(); + // Notify a condition, releasing all objects waiting + void NotifyAll(); +}; + + +WaitConditionImpl::WaitConditionImpl() +{ + pthread_mutex_init(&SMutex, 0); + pthread_cond_init(&Condv, 0); +} + +WaitConditionImpl::~WaitConditionImpl() +{ + pthread_mutex_destroy(&SMutex); + pthread_cond_destroy(&Condv); +} + +bool WaitConditionImpl::Wait(Mutex *pmutex, unsigned delay) +{ + bool result = 1; + unsigned lockCount = pmutex->pImpl->LockCount; + + // Mutex must have been locked + if (lockCount == 0) + return 0; + + pthread_mutex_lock(&SMutex); + + // Finally, release a mutex or semaphore + if (pmutex->pImpl->Recursive) + { + // Release the recursive mutex N times + pmutex->pImpl->LockCount = 0; + for(unsigned i=0; ipImpl->SMutex); + } + else + { + pmutex->pImpl->LockCount = 0; + pthread_mutex_unlock(&pmutex->pImpl->SMutex); + } + + // Note that there is a gap here between mutex.Unlock() and Wait(). + // The other mutex protects this gap. + + if (delay == OVR_WAIT_INFINITE) + pthread_cond_wait(&Condv,&SMutex); + else + { + timespec ts; + + struct timeval tv; + gettimeofday(&tv, 0); + + ts.tv_sec = tv.tv_sec + (delay / 1000); + ts.tv_nsec = (tv.tv_usec + (delay % 1000) * 1000) * 1000; + + if (ts.tv_nsec > 999999999) + { + ts.tv_sec++; + ts.tv_nsec -= 1000000000; + } + int r = pthread_cond_timedwait(&Condv,&SMutex, &ts); + OVR_ASSERT(r == 0 || r == ETIMEDOUT); + if (r) + result = 0; + } + + pthread_mutex_unlock(&SMutex); + + // Re-aquire the mutex + for(unsigned i=0; iDoLock(); + + // Return the result + return result; +} + +// Notify a condition, releasing the least object in a queue +void WaitConditionImpl::Notify() +{ + pthread_mutex_lock(&SMutex); + pthread_cond_signal(&Condv); + pthread_mutex_unlock(&SMutex); +} + +// Notify a condition, releasing all objects waiting +void WaitConditionImpl::NotifyAll() +{ + pthread_mutex_lock(&SMutex); + pthread_cond_broadcast(&Condv); + pthread_mutex_unlock(&SMutex); +} + + + +// *** Actual implementation of WaitCondition + +WaitCondition::WaitCondition() +{ + pImpl = new WaitConditionImpl; +} +WaitCondition::~WaitCondition() +{ + delete pImpl; +} + +bool WaitCondition::Wait(Mutex *pmutex, unsigned delay) +{ + return pImpl->Wait(pmutex, delay); +} +// Notification +void WaitCondition::Notify() +{ + pImpl->Notify(); +} +void WaitCondition::NotifyAll() +{ + pImpl->NotifyAll(); +} + + +// ***** Current thread + +// Per-thread variable +/* +static __thread Thread* pCurrentThread = 0; + +// Static function to return a pointer to the current thread +void Thread::InitCurrentThread(Thread *pthread) +{ + pCurrentThread = pthread; +} + +// Static function to return a pointer to the current thread +Thread* Thread::GetThread() +{ + return pCurrentThread; +} +*/ + + +// *** Thread constructors. + +Thread::Thread(UPInt stackSize, int processor) +{ + // NOTE: RefCount mode already thread-safe for all Waitable objects. + CreateParams params; + params.stackSize = stackSize; + params.processor = processor; + Init(params); +} + +Thread::Thread(Thread::ThreadFn threadFunction, void* userHandle, UPInt stackSize, + int processor, Thread::ThreadState initialState) +{ + CreateParams params(threadFunction, userHandle, stackSize, processor, initialState); + Init(params); +} + +Thread::Thread(const CreateParams& params) +{ + Init(params); +} + +void Thread::Init(const CreateParams& params) +{ + // Clear the variables + ThreadFlags = 0; + ThreadHandle = 0; + ExitCode = 0; + SuspendCount = 0; + StackSize = params.stackSize; + Processor = params.processor; + Priority = params.priority; + + // Clear Function pointers + ThreadFunction = params.threadFunction; + UserHandle = params.userHandle; + if (params.initialState != NotRunning) + Start(params.initialState); +} + +Thread::~Thread() +{ + // Thread should not running while object is being destroyed, + // this would indicate ref-counting issue. + //OVR_ASSERT(IsRunning() == 0); + + // Clean up thread. + ThreadHandle = 0; +} + + + +// *** Overridable User functions. + +// Default Run implementation +int Thread::Run() +{ + // Call pointer to function, if available. + return (ThreadFunction) ? ThreadFunction(this, UserHandle) : 0; +} +void Thread::OnExit() +{ +} + + +// Finishes the thread and releases internal reference to it. +void Thread::FinishAndRelease() +{ + // Note: thread must be US. + ThreadFlags &= (UInt32)~(OVR_THREAD_STARTED); + ThreadFlags |= OVR_THREAD_FINISHED; + + // Release our reference; this is equivalent to 'delete this' + // from the point of view of our thread. + Release(); +} + + + +// *** ThreadList - used to track all created threads + +class ThreadList : public NewOverrideBase +{ + //------------------------------------------------------------------------ + struct ThreadHashOp + { + size_t operator()(const Thread* ptr) + { + return (((size_t)ptr) >> 6) ^ (size_t)ptr; + } + }; + + HashSet ThreadSet; + Mutex ThreadMutex; + WaitCondition ThreadsEmpty; + // Track the root thread that created us. + pthread_t RootThreadId; + + static ThreadList* volatile pRunningThreads; + + void addThread(Thread *pthread) + { + Mutex::Locker lock(&ThreadMutex); + ThreadSet.Add(pthread); + } + + void removeThread(Thread *pthread) + { + Mutex::Locker lock(&ThreadMutex); + ThreadSet.Remove(pthread); + if (ThreadSet.GetSize() == 0) + ThreadsEmpty.Notify(); + } + + void finishAllThreads() + { + // Only original root thread can call this. + OVR_ASSERT(pthread_self() == RootThreadId); + + Mutex::Locker lock(&ThreadMutex); + while (ThreadSet.GetSize() != 0) + ThreadsEmpty.Wait(&ThreadMutex); + } + +public: + + ThreadList() + { + RootThreadId = pthread_self(); + } + ~ThreadList() { } + + + static void AddRunningThread(Thread *pthread) + { + // Non-atomic creation ok since only the root thread + if (!pRunningThreads) + { + pRunningThreads = new ThreadList; + OVR_ASSERT(pRunningThreads); + } + pRunningThreads->addThread(pthread); + } + + // NOTE: 'pthread' might be a dead pointer when this is + // called so it should not be accessed; it is only used + // for removal. + static void RemoveRunningThread(Thread *pthread) + { + OVR_ASSERT(pRunningThreads); + pRunningThreads->removeThread(pthread); + } + + static void FinishAllThreads() + { + // This is ok because only root thread can wait for other thread finish. + if (pRunningThreads) + { + pRunningThreads->finishAllThreads(); + delete pRunningThreads; + pRunningThreads = 0; + } + } +}; + +// By default, we have no thread list. +ThreadList* volatile ThreadList::pRunningThreads = 0; + + +// FinishAllThreads - exposed publicly in Thread. +void Thread::FinishAllThreads() +{ + ThreadList::FinishAllThreads(); +} + +// *** Run override + +int Thread::PRun() +{ + // Suspend us on start, if requested + if (ThreadFlags & OVR_THREAD_START_SUSPENDED) + { + Suspend(); + ThreadFlags &= (UInt32)~OVR_THREAD_START_SUSPENDED; + } + + // Call the virtual run function + ExitCode = Run(); + return ExitCode; +} + + + + +// *** User overridables + +bool Thread::GetExitFlag() const +{ + return (ThreadFlags & OVR_THREAD_EXIT) != 0; +} + +void Thread::SetExitFlag(bool exitFlag) +{ + // The below is atomic since ThreadFlags is AtomicInt. + if (exitFlag) + ThreadFlags |= OVR_THREAD_EXIT; + else + ThreadFlags &= (UInt32) ~OVR_THREAD_EXIT; +} + + +// Determines whether the thread was running and is now finished +bool Thread::IsFinished() const +{ + return (ThreadFlags & OVR_THREAD_FINISHED) != 0; +} +// Determines whether the thread is suspended +bool Thread::IsSuspended() const +{ + return SuspendCount > 0; +} +// Returns current thread state +Thread::ThreadState Thread::GetThreadState() const +{ + if (IsSuspended()) + return Suspended; + if (ThreadFlags & OVR_THREAD_STARTED) + return Running; + return NotRunning; +} + +// Join thread +bool Thread::Join(int maxWaitMs) const +{ + // If polling, + if (maxWaitMs == 0) + { + // Just return if finished + return IsFinished(); + } + // If waiting forever, + else if (maxWaitMs > 0) + { + UInt32 t0 = Timer::GetTicksMs(); + + while (!IsFinished()) + { + UInt32 t1 = Timer::GetTicksMs(); + + // If the wait has expired, + int delta = (int)(t1 - t0); + if (delta >= maxWaitMs) + { + return false; + } + + Thread::MSleep(10); + } + + return true; + } + else + { + while (!IsFinished()) + { + pthread_join(ThreadHandle, NULL); + } + } + + return true; +} + +/* +static const char* mapsched_policy(int policy) +{ + switch(policy) + { + case SCHED_OTHER: + return "SCHED_OTHER"; + case SCHED_RR: + return "SCHED_RR"; + case SCHED_FIFO: + return "SCHED_FIFO"; + + } + return "UNKNOWN"; +} + int policy; + sched_param sparam; + pthread_getschedparam(pthread_self(), &policy, &sparam); + int max_prior = sched_get_priority_max(policy); + int min_prior = sched_get_priority_min(policy); + printf(" !!!! policy: %s, priority: %d, max priority: %d, min priority: %d\n", mapsched_policy(policy), sparam.sched_priority, max_prior, min_prior); +#include +*/ +// ***** Thread management + +// The actual first function called on thread start +void* Thread_PthreadStartFn(void* phandle) +{ + Thread* pthread = (Thread*)phandle; + int result = pthread->PRun(); + // Signal the thread as done and release it atomically. + pthread->FinishAndRelease(); + // At this point Thread object might be dead; however we can still pass + // it to RemoveRunningThread since it is only used as a key there. + ThreadList::RemoveRunningThread(pthread); + return reinterpret_cast(result); +} + +int Thread::InitAttr = 0; +pthread_attr_t Thread::Attr; + +/* static */ +int Thread::GetOSPriority(ThreadPriority p) +{ + OVR_UNUSED(p); + return -1; +} + +/* static */ +Thread::ThreadPriority Thread::GetOVRPriority(int osPriority) +{ + #if defined(OVR_OS_LINUX) + return (ThreadPriority)(Thread::NormalPriority - osPriority); // This works for both SCHED_OTHER, SCHED_RR, and SCHED_FIFO. + #else + // Apple priorities are such that the min is a value less than the max. + static int minPriority = sched_get_priority_min(SCHED_FIFO); // We don't have a means to pass a policy type to this function. + static int maxPriority = sched_get_priority_max(SCHED_FIFO); + + return (ThreadPriority)(Thread::NormalPriority - (osPriority - ((minPriority + maxPriority) / 2))); + #endif +} + + +Thread::ThreadPriority Thread::GetPriority() +{ + int policy; + sched_param param; + + int result = pthread_getschedparam(ThreadHandle, &policy, ¶m); + + if(result == 0) + { + #if !defined(OVR_OS_LINUX) + if(policy == SCHED_OTHER) + { + return Thread::NormalPriority; //SCHED_OTHER allows only normal priority on BSD-style Unix and Mac OS X. + } + #endif + + return GetOVRPriority(param.sched_priority); + } + + return Thread::NormalPriority; +} + +/* static */ +Thread::ThreadPriority Thread::GetCurrentPriority() +{ + int policy; + sched_param param; + pthread_t currentThreadId = pthread_self(); + + int result = pthread_getschedparam(currentThreadId, &policy, ¶m); + + if(result == 0) + { + #if !defined(OVR_OS_LINUX) + if(policy == SCHED_OTHER) + { + return Thread::NormalPriority; //SCHED_OTHER allows only normal priority on BSD-style Unix and Mac OS X. + } + #endif + + return GetOVRPriority(param.sched_priority); + } + + return Thread::NormalPriority; +} + + +bool Thread::SetPriority(ThreadPriority) +{ + // We currently fail. To do: add code to support this via pthread_getschedparam/pthread_attr_setschedparam + // This won't work unless using SCHED_FIFO or SCHED_RR anyway, which require root privileges. + return false; +} + +/* static */ +bool Thread::SetCurrentPriority(ThreadPriority) +{ + // We currently fail. To do: add code to support this via pthread_getschedparam/pthread_attr_setschedparam + // This won't work unless using SCHED_FIFO or SCHED_RR anyway, which require root privileges. + return false; +} + +bool Thread::Start(ThreadState initialState) +{ + if (initialState == NotRunning) + return 0; + if (GetThreadState() != NotRunning) + { + OVR_DEBUG_LOG(("Thread::Start failed - thread %p already running", this)); + return 0; + } + + if (!InitAttr) + { + pthread_attr_init(&Attr); + pthread_attr_setdetachstate(&Attr, PTHREAD_CREATE_DETACHED); + pthread_attr_setstacksize(&Attr, 128 * 1024); + sched_param sparam; + sparam.sched_priority = Thread::GetOSPriority(NormalPriority); + pthread_attr_setschedparam(&Attr, &sparam); + InitAttr = 1; + } + + ExitCode = 0; + SuspendCount = 0; + ThreadFlags = (initialState == Running) ? 0 : OVR_THREAD_START_SUSPENDED; + + // AddRef to us until the thread is finished + AddRef(); + ThreadList::AddRunningThread(this); + + int result; + if (StackSize != 128 * 1024 || Priority != NormalPriority) + { + pthread_attr_t attr; + + pthread_attr_init(&attr); + pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); + pthread_attr_setstacksize(&attr, StackSize); + sched_param sparam; + sparam.sched_priority = Thread::GetOSPriority(Priority); + pthread_attr_setschedparam(&attr, &sparam); + result = pthread_create(&ThreadHandle, &attr, Thread_PthreadStartFn, this); + pthread_attr_destroy(&attr); + } + else + result = pthread_create(&ThreadHandle, &Attr, Thread_PthreadStartFn, this); + + if (result) + { + ThreadFlags = 0; + Release(); + ThreadList::RemoveRunningThread(this); + return 0; + } + return 1; +} + + +// Suspend the thread until resumed +bool Thread::Suspend() +{ + OVR_DEBUG_LOG(("Thread::Suspend - cannot suspend threads on this system")); + return 0; +} + +// Resumes currently suspended thread +bool Thread::Resume() +{ + return 0; +} + + +// Quits with an exit code +void Thread::Exit(int exitCode) +{ + // Can only exist the current thread + // if (GetThread() != this) + // return; + + // Call the virtual OnExit function + OnExit(); + + // Signal this thread object as done and release it's references. + FinishAndRelease(); + ThreadList::RemoveRunningThread(this); + + pthread_exit(reinterpret_cast(exitCode)); +} + +ThreadId GetCurrentThreadId() +{ + return (void*)pthread_self(); +} + +// *** Sleep functions + +/* static */ +bool Thread::Sleep(unsigned secs) +{ + sleep(secs); + return 1; +} +/* static */ +bool Thread::MSleep(unsigned msecs) +{ + usleep(msecs*1000); + return 1; +} + +/* static */ +int Thread::GetCPUCount() +{ + #if defined(OVR_OS_MAC) || defined(OVR_OS_BSD) + // http://developer.apple.com/mac/library/documentation/Darwin/Reference/ManPages/man3/sysctlbyname.3.html + int cpuCount = 0; + size_t len = sizeof(cpuCount); + + if(sysctlbyname("hw.logicalcpu", &cpuCount, &len, NULL, 0) != 0) + cpuCount = 1; + + return cpuCount; + + #else // Linux, Android + + // Alternative: read /proc/cpuinfo + #ifdef _SC_NPROCESSORS_ONLN + return (int)sysconf(_SC_NPROCESSORS_ONLN); + #else + return 1; + #endif + #endif +} + + +void Thread::SetThreadName( const char* name ) +{ + #if defined (OVR_OS_APPLE) + if(ThreadHandle == pthread_self()) + pthread_setname_np(name); + // Else there's nothing we can do. + #else + if(ThreadHandle != 0) + pthread_setname_np(ThreadHandle, name); + // Else we can possibly save this name and set it later when the thread starts. + #endif +} + + +void Thread::SetThreadName(const char* name, ThreadId threadId) +{ + #if defined (OVR_OS_APPLE) + if(pthread_equal((pthread_t)threadId, pthread_self())) + pthread_setname_np(name); + // Else there's no way to set the name of another thread. + #else + pthread_setname_np((pthread_t)threadId, name); + #endif +} + + +void Thread::SetCurrentThreadName(const char* name) +{ + #if defined (OVR_OS_APPLE) + pthread_setname_np(name); + #else + pthread_setname_np(pthread_self(), name); + #endif +} + + +void Thread::GetThreadName(char* name, size_t nameCapacity, ThreadId threadId) +{ + name[0] = 0; + pthread_getname_np((pthread_t)threadId, name, nameCapacity); +} + + +void Thread::GetCurrentThreadName(char* name, size_t nameCapacity) +{ + name[0] = 0; + pthread_getname_np(pthread_self(), name, nameCapacity); +} + + +} // namespace OVR + +#endif // OVR_ENABLE_THREADS diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Kernel/OVR_Timer.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Kernel/OVR_Timer.cpp Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,551 @@ +/************************************************************************************ + +Filename : OVR_Timer.cpp +Content : Provides static functions for precise timing +Created : September 19, 2012 +Notes : + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#include "OVR_Timer.h" +#include "OVR_Log.h" + +#if defined(OVR_OS_MS) && !defined(OVR_OS_MS_MOBILE) +#define WIN32_LEAN_AND_MEAN +#include +#include +#elif defined(OVR_OS_ANDROID) +#include +#include +#elif defined(OVR_OS_MAC) +#include +#else +#include +#include +#include +#endif + + +#if defined(OVR_BUILD_DEBUG) && defined(OVR_OS_WIN32) + #ifndef NTSTATUS + #define NTSTATUS DWORD + #endif + + typedef NTSTATUS (NTAPI* NtQueryTimerResolutionType)(PULONG MaximumTime, PULONG MinimumTime, PULONG CurrentTime); + NtQueryTimerResolutionType pNtQueryTimerResolution; +#endif + + + +#if defined(OVR_OS_MS) && !defined(OVR_OS_WIN32) // Non-desktop Microsoft platforms... + +// Add this alias here because we're not going to include OVR_CAPI.cpp +extern "C" { + double ovr_GetTimeInSeconds() + { + return Timer::GetSeconds(); + } +} + +#endif + + + + +namespace OVR { + +// For recorded data playback +bool Timer::useFakeSeconds = false; +double Timer::FakeSeconds = 0; + + + + +//------------------------------------------------------------------------ +// *** Android Specific Timer + +#if defined(OVR_OS_ANDROID) // To consider: This implementation can also work on most Linux distributions + +//------------------------------------------------------------------------ +// *** Timer - Platform Independent functions + +// Returns global high-resolution application timer in seconds. +double Timer::GetSeconds() +{ + if(useFakeSeconds) + return FakeSeconds; + + // Choreographer vsync timestamp is based on. + struct timespec tp; + const int status = clock_gettime(CLOCK_MONOTONIC, &tp); + +#ifdef OVR_BUILD_DEBUG + if (status != 0) + { + OVR_DEBUG_LOG(("clock_gettime status=%i", status )); + } +#else + OVR_UNUSED(status); +#endif + + return (double)tp.tv_sec; +} + + + +uint64_t Timer::GetTicksNanos() +{ + if (useFakeSeconds) + return (uint64_t) (FakeSeconds * NanosPerSecond); + + // Choreographer vsync timestamp is based on. + struct timespec tp; + const int status = clock_gettime(CLOCK_MONOTONIC, &tp); + +#ifdef OVR_BUILD_DEBUG + if (status != 0) + { + OVR_DEBUG_LOG(("clock_gettime status=%i", status )); + } +#else + OVR_UNUSED(status); +#endif + + const uint64_t result = (uint64_t)tp.tv_sec * (uint64_t)(1000 * 1000 * 1000) + uint64_t(tp.tv_nsec); + return result; +} + + +void Timer::initializeTimerSystem() +{ + // Empty for this platform. +} + +void Timer::shutdownTimerSystem() +{ + // Empty for this platform. +} + + + + + +//------------------------------------------------------------------------ +// *** Win32 Specific Timer + +#elif defined (OVR_OS_MS) + + +// This helper class implements high-resolution wrapper that combines timeGetTime() output +// with QueryPerformanceCounter. timeGetTime() is lower precision but drives the high bits, +// as it's tied to the system clock. +struct PerformanceTimer +{ + PerformanceTimer() + : UsingVistaOrLater(false), + TimeCS(), + OldMMTimeMs(0), + MMTimeWrapCounter(0), + PerfFrequency(0), + PerfFrequencyInverse(0), + PerfFrequencyInverseNanos(0), + PerfMinusTicksDeltaNanos(0), + LastResultNanos(0) + { } + + enum { + MMTimerResolutionNanos = 1000000 + }; + + void Initialize(); + void Shutdown(); + + uint64_t GetTimeSeconds(); + double GetTimeSecondsDouble(); + uint64_t GetTimeNanos(); + + UINT64 getFrequency() + { + if (PerfFrequency == 0) + { + LARGE_INTEGER freq; + QueryPerformanceFrequency(&freq); + PerfFrequency = freq.QuadPart; + PerfFrequencyInverse = 1.0 / (double)PerfFrequency; + PerfFrequencyInverseNanos = 1000000000.0 / (double)PerfFrequency; + } + return PerfFrequency; + } + + double GetFrequencyInverse() + { + OVR_ASSERT(PerfFrequencyInverse != 0.0); // Assert that the frequency has been initialized. + return PerfFrequencyInverse; + } + + bool UsingVistaOrLater; + + CRITICAL_SECTION TimeCS; + // timeGetTime() support with wrap. + uint32_t OldMMTimeMs; + uint32_t MMTimeWrapCounter; + // Cached performance frequency result. + uint64_t PerfFrequency; // cycles per second, typically a large value like 3000000, but usually not the same as the CPU clock rate. + double PerfFrequencyInverse; // seconds per cycle (will be a small fractional value). + double PerfFrequencyInverseNanos; // nanoseconds per cycle. + + // Computed as (perfCounterNanos - ticksCounterNanos) initially, + // and used to adjust timing. + uint64_t PerfMinusTicksDeltaNanos; + // Last returned value in nanoseconds, to ensure we don't back-step in time. + uint64_t LastResultNanos; +}; + +static PerformanceTimer Win32_PerfTimer; + + +void PerformanceTimer::Initialize() +{ + #if defined(OVR_OS_WIN32) // Desktop Windows only + // The following has the effect of setting the NT timer resolution (NtSetTimerResolution) to 1 millisecond. + MMRESULT mmr = timeBeginPeriod(1); + OVR_ASSERT(TIMERR_NOERROR == mmr); + OVR_UNUSED(mmr); + #endif + + InitializeCriticalSection(&TimeCS); + MMTimeWrapCounter = 0; + getFrequency(); + + #if defined(OVR_OS_WIN32) // Desktop Windows only + // Set Vista flag. On Vista, we can just use QPC() without all the extra work + OSVERSIONINFOEX ver; + ZeroMemory(&ver, sizeof(OSVERSIONINFOEX)); + ver.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); + ver.dwMajorVersion = 6; // Vista+ + + DWORDLONG condMask = 0; + VER_SET_CONDITION(condMask, VER_MAJORVERSION, VER_GREATER_EQUAL); + + // VerifyVersionInfo returns true if the OS meets the conditions set above + UsingVistaOrLater = VerifyVersionInfo(&ver, VER_MAJORVERSION, condMask) != 0; + #else + UsingVistaOrLater = true; + #endif + + OVR_DEBUG_LOG(("PerformanceTimer UsingVistaOrLater = %d", (int)UsingVistaOrLater)); + + #if defined(OVR_BUILD_DEBUG) && defined(OVR_OS_WIN32) + HMODULE hNtDll = LoadLibrary(L"NtDll.dll"); + if (hNtDll) + { + pNtQueryTimerResolution = (NtQueryTimerResolutionType)GetProcAddress(hNtDll, "NtQueryTimerResolution"); + //pNtSetTimerResolution = (NtSetTimerResolutionType)GetProcAddress(hNtDll, "NtSetTimerResolution"); + + if(pNtQueryTimerResolution) + { + ULONG MinimumResolution; // in 100-ns units + ULONG MaximumResolution; + ULONG ActualResolution; + pNtQueryTimerResolution(&MinimumResolution, &MaximumResolution, &ActualResolution); + OVR_DEBUG_LOG(("NtQueryTimerResolution = Min %ld us, Max %ld us, Current %ld us", MinimumResolution / 10, MaximumResolution / 10, ActualResolution / 10)); + } + + FreeLibrary(hNtDll); + } + #endif +} + +void PerformanceTimer::Shutdown() +{ + DeleteCriticalSection(&TimeCS); + + #if defined(OVR_OS_WIN32) // Desktop Windows only + MMRESULT mmr = timeEndPeriod(1); + OVR_ASSERT(TIMERR_NOERROR == mmr); + OVR_UNUSED(mmr); + #endif +} + + +uint64_t PerformanceTimer::GetTimeSeconds() +{ + if (UsingVistaOrLater) + { + LARGE_INTEGER li; + QueryPerformanceCounter(&li); + OVR_ASSERT(PerfFrequencyInverse != 0); // Initialize should have been called earlier. + return (uint64_t)(li.QuadPart * PerfFrequencyInverse); + } + + return (uint64_t)(GetTimeNanos() * .0000000001); +} + + +double PerformanceTimer::GetTimeSecondsDouble() +{ + if (UsingVistaOrLater) + { + LARGE_INTEGER li; + QueryPerformanceCounter(&li); + OVR_ASSERT(PerfFrequencyInverse != 0); + return (li.QuadPart * PerfFrequencyInverse); + } + + return (GetTimeNanos() * .0000000001); +} + + +uint64_t PerformanceTimer::GetTimeNanos() +{ + uint64_t resultNanos; + LARGE_INTEGER li; + + OVR_ASSERT(PerfFrequencyInverseNanos != 0); // Initialize should have been called earlier. + + if (UsingVistaOrLater) // Includes non-desktop platforms + { + // Then we can use QPC() directly without all that extra work + QueryPerformanceCounter(&li); + resultNanos = (uint64_t)(li.QuadPart * PerfFrequencyInverseNanos); + } + else + { + // On Win32 QueryPerformanceFrequency is unreliable due to SMP and + // performance levels, so use this logic to detect wrapping and track + // high bits. + ::EnterCriticalSection(&TimeCS); + + // Get raw value and perf counter "At the same time". + QueryPerformanceCounter(&li); + + DWORD mmTimeMs = timeGetTime(); + if (OldMMTimeMs > mmTimeMs) + MMTimeWrapCounter++; + OldMMTimeMs = mmTimeMs; + + // Normalize to nanoseconds. + uint64_t perfCounterNanos = (uint64_t)(li.QuadPart * PerfFrequencyInverseNanos); + uint64_t mmCounterNanos = ((uint64_t(MMTimeWrapCounter) << 32) | mmTimeMs) * 1000000; + if (PerfMinusTicksDeltaNanos == 0) + PerfMinusTicksDeltaNanos = perfCounterNanos - mmCounterNanos; + + // Compute result before snapping. + // + // On first call, this evaluates to: + // resultNanos = mmCounterNanos. + // Next call, assuming no wrap: + // resultNanos = prev_mmCounterNanos + (perfCounterNanos - prev_perfCounterNanos). + // After wrap, this would be: + // resultNanos = snapped(prev_mmCounterNanos +/- 1ms) + (perfCounterNanos - prev_perfCounterNanos). + // + resultNanos = perfCounterNanos - PerfMinusTicksDeltaNanos; + + // Snap the range so that resultNanos never moves further apart then its target resolution. + // It's better to allow more slack on the high side as timeGetTime() may be updated at sporadically + // larger then 1 ms intervals even when 1 ms resolution is requested. + if (resultNanos > (mmCounterNanos + MMTimerResolutionNanos*2)) + { + resultNanos = mmCounterNanos + MMTimerResolutionNanos*2; + if (resultNanos < LastResultNanos) + resultNanos = LastResultNanos; + PerfMinusTicksDeltaNanos = perfCounterNanos - resultNanos; + } + else if (resultNanos < (mmCounterNanos - MMTimerResolutionNanos)) + { + resultNanos = mmCounterNanos - MMTimerResolutionNanos; + if (resultNanos < LastResultNanos) + resultNanos = LastResultNanos; + PerfMinusTicksDeltaNanos = perfCounterNanos - resultNanos; + } + + LastResultNanos = resultNanos; + ::LeaveCriticalSection(&TimeCS); + } + + //Tom's addition, to keep precision + //static uint64_t initial_time = 0; + //if (!initial_time) initial_time = resultNanos; + //resultNanos -= initial_time; + // FIXME: This cannot be used for cross-process timestamps + + return resultNanos; +} + + +//------------------------------------------------------------------------ +// *** Timer - Platform Independent functions + +// Returns global high-resolution application timer in seconds. +double Timer::GetSeconds() +{ + if(useFakeSeconds) + return FakeSeconds; + + return Win32_PerfTimer.GetTimeSecondsDouble(); +} + + + +// Delegate to PerformanceTimer. +uint64_t Timer::GetTicksNanos() +{ + if (useFakeSeconds) + return (uint64_t) (FakeSeconds * NanosPerSecond); + + return Win32_PerfTimer.GetTimeNanos(); +} +void Timer::initializeTimerSystem() +{ + Win32_PerfTimer.Initialize(); +} +void Timer::shutdownTimerSystem() +{ + Win32_PerfTimer.Shutdown(); +} + + + +#elif defined(OVR_OS_MAC) + + +double Timer::TimeConvertFactorNanos = 0.0; +double Timer::TimeConvertFactorSeconds = 0.0; + + +//------------------------------------------------------------------------ +// *** Standard OS Timer + +// Returns global high-resolution application timer in seconds. +double Timer::GetSeconds() +{ + if(useFakeSeconds) + return FakeSeconds; + + OVR_ASSERT(TimeConvertFactorNanos != 0.0); + return (double)mach_absolute_time() * TimeConvertFactorNanos; +} + + +uint64_t Timer::GetTicksNanos() +{ + if (useFakeSeconds) + return (uint64_t) (FakeSeconds * NanosPerSecond); + + OVR_ASSERT(TimeConvertFactorSeconds != 0.0); + return (uint64_t)(mach_absolute_time() * TimeConvertFactorSeconds); +} + +void Timer::initializeTimerSystem() +{ + mach_timebase_info_data_t timeBase; + mach_timebase_info(&timeBase); + TimeConvertFactorSeconds = ((double)timeBase.numer / (double)timeBase.denom); + TimeConvertFactorNanos = TimeConvertFactorSeconds / 1000000000.0; +} + +void Timer::shutdownTimerSystem() +{ + // Empty for this platform. +} + + +#else // Posix platforms (e.g. Linux, BSD Unix) + + +bool Timer::MonotonicClockAvailable = false; + + +// Returns global high-resolution application timer in seconds. +double Timer::GetSeconds() +{ + if(useFakeSeconds) + return FakeSeconds; + + // http://linux/die/netman3/clock_gettime + #if defined(CLOCK_MONOTONIC) // If we can use clock_gettime, which has nanosecond precision... + if(MonotonicClockAvailable) + { + timespec ts; + clock_gettime(CLOCK_MONOTONIC, &ts); // Better to use CLOCK_MONOTONIC than CLOCK_REALTIME. + return static_cast(ts.tv_sec) + static_cast(ts.tv_nsec) / 1E9; + } + #endif + + // We cannot use rdtsc because its frequency changes at runtime. + struct timeval tv; + gettimeofday(&tv, 0); + + return static_cast(tv.tv_sec) + static_cast(tv.tv_usec) / 1E6; +} + + +uint64_t Timer::GetTicksNanos() +{ + if (useFakeSeconds) + return (uint64_t) (FakeSeconds * NanosPerSecond); + + #if defined(CLOCK_MONOTONIC) // If we can use clock_gettime, which has nanosecond precision... + if(MonotonicClockAvailable) + { + timespec ts; + clock_gettime(CLOCK_MONOTONIC, &ts); + return ((uint64_t)ts.tv_sec * 1000000000ULL) + (uint64_t)ts.tv_nsec; + } + #endif + + + // We cannot use rdtsc because its frequency changes at runtime. + uint64_t result; + + // Return microseconds. + struct timeval tv; + + gettimeofday(&tv, 0); + + result = (uint64_t)tv.tv_sec * 1000000; + result += tv.tv_usec; + + return result * 1000; +} + + +void Timer::initializeTimerSystem() +{ + #if defined(CLOCK_MONOTONIC) + timespec ts; // We could also check for the availability of CLOCK_MONOTONIC with sysconf(_SC_MONOTONIC_CLOCK) + int result = clock_gettime(CLOCK_MONOTONIC, &ts); + MonotonicClockAvailable = (result == 0); + #endif +} + +void Timer::shutdownTimerSystem() +{ + // Empty for this platform. +} + + + +#endif // OS-specific + + + +} // OVR + diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Kernel/OVR_Timer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Kernel/OVR_Timer.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,99 @@ +/************************************************************************************ + +PublicHeader: OVR +Filename : OVR_Timer.h +Content : Provides static functions for precise timing +Created : September 19, 2012 +Notes : + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#ifndef OVR_Timer_h +#define OVR_Timer_h + +#include "OVR_Types.h" + +namespace OVR { + +//----------------------------------------------------------------------------------- +// ***** Timer + +// Timer class defines a family of static functions used for application +// timing and profiling. + +class Timer +{ +public: + enum { + MsPerSecond = 1000, // Milliseconds in one second. + MksPerSecond = 1000 * 1000, // Microseconds in one second. + NanosPerSecond = 1000 * 1000 * 1000, // Nanoseconds in one second. + }; + + // ***** Timing APIs for Application + + // These APIs should be used to guide animation and other program functions + // that require precision. + + // Returns global high-resolution application timer in seconds. + static double OVR_STDCALL GetSeconds(); + + // Returns time in Nanoseconds, using highest possible system resolution. + static uint64_t OVR_STDCALL GetTicksNanos(); + + // Kept for compatibility. + // Returns ticks in milliseconds, as a 32-bit number. May wrap around every 49.2 days. + // Use either time difference of two values of GetTicks to avoid wrap-around. + static uint32_t OVR_STDCALL GetTicksMs() + { return uint32_t(GetTicksNanos() / 1000000); } + + // for recorded data playback + static void SetFakeSeconds(double fakeSeconds, bool enable = true) + { + FakeSeconds = fakeSeconds; + useFakeSeconds = enable; + } + +private: + friend class System; + // System called during program startup/shutdown. + static void initializeTimerSystem(); + static void shutdownTimerSystem(); + + // for recorded data playback + static double FakeSeconds; + static bool useFakeSeconds; + + #if defined(OVR_OS_ANDROID) + // Android-specific data + #elif defined (OVR_OS_MS) + // Microsoft-specific data + #elif defined(OVR_OS_MAC) + static double TimeConvertFactorNanos; // Conversion factor for GetTicksNanos + static double TimeConvertFactorSeconds; // Conversion factor for GetSeconds. + #else + static bool MonotonicClockAvailable; // True if clock_gettime supports CLOCK_MONOTONIC + #endif +}; + + +} // OVR::Timer + +#endif diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Kernel/OVR_Types.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Kernel/OVR_Types.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,909 @@ +/************************************************************************************ + +PublicHeader: OVR_Kernel.h +Filename : OVR_Types.h +Content : Standard library defines and simple types +Created : September 19, 2012 +Notes : + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#ifndef OVR_Types_H +#define OVR_Types_H + +#include "OVR_Compiler.h" + + +// Unsupported compiler configurations +#if _MSC_VER == 0x1600 +# if _MSC_FULL_VER < 160040219 +# error "Oculus does not support VS2010 without SP1 installed: It will crash in Release mode" +# endif +#endif + + +//----------------------------------------------------------------------------------- +// ****** Operating system identification +// +// Try to use the most generic version of these defines as possible in order to achieve +// the simplest portable code. For example, instead of using #if (defined(OVR_OS_IPHONE) || defined(OVR_OS_MAC)), +// consider using #if defined(OVR_OS_APPLE). +// +// Type definitions exist for the following operating systems: (OVR_OS_x) +// +// WIN32 - Win32 and Win64 (Windows XP and later) Does not include Microsoft phone and console platforms, despite that Microsoft's _WIN32 may be defined by the compiler for them. +// WIN64 - Win64 (Windows XP and later) +// MAC - Mac OS X (may be defined in addition to BSD) +// LINUX - Linux +// BSD - BSD Unix +// ANDROID - Android (may be defined in addition to LINUX) +// IPHONE - iPhone +// MS_MOBILE - Microsoft mobile OS. +// +// Meta platforms +// MS - Any OS by Microsoft (e.g. Win32, Win64, phone, console) +// APPLE - Any OS by Apple (e.g. iOS, OS X) +// UNIX - Linux, BSD, Mac OS X. +// MOBILE - iOS, Android, Microsoft phone +// CONSOLE - Console platforms +// + +#if (defined(__APPLE__) && (defined(__GNUC__) ||\ + defined(__xlC__) || defined(__xlc__))) || defined(__MACOS__) +# if (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) || defined(__IPHONE_OS_VERSION_MIN_REQUIRED)) +# define OVR_OS_IPHONE +# else +# define OVR_OS_DARWIN +# define OVR_OS_MAC +# define OVR_OS_BSD +# endif +#elif (defined(WIN64) || defined(_WIN64) || defined(__WIN64__)) +# define OVR_OS_WIN64 +# define OVR_OS_WIN32 // Defined for compatibility and because the Win64 API supports the Win32 API. +#elif (defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)) +# define OVR_OS_WIN32 +#elif defined(ANDROID) || defined(__ANDROID__) +# define OVR_OS_ANDROID +# define OVR_OS_LINUX +#elif defined(__linux__) || defined(__linux) +# define OVR_OS_LINUX +#elif defined(_BSD_) || defined(__FreeBSD__) +# define OVR_OS_BSD +#else +# define OVR_OS_OTHER +#endif + +#if !defined(OVR_OS_MS_MOBILE) +# if (defined(_M_ARM) || defined(_M_IX86) || defined(_M_AMD64)) && !defined(OVR_OS_WIN32) && !defined(OVR_OS_CONSOLE) +# define OVR_OS_MS_MOBILE +# endif +#endif + +#if !defined(OVR_OS_MS) +# if defined(OVR_OS_WIN32) || defined(OVR_OS_WIN64) || defined(OVR_OS_MS_MOBILE) +# define OVR_OS_MS +# endif +#endif + +#if !defined(OVR_OS_APPLE) +# if defined(OVR_OS_MAC) || defined(OVR_OS_IPHONE) +# define OVR_OS_APPLE +# endif +#endif + +#if !defined(OVR_OS_UNIX) +# if defined(OVR_OS_ANDROID) || defined(OVR_OS_BSD) || defined(OVR_OS_LINUX) || defined(OVR_OS_MAC) +# define OVR_OS_UNIX +# endif +#endif + +#if !defined(OVR_OS_MOBILE) +# if defined(OVR_OS_ANDROID) || defined(OVR_OS_IPHONE) || defined(OVR_OS_MS_MOBILE) +# define OVR_OS_MOBILE +# endif +#endif + + + + +//----------------------------------------------------------------------------------- +// ***** CPU Architecture +// +// The following CPUs are defined: (OVR_CPU_x) +// +// X86 - x86 (IA-32) +// X86_64 - x86_64 (amd64) +// PPC - PowerPC +// PPC64 - PowerPC64 +// MIPS - MIPS +// OTHER - CPU for which no special support is present or needed + + +#if defined(__x86_64__) || defined(WIN64) || defined(_WIN64) || defined(__WIN64__) || defined(_M_AMD64) +# define OVR_CPU_X86_64 +# define OVR_64BIT_POINTERS +#elif defined(__i386__) || defined(OVR_OS_WIN32) +# define OVR_CPU_X86 +#elif defined(__powerpc64__) +# define OVR_CPU_PPC64 +#elif defined(__ppc__) +# define OVR_CPU_PPC +#elif defined(__mips__) || defined(__MIPSEL__) +# define OVR_CPU_MIPS +#elif defined(__arm__) +# define OVR_CPU_ARM +#else +# define OVR_CPU_OTHER +#endif + +//----------------------------------------------------------------------------------- +// ***** Co-Processor Architecture +// +// The following co-processors are defined: (OVR_CPU_x) +// +// SSE - Available on all modern x86 processors. +// Altivec - Available on all modern ppc processors. +// Neon - Available on some armv7+ processors. + +#if defined(__SSE__) || defined(_M_IX86) || defined(_M_AMD64) // _M_IX86 and _M_AMD64 are Microsoft identifiers for Intel-based platforms. +# define OVR_CPU_SSE +#endif // __SSE__ + +#if defined( __ALTIVEC__ ) +# define OVR_CPU_ALTIVEC +#endif // __ALTIVEC__ + +#if defined(__ARM_NEON__) +# define OVR_CPU_ARM_NEON +#endif // __ARM_NEON__ + + +//----------------------------------------------------------------------------------- +// ***** Compiler Warnings + +// Disable MSVC warnings +#if defined(OVR_CC_MSVC) +# pragma warning(disable : 4127) // Inconsistent dll linkage +# pragma warning(disable : 4530) // Exception handling +# if (OVR_CC_MSVC<1300) +# pragma warning(disable : 4514) // Unreferenced inline function has been removed +# pragma warning(disable : 4710) // Function not inlined +# pragma warning(disable : 4714) // _force_inline not inlined +# pragma warning(disable : 4786) // Debug variable name longer than 255 chars +# endif // (OVR_CC_MSVC<1300) +#endif // (OVR_CC_MSVC) + + + +// *** Linux Unicode - must come before Standard Includes + +#ifdef OVR_OS_LINUX +// Use glibc unicode functions on linux. +# ifndef _GNU_SOURCE +# define _GNU_SOURCE +# endif +#endif + +//----------------------------------------------------------------------------------- +// ***** Standard Includes +// +#include +#include +#include + + +// MSVC Based Memory Leak checking - for now +#if defined(OVR_CC_MSVC) && defined(OVR_BUILD_DEBUG) +# define _CRTDBG_MAP_ALLOC +# include +# include +#endif + + +//----------------------------------------------------------------------------------- +// ***** int8_t, int16_t, etc. + +#if defined(OVR_CC_MSVC) && (OVR_CC_VER <= 1500) // VS2008 and earlier + typedef signed char int8_t; + typedef unsigned char uint8_t; + typedef signed short int16_t; + typedef unsigned short uint16_t; + typedef signed int int32_t; + typedef unsigned int uint32_t; + typedef signed __int64 int64_t; + typedef unsigned __int64 uint64_t; +#else + #include +#endif + + +//----------------------------------------------------------------------------------- +// ***** Type definitions for Common Systems + +namespace OVR { + +typedef char Char; + +// Pointer-sized integer +typedef size_t UPInt; +typedef ptrdiff_t SPInt; + + +#if defined(OVR_OS_MS) + +typedef char SByte; // 8 bit Integer (Byte) +typedef unsigned char UByte; +typedef short SInt16; // 16 bit Integer (Word) +typedef unsigned short UInt16; +typedef long SInt32; // 32 bit Integer +typedef unsigned long UInt32; +typedef __int64 SInt64; // 64 bit Integer (QWord) +typedef unsigned __int64 UInt64; + + +#elif defined(OVR_OS_MAC) || defined(OVR_OS_IPHONE) || defined(OVR_CC_GNU) + +typedef int SByte __attribute__((__mode__ (__QI__))); +typedef unsigned int UByte __attribute__((__mode__ (__QI__))); +typedef int SInt16 __attribute__((__mode__ (__HI__))); +typedef unsigned int UInt16 __attribute__((__mode__ (__HI__))); +typedef int SInt32 __attribute__((__mode__ (__SI__))); +typedef unsigned int UInt32 __attribute__((__mode__ (__SI__))); +typedef int SInt64 __attribute__((__mode__ (__DI__))); +typedef unsigned int UInt64 __attribute__((__mode__ (__DI__))); + +#else + +#include +typedef int8_t SByte; +typedef uint8_t UByte; +typedef int16_t SInt16; +typedef uint16_t UInt16; +typedef int32_t SInt32; +typedef uint32_t UInt32; +typedef int64_t SInt64; +typedef uint64_t UInt64; + +#endif + + +//osx PID is a signed int32 (already defined to pid_t in OSX framework) +//linux PID is a signed int32 (already defined) +//win32 PID is an unsigned int64 +#ifdef OVR_OS_WIN32 +//process ID representation +typedef unsigned long pid_t; +#endif + +struct OVR_GUID +{ + uint32_t Data1; + uint16_t Data2; + uint16_t Data3; + uint8_t Data4[8]; +}; + + + +} // OVR + + + +//----------------------------------------------------------------------------------- +// ****** Standard C/C++ Library +// +// Identifies which standard library is currently being used. +// +// LIBSTDCPP - GNU libstdc++, used by GCC. +// LIBCPP - LLVM libc++, typically used by clang and GCC. +// DINKUMWARE - Used by Microsoft and various non-Microsoft compilers (e.g. Sony clang). + +#if !defined(OVR_STDLIB_LIBSTDCPP) + #if defined(__GLIBCXX__) + #define OVR_STDLIB_LIBSTDCPP 1 + #endif +#endif + +#if !defined(OVR_STDLIB_LIBCPP) + #if defined(__clang__) + #if defined(__cplusplus) && __has_include(<__config>) + #define OVR_STDLIB_LIBCPP 1 + #endif + #endif +#endif + +#if !defined(OVR_STDLIB_DINKUMWARE) + #if defined(_YVALS) // Dinkumware globally #defines _YVALS from the #includes above. + #define OVR_STDLIB_DINKUMWARE 1 + #endif +#endif + + +//----------------------------------------------------------------------------------- +// ***** Macro Definitions +// +// We define the following: +// +// OVR_BYTE_ORDER - Defined to either OVR_LITTLE_ENDIAN or OVR_BIG_ENDIAN +// OVR_FORCE_INLINE - Forces inline expansion of function +// OVR_ASM - Assembly language prefix +// OVR_STR - Prefixes string with L"" if building unicode +// +// OVR_STDCALL - Use stdcall calling convention (Pascal arg order) +// OVR_CDECL - Use cdecl calling convention (C argument order) +// OVR_FASTCALL - Use fastcall calling convention (registers) +// + +// Byte order constants, OVR_BYTE_ORDER is defined to be one of these. +#define OVR_LITTLE_ENDIAN 1 +#define OVR_BIG_ENDIAN 2 + + +#if defined(OVR_OS_MS) + + // ***** Windows and non-desktop platforms + + // Byte order + #define OVR_BYTE_ORDER OVR_LITTLE_ENDIAN + + // Calling convention - goes after function return type but before function name + #ifdef __cplusplus_cli + # define OVR_FASTCALL __stdcall + #else + # define OVR_FASTCALL __fastcall + #endif + + #define OVR_STDCALL __stdcall + #define OVR_CDECL __cdecl + + + // Assembly macros + #if defined(OVR_CC_MSVC) + # define OVR_ASM _asm + #else + # define OVR_ASM asm + #endif // (OVR_CC_MSVC) + + #ifdef UNICODE + # define OVR_STR(str) L##str + #else + # define OVR_STR(str) str + #endif // UNICODE + +#else + + // **** Standard systems + + #if (defined(BYTE_ORDER) && (BYTE_ORDER == BIG_ENDIAN))|| \ + (defined(_BYTE_ORDER) && (_BYTE_ORDER == _BIG_ENDIAN)) + # define OVR_BYTE_ORDER OVR_BIG_ENDIAN + #elif (defined(__ARMEB__) || defined(OVR_CPU_PPC) || defined(OVR_CPU_PPC64)) + # define OVR_BYTE_ORDER OVR_BIG_ENDIAN + #else + # define OVR_BYTE_ORDER OVR_LITTLE_ENDIAN + #endif + + // Assembly macros + #define OVR_ASM __asm__ + #define OVR_ASM_PROC(procname) OVR_ASM + #define OVR_ASM_END OVR_ASM + + // Calling convention - goes after function return type but before function name + #define OVR_FASTCALL + #define OVR_STDCALL + #define OVR_CDECL + +#endif // defined(OVR_OS_WIN32) + + +//----------------------------------------------------------------------------------- +// ***** OVR_PTR_SIZE +// +// Specifies the byte size of pointers (same as sizeof void*). + +#if !defined(OVR_PTR_SIZE) + #if defined(__WORDSIZE) + #define OVR_PTR_SIZE ((__WORDSIZE) / 8) + #elif defined(_WIN64) || defined(__LP64__) || defined(_LP64) || defined(_M_IA64) || defined(__ia64__) || defined(__arch64__) || defined(__64BIT__) || defined(__Ptr_Is_64) + #define OVR_PTR_SIZE 8 + #elif defined(__CC_ARM) && (__sizeof_ptr == 8) + #define OVR_PTR_SIZE 8 + #else + #define OVR_PTR_SIZE 4 + #endif +#endif + + +//----------------------------------------------------------------------------------- +// ***** OVR_WORD_SIZE +// +// Specifies the byte size of a machine word/register. Not necessarily the same as +// the size of pointers, but usually >= the size of pointers. + +#if !defined(OVR_WORD_SIZE) + #define OVR_WORD_SIZE OVR_PTR_SIZE // For our currently supported platforms these are equal. +#endif + + +// ------------------------------------------------------------------------ +// ***** OVR_FORCE_INLINE +// +// Force inline substitute - goes before function declaration +// Example usage: +// OVR_FORCE_INLINE void Test(); + +#if !defined(OVR_FORCE_INLINE) + #if defined(OVR_CC_MSVC) + #define OVR_FORCE_INLINE __forceinline + #elif defined(OVR_CC_GNU) + #define OVR_FORCE_INLINE __attribute__((always_inline)) inline + #else + #define OVR_FORCE_INLINE inline + #endif // OVR_CC_MSVC +#endif + + +// ------------------------------------------------------------------------ +// ***** OVR_NO_INLINE +// +// Cannot be used with inline or OVR_FORCE_INLINE. +// Example usage: +// OVR_NO_INLINE void Test(); + +#if !defined(OVR_NO_INLINE) + #if defined(OVR_CC_MSVC) && (_MSC_VER >= 1500) // VS2008+ + #define OVR_NO_INLINE __declspec(noinline) + #elif !defined(OVR_CC_MSVC) + #define OVR_NO_INLINE __attribute__((noinline)) + #endif +#endif + + +// ----------------------------------------------------------------------------------- +// ***** OVR_STRINGIZE +// +// Converts a preprocessor symbol to a string. +// +// Example usage: +// printf("Line: %s", OVR_STRINGIZE(__LINE__)); +// +#if !defined(OVR_STRINGIFY) + #define OVR_STRINGIZEIMPL(x) #x + #define OVR_STRINGIZE(x) OVR_STRINGIZEIMPL(x) +#endif + + +// ----------------------------------------------------------------------------------- +// ***** OVR_JOIN +// +// Joins two preprocessing symbols together. Supports the case when either or the +// the symbols are macros themselves. +// +// Example usage: +// char OVR_JOIN(unique_, __LINE__); // Results in (e.g.) char unique_123; +// +#if !defined(OVR_JOIN) + #define OVR_JOIN(a, b) OVR_JOIN1(a, b) + #define OVR_JOIN1(a, b) OVR_JOIN2(a, b) + #define OVR_JOIN2(a, b) a##b +#endif + + +//----------------------------------------------------------------------------------- +// ***** OVR_OFFSETOF +// +// Portable implementation of offsetof for structs and classes. offsetof and GCC's +// __builtin_offsetof work only with POD types (standard-layout types under C++11), +// despite that it can safely work with a number of types that aren't POD. This +// version works with more types without generating compiler warnings or errors. +// Returns the offset as a size_t, as per offsetof. +// +// Example usage: +// struct Test{ int i; float f; }; +// size_t fPos = OVR_OFFSETOF(Test, f); + +#if defined(OVR_CC_GNU) + #define OVR_OFFSETOF(class_, member_) ((size_t)(((uintptr_t)&reinterpret_cast((((class_*)65536)->member_))) - 65536)) +#else + #define OVR_OFFSETOF(class_, member_) offsetof(class_, member_) +#endif + + +//----------------------------------------------------------------------------------- +// ***** OVR_SIZEOF_MEMBER +// +// Implements a portable way to determine the size of struct or class data member. +// C++11 allows this directly via sizeof (see OVR_CPP_NO_EXTENDED_SIZEOF), and this +// macro exists to handle pre-C++11 compilers. +// Returns the offset as a size_t, as per sizeof. +// +// Example usage: +// struct Test{ int i; float f; }; +// size_t fSize = OVR_SIZEOF_MEMBER(Test, f); +// +#if defined(OVR_CPP_NO_EXTENDED_SIZEOF) + #define OVR_SIZEOF_MEMBER(class_, member_) (sizeof(((class_*)0)->member_)) +#else + #define OVR_SIZEOF_MEMBER(class_, member_) (sizeof(class_::member_)) +#endif + + +//----------------------------------------------------------------------------------- +// ***** OVR_DEBUG_BREAK, OVR_DEBUG_CODE, +// OVR_ASSERT, OVR_ASSERT_M, OVR_ASSERT_AND_UNUSED +// +// Macros have effect only in debug builds. +// +// Example OVR_DEBUG_BREAK usage (note the lack of parentheses): +// #define MY_ASSERT(expression) do { if (!(expression)) { OVR_DEBUG_BREAK; } } while(0) +// +// Example OVR_DEBUG_CODE usage: +// OVR_DEBUG_CODE(printf("debug test\n");) +// or +// OVR_DEBUG_CODE(printf("debug test\n")); +// +// Example OVR_ASSERT usage: +// OVR_ASSERT(count < 100); +// OVR_ASSERT_M(count < 100, "count is too high"); +// +#if defined(OVR_BUILD_DEBUG) + // Causes a debugger breakpoint in debug builds. Has no effect in release builds. + // Microsoft Win32 specific debugging support + #if defined(OVR_CC_MSVC) + #define OVR_DEBUG_BREAK __debugbreak() + #elif defined(OVR_CC_GNU) || defined(OVR_CC_CLANG) + #if defined(OVR_CPU_X86) || defined(OVR_CPU_X86_64) + #define OVR_DEBUG_BREAK do { OVR_ASM("int $3\n\t"); } while(0) + #else + #define OVR_DEBUG_BREAK __builtin_trap() + #endif + #else + #define OVR_DEBUG_BREAK do { *((int *) 0) = 1; } while(0) + #endif + + // The expresssion is defined only in debug builds. It is defined away in release builds. + #define OVR_DEBUG_CODE(c) c + + // In debug builds this tests the given expression; if false then executes OVR_DEBUG_BREAK, + // if true then no action. Has no effect in release builds. + #if defined(__clang_analyzer__) // During static analysis, make it so the analyzer thinks that failed asserts result in program exit. Reduced false positives. + #include + #define OVR_ASSERT_M(p, message) do { if (!(p)) { OVR_DEBUG_BREAK; exit(0); } } while(0) + #define OVR_ASSERT(p) do { if (!(p)) { OVR_DEBUG_BREAK; exit(0); } } while(0) + #else + // void OVR_ASSERT_M(bool expression, const char message); + // Note: The expresion below is expanded into all usage of this assertion macro. + // We should try to minimize the size of the expanded code to the extent possible. + #define OVR_ASSERT_M(p, message) do \ + { \ + if (!(p)) \ + { \ + intptr_t ovrAssertUserParam; \ + OVRAssertionHandler ovrAssertUserHandler = OVR::GetAssertionHandler(&ovrAssertUserParam); \ + \ + if(ovrAssertUserHandler && !OVRIsDebuggerPresent()) \ + { \ + ovrAssertUserHandler(ovrAssertUserParam, "Assertion failure", message); \ + } \ + else \ + { \ + OVR_DEBUG_BREAK; \ + } \ + } \ + } while(0) + + // void OVR_ASSERT(bool expression); + #define OVR_ASSERT(p) OVR_ASSERT_M((p), (#p)) + #endif + + // Acts the same as OVR_ASSERT in debug builds. Acts the same as OVR_UNUSED in release builds. + // Example usage: OVR_ASSERT_AND_UNUSED(x < 30, x); + #define OVR_ASSERT_AND_UNUSED(expression, value) OVR_ASSERT(expression); OVR_UNUSED(value) + +#else + + // The expresssion is defined only in debug builds. It is defined away in release builds. + #define OVR_DEBUG_CODE(c) + + // Causes a debugger breakpoint in debug builds. Has no effect in release builds. + #define OVR_DEBUG_BREAK ((void)0) + + // In debug builds this tests the given expression; if false then executes OVR_DEBUG_BREAK, + // if true then no action. Has no effect in release builds. + #define OVR_ASSERT(p) ((void)0) + #define OVR_ASSERT_M(p, m) ((void)0) + + // Acts the same as OVR_ASSERT in debug builds. Acts the same as OVR_UNUSED in release builds. + // Example usage: OVR_ASSERT_AND_UNUSED(x < 30, x); + #define OVR_ASSERT_AND_UNUSED(expression, value) OVR_UNUSED(value) + +#endif // OVR_BUILD_DEBUG + + + +// Assert handler +// The user of this library can override the default assertion handler and provide their own. +namespace OVR +{ + // The return value meaning is reserved for future definition and currently has no effect. + typedef intptr_t (*OVRAssertionHandler)(intptr_t userParameter, const char* title, const char* message); + + // Returns the current assertion handler. + OVRAssertionHandler GetAssertionHandler(intptr_t* userParameter = NULL); + + // Sets the current assertion handler. + // The default assertion handler if none is set simply issues a debug break. + // Example usage: + // intptr_t CustomAssertionHandler(intptr_t /*userParameter*/, const char* title, const char* message)) { + // MessageBox(title, message); + // OVR_DEBUG_BREAK; + // } + void SetAssertionHandler(OVRAssertionHandler assertionHandler, intptr_t userParameter = 0); + + // Implements the default assertion handler. + intptr_t DefaultAssertionHandler(intptr_t userParameter, const char* title, const char* message); + + // Currently defined in OVR_DebugHelp.cpp + bool OVRIsDebuggerPresent(); +} + + +// ------------------------------------------------------------------------ +// ***** static_assert +// +// Portable support for C++11 static_assert. +// Acts as if the following were declared: +// void static_assert(bool const_expression, const char* msg); +// +// Example usage: +// static_assert(sizeof(int32_t) == 4, "int32_t expected to be 4 bytes."); + +#if defined(OVR_CPP_NO_STATIC_ASSERT) // If the compiler doesn't provide it intrinsically... + #if !defined(OVR_SA_UNUSED) + #if defined(OVR_CC_GNU) || defined(OVR_CC_CLANG) + #define OVR_SA_UNUSED __attribute__((unused)) + #else + #define OVR_SA_UNUSED + #endif + #define OVR_SA_PASTE(a,b) a##b + #define OVR_SA_HELP(a,b) OVR_SA_PASTE(a,b) + #endif + + #if defined(__COUNTER__) + #define static_assert(expression, msg) typedef char OVR_SA_HELP(compileTimeAssert, __COUNTER__) [((expression) != 0) ? 1 : -1] OVR_SA_UNUSED + #else + #define static_assert(expression, msg) typedef char OVR_SA_HELP(compileTimeAssert, __LINE__) [((expression) != 0) ? 1 : -1] OVR_SA_UNUSED + #endif +#endif + + +// ------------------------------------------------------------------------ +// ***** OVR_COMPILER_ASSERT +// +// Compile-time assert; produces compiler error if condition is false. +// The expression must be a compile-time constant expression. +// This macro is deprecated in favor of static_assert, which provides better +// compiler output and works in a broader range of contexts. +// +// Example usage: +// OVR_COMPILER_ASSERT(sizeof(int32_t == 4)); + +#if !defined(OVR_COMPILER_ASSERT) + #define OVR_COMPILER_ASSERT(expression) static_assert(expression, #expression) + #define OVR_COMPILER_ASSERT_M(expression, msg) static_assert(expression, msg) +#endif + + +// ***** OVR_PROCESSOR_PAUSE +// +// Yields the processor for other hyperthreads, usually for the purpose of implementing spins and spin locks. +// +// Example usage: +// while(!finished()) +// OVR_PROCESSOR_PAUSE(); + +#if defined(OVR_CPU_X86) || defined(OVR_CPU_X86_64) + #if defined(OVR_CC_GNU) || defined(OVR_CC_CLANG) + #define OVR_PROCESSOR_PAUSE() asm volatile("pause" ::: "memory") // Consumes 38-40 clocks on current Intel x86 and x64 hardware. + #elif defined(OVR_CC_MSVC) + #include + #pragma intrinsic(_mm_pause) // Maps to asm pause. + #define OVR_PROCESSOR_PAUSE _mm_pause + #else + #define OVR_PROCESSOR_PAUSE() + #endif +#else + #define OVR_PROCESSOR_PAUSE() +#endif + + +// ------------------------------------------------------------------------ +// ***** OVR_ARRAY_COUNT +// +// Returns the element count of a C array. +// +// Example usage: +// float itemArray[16]; +// for(size_t i = 0; i < OVR_ARRAY_COUNT(itemArray); i++) { ... } + +#if defined(OVR_CPP_NO_CONSTEXPR) + #ifndef OVR_ARRAY_COUNT + #define OVR_ARRAY_COUNT(x) (sizeof(x) / sizeof(x[0])) + #endif +#else + // Smarter C++11 version which knows the difference between arrays and pointers. + template + char (&OVRArrayCountHelper(T (&x)[N]))[N]; + #define OVR_ARRAY_COUNT(x) (sizeof(OVRArrayCountHelper(x))) +#endif + + +// ------------------------------------------------------------------------ +// ***** OVR_CURRENT_FUNCTION +// +// Portable wrapper for __PRETTY_FUNCTION__, C99 __func__, __FUNCTION__. +// This represents the most expressive version available. +// Acts as if the following were declared: +// static const char OVR_CURRENT_FUNCTION[] = "function-name"; +// +// Example usage: +// void Test() { printf("%s", OVR_CURRENT_FUNCTION); } + +#if defined(OVR_CC_GNU) || defined(OVR_CC_CLANG) || (defined(__ICC) && (__ICC >= 600)) // GCC, clang, Intel + #define OVR_CURRENT_FUNCTION __PRETTY_FUNCTION__ +#elif defined(__FUNCSIG__) // VC++ + #define OVR_CURRENT_FUNCTION __FUNCSIG__ +#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901) // C99 compilers + #define OVR_CURRENT_FUNCTION __func__ +#else + #define OVR_CURRENT_FUNCTION __FUNCTION__ +#endif + + +//----------------------------------------------------------------------------------- +// ***** OVR_DEPRECATED / OVR_DEPRECATED_MSG +// +// Portably annotates a function or struct as deprecated. +// Note that clang supports __deprecated_enum_msg, which may be useful to support. +// +// Example usage: +// OVR_DEPRECATED void Test(); // Use on the function declaration, as opposed to definition. +// +// struct OVR_DEPRECATED Test{ ... }; +// +// OVR_DEPRECATED_MSG("Test is deprecated") +// void Test(); + +#if !defined(OVR_DEPRECATED) + #if defined(OVR_CC_MSVC) && (OVR_CC_VERSION > 1400) // VS2005+ + #define OVR_DEPRECATED __declspec(deprecated) + #define OVR_DEPRECATED_MSG(msg) __declspec(deprecated(msg)) + #elif defined(OVR_CC_CLANG) && OVR_CC_HAS_FEATURE(attribute_deprecated_with_message) + #define OVR_DEPRECATED __declspec(deprecated) + #define OVR_DEPRECATED_MSG(msg) __attribute__((deprecated(msg))) + #elif defined(OVR_CC_GNU) && (OVR_CC_VERSION >= 405) + #define OVR_DEPRECATED __declspec(deprecated) + #define OVR_DEPRECATED_MSG(msg) __attribute__((deprecated(msg))) + #elif !defined(OVR_CC_MSVC) + #define OVR_DEPRECATED __attribute__((deprecated)) + #define OVR_DEPRECATED_MSG(msg) __attribute__((deprecated)) + #else + #define OVR_DEPRECATED + #define OVR_DEPRECATED_MSG(msg) + #endif +#endif + + +//----------------------------------------------------------------------------------- +// ***** OVR_UNUSED - Unused Argument handling +// Macro to quiet compiler warnings about unused parameters/variables. +// +// Example usage: +// void Test() { +// int x = SomeFunction(); +// OVR_UNUSED(x); +// } +// + +#if defined(OVR_CC_GNU) +# define OVR_UNUSED(a) do {__typeof__ (&a) __attribute__ ((unused)) __tmp = &a; } while(0) +#else +# define OVR_UNUSED(a) (a) +#endif + +#define OVR_UNUSED1(a1) OVR_UNUSED(a1) +#define OVR_UNUSED2(a1,a2) OVR_UNUSED(a1); OVR_UNUSED(a2) +#define OVR_UNUSED3(a1,a2,a3) OVR_UNUSED2(a1,a2); OVR_UNUSED(a3) +#define OVR_UNUSED4(a1,a2,a3,a4) OVR_UNUSED3(a1,a2,a3); OVR_UNUSED(a4) +#define OVR_UNUSED5(a1,a2,a3,a4,a5) OVR_UNUSED4(a1,a2,a3,a4); OVR_UNUSED(a5) +#define OVR_UNUSED6(a1,a2,a3,a4,a5,a6) OVR_UNUSED4(a1,a2,a3,a4); OVR_UNUSED2(a5,a6) +#define OVR_UNUSED7(a1,a2,a3,a4,a5,a6,a7) OVR_UNUSED4(a1,a2,a3,a4); OVR_UNUSED3(a5,a6,a7) +#define OVR_UNUSED8(a1,a2,a3,a4,a5,a6,a7,a8) OVR_UNUSED4(a1,a2,a3,a4); OVR_UNUSED4(a5,a6,a7,a8) +#define OVR_UNUSED9(a1,a2,a3,a4,a5,a6,a7,a8,a9) OVR_UNUSED4(a1,a2,a3,a4); OVR_UNUSED5(a5,a6,a7,a8,a9) + + +//----------------------------------------------------------------------------------- +// ***** Configuration Macros +// +// Expands to the current build type as a const char string literal. +// Acts as the following declaration: const char OVR_BUILD_STRING[]; + +#ifdef OVR_BUILD_DEBUG +# define OVR_BUILD_STRING "Debug" +#else +# define OVR_BUILD_STRING "Release" +#endif + + +//// Enables SF Debugging information +//# define OVR_BUILD_DEBUG + +// OVR_DEBUG_STATEMENT injects a statement only in debug builds. +// OVR_DEBUG_SELECT injects first argument in debug builds, second argument otherwise. +#ifdef OVR_BUILD_DEBUG +#define OVR_DEBUG_STATEMENT(s) s +#define OVR_DEBUG_SELECT(d, nd) d +#else +#define OVR_DEBUG_STATEMENT(s) +#define OVR_DEBUG_SELECT(d, nd) nd +#endif + + +#define OVR_ENABLE_THREADS +// +// Prevents OVR from defining new within +// type macros, so developers can override +// new using the #define new new(...) trick +// - used with OVR_DEFINE_NEW macro +//# define OVR_BUILD_DEFINE_NEW +// + + +//----------------------------------------------------------------------------------- +// ***** Find normal allocations +// +// Our allocations are all supposed to go through the OVR System Allocator, so that +// they can be run through a game's own preferred allocator. Occasionally we will +// accidentally introduce new code that doesn't adhere to this contract. And it +// then becomes difficult to track down these normal allocations. This piece of +// code makes it easy to check for normal allocations by asserting whenever they +// happen in our code. + +//#define OVR_FIND_NORMAL_ALLOCATIONS +#ifdef OVR_FIND_NORMAL_ALLOCATIONS + +inline void* operator new (size_t size, const char* filename, int line) +{ + void* ptr = new char[size]; + OVR_ASSERT(false); + return ptr; +} + +#define new new(__FILE__, __LINE__) + +#endif // OVR_FIND_NORMAL_ALLOCATIONS + + +#include "OVR_Nullptr.h" + + + + +#endif // OVR_Types_h diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Kernel/OVR_UTF8Util.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Kernel/OVR_UTF8Util.cpp Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,556 @@ +/************************************************************************** + +Filename : OVR_UTF8Util.cpp +Content : UTF8 Unicode character encoding/decoding support +Created : September 19, 2012 +Notes : +Notes : Much useful info at "UTF-8 and Unicode FAQ" + http://www.cl.cam.ac.uk/~mgk25/unicode.html + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#include "OVR_UTF8Util.h" + +namespace OVR { namespace UTF8Util { + +intptr_t OVR_STDCALL GetLength(const char* buf, intptr_t buflen) +{ + const char* p = buf; + intptr_t length = 0; + + if (buflen != -1) + { + while (p - buf < buflen) + { + // We should be able to have ASStrings with 0 in the middle. + UTF8Util::DecodeNextChar_Advance0(&p); + length++; + } + } + else + { + while (UTF8Util::DecodeNextChar_Advance0(&p)) + length++; + } + + return length; +} + +uint32_t OVR_STDCALL GetCharAt(intptr_t index, const char* putf8str, intptr_t length) +{ + const char* buf = putf8str; + uint32_t c = 0; + + if (length != -1) + { + while (buf - putf8str < length) + { + c = UTF8Util::DecodeNextChar_Advance0(&buf); + if (index == 0) + return c; + index--; + } + + return c; + } + + do + { + c = UTF8Util::DecodeNextChar_Advance0(&buf); + index--; + + if (c == 0) + { + // We've hit the end of the string; don't go further. + OVR_ASSERT(index == 0); + return c; + } + } while (index >= 0); + + return c; +} + +intptr_t OVR_STDCALL GetByteIndex(intptr_t index, const char *putf8str, intptr_t length) +{ + const char* buf = putf8str; + + if (length != -1) + { + while ((buf - putf8str) < length && index > 0) + { + UTF8Util::DecodeNextChar_Advance0(&buf); + index--; + } + + return buf-putf8str; + } + + while (index > 0) + { + uint32_t c = UTF8Util::DecodeNextChar_Advance0(&buf); + index--; + + if (c == 0) + return buf-putf8str; + }; + + return buf-putf8str; +} + +int OVR_STDCALL GetEncodeCharSize(uint32_t ucs_character) +{ + if (ucs_character <= 0x7F) + return 1; + else if (ucs_character <= 0x7FF) + return 2; + else if (ucs_character <= 0xFFFF) + return 3; + else if (ucs_character <= 0x1FFFFF) + return 4; + else if (ucs_character <= 0x3FFFFFF) + return 5; + else if (ucs_character <= 0x7FFFFFFF) + return 6; + else + return 0; +} + +uint32_t OVR_STDCALL DecodeNextChar_Advance0(const char** putf8Buffer) +{ + uint32_t uc; + char c; + + // Security considerations: + // + // Changed, this is now only the case for DecodeNextChar: + // - If we hit a zero byte, we want to return 0 without stepping + // the buffer pointer past the 0. th + // + // If we hit an "overlong sequence"; i.e. a character encoded + // in a longer multibyte string than is necessary, then we + // need to discard the character. This is so attackers can't + // disguise dangerous characters or character sequences -- + // there is only one valid encoding for each character. + // + // If we decode characters { 0xD800 .. 0xDFFF } or { 0xFFFE, + // 0xFFFF } then we ignore them; they are not valid in UTF-8. + + // This isn't actually an invalid character; it's a valid char that + // looks like an inverted question mark. +#define INVALID_CHAR 0x0FFFD + +#define FIRST_BYTE(mask, shift) \ + uc = (c & (mask)) << (shift); + +#define NEXT_BYTE(shift) \ + c = **putf8Buffer; \ + if (c == 0) return 0; /* end of buffer, do not advance */ \ + if ((c & 0xC0) != 0x80) return INVALID_CHAR; /* standard check */ \ + (*putf8Buffer)++; \ + uc |= (c & 0x3F) << shift; + + c = **putf8Buffer; + (*putf8Buffer)++; + if (c == 0) + return 0; // End of buffer. + + if ((c & 0x80) == 0) return (uint32_t) c; // Conventional 7-bit ASCII. + + // Multi-byte sequences. + if ((c & 0xE0) == 0xC0) + { + // Two-byte sequence. + FIRST_BYTE(0x1F, 6); + NEXT_BYTE(0); + if (uc < 0x80) return INVALID_CHAR; // overlong + return uc; + } + else if ((c & 0xF0) == 0xE0) + { + // Three-byte sequence. + FIRST_BYTE(0x0F, 12); + NEXT_BYTE(6); + NEXT_BYTE(0); + if (uc < 0x800) return INVALID_CHAR; // overlong + // Not valid ISO 10646, but Flash requires these to work + // see AS3 test e15_5_3_2_3 for String.fromCharCode().charCodeAt(0) + // if (uc >= 0x0D800 && uc <= 0x0DFFF) return INVALID_CHAR; + // if (uc == 0x0FFFE || uc == 0x0FFFF) return INVALID_CHAR; // not valid ISO 10646 + return uc; + } + else if ((c & 0xF8) == 0xF0) + { + // Four-byte sequence. + FIRST_BYTE(0x07, 18); + NEXT_BYTE(12); + NEXT_BYTE(6); + NEXT_BYTE(0); + if (uc < 0x010000) return INVALID_CHAR; // overlong + return uc; + } + else if ((c & 0xFC) == 0xF8) + { + // Five-byte sequence. + FIRST_BYTE(0x03, 24); + NEXT_BYTE(18); + NEXT_BYTE(12); + NEXT_BYTE(6); + NEXT_BYTE(0); + if (uc < 0x0200000) return INVALID_CHAR; // overlong + return uc; + } + else if ((c & 0xFE) == 0xFC) + { + // Six-byte sequence. + FIRST_BYTE(0x01, 30); + NEXT_BYTE(24); + NEXT_BYTE(18); + NEXT_BYTE(12); + NEXT_BYTE(6); + NEXT_BYTE(0); + if (uc < 0x04000000) return INVALID_CHAR; // overlong + return uc; + } + else + { + // Invalid. + return INVALID_CHAR; + } +} + + +void OVR_STDCALL EncodeChar(char* pbuffer, intptr_t* pindex, uint32_t ucs_character) +{ + if (ucs_character <= 0x7F) + { + // Plain single-byte ASCII. + pbuffer[(*pindex)++] = (char) ucs_character; + } + else if (ucs_character <= 0x7FF) + { + // Two bytes. + pbuffer[(*pindex)++] = 0xC0 | (char)(ucs_character >> 6); + pbuffer[(*pindex)++] = 0x80 | (char)((ucs_character >> 0) & 0x3F); + } + else if (ucs_character <= 0xFFFF) + { + // Three bytes. + pbuffer[(*pindex)++] = 0xE0 | (char)(ucs_character >> 12); + pbuffer[(*pindex)++] = 0x80 | (char)((ucs_character >> 6) & 0x3F); + pbuffer[(*pindex)++] = 0x80 | (char)((ucs_character >> 0) & 0x3F); + } + else if (ucs_character <= 0x1FFFFF) + { + // Four bytes. + pbuffer[(*pindex)++] = 0xF0 | (char)(ucs_character >> 18); + pbuffer[(*pindex)++] = 0x80 | (char)((ucs_character >> 12) & 0x3F); + pbuffer[(*pindex)++] = 0x80 | (char)((ucs_character >> 6) & 0x3F); + pbuffer[(*pindex)++] = 0x80 | (char)((ucs_character >> 0) & 0x3F); + } + else if (ucs_character <= 0x3FFFFFF) + { + // Five bytes. + pbuffer[(*pindex)++] = 0xF8 | (char)(ucs_character >> 24); + pbuffer[(*pindex)++] = 0x80 | (char)((ucs_character >> 18) & 0x3F); + pbuffer[(*pindex)++] = 0x80 | (char)((ucs_character >> 12) & 0x3F); + pbuffer[(*pindex)++] = 0x80 | (char)((ucs_character >> 6) & 0x3F); + pbuffer[(*pindex)++] = 0x80 | (char)((ucs_character >> 0) & 0x3F); + } + else if (ucs_character <= 0x7FFFFFFF) + { + // Six bytes. + pbuffer[(*pindex)++] = 0xFC | (char)(ucs_character >> 30); + pbuffer[(*pindex)++] = 0x80 | (char)((ucs_character >> 24) & 0x3F); + pbuffer[(*pindex)++] = 0x80 | (char)((ucs_character >> 18) & 0x3F); + pbuffer[(*pindex)++] = 0x80 | (char)((ucs_character >> 12) & 0x3F); + pbuffer[(*pindex)++] = 0x80 | (char)((ucs_character >> 6) & 0x3F); + pbuffer[(*pindex)++] = 0x80 | (char)((ucs_character >> 0) & 0x3F); + } + else + { + // Invalid char; don't encode anything. + } +} + +intptr_t OVR_STDCALL GetEncodeStringSize(const wchar_t* pchar, intptr_t length) +{ + intptr_t len = 0; + if (length != -1) + for (int i = 0; i < length; i++) + { + len += GetEncodeCharSize(pchar[i]); + } + else + for (int i = 0;; i++) + { + if (pchar[i] == 0) + return len; + len += GetEncodeCharSize(pchar[i]); + } + return len; +} + +void OVR_STDCALL EncodeString(char *pbuff, const wchar_t* pchar, intptr_t length) +{ + intptr_t ofs = 0; + if (length != -1) + { + for (int i = 0; i < length; i++) + { + EncodeChar(pbuff, &ofs, pchar[i]); + } + } + else + { + for (int i = 0;; i++) + { + if (pchar[i] == 0) + break; + EncodeChar(pbuff, &ofs, pchar[i]); + } + } + pbuff[ofs] = 0; +} + +size_t OVR_STDCALL DecodeString(wchar_t *pbuff, const char* putf8str, intptr_t bytesLen) +{ + wchar_t *pbegin = pbuff; + if (bytesLen == -1) + { + while (1) + { + uint32_t ch = DecodeNextChar_Advance0(&putf8str); + if (ch == 0) + break; + else if (ch >= 0xFFFF) + ch = 0xFFFD; + *pbuff++ = wchar_t(ch); + } + } + else + { + const char* p = putf8str; + while ((p - putf8str) < bytesLen) + { + uint32_t ch = DecodeNextChar_Advance0(&p); + if (ch >= 0xFFFF) + ch = 0xFFFD; + *pbuff++ = wchar_t(ch); + } + } + + *pbuff = 0; + return pbuff - pbegin; +} + + +#ifdef UTF8_UNIT_TEST + +// Compile this test case with something like: +// +// gcc utf8.cpp -g -I.. -DUTF8_UNIT_TEST -lstdc++ -o utf8_test +// +// or +// +// cl utf8.cpp -Zi -Od -DUTF8_UNIT_TEST -I.. +// +// If possible, try running the test program with the first arg +// pointing at the file: +// +// http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt +// +// and examine the results by eye to make sure they are acceptable to +// you. + + +#include "base/utility.h" +#include + + +bool check_equal(const char* utf8_in, const uint32_t* ucs_in) +{ + for (;;) + { + uint32_t next_ucs = *ucs_in++; + uint32_t next_ucs_from_utf8 = utf8::decode_next_unicode_character(&utf8_in); + if (next_ucs != next_ucs_from_utf8) + { + return false; + } + if (next_ucs == 0) + { + OVR_ASSERT(next_ucs_from_utf8 == 0); + break; + } + } + + return true; +} + + +void log_ascii(const char* line) +{ + for (;;) + { + unsigned char c = (unsigned char) *line++; + if (c == 0) + { + // End of line. + return; + } + else if (c != '\n' + && (c < 32 || c > 127)) + { + // Non-printable as plain ASCII. + printf("<0x%02X>", (int) c); + } + else + { + printf("%c", c); + } + } +} + + +void log_ucs(const uint32_t* line) +{ + for (;;) + { + uint32_t uc = *line++; + if (uc == 0) + { + // End of line. + return; + } + else if (uc != '\n' + && (uc < 32 || uc > 127)) + { + // Non-printable as plain ASCII. + printf("", uc); + } + else + { + printf("%c", (char) uc); + } + } +} + + +// Simple canned test. +int main(int argc, const char* argv[]) +{ + { + const char* test8 = "Ignacio Castaño"; + const uint32_t test32[] = + { + 0x49, 0x67, 0x6E, 0x61, 0x63, + 0x69, 0x6F, 0x20, 0x43, 0x61, + 0x73, 0x74, 0x61, 0xF1, 0x6F, + 0x00 + }; + + OVR_ASSERT(check_equal(test8, test32)); + } + + // If user passed an arg, try reading the file as UTF-8 encoded text. + if (argc > 1) + { + const char* filename = argv[1]; + FILE* fp = fopen(filename, "rb"); + if (fp == NULL) + { + printf("Can't open file '%s'\n", filename); + return 1; + } + + // Read lines from the file, encode/decode them, and highlight discrepancies. + const int LINE_SIZE = 200; // max line size + char line_buffer_utf8[LINE_SIZE]; + char reencoded_utf8[6 * LINE_SIZE]; + uint32_t line_buffer_ucs[LINE_SIZE]; + + int byte_counter = 0; + for (;;) + { + int c = fgetc(fp); + if (c == EOF) + { + // Done. + break; + } + line_buffer_utf8[byte_counter++] = c; + if (c == '\n' || byte_counter >= LINE_SIZE - 2) + { + // End of line. Process the line. + line_buffer_utf8[byte_counter++] = 0; // terminate. + + // Decode into UCS. + const char* p = line_buffer_utf8; + uint32_t* q = line_buffer_ucs; + for (;;) + { + uint32_t uc = UTF8Util::DecodeNextChar(&p); + *q++ = uc; + + OVR_ASSERT(q < line_buffer_ucs + LINE_SIZE); + OVR_ASSERT(p < line_buffer_utf8 + LINE_SIZE); + + if (uc == 0) break; + } + + // Encode back into UTF-8. + q = line_buffer_ucs; + int index = 0; + for (;;) + { + uint32_t uc = *q++; + OVR_ASSERT(index < LINE_SIZE * 6 - 6); + int last_index = index; + UTF8Util::EncodeChar(reencoded_utf8, &index, uc); + OVR_ASSERT(index <= last_index + 6); + if (uc == 0) break; + } + + // This can be useful for debugging. +#if 0 + // Show the UCS and the re-encoded UTF-8. + log_ucs(line_buffer_ucs); + log_ascii(reencoded_utf8); +#endif // 0 + + OVR_ASSERT(check_equal(line_buffer_utf8, line_buffer_ucs)); + OVR_ASSERT(check_equal(reencoded_utf8, line_buffer_ucs)); + + // Start next line. + byte_counter = 0; + } + } + + fclose(fp); + } + + return 0; +} + + +#endif // UTF8_UNIT_TEST + +}} // namespace UTF8Util::OVR + diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Kernel/OVR_UTF8Util.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Kernel/OVR_UTF8Util.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,99 @@ +/************************************************************************************ + +PublicHeader: OVR_Kernel.h +Filename : OVR_UTF8Util.h +Content : UTF8 Unicode character encoding/decoding support +Created : September 19, 2012 +Notes : + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#ifndef OVR_UTF8Util_h +#define OVR_UTF8Util_h + +#include "OVR_Types.h" + +namespace OVR { namespace UTF8Util { + +//----------------------------------------------------------------------------------- + +// *** UTF8 string length and indexing. + +// Determines the length of UTF8 string in characters. +// If source length is specified (in bytes), null 0 character is counted properly. +intptr_t OVR_STDCALL GetLength(const char* putf8str, intptr_t length = -1); + +// Gets a decoded UTF8 character at index; you can access up to the index returned +// by GetLength. 0 will be returned for out of bounds access. +uint32_t OVR_STDCALL GetCharAt(intptr_t index, const char* putf8str, intptr_t length = -1); + +// Converts UTF8 character index into byte offset. +// -1 is returned if index was out of bounds. +intptr_t OVR_STDCALL GetByteIndex(intptr_t index, const char* putf8str, intptr_t length = -1); + + +// *** 16-bit Unicode string Encoding/Decoding routines. + +// Determines the number of bytes necessary to encode a string. +// Does not count the terminating 0 (null) character. +intptr_t OVR_STDCALL GetEncodeStringSize(const wchar_t* pchar, intptr_t length = -1); + +// Encodes a unicode (UCS-2 only) string into a buffer. The size of buffer must be at +// least GetEncodeStringSize() + 1. +void OVR_STDCALL EncodeString(char *pbuff, const wchar_t* pchar, intptr_t length = -1); + +// Decode UTF8 into a wchar_t buffer. Must have GetLength()+1 characters available. +// Characters over 0xFFFF are replaced with 0xFFFD. +// Returns the length of resulting string (number of characters) +size_t OVR_STDCALL DecodeString(wchar_t *pbuff, const char* putf8str, intptr_t bytesLen = -1); + + +// *** Individual character Encoding/Decoding. + +// Determined the number of bytes necessary to encode a UCS character. +int OVR_STDCALL GetEncodeCharSize(uint32_t ucsCharacter); + +// Encodes the given UCS character into the given UTF-8 buffer. +// Writes the data starting at buffer[offset], and +// increments offset by the number of bytes written. +// May write up to 6 bytes, so make sure there's room in the buffer +void OVR_STDCALL EncodeChar(char* pbuffer, intptr_t* poffset, uint32_t ucsCharacter); + +// Return the next Unicode character in the UTF-8 encoded buffer. +// Invalid UTF-8 sequences produce a U+FFFD character as output. +// Advances *utf8_buffer past the character returned. Pointer advance +// occurs even if the terminating 0 character is hit, since that allows +// strings with middle '\0' characters to be supported. +uint32_t OVR_STDCALL DecodeNextChar_Advance0(const char** putf8Buffer); + +// Safer version of DecodeNextChar, which doesn't advance pointer if +// null character is hit. +inline uint32_t DecodeNextChar(const char** putf8Buffer) +{ + uint32_t ch = DecodeNextChar_Advance0(putf8Buffer); + if (ch == 0) + (*putf8Buffer)--; + return ch; +} + + +}} // OVR::UTF8Util + +#endif diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Net/OVR_BitStream.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Net/OVR_BitStream.cpp Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,1151 @@ +/************************************************************************************ + +Filename : OVR_BitStream.cpp +Content : A generic serialization toolkit for packing data to a binary stream. +Created : June 10, 2014 +Authors : Kevin Jenkins + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#include "OVR_BitStream.h" + +#ifdef OVR_OS_WIN32 +#include +#else +#include +#endif + +namespace OVR { namespace Net { + + +//----------------------------------------------------------------------------- +// BitStream + +BitStream::BitStream() +{ + numberOfBitsUsed = 0; + //numberOfBitsAllocated = 32 * 8; + numberOfBitsAllocated = BITSTREAM_STACK_ALLOCATION_SIZE * 8; + readOffset = 0; + //data = ( unsigned char* ) OVR_ALLOC( 32); + data = ( unsigned char* ) stackData; + +#ifdef _DEBUG + // OVR_ASSERT( data ); +#endif + //memset(data, 0, 32); + copyData = true; +} + +BitStream::BitStream( const unsigned int initialBytesToAllocate ) +{ + numberOfBitsUsed = 0; + readOffset = 0; + if (initialBytesToAllocate <= BITSTREAM_STACK_ALLOCATION_SIZE) + { + data = ( unsigned char* ) stackData; + numberOfBitsAllocated = BITSTREAM_STACK_ALLOCATION_SIZE * 8; + } + else + { + data = ( unsigned char* ) OVR_ALLOC( (size_t) initialBytesToAllocate); + numberOfBitsAllocated = initialBytesToAllocate << 3; + } +#ifdef _DEBUG + OVR_ASSERT( data ); +#endif + // memset(data, 0, initialBytesToAllocate); + copyData = true; +} + +BitStream::BitStream( char* _data, const unsigned int lengthInBytes, bool _copyData ) +{ + numberOfBitsUsed = lengthInBytes << 3; + readOffset = 0; + copyData = _copyData; + numberOfBitsAllocated = lengthInBytes << 3; + + if ( copyData ) + { + if ( lengthInBytes > 0 ) + { + if (lengthInBytes < BITSTREAM_STACK_ALLOCATION_SIZE) + { + data = ( unsigned char* ) stackData; + numberOfBitsAllocated = BITSTREAM_STACK_ALLOCATION_SIZE << 3; + } + else + { + data = ( unsigned char* ) OVR_ALLOC( (size_t) lengthInBytes); + } +#ifdef _DEBUG + OVR_ASSERT( data ); +#endif + memcpy( data, _data, (size_t) lengthInBytes ); + } + else + data = 0; + } + else + data = ( unsigned char* ) _data; +} + +// Use this if you pass a pointer copy to the constructor (_copyData==false) and want to overallocate to prevent reallocation +void BitStream::SetNumberOfBitsAllocated( const BitSize_t lengthInBits ) +{ +#ifdef _DEBUG + OVR_ASSERT( lengthInBits >= ( BitSize_t ) numberOfBitsAllocated ); +#endif + numberOfBitsAllocated = lengthInBits; +} + +BitStream::~BitStream() +{ + if ( copyData && numberOfBitsAllocated > (BITSTREAM_STACK_ALLOCATION_SIZE << 3)) + OVR_FREE( data ); // Use realloc and free so we are more efficient than delete and new for resizing +} + +void BitStream::Reset( void ) +{ + // Note: Do NOT reallocate memory because BitStream is used + // in places to serialize/deserialize a buffer. Reallocation + // is a dangerous operation (may result in leaks). + + if ( numberOfBitsUsed > 0 ) + { + // memset(data, 0, BITS_TO_BYTES(numberOfBitsUsed)); + } + + // Don't free memory here for speed efficiency + //free(data); // Use realloc and free so we are more efficient than delete and new for resizing + numberOfBitsUsed = 0; + + //numberOfBitsAllocated=8; + readOffset = 0; + + //data=(unsigned char*)OVR_ALLOC(1, _FILE_AND_LINE_); + // if (numberOfBitsAllocated>0) + // memset(data, 0, BITS_TO_BYTES(numberOfBitsAllocated)); +} + +// Write an array or casted stream +void BitStream::Write( const char* inputByteArray, const unsigned int numberOfBytes ) +{ + if (numberOfBytes==0) + return; + + // Optimization: + if ((numberOfBitsUsed & 7) == 0) + { + AddBitsAndReallocate( BYTES_TO_BITS(numberOfBytes) ); + memcpy(data+BITS_TO_BYTES(numberOfBitsUsed), inputByteArray, (size_t) numberOfBytes); + numberOfBitsUsed+=BYTES_TO_BITS(numberOfBytes); + } + else + { + WriteBits( ( unsigned char* ) inputByteArray, numberOfBytes * 8, true ); + } + +} +void BitStream::Write( BitStream *bitStream) +{ + Write(bitStream, bitStream->GetNumberOfBitsUsed()-bitStream->GetReadOffset()); +} +void BitStream::Write( BitStream *bitStream, BitSize_t numberOfBits ) +{ + AddBitsAndReallocate( numberOfBits ); + BitSize_t numberOfBitsMod8; + + if ((bitStream->GetReadOffset()&7)==0 && (numberOfBitsUsed&7)==0) + { + int readOffsetBytes=bitStream->GetReadOffset()/8; + int numBytes=numberOfBits/8; + memcpy(data + (numberOfBitsUsed >> 3), bitStream->GetData()+readOffsetBytes, numBytes); + numberOfBits-=BYTES_TO_BITS(numBytes); + bitStream->SetReadOffset(BYTES_TO_BITS(numBytes+readOffsetBytes)); + numberOfBitsUsed+=BYTES_TO_BITS(numBytes); + } + + while (numberOfBits-->0 && bitStream->readOffset + 1 <= bitStream->numberOfBitsUsed) + { + numberOfBitsMod8 = numberOfBitsUsed & 7; + if ( numberOfBitsMod8 == 0 ) + { + // New byte + if (bitStream->data[ bitStream->readOffset >> 3 ] & ( 0x80 >> ( bitStream->readOffset & 7 ) ) ) + { + // Write 1 + data[ numberOfBitsUsed >> 3 ] = 0x80; + } + else + { + // Write 0 + data[ numberOfBitsUsed >> 3 ] = 0; + } + + } + else + { + // Existing byte + if (bitStream->data[ bitStream->readOffset >> 3 ] & ( 0x80 >> ( bitStream->readOffset & 7 ) ) ) + data[ numberOfBitsUsed >> 3 ] |= 0x80 >> ( numberOfBitsMod8 ); // Set the bit to 1 + // else 0, do nothing + } + + bitStream->readOffset++; + numberOfBitsUsed++; + } +} +void BitStream::Write( BitStream &bitStream, BitSize_t numberOfBits ) +{ + Write(&bitStream, numberOfBits); +} +void BitStream::Write( BitStream &bitStream ) +{ + Write(&bitStream); +} +bool BitStream::Read( BitStream *bitStream, BitSize_t numberOfBits ) +{ + if (GetNumberOfUnreadBits() < numberOfBits) + return false; + bitStream->Write(this, numberOfBits); + return true; +} +bool BitStream::Read( BitStream *bitStream ) +{ + bitStream->Write(this); + return true; +} +bool BitStream::Read( BitStream &bitStream, BitSize_t numberOfBits ) +{ + if (GetNumberOfUnreadBits() < numberOfBits) + return false; + bitStream.Write(this, numberOfBits); + return true; +} +bool BitStream::Read( BitStream &bitStream ) +{ + bitStream.Write(this); + return true; +} + +// Read an array or casted stream +bool BitStream::Read( char* outByteArray, const unsigned int numberOfBytes ) +{ + // Optimization: + if ((readOffset & 7) == 0) + { + if ( readOffset + ( numberOfBytes << 3 ) > numberOfBitsUsed ) + return false; + + // Write the data + memcpy( outByteArray, data + ( readOffset >> 3 ), (size_t) numberOfBytes ); + + readOffset += numberOfBytes << 3; + return true; + } + else + { + return ReadBits( ( unsigned char* ) outByteArray, numberOfBytes * 8 ); + } +} + +// Sets the read pointer back to the beginning of your data. +void BitStream::ResetReadPointer( void ) +{ + readOffset = 0; +} + +// Sets the write pointer back to the beginning of your data. +void BitStream::ResetWritePointer( void ) +{ + numberOfBitsUsed = 0; +} + +// Write a 0 +void BitStream::Write0( void ) +{ + AddBitsAndReallocate( 1 ); + + // New bytes need to be zeroed + if ( ( numberOfBitsUsed & 7 ) == 0 ) + data[ numberOfBitsUsed >> 3 ] = 0; + + numberOfBitsUsed++; +} + +// Write a 1 +void BitStream::Write1( void ) +{ + AddBitsAndReallocate( 1 ); + + BitSize_t numberOfBitsMod8 = numberOfBitsUsed & 7; + + if ( numberOfBitsMod8 == 0 ) + data[ numberOfBitsUsed >> 3 ] = 0x80; + else + data[ numberOfBitsUsed >> 3 ] |= 0x80 >> ( numberOfBitsMod8 ); // Set the bit to 1 + + numberOfBitsUsed++; +} + +// Returns true if the next data read is a 1, false if it is a 0 +bool BitStream::ReadBit( void ) +{ + bool result = ( data[ readOffset >> 3 ] & ( 0x80 >> ( readOffset & 7 ) ) ) !=0; + readOffset++; + return result; +} + +// Align the bitstream to the byte boundary and then write the specified number of bits. +// This is faster than WriteBits but wastes the bits to do the alignment and requires you to call +// SetReadToByteAlignment at the corresponding read position +void BitStream::WriteAlignedBytes( const unsigned char* inByteArray, const unsigned int numberOfBytesToWrite ) +{ + AlignWriteToByteBoundary(); + Write((const char*) inByteArray, numberOfBytesToWrite); +} +void BitStream::EndianSwapBytes( int byteOffset, int length ) +{ + if (DoEndianSwap()) + { + ReverseBytesInPlace(data+byteOffset, length); + } +} +/// Aligns the bitstream, writes inputLength, and writes input. Won't write beyond maxBytesToWrite +void BitStream::WriteAlignedBytesSafe( const char *inByteArray, const unsigned int inputLength, const unsigned int maxBytesToWrite ) +{ + if (inByteArray==0 || inputLength==0) + { + WriteCompressed((unsigned int)0); + return; + } + WriteCompressed(inputLength); + WriteAlignedBytes((const unsigned char*) inByteArray, inputLength < maxBytesToWrite ? inputLength : maxBytesToWrite); +} + +// Read bits, starting at the next aligned bits. Note that the modulus 8 starting offset of the +// sequence must be the same as was used with WriteBits. This will be a problem with packet coalescence +// unless you byte align the coalesced packets. +bool BitStream::ReadAlignedBytes( unsigned char* inOutByteArray, const unsigned int numberOfBytesToRead ) +{ +#ifdef _DEBUG + OVR_ASSERT( numberOfBytesToRead > 0 ); +#endif + + if ( numberOfBytesToRead <= 0 ) + return false; + + // Byte align + AlignReadToByteBoundary(); + + if ( readOffset + ( numberOfBytesToRead << 3 ) > numberOfBitsUsed ) + return false; + + // Write the data + memcpy( inOutByteArray, data + ( readOffset >> 3 ), (size_t) numberOfBytesToRead ); + + readOffset += numberOfBytesToRead << 3; + + return true; +} +bool BitStream::ReadAlignedBytesSafe( char *inOutByteArray, int &inputLength, const int maxBytesToRead ) +{ + return ReadAlignedBytesSafe(inOutByteArray,(unsigned int&) inputLength,(unsigned int)maxBytesToRead); +} +bool BitStream::ReadAlignedBytesSafe( char *inOutByteArray, unsigned int &inputLength, const unsigned int maxBytesToRead ) +{ + if (ReadCompressed(inputLength)==false) + return false; + if (inputLength > maxBytesToRead) + inputLength=maxBytesToRead; + if (inputLength==0) + return true; + return ReadAlignedBytes((unsigned char*) inOutByteArray, inputLength); +} +bool BitStream::ReadAlignedBytesSafeAlloc( char **outByteArray, int &inputLength, const unsigned int maxBytesToRead ) +{ + return ReadAlignedBytesSafeAlloc(outByteArray,(unsigned int&) inputLength, maxBytesToRead); +} +bool BitStream::ReadAlignedBytesSafeAlloc( char ** outByteArray, unsigned int &inputLength, const unsigned int maxBytesToRead ) +{ + OVR_FREE(*outByteArray); + *outByteArray=0; + if (ReadCompressed(inputLength)==false) + return false; + if (inputLength > maxBytesToRead) + inputLength=maxBytesToRead; + if (inputLength==0) + return true; + *outByteArray = (char*) OVR_ALLOC( (size_t) inputLength); + return ReadAlignedBytes((unsigned char*) *outByteArray, inputLength); +} + +// Write numberToWrite bits from the input source +void BitStream::WriteBits( const unsigned char* inByteArray, BitSize_t numberOfBitsToWrite, const bool rightAlignedBits ) +{ +// if (numberOfBitsToWrite<=0) +// return; + + AddBitsAndReallocate( numberOfBitsToWrite ); + + const BitSize_t numberOfBitsUsedMod8 = numberOfBitsUsed & 7; + + // If currently aligned and numberOfBits is a multiple of 8, just memcpy for speed + if (numberOfBitsUsedMod8==0 && (numberOfBitsToWrite&7)==0) + { + memcpy( data + ( numberOfBitsUsed >> 3 ), inByteArray, numberOfBitsToWrite>>3); + numberOfBitsUsed+=numberOfBitsToWrite; + return; + } + + unsigned char dataByte; + const unsigned char* inputPtr=inByteArray; + + // Faster to put the while at the top surprisingly enough + while ( numberOfBitsToWrite > 0 ) + //do + { + dataByte = *( inputPtr++ ); + + if ( numberOfBitsToWrite < 8 && rightAlignedBits ) // rightAlignedBits means in the case of a partial byte, the bits are aligned from the right (bit 0) rather than the left (as in the normal internal representation) + dataByte <<= 8 - numberOfBitsToWrite; // shift left to get the bits on the left, as in our internal representation + + // Writing to a new byte each time + if ( numberOfBitsUsedMod8 == 0 ) + * ( data + ( numberOfBitsUsed >> 3 ) ) = dataByte; + else + { + // Copy over the new data. + *( data + ( numberOfBitsUsed >> 3 ) ) |= dataByte >> ( numberOfBitsUsedMod8 ); // First half + + if ( 8 - ( numberOfBitsUsedMod8 ) < 8 && 8 - ( numberOfBitsUsedMod8 ) < numberOfBitsToWrite ) // If we didn't write it all out in the first half (8 - (numberOfBitsUsed%8) is the number we wrote in the first half) + { + *( data + ( numberOfBitsUsed >> 3 ) + 1 ) = (unsigned char) ( dataByte << ( 8 - ( numberOfBitsUsedMod8 ) ) ); // Second half (overlaps byte boundary) + } + } + + if ( numberOfBitsToWrite >= 8 ) + { + numberOfBitsUsed += 8; + numberOfBitsToWrite -= 8; + } + else + { + numberOfBitsUsed += numberOfBitsToWrite; + numberOfBitsToWrite=0; + } + } + // } while(numberOfBitsToWrite>0); +} + +// Set the stream to some initial data. For internal use +void BitStream::SetData( unsigned char *inByteArray ) +{ + data=inByteArray; + copyData=false; +} + +// Assume the input source points to a native type, compress and write it +void BitStream::WriteCompressed( const unsigned char* inByteArray, + const unsigned int size, const bool unsignedData ) +{ + BitSize_t currentByte = ( size >> 3 ) - 1; // PCs + + unsigned char byteMatch; + + if ( unsignedData ) + { + byteMatch = 0; + } + + else + { + byteMatch = 0xFF; + } + + // Write upper bytes with a single 1 + // From high byte to low byte, if high byte is a byteMatch then write a 1 bit. Otherwise write a 0 bit and then write the remaining bytes + while ( currentByte > 0 ) + { + if ( inByteArray[ currentByte ] == byteMatch ) // If high byte is byteMatch (0 of 0xff) then it would have the same value shifted + { + bool b = true; + Write( b ); + } + else + { + // Write the remainder of the data after writing 0 + bool b = false; + Write( b ); + + WriteBits( inByteArray, ( currentByte + 1 ) << 3, true ); + // currentByte--; + + + return ; + } + + currentByte--; + } + + // If the upper half of the last byte is a 0 (positive) or 16 (negative) then write a 1 and the remaining 4 bits. Otherwise write a 0 and the 8 bites. + if ( ( unsignedData && ( ( *( inByteArray + currentByte ) ) & 0xF0 ) == 0x00 ) || + ( unsignedData == false && ( ( *( inByteArray + currentByte ) ) & 0xF0 ) == 0xF0 ) ) + { + bool b = true; + Write( b ); + WriteBits( inByteArray + currentByte, 4, true ); + } + + else + { + bool b = false; + Write( b ); + WriteBits( inByteArray + currentByte, 8, true ); + } +} + +// Read numberOfBitsToRead bits to the output source +// alignBitsToRight should be set to true to convert internal bitstream data to userdata +// It should be false if you used WriteBits with rightAlignedBits false +bool BitStream::ReadBits( unsigned char *inOutByteArray, BitSize_t numberOfBitsToRead, const bool alignBitsToRight ) +{ +#ifdef _DEBUG + // OVR_ASSERT( numberOfBitsToRead > 0 ); +#endif + if (numberOfBitsToRead<=0) + return false; + + if ( readOffset + numberOfBitsToRead > numberOfBitsUsed ) + return false; + + + const BitSize_t readOffsetMod8 = readOffset & 7; + + // If currently aligned and numberOfBits is a multiple of 8, just memcpy for speed + if (readOffsetMod8==0 && (numberOfBitsToRead&7)==0) + { + memcpy( inOutByteArray, data + ( readOffset >> 3 ), numberOfBitsToRead>>3); + readOffset+=numberOfBitsToRead; + return true; + } + + + + BitSize_t offset = 0; + + memset( inOutByteArray, 0, (size_t) BITS_TO_BYTES( numberOfBitsToRead ) ); + + while ( numberOfBitsToRead > 0 ) + { + *( inOutByteArray + offset ) |= *( data + ( readOffset >> 3 ) ) << ( readOffsetMod8 ); // First half + + if ( readOffsetMod8 > 0 && numberOfBitsToRead > 8 - ( readOffsetMod8 ) ) // If we have a second half, we didn't read enough bytes in the first half + *( inOutByteArray + offset ) |= *( data + ( readOffset >> 3 ) + 1 ) >> ( 8 - ( readOffsetMod8 ) ); // Second half (overlaps byte boundary) + + if (numberOfBitsToRead>=8) + { + numberOfBitsToRead -= 8; + readOffset += 8; + offset++; + } + else + { + int neg = (int) numberOfBitsToRead - 8; + + if ( neg < 0 ) // Reading a partial byte for the last byte, shift right so the data is aligned on the right + { + + if ( alignBitsToRight ) + * ( inOutByteArray + offset ) >>= -neg; + + readOffset += 8 + neg; + } + else + readOffset += 8; + + offset++; + + numberOfBitsToRead=0; + } + } + + return true; +} + +// Assume the input source points to a compressed native type. Decompress and read it +bool BitStream::ReadCompressed( unsigned char* inOutByteArray, + const unsigned int size, const bool unsignedData ) +{ + unsigned int currentByte = ( size >> 3 ) - 1; + + + unsigned char byteMatch, halfByteMatch; + + if ( unsignedData ) + { + byteMatch = 0; + halfByteMatch = 0; + } + + else + { + byteMatch = 0xFF; + halfByteMatch = 0xF0; + } + + // Upper bytes are specified with a single 1 if they match byteMatch + // From high byte to low byte, if high byte is a byteMatch then write a 1 bit. Otherwise write a 0 bit and then write the remaining bytes + while ( currentByte > 0 ) + { + // If we read a 1 then the data is byteMatch. + + bool b; + + if ( Read( b ) == false ) + return false; + + if ( b ) // Check that bit + { + inOutByteArray[ currentByte ] = byteMatch; + currentByte--; + } + else + { + // Read the rest of the bytes + + if ( ReadBits( inOutByteArray, ( currentByte + 1 ) << 3 ) == false ) + return false; + + return true; + } + } + + // All but the first bytes are byteMatch. If the upper half of the last byte is a 0 (positive) or 16 (negative) then what we read will be a 1 and the remaining 4 bits. + // Otherwise we read a 0 and the 8 bytes + //OVR_ASSERT(readOffset+1 <=numberOfBitsUsed); // If this assert is hit the stream wasn't long enough to read from + if ( readOffset + 1 > numberOfBitsUsed ) + return false; + + bool b=false; + + if ( Read( b ) == false ) + return false; + + if ( b ) // Check that bit + { + + if ( ReadBits( inOutByteArray + currentByte, 4 ) == false ) + return false; + + inOutByteArray[ currentByte ] |= halfByteMatch; // We have to set the high 4 bits since these are set to 0 by ReadBits + } + else + { + if ( ReadBits( inOutByteArray + currentByte, 8 ) == false ) + return false; + } + + return true; +} + +// Reallocates (if necessary) in preparation of writing numberOfBitsToWrite +void BitStream::AddBitsAndReallocate( const BitSize_t numberOfBitsToWrite ) +{ + BitSize_t newNumberOfBitsAllocated = numberOfBitsToWrite + numberOfBitsUsed; + + if ( numberOfBitsToWrite + numberOfBitsUsed > 0 && ( ( numberOfBitsAllocated - 1 ) >> 3 ) < ( ( newNumberOfBitsAllocated - 1 ) >> 3 ) ) // If we need to allocate 1 or more new bytes + { +#ifdef _DEBUG + // If this assert hits then we need to specify true for the third parameter in the constructor + // It needs to reallocate to hold all the data and can't do it unless we allocated to begin with + // Often hits if you call Write or Serialize on a read-only bitstream + OVR_ASSERT( copyData == true ); +#endif + + // Less memory efficient but saves on news and deletes + /// Cap to 1 meg buffer to save on huge allocations + newNumberOfBitsAllocated = ( numberOfBitsToWrite + numberOfBitsUsed ) * 2; + if (newNumberOfBitsAllocated - ( numberOfBitsToWrite + numberOfBitsUsed ) > 1048576 ) + newNumberOfBitsAllocated = numberOfBitsToWrite + numberOfBitsUsed + 1048576; + + // BitSize_t newByteOffset = BITS_TO_BYTES( numberOfBitsAllocated ); + // Use realloc and free so we are more efficient than delete and new for resizing + BitSize_t amountToAllocate = BITS_TO_BYTES( newNumberOfBitsAllocated ); + if (data==(unsigned char*)stackData) + { + if (amountToAllocate > BITSTREAM_STACK_ALLOCATION_SIZE) + { + data = ( unsigned char* ) OVR_ALLOC( (size_t) amountToAllocate); + OVR_ASSERT(data); + if (data) + { + // need to copy the stack data over to our new memory area too + memcpy ((void *)data, (void *)stackData, (size_t) BITS_TO_BYTES( numberOfBitsAllocated )); + } + } + } + else + { + data = ( unsigned char* ) OVR_REALLOC( data, (size_t) amountToAllocate); + } + +#ifdef _DEBUG + OVR_ASSERT( data ); // Make sure realloc succeeded +#endif + // memset(data+newByteOffset, 0, ((newNumberOfBitsAllocated-1)>>3) - ((numberOfBitsAllocated-1)>>3)); // Set the new data block to 0 + } + + if ( newNumberOfBitsAllocated > numberOfBitsAllocated ) + numberOfBitsAllocated = newNumberOfBitsAllocated; +} +BitSize_t BitStream::GetNumberOfBitsAllocated(void) const +{ + return numberOfBitsAllocated; +} +void BitStream::PadWithZeroToByteLength( unsigned int bytes ) +{ + if (GetNumberOfBytesUsed() < bytes) + { + AlignWriteToByteBoundary(); + unsigned int numToWrite = bytes - GetNumberOfBytesUsed(); + AddBitsAndReallocate( BYTES_TO_BITS(numToWrite) ); + memset(data+BITS_TO_BYTES(numberOfBitsUsed), 0, (size_t) numToWrite); + numberOfBitsUsed+=BYTES_TO_BITS(numToWrite); + } +} + +/* +// Julius Goryavsky's version of Harley's algorithm. +// 17 elementary ops plus an indexed load, if the machine +// has "and not." + +int nlz10b(unsigned x) { + + static char table[64] = + {32,20,19, u, u,18, u, 7, 10,17, u, u,14, u, 6, u, + u, 9, u,16, u, u, 1,26, u,13, u, u,24, 5, u, u, + u,21, u, 8,11, u,15, u, u, u, u, 2,27, 0,25, u, + 22, u,12, u, u, 3,28, u, 23, u, 4,29, u, u,30,31}; + + x = x | (x >> 1); // Propagate leftmost + x = x | (x >> 2); // 1-bit to the right. + x = x | (x >> 4); + x = x | (x >> 8); + x = x & ~(x >> 16); + x = x*0xFD7049FF; // Activate this line or the following 3. +// x = (x << 9) - x; // Multiply by 511. +// x = (x << 11) - x; // Multiply by 2047. +// x = (x << 14) - x; // Multiply by 16383. + return table[x >> 26]; +} +*/ +int BitStream::NumberOfLeadingZeroes( int8_t x ) {return NumberOfLeadingZeroes((uint8_t)x);} +int BitStream::NumberOfLeadingZeroes( uint8_t x ) +{ + uint8_t y; + int n; + + n = 8; + y = x >> 4; if (y != 0) {n = n - 4; x = y;} + y = x >> 2; if (y != 0) {n = n - 2; x = y;} + y = x >> 1; if (y != 0) return n - 2; + return (int)(n - x); +} +int BitStream::NumberOfLeadingZeroes( int16_t x ) {return NumberOfLeadingZeroes((uint16_t)x);} +int BitStream::NumberOfLeadingZeroes( uint16_t x ) +{ + uint16_t y; + int n; + + n = 16; + y = x >> 8; if (y != 0) {n = n - 8; x = y;} + y = x >> 4; if (y != 0) {n = n - 4; x = y;} + y = x >> 2; if (y != 0) {n = n - 2; x = y;} + y = x >> 1; if (y != 0) return n - 2; + return (int)(n - x); +} +int BitStream::NumberOfLeadingZeroes( int32_t x ) {return NumberOfLeadingZeroes((uint32_t)x);} +int BitStream::NumberOfLeadingZeroes( uint32_t x ) +{ + uint32_t y; + int n; + + n = 32; + y = x >>16; if (y != 0) {n = n -16; x = y;} + y = x >> 8; if (y != 0) {n = n - 8; x = y;} + y = x >> 4; if (y != 0) {n = n - 4; x = y;} + y = x >> 2; if (y != 0) {n = n - 2; x = y;} + y = x >> 1; if (y != 0) return n - 2; + return (int)(n - x); +} +int BitStream::NumberOfLeadingZeroes( int64_t x ) {return NumberOfLeadingZeroes((uint64_t)x);} +int BitStream::NumberOfLeadingZeroes( uint64_t x ) +{ + uint64_t y; + int n; + + n = 64; + y = x >>32; if (y != 0) {n = n -32; x = y;} + y = x >>16; if (y != 0) {n = n -16; x = y;} + y = x >> 8; if (y != 0) {n = n - 8; x = y;} + y = x >> 4; if (y != 0) {n = n - 4; x = y;} + y = x >> 2; if (y != 0) {n = n - 2; x = y;} + y = x >> 1; if (y != 0) return n - 2; + return (int)(n - x); +} + +// Should hit if reads didn't match writes +void BitStream::AssertStreamEmpty( void ) +{ + OVR_ASSERT( readOffset == numberOfBitsUsed ); +} +void BitStream::PrintBits( char *out ) const +{ + if ( numberOfBitsUsed <= 0 ) + { + OVR_strcpy(out, 128, "No bits\n" ); + return; + } + + unsigned int strIndex=0; + for ( BitSize_t counter = 0; counter < BITS_TO_BYTES( numberOfBitsUsed ) && strIndex < 2000 ; counter++ ) + { + BitSize_t stop; + + if ( counter == ( numberOfBitsUsed - 1 ) >> 3 ) + stop = 8 - ( ( ( numberOfBitsUsed - 1 ) & 7 ) + 1 ); + else + stop = 0; + + for ( BitSize_t counter2 = 7; counter2 >= stop; counter2-- ) + { + if ( ( data[ counter ] >> counter2 ) & 1 ) + out[strIndex++]='1'; + else + out[strIndex++]='0'; + + if (counter2==0) + break; + } + + out[strIndex++]=' '; + } + + out[strIndex++]='\n'; + + out[strIndex++]=0; +} +void BitStream::PrintBits( void ) const +{ + char out[2048]; + PrintBits(out); + printf("%s", out); +} +void BitStream::PrintHex( char *out ) const +{ + BitSize_t i; + for ( i=0; i < GetNumberOfBytesUsed(); i++) + { + OVR_sprintf(out+i*3, 128, "%02x ", data[i]); + } +} +void BitStream::PrintHex( void ) const +{ + char out[2048]; + PrintHex(out); + printf("%s", out); +} + +// Exposes the data for you to look at, like PrintBits does. +// Data will point to the stream. Returns the length in bits of the stream. +BitSize_t BitStream::CopyData( unsigned char** _data ) const +{ +#ifdef _DEBUG + OVR_ASSERT( numberOfBitsUsed > 0 ); +#endif + + *_data = (unsigned char*) OVR_ALLOC( (size_t) BITS_TO_BYTES( numberOfBitsUsed )); + memcpy( *_data, data, sizeof(unsigned char) * (size_t) ( BITS_TO_BYTES( numberOfBitsUsed ) ) ); + return numberOfBitsUsed; +} + +// Ignore data we don't intend to read +void BitStream::IgnoreBits( const BitSize_t numberOfBits ) +{ + readOffset += numberOfBits; +} + +void BitStream::IgnoreBytes( const unsigned int numberOfBytes ) +{ + IgnoreBits(BYTES_TO_BITS(numberOfBytes)); +} + +// Move the write pointer to a position on the array. Dangerous if you don't know what you are doing! +// Doesn't work with non-aligned data! +void BitStream::SetWriteOffset( const BitSize_t offset ) +{ + numberOfBitsUsed = offset; +} + +/* +BitSize_t BitStream::GetWriteOffset( void ) const +{ +return numberOfBitsUsed; +} + +// Returns the length in bits of the stream +BitSize_t BitStream::GetNumberOfBitsUsed( void ) const +{ +return GetWriteOffset(); +} + +// Returns the length in bytes of the stream +BitSize_t BitStream::GetNumberOfBytesUsed( void ) const +{ +return BITS_TO_BYTES( numberOfBitsUsed ); +} + +// Returns the number of bits into the stream that we have read +BitSize_t BitStream::GetReadOffset( void ) const +{ +return readOffset; +} + + +// Sets the read bit index +void BitStream::SetReadOffset( const BitSize_t newReadOffset ) +{ +readOffset=newReadOffset; +} + +// Returns the number of bits left in the stream that haven't been read +BitSize_t BitStream::GetNumberOfUnreadBits( void ) const +{ +return numberOfBitsUsed - readOffset; +} +// Exposes the internal data +unsigned char* BitStream::GetData( void ) const +{ +return data; +} + +*/ +// If we used the constructor version with copy data off, this makes sure it is set to on and the data pointed to is copied. +void BitStream::AssertCopyData( void ) +{ + if ( copyData == false ) + { + copyData = true; + + if ( numberOfBitsAllocated > 0 ) + { + unsigned char * newdata = ( unsigned char* ) OVR_ALLOC( (size_t) BITS_TO_BYTES( numberOfBitsAllocated )); +#ifdef _DEBUG + + OVR_ASSERT( data ); +#endif + + memcpy( newdata, data, (size_t) BITS_TO_BYTES( numberOfBitsAllocated ) ); + data = newdata; + } + + else + data = 0; + } +} +bool BitStream::IsNetworkOrderInternal(void) +{ +#if defined(_PS3) || defined(__PS3__) || defined(SN_TARGET_PS3) + return true; +#elif defined(SN_TARGET_PSP2) + return false; +#else + static unsigned long htonlValue = htonl(12345); + return htonlValue == 12345; +#endif +} +void BitStream::ReverseBytes(unsigned char *inByteArray, unsigned char *inOutByteArray, const unsigned int length) +{ + for (BitSize_t i=0; i < length; i++) + inOutByteArray[i]=inByteArray[length-i-1]; +} +void BitStream::ReverseBytesInPlace(unsigned char *inOutData,const unsigned int length) +{ + unsigned char temp; + BitSize_t i; + for (i=0; i < (length>>1); i++) + { + temp = inOutData[i]; + inOutData[i]=inOutData[length-i-1]; + inOutData[length-i-1]=temp; + } +} + +void BitStream::WriteAlignedVar8(const char *inByteArray) +{ + OVR_ASSERT((numberOfBitsUsed&7)==0); + AddBitsAndReallocate(1*8); + data[( numberOfBitsUsed >> 3 ) + 0] = inByteArray[0]; + numberOfBitsUsed+=1*8; +} +bool BitStream::ReadAlignedVar8(char *inOutByteArray) +{ + OVR_ASSERT((readOffset&7)==0); + if ( readOffset + 1*8 > numberOfBitsUsed ) + return false; + + inOutByteArray[0] = data[( readOffset >> 3 ) + 0]; + readOffset+=1*8; + return true; +} +void BitStream::WriteAlignedVar16(const char *inByteArray) +{ + OVR_ASSERT((numberOfBitsUsed&7)==0); + AddBitsAndReallocate(2*8); +#ifndef __BITSTREAM_NATIVE_END + if (DoEndianSwap()) + { + data[( numberOfBitsUsed >> 3 ) + 0] = inByteArray[1]; + data[( numberOfBitsUsed >> 3 ) + 1] = inByteArray[0]; + } + else +#endif + { + data[( numberOfBitsUsed >> 3 ) + 0] = inByteArray[0]; + data[( numberOfBitsUsed >> 3 ) + 1] = inByteArray[1]; + } + + numberOfBitsUsed+=2*8; +} +bool BitStream::ReadAlignedVar16(char *inOutByteArray) +{ + OVR_ASSERT((readOffset&7)==0); + if ( readOffset + 2*8 > numberOfBitsUsed ) + return false; +#ifndef __BITSTREAM_NATIVE_END + if (DoEndianSwap()) + { + inOutByteArray[0] = data[( readOffset >> 3 ) + 1]; + inOutByteArray[1] = data[( readOffset >> 3 ) + 0]; + } + else +#endif + { + inOutByteArray[0] = data[( readOffset >> 3 ) + 0]; + inOutByteArray[1] = data[( readOffset >> 3 ) + 1]; + } + + readOffset+=2*8; + return true; +} +void BitStream::WriteAlignedVar32(const char *inByteArray) +{ + OVR_ASSERT((numberOfBitsUsed&7)==0); + AddBitsAndReallocate(4*8); +#ifndef __BITSTREAM_NATIVE_END + if (DoEndianSwap()) + { + data[( numberOfBitsUsed >> 3 ) + 0] = inByteArray[3]; + data[( numberOfBitsUsed >> 3 ) + 1] = inByteArray[2]; + data[( numberOfBitsUsed >> 3 ) + 2] = inByteArray[1]; + data[( numberOfBitsUsed >> 3 ) + 3] = inByteArray[0]; + } + else +#endif + { + data[( numberOfBitsUsed >> 3 ) + 0] = inByteArray[0]; + data[( numberOfBitsUsed >> 3 ) + 1] = inByteArray[1]; + data[( numberOfBitsUsed >> 3 ) + 2] = inByteArray[2]; + data[( numberOfBitsUsed >> 3 ) + 3] = inByteArray[3]; + } + + numberOfBitsUsed+=4*8; +} +bool BitStream::ReadAlignedVar32(char *inOutByteArray) +{ + OVR_ASSERT((readOffset&7)==0); + if ( readOffset + 4*8 > numberOfBitsUsed ) + return false; +#ifndef __BITSTREAM_NATIVE_END + if (DoEndianSwap()) + { + inOutByteArray[0] = data[( readOffset >> 3 ) + 3]; + inOutByteArray[1] = data[( readOffset >> 3 ) + 2]; + inOutByteArray[2] = data[( readOffset >> 3 ) + 1]; + inOutByteArray[3] = data[( readOffset >> 3 ) + 0]; + } + else +#endif + { + inOutByteArray[0] = data[( readOffset >> 3 ) + 0]; + inOutByteArray[1] = data[( readOffset >> 3 ) + 1]; + inOutByteArray[2] = data[( readOffset >> 3 ) + 2]; + inOutByteArray[3] = data[( readOffset >> 3 ) + 3]; + } + + readOffset+=4*8; + return true; +} +bool BitStream::ReadFloat16( float &outFloat, float floatMin, float floatMax ) +{ + uint16_t percentile; + if (Read(percentile)) + { + OVR_ASSERT(floatMax>floatMin); + outFloat = floatMin + ((float) percentile / 65535.0f) * (floatMax-floatMin); + if (outFloatfloatMax) + outFloat=floatMax; + return true; + } + return false; +} +bool BitStream::SerializeFloat16(bool writeToBitstream, float &inOutFloat, float floatMin, float floatMax) +{ + if (writeToBitstream) + WriteFloat16(inOutFloat, floatMin, floatMax); + else + return ReadFloat16(inOutFloat, floatMin, floatMax); + return true; +} +void BitStream::WriteFloat16( float inOutFloat, float floatMin, float floatMax ) +{ + OVR_ASSERT(floatMax>floatMin); + if (inOutFloat>floatMax+.001) + { + OVR_ASSERT(inOutFloat<=floatMax+.001); + } + if (inOutFloat=floatMin-.001); + } + float percentile=65535.0f * (inOutFloat-floatMin)/(floatMax-floatMin); + if (percentile<0.0) + percentile=0.0; + if (percentile>65535.0f) + percentile=65535.0f; + Write((uint16_t)percentile); +} + + +}} // OVR::Net diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Net/OVR_BitStream.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Net/OVR_BitStream.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,1744 @@ +/************************************************************************************ + +PublicHeader: n/a +Filename : OVR_BitStream.h +Content : A generic serialization toolkit for packing data to a binary stream. +Created : June 10, 2014 +Authors : Kevin Jenkins + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#ifndef OVR_Bitstream_h +#define OVR_Bitstream_h + +#include +#include "../Kernel/OVR_Types.h" +#include "../Kernel/OVR_Std.h" +#include "../Kernel/OVR_String.h" + +namespace OVR { namespace Net { + +typedef uint32_t BitSize_t; +#define BITSTREAM_STACK_ALLOCATION_SIZE 256 +#define BITS_TO_BYTES(x) (((x)+7)>>3) +#define BYTES_TO_BITS(x) ((x)<<3) + + +//----------------------------------------------------------------------------- +// BitStream + +// Generic serialization class to binary stream +class BitStream : public NewOverrideBase +{ +public: + /// Default Constructor + BitStream(); + + /// \brief Create the bitstream, with some number of bytes to immediately allocate. + /// \details There is no benefit to calling this, unless you know exactly how many bytes you need and it is greater than BITSTREAM_STACK_ALLOCATION_SIZE. + /// In that case all it does is save you one or more realloc calls. + /// \param[in] initialBytesToAllocate the number of bytes to pre-allocate. + BitStream( const unsigned int initialBytesToAllocate ); + + /// \brief Initialize the BitStream, immediately setting the data it contains to a predefined pointer. + /// \details Set \a _copyData to true if you want to make an internal copy of the data you are passing. Set it to false to just save a pointer to the data. + /// You shouldn't call Write functions with \a _copyData as false, as this will write to unallocated memory + /// 99% of the time you will use this function to cast Packet::data to a bitstream for reading, in which case you should write something as follows: + /// \code + /// RakNet::BitStream bs(packet->data, packet->length, false); + /// \endcode + /// \param[in] _data An array of bytes. + /// \param[in] lengthInBytes Size of the \a _data. + /// \param[in] _copyData true or false to make a copy of \a _data or not. + BitStream( char* _data, const unsigned int lengthInBytes, bool _copyData ); + + // Destructor + ~BitStream(); + +public: + /// Resets the bitstream for reuse. + void Reset( void ); + + /// \brief Bidirectional serialize/deserialize any integral type to/from a bitstream. + /// \details Undefine __BITSTREAM_NATIVE_END if you need endian swapping. + /// \param[in] writeToBitstream true to write from your data to this bitstream. False to read from this bitstream and write to your data + /// \param[in] inOutTemplateVar The value to write + /// \return true if \a writeToBitstream is true. true if \a writeToBitstream is false and the read was successful. false if \a writeToBitstream is false and the read was not successful. + template + bool Serialize(bool writeToBitstream, templateType &inOutTemplateVar); + + /// \brief Bidirectional serialize/deserialize any integral type to/from a bitstream. + /// \details If the current value is different from the last value + /// the current value will be written. Otherwise, a single bit will be written + /// \param[in] writeToBitstream true to write from your data to this bitstream. False to read from this bitstream and write to your data + /// \param[in] inOutCurrentValue The current value to write + /// \param[in] lastValue The last value to compare against. Only used if \a writeToBitstream is true. + /// \return true if \a writeToBitstream is true. true if \a writeToBitstream is false and the read was successful. false if \a writeToBitstream is false and the read was not successful. + template + bool SerializeDelta(bool writeToBitstream, templateType &inOutCurrentValue, const templateType &lastValue); + + /// \brief Bidirectional version of SerializeDelta when you don't know what the last value is, or there is no last value. + /// \param[in] writeToBitstream true to write from your data to this bitstream. False to read from this bitstream and write to your data + /// \param[in] inOutCurrentValue The current value to write + /// \return true if \a writeToBitstream is true. true if \a writeToBitstream is false and the read was successful. false if \a writeToBitstream is false and the read was not successful. + template + bool SerializeDelta(bool writeToBitstream, templateType &inOutCurrentValue); + + /// \brief Bidirectional serialize/deserialize any integral type to/from a bitstream. + /// \details Undefine __BITSTREAM_NATIVE_END if you need endian swapping. + /// If you are not using __BITSTREAM_NATIVE_END the opposite is true for types larger than 1 byte + /// For floating point, this is lossy, using 2 bytes for a float and 4 for a double. The range must be between -1 and +1. + /// For non-floating point, this is lossless, but only has benefit if you use less than half the bits of the type + /// \param[in] writeToBitstream true to write from your data to this bitstream. False to read from this bitstream and write to your data + /// \param[in] inOutTemplateVar The value to write + /// \return true if \a writeToBitstream is true. true if \a writeToBitstream is false and the read was successful. false if \a writeToBitstream is false and the read was not successful. + template + bool SerializeCompressed(bool writeToBitstream, templateType &inOutTemplateVar); + + /// \brief Bidirectional serialize/deserialize any integral type to/from a bitstream. + /// \details If the current value is different from the last value + /// the current value will be written. Otherwise, a single bit will be written + /// For floating point, this is lossy, using 2 bytes for a float and 4 for a double. The range must be between -1 and +1. + /// For non-floating point, this is lossless, but only has benefit if you use less than half the bits of the type + /// If you are not using __BITSTREAM_NATIVE_END the opposite is true for types larger than 1 byte + /// \param[in] writeToBitstream true to write from your data to this bitstream. False to read from this bitstream and write to your data + /// \param[in] inOutCurrentValue The current value to write + /// \param[in] lastValue The last value to compare against. Only used if \a writeToBitstream is true. + /// \return true if \a writeToBitstream is true. true if \a writeToBitstream is false and the read was successful. false if \a writeToBitstream is false and the read was not successful. + template + bool SerializeCompressedDelta(bool writeToBitstream, templateType &inOutCurrentValue, const templateType &lastValue); + + /// \brief Save as SerializeCompressedDelta(templateType ¤tValue, const templateType &lastValue) when we have an unknown second parameter + /// \return true on data read. False on insufficient data in bitstream + template + bool SerializeCompressedDelta(bool writeToBitstream, templateType &inOutTemplateVar); + + /// \brief Bidirectional serialize/deserialize an array or casted stream or raw data. This does NOT do endian swapping. + /// \param[in] writeToBitstream true to write from your data to this bitstream. False to read from this bitstream and write to your data + /// \param[in] inOutByteArray a byte buffer + /// \param[in] numberOfBytes the size of \a input in bytes + /// \return true if \a writeToBitstream is true. true if \a writeToBitstream is false and the read was successful. false if \a writeToBitstream is false and the read was not successful. + bool Serialize(bool writeToBitstream, char* inOutByteArray, const unsigned int numberOfBytes ); + + /// \brief Serialize a float into 2 bytes, spanning the range between \a floatMin and \a floatMax + /// \param[in] writeToBitstream true to write from your data to this bitstream. False to read from this bitstream and write to your data + /// \param[in] inOutFloat The float to write + /// \param[in] floatMin Predetermined minimum value of f + /// \param[in] floatMax Predetermined maximum value of f + bool SerializeFloat16(bool writeToBitstream, float &inOutFloat, float floatMin, float floatMax); + + /// Serialize one type casted to another (smaller) type, to save bandwidth + /// serializationType should be uint8_t, uint16_t, uint24_t, or uint32_t + /// Example: int num=53; SerializeCasted(true, num); would use 1 byte to write what would otherwise be an integer (4 or 8 bytes) + /// \param[in] writeToBitstream true to write from your data to this bitstream. False to read from this bitstream and write to your data + /// \param[in] value The value to serialize + template + bool SerializeCasted( bool writeToBitstream, sourceType &value ); + + /// Given the minimum and maximum values for an integer type, figure out the minimum number of bits to represent the range + /// Then serialize only those bits + /// \note A static is used so that the required number of bits for (maximum-minimum) is only calculated once. This does require that \a minimum and \maximum are fixed values for a given line of code for the life of the program + /// \param[in] writeToBitstream true to write from your data to this bitstream. False to read from this bitstream and write to your data + /// \param[in] value Integer value to write, which should be between \a minimum and \a maximum + /// \param[in] minimum Minimum value of \a value + /// \param[in] maximum Maximum value of \a value + /// \param[in] allowOutsideRange If true, all sends will take an extra bit, however value can deviate from outside \a minimum and \a maximum. If false, will assert if the value deviates + template + bool SerializeBitsFromIntegerRange( bool writeToBitstream, templateType &value, const templateType minimum, const templateType maximum, bool allowOutsideRange=false ); + /// \param[in] requiredBits Primarily for internal use, called from above function() after calculating number of bits needed to represent maximum-minimum + template + bool SerializeBitsFromIntegerRange( bool writeToBitstream, templateType &value, const templateType minimum, const templateType maximum, const int requiredBits, bool allowOutsideRange=false ); + + /// \brief Bidirectional serialize/deserialize a normalized 3D vector, using (at most) 4 bytes + 3 bits instead of 12-24 bytes. + /// \details Will further compress y or z axis aligned vectors. + /// Accurate to 1/32767.5. + /// \param[in] writeToBitstream true to write from your data to this bitstream. False to read from this bitstream and write to your data + /// \param[in] x x + /// \param[in] y y + /// \param[in] z z + /// \return true if \a writeToBitstream is true. true if \a writeToBitstream is false and the read was successful. false if \a writeToBitstream is false and the read was not successful. + template // templateType for this function must be a float or double + bool SerializeNormVector(bool writeToBitstream, templateType &x, templateType &y, templateType &z ); + + /// \brief Bidirectional serialize/deserialize a vector, using 10 bytes instead of 12. + /// \details Loses accuracy to about 3/10ths and only saves 2 bytes, so only use if accuracy is not important. + /// \param[in] writeToBitstream true to write from your data to this bitstream. False to read from this bitstream and write to your data + /// \param[in] x x + /// \param[in] y y + /// \param[in] z z + /// \return true if \a writeToBitstream is true. true if \a writeToBitstream is false and the read was successful. false if \a writeToBitstream is false and the read was not successful. + template // templateType for this function must be a float or double + bool SerializeVector(bool writeToBitstream, templateType &x, templateType &y, templateType &z ); + + /// \brief Bidirectional serialize/deserialize a normalized quaternion in 6 bytes + 4 bits instead of 16 bytes. Slightly lossy. + /// \param[in] writeToBitstream true to write from your data to this bitstream. False to read from this bitstream and write to your data + /// \param[in] w w + /// \param[in] x x + /// \param[in] y y + /// \param[in] z z + /// \return true if \a writeToBitstream is true. true if \a writeToBitstream is false and the read was successful. false if \a writeToBitstream is false and the read was not successful. + template // templateType for this function must be a float or double + bool SerializeNormQuat(bool writeToBitstream, templateType &w, templateType &x, templateType &y, templateType &z); + + /// \brief Bidirectional serialize/deserialize an orthogonal matrix by creating a quaternion, and writing 3 components of the quaternion in 2 bytes each. + /// \details Use 6 bytes instead of 36 + /// Lossy, although the result is renormalized + /// \return true on success, false on failure. + template // templateType for this function must be a float or double + bool SerializeOrthMatrix( + bool writeToBitstream, + templateType &m00, templateType &m01, templateType &m02, + templateType &m10, templateType &m11, templateType &m12, + templateType &m20, templateType &m21, templateType &m22 ); + + /// \brief Bidirectional serialize/deserialize numberToSerialize bits to/from the input. + /// \details Right aligned data means in the case of a partial byte, the bits are aligned + /// from the right (bit 0) rather than the left (as in the normal + /// internal representation) You would set this to true when + /// writing user data, and false when copying bitstream data, such + /// as writing one bitstream to another + /// \param[in] writeToBitstream true to write from your data to this bitstream. False to read from this bitstream and write to your data + /// \param[in] inOutByteArray The data + /// \param[in] numberOfBitsToSerialize The number of bits to write + /// \param[in] rightAlignedBits if true data will be right aligned + /// \return true if \a writeToBitstream is true. true if \a writeToBitstream is false and the read was successful. false if \a writeToBitstream is false and the read was not successful. + bool SerializeBits(bool writeToBitstream, unsigned char* inOutByteArray, const BitSize_t numberOfBitsToSerialize, const bool rightAlignedBits = true ); + + /// \brief Write any integral type to a bitstream. + /// \details Undefine __BITSTREAM_NATIVE_END if you need endian swapping. + /// \param[in] inTemplateVar The value to write + template + void Write(const templateType &inTemplateVar); + + /// \brief Write the dereferenced pointer to any integral type to a bitstream. + /// \details Undefine __BITSTREAM_NATIVE_END if you need endian swapping. + /// \param[in] inTemplateVar The value to write + template + void WritePtr(templateType *inTemplateVar); + + /// \brief Write any integral type to a bitstream. + /// \details If the current value is different from the last value + /// the current value will be written. Otherwise, a single bit will be written + /// \param[in] currentValue The current value to write + /// \param[in] lastValue The last value to compare against + template + void WriteDelta(const templateType ¤tValue, const templateType &lastValue); + + /// \brief WriteDelta when you don't know what the last value is, or there is no last value. + /// \param[in] currentValue The current value to write + template + void WriteDelta(const templateType ¤tValue); + + /// \brief Write any integral type to a bitstream. + /// \details Undefine __BITSTREAM_NATIVE_END if you need endian swapping. + /// If you are not using __BITSTREAM_NATIVE_END the opposite is true for types larger than 1 byte + /// For floating point, this is lossy, using 2 bytes for a float and 4 for a double. The range must be between -1 and +1. + /// For non-floating point, this is lossless, but only has benefit if you use less than half the bits of the type + /// \param[in] inTemplateVar The value to write + template + void WriteCompressed(const templateType &inTemplateVar); + + /// \brief Write any integral type to a bitstream. + /// \details If the current value is different from the last value + /// the current value will be written. Otherwise, a single bit will be written + /// For floating point, this is lossy, using 2 bytes for a float and 4 for a double. The range must be between -1 and +1. + /// For non-floating point, this is lossless, but only has benefit if you use less than half the bits of the type + /// If you are not using __BITSTREAM_NATIVE_END the opposite is true for types larger than 1 byte + /// \param[in] currentValue The current value to write + /// \param[in] lastValue The last value to compare against + template + void WriteCompressedDelta(const templateType ¤tValue, const templateType &lastValue); + + /// \brief Save as WriteCompressedDelta(const templateType ¤tValue, const templateType &lastValue) when we have an unknown second parameter + template + void WriteCompressedDelta(const templateType ¤tValue); + + /// \brief Read any integral type from a bitstream. + /// \details Define __BITSTREAM_NATIVE_END if you need endian swapping. + /// \param[in] outTemplateVar The value to read + /// \return true on success, false on failure. + template + bool Read(templateType &outTemplateVar); + + /// \brief Read any integral type from a bitstream. + /// \details If the written value differed from the value compared against in the write function, + /// var will be updated. Otherwise it will retain the current value. + /// ReadDelta is only valid from a previous call to WriteDelta + /// \param[in] outTemplateVar The value to read + /// \return true on success, false on failure. + template + bool ReadDelta(templateType &outTemplateVar); + + /// \brief Read any integral type from a bitstream. + /// \details Undefine __BITSTREAM_NATIVE_END if you need endian swapping. + /// For floating point, this is lossy, using 2 bytes for a float and 4 for a double. The range must be between -1 and +1. + /// For non-floating point, this is lossless, but only has benefit if you use less than half the bits of the type + /// If you are not using __BITSTREAM_NATIVE_END the opposite is true for types larger than 1 byte + /// \param[in] outTemplateVar The value to read + /// \return true on success, false on failure. + template + bool ReadCompressed(templateType &outTemplateVar); + + /// \brief Read any integral type from a bitstream. + /// \details If the written value differed from the value compared against in the write function, + /// var will be updated. Otherwise it will retain the current value. + /// the current value will be updated. + /// For floating point, this is lossy, using 2 bytes for a float and 4 for a double. The range must be between -1 and +1. + /// For non-floating point, this is lossless, but only has benefit if you use less than half the bits of the type + /// If you are not using __BITSTREAM_NATIVE_END the opposite is true for types larger than 1 byte + /// ReadCompressedDelta is only valid from a previous call to WriteDelta + /// \param[in] outTemplateVar The value to read + /// \return true on success, false on failure. + template + bool ReadCompressedDelta(templateType &outTemplateVar); + + /// \brief Read one bitstream to another. + /// \param[in] numberOfBits bits to read + /// \param bitStream the bitstream to read into from + /// \return true on success, false on failure. + bool Read( BitStream *bitStream, BitSize_t numberOfBits ); + bool Read( BitStream *bitStream ); + bool Read( BitStream &bitStream, BitSize_t numberOfBits ); + bool Read( BitStream &bitStream ); + + /// \brief Write an array or casted stream or raw data. This does NOT do endian swapping. + /// \param[in] inputByteArray a byte buffer + /// \param[in] numberOfBytes the size of \a input in bytes + void Write( const char* inputByteArray, const unsigned int numberOfBytes ); + + /// \brief Write one bitstream to another. + /// \param[in] numberOfBits bits to write + /// \param bitStream the bitstream to copy from + void Write( BitStream *bitStream, BitSize_t numberOfBits ); + void Write( BitStream *bitStream ); + void Write( BitStream &bitStream, BitSize_t numberOfBits ); + void Write( BitStream &bitStream );\ + + /// \brief Write a float into 2 bytes, spanning the range between \a floatMin and \a floatMax + /// \param[in] x The float to write + /// \param[in] floatMin Predetermined minimum value of f + /// \param[in] floatMax Predetermined maximum value of f + void WriteFloat16( float x, float floatMin, float floatMax ); + + /// Write one type serialized as another (smaller) type, to save bandwidth + /// serializationType should be uint8_t, uint16_t, uint24_t, or uint32_t + /// Example: int num=53; WriteCasted(num); would use 1 byte to write what would otherwise be an integer (4 or 8 bytes) + /// \param[in] value The value to write + template + void WriteCasted( const sourceType &value ); + + /// Given the minimum and maximum values for an integer type, figure out the minimum number of bits to represent the range + /// Then write only those bits + /// \note A static is used so that the required number of bits for (maximum-minimum) is only calculated once. This does require that \a minimum and \maximum are fixed values for a given line of code for the life of the program + /// \param[in] value Integer value to write, which should be between \a minimum and \a maximum + /// \param[in] minimum Minimum value of \a value + /// \param[in] maximum Maximum value of \a value + /// \param[in] allowOutsideRange If true, all sends will take an extra bit, however value can deviate from outside \a minimum and \a maximum. If false, will assert if the value deviates. This should match the corresponding value passed to Read(). + template + void WriteBitsFromIntegerRange( const templateType value, const templateType minimum, const templateType maximum, bool allowOutsideRange=false ); + /// \param[in] requiredBits Primarily for internal use, called from above function() after calculating number of bits needed to represent maximum-minimum + template + void WriteBitsFromIntegerRange( const templateType value, const templateType minimum, const templateType maximum, const int requiredBits, bool allowOutsideRange=false ); + + /// \brief Write a normalized 3D vector, using (at most) 4 bytes + 3 bits instead of 12-24 bytes. + /// \details Will further compress y or z axis aligned vectors. + /// Accurate to 1/32767.5. + /// \param[in] x x + /// \param[in] y y + /// \param[in] z z + template // templateType for this function must be a float or double + void WriteNormVector( templateType x, templateType y, templateType z ); + + /// \brief Write a vector, using 10 bytes instead of 12. + /// \details Loses accuracy to about 3/10ths and only saves 2 bytes, + /// so only use if accuracy is not important. + /// \param[in] x x + /// \param[in] y y + /// \param[in] z z + template // templateType for this function must be a float or double + void WriteVector( templateType x, templateType y, templateType z ); + + /// \brief Write a normalized quaternion in 6 bytes + 4 bits instead of 16 bytes. Slightly lossy. + /// \param[in] w w + /// \param[in] x x + /// \param[in] y y + /// \param[in] z z + template // templateType for this function must be a float or double + void WriteNormQuat( templateType w, templateType x, templateType y, templateType z); + + /// \brief Write an orthogonal matrix by creating a quaternion, and writing 3 components of the quaternion in 2 bytes each. + /// \details Use 6 bytes instead of 36 + /// Lossy, although the result is renormalized + template // templateType for this function must be a float or double + void WriteOrthMatrix( + templateType m00, templateType m01, templateType m02, + templateType m10, templateType m11, templateType m12, + templateType m20, templateType m21, templateType m22 ); + + /// \brief Read an array or casted stream of byte. + /// \details The array is raw data. There is no automatic endian conversion with this function + /// \param[in] output The result byte array. It should be larger than @em numberOfBytes. + /// \param[in] numberOfBytes The number of byte to read + /// \return true on success false if there is some missing bytes. + bool Read( char* output, const unsigned int numberOfBytes ); + + /// \brief Read a float into 2 bytes, spanning the range between \a floatMin and \a floatMax + /// \param[in] outFloat The float to read + /// \param[in] floatMin Predetermined minimum value of f + /// \param[in] floatMax Predetermined maximum value of f + bool ReadFloat16( float &outFloat, float floatMin, float floatMax ); + + /// Read one type serialized to another (smaller) type, to save bandwidth + /// serializationType should be uint8_t, uint16_t, uint24_t, or uint32_t + /// Example: int num; ReadCasted(num); would read 1 bytefrom the stream, and put the value in an integer + /// \param[in] value The value to write + template + bool ReadCasted( sourceType &value ); + + /// Given the minimum and maximum values for an integer type, figure out the minimum number of bits to represent the range + /// Then read only those bits + /// \note A static is used so that the required number of bits for (maximum-minimum) is only calculated once. This does require that \a minimum and \maximum are fixed values for a given line of code for the life of the program + /// \param[in] value Integer value to read, which should be between \a minimum and \a maximum + /// \param[in] minimum Minimum value of \a value + /// \param[in] maximum Maximum value of \a value + /// \param[in] allowOutsideRange If true, all sends will take an extra bit, however value can deviate from outside \a minimum and \a maximum. If false, will assert if the value deviates. This should match the corresponding value passed to Write(). + template + bool ReadBitsFromIntegerRange( templateType &value, const templateType minimum, const templateType maximum, bool allowOutsideRange=false ); + /// \param[in] requiredBits Primarily for internal use, called from above function() after calculating number of bits needed to represent maximum-minimum + template + bool ReadBitsFromIntegerRange( templateType &value, const templateType minimum, const templateType maximum, const int requiredBits, bool allowOutsideRange=false ); + + /// \brief Read a normalized 3D vector, using (at most) 4 bytes + 3 bits instead of 12-24 bytes. + /// \details Will further compress y or z axis aligned vectors. + /// Accurate to 1/32767.5. + /// \param[in] x x + /// \param[in] y y + /// \param[in] z z + /// \return true on success, false on failure. + template // templateType for this function must be a float or double + bool ReadNormVector( templateType &x, templateType &y, templateType &z ); + + /// \brief Read 3 floats or doubles, using 10 bytes, where those float or doubles comprise a vector. + /// \details Loses accuracy to about 3/10ths and only saves 2 bytes, + /// so only use if accuracy is not important. + /// \param[in] x x + /// \param[in] y y + /// \param[in] z z + /// \return true on success, false on failure. + template // templateType for this function must be a float or double + bool ReadVector( templateType &x, templateType &y, templateType &z ); + + /// \brief Read a normalized quaternion in 6 bytes + 4 bits instead of 16 bytes. + /// \param[in] w w + /// \param[in] x x + /// \param[in] y y + /// \param[in] z z + /// \return true on success, false on failure. + template // templateType for this function must be a float or double + bool ReadNormQuat( templateType &w, templateType &x, templateType &y, templateType &z); + + /// \brief Read an orthogonal matrix from a quaternion, reading 3 components of the quaternion in 2 bytes each and extrapolatig the 4th. + /// \details Use 6 bytes instead of 36 + /// Lossy, although the result is renormalized + /// \return true on success, false on failure. + template // templateType for this function must be a float or double + bool ReadOrthMatrix( + templateType &m00, templateType &m01, templateType &m02, + templateType &m10, templateType &m11, templateType &m12, + templateType &m20, templateType &m21, templateType &m22 ); + + /// \brief Sets the read pointer back to the beginning of your data. + void ResetReadPointer( void ); + + /// \brief Sets the write pointer back to the beginning of your data. + void ResetWritePointer( void ); + + /// \brief This is good to call when you are done with the stream to make + /// sure you didn't leave any data left over void + void AssertStreamEmpty( void ); + + /// \brief RAKNET_DEBUG_PRINTF the bits in the stream. Great for debugging. + void PrintBits( char *out ) const; + void PrintBits( void ) const; + void PrintHex( char *out ) const; + void PrintHex( void ) const; + + /// \brief Ignore data we don't intend to read + /// \param[in] numberOfBits The number of bits to ignore + void IgnoreBits( const BitSize_t numberOfBits ); + + /// \brief Ignore data we don't intend to read + /// \param[in] numberOfBits The number of bytes to ignore + void IgnoreBytes( const unsigned int numberOfBytes ); + + /// \brief Move the write pointer to a position on the array. + /// \param[in] offset the offset from the start of the array. + /// \attention + /// \details Dangerous if you don't know what you are doing! + /// For efficiency reasons you can only write mid-stream if your data is byte aligned. + void SetWriteOffset( const BitSize_t offset ); + + /// \brief Returns the length in bits of the stream + inline BitSize_t GetNumberOfBitsUsed( void ) const {return GetWriteOffset();} + inline BitSize_t GetWriteOffset( void ) const {return numberOfBitsUsed;} + + /// \brief Returns the length in bytes of the stream + inline BitSize_t GetNumberOfBytesUsed( void ) const {return BITS_TO_BYTES( numberOfBitsUsed );} + + /// \brief Returns the number of bits into the stream that we have read + inline BitSize_t GetReadOffset( void ) const {return readOffset;} + + /// \brief Sets the read bit index + void SetReadOffset( const BitSize_t newReadOffset ) {readOffset=newReadOffset;} + + /// \brief Returns the number of bits left in the stream that haven't been read + inline BitSize_t GetNumberOfUnreadBits( void ) const {return numberOfBitsUsed - readOffset;} + + /// \brief Makes a copy of the internal data for you \a _data will point to + /// the stream. Partial bytes are left aligned. + /// \param[out] _data The allocated copy of GetData() + /// \return The length in bits of the stream. + BitSize_t CopyData( unsigned char** _data ) const; + + /// \internal + /// Set the stream to some initial data. + void SetData( unsigned char *inByteArray ); + + /// Gets the data that BitStream is writing to / reading from. + /// Partial bytes are left aligned. + /// \return A pointer to the internal state + inline char* GetData( void ) const {return (char*) data;} + + /// \brief Write numberToWrite bits from the input source. + /// \details Right aligned data means in the case of a partial byte, the bits are aligned + /// from the right (bit 0) rather than the left (as in the normal + /// internal representation) You would set this to true when + /// writing user data, and false when copying bitstream data, such + /// as writing one bitstream to another. + /// \param[in] inByteArray The data + /// \param[in] numberOfBitsToWrite The number of bits to write + /// \param[in] rightAlignedBits if true data will be right aligned + void WriteBits( const unsigned char* inByteArray, BitSize_t numberOfBitsToWrite, const bool rightAlignedBits = true ); + + /// \brief Align the bitstream to the byte boundary and then write the + /// specified number of bits. + /// \details This is faster than WriteBits but + /// wastes the bits to do the alignment and requires you to call + /// ReadAlignedBits at the corresponding read position. + /// \param[in] inByteArray The data + /// \param[in] numberOfBytesToWrite The size of input. + void WriteAlignedBytes( const unsigned char *inByteArray, const unsigned int numberOfBytesToWrite ); + + // Endian swap bytes already in the bitstream + void EndianSwapBytes( int byteOffset, int length ); + + /// \brief Aligns the bitstream, writes inputLength, and writes input. Won't write beyond maxBytesToWrite + /// \param[in] inByteArray The data + /// \param[in] inputLength The size of input. + /// \param[in] maxBytesToWrite Max bytes to write + void WriteAlignedBytesSafe( const char *inByteArray, const unsigned int inputLength, const unsigned int maxBytesToWrite ); + + /// \brief Read bits, starting at the next aligned bits. + /// \details Note that the modulus 8 starting offset of the sequence must be the same as + /// was used with WriteBits. This will be a problem with packet + /// coalescence unless you byte align the coalesced packets. + /// \param[in] inOutByteArray The byte array larger than @em numberOfBytesToRead + /// \param[in] numberOfBytesToRead The number of byte to read from the internal state + /// \return true if there is enough byte. + bool ReadAlignedBytes( unsigned char *inOutByteArray, const unsigned int numberOfBytesToRead ); + + /// \brief Reads what was written by WriteAlignedBytesSafe. + /// \param[in] inOutByteArray The data + /// \param[in] maxBytesToRead Maximum number of bytes to read + /// \return true on success, false on failure. + bool ReadAlignedBytesSafe( char *inOutByteArray, int &inputLength, const int maxBytesToRead ); + bool ReadAlignedBytesSafe( char *inOutByteArray, unsigned int &inputLength, const unsigned int maxBytesToRead ); + + /// \brief Same as ReadAlignedBytesSafe() but allocates the memory for you using new, rather than assuming it is safe to write to + /// \param[in] outByteArray outByteArray will be deleted if it is not a pointer to 0 + /// \return true on success, false on failure. + bool ReadAlignedBytesSafeAlloc( char **outByteArray, int &inputLength, const unsigned int maxBytesToRead ); + bool ReadAlignedBytesSafeAlloc( char **outByteArray, unsigned int &inputLength, const unsigned int maxBytesToRead ); + + /// \brief Align the next write and/or read to a byte boundary. + /// \details This can be used to 'waste' bits to byte align for efficiency reasons It + /// can also be used to force coalesced bitstreams to start on byte + /// boundaries so so WriteAlignedBits and ReadAlignedBits both + /// calculate the same offset when aligning. + inline void AlignWriteToByteBoundary( void ) {numberOfBitsUsed += 8 - ( (( numberOfBitsUsed - 1 ) & 7) + 1 );} + + /// \brief Align the next write and/or read to a byte boundary. + /// \details This can be used to 'waste' bits to byte align for efficiency reasons It + /// can also be used to force coalesced bitstreams to start on byte + /// boundaries so so WriteAlignedBits and ReadAlignedBits both + /// calculate the same offset when aligning. + inline void AlignReadToByteBoundary( void ) {readOffset += 8 - ( (( readOffset - 1 ) & 7 ) + 1 );} + + /// \brief Read \a numberOfBitsToRead bits to the output source. + /// \details alignBitsToRight should be set to true to convert internal + /// bitstream data to userdata. It should be false if you used + /// WriteBits with rightAlignedBits false + /// \param[in] inOutByteArray The resulting bits array + /// \param[in] numberOfBitsToRead The number of bits to read + /// \param[in] alignBitsToRight if true bits will be right aligned. + /// \return true if there is enough bits to read + bool ReadBits( unsigned char *inOutByteArray, BitSize_t numberOfBitsToRead, const bool alignBitsToRight = true ); + + /// \brief Write a 0 + void Write0( void ); + + /// \brief Write a 1 + void Write1( void ); + + /// \brief Reads 1 bit and returns true if that bit is 1 and false if it is 0. + bool ReadBit( void ); + + /// \brief If we used the constructor version with copy data off, this + /// *makes sure it is set to on and the data pointed to is copied. + void AssertCopyData( void ); + + /// \brief Use this if you pass a pointer copy to the constructor + /// *(_copyData==false) and want to overallocate to prevent + /// reallocation. + void SetNumberOfBitsAllocated( const BitSize_t lengthInBits ); + + /// \brief Reallocates (if necessary) in preparation of writing numberOfBitsToWrite + void AddBitsAndReallocate( const BitSize_t numberOfBitsToWrite ); + + /// \internal + /// \return How many bits have been allocated internally + BitSize_t GetNumberOfBitsAllocated(void) const; + + /// Write zeros until the bitstream is filled up to \a bytes + void PadWithZeroToByteLength( unsigned int bytes ); + + /// Get the number of leading zeros for a number + /// \param[in] x Number to test + static int NumberOfLeadingZeroes( uint8_t x ); + static int NumberOfLeadingZeroes( uint16_t x ); + static int NumberOfLeadingZeroes( uint32_t x ); + static int NumberOfLeadingZeroes( uint64_t x ); + static int NumberOfLeadingZeroes( int8_t x ); + static int NumberOfLeadingZeroes( int16_t x ); + static int NumberOfLeadingZeroes( int32_t x ); + static int NumberOfLeadingZeroes( int64_t x ); + + /// \internal Unrolled inner loop, for when performance is critical + void WriteAlignedVar8(const char *inByteArray); + /// \internal Unrolled inner loop, for when performance is critical + bool ReadAlignedVar8(char *inOutByteArray); + /// \internal Unrolled inner loop, for when performance is critical + void WriteAlignedVar16(const char *inByteArray); + /// \internal Unrolled inner loop, for when performance is critical + bool ReadAlignedVar16(char *inOutByteArray); + /// \internal Unrolled inner loop, for when performance is critical + void WriteAlignedVar32(const char *inByteArray); + /// \internal Unrolled inner loop, for when performance is critical + bool ReadAlignedVar32(char *inOutByteArray); + + inline void Write(const char * const inStringVar) + { + uint16_t l = (uint16_t) OVR_strlen(inStringVar); + Write(l); + WriteAlignedBytes((const unsigned char*) inStringVar, (const unsigned int) l); + } + inline void Write(const unsigned char * const inTemplateVar) + { + Write((const char*)inTemplateVar); + } + inline void Write(char * const inTemplateVar) + { + Write((const char*)inTemplateVar); + } + inline void Write(unsigned char * const inTemplateVar) + { + Write((const char*)inTemplateVar); + } + + /// ---- Member function template specialization declarations ---- + // Used for VC7 +#if defined(OVR_CC_MSVC) && _MSC_VER == 1300 + /// Write a bool to a bitstream. + /// \param[in] var The value to write + template <> + void Write(const bool &var); + + /// Write a RakNetGUID to a bitsteam + /// \param[in] var The value to write + template <> + void Write(const RakNetGuid &var); + + /// Write a string to a bitstream + /// \param[in] var The value to write + template <> + void Write(const char* const &var); + template <> + void Write(const unsigned char* const &var); + template <> + void Write(char* const &var); + template <> + void Write(unsigned char* const &var); + template <> + void Write(const OVR::String &var); + + /// \brief Write a bool delta. + /// \details Same thing as just calling Write + /// \param[in] currentValue The current value to write + /// \param[in] lastValue The last value to compare against + template <> + void WriteDelta(const bool ¤tValue, const bool &lastValue); + + template <> + void WriteCompressed(const bool &var); + + /// For values between -1 and 1 + template <> + void WriteCompressed(const float &var); + + /// For values between -1 and 1 + template <> + void WriteCompressed(const double &var); + + /// \brief Write a bool delta. + /// \details Same thing as just calling Write + /// \param[in] currentValue The current value to write + /// \param[in] lastValue The last value to compare against + template <> + void WriteCompressedDelta(const bool ¤tValue, const bool &lastValue); + + /// \brief Save as WriteCompressedDelta(bool currentValue, const templateType &lastValue) + /// when we have an unknown second bool + template <> + void WriteCompressedDelta(const bool ¤tValue); + + /// \brief Read a bool from a bitstream. + /// \param[in] var The value to read + /// \return true on success, false on failure. + template <> + bool Read(bool &var); + + /// \brief Read a String from a bitstream. + /// \param[in] var The value to read + /// \return true on success, false on failure. + template <> + bool Read(char *&var); + template <> + bool Read(wchar_t *&var); + template <> + bool Read(unsigned char *&var); + + /// \brief Read a bool from a bitstream. + /// \param[in] var The value to read + /// \return true on success, false on failure. + template <> + bool ReadDelta(bool &var); + + template <> + bool ReadCompressed(bool &var); + + template <> + bool ReadCompressed(float &var); + + /// For values between -1 and 1 + /// \return true on success, false on failure. + template <> + bool ReadCompressed(double &var); + + template <> + bool ReadCompressed(char* &var); + template <> + bool ReadCompressed(wchar_t* &var); + template <> + bool ReadCompressed(unsigned char *&var); + template <> + bool ReadCompressed(OVR::String &var); + + /// \brief Read a bool from a bitstream. + /// \param[in] var The value to read + /// \return true on success, false on failure. + template <> + bool ReadCompressedDelta(bool &var); +#endif + + inline static bool DoEndianSwap(void) { +#ifndef __BITSTREAM_NATIVE_END + return IsNetworkOrder()==false; +#else + return false; +#endif + } + inline static bool IsBigEndian(void) + { + return IsNetworkOrder(); + } + inline static bool IsNetworkOrder(void) {bool r = IsNetworkOrderInternal(); return r;} + // Not inline, won't compile on PC due to winsock include errors + static bool IsNetworkOrderInternal(void); + static void ReverseBytes(unsigned char *inByteArray, unsigned char *inOutByteArray, const unsigned int length); + static void ReverseBytesInPlace(unsigned char *inOutData,const unsigned int length); + +private: + + BitStream( const BitStream & /*invalid*/) : numberOfBitsUsed(0), numberOfBitsAllocated(0), readOffset(0),data(NULL), copyData(false) { + OVR_ASSERT(0); + } + + BitStream& operator = ( const BitStream& /*invalid*/ ) { + OVR_ASSERT(0); + static BitStream i; + return i; + } + + /// \brief Assume the input source points to a native type, compress and write it. + void WriteCompressed( const unsigned char* inByteArray, const unsigned int size, const bool unsignedData ); + + /// \brief Assume the input source points to a compressed native type. Decompress and read it. + bool ReadCompressed( unsigned char* inOutByteArray, const unsigned int size, const bool unsignedData ); + + + BitSize_t numberOfBitsUsed; + + BitSize_t numberOfBitsAllocated; + + BitSize_t readOffset; + + unsigned char *data; + + /// true if the internal buffer is copy of the data passed to the constructor + bool copyData; + + /// BitStreams that use less than BITSTREAM_STACK_ALLOCATION_SIZE use the stack, rather than the heap to store data. It switches over if BITSTREAM_STACK_ALLOCATION_SIZE is exceeded + unsigned char stackData[BITSTREAM_STACK_ALLOCATION_SIZE]; +}; + +template +inline bool BitStream::Serialize(bool writeToBitstream, templateType &inOutTemplateVar) +{ + if (writeToBitstream) + Write(inOutTemplateVar); + else + return Read(inOutTemplateVar); + return true; +} + +template +inline bool BitStream::SerializeDelta(bool writeToBitstream, templateType &inOutCurrentValue, const templateType &lastValue) +{ + if (writeToBitstream) + WriteDelta(inOutCurrentValue, lastValue); + else + return ReadDelta(inOutCurrentValue); + return true; +} + +template +inline bool BitStream::SerializeDelta(bool writeToBitstream, templateType &inOutCurrentValue) +{ + if (writeToBitstream) + WriteDelta(inOutCurrentValue); + else + return ReadDelta(inOutCurrentValue); + return true; +} + +template +inline bool BitStream::SerializeCompressed(bool writeToBitstream, templateType &inOutTemplateVar) +{ + if (writeToBitstream) + WriteCompressed(inOutTemplateVar); + else + return ReadCompressed(inOutTemplateVar); + return true; +} + +template +inline bool BitStream::SerializeCompressedDelta(bool writeToBitstream, templateType &inOutCurrentValue, const templateType &lastValue) +{ + if (writeToBitstream) + WriteCompressedDelta(inOutCurrentValue,lastValue); + else + return ReadCompressedDelta(inOutCurrentValue); + return true; +} +//Stoppedhere +template +inline bool BitStream::SerializeCompressedDelta(bool writeToBitstream, templateType &inOutCurrentValue) +{ + if (writeToBitstream) + WriteCompressedDelta(inOutCurrentValue); + else + return ReadCompressedDelta(inOutCurrentValue); + return true; +} + +inline bool BitStream::Serialize(bool writeToBitstream, char* inOutByteArray, const unsigned int numberOfBytes ) +{ + if (writeToBitstream) + Write(inOutByteArray, numberOfBytes); + else + return Read(inOutByteArray, numberOfBytes); + return true; +} + +template +bool BitStream::SerializeCasted( bool writeToBitstream, sourceType &value ) +{ + if (writeToBitstream) WriteCasted(value); + else return ReadCasted(value); + return true; +} + +template +bool BitStream::SerializeBitsFromIntegerRange( bool writeToBitstream, templateType &value, const templateType minimum, const templateType maximum, bool allowOutsideRange ) +{ + int requiredBits=BYTES_TO_BITS(sizeof(templateType))-NumberOfLeadingZeroes(templateType(maximum-minimum)); + return SerializeBitsFromIntegerRange(writeToBitstream,value,minimum,maximum,requiredBits,allowOutsideRange); +} +template +bool BitStream::SerializeBitsFromIntegerRange( bool writeToBitstream, templateType &value, const templateType minimum, const templateType maximum, const int requiredBits, bool allowOutsideRange ) +{ + if (writeToBitstream) WriteBitsFromIntegerRange(value,minimum,maximum,requiredBits,allowOutsideRange); + else return ReadBitsFromIntegerRange(value,minimum,maximum,requiredBits,allowOutsideRange); + return true; +} + +template +inline bool BitStream::SerializeNormVector(bool writeToBitstream, templateType &x, templateType &y, templateType &z ) +{ + if (writeToBitstream) + WriteNormVector(x,y,z); + else + return ReadNormVector(x,y,z); + return true; +} + +template +inline bool BitStream::SerializeVector(bool writeToBitstream, templateType &x, templateType &y, templateType &z ) +{ + if (writeToBitstream) + WriteVector(x,y,z); + else + return ReadVector(x,y,z); + return true; +} + +template +inline bool BitStream::SerializeNormQuat(bool writeToBitstream, templateType &w, templateType &x, templateType &y, templateType &z) +{ + if (writeToBitstream) + WriteNormQuat(w,x,y,z); + else + return ReadNormQuat(w,x,y,z); + return true; +} + +template +inline bool BitStream::SerializeOrthMatrix( + bool writeToBitstream, + templateType &m00, templateType &m01, templateType &m02, + templateType &m10, templateType &m11, templateType &m12, + templateType &m20, templateType &m21, templateType &m22 ) +{ + if (writeToBitstream) + WriteOrthMatrix(m00,m01,m02,m10,m11,m12,m20,m21,m22); + else + return ReadOrthMatrix(m00,m01,m02,m10,m11,m12,m20,m21,m22); + return true; +} + +inline bool BitStream::SerializeBits(bool writeToBitstream, unsigned char* inOutByteArray, const BitSize_t numberOfBitsToSerialize, const bool rightAlignedBits ) +{ + if (writeToBitstream) + WriteBits(inOutByteArray,numberOfBitsToSerialize,rightAlignedBits); + else + return ReadBits(inOutByteArray,numberOfBitsToSerialize,rightAlignedBits); + return true; +} + +template +inline void BitStream::Write(const templateType &inTemplateVar) +{ +#ifdef OVR_CC_MSVC +#pragma warning(disable:4127) // conditional expression is constant +#endif + if (sizeof(inTemplateVar)==1) + WriteBits( ( unsigned char* ) & inTemplateVar, sizeof( templateType ) * 8, true ); + else + { +#ifndef __BITSTREAM_NATIVE_END + if (DoEndianSwap()) + { + unsigned char output[sizeof(templateType)]; + ReverseBytes((unsigned char*)&inTemplateVar, output, sizeof(templateType)); + WriteBits( ( unsigned char* ) output, sizeof(templateType) * 8, true ); + } + else +#endif + WriteBits( ( unsigned char* ) & inTemplateVar, sizeof(templateType) * 8, true ); + } +} + +template +inline void BitStream::WritePtr(templateType *inTemplateVar) +{ +#ifdef OVR_CC_MSVC +#pragma warning(disable:4127) // conditional expression is constant +#endif + if (sizeof(templateType)==1) + WriteBits( ( unsigned char* ) inTemplateVar, sizeof( templateType ) * 8, true ); + else + { +#ifndef __BITSTREAM_NATIVE_END + if (DoEndianSwap()) + { + unsigned char output[sizeof(templateType)]; + ReverseBytes((unsigned char*) inTemplateVar, output, sizeof(templateType)); + WriteBits( ( unsigned char* ) output, sizeof(templateType) * 8, true ); + } + else +#endif + WriteBits( ( unsigned char* ) inTemplateVar, sizeof(templateType) * 8, true ); + } +} + +/// \brief Write a bool to a bitstream. +/// \param[in] inTemplateVar The value to write +template <> +inline void BitStream::Write(const bool &inTemplateVar) +{ + if ( inTemplateVar ) + Write1(); + else + Write0(); +} + + +/// \brief Write a string to a bitstream. +/// \param[in] var The value to write +template <> +inline void BitStream::Write(const OVR::String &inTemplateVar) +{ + uint16_t l = (uint16_t) inTemplateVar.GetLength(); + Write(l); + WriteAlignedBytes((const unsigned char*) inTemplateVar.ToCStr(), (const unsigned int) l); +} +template <> +inline void BitStream::Write(const char * const &inStringVar) +{ + uint16_t l = (uint16_t) strlen(inStringVar); + Write(l); + WriteAlignedBytes((const unsigned char*) inStringVar, (const unsigned int) l); +} +template <> +inline void BitStream::Write(const unsigned char * const &inTemplateVar) +{ + Write((const char*)inTemplateVar); +} +template <> +inline void BitStream::Write(char * const &inTemplateVar) +{ + Write((const char*)inTemplateVar); +} +template <> +inline void BitStream::Write(unsigned char * const &inTemplateVar) +{ + Write((const char*)inTemplateVar); +} + +/// \brief Write any integral type to a bitstream. +/// \details If the current value is different from the last value +/// the current value will be written. Otherwise, a single bit will be written +/// \param[in] currentValue The current value to write +/// \param[in] lastValue The last value to compare against +template +inline void BitStream::WriteDelta(const templateType ¤tValue, const templateType &lastValue) +{ + if (currentValue==lastValue) + { + Write(false); + } + else + { + Write(true); + Write(currentValue); + } +} + +/// \brief Write a bool delta. Same thing as just calling Write +/// \param[in] currentValue The current value to write +/// \param[in] lastValue The last value to compare against +template <> +inline void BitStream::WriteDelta(const bool ¤tValue, const bool &lastValue) +{ + (void) lastValue; + + Write(currentValue); +} + +/// \brief WriteDelta when you don't know what the last value is, or there is no last value. +/// \param[in] currentValue The current value to write +template +inline void BitStream::WriteDelta(const templateType ¤tValue) +{ + Write(true); + Write(currentValue); +} + +/// \brief Write any integral type to a bitstream. +/// \details Undefine __BITSTREAM_NATIVE_END if you need endian swapping. +/// For floating point, this is lossy, using 2 bytes for a float and 4 for a double. The range must be between -1 and +1. +/// For non-floating point, this is lossless, but only has benefit if you use less than half the bits of the type +/// If you are not using __BITSTREAM_NATIVE_END the opposite is true for types larger than 1 byte +/// \param[in] inTemplateVar The value to write +template +inline void BitStream::WriteCompressed(const templateType &inTemplateVar) +{ +#ifdef OVR_CC_MSVC +#pragma warning(disable:4127) // conditional expression is constant +#endif + if (sizeof(inTemplateVar)==1) + WriteCompressed( ( unsigned char* ) & inTemplateVar, sizeof( templateType ) * 8, true ); + else + { +#ifndef __BITSTREAM_NATIVE_END +#ifdef OVR_CC_MSVC +#pragma warning(disable:4244) // '=' : conversion from 'unsigned long' to 'uint16_t', possible loss of data +#endif + + if (DoEndianSwap()) + { + unsigned char output[sizeof(templateType)]; + ReverseBytes((unsigned char*)&inTemplateVar, output, sizeof(templateType)); + WriteCompressed( ( unsigned char* ) output, sizeof(templateType) * 8, true ); + } + else +#endif + WriteCompressed( ( unsigned char* ) & inTemplateVar, sizeof(templateType) * 8, true ); + } +} + +template <> +inline void BitStream::WriteCompressed(const bool &inTemplateVar) +{ + Write(inTemplateVar); +} + +/// For values between -1 and 1 +template <> +inline void BitStream::WriteCompressed(const float &inTemplateVar) +{ + OVR_ASSERT(inTemplateVar > -1.01f && inTemplateVar < 1.01f); + float varCopy=inTemplateVar; + if (varCopy < -1.0f) + varCopy=-1.0f; + if (varCopy > 1.0f) + varCopy=1.0f; + Write((uint16_t)((varCopy+1.0f)*32767.5f)); +} + +/// For values between -1 and 1 +template <> +inline void BitStream::WriteCompressed(const double &inTemplateVar) +{ + OVR_ASSERT(inTemplateVar > -1.01 && inTemplateVar < 1.01); + double varCopy=inTemplateVar; + if (varCopy < -1.0f) + varCopy=-1.0f; + if (varCopy > 1.0f) + varCopy=1.0f; + Write((uint32_t)((varCopy+1.0)*2147483648.0)); +} + +/// \brief Write any integral type to a bitstream. +/// \details If the current value is different from the last value +/// the current value will be written. Otherwise, a single bit will be written +/// For floating point, this is lossy, using 2 bytes for a float and 4 for a double. The range must be between -1 and +1. +/// For non-floating point, this is lossless, but only has benefit if you use less than half the bits of the type +/// If you are not using __BITSTREAM_NATIVE_END the opposite is true for types larger than 1 byte +/// \param[in] currentValue The current value to write +/// \param[in] lastValue The last value to compare against +template +inline void BitStream::WriteCompressedDelta(const templateType ¤tValue, const templateType &lastValue) +{ + if (currentValue==lastValue) + { + Write(false); + } + else + { + Write(true); + WriteCompressed(currentValue); + } +} + +/// \brief Write a bool delta. Same thing as just calling Write +/// \param[in] currentValue The current value to write +/// \param[in] lastValue The last value to compare against +template <> +inline void BitStream::WriteCompressedDelta(const bool ¤tValue, const bool &lastValue) +{ + (void) lastValue; + + Write(currentValue); +} + +/// \brief Save as WriteCompressedDelta(const templateType ¤tValue, const templateType &lastValue) +/// when we have an unknown second parameter +template +inline void BitStream::WriteCompressedDelta(const templateType ¤tValue) +{ + Write(true); + WriteCompressed(currentValue); +} + +/// \brief Save as WriteCompressedDelta(bool currentValue, const templateType &lastValue) +/// when we have an unknown second bool +template <> +inline void BitStream::WriteCompressedDelta(const bool ¤tValue) +{ + Write(currentValue); +} + +/// \brief Read any integral type from a bitstream. Define __BITSTREAM_NATIVE_END if you need endian swapping. +/// \param[in] outTemplateVar The value to read +template +inline bool BitStream::Read(templateType &outTemplateVar) +{ +#ifdef OVR_CC_MSVC +#pragma warning(disable:4127) // conditional expression is constant +#endif + if (sizeof(outTemplateVar)==1) + return ReadBits( ( unsigned char* ) &outTemplateVar, sizeof(templateType) * 8, true ); + else + { +#ifndef __BITSTREAM_NATIVE_END +#ifdef OVR_CC_MSVC +#pragma warning(disable:4244) // '=' : conversion from 'unsigned long' to 'uint16_t', possible loss of data +#endif + if (DoEndianSwap()) + { + unsigned char output[sizeof(templateType)]; + if (ReadBits( ( unsigned char* ) output, sizeof(templateType) * 8, true )) + { + ReverseBytes(output, (unsigned char*)&outTemplateVar, sizeof(templateType)); + return true; + } + return false; + } + else +#endif + return ReadBits( ( unsigned char* ) & outTemplateVar, sizeof(templateType) * 8, true ); + } +} + +/// \brief Read a bool from a bitstream. +/// \param[in] outTemplateVar The value to read +template <> +inline bool BitStream::Read(bool &outTemplateVar) +{ + if ( readOffset + 1 > numberOfBitsUsed ) + return false; + + if ( data[ readOffset >> 3 ] & ( 0x80 >> ( readOffset & 7 ) ) ) // Is it faster to just write it out here? + outTemplateVar = true; + else + outTemplateVar = false; + + // Has to be on a different line for Mac + readOffset++; + + return true; +} + +template <> +inline bool BitStream::Read(OVR::String &outTemplateVar) +{ + bool b; + uint16_t l; + b=Read(l); + if (b && l>0) + { + AlignReadToByteBoundary(); + outTemplateVar.AssignString((const char*) (data + ( readOffset >> 3 )), (size_t) l); + IgnoreBytes(l); + } + else + { + AlignReadToByteBoundary(); + } + return b; +} +template <> +inline bool BitStream::Read(char *&varString) +{ + bool b; + uint16_t l; + b=Read(l); + if (b && l>0) + { + memcpy(varString, data + ( readOffset >> 3 ), l); + IgnoreBytes(l); + } + else + { + AlignReadToByteBoundary(); + } + return b; +} +template <> +inline bool BitStream::Read(unsigned char *&varString) +{ + bool b; + uint16_t l; + b=Read(l); + if (b && l>0) + { + memcpy(varString, data + ( readOffset >> 3 ), l); + IgnoreBytes(l); + } + else + { + AlignReadToByteBoundary(); + } + return b; +} + +/// \brief Read any integral type from a bitstream. +/// \details If the written value differed from the value compared against in the write function, +/// var will be updated. Otherwise it will retain the current value. +/// ReadDelta is only valid from a previous call to WriteDelta +/// \param[in] outTemplateVar The value to read +template +inline bool BitStream::ReadDelta(templateType &outTemplateVar) +{ + bool dataWritten; + bool success; + success=Read(dataWritten); + if (dataWritten) + success=Read(outTemplateVar); + return success; +} + +/// \brief Read a bool from a bitstream. +/// \param[in] outTemplateVar The value to read +template <> +inline bool BitStream::ReadDelta(bool &outTemplateVar) +{ + return Read(outTemplateVar); +} + +/// \brief Read any integral type from a bitstream. +/// \details Undefine __BITSTREAM_NATIVE_END if you need endian swapping. +/// For floating point, this is lossy, using 2 bytes for a float and 4 for a double. The range must be between -1 and +1. +/// For non-floating point, this is lossless, but only has benefit if you use less than half the bits of the type +/// If you are not using __BITSTREAM_NATIVE_END the opposite is true for types larger than 1 byte +/// \param[in] outTemplateVar The value to read +template +inline bool BitStream::ReadCompressed(templateType &outTemplateVar) +{ +#ifdef OVR_CC_MSVC +#pragma warning(disable:4127) // conditional expression is constant +#endif + if (sizeof(outTemplateVar)==1) + return ReadCompressed( ( unsigned char* ) &outTemplateVar, sizeof(templateType) * 8, true ); + else + { +#ifndef __BITSTREAM_NATIVE_END + if (DoEndianSwap()) + { + unsigned char output[sizeof(templateType)]; + if (ReadCompressed( ( unsigned char* ) output, sizeof(templateType) * 8, true )) + { + ReverseBytes(output, (unsigned char*)&outTemplateVar, sizeof(templateType)); + return true; + } + return false; + } + else +#endif + return ReadCompressed( ( unsigned char* ) & outTemplateVar, sizeof(templateType) * 8, true ); + } +} + +template <> +inline bool BitStream::ReadCompressed(bool &outTemplateVar) +{ + return Read(outTemplateVar); +} + +/// For values between -1 and 1 +template <> +inline bool BitStream::ReadCompressed(float &outTemplateVar) +{ + uint16_t compressedFloat; + if (Read(compressedFloat)) + { + outTemplateVar = ((float)compressedFloat / 32767.5f - 1.0f); + return true; + } + return false; +} + +/// For values between -1 and 1 +template <> +inline bool BitStream::ReadCompressed(double &outTemplateVar) +{ + uint32_t compressedFloat; + if (Read(compressedFloat)) + { + outTemplateVar = ((double)compressedFloat / 2147483648.0 - 1.0); + return true; + } + return false; +} + +/// \brief Read any integral type from a bitstream. +/// \details If the written value differed from the value compared against in the write function, +/// var will be updated. Otherwise it will retain the current value. +/// the current value will be updated. +/// For floating point, this is lossy, using 2 bytes for a float and 4 for a double. The range must be between -1 and +1. +/// For non-floating point, this is lossless, but only has benefit if you use less than half the bits of the type +/// If you are not using __BITSTREAM_NATIVE_END the opposite is true for types larger than 1 byte +/// ReadCompressedDelta is only valid from a previous call to WriteDelta +/// \param[in] outTemplateVar The value to read +template +inline bool BitStream::ReadCompressedDelta(templateType &outTemplateVar) +{ + bool dataWritten; + bool success; + success=Read(dataWritten); + if (dataWritten) + success=ReadCompressed(outTemplateVar); + return success; +} + +/// \brief Read a bool from a bitstream. +/// \param[in] outTemplateVar The value to read +template <> +inline bool BitStream::ReadCompressedDelta(bool &outTemplateVar) +{ + return Read(outTemplateVar); +} + +template +void BitStream::WriteCasted( const sourceType &value ) +{ + destinationType val = (destinationType) value; + Write(val); +} + +template +void BitStream::WriteBitsFromIntegerRange( const templateType value, const templateType minimum,const templateType maximum, bool allowOutsideRange ) +{ + int requiredBits=BYTES_TO_BITS(sizeof(templateType))-NumberOfLeadingZeroes(templateType(maximum-minimum)); + WriteBitsFromIntegerRange(value,minimum,maximum,requiredBits,allowOutsideRange); +} +template +void BitStream::WriteBitsFromIntegerRange( const templateType value, const templateType minimum,const templateType maximum, const int requiredBits, bool allowOutsideRange ) +{ + OVR_ASSERT(maximum>=minimum); + OVR_ASSERT(allowOutsideRange==true || (value>=minimum && value<=maximum)); + if (allowOutsideRange) + { + if (valuemaximum) + { + Write(true); + Write(value); + return; + } + Write(false); + } + templateType valueOffMin=value-minimum; + if (IsBigEndian()==true) + { + unsigned char output[sizeof(templateType)]; + ReverseBytes((unsigned char*)&valueOffMin, output, sizeof(templateType)); + WriteBits(output,requiredBits); + } + else + { + WriteBits((unsigned char*) &valueOffMin,requiredBits); + } +} + +template // templateType for this function must be a float or double +void BitStream::WriteNormVector( templateType x, templateType y, templateType z ) +{ +#ifdef _DEBUG + OVR_ASSERT(x <= 1.01 && y <= 1.01 && z <= 1.01 && x >= -1.01 && y >= -1.01 && z >= -1.01); +#endif + + WriteFloat16((float)x,-1.0f,1.0f); + WriteFloat16((float)y,-1.0f,1.0f); + WriteFloat16((float)z,-1.0f,1.0f); +} + +template // templateType for this function must be a float or double +void BitStream::WriteVector( templateType x, templateType y, templateType z ) +{ + templateType magnitude = sqrt(x * x + y * y + z * z); + Write((float)magnitude); + if (magnitude > 0.00001f) + { + WriteCompressed((float)(x/magnitude)); + WriteCompressed((float)(y/magnitude)); + WriteCompressed((float)(z/magnitude)); + // Write((uint16_t)((x/magnitude+1.0f)*32767.5f)); + // Write((uint16_t)((y/magnitude+1.0f)*32767.5f)); + // Write((uint16_t)((z/magnitude+1.0f)*32767.5f)); + } +} + +template // templateType for this function must be a float or double +void BitStream::WriteNormQuat( templateType w, templateType x, templateType y, templateType z) +{ + Write((bool)(w<0.0)); + Write((bool)(x<0.0)); + Write((bool)(y<0.0)); + Write((bool)(z<0.0)); + Write((uint16_t)(fabs(x)*65535.0)); + Write((uint16_t)(fabs(y)*65535.0)); + Write((uint16_t)(fabs(z)*65535.0)); + // Leave out w and calculate it on the target +} + +template // templateType for this function must be a float or double +void BitStream::WriteOrthMatrix( + templateType m00, templateType m01, templateType m02, + templateType m10, templateType m11, templateType m12, + templateType m20, templateType m21, templateType m22 ) +{ + + double qw; + double qx; + double qy; + double qz; + + // Convert matrix to quat + // http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/ + float sum; + sum = 1 + m00 + m11 + m22; + if (sum < 0.0f) sum=0.0f; + qw = sqrt( sum ) / 2; + sum = 1 + m00 - m11 - m22; + if (sum < 0.0f) sum=0.0f; + qx = sqrt( sum ) / 2; + sum = 1 - m00 + m11 - m22; + if (sum < 0.0f) sum=0.0f; + qy = sqrt( sum ) / 2; + sum = 1 - m00 - m11 + m22; + if (sum < 0.0f) sum=0.0f; + qz = sqrt( sum ) / 2; + if (qw < 0.0) qw=0.0; + if (qx < 0.0) qx=0.0; + if (qy < 0.0) qy=0.0; + if (qz < 0.0) qz=0.0; +#ifdef OVR_OS_WIN32 + qx = _copysign( (double) qx, (double) (m21 - m12) ); + qy = _copysign( (double) qy, (double) (m02 - m20) ); + qz = _copysign( (double) qz, (double) (m10 - m01) ); +#else + qx = copysign( (double) qx, (double) (m21 - m12) ); + qy = copysign( (double) qy, (double) (m02 - m20) ); + qz = copysign( (double) qz, (double) (m10 - m01) ); +#endif + + WriteNormQuat(qw,qx,qy,qz); +} + +template +bool BitStream::ReadCasted( sourceType &value ) +{ + serializationType val; + bool success = Read(val); + value=(sourceType) val; + return success; +} + +template +bool BitStream::ReadBitsFromIntegerRange( templateType &value, const templateType minimum, const templateType maximum, bool allowOutsideRange ) +{ + int requiredBits=BYTES_TO_BITS(sizeof(templateType))-NumberOfLeadingZeroes(templateType(maximum-minimum)); + return ReadBitsFromIntegerRange(value,minimum,maximum,requiredBits,allowOutsideRange); +} +template +bool BitStream::ReadBitsFromIntegerRange( templateType &value, const templateType minimum, const templateType maximum, const int requiredBits, bool allowOutsideRange ) +{ + OVR_ASSERT_AND_UNUSED(maximum>=minimum, maximum); + if (allowOutsideRange) + { + bool isOutsideRange; + Read(isOutsideRange); + if (isOutsideRange) + return Read(value); + } + unsigned char output[sizeof(templateType)]; + memset(output,0,sizeof(output)); + bool success = ReadBits(output,requiredBits); + if (success) + { + if (IsBigEndian()==true) + ReverseBytesInPlace(output,sizeof(output)); + memcpy(&value,output,sizeof(output)); + + value+=minimum; + } + + return success; +} + +template // templateType for this function must be a float or double +bool BitStream::ReadNormVector( templateType &x, templateType &y, templateType &z ) +{ + float xIn,yIn,zIn; + ReadFloat16(xIn,-1.0f,1.0f); + ReadFloat16(yIn,-1.0f,1.0f); + ReadFloat16(zIn,-1.0f,1.0f); + x=xIn; + y=yIn; + z=zIn; + return true; +} + +template // templateType for this function must be a float or double +bool BitStream::ReadVector( templateType &x, templateType &y, templateType &z ) +{ + float magnitude; + //uint16_t sx,sy,sz; + if (!Read(magnitude)) + return false; + if (magnitude>0.00001f) + { + // Read(sx); + // Read(sy); + // if (!Read(sz)) + // return false; + // x=((float)sx / 32767.5f - 1.0f) * magnitude; + // y=((float)sy / 32767.5f - 1.0f) * magnitude; + // z=((float)sz / 32767.5f - 1.0f) * magnitude; + float cx=0.0f,cy=0.0f,cz=0.0f; + ReadCompressed(cx); + ReadCompressed(cy); + if (!ReadCompressed(cz)) + return false; + x=cx; + y=cy; + z=cz; + x*=magnitude; + y*=magnitude; + z*=magnitude; + } + else + { + x=0.0; + y=0.0; + z=0.0; + } + return true; +} + +template // templateType for this function must be a float or double +bool BitStream::ReadNormQuat( templateType &w, templateType &x, templateType &y, templateType &z) +{ + bool cwNeg=false, cxNeg=false, cyNeg=false, czNeg=false; + uint16_t cx,cy,cz; + Read(cwNeg); + Read(cxNeg); + Read(cyNeg); + Read(czNeg); + Read(cx); + Read(cy); + if (!Read(cz)) + return false; + + // Calculate w from x,y,z + x=(templateType)(cx/65535.0); + y=(templateType)(cy/65535.0); + z=(templateType)(cz/65535.0); + if (cxNeg) x=-x; + if (cyNeg) y=-y; + if (czNeg) z=-z; + float difference = 1.0f - x*x - y*y - z*z; + if (difference < 0.0f) + difference=0.0f; + w = (templateType)(sqrt(difference)); + if (cwNeg) + w=-w; + + return true; +} + +template // templateType for this function must be a float or double +bool BitStream::ReadOrthMatrix( + templateType &m00, templateType &m01, templateType &m02, + templateType &m10, templateType &m11, templateType &m12, + templateType &m20, templateType &m21, templateType &m22 ) +{ + float qw,qx,qy,qz; + if (!ReadNormQuat(qw,qx,qy,qz)) + return false; + + // Quat to orthogonal rotation matrix + // http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToMatrix/index.htm + double sqw = (double)qw*(double)qw; + double sqx = (double)qx*(double)qx; + double sqy = (double)qy*(double)qy; + double sqz = (double)qz*(double)qz; + m00 = (templateType)(sqx - sqy - sqz + sqw); // since sqw + sqx + sqy + sqz =1 + m11 = (templateType)(-sqx + sqy - sqz + sqw); + m22 = (templateType)(-sqx - sqy + sqz + sqw); + + double tmp1 = (double)qx*(double)qy; + double tmp2 = (double)qz*(double)qw; + m10 = (templateType)(2.0 * (tmp1 + tmp2)); + m01 = (templateType)(2.0 * (tmp1 - tmp2)); + + tmp1 = (double)qx*(double)qz; + tmp2 = (double)qy*(double)qw; + m20 =(templateType)(2.0 * (tmp1 - tmp2)); + m02 = (templateType)(2.0 * (tmp1 + tmp2)); + tmp1 = (double)qy*(double)qz; + tmp2 = (double)qx*(double)qw; + m21 = (templateType)(2.0 * (tmp1 + tmp2)); + m12 = (templateType)(2.0 * (tmp1 - tmp2)); + + return true; +} + +template +BitStream& operator<<(BitStream& out, templateType& c) +{ + out.Write(c); + return out; +} +template +BitStream& operator>>(BitStream& in, templateType& c) +{ + bool success = in.Read(c); + (void)success; + + OVR_ASSERT(success); + return in; +} + + +}} // OVR::Net + +#endif diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Net/OVR_MessageIDTypes.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Net/OVR_MessageIDTypes.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,39 @@ +/************************************************************************************ + +Filename : OVR_MessageIDTypes.h +Content : Enumeration list indicating what type of message is being sent +Created : July 3, 2014 +Authors : Kevin Jenkins + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +namespace OVR { namespace Net { + +/// First byte of a network message +typedef unsigned char MessageID; + +enum DefaultMessageIDTypes +{ + OVRID_RPC1, + OVRID_END = 128, + OVRID_LATENCY_TESTER_1, +}; + +}} // namespace OVR::Net diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Net/OVR_NetworkPlugin.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Net/OVR_NetworkPlugin.cpp Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,70 @@ +/************************************************************************************ + +Filename : OVR_NetworkPlugin.cpp +Content : Base class for an extension to the network objects. +Created : June 10, 2014 +Authors : Kevin Jenkins + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#include "OVR_NetworkPlugin.h" + +namespace OVR { namespace Net { namespace Plugins { + + +//----------------------------------------------------------------------------- +// Plugin identifier to assign next + +//static uint8_t pluginIdNext = 0; + + +//----------------------------------------------------------------------------- +// NetworkPlugin + +NetworkPlugin::NetworkPlugin() +{ + pSession = 0; + //PluginId = pluginIdNext++; +} + +NetworkPlugin::~NetworkPlugin() +{ +} + +void NetworkPlugin::OnAddedToSession(Session* _pSession) +{ + if (pSession != 0) + { + pSession->RemoveSessionListener(this); + } + + pSession = _pSession; +} + +void NetworkPlugin::OnRemovedFromSession(Session* _pSession) +{ + OVR_UNUSED(_pSession); + OVR_ASSERT(_pSession == pSession); + + pSession = 0; +} + + +}}} // OVR::Net::Plugins diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Net/OVR_NetworkPlugin.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Net/OVR_NetworkPlugin.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,60 @@ +/************************************************************************************ + +PublicHeader: n/a +Filename : OVR_NetworkPlugin.h +Content : Base class for an extension to the network objects. +Created : June 10, 2014 +Authors : Kevin Jenkins + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#ifndef OVR_NetworkPlugin_h +#define OVR_NetworkPlugin_h + +#include "OVR_Session.h" + +namespace OVR { namespace Net { namespace Plugins { + + +//----------------------------------------------------------------------------- +// NetworkPlugin + +// NetworkPlugins use Session and SessionListener to provide network functionality +// independent of the transport medium. +// Uses the chain of command design pattern such that plugins can invoke or intercept +// network events via the Session. +class NetworkPlugin : public SessionListener +{ +public: + NetworkPlugin(); + virtual ~NetworkPlugin(); + +protected: + virtual void OnAddedToSession(Session* _pSession); + virtual void OnRemovedFromSession(Session* _pSession); + + Session *pSession; + //uint8_t PluginId; +}; + + +}}} // OVR::Net::Plugins + +#endif diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Net/OVR_NetworkTypes.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Net/OVR_NetworkTypes.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,42 @@ +/************************************************************************************ + +PublicHeader: n/a +Filename : OVR_NetworkTypes.h +Content : Shared header for network types +Created : June 12, 2014 +Authors : Kevin Jenkins + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#ifndef OVR_NetworkTypes_h +#define OVR_NetworkTypes_h + +#include "../Kernel/OVR_Types.h" + +namespace OVR { namespace Net { + + +typedef uint64_t NetworkID; +const NetworkID InvalidNetworkID = ~((NetworkID)0); + + +} } // OVR::Net + +#endif diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Net/OVR_PacketizedTCPSocket.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Net/OVR_PacketizedTCPSocket.cpp Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,215 @@ +/************************************************************************************ + +Filename : OVR_PacketizedTCPSocket.cpp +Content : TCP with automated message framing. +Created : June 10, 2014 +Authors : Kevin Jenkins + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#include "OVR_PacketizedTCPSocket.h" + +namespace OVR { namespace Net { + + +//----------------------------------------------------------------------------- +// Constants + +static const int LENGTH_FIELD_BYTES = 4; + + +//----------------------------------------------------------------------------- +// PacketizedTCPSocket + +PacketizedTCPSocket::PacketizedTCPSocket() +{ + pRecvBuff = 0; + pRecvBuffSize = 0; + Transport = TransportType_PacketizedTCP; +} + +PacketizedTCPSocket::PacketizedTCPSocket(SocketHandle _sock, bool isListenSocket) : PacketizedTCPSocketBase(_sock, isListenSocket) +{ + pRecvBuff = 0; + pRecvBuffSize = 0; + Transport = TransportType_PacketizedTCP; +} + +PacketizedTCPSocket::~PacketizedTCPSocket() +{ + OVR_FREE(pRecvBuff); +} + +int PacketizedTCPSocket::Send(const void* pData, int bytes) +{ + Lock::Locker locker(&sendLock); + + if (bytes <= 0) + { + return -1; + } + + // Convert length to 4 endian-neutral bytes + uint32_t lengthWord = bytes; + uint8_t lengthBytes[LENGTH_FIELD_BYTES] = { + (uint8_t)lengthWord, + (uint8_t)(lengthWord >> 8), + (uint8_t)(lengthWord >> 16), + (uint8_t)(lengthWord >> 24) + }; + + int s = PacketizedTCPSocketBase::Send(lengthBytes, LENGTH_FIELD_BYTES); + if (s > 0) + { + return PacketizedTCPSocketBase::Send(pData,bytes); + } + else + { + return s; + } +} + +int PacketizedTCPSocket::SendAndConcatenate(const void** pDataArray, int* dataLengthArray, int arrayCount) +{ + Lock::Locker locker(&sendLock); + + if (arrayCount == 0) + return 0; + + int totalBytes = 0; + for (int i = 0; i < arrayCount; i++) + totalBytes += dataLengthArray[i]; + + // Convert length to 4 endian-neutral bytes + uint32_t lengthWord = totalBytes; + uint8_t lengthBytes[LENGTH_FIELD_BYTES] = { + (uint8_t)lengthWord, + (uint8_t)(lengthWord >> 8), + (uint8_t)(lengthWord >> 16), + (uint8_t)(lengthWord >> 24) + }; + + int s = PacketizedTCPSocketBase::Send(lengthBytes, LENGTH_FIELD_BYTES); + if (s > 0) + { + for (int i = 0; i < arrayCount; i++) + { + PacketizedTCPSocketBase::Send(pDataArray[i], dataLengthArray[i]); + } + } + + return s; +} + +void PacketizedTCPSocket::OnRecv(SocketEvent_TCP* eventHandler, uint8_t* pData, int bytesRead) +{ + uint8_t* dataSource = NULL; + int dataSourceSize = 0; + + recvBuffLock.DoLock(); + + if (pRecvBuff == NULL) + { + dataSource = pData; + dataSourceSize = bytesRead; + } + else + { + uint8_t* pRecvBuffNew = (uint8_t*)OVR_REALLOC(pRecvBuff, bytesRead + pRecvBuffSize); + if (!pRecvBuffNew) + { + OVR_FREE(pRecvBuff); + pRecvBuff = NULL; + pRecvBuffSize = 0; + recvBuffLock.Unlock(); + return; + } + else + { + pRecvBuff = pRecvBuffNew; + + memcpy(pRecvBuff + pRecvBuffSize, pData, bytesRead); + + dataSourceSize = pRecvBuffSize + bytesRead; + dataSource = pRecvBuff; + } + } + + int bytesReadFromStream; + while (bytesReadFromStream = BytesFromStream(dataSource, dataSourceSize), + LENGTH_FIELD_BYTES + bytesReadFromStream <= dataSourceSize) + { + dataSource += LENGTH_FIELD_BYTES; + dataSourceSize -= LENGTH_FIELD_BYTES; + + TCPSocket::OnRecv(eventHandler, dataSource, bytesReadFromStream); + + dataSource += bytesReadFromStream; + dataSourceSize -= bytesReadFromStream; + } + + if (dataSourceSize > 0) + { + if (dataSource != NULL) + { + if (pRecvBuff == NULL) + { + pRecvBuff = (uint8_t*)OVR_ALLOC(dataSourceSize); + if (!pRecvBuff) + { + pRecvBuffSize = 0; + recvBuffLock.Unlock(); + return; + } + else + { + memcpy(pRecvBuff, dataSource, dataSourceSize); + } + } + else + { + memmove(pRecvBuff, dataSource, dataSourceSize); + } + } + } + else + { + if (pRecvBuff != NULL) + OVR_FREE(pRecvBuff); + + pRecvBuff = NULL; + } + pRecvBuffSize = dataSourceSize; + + recvBuffLock.Unlock(); +} + +int PacketizedTCPSocket::BytesFromStream(uint8_t* pData, int bytesRead) +{ + if (pData != 0 && bytesRead >= LENGTH_FIELD_BYTES) + { + return pData[0] | ((uint32_t)pData[1] << 8) | ((uint32_t)pData[2] << 16) | ((uint32_t)pData[3] << 24); + } + + return 0; +} + + +}} // OVR::Net diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Net/OVR_PacketizedTCPSocket.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Net/OVR_PacketizedTCPSocket.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,87 @@ +/************************************************************************************ + +PublicHeader: n/a +Filename : OVR_PacketizedTCPSocket.cpp +Content : TCP with automated message framing. +Created : June 10, 2014 +Authors : Kevin Jenkins + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#ifndef OVR_PacketizedTCPSocket_h +#define OVR_PacketizedTCPSocket_h + +#include "OVR_Socket.h" +#include "../Kernel/OVR_Allocator.h" +#include "../Kernel/OVR_Atomic.h" + +#ifdef OVR_OS_WIN32 +#include "OVR_Win32_Socket.h" +#else +#include "OVR_Unix_Socket.h" +#endif + +namespace OVR { namespace Net { + + +//----------------------------------------------------------------------------- +// NetworkPlugin + +// Packetized TCP base socket +class PacketizedTCPSocketBase : public TCPSocket +{ +public: + PacketizedTCPSocketBase() {} + PacketizedTCPSocketBase(SocketHandle _sock, bool isListenSocket) : TCPSocket(_sock, isListenSocket) {} +}; + + +//----------------------------------------------------------------------------- +// PacketizedTCPSocket + +// Uses TCP but is message aligned rather than stream aligned +// Alternative to reliable UDP +class PacketizedTCPSocket : public PacketizedTCPSocketBase +{ +public: + PacketizedTCPSocket(); + PacketizedTCPSocket(SocketHandle _sock, bool isListenSocket); + virtual ~PacketizedTCPSocket(); + +public: + virtual int Send(const void* pData, int bytes); + virtual int SendAndConcatenate(const void** pDataArray, int *dataLengthArray, int arrayCount); + +protected: + virtual void OnRecv(SocketEvent_TCP* eventHandler, uint8_t* pData, int bytesRead); + + int BytesFromStream(uint8_t* pData, int bytesRead); + + Lock sendLock; + Lock recvBuffLock; + + uint8_t* pRecvBuff; // Queued receive buffered data + int pRecvBuffSize; // Size of receive queue in bytes +}; + + +}} // OVR::Net + +#endif diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Net/OVR_RPC1.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Net/OVR_RPC1.cpp Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,270 @@ +/************************************************************************************ + +Filename : OVR_RPC1.cpp +Content : A network plugin that provides remote procedure call functionality. +Created : June 10, 2014 +Authors : Kevin Jenkins + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#include "OVR_RPC1.h" +#include "OVR_BitStream.h" +#include "../Kernel/OVR_Threads.h" // Thread::MSleep +#include "OVR_MessageIDTypes.h" + +namespace OVR { namespace Net { namespace Plugins { + + +//----------------------------------------------------------------------------- +// Types + +enum { + ID_RPC4_SIGNAL, + CALL_BLOCKING, + RPC_ERROR_FUNCTION_NOT_REGISTERED, + ID_RPC4_RETURN, +}; + + +//----------------------------------------------------------------------------- +// RPC1 + +RPC1::RPC1() +{ + blockingOnThisConnection = 0; + blockingReturnValue = new BitStream(); +} + +RPC1::~RPC1() +{ + slotHash.Clear(); + delete blockingReturnValue; +} + +void RPC1::RegisterSlot(OVR::String sharedIdentifier, OVR::Observer* rpcSlotObserver ) +{ + slotHash.AddObserverToSubject(sharedIdentifier, rpcSlotObserver); +} + +bool RPC1::RegisterBlockingFunction(OVR::String uniqueID, RPCDelegate blockingFunction) +{ + if (registeredBlockingFunctions.Get(uniqueID)) + return false; + + registeredBlockingFunctions.Set(uniqueID, blockingFunction); + return true; +} + +void RPC1::UnregisterBlockingFunction(OVR::String uniqueID) +{ + registeredBlockingFunctions.Remove(uniqueID); +} + +bool RPC1::CallBlocking( OVR::String uniqueID, OVR::Net::BitStream* bitStream, Ptr pConnection, OVR::Net::BitStream* returnData ) +{ + // If invalid parameters, + if (!pConnection) + { + // Note: This may happen if the endpoint disconnects just before the call + return false; + } + + OVR::Net::BitStream out; + out.Write((MessageID) OVRID_RPC1); + out.Write((MessageID) CALL_BLOCKING); + out.Write(uniqueID); + if (bitStream) + { + bitStream->ResetReadPointer(); + out.AlignWriteToByteBoundary(); + out.Write(bitStream); + } + + SendParameters sp(pConnection, out.GetData(), out.GetNumberOfBytesUsed()); + + if (returnData) + { + returnData->Reset(); + } + + // Only one thread call at a time + Lock::Locker singleRPCLocker(&singleRPCLock); + + // Note this does not prevent multiple calls at a time because .Wait will unlock it below. + // The purpose of this mutex is to synchronize the polling thread and this one, not prevent + // multiple threads from invoking RPC. + Mutex::Locker locker(&callBlockingMutex); + + blockingReturnValue->Reset(); + blockingOnThisConnection = pConnection; + + int bytesSent = pSession->Send(&sp); + if (bytesSent == sp.Bytes) + { + while (blockingOnThisConnection == pConnection) + { + callBlockingWait.Wait(&callBlockingMutex); + } + } + else + { + return false; + } + + if (returnData) + { + returnData->Write(blockingReturnValue); + returnData->ResetReadPointer(); + } + + return true; +} + +bool RPC1::Signal(OVR::String sharedIdentifier, OVR::Net::BitStream* bitStream, Ptr pConnection) +{ + OVR::Net::BitStream out; + out.Write((MessageID) OVRID_RPC1); + out.Write((MessageID) ID_RPC4_SIGNAL); + //out.Write(PluginId); + out.Write(sharedIdentifier); + if (bitStream) + { + bitStream->ResetReadPointer(); + out.AlignWriteToByteBoundary(); + out.Write(bitStream); + } + SendParameters sp(pConnection, out.GetData(), out.GetNumberOfBytesUsed()); + int32_t bytesSent = pSession->Send(&sp); + return bytesSent == sp.Bytes; +} +void RPC1::BroadcastSignal(OVR::String sharedIdentifier, OVR::Net::BitStream* bitStream) +{ + OVR::Net::BitStream out; + out.Write((MessageID) OVRID_RPC1); + out.Write((MessageID) ID_RPC4_SIGNAL); + //out.Write(PluginId); + out.Write(sharedIdentifier); + if (bitStream) + { + bitStream->ResetReadPointer(); + out.AlignWriteToByteBoundary(); + out.Write(bitStream); + } + BroadcastParameters p(out.GetData(), out.GetNumberOfBytesUsed()); + pSession->Broadcast(&p); +} +void RPC1::OnReceive(ReceivePayload *pPayload, ListenerReceiveResult *lrrOut) +{ + OVR_UNUSED(lrrOut); + + if (pPayload->pData[0] == OVRID_RPC1) + { + OVR_ASSERT(pPayload->Bytes >= 2); + + OVR::Net::BitStream bsIn((char*)pPayload->pData, pPayload->Bytes, false); + bsIn.IgnoreBytes(2); + + if (pPayload->pData[1] == RPC_ERROR_FUNCTION_NOT_REGISTERED) + { + Mutex::Locker locker(&callBlockingMutex); + + blockingReturnValue->Reset(); + blockingOnThisConnection = 0; + callBlockingWait.NotifyAll(); + } + else if (pPayload->pData[1] == ID_RPC4_RETURN) + { + Mutex::Locker locker(&callBlockingMutex); + + blockingReturnValue->Reset(); + blockingReturnValue->Write(bsIn); + blockingOnThisConnection = 0; + callBlockingWait.NotifyAll(); + } + else if (pPayload->pData[1] == CALL_BLOCKING) + { + OVR::String uniqueId; + bsIn.Read(uniqueId); + + RPCDelegate *bf = registeredBlockingFunctions.Get(uniqueId); + if (bf==0) + { + OVR::Net::BitStream bsOut; + bsOut.Write((unsigned char) OVRID_RPC1); + bsOut.Write((unsigned char) RPC_ERROR_FUNCTION_NOT_REGISTERED); + + SendParameters sp(pPayload->pConnection, bsOut.GetData(), bsOut.GetNumberOfBytesUsed()); + pSession->Send(&sp); + + return; + } + + OVR::Net::BitStream returnData; + bsIn.AlignReadToByteBoundary(); + (*bf)(&bsIn, &returnData, pPayload); + + OVR::Net::BitStream out; + out.Write((MessageID) OVRID_RPC1); + out.Write((MessageID) ID_RPC4_RETURN); + returnData.ResetReadPointer(); + out.AlignWriteToByteBoundary(); + out.Write(returnData); + + SendParameters sp(pPayload->pConnection, out.GetData(), out.GetNumberOfBytesUsed()); + pSession->Send(&sp); + } + else if (pPayload->pData[1]==ID_RPC4_SIGNAL) + { + OVR::String sharedIdentifier; + bsIn.Read(sharedIdentifier); + + Observer *o = slotHash.GetSubject(sharedIdentifier); + + if (o) + { + bsIn.AlignReadToByteBoundary(); + + if (o) + { + OVR::Net::BitStream serializedParameters(bsIn.GetData() + bsIn.GetReadOffset()/8, bsIn.GetNumberOfUnreadBits()/8, false); + + o->Call(&serializedParameters, pPayload); + } + } + } + } +} + +void RPC1::OnDisconnected(Connection* conn) +{ + if (blockingOnThisConnection == conn) + { + blockingOnThisConnection = 0; + callBlockingWait.NotifyAll(); + } +} + +void RPC1::OnConnected(Connection* conn) +{ + OVR_UNUSED(conn); +} + + +}}} // OVR::Net::Plugins diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Net/OVR_RPC1.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Net/OVR_RPC1.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,105 @@ +/************************************************************************************ + +PublicHeader: n/a +Filename : OVR_RPC1.h +Content : A network plugin that provides remote procedure call functionality. +Created : June 10, 2014 +Authors : Kevin Jenkins + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#ifndef OVR_Net_RPC_h +#define OVR_Net_RPC_h + +#include "OVR_NetworkPlugin.h" +#include "../Kernel/OVR_Hash.h" +#include "../Kernel/OVR_String.h" +#include "OVR_BitStream.h" +#include "../Kernel/OVR_Threads.h" +#include "../Kernel/OVR_Delegates.h" +#include "../Kernel//OVR_Observer.h" + +namespace OVR { namespace Net { namespace Plugins { + + +typedef Delegate3 RPCDelegate; +typedef Delegate2 RPCSlot; +// typedef void ( *Slot ) ( OVR::Net::BitStream *userData, OVR::Net::ReceivePayload *pPayload ); + +/// NetworkPlugin that maps strings to function pointers. Can invoke the functions using blocking calls with return values, or signal/slots. Networked parameters serialized with BitStream +class RPC1 : public NetworkPlugin, public NewOverrideBase +{ +public: + RPC1(); + virtual ~RPC1(); + + /// Register a slot, which is a function pointer to one or more implementations that supports this function signature + /// When a signal occurs, all slots with the same identifier are called. + /// \param[in] sharedIdentifier A string to identify the slot. Recommended to be the same as the name of the function. + /// \param[in] functionPtr Pointer to the function. + /// \param[in] callPriority Slots are called by order of the highest callPriority first. For slots with the same priority, they are called in the order they are registered + void RegisterSlot(OVR::String sharedIdentifier, OVR::Observer *rpcSlotObserver); + + /// \brief Same as \a RegisterFunction, but is called with CallBlocking() instead of Call() and returns a value to the caller + bool RegisterBlockingFunction(OVR::String uniqueID, RPCDelegate blockingFunction); + + /// \brief Same as UnregisterFunction, except for a blocking function + void UnregisterBlockingFunction(OVR::String uniqueID); + + // \brief Same as call, but don't return until the remote system replies. + /// Broadcasting parameter does not exist, this can only call one remote system + /// \note This function does not return until the remote system responds, disconnects, or was never connected to begin with + /// \param[in] Identifier originally passed to RegisterBlockingFunction() on the remote system(s) + /// \param[in] bitStream bitStream encoded data to send to the function callback + /// \param[in] pConnection connection to send on + /// \param[out] returnData Written to by the function registered with RegisterBlockingFunction. + /// \return true if successfully called. False on disconnect, function not registered, or not connected to begin with + bool CallBlocking( OVR::String uniqueID, OVR::Net::BitStream * bitStream, Ptr pConnection, OVR::Net::BitStream *returnData = NULL ); + + /// Calls zero or more functions identified by sharedIdentifier registered with RegisterSlot() + /// \param[in] sharedIdentifier parameter of the same name passed to RegisterSlot() on the remote system + /// \param[in] bitStream bitStream encoded data to send to the function callback + /// \param[in] pConnection connection to send on + bool Signal(OVR::String sharedIdentifier, OVR::Net::BitStream * bitStream, Ptr pConnection); + void BroadcastSignal(OVR::String sharedIdentifier, OVR::Net::BitStream * bitStream); + + +protected: + virtual void OnReceive(ReceivePayload *pPayload, ListenerReceiveResult *lrrOut); + + virtual void OnDisconnected(Connection* conn); + virtual void OnConnected(Connection* conn); + + Hash< String, RPCDelegate, String::HashFunctor > registeredBlockingFunctions; + ObserverHash< RPCSlot > slotHash; + + // Synchronization for RPC caller + Lock singleRPCLock; + Mutex callBlockingMutex; + WaitCondition callBlockingWait; + + Net::BitStream* blockingReturnValue; + Ptr blockingOnThisConnection; +}; + + +}}} // OVR::Net::Plugins + +#endif // OVR_Net_RPC_h diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Net/OVR_Session.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Net/OVR_Session.cpp Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,736 @@ +/************************************************************************************ + +Filename : OVR_Session.h +Content : One network session that provides connection/disconnection events. +Created : June 10, 2014 +Authors : Kevin Jenkins, Chris Taylor + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#include "OVR_Session.h" +#include "OVR_PacketizedTCPSocket.h" +#include "../Kernel/OVR_Log.h" +#include "../Service/Service_NetSessionCommon.h" + +namespace OVR { namespace Net { + + +//----------------------------------------------------------------------------- +// Protocol + +static const char* OfficialHelloString = "OculusVR_Hello"; +static const char* OfficialAuthorizedString = "OculusVR_Authorized"; + +void RPC_C2S_Hello::Generate(Net::BitStream* bs) +{ + RPC_C2S_Hello hello; + hello.HelloString = OfficialHelloString; + hello.MajorVersion = RPCVersion_Major; + hello.MinorVersion = RPCVersion_Minor; + hello.PatchVersion = RPCVersion_Patch; + hello.Serialize(bs); +} + +bool RPC_C2S_Hello::Validate() +{ + return MajorVersion == RPCVersion_Major && + MinorVersion <= RPCVersion_Minor && + HelloString.CompareNoCase(OfficialHelloString) == 0; +} + +void RPC_S2C_Authorization::Generate(Net::BitStream* bs, String errorString) +{ + RPC_S2C_Authorization auth; + if (errorString.IsEmpty()) + { + auth.AuthString = OfficialAuthorizedString; + } + else + { + auth.AuthString = errorString; + } + auth.MajorVersion = RPCVersion_Major; + auth.MinorVersion = RPCVersion_Minor; + auth.PatchVersion = RPCVersion_Patch; + auth.Serialize(bs); +} + +bool RPC_S2C_Authorization::Validate() +{ + return AuthString.CompareNoCase(OfficialAuthorizedString) == 0; +} + + +//----------------------------------------------------------------------------- +// Session + +void Session::Shutdown() +{ + { + Lock::Locker locker(&SocketListenersLock); + + const int count = SocketListeners.GetSizeI(); + for (int i = 0; i < count; ++i) + { + SocketListeners[i]->Close(); + } + } + + Lock::Locker locker(&ConnectionsLock); + + const int count = AllConnections.GetSizeI(); + for (int i = 0; i < count; ++i) + { + Connection* arrayItem = AllConnections[i].GetPtr(); + + if (arrayItem->Transport == TransportType_PacketizedTCP) + { + PacketizedTCPConnection* ptcp = (PacketizedTCPConnection*)arrayItem; + + ptcp->pSocket->Close(); + } + } +} + +SessionResult Session::Listen(ListenerDescription* pListenerDescription) +{ + if (pListenerDescription->Transport == TransportType_PacketizedTCP) + { + BerkleyListenerDescription* bld = (BerkleyListenerDescription*)pListenerDescription; + TCPSocket* tcpSocket = (TCPSocket*)bld->BoundSocketToListenWith.GetPtr(); + + if (tcpSocket->Listen() < 0) + { + return SessionResult_ListenFailure; + } + + Lock::Locker locker(&SocketListenersLock); + SocketListeners.PushBack(tcpSocket); + } + else if (pListenerDescription->Transport == TransportType_Loopback) + { + HasLoopbackListener = true; + } + else + { + OVR_ASSERT(false); + } + + return SessionResult_OK; +} + +SessionResult Session::Connect(ConnectParameters *cp) +{ + if (cp->Transport == TransportType_PacketizedTCP) + { + ConnectParametersBerkleySocket* cp2 = (ConnectParametersBerkleySocket*)cp; + Ptr c; + + { + Lock::Locker locker(&ConnectionsLock); + + int connIndex; + Ptr conn = findConnectionBySocket(AllConnections, cp2->BoundSocketToConnectWith, &connIndex); + if (conn) + { + return SessionResult_AlreadyConnected; + } + + TCPSocketBase* tcpSock = (TCPSocketBase*)cp2->BoundSocketToConnectWith.GetPtr(); + + int ret = tcpSock->Connect(&cp2->RemoteAddress); + if (ret < 0) + { + return SessionResult_ConnectFailure; + } + + Ptr newConnection = AllocConnection(cp2->Transport); + if (!newConnection) + { + return SessionResult_ConnectFailure; + } + + c = (PacketizedTCPConnection*)newConnection.GetPtr(); + c->pSocket = (TCPSocket*) cp2->BoundSocketToConnectWith.GetPtr(); + c->Address = cp2->RemoteAddress; + c->Transport = cp2->Transport; + c->SetState(Client_Connecting); + + AllConnections.PushBack(c); + + } + + if (cp2->Blocking) + { + c->WaitOnConnecting(); + } + + if (c->State == State_Connected) + { + return SessionResult_OK; + } + else if (c->State == Client_Connecting) + { + return SessionResult_ConnectInProgress; + } + else + { + return SessionResult_ConnectFailure; + } + } + else if (cp->Transport == TransportType_Loopback) + { + if (HasLoopbackListener) + { + Ptr c = AllocConnection(cp->Transport); + if (!c) + { + return SessionResult_ConnectFailure; + } + + c->Transport = cp->Transport; + c->SetState(State_Connected); + + { + Lock::Locker locker(&ConnectionsLock); + AllConnections.PushBack(c); + } + + invokeSessionEvent(&SessionListener::OnConnectionRequestAccepted, c); + } + else + { + OVR_ASSERT(false); + } + } + else + { + OVR_ASSERT(false); + } + + return SessionResult_OK; +} + +SessionResult Session::ListenPTCP(OVR::Net::BerkleyBindParameters *bbp) +{ + Ptr listenSocket = *new OVR::Net::PacketizedTCPSocket(); + if (listenSocket->Bind(bbp) == INVALID_SOCKET) + { + return SessionResult_BindFailure; + } + + BerkleyListenerDescription bld; + bld.BoundSocketToListenWith = listenSocket.GetPtr(); + bld.Transport = TransportType_PacketizedTCP; + + return Listen(&bld); +} + +SessionResult Session::ConnectPTCP(OVR::Net::BerkleyBindParameters* bbp, SockAddr* remoteAddress, bool blocking) +{ + ConnectParametersBerkleySocket cp(NULL, remoteAddress, blocking, TransportType_PacketizedTCP); + Ptr connectSocket = *new PacketizedTCPSocket(); + + cp.BoundSocketToConnectWith = connectSocket.GetPtr(); + if (connectSocket->Bind(bbp) == INVALID_SOCKET) + { + return SessionResult_BindFailure; + } + + return Connect(&cp); +} + +Ptr Session::findConnectionBySockAddr(SockAddr* address) +{ + const int count = AllConnections.GetSizeI(); + for (int i = 0; i < count; ++i) + { + Connection* arrayItem = AllConnections[i].GetPtr(); + + if (arrayItem->Transport == TransportType_PacketizedTCP) + { + PacketizedTCPConnection* conn = (PacketizedTCPConnection*)arrayItem; + + if (conn->Address == *address) + { + return conn; + } + } + } + + return 0; +} + +int Session::Send(SendParameters *payload) +{ + if (payload->pConnection->Transport == TransportType_Loopback) + { + Lock::Locker locker(&SessionListenersLock); + + const int count = SessionListeners.GetSizeI(); + for (int i = 0; i < count; ++i) + { + SessionListener* sl = SessionListeners[i]; + + // FIXME: This looks like it needs to be reviewed at some point.. + ReceivePayload rp; + rp.Bytes = payload->Bytes; + rp.pConnection = payload->pConnection; + rp.pData = (uint8_t*)payload->pData; // FIXME + ListenerReceiveResult lrr = LRR_CONTINUE; + sl->OnReceive(&rp, &lrr); + if (lrr == LRR_RETURN) + { + return payload->Bytes; + } + else if (lrr == LRR_BREAK) + { + break; + } + } + + return payload->Bytes; + } + else if (payload->pConnection->Transport == TransportType_PacketizedTCP) + { + PacketizedTCPConnection* conn = (PacketizedTCPConnection*)payload->pConnection.GetPtr(); + + return conn->pSocket->Send(payload->pData, payload->Bytes); + } + else + { + OVR_ASSERT(false); + } + + return 0; +} +void Session::Broadcast(BroadcastParameters *payload) +{ + SendParameters sp; + sp.Bytes=payload->Bytes; + sp.pData=payload->pData; + + { + Lock::Locker locker(&ConnectionsLock); + + const int connectionCount = FullConnections.GetSizeI(); + for (int i = 0; i < connectionCount; ++i) + { + sp.pConnection = FullConnections[i]; + Send(&sp); + } + } +} +// DO NOT CALL Poll() FROM MULTIPLE THREADS due to allBlockingTcpSockets being a member +void Session::Poll(bool listeners) +{ + allBlockingTcpSockets.Clear(); + + if (listeners) + { + Lock::Locker locker(&SocketListenersLock); + + const int listenerCount = SocketListeners.GetSizeI(); + for (int i = 0; i < listenerCount; ++i) + { + allBlockingTcpSockets.PushBack(SocketListeners[i]); + } + } + + { + Lock::Locker locker(&ConnectionsLock); + + const int connectionCount = AllConnections.GetSizeI(); + for (int i = 0; i < connectionCount; ++i) + { + Connection* arrayItem = AllConnections[i].GetPtr(); + + if (arrayItem->Transport == TransportType_PacketizedTCP) + { + PacketizedTCPConnection* ptcp = (PacketizedTCPConnection*)arrayItem; + + allBlockingTcpSockets.PushBack(ptcp->pSocket); + } + else + { + OVR_ASSERT(false); + } + } + } + + const int count = allBlockingTcpSockets.GetSizeI(); + if (count > 0) + { + TCPSocketPollState state; + + // Add all the sockets for polling, + for (int i = 0; i < count; ++i) + { + Net::TCPSocket* sock = allBlockingTcpSockets[i].GetPtr(); + + // If socket handle is invalid, + if (sock->GetSocketHandle() == INVALID_SOCKET) + { + OVR_DEBUG_LOG(("[Session] Detected an invalid socket handle - Treating it as a disconnection.")); + sock->IsConnecting = false; + TCP_OnClosed(sock); + } + else + { + state.Add(sock); + } + } + + // If polling returns with an event, + if (state.Poll(allBlockingTcpSockets[0]->GetBlockingTimeoutUsec(), allBlockingTcpSockets[0]->GetBlockingTimeoutSec())) + { + // Handle any events for each socket + for (int i = 0; i < count; ++i) + { + state.HandleEvent(allBlockingTcpSockets[i], this); + } + } + } +} + +void Session::AddSessionListener(SessionListener* se) +{ + Lock::Locker locker(&SessionListenersLock); + + const int count = SessionListeners.GetSizeI(); + for (int i = 0; i < count; ++i) + { + if (SessionListeners[i] == se) + { + // Already added + return; + } + } + + SessionListeners.PushBack(se); + se->OnAddedToSession(this); +} + +void Session::RemoveSessionListener(SessionListener* se) +{ + Lock::Locker locker(&SessionListenersLock); + + const int count = SessionListeners.GetSizeI(); + for (int i = 0; i < count; ++i) + { + if (SessionListeners[i] == se) + { + se->OnRemovedFromSession(this); + + SessionListeners.RemoveAtUnordered(i); + break; + } + } +} +SInt32 Session::GetActiveSocketsCount() +{ + Lock::Locker locker1(&SocketListenersLock); + Lock::Locker locker2(&ConnectionsLock); + return SocketListeners.GetSize() + AllConnections.GetSize()>0; +} +Ptr Session::AllocConnection(TransportType transport) +{ + switch (transport) + { + case TransportType_Loopback: return *new Connection(); + case TransportType_TCP: return *new TCPConnection(); + case TransportType_PacketizedTCP: return *new PacketizedTCPConnection(); + default: + OVR_ASSERT(false); + break; + } + + return NULL; +} + +Ptr Session::findConnectionBySocket(Array< Ptr >& connectionArray, Socket* s, int *connectionIndex) +{ + const int count = connectionArray.GetSizeI(); + for (int i = 0; i < count; ++i) + { + Connection* arrayItem = connectionArray[i].GetPtr(); + + if (arrayItem->Transport == TransportType_PacketizedTCP) + { + PacketizedTCPConnection* ptc = (PacketizedTCPConnection*)arrayItem; + + if (ptc->pSocket == s) + { + if (connectionIndex) + { + *connectionIndex = i; + } + return ptc; + } + } + } + + return NULL; +} + +int Session::invokeSessionListeners(ReceivePayload* rp) +{ + Lock::Locker locker(&SessionListenersLock); + + const int count = SessionListeners.GetSizeI(); + for (int j = 0; j < count; ++j) + { + ListenerReceiveResult lrr = LRR_CONTINUE; + SessionListeners[j]->OnReceive(rp, &lrr); + + if (lrr == LRR_RETURN || lrr == LRR_BREAK) + { + break; + } + } + + return rp->Bytes; +} + +void Session::TCP_OnRecv(Socket* pSocket, uint8_t* pData, int bytesRead) +{ + // KevinJ: 9/2/2014 Fix deadlock - Watchdog calls Broadcast(), which locks ConnectionsLock(). + // Lock::Locker locker(&ConnectionsLock); + + // Look for the connection in the full connection list first + int connIndex; + ConnectionsLock.DoLock(); + Ptr conn = findConnectionBySocket(AllConnections, pSocket, &connIndex); + ConnectionsLock.Unlock(); + if (conn) + { + if (conn->State == State_Connected) + { + ReceivePayload rp; + rp.Bytes = bytesRead; + rp.pConnection = conn; + rp.pData = pData; + + // Call listeners + invokeSessionListeners(&rp); + } + else if (conn->State == Client_ConnectedWait) + { + // Check the version data from the message + BitStream bsIn((char*)pData, bytesRead, false); + + RPC_S2C_Authorization auth; + if (!auth.Deserialize(&bsIn) || + !auth.Validate()) + { + LogError("{ERR-001} [Session] REJECTED: OVRService did not authorize us: %s", auth.AuthString.ToCStr()); + + conn->SetState(State_Zombie); + invokeSessionEvent(&SessionListener::OnIncompatibleProtocol, conn); + } + else + { + // Read remote version + conn->RemoteMajorVersion = auth.MajorVersion; + conn->RemoteMinorVersion = auth.MinorVersion; + conn->RemotePatchVersion = auth.PatchVersion; + + // Mark as connected + conn->SetState(State_Connected); + ConnectionsLock.DoLock(); + int connIndex2; + if (findConnectionBySocket(AllConnections, pSocket, &connIndex2)==conn && findConnectionBySocket(FullConnections, pSocket, &connIndex2)==NULL) + { + FullConnections.PushBack(conn); + } + ConnectionsLock.Unlock(); + invokeSessionEvent(&SessionListener::OnConnectionRequestAccepted, conn); + } + } + else if (conn->State == Server_ConnectedWait) + { + // Check the version data from the message + BitStream bsIn((char*)pData, bytesRead, false); + + RPC_C2S_Hello hello; + if (!hello.Deserialize(&bsIn) || + !hello.Validate()) + { + LogError("{ERR-002} [Session] REJECTED: Rift application is using an incompatible version %d.%d.%d (my version=%d.%d.%d)", + hello.MajorVersion, hello.MinorVersion, hello.PatchVersion, + RPCVersion_Major, RPCVersion_Minor, RPCVersion_Patch); + + conn->SetState(State_Zombie); + + // Send auth response + BitStream bsOut; + RPC_S2C_Authorization::Generate(&bsOut, "Incompatible protocol version. Please make sure your OVRService and SDK are both up to date."); + conn->pSocket->Send(bsOut.GetData(), bsOut.GetNumberOfBytesUsed()); + } + else + { + // Read remote version + conn->RemoteMajorVersion = hello.MajorVersion; + conn->RemoteMinorVersion = hello.MinorVersion; + conn->RemotePatchVersion = hello.PatchVersion; + + // Send auth response + BitStream bsOut; + RPC_S2C_Authorization::Generate(&bsOut); + conn->pSocket->Send(bsOut.GetData(), bsOut.GetNumberOfBytesUsed()); + + // Mark as connected + conn->SetState(State_Connected); + ConnectionsLock.DoLock(); + int connIndex2; + if (findConnectionBySocket(AllConnections, pSocket, &connIndex2)==conn && findConnectionBySocket(FullConnections, pSocket, &connIndex2)==NULL) + { + FullConnections.PushBack(conn); + } + ConnectionsLock.Unlock(); + invokeSessionEvent(&SessionListener::OnNewIncomingConnection, conn); + + } + } + else + { + OVR_ASSERT(false); + } + } +} + +void Session::TCP_OnClosed(TCPSocket* s) +{ + Lock::Locker locker(&ConnectionsLock); + + // If found in the full connection list, + int connIndex; + Ptr conn = findConnectionBySocket(AllConnections, s, &connIndex); + if (conn) + { + AllConnections.RemoveAtUnordered(connIndex); + + // If in the full connection list, + if (findConnectionBySocket(FullConnections, s, &connIndex)) + { + FullConnections.RemoveAtUnordered(connIndex); + } + + // Generate an appropriate event for the current state + switch (conn->State) + { + case Client_Connecting: + invokeSessionEvent(&SessionListener::OnConnectionAttemptFailed, conn); + break; + case Client_ConnectedWait: + case Server_ConnectedWait: + invokeSessionEvent(&SessionListener::OnHandshakeAttemptFailed, conn); + break; + case State_Connected: + case State_Zombie: + invokeSessionEvent(&SessionListener::OnDisconnected, conn); + break; + default: + OVR_ASSERT(false); + break; + } + + conn->SetState(State_Zombie); + } +} + +void Session::TCP_OnAccept(TCPSocket* pListener, SockAddr* pSockAddr, SocketHandle newSock) +{ + OVR_UNUSED(pListener); + OVR_ASSERT(pListener->Transport == TransportType_PacketizedTCP); + + + Ptr newSocket = *new PacketizedTCPSocket(newSock, false); + // If pSockAddr is not localhost, then close newSock + if (pSockAddr->IsLocalhost()==false) + { + newSocket->Close(); + return; + } + + if (newSocket) + { + Ptr b = AllocConnection(TransportType_PacketizedTCP); + Ptr c = (PacketizedTCPConnection*)b.GetPtr(); + c->pSocket = newSocket; + c->Address = *pSockAddr; + c->State = Server_ConnectedWait; + + { + Lock::Locker locker(&ConnectionsLock); + AllConnections.PushBack(c); + } + + // Server does not send the first packet. It waits for the client to send its version + } +} + +void Session::TCP_OnConnected(TCPSocket *s) +{ + Lock::Locker locker(&ConnectionsLock); + + // If connection was found, + PacketizedTCPConnection* conn = findConnectionBySocket(AllConnections, s); + if (conn) + { + OVR_ASSERT(conn->State == Client_Connecting); + + // Send hello message + BitStream bsOut; + RPC_C2S_Hello::Generate(&bsOut); + conn->pSocket->Send(bsOut.GetData(), bsOut.GetNumberOfBytesUsed()); + + // Just update state but do not generate any notifications yet + conn->State = Client_ConnectedWait; + } +} + +void Session::invokeSessionEvent(void(SessionListener::*f)(Connection*), Connection* conn) +{ + Lock::Locker locker(&SessionListenersLock); + + const int count = SessionListeners.GetSizeI(); + for (int i = 0; i < count; ++i) + { + (SessionListeners[i]->*f)(conn); + } +} + +Ptr Session::GetConnectionAtIndex(int index) +{ + Lock::Locker locker(&ConnectionsLock); + + const int count = FullConnections.GetSizeI(); + + if (index < count) + { + return FullConnections[index]; + } + + return NULL; +} + + +}} // OVR::Net diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Net/OVR_Session.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Net/OVR_Session.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,513 @@ +/************************************************************************************ + +PublicHeader: n/a +Filename : OVR_Session.h +Content : One network session that provides connection/disconnection events. +Created : June 10, 2014 +Authors : Kevin Jenkins, Chris Taylor + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#ifndef OVR_Session_h +#define OVR_Session_h + +#include "OVR_Socket.h" +#include "OVR_PacketizedTCPSocket.h" +#include "../Kernel/OVR_Array.h" +#include "../Kernel/OVR_Threads.h" +#include "../Kernel/OVR_Atomic.h" +#include "../Kernel/OVR_RefCount.h" + +namespace OVR { namespace Net { + +class Session; + + +//----------------------------------------------------------------------------- +// Based on Semantic Versioning ( http://semver.org/ ) +// +// Please update changelog below: +// 1.0.0 - [SDK 0.4.0] Initial version (July 21, 2014) +// 1.1.0 - Add Get/SetDriverMode_1, HMDCountUpdate_1 +// Version mismatch results (July 28, 2014) +//----------------------------------------------------------------------------- + +static const uint16_t RPCVersion_Major = 1; // MAJOR version when you make incompatible API changes, +static const uint16_t RPCVersion_Minor = 2; // MINOR version when you add functionality in a backwards-compatible manner, and +static const uint16_t RPCVersion_Patch = 0; // PATCH version when you make backwards-compatible bug fixes. + +// Client starts communication by sending its version number. +struct RPC_C2S_Hello +{ + RPC_C2S_Hello() : + MajorVersion(0), + MinorVersion(0), + PatchVersion(0) + { + } + + String HelloString; + + // Client version info + uint16_t MajorVersion, MinorVersion, PatchVersion; + + void Serialize(Net::BitStream* bs) + { + bs->Write(HelloString); + bs->Write(MajorVersion); + bs->Write(MinorVersion); + bs->Write(PatchVersion); + } + + bool Deserialize(Net::BitStream* bs) + { + bs->Read(HelloString); + bs->Read(MajorVersion); + bs->Read(MinorVersion); + return bs->Read(PatchVersion); + } + + static void Generate(Net::BitStream* bs); + + bool Validate(); +}; + +// Server responds with an authorization accepted message, including the server's version number +struct RPC_S2C_Authorization +{ + RPC_S2C_Authorization() : + MajorVersion(0), + MinorVersion(0), + PatchVersion(0) + { + } + + String AuthString; + + // Server version info + uint16_t MajorVersion, MinorVersion, PatchVersion; + + void Serialize(Net::BitStream* bs) + { + bs->Write(AuthString); + bs->Write(MajorVersion); + bs->Write(MinorVersion); + bs->Write(PatchVersion); + } + + bool Deserialize(Net::BitStream* bs) + { + bs->Read(AuthString); + bs->Read(MajorVersion); + bs->Read(MinorVersion); + return bs->Read(PatchVersion); + } + + static void Generate(Net::BitStream* bs, String errorString = ""); + + bool Validate(); +}; + + +//----------------------------------------------------------------------------- +// Result of a session function +enum SessionResult +{ + SessionResult_OK, + SessionResult_BindFailure, + SessionResult_ListenFailure, + SessionResult_ConnectFailure, + SessionResult_ConnectInProgress, + SessionResult_AlreadyConnected, +}; + + +//----------------------------------------------------------------------------- +// Connection state +enum EConnectionState +{ + State_Zombie, // Disconnected + + // Client-only: + Client_Connecting, // Waiting for TCP connection + Client_ConnectedWait, // Connected! Waiting for server to authorize + + // Server-only: + Server_ConnectedWait, // Connected! Waiting for client handshake + + State_Connected // Connected +}; + + +//----------------------------------------------------------------------------- +// Generic connection over any transport +class Connection : public RefCountBase +{ +public: + Connection() : + Transport(TransportType_None), + State(State_Zombie), + RemoteMajorVersion(0), + RemoteMinorVersion(0), + RemotePatchVersion(0) + { + } + virtual ~Connection() // Allow delete from base + { + } + +public: + virtual void SetState(EConnectionState s) {State = s;} + + TransportType Transport; + EConnectionState State; + + // Version number read from remote host just before connection completes + int RemoteMajorVersion; + int RemoteMinorVersion; + int RemotePatchVersion; +}; + + +//----------------------------------------------------------------------------- +// Generic network connection over any network transport +class NetworkConnection : public Connection +{ +protected: + NetworkConnection() + { + } + virtual ~NetworkConnection() + { + } + +public: + virtual void SetState(EConnectionState s) + { + if (s != State) + { + Mutex::Locker locker(&StateMutex); + + if (s != State) + { + State = s; + + if (State != Client_Connecting) + { + ConnectingWait.NotifyAll(); + } + } + } + } + + void WaitOnConnecting() + { + Mutex::Locker locker(&StateMutex); + + while (State == Client_Connecting) + { + ConnectingWait.Wait(&StateMutex); + } + } + + SockAddr Address; + Mutex StateMutex; + WaitCondition ConnectingWait; +}; + + +//----------------------------------------------------------------------------- +// TCP Connection +class TCPConnection : public NetworkConnection +{ +public: + TCPConnection() + { + } + virtual ~TCPConnection() + { + } + +public: + Ptr pSocket; +}; + + +//----------------------------------------------------------------------------- +// Packetized TCP Connection +class PacketizedTCPConnection : public TCPConnection +{ +public: + PacketizedTCPConnection() + { + Transport = TransportType_PacketizedTCP; + } + virtual ~PacketizedTCPConnection() + { + } +}; + + +//----------------------------------------------------------------------------- +// Generic socket listener description +class ListenerDescription +{ +public: + ListenerDescription() : + Transport(TransportType_None) + { + } + + TransportType Transport; +}; + + +//----------------------------------------------------------------------------- +// Description for a Berkley socket listener +class BerkleyListenerDescription : public ListenerDescription +{ +public: + static const int DefaultMaxIncomingConnections = 64; + static const int DefaultMaxConnections = 128; + + BerkleyListenerDescription() : + MaxIncomingConnections(DefaultMaxIncomingConnections), + MaxConnections(DefaultMaxConnections) + { + } + + Ptr BoundSocketToListenWith; + int MaxIncomingConnections; + int MaxConnections; +}; + + +//----------------------------------------------------------------------------- +// Receive payload +struct ReceivePayload +{ + Connection* pConnection; // Source connection + uint8_t* pData; // Pointer to data received + int Bytes; // Number of bytes of data received +}; + +//----------------------------------------------------------------------------- +// Broadcast parameters +class BroadcastParameters +{ +public: + BroadcastParameters() : + pData(NULL), + Bytes(0) + { + } + + BroadcastParameters(const void* _pData, int _bytes) : + pData(_pData), + Bytes(_bytes) + { + } + +public: + const void* pData; // Pointer to data to send + int Bytes; // Number of bytes of data received +}; + +//----------------------------------------------------------------------------- +// Send parameters +class SendParameters +{ +public: + SendParameters() : + pData(NULL), + Bytes(0) + { + } + SendParameters(Ptr _pConnection, const void* _pData, int _bytes) : + pConnection(_pConnection), + pData(_pData), + Bytes(_bytes) + { + } + +public: + Ptr pConnection; // Connection to use + const void* pData; // Pointer to data to send + int Bytes; // Number of bytes of data received +}; + + +//----------------------------------------------------------------------------- +// Parameters to connect +struct ConnectParameters +{ +public: + ConnectParameters() : + Transport(TransportType_None) + { + } + + TransportType Transport; +}; + +struct ConnectParametersBerkleySocket : public ConnectParameters +{ + SockAddr RemoteAddress; + Ptr BoundSocketToConnectWith; + bool Blocking; + + ConnectParametersBerkleySocket(BerkleySocket* s, SockAddr* addr, bool blocking, + TransportType transport) : + RemoteAddress(*addr), + BoundSocketToConnectWith(s), + Blocking(blocking) + { + Transport = transport; + } +}; + + +//----------------------------------------------------------------------------- +// Listener receive result +enum ListenerReceiveResult +{ + /// The SessionListener used this message and it shouldn't be given to the user. + LRR_RETURN = 0, + + /// The SessionListener is going to hold on to this message. Do not deallocate it but do not pass it to other plugins either. + LRR_BREAK, + + /// This message will be processed by other SessionListeners, and at last by the user. + LRR_CONTINUE, +}; + + +//----------------------------------------------------------------------------- +// SessionListener + +// Callback interface for network events such as connecting, disconnecting, getting data, independent of the transport medium +class SessionListener +{ +public: + virtual ~SessionListener(){} + + // Data events + virtual void OnReceive(ReceivePayload* pPayload, ListenerReceiveResult* lrrOut) { OVR_UNUSED2(pPayload, lrrOut); } + + // Connection was closed + virtual void OnDisconnected(Connection* conn) = 0; + + // Connection was created (some data was exchanged to verify protocol compatibility too) + virtual void OnConnected(Connection* conn) = 0; + + // Server accepted client + virtual void OnNewIncomingConnection(Connection* conn) { OnConnected(conn); } + // Client was accepted + virtual void OnConnectionRequestAccepted(Connection* conn) { OnConnected(conn); } + + // Connection attempt failed for some reason + virtual void OnConnectionAttemptFailed(Connection* conn) { OnDisconnected(conn); } + + // Incompatible protocol + virtual void OnIncompatibleProtocol(Connection* conn) { OnConnectionAttemptFailed(conn); } + // Disconnected during initial handshake + virtual void OnHandshakeAttemptFailed(Connection* conn) { OnConnectionAttemptFailed(conn); } + + // Other + virtual void OnAddedToSession(Session* session) { OVR_UNUSED(session); } + virtual void OnRemovedFromSession(Session* session) { OVR_UNUSED(session); } +}; + + +//----------------------------------------------------------------------------- +// Session + +// Interface for network events such as listening on a socket, sending data, connecting, and disconnecting. Works independently of the transport medium and also implements loopback +class Session : public SocketEvent_TCP, public NewOverrideBase +{ + // Implement a policy to avoid releasing memory backing allBlockingTcpSockets + struct ArrayNoShrinkPolicy : ArrayDefaultPolicy + { + bool NeverShrinking() const { return 1; } + }; + +public: + Session() : + HasLoopbackListener(false) + { + } + virtual ~Session() + { + // Ensure memory backing the sockets array is released + allBlockingTcpSockets.ClearAndRelease(); + } + + virtual SessionResult Listen(ListenerDescription* pListenerDescription); + virtual SessionResult Connect(ConnectParameters* cp); + virtual int Send(SendParameters* payload); + virtual void Broadcast(BroadcastParameters* payload); + // DO NOT CALL Poll() FROM MULTIPLE THREADS due to allBlockingTcpSockets being a member + virtual void Poll(bool listeners = true); + virtual void AddSessionListener(SessionListener* se); + virtual void RemoveSessionListener(SessionListener* se); + virtual SInt32 GetActiveSocketsCount(); + + // Packetized TCP convenience functions + virtual SessionResult ListenPTCP(BerkleyBindParameters* bbp); + virtual SessionResult ConnectPTCP(BerkleyBindParameters* bbp, SockAddr* RemoteAddress, bool blocking); + + // Closes all the sockets; useful for interrupting the socket polling during shutdown + void Shutdown(); + + // Get count of successful connections (past handshake point) + int GetConnectionCount() const + { + return FullConnections.GetSizeI(); + } + Ptr GetConnectionAtIndex(int index); + +protected: + virtual Ptr AllocConnection(TransportType transportType); + + Lock SocketListenersLock, ConnectionsLock, SessionListenersLock; + bool HasLoopbackListener; // Has loopback listener installed? + Array< Ptr > SocketListeners; // List of active sockets + Array< Ptr > AllConnections; // List of active connections stuck at the versioning handshake + Array< Ptr > FullConnections; // List of active connections past the versioning handshake + Array< SessionListener* > SessionListeners; // List of session listeners + Array< Ptr< Net::TCPSocket >, ArrayNoShrinkPolicy > allBlockingTcpSockets; // Preallocated blocking sockets array + + // Tools + Ptr findConnectionBySocket(Array< Ptr >& connectionArray, Socket* s, int *connectionIndex = NULL); // Call with ConnectionsLock held + Ptr findConnectionBySockAddr(SockAddr* address); // Call with ConnectionsLock held + int invokeSessionListeners(ReceivePayload*); + void invokeSessionEvent(void(SessionListener::*f)(Connection*), Connection* pConnection); + + // TCP + virtual void TCP_OnRecv(Socket* pSocket, uint8_t* pData, int bytesRead); + virtual void TCP_OnClosed(TCPSocket* pSocket); + virtual void TCP_OnAccept(TCPSocket* pListener, SockAddr* pSockAddr, SocketHandle newSock); + virtual void TCP_OnConnected(TCPSocket* pSocket); +}; + + +}} // OVR::Net + +#endif diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Net/OVR_Socket.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Net/OVR_Socket.cpp Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,94 @@ +/************************************************************************************ + +Filename : OVR_Socket.cpp +Content : Socket common data shared between all platforms. +Created : June 10, 2014 +Authors : Kevin Jenkins, Chris Taylor + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#include "OVR_Socket.h" + +namespace OVR { namespace Net { + + +//----------------------------------------------------------------------------- +// Socket + +Socket::Socket() : + Transport(TransportType_None) +{ +} + + +//----------------------------------------------------------------------------- +// BerkleyBindParameters + +BerkleyBindParameters::BerkleyBindParameters() : + Port(0), + Address(), + blockingTimeout(0x7fffffff) +{ +} + +//----------------------------------------------------------------------------- +// BerkleySocket + +BerkleySocket::BerkleySocket() : + TheSocket(INVALID_SOCKET) + //TimeoutUsec(0) // Initialized by SetBlockingTimeout + //TimeoutSec(0) // " +{ + SetBlockingTimeout(1000); +} + +BerkleySocket::~BerkleySocket() +{ + // Close socket on destruction + Close(); +} + + +//----------------------------------------------------------------------------- +// UDPSocketBase + +UDPSocketBase::UDPSocketBase() +{ + Transport = TransportType_UDP; +} + + +//----------------------------------------------------------------------------- +// TCPSocketBase + +TCPSocketBase::TCPSocketBase() + : IsListenSocket(false) +{ + Transport = TransportType_TCP; +} + +TCPSocketBase::TCPSocketBase(SocketHandle handle) + : IsListenSocket(false) +{ + TheSocket = handle; +} + + +}} // OVR::Net diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Net/OVR_Socket.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Net/OVR_Socket.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,242 @@ +/************************************************************************************ + +PublicHeader: n/a +Filename : OVR_Socket.h +Content : Socket common data shared between all platforms. +Created : June 10, 2014 +Authors : Kevin Jenkins, Chris Taylor + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#ifndef OVR_Socket_h +#define OVR_Socket_h + +#include "../Kernel/OVR_Types.h" +#include "../Kernel/OVR_Timer.h" +#include "../Kernel/OVR_Allocator.h" +#include "../Kernel/OVR_RefCount.h" +#include "../Kernel/OVR_String.h" + +// OS-specific socket headers +#if defined(OVR_OS_WIN32) +#include +#include +#define WIN32_LEAN_AND_MEAN +#include +#else +# include +# include +# include +#ifdef OVR_OS_ANDROID +#include +#endif +#endif + +namespace OVR { namespace Net { + +class SockAddr; +class UDPSocket; +class TCPSocket; + + +//----------------------------------------------------------------------------- +// Portable numeric Socket handle +#if defined(OVR_OS_WIN32) +typedef SOCKET SocketHandle; +#else +typedef int SocketHandle; +static const SocketHandle INVALID_SOCKET = -1; +static const int SOCKET_ERROR = -1; +#endif + + +//----------------------------------------------------------------------------- +// Types of network transport +enum TransportType +{ + TransportType_None, // No transport (useful placeholder for invalid states) + TransportType_Loopback, // Loopback transport: Class talks to itself + TransportType_TCP, // TCP/IPv4/v6 + TransportType_UDP, // UDP/IPv4/v6 + TransportType_PacketizedTCP // Packetized TCP: Message framing is automatic +}; + + +//----------------------------------------------------------------------------- +// Abstraction for a network socket. Inheritance hierarchy +// modeled after RakNet so that future support can be added +// for Linux, Windows RT, consoles, etc. +class Socket : public RefCountBase +{ +public: + Socket(); + virtual void Close() = 0; + +public: + TransportType Transport; // Type of transport +}; + + +//----------------------------------------------------------------------------- +// Bind parameters for Berkley sockets +struct BerkleyBindParameters +{ +public: + BerkleyBindParameters(); + +public: + uint16_t Port; // Port + String Address; + uint32_t blockingTimeout; +}; + + +//----------------------------------------------------------------------------- +// Berkley socket +class BerkleySocket : public Socket +{ +public: + BerkleySocket(); + virtual ~BerkleySocket(); + + virtual void Close(); + virtual int32_t GetSockname(SockAddr* pSockAddrOut); + virtual void SetBlockingTimeout(int timeoutMs) // milliseconds + { + TimeoutSec = timeoutMs / 1000; + TimeoutUsec = (timeoutMs % 1000) * 1000; + } + int GetBlockingTimeoutUsec() const + { + return TimeoutUsec; + } + int GetBlockingTimeoutSec() const + { + return TimeoutSec; + } + SocketHandle GetSocketHandle() const + { + return TheSocket; + } + +protected: + SocketHandle TheSocket; // Socket handle + int TimeoutUsec, TimeoutSec; +}; + + +//----------------------------------------------------------------------------- +// UDP socket events +class SocketEvent_UDP +{ +public: + virtual ~SocketEvent_UDP(){} + + virtual void UDP_OnRecv(Socket* pSocket, uint8_t* pData, + uint32_t bytesRead, SockAddr* pSockAddr) + { + OVR_UNUSED4(pSocket, pData, bytesRead, pSockAddr); + } +}; + + +//----------------------------------------------------------------------------- +// TCP socket events +class SocketEvent_TCP +{ +public: + virtual ~SocketEvent_TCP(){} + + virtual void TCP_OnRecv (Socket* pSocket, + uint8_t* pData, + int bytesRead) + { + OVR_UNUSED3(pSocket, pData, bytesRead); + } + virtual void TCP_OnClosed (TCPSocket* pSocket) + { + OVR_UNUSED(pSocket); + } + virtual void TCP_OnAccept (TCPSocket* pListener, + SockAddr* pSockAddr, + SocketHandle newSock) + { + OVR_UNUSED3(pListener, pSockAddr, newSock); + } + virtual void TCP_OnConnected(TCPSocket* pSocket) + { + OVR_UNUSED(pSocket); + } +}; + + +//----------------------------------------------------------------------------- +// UDP Berkley socket + +// Base class for UDP sockets, code shared between platforms +class UDPSocketBase : public BerkleySocket +{ +public: + UDPSocketBase(); + +public: + virtual SocketHandle Bind(BerkleyBindParameters* pBindParameters) = 0; + virtual int Send(const void* pData, + int bytes, + SockAddr* pSockAddr) = 0; + virtual void Poll(SocketEvent_UDP* eventHandler) = 0; + +protected: + virtual void OnRecv(SocketEvent_UDP* eventHandler, + uint8_t* pData, + int bytesRead, + SockAddr* address) = 0; +}; + + +//----------------------------------------------------------------------------- +// TCP Berkley socket + +// Base class for TCP sockets, code shared between platforms +class TCPSocketBase : public BerkleySocket +{ +public: + TCPSocketBase(); + TCPSocketBase(SocketHandle handle); + +public: + virtual SocketHandle Bind(BerkleyBindParameters* pBindParameters) = 0; + virtual int Listen() = 0; + virtual int Connect(SockAddr* pSockAddr) = 0; + virtual int Send(const void* pData, + int bytes) = 0; +protected: + virtual void OnRecv(SocketEvent_TCP* eventHandler, + uint8_t* pData, + int bytesRead) = 0; + +protected: + bool IsListenSocket; // Is the socket listening (acting as a server)? +}; + + +}} // OVR::Net + +#endif diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Net/OVR_Unix_Socket.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Net/OVR_Unix_Socket.cpp Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,600 @@ +/************************************************************************************ + +Filename : OVR_Unix_Socket.cpp +Content : Berkley sockets networking implementation +Created : July 1, 2014 +Authors : Kevin Jenkins + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#include "OVR_Unix_Socket.h" +#include "../Kernel/OVR_Std.h" +#include "../Kernel/OVR_Allocator.h" +#include "../Kernel/OVR_Threads.h" // Thread::MSleep +#include "../Kernel/OVR_Log.h" + +#include + +namespace OVR { namespace Net { + +//----------------------------------------------------------------------------- +// BerkleySocket + +void BerkleySocket::Close() +{ + if (TheSocket != INVALID_SOCKET) + { + close(TheSocket); + TheSocket = INVALID_SOCKET; + } +} + +SInt32 BerkleySocket::GetSockname(SockAddr *pSockAddrOut) +{ + struct sockaddr_in6 sa; + memset(&sa,0,sizeof(sa)); + socklen_t size = sizeof(sa); + SInt32 i = getsockname(TheSocket, (sockaddr*)&sa, &size); + if (i>=0) + { + pSockAddrOut->Set(&sa); + } + return i; +} + + +//----------------------------------------------------------------------------- +// BitStream overloads for SockAddr + +BitStream& operator<<(BitStream& out, SockAddr& in) +{ + out.WriteBits((const unsigned char*) &in.Addr6, sizeof(in.Addr6)*8, true); + return out; +} + +BitStream& operator>>(BitStream& in, SockAddr& out) +{ + bool success = in.ReadBits((unsigned char*) &out.Addr6, sizeof(out.Addr6)*8, true); + OVR_ASSERT(success); + OVR_UNUSED(success); + return in; +} + + +//----------------------------------------------------------------------------- +// SockAddr + +SockAddr::SockAddr() +{ +} + +SockAddr::SockAddr(SockAddr* address) +{ + Set(&address->Addr6); +} + +SockAddr::SockAddr(sockaddr_storage* storage) +{ + Set(storage); +} + +SockAddr::SockAddr(sockaddr_in6* address) +{ + Set(address); +} + +SockAddr::SockAddr(const char* hostAddress, UInt16 port, int sockType) +{ + Set(hostAddress, port, sockType); +} + +void SockAddr::Set(const sockaddr_storage* storage) +{ + memcpy(&Addr6, storage, sizeof(Addr6)); +} + +void SockAddr::Set(const sockaddr_in6* address) +{ + memcpy(&Addr6, address, sizeof(Addr6)); +} + +void SockAddr::Set(const char* hostAddress, UInt16 port, int sockType) +{ + memset(&Addr6, 0, sizeof(Addr6)); + + struct addrinfo hints; + + // make sure the struct is empty + memset(&hints, 0, sizeof (addrinfo)); + + hints.ai_socktype = sockType; // SOCK_DGRAM or SOCK_STREAM + hints.ai_flags = AI_PASSIVE; // fill in my IP for me + hints.ai_family = AF_UNSPEC ; + + if (SOCK_DGRAM == sockType) + { + hints.ai_protocol = IPPROTO_UDP; + } + else if (SOCK_STREAM == sockType) + { + hints.ai_protocol = IPPROTO_TCP; + } + + struct addrinfo* servinfo = NULL; // will point to the results + + char portStr[32]; + OVR_itoa(port, portStr, sizeof(portStr), 10); + int errcode = getaddrinfo(hostAddress, portStr, &hints, &servinfo); + + if (0 != errcode) + { + OVR::LogError("getaddrinfo error: %s", gai_strerror(errcode)); + } + + OVR_ASSERT(servinfo); + + if (servinfo) + { + memcpy(&Addr6, servinfo->ai_addr, sizeof(Addr6)); + + freeaddrinfo(servinfo); + } +} + +UInt16 SockAddr::GetPort() +{ + return htons(Addr6.sin6_port); +} + +String SockAddr::ToString(bool writePort, char portDelineator) const +{ + char dest[INET6_ADDRSTRLEN + 1]; + + int ret = getnameinfo((struct sockaddr*)&Addr6, + sizeof(struct sockaddr_in6), + dest, + INET6_ADDRSTRLEN, + NULL, + 0, + NI_NUMERICHOST); + if (ret != 0) + { + dest[0] = '\0'; + } + + if (writePort) + { + unsigned char ch[2]; + ch[0]=portDelineator; + ch[1]=0; + OVR_strcat(dest, 16, (const char*) ch); + OVR_itoa(ntohs(Addr6.sin6_port), dest+strlen(dest), 16, 10); + } + + return String(dest); +} +bool SockAddr::IsLocalhost() const +{ + static const unsigned char localhost_bytes[] = + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }; + + return memcmp(Addr6.sin6_addr.s6_addr, localhost_bytes, 16) == 0; +} +bool SockAddr::operator==( const SockAddr& right ) const +{ + return memcmp(&Addr6, &right.Addr6, sizeof(Addr6)) == 0; +} + +bool SockAddr::operator!=( const SockAddr& right ) const +{ + return !(*this == right); +} + +bool SockAddr::operator>( const SockAddr& right ) const +{ + return memcmp(&Addr6, &right.Addr6, sizeof(Addr6)) > 0; +} + +bool SockAddr::operator<( const SockAddr& right ) const +{ + return memcmp(&Addr6, &right.Addr6, sizeof(Addr6)) < 0; +} + + +// Returns true on success +static bool SetSocketOptions(SocketHandle sock) +{ + bool failed = false; + int sock_opt; + int sockError = 0; + + // This doubles the max throughput rate + sock_opt=1024*256; + sockError = setsockopt(sock, SOL_SOCKET, SO_RCVBUF, ( char * ) & sock_opt, sizeof ( sock_opt ) ); + if (sockError != 0) + { + int errsv = errno; + OVR::LogError("[Socket] Failed SO_RCVBUF setsockopt, errno: %d", errsv); + failed = true; + } + + // This doesn't make much difference: 10% maybe + // Not supported on console 2 + sock_opt=1024*16; + sockError = setsockopt(sock, SOL_SOCKET, SO_SNDBUF, ( char * ) & sock_opt, sizeof ( sock_opt ) ); + if (sockError != 0) + { + int errsv = errno; + OVR::LogError("[Socket] Failed SO_SNDBUF setsockopt, errno: %d", errsv); + failed = true; + } + + // NOTE: This should be OVR_OS_BSD, not Mac. +#ifdef OVR_OS_MAC + int value = 1; + sockError = setsockopt(sock, SOL_SOCKET, SO_NOSIGPIPE, &value, sizeof(value)); + if (sockError != 0) + { + int errsv = errno; + OVR::LogError("[Socket] Failed SO_NOSIGPIPE setsockopt, errno: %d", errsv); + failed = true; + } +#endif + + // Reuse address is only needed for posix platforms, as it is the default + // on Windows platforms. + int optval = 1; + sockError = setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(int)); + if (sockError != 0) + { + int errsv = errno; + OVR::LogError("[Socket] Failed SO_REUSEADDR setsockopt, errno: %d", errsv); + failed = true; + } + + return !failed; +} + +void _Ioctlsocket(SocketHandle sock, unsigned long nonblocking) +{ + int flags = fcntl(sock, F_GETFL, 0); + if (flags < 0) return; // return false + if (nonblocking == 0) { flags &= ~O_NONBLOCK; } + else { flags |= O_NONBLOCK; } + fcntl(sock, F_SETFL, flags); +} + +static SocketHandle BindShared(int ai_family, int ai_socktype, BerkleyBindParameters *pBindParameters) +{ + SocketHandle sock; + + struct addrinfo hints; + memset(&hints, 0, sizeof (addrinfo)); // make sure the struct is empty + hints.ai_family = ai_family; + hints.ai_socktype = ai_socktype; + hints.ai_flags = AI_PASSIVE; // fill in my IP for me + struct addrinfo *servinfo=0, *aip; // will point to the results + char portStr[32]; + OVR_itoa(pBindParameters->Port, portStr, sizeof(portStr), 10); + + int errcode = 0; + if (!pBindParameters->Address.IsEmpty()) + errcode = getaddrinfo(pBindParameters->Address.ToCStr(), portStr, &hints, &servinfo); + else + errcode = getaddrinfo(0, portStr, &hints, &servinfo); + + if (0 != errcode) + { + OVR::LogError("getaddrinfo error: %s", gai_strerror(errcode)); + } + + for (aip = servinfo; aip != NULL; aip = aip->ai_next) + { + // Open socket. The address type depends on what + // getaddrinfo() gave us. + sock = socket(aip->ai_family, aip->ai_socktype, aip->ai_protocol); + if (sock != 0) + { + SetSocketOptions(sock); + int ret = bind( sock, aip->ai_addr, (int) aip->ai_addrlen ); + if (ret>=0) + { + // The actual socket is always non-blocking + // I control blocking or not using WSAEventSelect + _Ioctlsocket(sock, 1); + freeaddrinfo(servinfo); + return sock; + } + else + { + close(sock); + } + } + } + + if (servinfo) { freeaddrinfo(servinfo); } + return INVALID_SOCKET; +} + + +//----------------------------------------------------------------------------- +// UDPSocket + +UDPSocket::UDPSocket() +{ + RecvBuf = new UByte[RecvBufSize]; +} + +UDPSocket::~UDPSocket() +{ + delete[] RecvBuf; +} + +SocketHandle UDPSocket::Bind(BerkleyBindParameters *pBindParameters) +{ + SocketHandle s = BindShared(AF_INET6, SOCK_DGRAM, pBindParameters); + if (s < 0) + return s; + + Close(); + TheSocket = s; + + return TheSocket; +} + +void UDPSocket::OnRecv(SocketEvent_UDP* eventHandler, UByte* pData, int bytesRead, SockAddr* address) +{ + eventHandler->UDP_OnRecv(this, pData, bytesRead, address); +} + +int UDPSocket::Send(const void* pData, int bytes, SockAddr* address) +{ + // NOTE: This should be OVR_OS_BSD +#ifdef OVR_OS_MAC + int flags = 0; +#else + int flags = MSG_NOSIGNAL; +#endif + + return (int)sendto(TheSocket, (const char*)pData, bytes, flags, (const sockaddr*)&address->Addr6, sizeof(address->Addr6)); +} + +void UDPSocket::Poll(SocketEvent_UDP *eventHandler) +{ + struct sockaddr_storage win32_addr; + socklen_t fromlen; + int bytesRead; + + // FIXME: Implement blocking poll wait for UDP + + // While some bytes are read, + while (fromlen = sizeof(win32_addr), // Must set fromlen each time + bytesRead = (int)recvfrom(TheSocket, (char*)RecvBuf, RecvBufSize, 0, (sockaddr*)&win32_addr, &fromlen), + bytesRead > 0) + { + SockAddr address(&win32_addr); // Wrap address + + OnRecv(eventHandler, RecvBuf, bytesRead, &address); + } +} + + +//----------------------------------------------------------------------------- +// TCPSocket + +TCPSocket::TCPSocket() +{ + IsConnecting = false; + IsListenSocket = false; +} +TCPSocket::TCPSocket(SocketHandle boundHandle, bool isListenSocket) +{ + TheSocket = boundHandle; + IsListenSocket = isListenSocket; + IsConnecting = false; + SetSocketOptions(TheSocket); + + // The actual socket is always non-blocking + _Ioctlsocket(TheSocket, 1); +} + +TCPSocket::~TCPSocket() +{ +} + +void TCPSocket::OnRecv(SocketEvent_TCP* eventHandler, UByte* pData, int bytesRead) +{ + eventHandler->TCP_OnRecv(this, pData, bytesRead); +} + +SocketHandle TCPSocket::Bind(BerkleyBindParameters* pBindParameters) +{ + SocketHandle s = BindShared(AF_INET6, SOCK_STREAM, pBindParameters); + if (s < 0) + return s; + + Close(); + + SetBlockingTimeout(pBindParameters->blockingTimeout); + TheSocket = s; + + return TheSocket; +} + +int TCPSocket::Listen() +{ + if (IsListenSocket) + { + return 0; + } + + int i = listen(TheSocket, SOMAXCONN); + if (i >= 0) + { + IsListenSocket = true; + } + + return i; +} + +int TCPSocket::Connect(SockAddr* address) +{ + int retval; + + retval = connect(TheSocket, (struct sockaddr *) &address->Addr6, sizeof(address->Addr6)); + if (retval < 0) + { + int errsv = errno; + // EINPROGRESS should not be checked on windows but should + // be checked on POSIX platforms. + if (errsv == EWOULDBLOCK || errsv == EINPROGRESS) + { + IsConnecting = true; + return 0; + } + + OVR::LogText( "TCPSocket::Connect failed:Error code - %d\n", errsv ); + } + + return retval; +} + +int TCPSocket::Send(const void* pData, int bytes) +{ + if (bytes <= 0) + { + return 0; + } + else + { + return (int)send(TheSocket, (const char*)pData, bytes, 0); + } +} + + +//// TCPSocketPollState + +TCPSocketPollState::TCPSocketPollState() +{ + FD_ZERO(&readFD); + FD_ZERO(&exceptionFD); + FD_ZERO(&writeFD); + largestDescriptor = INVALID_SOCKET; +} + +bool TCPSocketPollState::IsValid() const +{ + return largestDescriptor != INVALID_SOCKET; +} + +void TCPSocketPollState::Add(TCPSocket* tcpSocket) +{ + if (!tcpSocket) + { + return; + } + + SocketHandle handle = tcpSocket->GetSocketHandle(); + + if (handle == INVALID_SOCKET) + { + return; + } + + if (largestDescriptor == INVALID_SOCKET || + largestDescriptor < handle) + { + largestDescriptor = handle; + } + + FD_SET(handle, &readFD); + FD_SET(handle, &exceptionFD); + + if (tcpSocket->IsConnecting) + { + FD_SET(handle, &writeFD); + } +} + +bool TCPSocketPollState::Poll(long usec, long seconds) +{ + timeval tv; + tv.tv_sec = seconds; + tv.tv_usec = (int)usec; + + return select(largestDescriptor + 1, &readFD, &writeFD, &exceptionFD, &tv) > 0; +} + +void TCPSocketPollState::HandleEvent(TCPSocket* tcpSocket, SocketEvent_TCP* eventHandler) +{ + if (!tcpSocket || !eventHandler) + { + return; + } + + SocketHandle handle = tcpSocket->GetSocketHandle(); + + if (tcpSocket->IsConnecting && FD_ISSET(handle, &writeFD)) + { + tcpSocket->IsConnecting = false; + eventHandler->TCP_OnConnected(tcpSocket); + } + + if (FD_ISSET(handle, &readFD)) + { + if (!tcpSocket->IsListenSocket) + { + static const int BUFF_SIZE = 8096; + char data[BUFF_SIZE]; + + int bytesRead = (int)recv(handle, data, BUFF_SIZE, 0); + if (bytesRead > 0) + { + tcpSocket->OnRecv(eventHandler, (UByte*)data, bytesRead); + } + else // Disconnection event: + { + tcpSocket->IsConnecting = false; + eventHandler->TCP_OnClosed(tcpSocket); + } + } + else + { + struct sockaddr_storage sockAddr; + socklen_t sockAddrSize = sizeof(sockAddr); + + SocketHandle newSock = accept(handle, (sockaddr*)&sockAddr, (socklen_t*)&sockAddrSize); + if (newSock > 0) + { + SockAddr sa(&sockAddr); + eventHandler->TCP_OnAccept(tcpSocket, &sa, newSock); + } + } + } + + if (FD_ISSET(handle, &exceptionFD)) + { + tcpSocket->IsConnecting = false; + eventHandler->TCP_OnClosed(tcpSocket); + } +} + + +}} // namespace OVR::Net diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Net/OVR_Unix_Socket.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Net/OVR_Unix_Socket.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,152 @@ +/************************************************************************************ + +PublicHeader: n/a +Filename : OVR_Unix_Socket.h +Content : Berkley sockets networking implementation +Created : July 1, 2014 +Authors : Kevin Jenkins + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#ifndef OVR_Unix_Socket_h +#define OVR_Unix_Socket_h + +#include "OVR_Socket.h" +#include "OVR_BitStream.h" + +#include +#include +#include +#include +#include +#include + +namespace OVR { namespace Net { + +//----------------------------------------------------------------------------- +// SockAddr + +// Abstraction for IPV6 socket address, with various convenience functions +class SockAddr +{ +public: + SockAddr(); + SockAddr(SockAddr* sa); + SockAddr(sockaddr_storage* sa); + SockAddr(sockaddr_in6* sa); + SockAddr(const char* hostAddress, UInt16 port, int sockType); + +public: + void Set(const sockaddr_storage* sa); + void Set(const sockaddr_in6* sa); + void Set(const char* hostAddress, UInt16 port, int sockType); // SOCK_DGRAM or SOCK_STREAM + + UInt16 GetPort(); + + String ToString(bool writePort, char portDelineator) const; + + bool IsLocalhost() const; + + void Serialize(BitStream* bs); + bool Deserialize(BitStream); + + bool operator==( const SockAddr& right ) const; + bool operator!=( const SockAddr& right ) const; + bool operator >( const SockAddr& right ) const; + bool operator <( const SockAddr& right ) const; + +public: + sockaddr_in6 Addr6; +}; + + +//----------------------------------------------------------------------------- +// UDP Socket + +// Windows version of TCP socket +class UDPSocket : public UDPSocketBase +{ +public: + UDPSocket(); + virtual ~UDPSocket(); + +public: + virtual SocketHandle Bind(BerkleyBindParameters* pBindParameters); + virtual int Send(const void* pData, int bytes, SockAddr* address); + virtual void Poll(SocketEvent_UDP* eventHandler); + +protected: + static const int RecvBufSize = 1048576; + UByte* RecvBuf; + + virtual void OnRecv(SocketEvent_UDP* eventHandler, UByte* pData, + int bytesRead, SockAddr* address); +}; + + +//----------------------------------------------------------------------------- +// TCP Socket + +// Windows version of TCP socket +class TCPSocket : public TCPSocketBase +{ + friend class TCPSocketPollState; + +public: + TCPSocket(); + TCPSocket(SocketHandle boundHandle, bool isListenSocket); + virtual ~TCPSocket(); + +public: + virtual SocketHandle Bind(BerkleyBindParameters* pBindParameters); + virtual int Listen(); + virtual int Connect(SockAddr* address); + virtual int Send(const void* pData, int bytes); + +protected: + virtual void OnRecv(SocketEvent_TCP* eventHandler, UByte* pData, + int bytesRead); + +public: + bool IsConnecting; // Is in the process of connecting? +}; + + +//----------------------------------------------------------------------------- +// TCPSocketPollState + +// Polls multiple blocking TCP sockets at once +class TCPSocketPollState +{ + fd_set readFD, exceptionFD, writeFD; + SocketHandle largestDescriptor; + +public: + TCPSocketPollState(); + bool IsValid() const; + void Add(TCPSocket* tcpSocket); + bool Poll(long usec = 30000, long seconds = 0); + void HandleEvent(TCPSocket* tcpSocket, SocketEvent_TCP* eventHandler); +}; + + +}} // OVR::Net + +#endif diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/OVR_CAPI.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/OVR_CAPI.cpp Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,1289 @@ +/************************************************************************************ + +Filename : OVR_CAPI.cpp +Content : Experimental simple C interface to the HMD - version 1. +Created : November 30, 2013 +Authors : Michael Antonov + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#include "OVR_CAPI.h" +#include "Kernel/OVR_Timer.h" +#include "Kernel/OVR_Math.h" +#include "Kernel/OVR_System.h" +#include "OVR_Stereo.h" +#include "OVR_Profile.h" +#include "../Include/OVR_Version.h" + +#include "CAPI/CAPI_HMDState.h" +#include "CAPI/CAPI_FrameTimeManager.h" + +#include "Service/Service_NetClient.h" +#ifdef OVR_SINGLE_PROCESS +#include "Service/Service_NetServer.h" +#endif + +#ifdef OVR_OS_WIN32 +#include "Displays/OVR_Win32_ShimFunctions.h" +#endif + + +using namespace OVR; +using namespace OVR::Util::Render; +using namespace OVR::Tracking; + +//------------------------------------------------------------------------------------- +// Math +namespace OVR { + + +// ***** FovPort + +// C-interop support: FovPort <-> ovrFovPort +FovPort::FovPort(const ovrFovPort &src) + : UpTan(src.UpTan), DownTan(src.DownTan), LeftTan(src.LeftTan), RightTan(src.RightTan) +{ } + +FovPort::operator ovrFovPort () const +{ + ovrFovPort result; + result.LeftTan = LeftTan; + result.RightTan = RightTan; + result.UpTan = UpTan; + result.DownTan = DownTan; + return result; +} + +// Converts Fov Tan angle units to [-1,1] render target NDC space +Vector2f FovPort::TanAngleToRendertargetNDC(Vector2f const &tanEyeAngle) +{ + ScaleAndOffset2D eyeToSourceNDC = CreateNDCScaleAndOffsetFromFov(*this); + return tanEyeAngle * eyeToSourceNDC.Scale + eyeToSourceNDC.Offset; +} + +// ***** SensorDataType + +SensorDataType::SensorDataType(const ovrSensorData& s) +{ + Acceleration = s.Accelerometer; + RotationRate = s.Gyro; + MagneticField = s.Magnetometer; + Temperature = s.Temperature; + AbsoluteTimeSeconds = s.TimeInSeconds; +} + +SensorDataType::operator ovrSensorData () const +{ + ovrSensorData result; + result.Accelerometer = Acceleration; + result.Gyro = RotationRate; + result.Magnetometer = MagneticField; + result.Temperature = Temperature; + result.TimeInSeconds = (float) AbsoluteTimeSeconds; + return result; +} + + +// ***** SensorState + +TrackingState::TrackingState(const ovrTrackingState& s) +{ + HeadPose = s.HeadPose; + CameraPose = s.CameraPose; + LeveledCameraPose = s.LeveledCameraPose; + RawSensorData = s.RawSensorData; + StatusFlags = s.StatusFlags; + LastVisionProcessingTime = s.LastVisionProcessingTime; + LastVisionFrameLatency = s.LastVisionFrameLatency; + LastCameraFrameCounter = s.LastCameraFrameCounter; +} + +TrackingState::operator ovrTrackingState() const +{ + ovrTrackingState result; + result.HeadPose = HeadPose; + result.CameraPose = CameraPose; + result.LeveledCameraPose = LeveledCameraPose; + result.RawSensorData = RawSensorData; + result.StatusFlags = StatusFlags; + result.LastVisionProcessingTime = LastVisionProcessingTime; + result.LastVisionFrameLatency = LastVisionFrameLatency; + result.LastCameraFrameCounter = LastCameraFrameCounter; + return result; +} + + +} // namespace OVR + +//------------------------------------------------------------------------------------- + +using namespace OVR::CAPI; + +#ifdef __cplusplus +extern "C" { +#endif + + +// Used to generate projection from ovrEyeDesc::Fov +OVR_EXPORT ovrMatrix4f ovrMatrix4f_Projection(ovrFovPort fov, float znear, float zfar, ovrBool rightHanded) +{ + return CreateProjection(rightHanded ? true : false, fov, znear, zfar); +} + + +OVR_EXPORT ovrMatrix4f ovrMatrix4f_OrthoSubProjection(ovrMatrix4f projection, ovrVector2f orthoScale, + float orthoDistance, float hmdToEyeViewOffsetX) +{ + + float orthoHorizontalOffset = hmdToEyeViewOffsetX / orthoDistance; + + // Current projection maps real-world vector (x,y,1) to the RT. + // We want to find the projection that maps the range [-FovPixels/2,FovPixels/2] to + // the physical [-orthoHalfFov,orthoHalfFov] + // Note moving the offset from M[0][2]+M[1][2] to M[0][3]+M[1][3] - this means + // we don't have to feed in Z=1 all the time. + // The horizontal offset math is a little hinky because the destination is + // actually [-orthoHalfFov+orthoHorizontalOffset,orthoHalfFov+orthoHorizontalOffset] + // So we need to first map [-FovPixels/2,FovPixels/2] to + // [-orthoHalfFov+orthoHorizontalOffset,orthoHalfFov+orthoHorizontalOffset]: + // x1 = x0 * orthoHalfFov/(FovPixels/2) + orthoHorizontalOffset; + // = x0 * 2*orthoHalfFov/FovPixels + orthoHorizontalOffset; + // But then we need the same mapping as the existing projection matrix, i.e. + // x2 = x1 * Projection.M[0][0] + Projection.M[0][2]; + // = x0 * (2*orthoHalfFov/FovPixels + orthoHorizontalOffset) * Projection.M[0][0] + Projection.M[0][2]; + // = x0 * Projection.M[0][0]*2*orthoHalfFov/FovPixels + + // orthoHorizontalOffset*Projection.M[0][0] + Projection.M[0][2]; + // So in the new projection matrix we need to scale by Projection.M[0][0]*2*orthoHalfFov/FovPixels and + // offset by orthoHorizontalOffset*Projection.M[0][0] + Projection.M[0][2]. + + Matrix4f ortho; + ortho.M[0][0] = projection.M[0][0] * orthoScale.x; + ortho.M[0][1] = 0.0f; + ortho.M[0][2] = 0.0f; + ortho.M[0][3] = -projection.M[0][2] + ( orthoHorizontalOffset * projection.M[0][0] ); + + ortho.M[1][0] = 0.0f; + ortho.M[1][1] = -projection.M[1][1] * orthoScale.y; // Note sign flip (text rendering uses Y=down). + ortho.M[1][2] = 0.0f; + ortho.M[1][3] = -projection.M[1][2]; + + /* + if ( fabsf ( zNear - zFar ) < 0.001f ) + { + ortho.M[2][0] = 0.0f; + ortho.M[2][1] = 0.0f; + ortho.M[2][2] = 0.0f; + ortho.M[2][3] = zFar; + } + else + { + ortho.M[2][0] = 0.0f; + ortho.M[2][1] = 0.0f; + ortho.M[2][2] = zFar / (zNear - zFar); + ortho.M[2][3] = (zFar * zNear) / (zNear - zFar); + } + */ + + // MA: Undo effect of sign + ortho.M[2][0] = 0.0f; + ortho.M[2][1] = 0.0f; + //ortho.M[2][2] = projection.M[2][2] * projection.M[3][2] * -1.0f; // reverse right-handedness + ortho.M[2][2] = 0.0f; + ortho.M[2][3] = 0.0f; + //projection.M[2][3]; + + // No perspective correction for ortho. + ortho.M[3][0] = 0.0f; + ortho.M[3][1] = 0.0f; + ortho.M[3][2] = 0.0f; + ortho.M[3][3] = 1.0f; + + return ortho; +} + + +OVR_EXPORT double ovr_GetTimeInSeconds() +{ + return Timer::GetSeconds(); +} + +// Waits until the specified absolute time. +OVR_EXPORT double ovr_WaitTillTime(double absTime) +{ + double initialTime = ovr_GetTimeInSeconds(); + double newTime = initialTime; + + while(newTime < absTime) + { + for (int j = 0; j < 5; j++) + OVR_PROCESSOR_PAUSE(); + + newTime = ovr_GetTimeInSeconds(); + } + + // How long we waited + return newTime - initialTime; +} + + +//------------------------------------------------------------------------------------- + +// 1. Init/shutdown. + +static ovrBool CAPI_SystemInitCalled = 0; +static ovrBool CAPI_ovrInitializeCalled = 0; + +static OVR::Service::NetClient* CAPI_pNetClient = 0; + +OVR_EXPORT ovrBool ovr_InitializeRenderingShim() +{ + OVR::System::DirectDisplayInitialize(); + return OVR::System::DirectDisplayEnabled(); +} + +OVR_EXPORT ovrBool ovr_Initialize() +{ + if (CAPI_ovrInitializeCalled) + return 1; + + // We must set up the system for the plugin to work + if (!OVR::System::IsInitialized()) + { + OVR::System::Init(OVR::Log::ConfigureDefaultLog(OVR::LogMask_All)); + CAPI_SystemInitCalled = 1; + } + + if (!OVR::System::DirectDisplayEnabled() && !OVR::Display::InCompatibilityMode(false)) + { + OVR_ASSERT(false); + return 0; + } + + CAPI_pNetClient = NetClient::GetInstance(); + +#ifdef OVR_SINGLE_PROCESS + + // If the server could not start running, + if (Service::NetServer::GetInstance()->IsInitialized()) + { + CAPI_pNetClient->Connect(true); + } + else + { + // This normally will happen if the OVRService is running in the background, + // or another SingleProcess-mode app is running in the background. + // In this case, it's using the hardware and we should not also attempt to use + // the hardware. + LogError("{ERR-079} [LibOVR] Server is already running"); + } +#else + CAPI_pNetClient->Connect(true); +#endif + + CAPI_ovrInitializeCalled = 1; + + return 1; +} + +OVR_EXPORT void ovr_Shutdown() +{ + // We should clean up the system to be complete + if (OVR::System::IsInitialized() && CAPI_SystemInitCalled) + { + OVR::System::Destroy(); + } + + CAPI_SystemInitCalled = 0; + CAPI_ovrInitializeCalled = 0; +} + + +// There is a thread safety issue with ovrHmd_Detect in that multiple calls from different +// threads can corrupt the global array state. This would lead to two problems: +// a) Create(index) enumerator may miss or overshoot items. Probably not a big deal +// as game logic can easily be written to only do Detect(s)/Creates in one place. +// The alternative would be to return list handle. +// b) TBD: Un-mutexed Detect access from two threads could lead to crash. We should +// probably check this. +// + +OVR_EXPORT int ovrHmd_Detect() +{ + if (!CAPI_ovrInitializeCalled) + return 0; + + return CAPI_pNetClient->Hmd_Detect(); +} + + +// ovrHmd_Create us explicitly separated from ConfigureTracking and ConfigureRendering to allow creation of +// a relatively light-weight handle that would reference the device going forward and would +// survive future ovrHmd_Detect calls. That is once ovrHMD is returned, index is no longer +// necessary and can be changed by a ovrHmd_Detect call. +OVR_EXPORT ovrHmd ovrHmd_Create(int index) +{ + if (!CAPI_ovrInitializeCalled) + return 0; + + double t0 = Timer::GetSeconds(); + HMDNetworkInfo netInfo; + + // There may be some delay before the HMD is fully detected. + // Since we are also trying to create the HMD immediately it may lose this race and + // get "NO HMD DETECTED." Wait a bit longer to avoid this. + while (!CAPI_pNetClient->Hmd_Create(index, &netInfo) || + netInfo.NetId == InvalidVirtualHmdId) + { + // If two seconds elapse and still no HMD detected, + if (Timer::GetSeconds() - t0 > 2.) + { + if (!NetClient::GetInstance()->IsConnected(false, false)) + { + NetClient::GetInstance()->SetLastError("Not connected to service"); + } + else + { + NetClient::GetInstance()->SetLastError("No HMD Detected"); + } + + return 0; + } + } + + // Create HMD State object + HMDState* hmds = HMDState::CreateHMDState(CAPI_pNetClient, netInfo); + if (!hmds) + { + CAPI_pNetClient->Hmd_Release(netInfo.NetId); + + NetClient::GetInstance()->SetLastError("Unable to create HMD state"); + return 0; + } + + // Reset frame timing so that FrameTimeManager values are properly initialized in AppRendered mode. + ovrHmd_ResetFrameTiming(hmds->pHmdDesc, 0); + + return hmds->pHmdDesc; +} + + +OVR_EXPORT ovrBool ovrHmd_AttachToWindow( ovrHmd hmd, void* window, + const ovrRecti* destMirrorRect, + const ovrRecti* sourceRenderTargetRect ) +{ + OVR_UNUSED( destMirrorRect ); + OVR_UNUSED( sourceRenderTargetRect ); + + if (!CAPI_ovrInitializeCalled) + return false; + + if (!hmd || !hmd->Handle) + return false; +#ifndef OVR_OS_MAC + HMDState* hmds = (HMDState*)hmd->Handle; + CAPI_pNetClient->Hmd_AttachToWindow(hmds->GetNetId(), window); + hmds->pWindow = window; +#endif +#ifdef OVR_OS_WIN32 + Win32::DisplayShim::GetInstance().hWindow = (HWND)window; +#endif +#ifdef OVR_OS_MAC + OVR_UNUSED(window); +#endif + + return true; +} + +OVR_EXPORT ovrHmd ovrHmd_CreateDebug(ovrHmdType type) +{ + if (!CAPI_ovrInitializeCalled) + return 0; + + HMDState* hmds = HMDState::CreateHMDState(type); + + return hmds->pHmdDesc; +} + +OVR_EXPORT void ovrHmd_Destroy(ovrHmd hmddesc) +{ + if (!hmddesc || !hmddesc->Handle) + return; + + // TBD: Any extra shutdown? + HMDState* hmds = (HMDState*)hmddesc->Handle; + + { // Thread checker in its own scope, to avoid access after 'delete'. + // Essentially just checks that no other RenderAPI function is executing. + ThreadChecker::Scope checkScope(&hmds->RenderAPIThreadChecker, "ovrHmd_Destroy"); + } + +#ifdef OVR_OS_WIN32 + if (hmds->pWindow) + { + // ? ok to call + //CAPI_pNetClient->Hmd_AttachToWindow(hmds->GetNetId(), 0); + hmds->pWindow = 0; + Win32::DisplayShim::GetInstance().hWindow = (HWND)0; + } +#endif + + delete (HMDState*)hmddesc->Handle; +} + + +OVR_EXPORT const char* ovrHmd_GetLastError(ovrHmd hmddesc) +{ + if (!CAPI_ovrInitializeCalled) + { + return "System initialize not called"; + } + + VirtualHmdId netId = InvalidVirtualHmdId; + + if (hmddesc && hmddesc->Handle) + { + HMDState* p = (HMDState*)hmddesc->Handle; + netId = p->GetNetId(); + } + + return CAPI_pNetClient->Hmd_GetLastError(netId); +} + +#define OVR_VERSION_LIBOVR_PFX "libOVR:" + +// Returns version string representing libOVR version. Static, so +// string remains valid for app lifespan +OVR_EXPORT const char* ovr_GetVersionString() +{ + static const char* version = OVR_VERSION_LIBOVR_PFX OVR_VERSION_STRING; + return version + sizeof(OVR_VERSION_LIBOVR_PFX) - 1; +} + + + +//------------------------------------------------------------------------------------- + +// Returns capability bits that are enabled at this time; described by ovrHmdCapBits. +// Note that this value is different font ovrHmdDesc::Caps, which describes what +// capabilities are available. +OVR_EXPORT unsigned int ovrHmd_GetEnabledCaps(ovrHmd hmddesc) +{ + HMDState* p = (HMDState*)hmddesc->Handle; + return p ? p->EnabledHmdCaps : 0; +} + +// Modifies capability bits described by ovrHmdCapBits that can be modified, +// such as ovrHmdCap_LowPersistance. +OVR_EXPORT void ovrHmd_SetEnabledCaps(ovrHmd hmddesc, unsigned int capsBits) +{ + HMDState* p = (HMDState*)hmddesc->Handle; + if (p) + { + p->SetEnabledHmdCaps(capsBits); + } +} + + +//------------------------------------------------------------------------------------- +// *** Sensor + +// Sensor APIs are separated from Create & Configure for several reasons: +// - They need custom parameters that control allocation of heavy resources +// such as Vision tracking, which you don't want to create unless necessary. +// - A game may want to switch some sensor settings based on user input, +// or at lease enable/disable features such as Vision for debugging. +// - The same or syntactically similar sensor interface is likely to be used if we +// introduce controllers. +// +// - Sensor interface functions are all Thread-safe, unlike the frame/render API +// functions that have different rules (all frame access functions +// must be on render thread) + +OVR_EXPORT ovrBool ovrHmd_ConfigureTracking(ovrHmd hmddesc, unsigned int supportedCaps, + unsigned int requiredCaps) +{ + if (hmddesc) + { + HMDState* p = (HMDState*)hmddesc->Handle; + return p->ConfigureTracking(supportedCaps, requiredCaps); + } + + return 0; +} + +OVR_EXPORT void ovrHmd_RecenterPose(ovrHmd hmddesc) +{ + if (hmddesc) + { + HMDState* p = (HMDState*)hmddesc->Handle; + p->TheSensorStateReader.RecenterPose(); + } +} + +OVR_EXPORT ovrTrackingState ovrHmd_GetTrackingState(ovrHmd hmddesc, double absTime) +{ + ovrTrackingState result; + + if (hmddesc) + { + HMDState* p = (HMDState*)hmddesc->Handle; + result = p->PredictedTrackingState(absTime); + + // Instrument data from eye pose + p->LagStats.InstrumentEyePose(result); + } + else + memset(&result, 0, sizeof(result)); + +#ifdef OVR_OS_WIN32 + // Set up display code for Windows + Win32::DisplayShim::GetInstance().Active = (result.StatusFlags & ovrStatus_HmdConnected) != 0; +#endif + + return result; +} + + +//------------------------------------------------------------------------------------- +// *** General Setup + +// Per HMD -> calculateIdealPixelSize +OVR_EXPORT ovrSizei ovrHmd_GetFovTextureSize(ovrHmd hmddesc, ovrEyeType eye, ovrFovPort fov, + float pixelsPerDisplayPixel) +{ + ovrHmdStruct * hmd = hmddesc->Handle; + if (!hmd) return Sizei(0); + + HMDState* hmds = (HMDState*)hmd; + return hmds->RenderState.GetFOVTextureSize(eye, fov, pixelsPerDisplayPixel); +} + + +//------------------------------------------------------------------------------------- + + +OVR_EXPORT +ovrBool ovrHmd_ConfigureRendering( ovrHmd hmddesc, + const ovrRenderAPIConfig* apiConfig, + unsigned int distortionCaps, + const ovrFovPort eyeFovIn[2], + ovrEyeRenderDesc eyeRenderDescOut[2] ) +{ + ovrHmdStruct * hmd = hmddesc->Handle; + if (!hmd) return 0; + return ((HMDState*)hmd)->ConfigureRendering(eyeRenderDescOut, eyeFovIn, + apiConfig, distortionCaps); +} + + + +// TBD: MA - Deprecated, need alternative +void ovrHmd_SetVsync(ovrHmd hmddesc, ovrBool vsync) +{ + ovrHmdStruct * hmd = hmddesc->Handle; + if (!hmd) return; + + return ((HMDState*)hmd)->TimeManager.SetVsync(vsync? true : false); +} + + +OVR_EXPORT ovrFrameTiming ovrHmd_BeginFrame(ovrHmd hmddesc, unsigned int frameIndex) +{ + HMDState* hmds = (HMDState*)hmddesc->Handle; + if (!hmds) + { + ovrFrameTiming f; + memset(&f, 0, sizeof(f)); + return f; + } + + // Check: Proper configure and threading state for the call. + hmds->checkRenderingConfigured("ovrHmd_BeginFrame"); + OVR_DEBUG_LOG_COND(hmds->BeginFrameCalled, ("ovrHmd_BeginFrame called multiple times.")); + ThreadChecker::Scope checkScope(&hmds->RenderAPIThreadChecker, "ovrHmd_BeginFrame"); + + hmds->BeginFrameCalled = true; + hmds->BeginFrameThreadId = OVR::GetCurrentThreadId(); + + return ovrHmd_BeginFrameTiming(hmddesc, frameIndex); +} + + +// Renders textures to frame buffer +OVR_EXPORT void ovrHmd_EndFrame(ovrHmd hmddesc, + const ovrPosef renderPose[2], + const ovrTexture eyeTexture[2]) +{ + HMDState* hmds = (HMDState*)hmddesc->Handle; + if (!hmds) return; + + // Instrument when the EndFrame() call started + hmds->LagStats.InstrumentEndFrameStart(ovr_GetTimeInSeconds()); + + hmds->SubmitEyeTextures(renderPose, eyeTexture); + + // Debug state checks: Must be in BeginFrame, on the same thread. + hmds->checkBeginFrameScope("ovrHmd_EndFrame"); + ThreadChecker::Scope checkScope(&hmds->RenderAPIThreadChecker, "ovrHmd_EndFrame"); + + hmds->pRenderer->SetLatencyTestColor(hmds->LatencyTestActive ? hmds->LatencyTestDrawColor : NULL); + + ovrHmd_GetLatencyTest2DrawColor(hmddesc, NULL); // We don't actually need to draw color, so send NULL + + if (hmds->pRenderer) + { + hmds->pRenderer->SaveGraphicsState(); + + // See if we need to show the HSWDisplay. + if (hmds->pHSWDisplay) // Until we know that these are valid, assume any of them can't be. + { + ovrHSWDisplayState hswDisplayState; + hmds->pHSWDisplay->TickState(&hswDisplayState, true); // This may internally call HASWarning::Display. + + if (hswDisplayState.Displayed) + { + hmds->pHSWDisplay->Render(ovrEye_Left, &eyeTexture[ovrEye_Left]); + hmds->pHSWDisplay->Render(ovrEye_Right, &eyeTexture[ovrEye_Right]); + } + } + + hmds->pRenderer->EndFrame(true); + hmds->pRenderer->RestoreGraphicsState(); + } + + // Call after present + ovrHmd_EndFrameTiming(hmddesc); + + // Instrument latency tester + hmds->LagStats.InstrumentLatencyTimings(hmds->TimeManager); + + // Instrument when the EndFrame() call ended + hmds->LagStats.InstrumentEndFrameEnd(ovr_GetTimeInSeconds()); + + // Out of BeginFrame + hmds->BeginFrameThreadId = 0; + hmds->BeginFrameCalled = false; +} + + +// Not exposed as part of public API +OVR_EXPORT void ovrHmd_RegisterPostDistortionCallback(ovrHmd hmddesc, PostDistortionCallback callback) +{ + HMDState* hmds = (HMDState*)hmddesc->Handle; + if (!hmds) return; + + if (hmds->pRenderer) + { + hmds->pRenderer->RegisterPostDistortionCallback(callback); + } +} + + + +//------------------------------------------------------------------------------------- +// ***** Frame Timing logic + + +OVR_EXPORT ovrFrameTiming ovrHmd_GetFrameTiming(ovrHmd hmddesc, unsigned int frameIndex) +{ + ovrHmdStruct * hmd = hmddesc->Handle; + ovrFrameTiming f; + memset(&f, 0, sizeof(f)); + + HMDState* hmds = (HMDState*)hmd; + if (hmds) + { + FrameTimeManager::Timing frameTiming = hmds->TimeManager.GetFrameTiming(frameIndex); + + f.ThisFrameSeconds = frameTiming.ThisFrameTime; + f.NextFrameSeconds = frameTiming.NextFrameTime; + f.TimewarpPointSeconds = frameTiming.TimewarpPointTime; + f.ScanoutMidpointSeconds = frameTiming.MidpointTime; + f.EyeScanoutSeconds[0] = frameTiming.EyeRenderTimes[0]; + f.EyeScanoutSeconds[1] = frameTiming.EyeRenderTimes[1]; + + // Compute DeltaSeconds. + f.DeltaSeconds = (hmds->LastGetFrameTimeSeconds == 0.0f) ? 0.0f : + (float) (f.ThisFrameSeconds - hmds->LastFrameTimeSeconds); + hmds->LastGetFrameTimeSeconds = f.ThisFrameSeconds; + if (f.DeltaSeconds > 1.0f) + f.DeltaSeconds = 1.0f; + } + + return f; +} + +OVR_EXPORT ovrFrameTiming ovrHmd_BeginFrameTiming(ovrHmd hmddesc, unsigned int frameIndex) +{ + ovrHmdStruct * hmd = hmddesc->Handle; + ovrFrameTiming f; + memset(&f, 0, sizeof(f)); + + HMDState* hmds = (HMDState*)hmd; + if (!hmds) return f; + + // Check: Proper state for the call. + OVR_DEBUG_LOG_COND(hmds->BeginFrameTimingCalled, + ("ovrHmd_BeginFrameTiming called multiple times.")); + hmds->BeginFrameTimingCalled = true; + + double thisFrameTime = hmds->TimeManager.BeginFrame(frameIndex); + + const FrameTimeManager::Timing &frameTiming = hmds->TimeManager.GetFrameTiming(); + + f.ThisFrameSeconds = thisFrameTime; + f.NextFrameSeconds = frameTiming.NextFrameTime; + f.TimewarpPointSeconds = frameTiming.TimewarpPointTime; + f.ScanoutMidpointSeconds= frameTiming.MidpointTime; + f.EyeScanoutSeconds[0] = frameTiming.EyeRenderTimes[0]; + f.EyeScanoutSeconds[1] = frameTiming.EyeRenderTimes[1]; + + // Compute DeltaSeconds. + f.DeltaSeconds = (hmds->LastFrameTimeSeconds == 0.0f) ? 0.0f : + (float) (thisFrameTime - hmds->LastFrameTimeSeconds); + hmds->LastFrameTimeSeconds = thisFrameTime; + if (f.DeltaSeconds > 1.0f) + f.DeltaSeconds = 1.0f; + + return f; +} + + +OVR_EXPORT void ovrHmd_EndFrameTiming(ovrHmd hmddesc) +{ + HMDState* hmds = (HMDState*)hmddesc->Handle; + if (!hmds) return; + + // Debug state checks: Must be in BeginFrameTiming, on the same thread. + hmds->checkBeginFrameTimingScope("ovrHmd_EndTiming"); + // MA TBD: Correct check or not? + // ThreadChecker::Scope checkScope(&hmds->RenderAPIThreadChecker, "ovrHmd_EndFrame"); + + hmds->TimeManager.EndFrame(); + hmds->BeginFrameTimingCalled = false; + + bool dk2LatencyTest = (hmds->EnabledHmdCaps & ovrHmdCap_DynamicPrediction) != 0; + if (dk2LatencyTest) + { + Util::FrameTimeRecordSet recordset; + hmds->TheLatencyTestStateReader.GetRecordSet(recordset); + hmds->TimeManager.UpdateFrameLatencyTrackingAfterEndFrame( hmds->LatencyTest2DrawColor, + recordset); + } +} + + +OVR_EXPORT void ovrHmd_ResetFrameTiming(ovrHmd hmddesc, unsigned int frameIndex) +{ + HMDState* hmds = (HMDState*)hmddesc->Handle; + if (!hmds) return; + + hmds->TimeManager.ResetFrameTiming(frameIndex, + false, + hmds->RenderingConfigured); + hmds->LastFrameTimeSeconds = 0.0; + hmds->LastGetFrameTimeSeconds = 0.0; +} + +OVR_EXPORT void ovrHmd_GetEyePoses(ovrHmd hmd, unsigned int frameIndex, ovrVector3f hmdToEyeViewOffset[2], + ovrPosef outEyePoses[2], ovrTrackingState* outHmdTrackingState) +{ + HMDState* hmds = (HMDState*)hmd->Handle; + if (!hmds) return; + + hmds->LatencyTestActive = hmds->ProcessLatencyTest(hmds->LatencyTestDrawColor); + + ovrTrackingState hmdTrackingState = hmds->TimeManager.GetEyePredictionTracking(hmd, ovrEye_Count, frameIndex); + ovrPosef hmdPose = hmdTrackingState.HeadPose.ThePose; + + // caller passed in a valid pointer, so copy to output + if(outHmdTrackingState) + *outHmdTrackingState = hmdTrackingState; + + // Currently HmdToEyeViewOffset is only a 3D vector + // (Negate HmdToEyeViewOffset because offset is a view matrix offset and not a camera offset) + outEyePoses[0] = Posef(hmdPose.Orientation, ((Posef)hmdPose).Apply(-((Vector3f)hmdToEyeViewOffset[0]))); + outEyePoses[1] = Posef(hmdPose.Orientation, ((Posef)hmdPose).Apply(-((Vector3f)hmdToEyeViewOffset[1]))); + + // Instrument data from eye pose + hmds->LagStats.InstrumentEyePose(hmdTrackingState); +} + +ovrPosef ovrHmd_GetHmdPosePerEye(ovrHmd hmd, ovrEyeType eye) +{ + HMDState* hmds = (HMDState*)hmd->Handle; + if (!hmds) return ovrPosef(); + + // This isn't a great place, but since we removed ovrHmd_BeginEyeRender... + // Only process latency tester for drawing the left eye (assumes left eye is drawn first) + if (hmds->pRenderer && eye == 0) + { + hmds->LatencyTestActive = hmds->ProcessLatencyTest(hmds->LatencyTestDrawColor); + } + + hmds->checkBeginFrameTimingScope("ovrHmd_GetEyePose"); + return hmds->TimeManager.GetEyePredictionPose(hmd, eye); +} + +OVR_EXPORT void ovrHmd_AddDistortionTimeMeasurement(ovrHmd hmddesc, double distortionTimeSeconds) +{ + if (!hmddesc) + return; + HMDState* hmds = (HMDState*)hmddesc->Handle; + + hmds->checkBeginFrameTimingScope("ovrHmd_GetTimewarpEyeMatrices"); + hmds->TimeManager.AddDistortionTimeMeasurement(distortionTimeSeconds); +} + + + +OVR_EXPORT void ovrHmd_GetEyeTimewarpMatricesDebug(ovrHmd hmddesc, ovrEyeType eye, + ovrPosef renderPose, ovrMatrix4f twmOut[2],double debugTimingOffsetInSeconds) +{ + if (!hmddesc) + return; + HMDState* hmds = (HMDState*)hmddesc->Handle; + + // Debug checks: BeginFrame was called, on the same thread. + hmds->checkBeginFrameTimingScope("ovrHmd_GetTimewarpEyeMatrices"); + + hmds->TimeManager.GetTimewarpMatrices(hmddesc, eye, renderPose, twmOut, debugTimingOffsetInSeconds); + + /* + // MA: Took this out because new latency test approach just sames + // the sample times in FrameTimeManager. + // TODO: if no timewarp, then test latency in begin eye render + if (eye == 0) + { + hmds->ProcessLatencyTest2(hmds->LatencyTest2DrawColor, -1.0f); + } + */ +} + + +OVR_EXPORT void ovrHmd_GetEyeTimewarpMatrices(ovrHmd hmddesc, ovrEyeType eye, + ovrPosef renderPose, ovrMatrix4f twmOut[2]) +{ + return(ovrHmd_GetEyeTimewarpMatricesDebug(hmddesc, eye, renderPose, twmOut, 0.0)); +} + + + +OVR_EXPORT ovrEyeRenderDesc ovrHmd_GetRenderDesc(ovrHmd hmddesc, + ovrEyeType eyeType, ovrFovPort fov) +{ + HMDState* hmds = (HMDState*)hmddesc->Handle; + ovrEyeRenderDesc erd; + + if (!hmds) + { + memset(&erd, 0, sizeof(erd)); + return erd; + } + + return hmds->RenderState.CalcRenderDesc(eyeType, fov); +} + + + +#define OVR_OFFSET_OF(s, field) ((size_t)&((s*)0)->field) + + + + +OVR_EXPORT ovrBool ovrHmd_CreateDistortionMeshDebug( ovrHmd hmddesc, + ovrEyeType eyeType, ovrFovPort fov, + unsigned int distortionCaps, + ovrDistortionMesh *meshData, + float debugEyeReliefOverrideInMetres) +{ + // The 'internal' function below can be found in CAPI_HMDState. + // Not ideal, but navigating the convolutions of what compiles + // where, meant they are in the few places which actually lets these compile. + // Please relocate (if you wish) to a more meaningful place if you can navigate the compiler gymnastics :) + return(ovrHmd_CreateDistortionMeshInternal( hmddesc->Handle, + eyeType, fov, + distortionCaps, + meshData, + debugEyeReliefOverrideInMetres)); + +} +OVR_EXPORT ovrBool ovrHmd_CreateDistortionMesh( ovrHmd hmddesc, + ovrEyeType eyeType, ovrFovPort fov, + unsigned int distortionCaps, + ovrDistortionMesh *meshData) +{ + return(ovrHmd_CreateDistortionMeshDebug( hmddesc, eyeType, fov, distortionCaps,meshData, 0)); +} + + + +// Frees distortion mesh allocated by ovrHmd_GenerateDistortionMesh. meshData elements +// are set to null and 0s after the call. +OVR_EXPORT void ovrHmd_DestroyDistortionMesh(ovrDistortionMesh* meshData) +{ + if (meshData->pVertexData) + DistortionMeshDestroy((DistortionMeshVertexData*)meshData->pVertexData, + meshData->pIndexData); + meshData->pVertexData = 0; + meshData->pIndexData = 0; + meshData->VertexCount = 0; + meshData->IndexCount = 0; +} + + + +// Computes updated 'uvScaleOffsetOut' to be used with a distortion if render target size or +// viewport changes after the fact. This can be used to adjust render size every frame, if desired. +OVR_EXPORT void ovrHmd_GetRenderScaleAndOffset( ovrFovPort fov, + ovrSizei textureSize, ovrRecti renderViewport, + ovrVector2f uvScaleOffsetOut[2] ) +{ + // Find the mapping from TanAngle space to target NDC space. + ScaleAndOffset2D eyeToSourceNDC = CreateNDCScaleAndOffsetFromFov(fov); + // Find the mapping from TanAngle space to textureUV space. + ScaleAndOffset2D eyeToSourceUV = CreateUVScaleAndOffsetfromNDCScaleandOffset( + eyeToSourceNDC, + renderViewport, textureSize ); + + uvScaleOffsetOut[0] = eyeToSourceUV.Scale; + uvScaleOffsetOut[1] = eyeToSourceUV.Offset; +} + + +//------------------------------------------------------------------------------------- +// ***** Latency Test interface + +OVR_EXPORT ovrBool ovrHmd_GetLatencyTestDrawColor(ovrHmd hmddesc, unsigned char rgbColorOut[3]) +{ + HMDState* p = (HMDState*)hmddesc->Handle; + rgbColorOut[0] = p->LatencyTestDrawColor[0]; + rgbColorOut[1] = p->LatencyTestDrawColor[1]; + rgbColorOut[2] = p->LatencyTestDrawColor[2]; + return p->LatencyTestActive; +} + +OVR_EXPORT ovrBool ovrHmd_ProcessLatencyTest(ovrHmd hmddesc, unsigned char rgbColorOut[3]) +{ + OVR_UNUSED(hmddesc); + return NetClient::GetInstance()->LatencyUtil_ProcessInputs(Timer::GetSeconds(), rgbColorOut); +} + +OVR_EXPORT const char* ovrHmd_GetLatencyTestResult(ovrHmd hmddesc) +{ + OVR_UNUSED(hmddesc); + return NetClient::GetInstance()->LatencyUtil_GetResultsString(); +} + +OVR_EXPORT ovrBool ovrHmd_GetLatencyTest2DrawColor(ovrHmd hmddesc, unsigned char rgbColorOut[3]) +{ + HMDState* hmds = (HMDState*)hmddesc->Handle; + if (!hmds) return false; + + // TBD: Move directly into renderer + bool dk2LatencyTest = (hmds->EnabledHmdCaps & ovrHmdCap_DynamicPrediction) != 0; + if (dk2LatencyTest) + { + hmds->TimeManager.GetFrameLatencyTestDrawColor(hmds->LatencyTest2DrawColor); + if(rgbColorOut != NULL) + { + rgbColorOut[0] = hmds->LatencyTest2DrawColor[0]; + rgbColorOut[1] = hmds->LatencyTest2DrawColor[1]; + rgbColorOut[2] = hmds->LatencyTest2DrawColor[2]; + } + + if(hmds->pRenderer != NULL) + hmds->pRenderer->SetLatencyTest2Color(hmds->LatencyTest2DrawColor); + } + else + { + if(hmds->pRenderer != NULL) + hmds->pRenderer->SetLatencyTest2Color(NULL); + } + + return dk2LatencyTest; +} + + +OVR_EXPORT double ovrHmd_GetMeasuredLatencyTest2(ovrHmd hmddesc) +{ + HMDState* p = (HMDState*)hmddesc->Handle; + + // MA Test + float latencyRender, latencyTimewarp, latencyPostPresent; + + p->TimeManager.GetLatencyTimings(latencyRender, latencyTimewarp, latencyPostPresent); + return latencyPostPresent; +} + + +//------------------------------------------------------------------------------------- +// ***** Health and Safety Warning Display interface +// + +OVR_EXPORT void ovrHmd_GetHSWDisplayState(ovrHmd hmd, ovrHSWDisplayState *hswDisplayState) +{ + OVR::CAPI::HMDState* pHMDState = (OVR::CAPI::HMDState*)hmd->Handle; + + if (pHMDState) + { + OVR::CAPI::HSWDisplay* pHSWDisplay = pHMDState->pHSWDisplay; + + if(pHSWDisplay) + pHSWDisplay->TickState(hswDisplayState); // This may internally call HSWDisplay::Display. + } +} + +OVR_EXPORT ovrBool ovrHmd_DismissHSWDisplay(ovrHmd hmd) +{ + OVR::CAPI::HMDState* pHMDState = (OVR::CAPI::HMDState*)hmd->Handle; + + if (pHMDState) + { + OVR::CAPI::HSWDisplay* pHSWDisplay = pHMDState->pHSWDisplay; + + if(pHSWDisplay) + return (pHSWDisplay->Dismiss() ? 1 : 0); + } + + return false; +} + + +// ----------------------------------------------------------------------------------- +// ***** Property Access +OVR_EXPORT ovrBool ovrHmd_GetBool(ovrHmd hmddesc, + const char* propertyName, + ovrBool defaultVal) +{ + OVR_ASSERT(propertyName); + if (hmddesc) + { + HMDState* hmds = (HMDState*)hmddesc->Handle; + OVR_ASSERT(hmds); + if (hmds) + { + return hmds->getBoolValue(propertyName, (defaultVal != 0)); + } + } + + return NetClient::GetInstance()->GetBoolValue(InvalidVirtualHmdId, propertyName, (defaultVal != 0)) ? 1 : 0; +} + +OVR_EXPORT ovrBool ovrHmd_SetBool(ovrHmd hmddesc, + const char* propertyName, + ovrBool value) +{ + OVR_ASSERT(propertyName); + if (hmddesc) + { + HMDState* hmds = (HMDState*)hmddesc->Handle; + OVR_ASSERT(hmds); + if (hmds) + { + return hmds->setBoolValue(propertyName, value != 0) ? 1 : 0; + } + } + + return NetClient::GetInstance()->SetBoolValue(InvalidVirtualHmdId, propertyName, (value != 0)) ? 1 : 0; +} + +OVR_EXPORT int ovrHmd_GetInt(ovrHmd hmddesc, + const char* propertyName, + int defaultVal) +{ + OVR_ASSERT(propertyName); + if (hmddesc) + { + HMDState* hmds = (HMDState*)hmddesc->Handle; + OVR_ASSERT(hmds); + if (hmds) + { + return hmds->getIntValue(propertyName, defaultVal); + } + } + + return NetClient::GetInstance()->GetIntValue(InvalidVirtualHmdId, propertyName, defaultVal); +} + +OVR_EXPORT ovrBool ovrHmd_SetInt(ovrHmd hmddesc, + const char* propertyName, + int value) +{ + OVR_ASSERT(propertyName); + if (hmddesc) + { + HMDState* hmds = (HMDState*)hmddesc->Handle; + OVR_ASSERT(hmds); + if (hmds) + { + return hmds->setIntValue(propertyName, value) ? 1 : 0; + } + } + + return NetClient::GetInstance()->SetIntValue(InvalidVirtualHmdId, propertyName, value) ? 1 : 0; +} + +OVR_EXPORT float ovrHmd_GetFloat(ovrHmd hmddesc, + const char* propertyName, + float defaultVal) +{ + OVR_ASSERT(propertyName); + if (hmddesc) + { + HMDState* hmds = (HMDState*)hmddesc->Handle; + OVR_ASSERT(hmds); + if (hmds) + { + return hmds->getFloatValue(propertyName, defaultVal); + } + } + + return (float)NetClient::GetInstance()->GetNumberValue(InvalidVirtualHmdId, propertyName, defaultVal); +} + +OVR_EXPORT ovrBool ovrHmd_SetFloat(ovrHmd hmddesc, + const char* propertyName, + float value) +{ + OVR_ASSERT(propertyName); + if (hmddesc) + { + HMDState* hmds = (HMDState*)hmddesc->Handle; + OVR_ASSERT(hmds); + if (hmds) + { + return hmds->setFloatValue(propertyName, value) ? 1 : 0; + } + } + + return NetClient::GetInstance()->SetNumberValue(InvalidVirtualHmdId, propertyName, value) ? 1 : 0; +} + +OVR_EXPORT unsigned int ovrHmd_GetFloatArray(ovrHmd hmddesc, + const char* propertyName, + float values[], + unsigned int arraySize) +{ + OVR_ASSERT(propertyName); + OVR_ASSERT(hmddesc); + if (hmddesc) + { + HMDState* hmds = (HMDState*)hmddesc->Handle; + OVR_ASSERT(hmds); + if (hmds) + { + return hmds->getFloatArray(propertyName, values, arraySize); + } + } + + // FIXME: Currently it takes a few lines of code to do this, so just not supported for now. + return 0; +} + +// Modify float[] property; false if property doesn't exist or is readonly. +OVR_EXPORT ovrBool ovrHmd_SetFloatArray(ovrHmd hmddesc, + const char* propertyName, + float values[], + unsigned int arraySize) +{ + OVR_ASSERT(propertyName); + OVR_ASSERT(hmddesc); + if (hmddesc) + { + HMDState* hmds = (HMDState*)hmddesc->Handle; + OVR_ASSERT(hmds); + if (hmds) + { + return hmds->setFloatArray(propertyName, values, arraySize) ? 1 : 0; + } + } + + // FIXME: Currently it takes a few lines of code to do this, so just not supported for now. + return 0; +} + +OVR_EXPORT const char* ovrHmd_GetString(ovrHmd hmddesc, + const char* propertyName, + const char* defaultVal) +{ + OVR_ASSERT(propertyName); + if (hmddesc) + { + HMDState* hmds = (HMDState*)hmddesc->Handle; + if (hmds) + { + return hmds->getString(propertyName, defaultVal); + } + } + + return NetClient::GetInstance()->GetStringValue(InvalidVirtualHmdId, propertyName, defaultVal); +} + +OVR_EXPORT ovrBool ovrHmd_SetString(ovrHmd hmddesc, + const char* propertyName, + const char* value) +{ + OVR_ASSERT(propertyName); + if (hmddesc) + { + HMDState* hmds = (HMDState*)hmddesc->Handle; + if (hmds) + { + return hmds->setString(propertyName, value) ? 1 : 0; + } + } + + return NetClient::GetInstance()->SetStringValue(InvalidVirtualHmdId, propertyName, value) ? 1 : 0; +} + +// ----------------------------------------------------------------------------------- +// ***** Logging + +OVR_EXPORT ovrBool ovrHmd_StartPerfLog(ovrHmd hmd, const char* fileName, const char* userData1) +{ + OVR_ASSERT(fileName && fileName[0]); + + OVR::CAPI::HMDState* pHMDState = (OVR::CAPI::HMDState*)hmd->Handle; + + if (pHMDState) + { + ovrBool started = pHMDState->LagStatsCSV.Start(fileName, userData1) ? 1 : 0; + if (started) + pHMDState->LagStats.AddResultsObserver(pHMDState->LagStatsCSV.GetObserver()); + return started; + } + return 0; +} +OVR_EXPORT ovrBool ovrHmd_StopPerfLog(ovrHmd hmd) +{ + OVR::CAPI::HMDState* pHMDState = (OVR::CAPI::HMDState*)hmd->Handle; + + if (pHMDState) + { + return pHMDState->LagStatsCSV.Stop() ? 1 : 0; + } + return false; +} + + +#ifdef __cplusplus +} // extern "C" +#endif diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/OVR_CAPI.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/OVR_CAPI.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,950 @@ +/************************************************************************************ + +Filename : OVR_CAPI.h +Content : C Interface to Oculus tracking and rendering. +Created : November 23, 2013 +Authors : Michael Antonov + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +/// @file OVR_CAPI.h +/// Exposes all general Rift functionality. + +#ifndef OVR_CAPI_h +#define OVR_CAPI_h + +#include + +#include "OVR_CAPI_Keys.h" + +typedef char ovrBool; + +//----------------------------------------------------------------------------------- +// ***** OVR_EXPORT definition + +#if !defined(OVR_EXPORT) + #ifdef OVR_OS_WIN32 + #define OVR_EXPORT __declspec(dllexport) + #else + #define OVR_EXPORT + #endif +#endif + + + +//----------------------------------------------------------------------------------- +// ***** OVR_ALIGNAS definition +// +#if !defined(OVR_ALIGNAS) + // C++11 alignas + #if defined(__GNUC__) && (((__GNUC__ * 100) + __GNUC_MINOR__) >= 408) && (defined(__GXX_EXPERIMENTAL_CXX0X__) || (__cplusplus >= 201103L)) + #define OVR_ALIGNAS(n) alignas(n) + #elif defined(__clang__) && !defined(__APPLE__) && (((__clang_major__ * 100) + __clang_minor__) >= 300) && (__cplusplus >= 201103L) + #define OVR_ALIGNAS(n) alignas(n) + #elif defined(__clang__) && defined(__APPLE__) && (((__clang_major__ * 100) + __clang_minor__) >= 401) && (__cplusplus >= 201103L) + #define OVR_ALIGNAS(n) alignas(n) + #elif defined(_MSC_VER) && (_MSC_VER >= 1900) + #define OVR_ALIGNAS(n) alignas(n) + #elif defined(__EDG_VERSION__) && (__EDG_VERSION__ >= 408) + #define OVR_ALIGNAS(n) alignas(n) + + // Pre-C++11 alignas fallbacks + #elif defined(__GNUC__) || defined(__clang__) + #define OVR_ALIGNAS(n) __attribute__((aligned(n))) + #elif defined(_MSC_VER) || defined(__INTEL_COMPILER) + #define OVR_ALIGNAS(n) __declspec(align(n)) // For Microsoft the alignment must be a literal integer. + #elif defined(__CC_ARM) + #define OVR_ALIGNAS(n) __align(n) + #else + #error Need to define OVR_ALIGNAS + #endif +#endif + +#if defined(_MSC_VER) + #pragma warning(push) + #pragma warning(disable: 4324) // structure was padded due to __declspec(align()) +#endif + + +//#define ENABLE_LATENCY_TESTER + +//----------------------------------------------------------------------------------- +// ***** Simple Math Structures + +/// A 2D vector with integer components. +typedef struct ovrVector2i_ +{ + int x, y; +} ovrVector2i; + +/// A 2D size with integer components. +typedef struct ovrSizei_ +{ + int w, h; +} ovrSizei; +/// A 2D rectangle with a position and size. +/// All components are integers. +typedef struct ovrRecti_ +{ + ovrVector2i Pos; + ovrSizei Size; +} ovrRecti; + +/// A quaternion rotation. +typedef struct ovrQuatf_ +{ + float x, y, z, w; +} ovrQuatf; + +/// A 2D vector with float components. +typedef struct ovrVector2f_ +{ + float x, y; +} ovrVector2f; + +/// A 3D vector with float components. +typedef struct ovrVector3f_ +{ + float x, y, z; +} ovrVector3f; + +/// A 4x4 matrix with float elements. +typedef struct ovrMatrix4f_ +{ + float M[4][4]; +} ovrMatrix4f; + +/// Position and orientation together. +typedef struct ovrPosef_ +{ + ovrQuatf Orientation; + ovrVector3f Position; +} ovrPosef; + +/// A full pose (rigid body) configuration with first and second derivatives. +typedef struct ovrPoseStatef_ +{ + ovrPosef ThePose; ///< The body's position and orientation. + ovrVector3f AngularVelocity; ///< The body's angular velocity in radians per second. + ovrVector3f LinearVelocity; ///< The body's velocity in meters per second. + ovrVector3f AngularAcceleration; ///< The body's angular acceleration in radians per second per second. + ovrVector3f LinearAcceleration; ///< The body's acceleration in meters per second per second. + double TimeInSeconds; ///< Absolute time of this state sample. +} ovrPoseStatef; + +/// Field Of View (FOV) in tangent of the angle units. +/// As an example, for a standard 90 degree vertical FOV, we would +/// have: { UpTan = tan(90 degrees / 2), DownTan = tan(90 degrees / 2) }. +typedef struct ovrFovPort_ +{ + /// The tangent of the angle between the viewing vector and the top edge of the field of view. + float UpTan; + /// The tangent of the angle between the viewing vector and the bottom edge of the field of view. + float DownTan; + /// The tangent of the angle between the viewing vector and the left edge of the field of view. + float LeftTan; + /// The tangent of the angle between the viewing vector and the right edge of the field of view. + float RightTan; +} ovrFovPort; + +//----------------------------------------------------------------------------------- +// ***** HMD Types + +/// Enumerates all HMD types that we support. +typedef enum +{ + ovrHmd_None = 0, + ovrHmd_DK1 = 3, + ovrHmd_DKHD = 4, + ovrHmd_DK2 = 6, + ovrHmd_Other // Some HMD other then the one in the enumeration. +} ovrHmdType; + +/// HMD capability bits reported by device. +typedef enum +{ + // Read-only flags. + ovrHmdCap_Present = 0x0001, /// The HMD is plugged in and detected by the system. + ovrHmdCap_Available = 0x0002, /// The HMD and its sensor are available for ownership use. + /// i.e. it is not already owned by another application. + ovrHmdCap_Captured = 0x0004, /// Set to 'true' if we captured ownership of this HMD. + + // These flags are intended for use with the new driver display mode. + ovrHmdCap_ExtendDesktop = 0x0008, /// (read only) Means the display driver is in compatibility mode. + + // Modifiable flags (through ovrHmd_SetEnabledCaps). + ovrHmdCap_NoMirrorToWindow = 0x2000, /// Disables mirroring of HMD output to the window. This may improve + /// rendering performance slightly (only if 'ExtendDesktop' is off). + ovrHmdCap_DisplayOff = 0x0040, /// Turns off HMD screen and output (only if 'ExtendDesktop' is off). + + ovrHmdCap_LowPersistence = 0x0080, /// HMD supports low persistence mode. + ovrHmdCap_DynamicPrediction = 0x0200, /// Adjust prediction dynamically based on internally measured latency. + ovrHmdCap_DirectPentile = 0x0400, /// Write directly in pentile color mapping format + ovrHmdCap_NoVSync = 0x1000, /// Support rendering without VSync for debugging. + + // These bits can be modified by ovrHmd_SetEnabledCaps. + ovrHmdCap_Writable_Mask = 0x32F0, + + /// These flags are currently passed into the service. May change without notice. + ovrHmdCap_Service_Mask = 0x22F0 +} ovrHmdCaps; + + +/// Tracking capability bits reported by the device. +/// Used with ovrHmd_ConfigureTracking. +typedef enum +{ + ovrTrackingCap_Orientation = 0x0010, /// Supports orientation tracking (IMU). + ovrTrackingCap_MagYawCorrection = 0x0020, /// Supports yaw drift correction via a magnetometer or other means. + ovrTrackingCap_Position = 0x0040, /// Supports positional tracking. + /// Overrides the other flags. Indicates that the application + /// doesn't care about tracking settings. This is the internal + /// default before ovrHmd_ConfigureTracking is called. + ovrTrackingCap_Idle = 0x0100, +} ovrTrackingCaps; + +/// Distortion capability bits reported by device. +/// Used with ovrHmd_ConfigureRendering and ovrHmd_CreateDistortionMesh. +typedef enum +{ + ovrDistortionCap_Chromatic = 0x01, /// Supports chromatic aberration correction. + ovrDistortionCap_TimeWarp = 0x02, /// Supports timewarp. + // 0x04 unused + ovrDistortionCap_Vignette = 0x08, /// Supports vignetting around the edges of the view. + ovrDistortionCap_NoRestore = 0x10, /// Do not save and restore the graphics and compute state when rendering distortion. + ovrDistortionCap_FlipInput = 0x20, /// Flip the vertical texture coordinate of input images. + ovrDistortionCap_SRGB = 0x40, /// Assume input images are in sRGB gamma-corrected color space. + ovrDistortionCap_Overdrive = 0x80, /// Overdrive brightness transitions to reduce artifacts on DK2+ displays + ovrDistortionCap_HqDistortion = 0x100, /// High-quality sampling of distortion buffer for anti-aliasing + ovrDistortionCap_LinuxDevFullscreen = 0x200, /// Indicates window is fullscreen on a device when set. The SDK will automatically apply distortion mesh rotation if needed. + ovrDistortionCap_ComputeShader = 0x400, /// Using compute shader (DX11+ only) + + ovrDistortionCap_ProfileNoTimewarpSpinWaits = 0x10000, /// Use when profiling with timewarp to remove false positives +} ovrDistortionCaps; + +/// Specifies which eye is being used for rendering. +/// This type explicitly does not include a third "NoStereo" option, as such is +/// not required for an HMD-centered API. +typedef enum +{ + ovrEye_Left = 0, + ovrEye_Right = 1, + ovrEye_Count = 2 +} ovrEyeType; + +/// This is a complete descriptor of the HMD. +typedef struct ovrHmdDesc_ +{ + /// Internal handle of this HMD. + struct ovrHmdStruct* Handle; + + /// This HMD's type. + ovrHmdType Type; + + /// Name string describing the product: "Oculus Rift DK1", etc. + const char* ProductName; + const char* Manufacturer; + + /// HID Vendor and ProductId of the device. + short VendorId; + short ProductId; + /// Sensor (and display) serial number. + char SerialNumber[24]; + /// Sensor firmware version. + short FirmwareMajor; + short FirmwareMinor; + /// External tracking camera frustum dimensions (if present). + float CameraFrustumHFovInRadians; + float CameraFrustumVFovInRadians; + float CameraFrustumNearZInMeters; + float CameraFrustumFarZInMeters; + + /// Capability bits described by ovrHmdCaps. + unsigned int HmdCaps; + /// Capability bits described by ovrTrackingCaps. + unsigned int TrackingCaps; + /// Capability bits described by ovrDistortionCaps. + unsigned int DistortionCaps; + + /// These define the recommended and maximum optical FOVs for the HMD. + ovrFovPort DefaultEyeFov[ovrEye_Count]; + ovrFovPort MaxEyeFov[ovrEye_Count]; + + /// Preferred eye rendering order for best performance. + /// Can help reduce latency on sideways-scanned screens. + ovrEyeType EyeRenderOrder[ovrEye_Count]; + + /// Resolution of the full HMD screen (both eyes) in pixels. + ovrSizei Resolution; + /// Location of the application window on the desktop (or 0,0). + ovrVector2i WindowsPos; + + /// Display that the HMD should present on. + /// TBD: It may be good to remove this information relying on WindowPos instead. + /// Ultimately, we may need to come up with a more convenient alternative, + /// such as API-specific functions that return adapter, or something that will + /// work with our monitor driver. + /// Windows: (e.g. "\\\\.\\DISPLAY3", can be used in EnumDisplaySettings/CreateDC). + const char* DisplayDeviceName; + /// MacOS: + int DisplayId; + +} ovrHmdDesc; + +/// Simple type ovrHmd is used in ovrHmd_* calls. +typedef const ovrHmdDesc * ovrHmd; + +/// Bit flags describing the current status of sensor tracking. +typedef enum +{ + ovrStatus_OrientationTracked = 0x0001, /// Orientation is currently tracked (connected and in use). + ovrStatus_PositionTracked = 0x0002, /// Position is currently tracked (false if out of range). + ovrStatus_CameraPoseTracked = 0x0004, /// Camera pose is currently tracked. + ovrStatus_PositionConnected = 0x0020, /// Position tracking hardware is connected. + ovrStatus_HmdConnected = 0x0080 /// HMD Display is available and connected. +} ovrStatusBits; + +/// Specifies a reading we can query from the sensor. +typedef struct ovrSensorData_ +{ + ovrVector3f Accelerometer; /// Acceleration reading in m/s^2. + ovrVector3f Gyro; /// Rotation rate in rad/s. + ovrVector3f Magnetometer; /// Magnetic field in Gauss. + float Temperature; /// Temperature of the sensor in degrees Celsius. + float TimeInSeconds; /// Time when the reported IMU reading took place, in seconds. +} ovrSensorData; + +/// Tracking state at a given absolute time (describes predicted HMD pose etc). +/// Returned by ovrHmd_GetTrackingState. +typedef struct ovrTrackingState_ +{ + /// Predicted head pose (and derivatives) at the requested absolute time. + /// The look-ahead interval is equal to (HeadPose.TimeInSeconds - RawSensorData.TimeInSeconds). + ovrPoseStatef HeadPose; + + /// Current pose of the external camera (if present). + /// This pose includes camera tilt (roll and pitch). For a leveled coordinate + /// system use LeveledCameraPose. + ovrPosef CameraPose; + + /// Camera frame aligned with gravity. + /// This value includes position and yaw of the camera, but not roll and pitch. + /// It can be used as a reference point to render real-world objects in the correct location. + ovrPosef LeveledCameraPose; + + /// The most recent sensor data received from the HMD. + ovrSensorData RawSensorData; + + /// Tracking status described by ovrStatusBits. + unsigned int StatusFlags; + + //// 0.4.1 + + // Measures the time from receiving the camera frame until vision CPU processing completes. + double LastVisionProcessingTime; + + //// 0.4.3 + + // Measures the time from exposure until the pose is available for the frame, including processing time. + double LastVisionFrameLatency; + + /// Tag the vision processing results to a certain frame counter number. + uint32_t LastCameraFrameCounter; +} ovrTrackingState; + +/// Frame timing data reported by ovrHmd_BeginFrameTiming() or ovrHmd_BeginFrame(). +typedef struct ovrFrameTiming_ +{ + /// The amount of time that has passed since the previous frame's + /// ThisFrameSeconds value (usable for movement scaling). + /// This will be clamped to no more than 0.1 seconds to prevent + /// excessive movement after pauses due to loading or initialization. + float DeltaSeconds; + + /// It is generally expected that the following holds: + /// ThisFrameSeconds < TimewarpPointSeconds < NextFrameSeconds < + /// EyeScanoutSeconds[EyeOrder[0]] <= ScanoutMidpointSeconds <= EyeScanoutSeconds[EyeOrder[1]]. + + /// Absolute time value when rendering of this frame began or is expected to + /// begin. Generally equal to NextFrameSeconds of the previous frame. Can be used + /// for animation timing. + double ThisFrameSeconds; + /// Absolute point when IMU expects to be sampled for this frame. + double TimewarpPointSeconds; + /// Absolute time when frame Present followed by GPU Flush will finish and the next frame begins. + double NextFrameSeconds; + + /// Time when half of the screen will be scanned out. Can be passed as an absolute time + /// to ovrHmd_GetTrackingState() to get the predicted general orientation. + double ScanoutMidpointSeconds; + /// Timing points when each eye will be scanned out to display. Used when rendering each eye. + double EyeScanoutSeconds[2]; +} ovrFrameTiming; + +/// Rendering information for each eye. Computed by either ovrHmd_ConfigureRendering() +/// or ovrHmd_GetRenderDesc() based on the specified FOV. Note that the rendering viewport +/// is not included here as it can be specified separately and modified per frame through: +/// (a) ovrHmd_GetRenderScaleAndOffset in the case of client rendered distortion, +/// or (b) passing different values via ovrTexture in the case of SDK rendered distortion. +typedef struct ovrEyeRenderDesc_ +{ + ovrEyeType Eye; ///< The eye index this instance corresponds to. + ovrFovPort Fov; ///< The field of view. + ovrRecti DistortedViewport; ///< Distortion viewport. + ovrVector2f PixelsPerTanAngleAtCenter; ///< How many display pixels will fit in tan(angle) = 1. + ovrVector3f HmdToEyeViewOffset; ///< Translation to be applied to view matrix for each eye offset. +} ovrEyeRenderDesc; + +//----------------------------------------------------------------------------------- +// ***** Platform-independent Rendering Configuration + +/// These types are used to hide platform-specific details when passing +/// render device, OS, and texture data to the API. +/// +/// The benefit of having these wrappers versus platform-specific API functions is +/// that they allow game glue code to be portable. A typical example is an +/// engine that has multiple back ends, say GL and D3D. Portable code that calls +/// these back ends may also use LibOVR. To do this, back ends can be modified +/// to return portable types such as ovrTexture and ovrRenderAPIConfig. +typedef enum +{ + ovrRenderAPI_None, + ovrRenderAPI_OpenGL, + ovrRenderAPI_Android_GLES, // May include extra native window pointers, etc. + ovrRenderAPI_D3D9, + ovrRenderAPI_D3D10, + ovrRenderAPI_D3D11, + ovrRenderAPI_Count +} ovrRenderAPIType; + +/// Platform-independent part of rendering API-configuration data. +/// It is a part of ovrRenderAPIConfig, passed to ovrHmd_Configure. +typedef struct OVR_ALIGNAS(8) ovrRenderAPIConfigHeader_ +{ + ovrRenderAPIType API; + ovrSizei BackBufferSize; // Previously named RTSize. + int Multisample; +} ovrRenderAPIConfigHeader; + +/// Contains platform-specific information for rendering. +typedef struct OVR_ALIGNAS(8) ovrRenderAPIConfig_ +{ + ovrRenderAPIConfigHeader Header; + uintptr_t PlatformData[8]; +} ovrRenderAPIConfig; + +/// Platform-independent part of the eye texture descriptor. +/// It is a part of ovrTexture, passed to ovrHmd_EndFrame. +/// If RenderViewport is all zeros then the full texture will be used. +typedef struct OVR_ALIGNAS(8) ovrTextureHeader_ +{ + ovrRenderAPIType API; + ovrSizei TextureSize; + ovrRecti RenderViewport; // Pixel viewport in texture that holds eye image. + uint32_t _PAD0_; +} ovrTextureHeader; + +/// Contains platform-specific information about a texture. +typedef struct OVR_ALIGNAS(8) ovrTexture_ +{ + ovrTextureHeader Header; + uintptr_t PlatformData[8]; +} ovrTexture; + + +// ----------------------------------------------------------------------------------- +// ***** API Interfaces + +// Basic steps to use the API: +// +// Setup: +// * ovrInitialize() +// * ovrHMD hmd = ovrHmd_Create(0) +// * Use hmd members and ovrHmd_GetFovTextureSize() to determine graphics configuration. +// * Call ovrHmd_ConfigureTracking() to configure and initialize tracking. +// * Call ovrHmd_ConfigureRendering() to setup graphics for SDK rendering, +// which is the preferred approach. +// Please refer to "Client Distorton Rendering" below if you prefer to do that instead. +// * If the ovrHmdCap_ExtendDesktop flag is not set, then use ovrHmd_AttachToWindow to +// associate the relevant application window with the hmd. +// * Allocate render target textures as needed. +// +// Game Loop: +// * Call ovrHmd_BeginFrame() to get the current frame timing information. +// * Render each eye using ovrHmd_GetEyePoses or ovrHmd_GetHmdPosePerEye to get +// the predicted hmd pose and each eye pose. +// * Call ovrHmd_EndFrame() to render the distorted textures to the back buffer +// and present them on the hmd. +// +// Shutdown: +// * ovrHmd_Destroy(hmd) +// * ovr_Shutdown() +// + +#ifdef __cplusplus +extern "C" { +#endif + +// ovr_InitializeRenderingShim initializes the rendering shim appart from everything +// else in LibOVR. This may be helpful if the application prefers to avoid +// creating any OVR resources (allocations, service connections, etc) at this point. +// ovr_InitializeRenderingShim does not bring up anything within LibOVR except the +// necessary hooks to enable the Direct-to-Rift functionality. +// +// Either ovr_InitializeRenderingShim() or ovr_Initialize() must be called before any +// Direct3D or OpenGL initilization is done by applictaion (creation of devices, etc). +// ovr_Initialize() must still be called after to use the rest of LibOVR APIs. +OVR_EXPORT ovrBool ovr_InitializeRenderingShim(); + +// Library init/shutdown, must be called around all other OVR code. +// No other functions calls besides ovr_InitializeRenderingShim are allowed +// before ovr_Initialize succeeds or after ovr_Shutdown. +/// Initializes all Oculus functionality. +OVR_EXPORT ovrBool ovr_Initialize(); +/// Shuts down all Oculus functionality. +OVR_EXPORT void ovr_Shutdown(); + +/// Returns version string representing libOVR version. Static, so +/// string remains valid for app lifespan +OVR_EXPORT const char* ovr_GetVersionString(); + +/// Detects or re-detects HMDs and reports the total number detected. +/// Users can get information about each HMD by calling ovrHmd_Create with an index. +OVR_EXPORT int ovrHmd_Detect(); + +/// Creates a handle to an HMD which doubles as a description structure. +/// Index can [0 .. ovrHmd_Detect()-1]. Index mappings can cange after each ovrHmd_Detect call. +/// If not null, then the returned handle must be freed with ovrHmd_Destroy. +OVR_EXPORT ovrHmd ovrHmd_Create(int index); +OVR_EXPORT void ovrHmd_Destroy(ovrHmd hmd); + +/// Creates a 'fake' HMD used for debugging only. This is not tied to specific hardware, +/// but may be used to debug some of the related rendering. +OVR_EXPORT ovrHmd ovrHmd_CreateDebug(ovrHmdType type); + +/// Returns last error for HMD state. Returns null for no error. +/// String is valid until next call or GetLastError or HMD is destroyed. +/// Pass null hmd to get global errors (during create etc). +OVR_EXPORT const char* ovrHmd_GetLastError(ovrHmd hmd); + +/// Platform specific function to specify the application window whose output will be +/// displayed on the HMD. Only used if the ovrHmdCap_ExtendDesktop flag is false. +/// Windows: SwapChain associated with this window will be displayed on the HMD. +/// Specify 'destMirrorRect' in window coordinates to indicate an area +/// of the render target output that will be mirrored from 'sourceRenderTargetRect'. +/// Null pointers mean "full size". +/// @note Source and dest mirror rects are not yet implemented. +OVR_EXPORT ovrBool ovrHmd_AttachToWindow(ovrHmd hmd, void* window, + const ovrRecti* destMirrorRect, + const ovrRecti* sourceRenderTargetRect); + +/// Returns capability bits that are enabled at this time as described by ovrHmdCaps. +/// Note that this value is different font ovrHmdDesc::HmdCaps, which describes what +/// capabilities are available for that HMD. +OVR_EXPORT unsigned int ovrHmd_GetEnabledCaps(ovrHmd hmd); + +/// Modifies capability bits described by ovrHmdCaps that can be modified, +/// such as ovrHmdCap_LowPersistance. +OVR_EXPORT void ovrHmd_SetEnabledCaps(ovrHmd hmd, unsigned int hmdCaps); + +//------------------------------------------------------------------------------------- +// ***** Tracking Interface + +/// All tracking interface functions are thread-safe, allowing tracking state to be sampled +/// from different threads. +/// ConfigureTracking starts sensor sampling, enabling specified capabilities, +/// described by ovrTrackingCaps. +/// - supportedTrackingCaps specifies support that is requested. The function will succeed +/// even if these caps are not available (i.e. sensor or camera is unplugged). Support +/// will automatically be enabled if such device is plugged in later. Software should +/// check ovrTrackingState.StatusFlags for real-time status. +/// - requiredTrackingCaps specify sensor capabilities required at the time of the call. +/// If they are not available, the function will fail. Pass 0 if only specifying +/// supportedTrackingCaps. +/// - Pass 0 for both supportedTrackingCaps and requiredTrackingCaps to disable tracking. +OVR_EXPORT ovrBool ovrHmd_ConfigureTracking(ovrHmd hmd, unsigned int supportedTrackingCaps, + unsigned int requiredTrackingCaps); + +/// Re-centers the sensor orientation. +/// Normally this will recenter the (x,y,z) translational components and the yaw +/// component of orientation. +OVR_EXPORT void ovrHmd_RecenterPose(ovrHmd hmd); + +/// Returns tracking state reading based on the specified absolute system time. +/// Pass an absTime value of 0.0 to request the most recent sensor reading. In this case +/// both PredictedPose and SamplePose will have the same value. +/// ovrHmd_GetEyePoses relies on this function internally. +/// This may also be used for more refined timing of FrontBuffer rendering logic, etc. +OVR_EXPORT ovrTrackingState ovrHmd_GetTrackingState(ovrHmd hmd, double absTime); + +//------------------------------------------------------------------------------------- +// ***** Graphics Setup + +/// Calculates the recommended texture size for rendering a given eye within the HMD +/// with a given FOV cone. Higher FOV will generally require larger textures to +/// maintain quality. +/// - pixelsPerDisplayPixel specifies the ratio of the number of render target pixels +/// to display pixels at the center of distortion. 1.0 is the default value. Lower +/// values can improve performance. +OVR_EXPORT ovrSizei ovrHmd_GetFovTextureSize(ovrHmd hmd, ovrEyeType eye, ovrFovPort fov, + float pixelsPerDisplayPixel); + +//------------------------------------------------------------------------------------- +// ***** Rendering API Thread Safety + +// All of rendering functions including the configure and frame functions +// are *NOT thread safe*. It is ok to use ConfigureRendering on one thread and handle +// frames on another thread, but explicit synchronization must be done since +// functions that depend on configured state are not reentrant. +// +// As an extra requirement, any of the following calls must be done on +// the render thread, which is the same thread that calls ovrHmd_BeginFrame +// or ovrHmd_BeginFrameTiming. +// - ovrHmd_EndFrame +// - ovrHmd_GetEyeTimewarpMatrices + +//------------------------------------------------------------------------------------- +// ***** SDK Distortion Rendering Functions + +// These functions support rendering of distortion by the SDK through direct +// access to the underlying rendering API, such as D3D or GL. +// This is the recommended approach since it allows better support for future +// Oculus hardware, and enables a range of low-level optimizations. + +/// Configures rendering and fills in computed render parameters. +/// This function can be called multiple times to change rendering settings. +/// eyeRenderDescOut is a pointer to an array of two ovrEyeRenderDesc structs +/// that are used to return complete rendering information for each eye. +/// - apiConfig provides D3D/OpenGL specific parameters. Pass null +/// to shutdown rendering and release all resources. +/// - distortionCaps describe desired distortion settings. +OVR_EXPORT ovrBool ovrHmd_ConfigureRendering( ovrHmd hmd, + const ovrRenderAPIConfig* apiConfig, + unsigned int distortionCaps, + const ovrFovPort eyeFovIn[2], + ovrEyeRenderDesc eyeRenderDescOut[2] ); + + +/// Begins a frame, returning timing information. +/// This should be called at the beginning of the game rendering loop (on the render thread). +/// Pass 0 for the frame index if not using ovrHmd_GetFrameTiming. +OVR_EXPORT ovrFrameTiming ovrHmd_BeginFrame(ovrHmd hmd, unsigned int frameIndex); + +/// Ends a frame, submitting the rendered textures to the frame buffer. +/// - RenderViewport within each eyeTexture can change per frame if necessary. +/// - 'renderPose' will typically be the value returned from ovrHmd_GetEyePoses, +/// ovrHmd_GetHmdPosePerEye but can be different if a different head pose was +/// used for rendering. +/// - This may perform distortion and scaling internally, assuming is it not +/// delegated to another thread. +/// - Must be called on the same thread as BeginFrame. +/// - *** This Function will call Present/SwapBuffers and potentially wait for GPU Sync ***. +OVR_EXPORT void ovrHmd_EndFrame(ovrHmd hmd, + const ovrPosef renderPose[2], + const ovrTexture eyeTexture[2]); + +/// Returns predicted head pose in outHmdTrackingState and offset eye poses in outEyePoses +/// as an atomic operation. Caller need not worry about applying HmdToEyeViewOffset to the +/// returned outEyePoses variables. +/// - Thread-safe function where caller should increment frameIndex with every frame +/// and pass the index where applicable to functions called on the rendering thread. +/// - hmdToEyeViewOffset[2] can be ovrEyeRenderDesc.HmdToEyeViewOffset returned from +/// ovrHmd_ConfigureRendering or ovrHmd_GetRenderDesc. For monoscopic rendering, +/// use a vector that is the average of the two vectors for both eyes. +/// - If frameIndex is not being used, pass in 0. +/// - Assuming outEyePoses are used for rendering, it should be passed into ovrHmd_EndFrame. +/// - If called doesn't need outHmdTrackingState, it can be NULL +OVR_EXPORT void ovrHmd_GetEyePoses(ovrHmd hmd, unsigned int frameIndex, ovrVector3f hmdToEyeViewOffset[2], + ovrPosef outEyePoses[2], ovrTrackingState* outHmdTrackingState); + +/// Function was previously called ovrHmd_GetEyePose +/// Returns the predicted head pose to use when rendering the specified eye. +/// - Important: Caller must apply HmdToEyeViewOffset before using ovrPosef for rendering +/// - Must be called between ovrHmd_BeginFrameTiming and ovrHmd_EndFrameTiming. +/// - If the pose is used for rendering the eye, it should be passed to ovrHmd_EndFrame. +/// - Parameter 'eye' is used for prediction timing only +OVR_EXPORT ovrPosef ovrHmd_GetHmdPosePerEye(ovrHmd hmd, ovrEyeType eye); + + +//------------------------------------------------------------------------------------- +// ***** Client Distortion Rendering Functions + +// These functions provide the distortion data and render timing support necessary to allow +// client rendering of distortion. Client-side rendering involves the following steps: +// +// 1. Setup ovrEyeDesc based on the desired texture size and FOV. +// Call ovrHmd_GetRenderDesc to get the necessary rendering parameters for each eye. +// +// 2. Use ovrHmd_CreateDistortionMesh to generate the distortion mesh. +// +// 3. Use ovrHmd_BeginFrameTiming, ovrHmd_GetEyePoses, and ovrHmd_BeginFrameTiming in +// the rendering loop to obtain timing and predicted head orientation when rendering each eye. +// - When using timewarp, use ovr_WaitTillTime after the rendering and gpu flush, followed +// by ovrHmd_GetEyeTimewarpMatrices to obtain the timewarp matrices used +// by the distortion pixel shader. This will minimize latency. +// + +/// Computes the distortion viewport, view adjust, and other rendering parameters for +/// the specified eye. This can be used instead of ovrHmd_ConfigureRendering to do +/// setup for client rendered distortion. +OVR_EXPORT ovrEyeRenderDesc ovrHmd_GetRenderDesc(ovrHmd hmd, + ovrEyeType eyeType, ovrFovPort fov); + + +/// Describes a vertex used by the distortion mesh. This is intended to be converted into +/// the engine-specific format. Some fields may be unused based on the ovrDistortionCaps +/// flags selected. TexG and TexB, for example, are not used if chromatic correction is +/// not requested. +typedef struct ovrDistortionVertex_ +{ + ovrVector2f ScreenPosNDC; ///< [-1,+1],[-1,+1] over the entire framebuffer. + float TimeWarpFactor; ///< Lerp factor between time-warp matrices. Can be encoded in Pos.z. + float VignetteFactor; ///< Vignette fade factor. Can be encoded in Pos.w. + ovrVector2f TanEyeAnglesR; ///< The tangents of the horizontal and vertical eye angles for the red channel. + ovrVector2f TanEyeAnglesG; ///< The tangents of the horizontal and vertical eye angles for the green channel. + ovrVector2f TanEyeAnglesB; ///< The tangents of the horizontal and vertical eye angles for the blue channel. +} ovrDistortionVertex; + +/// Describes a full set of distortion mesh data, filled in by ovrHmd_CreateDistortionMesh. +/// Contents of this data structure, if not null, should be freed by ovrHmd_DestroyDistortionMesh. +typedef struct ovrDistortionMesh_ +{ + ovrDistortionVertex* pVertexData; ///< The distortion vertices representing each point in the mesh. + unsigned short* pIndexData; ///< Indices for connecting the mesh vertices into polygons. + unsigned int VertexCount; ///< The number of vertices in the mesh. + unsigned int IndexCount; ///< The number of indices in the mesh. +} ovrDistortionMesh; + +/// Generate distortion mesh per eye. +/// Distortion capabilities will depend on 'distortionCaps' flags. Users should +/// render using the appropriate shaders based on their settings. +/// Distortion mesh data will be allocated and written into the ovrDistortionMesh data structure, +/// which should be explicitly freed with ovrHmd_DestroyDistortionMesh. +/// Users should call ovrHmd_GetRenderScaleAndOffset to get uvScale and Offset values for rendering. +/// The function shouldn't fail unless theres is a configuration or memory error, in which case +/// ovrDistortionMesh values will be set to null. +/// This is the only function in the SDK reliant on eye relief, currently imported from profiles, +/// or overridden here. +OVR_EXPORT ovrBool ovrHmd_CreateDistortionMesh( ovrHmd hmd, + ovrEyeType eyeType, ovrFovPort fov, + unsigned int distortionCaps, + ovrDistortionMesh *meshData); +OVR_EXPORT ovrBool ovrHmd_CreateDistortionMeshDebug( ovrHmd hmddesc, + ovrEyeType eyeType, ovrFovPort fov, + unsigned int distortionCaps, + ovrDistortionMesh *meshData, + float debugEyeReliefOverrideInMetres); + + +/// Used to free the distortion mesh allocated by ovrHmd_GenerateDistortionMesh. meshData elements +/// are set to null and zeroes after the call. +OVR_EXPORT void ovrHmd_DestroyDistortionMesh( ovrDistortionMesh* meshData ); + +/// Computes updated 'uvScaleOffsetOut' to be used with a distortion if render target size or +/// viewport changes after the fact. This can be used to adjust render size every frame if desired. +OVR_EXPORT void ovrHmd_GetRenderScaleAndOffset( ovrFovPort fov, + ovrSizei textureSize, ovrRecti renderViewport, + ovrVector2f uvScaleOffsetOut[2] ); + +/// Thread-safe timing function for the main thread. Caller should increment frameIndex +/// with every frame and pass the index where applicable to functions called on the +/// rendering thread. +OVR_EXPORT ovrFrameTiming ovrHmd_GetFrameTiming(ovrHmd hmd, unsigned int frameIndex); + +/// Called at the beginning of the frame on the rendering thread. +/// Pass frameIndex == 0 if ovrHmd_GetFrameTiming isn't being used. Otherwise, +/// pass the same frame index as was used for GetFrameTiming on the main thread. +OVR_EXPORT ovrFrameTiming ovrHmd_BeginFrameTiming(ovrHmd hmd, unsigned int frameIndex); + +/// Marks the end of client distortion rendered frame, tracking the necessary timing information. +/// This function must be called immediately after Present/SwapBuffers + GPU sync. GPU sync is +/// important before this call to reduce latency and ensure proper timing. +OVR_EXPORT void ovrHmd_EndFrameTiming(ovrHmd hmd); + +/// Initializes and resets frame time tracking. This is typically not necessary, but +/// is helpful if game changes vsync state or video mode. vsync is assumed to be on if this +/// isn't called. Resets internal frame index to the specified number. +OVR_EXPORT void ovrHmd_ResetFrameTiming(ovrHmd hmd, unsigned int frameIndex); + +/// Computes timewarp matrices used by distortion mesh shader, these are used to adjust +/// for head orientation change since the last call to ovrHmd_GetEyePoses +/// when rendering this eye. The ovrDistortionVertex::TimeWarpFactor is used to blend between the +/// matrices, usually representing two different sides of the screen. +/// Must be called on the same thread as ovrHmd_BeginFrameTiming. +OVR_EXPORT void ovrHmd_GetEyeTimewarpMatrices (ovrHmd hmd, ovrEyeType eye, + ovrPosef renderPose, ovrMatrix4f twmOut[2]); +OVR_EXPORT void ovrHmd_GetEyeTimewarpMatricesDebug(ovrHmd hmd, ovrEyeType eye, + ovrPosef renderPose, ovrMatrix4f twmOut[2], + double debugTimingOffsetInSeconds); + + + + +//------------------------------------------------------------------------------------- +// ***** Stateless math setup functions + +/// Used to generate projection from ovrEyeDesc::Fov. +OVR_EXPORT ovrMatrix4f ovrMatrix4f_Projection( ovrFovPort fov, + float znear, float zfar, ovrBool rightHanded ); + +/// Used for 2D rendering, Y is down +/// orthoScale = 1.0f / pixelsPerTanAngleAtCenter +/// orthoDistance = distance from camera, such as 0.8m +OVR_EXPORT ovrMatrix4f ovrMatrix4f_OrthoSubProjection(ovrMatrix4f projection, ovrVector2f orthoScale, + float orthoDistance, float hmdToEyeViewOffsetX); + +/// Returns global, absolute high-resolution time in seconds. This is the same +/// value as used in sensor messages. +OVR_EXPORT double ovr_GetTimeInSeconds(); + +/// Waits until the specified absolute time. +OVR_EXPORT double ovr_WaitTillTime(double absTime); + +// ----------------------------------------------------------------------------------- +// ***** Latency Test interface + +/// Does latency test processing and returns 'TRUE' if specified rgb color should +/// be used to clear the screen. +OVR_EXPORT ovrBool ovrHmd_ProcessLatencyTest(ovrHmd hmd, unsigned char rgbColorOut[3]); + +/// Returns non-null string once with latency test result, when it is available. +/// Buffer is valid until next call. +OVR_EXPORT const char* ovrHmd_GetLatencyTestResult(ovrHmd hmd); + +/// Returns the latency testing color in rgbColorOut to render when using a DK2 +/// Returns false if this feature is disabled or not-applicable (e.g. using a DK1) +OVR_EXPORT ovrBool ovrHmd_GetLatencyTest2DrawColor(ovrHmd hmddesc, unsigned char rgbColorOut[3]); + +//------------------------------------------------------------------------------------- +// ***** Health and Safety Warning Display interface +// + +/// Used by ovrhmd_GetHSWDisplayState to report the current display state. +typedef struct ovrHSWDisplayState_ +{ + /// If true then the warning should be currently visible + /// and the following variables have meaning. Else there is no + /// warning being displayed for this application on the given HMD. + ovrBool Displayed; ///< True if the Health&Safety Warning is currently displayed. + double StartTime; ///< Absolute time when the warning was first displayed. See ovr_GetTimeInSeconds(). + double DismissibleTime; ///< Earliest absolute time when the warning can be dismissed. May be a time in the past. +} ovrHSWDisplayState; + +/// Returns the current state of the HSW display. If the application is doing the rendering of +/// the HSW display then this function serves to indicate that the warning should be +/// currently displayed. If the application is using SDK-based eye rendering then the SDK by +/// default automatically handles the drawing of the HSW display. An application that uses +/// application-based eye rendering should use this function to know when to start drawing the +/// HSW display itself and can optionally use it in conjunction with ovrhmd_DismissHSWDisplay +/// as described below. +/// +/// Example usage for application-based rendering: +/// bool HSWDisplayCurrentlyDisplayed = false; // global or class member variable +/// ovrHSWDisplayState hswDisplayState; +/// ovrhmd_GetHSWDisplayState(Hmd, &hswDisplayState); +/// +/// if (hswDisplayState.Displayed && !HSWDisplayCurrentlyDisplayed) { +/// +/// HSWDisplayCurrentlyDisplayed = true; +/// } +OVR_EXPORT void ovrHmd_GetHSWDisplayState(ovrHmd hmd, ovrHSWDisplayState *hasWarningState); + +/// Dismisses the HSW display if the warning is dismissible and the earliest dismissal time +/// has occurred. Returns true if the display is valid and could be dismissed. The application +/// should recognize that the HSW display is being displayed (via ovrhmd_GetHSWDisplayState) +/// and if so then call this function when the appropriate user input to dismiss the warning +/// occurs. +/// +/// Example usage : +/// void ProcessEvent(int key) { +/// if (key == escape) { +/// ovrHSWDisplayState hswDisplayState; +/// ovrhmd_GetHSWDisplayState(hmd, &hswDisplayState); +/// +/// if (hswDisplayState.Displayed && ovrhmd_DismissHSWDisplay(hmd)) { +/// +/// HSWDisplayCurrentlyDisplayed = false; +/// } +/// } +/// } +OVR_EXPORT ovrBool ovrHmd_DismissHSWDisplay(ovrHmd hmd); + +/// Get boolean property. Returns first element if property is a boolean array. +/// Returns defaultValue if property doesn't exist. +OVR_EXPORT ovrBool ovrHmd_GetBool(ovrHmd hmd, const char* propertyName, ovrBool defaultVal); + +/// Modify bool property; false if property doesn't exist or is readonly. +OVR_EXPORT ovrBool ovrHmd_SetBool(ovrHmd hmd, const char* propertyName, ovrBool value); + +/// Get integer property. Returns first element if property is an integer array. +/// Returns defaultValue if property doesn't exist. +OVR_EXPORT int ovrHmd_GetInt(ovrHmd hmd, const char* propertyName, int defaultVal); + +/// Modify integer property; false if property doesn't exist or is readonly. +OVR_EXPORT ovrBool ovrHmd_SetInt(ovrHmd hmd, const char* propertyName, int value); + +/// Get float property. Returns first element if property is a float array. +/// Returns defaultValue if property doesn't exist. +OVR_EXPORT float ovrHmd_GetFloat(ovrHmd hmd, const char* propertyName, float defaultVal); + +/// Modify float property; false if property doesn't exist or is readonly. +OVR_EXPORT ovrBool ovrHmd_SetFloat(ovrHmd hmd, const char* propertyName, float value); + +/// Get float[] property. Returns the number of elements filled in, 0 if property doesn't exist. +/// Maximum of arraySize elements will be written. +OVR_EXPORT unsigned int ovrHmd_GetFloatArray(ovrHmd hmd, const char* propertyName, + float values[], unsigned int arraySize); + +/// Modify float[] property; false if property doesn't exist or is readonly. +OVR_EXPORT ovrBool ovrHmd_SetFloatArray(ovrHmd hmd, const char* propertyName, + float values[], unsigned int arraySize); + +/// Get string property. Returns first element if property is a string array. +/// Returns defaultValue if property doesn't exist. +/// String memory is guaranteed to exist until next call to GetString or GetStringArray, or HMD is destroyed. +OVR_EXPORT const char* ovrHmd_GetString(ovrHmd hmd, const char* propertyName, + const char* defaultVal); + +/// Set string property +OVR_EXPORT ovrBool ovrHmd_SetString(ovrHmd hmddesc, const char* propertyName, + const char* value); + +// ----------------------------------------------------------------------------------- +// ***** Logging + +/// Start performance logging. guid is optional and if included is written with each file entry. +/// If called while logging is already active with the same filename, only the guid will be updated +/// If called while logging is already active with a different filename, ovrHmd_StopPerfLog() will be called, followed by ovrHmd_StartPerfLog() +OVR_EXPORT ovrBool ovrHmd_StartPerfLog(ovrHmd hmd, const char* fileName, const char* userData1); +/// Stop performance logging. +OVR_EXPORT ovrBool ovrHmd_StopPerfLog(ovrHmd hmd); + + +#ifdef __cplusplus +} // extern "C" +#endif + + +#if defined(_MSC_VER) + #pragma warning(pop) +#endif + + +#endif // OVR_CAPI_h diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/OVR_CAPI_GL.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/OVR_CAPI_GL.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,76 @@ +/************************************************************************************ + +Filename : OVR_CAPI_GL.h +Content : GL specific structures used by the CAPI interface. +Created : November 7, 2013 +Authors : Lee Cooper + +Copyright : Copyright 2013 Oculus VR, LLC. All Rights reserved. + +Use of this software is subject to the terms of the Oculus Inc license +agreement provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +************************************************************************************/ +#ifndef OVR_CAPI_GL_h +#define OVR_CAPI_GL_h + +/// @file OVR_CAPI_GL.h +/// OpenGL rendering support. + +#include "OVR_CAPI.h" +#if defined(__APPLE__) + #include +#else + #include +#endif + + +/// Used to configure slave GL rendering (i.e. for devices created externally). +typedef struct OVR_ALIGNAS(8) ovrGLConfigData_s +{ + /// General device settings. + ovrRenderAPIConfigHeader Header; + +#if defined(OVR_OS_WIN32) + /// The optional window handle. If unset, rendering will use the current window. + HWND Window; + /// The optional device context. If unset, rendering will use a new context. + HDC DC; +#elif defined (OVR_OS_LINUX) + /// Optional display. If unset, will issue glXGetCurrentDisplay when context + /// is current. + struct _XDisplay* Disp; +#endif +} ovrGLConfigData; + +/// Contains OpenGL-specific rendering information. +union ovrGLConfig +{ + /// General device settings. + ovrRenderAPIConfig Config; + /// OpenGL-specific settings. + ovrGLConfigData OGL; +}; + +/// Used to pass GL eye texture data to ovrHmd_EndFrame. +typedef struct OVR_ALIGNAS(8) ovrGLTextureData_s +{ + /// General device settings. + ovrTextureHeader Header; + /// The OpenGL name for this texture. + GLuint TexId; +} ovrGLTextureData; + +static_assert(offsetof(ovrGLTextureData, TexId) == offsetof(ovrTexture, PlatformData), "Mismatch of structs that are presumed binary equivalents."); + +/// Contains OpenGL-specific texture information. +typedef union ovrGLTexture_s +{ + /// General device settings. + ovrTexture Texture; + /// OpenGL-specific settings. + ovrGLTextureData OGL; +} ovrGLTexture; + +#endif // OVR_CAPI_GL_h diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/OVR_CAPI_Keys.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/OVR_CAPI_Keys.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,56 @@ +/************************************************************************************ + +Filename : OVR_CAPI.h +Content : Keys for CAPI calls +Created : September 25, 2014 +Authors : + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + + + +#define OVR_KEY_USER "User" // string +#define OVR_KEY_NAME "Name" // string +#define OVR_KEY_GENDER "Gender" // string +#define OVR_KEY_PLAYER_HEIGHT "PlayerHeight" // float +#define OVR_KEY_EYE_HEIGHT "EyeHeight" // float +#define OVR_KEY_IPD "IPD" // float +#define OVR_KEY_NECK_TO_EYE_DISTANCE "NeckEyeDistance" // float[2] +#define OVR_KEY_EYE_RELIEF_DIAL "EyeReliefDial" // int +#define OVR_KEY_EYE_TO_NOSE_DISTANCE "EyeToNoseDist" // float[2] +#define OVR_KEY_MAX_EYE_TO_PLATE_DISTANCE "MaxEyeToPlateDist" // float[2] +#define OVR_KEY_EYE_CUP "EyeCup" // char[16] +#define OVR_KEY_CUSTOM_EYE_RENDER "CustomEyeRender" // bool +#define OVR_KEY_CAMERA_POSITION "CenteredFromWorld" // double[7] + +// Default measurements empirically determined at Oculus to make us happy +// The neck model numbers were derived as an average of the male and female averages from ANSUR-88 +// NECK_TO_EYE_HORIZONTAL = H22 - H43 = INFRAORBITALE_BACK_OF_HEAD - TRAGION_BACK_OF_HEAD +// NECK_TO_EYE_VERTICAL = H21 - H15 = GONION_TOP_OF_HEAD - ECTOORBITALE_TOP_OF_HEAD +// These were determined to be the best in a small user study, clearly beating out the previous default values +#define OVR_DEFAULT_GENDER "Unknown" +#define OVR_DEFAULT_PLAYER_HEIGHT 1.778f +#define OVR_DEFAULT_EYE_HEIGHT 1.675f +#define OVR_DEFAULT_IPD 0.064f +#define OVR_DEFAULT_NECK_TO_EYE_HORIZONTAL 0.0805f +#define OVR_DEFAULT_NECK_TO_EYE_VERTICAL 0.075f +#define OVR_DEFAULT_EYE_RELIEF_DIAL 3 +#define OVR_DEFAULT_CAMERA_POSITION {0,0,0,1,0,0,0} + diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/OVR_JSON.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/OVR_JSON.cpp Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,1287 @@ +/************************************************************************************ + +PublicHeader: None +Filename : OVR_JSON.h +Content : JSON format reader and writer +Created : April 9, 2013 +Author : Brant Lewis +Notes : + The code is a derivative of the cJSON library written by Dave Gamble and subject + to the following permissive copyright. + + Copyright (c) 2009 Dave Gamble + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include "OVR_JSON.h" +#include "Kernel/OVR_SysFile.h" +#include "Kernel/OVR_Log.h" + +#ifdef OVR_OS_LINUX +#include +#endif + +namespace OVR { + + +//----------------------------------------------------------------------------- +// Create a new copy of a string +static char* JSON_strdup(const char* str) +{ + size_t len = OVR_strlen(str) + 1; + char* copy = (char*)OVR_ALLOC(len); + if (!copy) + return 0; + memcpy(copy, str, len); + return copy; +} + + +//----------------------------------------------------------------------------- +// Render the number from the given item into a string. +static char* PrintInt(int valueint) +{ + char *str; + str = (char*)OVR_ALLOC(21); // 2^64+1 can be represented in 21 chars. + if (str) + { + OVR_sprintf(str, 21, "%d", valueint); + } + return str; +} + + +//----------------------------------------------------------------------------- +// Render the number from the given item into a string. +static char* PrintNumber(double d) +{ + char *str; + int valueint = (int)d; + if (fabs(((double)valueint)-d)<=DBL_EPSILON && d<=INT_MAX && d>=INT_MIN) + { + return PrintInt(valueint); + } + else + { + str=(char*)OVR_ALLOC(64); // This is a nice tradeoff. + if (str) + { + if (fabs(floor(d)-d)<=DBL_EPSILON && fabs(d)<1.0e60) + OVR_sprintf(str, 64, "%.0f", d); + else if (fabs(d)<1.0e-6 || fabs(d)>1.0e9) + OVR_sprintf(str, 64, "%e", d); + else + OVR_sprintf(str, 64, "%f", d); + } + } + return str; +} + + +// Parse the input text into an un-escaped cstring, and populate item. +static const unsigned char firstByteMark[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC }; + +// Helper to assign error sting and return 0. +const char* AssignError(const char** perror, const char *errorMessage) +{ + if (perror) + *perror = errorMessage; + return 0; +} + +//----------------------------------------------------------------------------- +// ***** JSON Node class + +JSON::JSON(JSONItemType itemType) : + Type(itemType), dValue(0.) +{ +} + +JSON::~JSON() +{ + JSON* child = Children.GetFirst(); + while (!Children.IsNull(child)) + { + child->RemoveNode(); + child->Release(); + child = Children.GetFirst(); + } +} + +//----------------------------------------------------------------------------- +// Parse the input text to generate a number, and populate the result into item +// Returns the text position after the parsed number +const char* JSON::parseNumber(const char *num) +{ + const char* num_start = num; + double n=0, scale=0; + int subscale = 0, + signsubscale = 1; + bool positiveSign = true; + char localeSeparator = '.'; + +#ifdef OVR_OS_LINUX + // We should switch to a locale aware parsing function, such as atof. We + // will probably want to go farther and enforce the 'C' locale on all JSON + // output/input. + struct lconv* localeConv = localeconv(); + localeSeparator = localeConv->decimal_point[0]; +#endif + + // Could use sscanf for this? + if (*num == '-') + { + positiveSign = false; + num++; // Has sign? + } + if (*num == '0') + { + num++; // is zero + } + + if (*num>='1' && *num<='9') + { + do + { + n = (n*10.0) + (*num++ - '0'); + } + while (*num>='0' && *num<='9'); // Number? + } + + if ((*num=='.' || *num==localeSeparator) && num[1]>='0' && num[1]<='9') + { + num++; + do + { + n=(n*10.0)+(*num++ -'0'); + scale--; + } + while (*num>='0' && *num<='9'); // Fractional part? + } + + if (*num=='e' || *num=='E') // Exponent? + { + num++; + if (*num == '+') + { + num++; + } + else if (*num=='-') + { + signsubscale=-1; + num++; // With sign? + } + + while (*num >= '0' && *num <= '9') + { + subscale = (subscale * 10) + (*num++ - '0'); // Number? + } + } + + // Number = +/- number.fraction * 10^+/- exponent + n *= pow(10.0, (scale + subscale*signsubscale)); + + if (!positiveSign) + { + n = -n; + } + + // Assign parsed value. + Type = JSON_Number; + dValue = n; + Value.AssignString(num_start, num - num_start); + + return num; +} + +// Parses a hex string up to the specified number of digits. +// Returns the first character after the string. +const char* ParseHex(unsigned* val, unsigned digits, const char* str) +{ + *val = 0; + + for(unsigned digitCount = 0; digitCount < digits; digitCount++, str++) + { + unsigned v = *str; + + if ((v >= '0') && (v <= '9')) + v -= '0'; + else if ((v >= 'a') && (v <= 'f')) + v = 10 + v - 'a'; + else if ((v >= 'A') && (v <= 'F')) + v = 10 + v - 'A'; + else + break; + + *val = *val * 16 + v; + } + + return str; +} + +//----------------------------------------------------------------------------- +// Parses the input text into a string item and returns the text position after +// the parsed string +const char* JSON::parseString(const char* str, const char** perror) +{ + const char* ptr = str+1; + const char* p; + char* ptr2; + char* out; + int len=0; + unsigned uc, uc2; + + if (*str!='\"') + { + return AssignError(perror, "Syntax Error: Missing quote"); + } + + while (*ptr!='\"' && *ptr && ++len) + { + if (*ptr++ == '\\') ptr++; // Skip escaped quotes. + } + + // This is how long we need for the string, roughly. + out=(char*)OVR_ALLOC(len+1); + if (!out) + return 0; + + ptr = str+1; + ptr2= out; + + while (*ptr!='\"' && *ptr) + { + if (*ptr!='\\') + { + *ptr2++ = *ptr++; + } + else + { + ptr++; + switch (*ptr) + { + case 'b': *ptr2++ = '\b'; break; + case 'f': *ptr2++ = '\f'; break; + case 'n': *ptr2++ = '\n'; break; + case 'r': *ptr2++ = '\r'; break; + case 't': *ptr2++ = '\t'; break; + + // Transcode utf16 to utf8. + case 'u': + + // Get the unicode char. + p = ParseHex(&uc, 4, ptr + 1); + if (ptr != p) + ptr = p - 1; + + if ((uc>=0xDC00 && uc<=0xDFFF) || uc==0) + break; // Check for invalid. + + // UTF16 surrogate pairs. + if (uc>=0xD800 && uc<=0xDBFF) + { + if (ptr[1]!='\\' || ptr[2]!='u') + break; // Missing second-half of surrogate. + + p= ParseHex(&uc2, 4, ptr + 3); + if (ptr != p) + ptr = p - 1; + + if (uc2<0xDC00 || uc2>0xDFFF) + break; // Invalid second-half of surrogate. + + uc = 0x10000 + (((uc&0x3FF)<<10) | (uc2&0x3FF)); + } + + len=4; + + if (uc<0x80) + len=1; + else if (uc<0x800) + len=2; + else if (uc<0x10000) + len=3; + + ptr2+=len; + + switch (len) + { + case 4: *--ptr2 =((uc | 0x80) & 0xBF); uc >>= 6; + //no break, fall through + case 3: *--ptr2 =((uc | 0x80) & 0xBF); uc >>= 6; + //no break + case 2: *--ptr2 =((uc | 0x80) & 0xBF); uc >>= 6; + //no break + case 1: *--ptr2 = (char)(uc | firstByteMark[len]); + //no break + } + ptr2+=len; + break; + + default: + *ptr2++ = *ptr; + break; + } + ptr++; + } + } + + *ptr2 = 0; + if (*ptr=='\"') + ptr++; + + // Make a copy of the string + Value=out; + OVR_FREE(out); + Type=JSON_String; + + return ptr; +} + +//----------------------------------------------------------------------------- +// Render the string provided to an escaped version that can be printed. +char* PrintString(const char* str) +{ + const char *ptr; + char *ptr2,*out; + int len=0; + unsigned char token; + + if (!str) + return JSON_strdup(""); + ptr=str; + + token=*ptr; + while (token && ++len)\ + { + if (strchr("\"\\\b\f\n\r\t",token)) + len++; + else if (token<32) + len+=5; + ptr++; + token=*ptr; + } + + int buff_size = len+3; + out=(char*)OVR_ALLOC(buff_size); + if (!out) + return 0; + + ptr2 = out; + ptr = str; + *ptr2++ = '\"'; + + while (*ptr) + { + if ((unsigned char)*ptr>31 && *ptr!='\"' && *ptr!='\\') + *ptr2++=*ptr++; + else + { + *ptr2++='\\'; + switch (token=*ptr++) + { + case '\\': *ptr2++='\\'; break; + case '\"': *ptr2++='\"'; break; + case '\b': *ptr2++='b'; break; + case '\f': *ptr2++='f'; break; + case '\n': *ptr2++='n'; break; + case '\r': *ptr2++='r'; break; + case '\t': *ptr2++='t'; break; + default: + OVR_sprintf(ptr2, buff_size - (ptr2-out), "u%04x",token); + ptr2+=5; + break; // Escape and print. + } + } + } + *ptr2++='\"'; + *ptr2++=0; + return out; +} + +//----------------------------------------------------------------------------- +// Utility to jump whitespace and cr/lf +static const char* skip(const char* in) +{ + while (in && *in && (unsigned char)*in<=' ') + in++; + return in; +} + +//----------------------------------------------------------------------------- +// Parses the supplied buffer of JSON text and returns a JSON object tree +// The returned object must be Released after use +JSON* JSON::Parse(const char* buff, const char** perror) +{ + const char* end = 0; + JSON* json = new JSON(); + + if (!json) + { + AssignError(perror, "Error: Failed to allocate memory"); + return 0; + } + + end = json->parseValue(skip(buff), perror); + if (!end) + { + json->Release(); + return NULL; + } // parse failure. ep is set. + + return json; +} + +//----------------------------------------------------------------------------- +// This version works for buffers that are not null terminated strings. +JSON* JSON::ParseBuffer(const char *buff, int len, const char** perror) +{ + // Our JSON parser does not support length-based parsing, + // so ensure it is null-terminated. + char *termStr = new char[len + 1]; + memcpy(termStr, buff, len); + termStr[len] = '\0'; + + JSON *objJson = Parse(termStr, perror); + + delete[]termStr; + + return objJson; +} + +//----------------------------------------------------------------------------- +// Parser core - when encountering text, process appropriately. +const char* JSON::parseValue(const char* buff, const char** perror) +{ + if (perror) + *perror = 0; + + if (!buff) + return NULL; // Fail on null. + + if (!strncmp(buff,"null",4)) + { + Type = JSON_Null; + return buff+4; + } + if (!strncmp(buff,"false",5)) + { + Type = JSON_Bool; + Value = "false"; + dValue = 0.; + return buff+5; + } + if (!strncmp(buff,"true",4)) + { + Type = JSON_Bool; + Value = "true"; + dValue = 1.; + return buff + 4; + } + if (*buff=='\"') + { + return parseString(buff, perror); + } + if (*buff=='-' || (*buff>='0' && *buff<='9')) + { + return parseNumber(buff); + } + if (*buff=='[') + { + return parseArray(buff, perror); + } + if (*buff=='{') + { + return parseObject(buff, perror); + } + + return AssignError(perror, "Syntax Error: Invalid syntax"); +} + + +//----------------------------------------------------------------------------- +// Render a value to text. +char* JSON::PrintValue(int depth, bool fmt) +{ + char *out=0; + + switch (Type) + { + case JSON_Null: out = JSON_strdup("null"); break; + case JSON_Bool: + if ((int)dValue == 0) + out = JSON_strdup("false"); + else + out = JSON_strdup("true"); + break; + case JSON_Number: out = PrintNumber(dValue); break; + case JSON_String: out = PrintString(Value); break; + case JSON_Array: out = PrintArray(depth, fmt); break; + case JSON_Object: out = PrintObject(depth, fmt); break; + case JSON_None: OVR_ASSERT_LOG(false, ("Bad JSON type.")); break; + } + return out; +} + +//----------------------------------------------------------------------------- +// Build an array object from input text and returns the text position after +// the parsed array +const char* JSON::parseArray(const char* buff, const char** perror) +{ + JSON *child; + if (*buff!='[') + { + return AssignError(perror, "Syntax Error: Missing opening bracket"); + } + + Type=JSON_Array; + buff=skip(buff+1); + + if (*buff==']') + return buff+1; // empty array. + + child = new JSON(); + if (!child) + return 0; // memory fail + Children.PushBack(child); + + buff=skip(child->parseValue(skip(buff), perror)); // skip any spacing, get the buff. + if (!buff) + return 0; + + while (*buff==',') + { + JSON *new_item = new JSON(); + if (!new_item) + return AssignError(perror, "Error: Failed to allocate memory"); + + Children.PushBack(new_item); + + buff=skip(new_item->parseValue(skip(buff+1), perror)); + if (!buff) + return AssignError(perror, "Error: Failed to allocate memory"); + } + + if (*buff==']') + return buff+1; // end of array + + return AssignError(perror, "Syntax Error: Missing ending bracket"); +} + +//----------------------------------------------------------------------------- +// Render an array to text. The returned text must be freed +char* JSON::PrintArray(int depth, bool fmt) +{ + char ** entries; + char * out = 0, *ptr,*ret; + intptr_t len = 5; + + bool fail = false; + + // How many entries in the array? + int numentries = GetItemCount(); + if (!numentries) + { + out=(char*)OVR_ALLOC(3); + if (out) + OVR_strcpy(out, 3, "[]"); + return out; + } + // Allocate an array to hold the values for each + entries=(char**)OVR_ALLOC(numentries*sizeof(char*)); + if (!entries) + return 0; + memset(entries,0,numentries*sizeof(char*)); + + //// Retrieve all the results: + JSON* child = Children.GetFirst(); + for (int i=0; iPrintValue(depth+1, fmt); + entries[i]=ret; + if (ret) + len+=OVR_strlen(ret)+2+(fmt?1:0); + else + { + fail = true; + break; + } + child = Children.GetNext(child); + } + + // If we didn't fail, try to malloc the output string + if (!fail) + out=(char*)OVR_ALLOC(len); + // If that fails, we fail. + if (!out) + fail = true; + + // Handle failure. + if (fail) + { + for (int i=0; iparseString(skip(buff), perror)); + if (!buff) + return 0; + child->Name = child->Value; + child->Value.Clear(); + + if (*buff!=':') + { + return AssignError(perror, "Syntax Error: Missing colon"); + } + + buff=skip(child->parseValue(skip(buff+1), perror)); // skip any spacing, get the value. + if (!buff) + return 0; + + while (*buff==',') + { + child = new JSON(); + if (!child) + return 0; // memory fail + + Children.PushBack(child); + + buff=skip(child->parseString(skip(buff+1), perror)); + if (!buff) + return 0; + + child->Name=child->Value; + child->Value.Clear(); + + if (*buff!=':') + { + return AssignError(perror, "Syntax Error: Missing colon"); + } // fail! + + // Skip any spacing, get the value. + buff=skip(child->parseValue(skip(buff+1), perror)); + if (!buff) + return 0; + } + + if (*buff=='}') + return buff+1; // end of array + + return AssignError(perror, "Syntax Error: Missing closing brace"); +} + +//----------------------------------------------------------------------------- +// Render an object to text. The returned string must be freed +char* JSON::PrintObject(int depth, bool fmt) +{ + char** entries = 0, **names = 0; + char* out = 0; + char* ptr, *ret, *str; + intptr_t len = 7, i = 0, j; + bool fail = false; + + // Count the number of entries. + int numentries = GetItemCount(); + + // Explicitly handle empty object case + if (numentries == 0) + { + out=(char*)OVR_ALLOC(fmt?depth+4:4); + if (!out) + return 0; + ptr=out; + *ptr++='{'; + + if (fmt) + { + *ptr++='\n'; + for (i=0;iName); + entries[i++] = ret = child->PrintValue(depth, fmt); + + if (str && ret) + { + len += OVR_strlen(ret)+OVR_strlen(str)+2+(fmt?3+depth:0); + } + else + { + fail = true; + break; + } + + child = Children.GetNext(child); + } + + // Try to allocate the output string + if (!fail) + out=(char*)OVR_ALLOC(len); + if (!out) + fail=true; + + // Handle failure + if (fail) + { + for (i=0;ipNext) + { + count++; + } + return count; +} + +JSON* JSON::GetItemByIndex(unsigned index) +{ + unsigned i = 0; + JSON* child = 0; + + if (!Children.IsEmpty()) + { + child = Children.GetFirst(); + + while (i < index) + { + if (Children.IsNull(child->pNext)) + { + child = 0; + break; + } + child = child->pNext; + i++; + } + } + + return child; +} + +// Returns the child item with the given name or NULL if not found +JSON* JSON::GetItemByName(const char* name) +{ + JSON* child = 0; + + if (!Children.IsEmpty()) + { + child = Children.GetFirst(); + + while (OVR_strcmp(child->Name, name) != 0) + { + if (Children.IsNull(child->pNext)) + { + child = 0; + break; + } + child = child->pNext; + } + } + + return child; +} + +//----------------------------------------------------------------------------- +// Adds a new item to the end of the child list +void JSON::AddItem(const char *string, JSON *item) +{ + if (item) + { + item->Name = string; + Children.PushBack(item); + } +} + +/* + +// Removes and frees the items at the given index +void JSON::DeleteItem(unsigned int index) +{ + unsigned int num_items = 0; + JSON* child = Children.GetFirst(); + while (!Children.IsNull(child) && num_items < index) + { + num_items++; + child = Children.GetNext(child); + } + + if (!Children.IsNull(child)) + + child->RemoveNode(); + child->Release(); + } +} + +// Replaces and frees the item at the give index with the new item +void JSON::ReplaceItem(unsigned int index, JSON* new_item) +{ + unsigned int num_items = 0; + JSON* child = Children.GetFirst(); + while (!Children.IsNull(child) && num_items < index) + { + num_items++; + child = Children.GetNext(child); + } + + if (!Children.IsNull(child)) + { + child->ReplaceNodeWith(new_item); + child->Release(); + } +} +*/ + +// Removes and frees the last child item +void JSON::RemoveLast() +{ + JSON* child = Children.GetLast(); + if (!Children.IsNull(child)) + { + child->RemoveNode(); + child->Release(); + } +} + +JSON* JSON::CreateBool(bool b) +{ + JSON *item = new JSON(JSON_Bool); + if (item) + { + item->dValue = b ? 1. : 0.; + item->Value = b ? "true" : "false"; + } + return item; +} + +JSON* JSON::CreateNumber(double num) +{ + JSON *item = new JSON(JSON_Number); + if (item) + { + item->dValue = num; + } + return item; +} + +JSON* JSON::CreateInt(int num) +{ + JSON *item = new JSON(JSON_Number); + if (item) + { + item->dValue = num; + } + return item; +} + +JSON* JSON::CreateString(const char *s) +{ + JSON *item = new JSON(JSON_String); + if (item && s) + { + item->Value = s; + } + return item; +} + + +//----------------------------------------------------------------------------- +// Get elements by name +double JSON::GetNumberByName(const char *name, double defValue) +{ + JSON* item = GetItemByName(name); + if (!item || item->Type != JSON_Number) + { + return defValue; + } + else + { + return item->dValue; + } +} + +int JSON::GetIntByName(const char *name, int defValue) +{ + JSON* item = GetItemByName(name); + if (!item || item->Type != JSON_Number) + { + return defValue; + } + else + { + return (int)item->dValue; + } +} + +bool JSON::GetBoolByName(const char *name, bool defValue) +{ + JSON* item = GetItemByName(name); + if (!item || item->Type != JSON_Bool) + { + return defValue; + } + else + { + return (int)item->dValue != 0; + } +} + +String JSON::GetStringByName(const char *name, const String &defValue) +{ + JSON* item = GetItemByName(name); + if (!item || item->Type != JSON_String) + { + return defValue; + } + else + { + return item->Value; + } +} + +//----------------------------------------------------------------------------- +// Adds an element to an array object type +void JSON::AddArrayElement(JSON *item) +{ + if (item) + { + Children.PushBack(item); + } +} + +// Inserts an element into a valid array position +void JSON::InsertArrayElement(int index, JSON *item) +{ + if (!item) + { + return; + } + + if (index == 0) + { + Children.PushFront(item); + return; + } + + JSON* iter = Children.GetFirst(); + int i=0; + while (iter && iInsertNodeBefore(item); + else + Children.PushBack(item); +} + +// Returns the size of an array +int JSON::GetArraySize() +{ + if (Type == JSON_Array) + { + return GetItemCount(); + } + + return 0; +} + +// Returns the number value an the give array index +double JSON::GetArrayNumber(int index) +{ + if (Type == JSON_Array) + { + JSON* number = GetItemByIndex(index); + return number ? number->dValue : 0.0; + } + + return 0; +} + +// Returns the string value at the given array index +const char* JSON::GetArrayString(int index) +{ + if (Type == JSON_Array) + { + JSON* number = GetItemByIndex(index); + return number ? number->Value : 0; + } + + return 0; +} + +JSON* JSON::Copy() +{ + JSON* copy = new JSON(Type); + copy->Name = Name; + copy->Value = Value; + copy->dValue = dValue; + + JSON* child = Children.GetFirst(); + while (!Children.IsNull(child)) + { + copy->Children.PushBack(child->Copy()); + child = Children.GetNext(child); + } + + return copy; +} + +//----------------------------------------------------------------------------- +// Loads and parses the given JSON file pathname and returns a JSON object tree. +// The returned object must be Released after use. +JSON* JSON::Load(const char* path, const char** perror) +{ + SysFile f; + if (!f.Open(path, File::Open_Read, File::Mode_Read)) + { + AssignError(perror, "Failed to open file"); + return NULL; + } + + int len = f.GetLength(); + uint8_t* buff = (uint8_t*)OVR_ALLOC(len + 1); + int bytes = f.Read(buff, len); + f.Close(); + + if (bytes == 0 || bytes != len) + { + OVR_FREE(buff); + return NULL; + } + + // Ensure the result is null-terminated since Parse() expects null-terminated input. + buff[len] = '\0'; + + JSON* json = JSON::Parse((char*)buff, perror); + OVR_FREE(buff); + return json; +} + +//----------------------------------------------------------------------------- +// Serializes the JSON object and writes to the give file path +bool JSON::Save(const char* path) +{ + SysFile f; + if (!f.Open(path, File::Open_Write | File::Open_Create | File::Open_Truncate, File::Mode_Write)) + return false; + + char* text = PrintValue(0, true); + if (text) + { + intptr_t len = OVR_strlen(text); + OVR_ASSERT(len <= (intptr_t)(int)len); + + int bytes = f.Write((uint8_t*)text, (int)len); + f.Close(); + OVR_FREE(text); + return (bytes == len); + } + else + { + return false; + } +} + + +} // namespace OVR diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/OVR_JSON.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/OVR_JSON.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,165 @@ +/************************************************************************************ + +PublicHeader: None +Filename : OVR_JSON.h +Content : JSON format reader and writer +Created : April 9, 2013 +Author : Brant Lewis +Notes : + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#ifndef OVR_JSON_H +#define OVR_JSON_H + +#include "Kernel/OVR_RefCount.h" +#include "Kernel/OVR_String.h" +#include "Kernel/OVR_List.h" + +namespace OVR { + +// JSONItemType describes the type of JSON item, specifying the type of +// data that can be obtained from it. +enum JSONItemType +{ + JSON_None = 0, + JSON_Null = 1, + JSON_Bool = 2, + JSON_Number = 3, + JSON_String = 4, + JSON_Array = 5, + JSON_Object = 6 +}; + +//----------------------------------------------------------------------------- +// ***** JSON + +// JSON object represents a JSON node that can be either a root of the JSON tree +// or a child item. Every node has a type that describes what is is. +// New JSON trees are typically loaded JSON::Load or created with JSON::Parse. + +class JSON : public RefCountBase, public ListNode +{ +protected: + List Children; + +public: + JSONItemType Type; // Type of this JSON node. + String Name; // Name part of the {Name, Value} pair in a parent object. + String Value; + double dValue; + +public: + ~JSON(); + + // *** Creation of NEW JSON objects + + static JSON* CreateObject() { return new JSON(JSON_Object);} + static JSON* CreateNull() { return new JSON(JSON_Null); } + static JSON* CreateArray() { return new JSON(JSON_Array); } + static JSON* CreateBool(bool b); + static JSON* CreateNumber(double num); + static JSON* CreateInt(int num); + static JSON* CreateString(const char *s); + + // Creates a new JSON object from parsing string. + // Returns null pointer and fills in *perror in case of parse error. + static JSON* Parse(const char* buff, const char** perror = 0); + + // This version works for buffers that are not null terminated strings. + static JSON* ParseBuffer(const char *buff, int len, const char** perror = 0); + + // Loads and parses a JSON object from a file. + // Returns 0 and assigns perror with error message on fail. + static JSON* Load(const char* path, const char** perror = 0); + + // Saves a JSON object to a file. + bool Save(const char* path); + + // *** Object Member Access + + // These provide access to child items of the list. + bool HasItems() const { return Children.IsEmpty(); } + // Returns first/last child item, or null if child list is empty + JSON* GetFirstItem() { return (!Children.IsEmpty()) ? Children.GetFirst() : 0; } + JSON* GetLastItem() { return (!Children.IsEmpty()) ? Children.GetLast() : 0; } + + // Counts the number of items in the object; these methods are inefficient. + unsigned GetItemCount() const; + JSON* GetItemByIndex(unsigned i); + JSON* GetItemByName(const char* name); + + // Accessors by name + double GetNumberByName(const char *name, double defValue = 0.0); + int GetIntByName(const char *name, int defValue = 0); + bool GetBoolByName(const char *name, bool defValue = false); + String GetStringByName(const char *name, const String &defValue = ""); + + // Returns next item in a list of children; 0 if no more items exist. + JSON* GetNextItem(JSON* item) { return Children.IsNull(item->pNext) ? 0 : item->pNext; } + JSON* GetPrevItem(JSON* item) { return Children.IsNull(item->pPrev) ? 0 : item->pPrev; } + + + // Child item access functions + void AddItem(const char *string, JSON* item); + void AddNullItem(const char* name) { AddItem(name, CreateNull()); } + void AddBoolItem(const char* name, bool b) { AddItem(name, CreateBool(b)); } + void AddIntItem(const char* name, int n) { AddItem(name, CreateInt(n)); } + void AddNumberItem(const char* name, double n) { AddItem(name, CreateNumber(n)); } + void AddStringItem(const char* name, const char* s) { AddItem(name, CreateString(s)); } +// void ReplaceItem(unsigned index, JSON* new_item); +// void DeleteItem(unsigned index); + void RemoveLast(); + + // *** Array Element Access + + // Add new elements to the end of array. + void AddArrayElement(JSON *item); + void InsertArrayElement(int index, JSON* item); + void AddArrayNumber(double n) { AddArrayElement(CreateNumber(n)); } + void AddArrayInt(int n) { AddArrayElement(CreateInt(n)); } + void AddArrayString(const char* s) { AddArrayElement(CreateString(s)); } + + // Accessed array elements; currently inefficient. + int GetArraySize(); + double GetArrayNumber(int index); + const char* GetArrayString(int index); + + JSON* Copy(); // Create a copy of this object + +protected: + JSON(JSONItemType itemType = JSON_Object); + + // JSON Parsing helper functions. + const char* parseValue(const char *buff, const char** perror); + const char* parseNumber(const char *num); + const char* parseArray(const char* value, const char** perror); + const char* parseObject(const char* value, const char** perror); + const char* parseString(const char* str, const char** perror); + + char* PrintValue(int depth, bool fmt); + char* PrintObject(int depth, bool fmt); + char* PrintArray(int depth, bool fmt); +}; + + +} + +#endif diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/OVR_Profile.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/OVR_Profile.cpp Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,1627 @@ +/************************************************************************************ + +PublicHeader: None +Filename : OVR_Profile.cpp +Content : Structs and functions for loading and storing device profile settings +Created : February 14, 2013 +Notes : + + Profiles are used to store per-user settings that can be transferred and used + across multiple applications. For example, player IPD can be configured once + and reused for a unified experience across games. Configuration and saving of profiles + can be accomplished in game via the Profile API or by the official Oculus Configuration + Utility. + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#include "OVR_Profile.h" +#include "OVR_JSON.h" +#include "Kernel/OVR_SysFile.h" +#include "Kernel/OVR_Allocator.h" +#include "OVR_Stereo.h" + +#ifdef OVR_OS_WIN32 +#define WIN32_LEAN_AND_MEAN +#include +#include +#elif defined(OVR_OS_MS) // Other Microsoft OSs +// Nothing, thanks. +#else +#include +#include + +#ifdef OVR_OS_LINUX +#include +#include +#endif + +#endif + +#define PROFILE_VERSION 2.0 +#define MAX_PROFILE_MAJOR_VERSION 2 +#define MAX_DEVICE_PROFILE_MAJOR_VERSION 1 + + +namespace OVR { + + +//----------------------------------------------------------------------------- +// ProfileDeviceKey + +ProfileDeviceKey::ProfileDeviceKey(const HMDInfo* info) : + Valid(false) +{ + if (info) + { + PrintedSerial = info->PrintedSerial; + ProductName = SanitizeProductName(info->ProductName); + ProductId = info->ProductId; + HmdType = info->HmdType; + + if (ProductId != 0) + { + Valid = true; + } + } + else + { + ProductId = 0; + HmdType = HmdType_None; + } +} + +String ProfileDeviceKey::SanitizeProductName(String productName) +{ + String result; + + if (!productName.IsEmpty()) + { + const char* product_name = productName.ToCStr(); + + // First strip off "Oculus" + const char* oculus = strstr(product_name, "Oculus "); + if (oculus) + { + product_name = oculus + OVR_strlen("Oculus "); + } + + // And remove spaces from the name + for (const char* s = product_name; *s != 0; s++) + { + if (*s != ' ') + { + result.AppendChar(*s); + } + } + } + + return result; +} + + + +//----------------------------------------------------------------------------- +// Returns the pathname of the JSON file containing the stored profiles +String GetBaseOVRPath(bool create_dir) +{ + String path; + +#if defined(OVR_OS_WIN32) + + TCHAR data_path[MAX_PATH]; + SHGetFolderPath(0, CSIDL_LOCAL_APPDATA, NULL, 0, data_path); + path = String(data_path); + + path += "/Oculus"; + + if (create_dir) + { // Create the Oculus directory if it doesn't exist + WCHAR wpath[128]; + OVR::UTF8Util::DecodeString(wpath, path.ToCStr()); + + DWORD attrib = GetFileAttributes(wpath); + bool exists = attrib != INVALID_FILE_ATTRIBUTES && (attrib & FILE_ATTRIBUTE_DIRECTORY); + if (!exists) + { + CreateDirectory(wpath, NULL); + } + } + +#elif defined(OVR_OS_OS) // Other Microsoft OSs + + // TODO: figure this out. + OVR_UNUSED ( create_dir ); + path = ""; + +#elif defined(OVR_OS_MAC) + + const char* home = getenv("HOME"); + path = home; + path += "/Library/Preferences/Oculus"; + + if (create_dir) + { // Create the Oculus directory if it doesn't exist + DIR* dir = opendir(path); + if (dir == NULL) + { + mkdir(path, S_IRWXU | S_IRWXG | S_IRWXO); + } + else + { + closedir(dir); + } + } + +#else + + const char* home = getenv("HOME"); + path = home; + path += "/.config/Oculus"; + + if (create_dir) + { // Create the Oculus directory if it doesn't exist + DIR* dir = opendir(path); + if (dir == NULL) + { + mkdir(path, S_IRWXU | S_IRWXG | S_IRWXO); + } + else + { + closedir(dir); + } + } + +#endif + + return path; +} + +String ProfileManager::GetProfilePath() +{ + return BasePath + "/ProfileDB.json"; +} + +static JSON* FindTaggedData(JSON* data, const char** tag_names, const char** qtags, int num_qtags) +{ + if (data == NULL || !(data->Name == "TaggedData") || data->Type != JSON_Array) + return NULL; + + JSON* tagged_item = data->GetFirstItem(); + while (tagged_item) + { + JSON* tags = tagged_item->GetItemByName("tags"); + if (tags->Type == JSON_Array && num_qtags == tags->GetArraySize()) + { // Check for a full tag match on each item + int num_matches = 0; + + for (int k=0; kGetFirstItem(); + while (tag) + { + JSON* tagval = tag->GetFirstItem(); + if (tagval && tagval->Name == tag_names[k]) + { + if (tagval->Value == qtags[k]) + num_matches++; + break; + } + tag = tags->GetNextItem(tag); + } + } + + // if all tags were matched then copy the values into this Profile + if (num_matches == num_qtags) + { + JSON* vals = tagged_item->GetItemByName("vals"); + return vals; + } + } + + tagged_item = data->GetNextItem(tagged_item); + } + + return NULL; +} + +static void FilterTaggedData(JSON* data, const char* tag_name, const char* qtag, Array& items) +{ + if (data == NULL || !(data->Name == "TaggedData") || data->Type != JSON_Array) + return; + + JSON* tagged_item = data->GetFirstItem(); + while (tagged_item) + { + JSON* tags = tagged_item->GetItemByName("tags"); + if (tags->Type == JSON_Array) + { // Check for a tag match on the requested tag + + JSON* tag = tags->GetFirstItem(); + while (tag) + { + JSON* tagval = tag->GetFirstItem(); + if (tagval && tagval->Name == tag_name) + { + if (tagval->Value == qtag) + { // Add this item to the output list + items.PushBack(tagged_item); + } + break; + } + tag = tags->GetNextItem(tag); + } + } + + tagged_item = data->GetNextItem(tagged_item); + } +} + + +//----------------------------------------------------------------------------- +// ***** ProfileManager + +template<> ProfileManager* OVR::SystemSingletonBase::SlowGetInstance() +{ + static OVR::Lock lock; + OVR::Lock::Locker locker(&lock); + if (!SingletonInstance) SingletonInstance = new ProfileManager(true); + return SingletonInstance; +} + +ProfileManager::ProfileManager(bool sys_register) : + Changed(false) +{ + // Attempt to get the base path automatically, but this may fail + BasePath = GetBaseOVRPath(false); + + if (sys_register) + PushDestroyCallbacks(); +} + +ProfileManager::~ProfileManager() +{ + ClearProfileData(); +} + +void ProfileManager::OnSystemDestroy() +{ + delete this; +} + +// In the service process it is important to set the base path because this cannot be detected automatically +void ProfileManager::SetBasePath(String basePath) +{ + if (basePath != BasePath) + { + BasePath = basePath; + LoadCache(false); + } +} + +// Clear the local profile cache +void ProfileManager::ClearProfileData() +{ + Lock::Locker lockScope(&ProfileLock); + + ProfileCache.Clear(); + Changed = false; +} + +// Serializes the profiles to disk. +void ProfileManager::Save() +{ + Lock::Locker lockScope(&ProfileLock); + + if (ProfileCache == NULL) + return; + + // Save the profile to disk + BasePath = GetBaseOVRPath(true); // create the base directory if it doesn't exist + String path = GetProfilePath(); + ProfileCache->Save(path); + Changed = false; +} + +// Returns a profile with all system default values +Profile* ProfileManager::GetDefaultProfile(HmdTypeEnum device) +{ + // In the absence of any data, set some reasonable profile defaults. + // However, this is not future proof and developers should still + // provide reasonable default values for queried fields. + + // Biometric data + Profile* profile = CreateProfile(); + profile->SetValue(OVR_KEY_USER, "default"); + profile->SetValue(OVR_KEY_NAME, "Default"); + profile->SetValue(OVR_KEY_GENDER, OVR_DEFAULT_GENDER); + profile->SetFloatValue(OVR_KEY_PLAYER_HEIGHT, OVR_DEFAULT_PLAYER_HEIGHT); + profile->SetFloatValue(OVR_KEY_EYE_HEIGHT, OVR_DEFAULT_EYE_HEIGHT); + profile->SetFloatValue(OVR_KEY_IPD, OVR_DEFAULT_IPD); + float half_ipd[2] = { OVR_DEFAULT_IPD / 2, OVR_DEFAULT_IPD / 2 }; + profile->SetFloatValues(OVR_KEY_EYE_TO_NOSE_DISTANCE, half_ipd, 2); + float dist[2] = {OVR_DEFAULT_NECK_TO_EYE_HORIZONTAL, OVR_DEFAULT_NECK_TO_EYE_VERTICAL}; + profile->SetFloatValues(OVR_KEY_NECK_TO_EYE_DISTANCE, dist, 2); + + // Device specific data + if (device != HmdType_None) + { + if (device == HmdType_CrystalCoveProto || device == HmdType_DK2) + { + profile->SetValue("EyeCup", "A"); + profile->SetIntValue(OVR_KEY_EYE_RELIEF_DIAL, OVR_DEFAULT_EYE_RELIEF_DIAL); + + // TODO: These defaults are a little bogus and designed for continuity with 0.3 + // eye-relief values. We need better measurement-based numbers in future releases + float max_eye_plate[2] = { 0.01965f + 0.018f, 0.01965f + 0.018f }; + profile->SetFloatValues(OVR_KEY_MAX_EYE_TO_PLATE_DISTANCE, max_eye_plate, 2); + } + else + { // DK1 and DKHD variants + profile->SetValue("EyeCup", "A"); + profile->SetIntValue(OVR_KEY_EYE_RELIEF_DIAL, OVR_DEFAULT_EYE_RELIEF_DIAL); + + // TODO: These defaults are a little bogus and designed for continuity with 0.3 + // DK1 distortion. We need better measurement-based numbers in future releases + float max_eye_plate[2] = { 0.02357f + 0.017f, 0.02357f + 0.017f }; + profile->SetFloatValues(OVR_KEY_MAX_EYE_TO_PLATE_DISTANCE, max_eye_plate, 2); + } + } + + return profile; +} + +//------------------------------------------------------------------------------ +void ProfileManager::Read() +{ + LoadCache(false); +} + +// Populates the local profile cache. This occurs on the first access of the profile +// data. All profile operations are performed against the local cache until the +// ProfileManager is released or goes out of scope at which time the cache is serialized +// to disk. +void ProfileManager::LoadCache(bool create) +{ + Lock::Locker lockScope(&ProfileLock); + + ClearProfileData(); + + String path = GetProfilePath(); + + Ptr root = *JSON::Load(path); + if (root == NULL) + { + path = BasePath + "/Profiles.json"; // look for legacy profile + root = *JSON::Load(path); + + if (root == NULL) + { + if (create) + { // Generate a skeleton profile database + root = *JSON::CreateObject(); + root->AddNumberItem("Oculus Profile Version", 2.0); + root->AddItem("Users", JSON::CreateArray()); + root->AddItem("TaggedData", JSON::CreateArray()); + ProfileCache = root; + } + + return; + } + + // Verify the legacy version + JSON* version_item = root->GetFirstItem(); + if (version_item->Name == "Oculus Profile Version") + { + int major = atoi(version_item->Value.ToCStr()); + if (major != 1) + return; // don't use the file on unsupported major version number + } + else + { + return; // invalid file + } + + // Convert the legacy format to the new database format + LoadV1Profiles(root); + } + else + { + // Verify the file format and version + JSON* version_item = root->GetFirstItem(); + if (version_item && version_item->Name == "Oculus Profile Version") + { + int major = atoi(version_item->Value.ToCStr()); + if (major != 2) + return; // don't use the file on unsupported major version number + } + else + { + return; // invalid file + } + + ProfileCache = root; // store the database contents for traversal + } +} + +void ProfileManager::LoadV1Profiles(JSON* v1) +{ + JSON* item0 = v1->GetFirstItem(); + JSON* item1 = v1->GetNextItem(item0); + JSON* item2 = v1->GetNextItem(item1); + + OVR_ASSERT(item1 && item2); + if(!item1 || !item2) + return; + + // Create the new profile database + Ptr root = *JSON::CreateObject(); + root->AddNumberItem("Oculus Profile Version", 2.0); + root->AddItem("Users", JSON::CreateArray()); + root->AddItem("TaggedData", JSON::CreateArray()); + ProfileCache = root; + + const char* default_dk1_user = item1->Value; + + // Read the number of profiles + int profileCount = (int)item2->dValue; + JSON* profileItem = item2; + + for (int p=0; pGetNextItem(profileItem); + if (profileItem == NULL) + break; + + if (profileItem->Name == "Profile") + { + // Read the required Name field + const char* profileName; + JSON* item = profileItem->GetFirstItem(); + + if (item && (item->Name == "Name")) + { + profileName = item->Value; + } + else + { + return; // invalid field + } + + // Read the user profile fields + if (CreateUser(profileName, profileName)) + { + const char* tag_names[2] = {"User", "Product"}; + const char* tags[2]; + tags[0] = profileName; + + Ptr user_profile = *CreateProfile(); + user_profile->SetValue(OVR_KEY_NAME, profileName); + + float neckeye[2] = { 0, 0 }; + + item = profileItem->GetNextItem(item); + while (item) + { + if (item->Type != JSON_Object) + { + if (item->Name == OVR_KEY_PLAYER_HEIGHT) + { // Add an explicit eye height + + } + if (item->Name == "NeckEyeHori") + neckeye[0] = (float)item->dValue; + else if (item->Name == "NeckEyeVert") + neckeye[1] = (float)item->dValue; + else + user_profile->SetValue(item); + } + else + { + // Add the user/device tag values + const char* device_name = item->Name.ToCStr(); + Ptr device_profile = *CreateProfile(); + + JSON* device_item = item->GetFirstItem(); + while (device_item) + { + device_profile->SetValue(device_item); + device_item = item->GetNextItem(device_item); + } + + tags[1] = device_name; + SetTaggedProfile(tag_names, tags, 2, device_profile); + } + + item = profileItem->GetNextItem(item); + } + + // Add an explicit eye-height field + float player_height = user_profile->GetFloatValue(OVR_KEY_PLAYER_HEIGHT, + OVR_DEFAULT_PLAYER_HEIGHT); + if (player_height > 0) + { + char gender[16]; + user_profile->GetValue(OVR_KEY_GENDER, gender, 16); + + const float EYE_TO_HEADTOP_RATIO = 0.44538f; + const float MALE_AVG_HEAD_HEIGHT = 0.232f; + const float FEMALE_AVG_HEAD_HEIGHT = 0.218f; + + // compute distance from top of skull to the eye + float head_height; + if (OVR_strcmp(gender, "Female") == 0) + head_height = FEMALE_AVG_HEAD_HEIGHT; + else + head_height = MALE_AVG_HEAD_HEIGHT; + + float skull = EYE_TO_HEADTOP_RATIO * head_height; + float eye_height = player_height - skull; + + user_profile->SetFloatValue(OVR_KEY_EYE_HEIGHT, eye_height); + } + + // Convert NeckEye values to an array + if (neckeye[0] > 0 && neckeye[1] > 0) + user_profile->SetFloatValues(OVR_KEY_NECK_TO_EYE_DISTANCE, neckeye, 2); + + // Add the user tag values + SetTaggedProfile(tag_names, tags, 1, user_profile); + } + } + } + + // since V1 profiles were only for DK1, the assign the user to all DK1's + const char* tag_names[1] = { "Product" }; + const char* tags[1] = { "RiftDK1" }; + Ptr product_profile = *CreateProfile(); + product_profile->SetValue("DefaultUser", default_dk1_user); + SetTaggedProfile(tag_names, tags, 1, product_profile); +} + +// Returns the number of stored profiles for this device type +int ProfileManager::GetUserCount() +{ + Lock::Locker lockScope(&ProfileLock); + + if (ProfileCache == NULL) + { // Load the cache + LoadCache(false); + if (ProfileCache == NULL) + return 0; + } + + JSON* users = ProfileCache->GetItemByName("Users"); + if (users == NULL) + return 0; + + return users->GetItemCount(); +} + +bool ProfileManager::CreateUser(const char* user, const char* name) +{ + Lock::Locker lockScope(&ProfileLock); + + if (ProfileCache == NULL) + { // Load the cache + LoadCache(true); + if (ProfileCache == NULL) + return false; + } + + JSON* users = ProfileCache->GetItemByName("Users"); + if (users == NULL) + { // Generate the User section + users = JSON::CreateArray(); + ProfileCache->AddItem("Users", users); +//TODO: Insert this before the TaggedData + } + + // Search for the pre-existence of this user + JSON* user_item = users->GetFirstItem(); + int index = 0; + while (user_item) + { + JSON* userid = user_item->GetItemByName("User"); + int compare = OVR_strcmp(user, userid->Value); + if (compare == 0) + { // The user already exists so simply update the fields + JSON* name_item = user_item->GetItemByName("Name"); + if (name_item && OVR_strcmp(name, name_item->Value) != 0) + { + name_item->Value = name; + Changed = true; + } + return true; + } + else if (compare < 0) + { // A new user should be placed before this item + break; + } + + user_item = users->GetNextItem(user_item); + index++; + } + + // Create and fill the user struct + JSON* new_user = JSON::CreateObject(); + new_user->AddStringItem(OVR_KEY_USER, user); + new_user->AddStringItem(OVR_KEY_NAME, name); + // user_item->AddStringItem("Password", password); + + if (user_item == NULL) + users->AddArrayElement(new_user); + else + users->InsertArrayElement(index, new_user); + + Changed = true; + return true; +} + +bool ProfileManager::HasUser(const char* user) +{ + Lock::Locker lockScope(&ProfileLock); + + if (ProfileCache == NULL) + { // Load the cache + LoadCache(false); + if (ProfileCache == NULL) + return false; + } + + JSON* users = ProfileCache->GetItemByName("Users"); + if (users == NULL) + return false; + + // Remove this user from the User table + JSON* user_item = users->GetFirstItem(); + while (user_item) + { + JSON* userid = user_item->GetItemByName("User"); + if (OVR_strcmp(user, userid->Value) == 0) + { + return true; + } + + user_item = users->GetNextItem(user_item); + } + + return false; +} + +// Returns the user id of a specific user in the list. The returned +// memory is locally allocated and should not be stored or deleted. Returns NULL +// if the index is invalid +const char* ProfileManager::GetUser(unsigned int index) +{ + Lock::Locker lockScope(&ProfileLock); + + if (ProfileCache == NULL) + { // Load the cache + LoadCache(false); + if (ProfileCache == NULL) + return NULL; + } + + JSON* users = ProfileCache->GetItemByName("Users"); + + if (users && index < users->GetItemCount()) + { + JSON* user_item = users->GetItemByIndex(index); + if (user_item) + { + JSON* user = user_item->GetFirstItem(); + if (user) + { + JSON* userid = user_item->GetItemByName(OVR_KEY_USER); + if (userid) + return userid->Value.ToCStr(); + } + } + } + + + return NULL; +} + +bool ProfileManager::RemoveUser(const char* user) +{ + Lock::Locker lockScope(&ProfileLock); + + if (ProfileCache == NULL) + { // Load the cache + LoadCache(false); + if (ProfileCache == NULL) + return true; + } + + JSON* users = ProfileCache->GetItemByName("Users"); + if (users == NULL) + return true; + + // Remove this user from the User table + JSON* user_item = users->GetFirstItem(); + while (user_item) + { + JSON* userid = user_item->GetItemByName("User"); + if (OVR_strcmp(user, userid->Value) == 0) + { // Delete the user entry + user_item->RemoveNode(); + user_item->Release(); + Changed = true; + break; + } + + user_item = users->GetNextItem(user_item); + } + + // Now remove all data entries with this user tag + JSON* tagged_data = ProfileCache->GetItemByName("TaggedData"); + Array user_items; + FilterTaggedData(tagged_data, "User", user, user_items); + for (unsigned int i=0; iRemoveNode(); + user_items[i]->Release(); + Changed = true; + } + + return Changed; +} + +Profile* ProfileManager::CreateProfile() +{ + Profile* profile = new Profile(BasePath); + return profile; +} + +const char* ProfileManager::GetDefaultUser(const ProfileDeviceKey& deviceKey) +{ + const char* product_str = deviceKey.ProductName.IsEmpty() ? NULL : deviceKey.ProductName.ToCStr(); + const char* serial_str = deviceKey.PrintedSerial.IsEmpty() ? NULL : deviceKey.PrintedSerial.ToCStr(); + + return GetDefaultUser(product_str, serial_str); +} + +// Returns the name of the profile that is marked as the current default user. +const char* ProfileManager::GetDefaultUser(const char* product, const char* serial) +{ + const char* tag_names[2] = {"Product", "Serial"}; + const char* tags[2]; + + if (product && serial) + { + tags[0] = product; + tags[1] = serial; + // Look for a default user on this specific device + Ptr p = *GetTaggedProfile(tag_names, tags, 2); + if (p == NULL) + { // Look for a default user on this product + p = *GetTaggedProfile(tag_names, tags, 1); + } + + if (p) + { + const char* user = p->GetValue("DefaultUser"); + if (user != NULL && user[0] != 0) + { + TempBuff = user; + return TempBuff.ToCStr(); + } + } + } + + return NULL; +} + +//----------------------------------------------------------------------------- +bool ProfileManager::SetDefaultUser(const ProfileDeviceKey& deviceKey, const char* user) +{ + const char* tag_names[2] = {"Product", "Serial"}; + const char* tags[2]; + + const char* product_str = deviceKey.ProductName.IsEmpty() ? NULL : deviceKey.ProductName.ToCStr(); + const char* serial_str = deviceKey.PrintedSerial.IsEmpty() ? NULL : deviceKey.PrintedSerial.ToCStr(); + + if (product_str && serial_str) + { + tags[0] = product_str; + tags[1] = serial_str; + + Ptr p = *CreateProfile(); + p->SetValue("DefaultUser", user); + return SetTaggedProfile(tag_names, tags, 2, p); + } + + return false; +} + +//----------------------------------------------------------------------------- +Profile* ProfileManager::GetTaggedProfile(const char** tag_names, const char** tags, int num_tags) +{ + Lock::Locker lockScope(&ProfileLock); + + if (ProfileCache == NULL) + { // Load the cache + LoadCache(false); + if (ProfileCache == NULL) + return NULL; + } + + JSON* tagged_data = ProfileCache->GetItemByName("TaggedData"); + OVR_ASSERT(tagged_data); + if (tagged_data == NULL) + return NULL; + + Profile* profile = new Profile(BasePath); + + JSON* vals = FindTaggedData(tagged_data, tag_names, tags, num_tags); + if (vals) + { + JSON* item = vals->GetFirstItem(); + while (item) + { + //printf("Add %s, %s\n", item->Name.ToCStr(), item->Value.ToCStr()); + //profile->Settings.Set(item->Name, item->Value); + profile->SetValue(item); + item = vals->GetNextItem(item); + } + + return profile; + } + else + { + profile->Release(); + return NULL; + } +} + +//----------------------------------------------------------------------------- +bool ProfileManager::SetTaggedProfile(const char** tag_names, const char** tags, int num_tags, Profile* profile) +{ + Lock::Locker lockScope(&ProfileLock); + + if (ProfileCache == NULL) + { // Load the cache + LoadCache(true); + if (ProfileCache == NULL) + return false; // TODO: Generate a new profile DB + } + + JSON* tagged_data = ProfileCache->GetItemByName("TaggedData"); + OVR_ASSERT(tagged_data); + if (tagged_data == NULL) + return false; + + // Get the cached tagged data section + JSON* vals = FindTaggedData(tagged_data, tag_names, tags, num_tags); + if (vals == NULL) + { + JSON* tagged_item = JSON::CreateObject(); + JSON* taglist = JSON::CreateArray(); + for (int i=0; iAddStringItem(tag_names[i], tags[i]); + taglist->AddArrayElement(k); + } + + vals = JSON::CreateObject(); + + tagged_item->AddItem("tags", taglist); + tagged_item->AddItem("vals", vals); + tagged_data->AddArrayElement(tagged_item); + } + + // Now add or update each profile setting in cache + for (unsigned int i=0; iValues.GetSize(); i++) + { + JSON* value = profile->Values[i]; + + bool found = false; + JSON* item = vals->GetFirstItem(); + while (item) + { + if (value->Name == item->Name) + { + // Don't allow a pre-existing type to be overridden + OVR_ASSERT(value->Type == item->Type); + + if (value->Type == item->Type) + { // Check for the same value + if (value->Type == JSON_Array) + { // Update each array item + if (item->GetArraySize() == value->GetArraySize()) + { // Update each value (assumed to be basic types and not array of objects) + JSON* value_element = value->GetFirstItem(); + JSON* item_element = item->GetFirstItem(); + while (item_element && value_element) + { + if (value_element->Type == JSON_String) + { + if (item_element->Value != value_element->Value) + { // Overwrite the changed value and mark for file update + item_element->Value = value_element->Value; + Changed = true; + } + } + else { + if (item_element->dValue != value_element->dValue) + { // Overwrite the changed value and mark for file update + item_element->dValue = value_element->dValue; + Changed = true; + } + } + + value_element = value->GetNextItem(value_element); + item_element = item->GetNextItem(item_element); + } + } + else + { // if the array size changed, simply create a new one +// TODO: Create the new array + } + } + else if (value->Type == JSON_String) + { + if (item->Value != value->Value) + { // Overwrite the changed value and mark for file update + item->Value = value->Value; + Changed = true; + } + } + else { + if (item->dValue != value->dValue) + { // Overwrite the changed value and mark for file update + item->dValue = value->dValue; + Changed = true; + } + } + } + else + { + return false; + } + + found = true; + break; + } + + item = vals->GetNextItem(item); + } + + if (!found) + { // Add the new value + Changed = true; + + if (value->Type == JSON_String) + vals->AddStringItem(value->Name, value->Value); + else if (value->Type == JSON_Bool) + vals->AddBoolItem(value->Name, ((int)value->dValue != 0)); + else if (value->Type == JSON_Number) + vals->AddNumberItem(value->Name, value->dValue); + else if (value->Type == JSON_Array) + vals->AddItem(value->Name, value->Copy()); + else + { + OVR_ASSERT(false); + Changed = false; + } + } + } + + return true; +} + +//----------------------------------------------------------------------------- +Profile* ProfileManager::GetDefaultUserProfile(const ProfileDeviceKey& deviceKey) +{ + const char* userName = GetDefaultUser(deviceKey); + + Profile* profile = GetProfile(deviceKey, userName); + + if (!profile) + { + profile = GetDefaultProfile(deviceKey.HmdType); + } + + return profile; +} + +//----------------------------------------------------------------------------- +Profile* ProfileManager::GetProfile(const ProfileDeviceKey& deviceKey, const char* user) +{ + Lock::Locker lockScope(&ProfileLock); + + if (ProfileCache == NULL) + { // Load the cache + LoadCache(false); + if (ProfileCache == NULL) + return NULL; + } + + Profile* profile = new Profile(BasePath); + + if (deviceKey.Valid) + { + if (!profile->LoadDeviceProfile(deviceKey) && (user == NULL)) + { + profile->Release(); + return NULL; + } + } + + if (user) + { + const char* product_str = deviceKey.ProductName.IsEmpty() ? NULL : deviceKey.ProductName.ToCStr(); + const char* serial_str = deviceKey.PrintedSerial.IsEmpty() ? NULL : deviceKey.PrintedSerial.ToCStr(); + + if (!profile->LoadProfile(ProfileCache.GetPtr(), user, product_str, serial_str)) + { + profile->Release(); + return NULL; + } + } + + return profile; +} + + +//----------------------------------------------------------------------------- +// ***** Profile + +Profile::~Profile() +{ + ValMap.Clear(); + for (unsigned int i=0; iRelease(); + + Values.Clear(); +} + +bool Profile::Close() +{ + // TODO: + return true; +} + +//----------------------------------------------------------------------------- +void Profile::CopyItems(JSON* root, String prefix) +{ + JSON* item = root->GetFirstItem(); + while (item) + { + String item_name; + if (prefix.IsEmpty()) + item_name = item->Name; + else + item_name = prefix + "." + item->Name; + + if (item->Type == JSON_Object) + { // recursively copy the children + + CopyItems(item, item_name); + } + else + { + //Settings.Set(item_name, item->Value); + SetValue(item); + } + + item = root->GetNextItem(item); + } +} + +//----------------------------------------------------------------------------- +bool Profile::LoadDeviceFile(unsigned int productId, const char* printedSerialNumber) +{ + if (printedSerialNumber[0] == 0) + return false; + + String path = BasePath + "/Devices.json"; + + // Load the device profiles + Ptr root = *JSON::Load(path); + if (root == NULL) + return false; + + // Quick sanity check of the file type and format before we parse it + JSON* version = root->GetFirstItem(); + if (version && version->Name == "Oculus Device Profile Version") + { + int major = atoi(version->Value.ToCStr()); + if (major > MAX_DEVICE_PROFILE_MAJOR_VERSION) + return false; // don't parse the file on unsupported major version number + } + else + { + return false; + } + + JSON* device = root->GetNextItem(version); + while (device) + { + if (device->Name == "Device") + { + JSON* product_item = device->GetItemByName("ProductID"); + JSON* serial_item = device->GetItemByName("Serial"); + if (product_item && serial_item && + (product_item->dValue == productId) && (serial_item->Value == printedSerialNumber)) + { + // found the entry for this device so recursively copy all the settings to the profile + CopyItems(device, ""); + return true; + } + } + + device = root->GetNextItem(device); + } + + return false; +} + +#if 0 +//----------------------------------------------------------------------------- +static int BCDByte(unsigned int byte) +{ + int digit1 = (byte >> 4) & 0x000f; + int digit2 = byte & 0x000f; + int decimal = digit1 * 10 + digit2; + return decimal; +} +#endif + +//----------------------------------------------------------------------------- +bool Profile::LoadDeviceProfile(const ProfileDeviceKey& deviceKey) +{ + bool success = false; + if (!deviceKey.Valid) + return false; + +#if 0 + int dev_major = BCDByte((sinfo.Version >> 8) & 0x00ff); + OVR_UNUSED(dev_major); + //int dev_minor = BCDByte(sinfo.Version & 0xff); + + //if (dev_minor > 18) + //{ // If the firmware supports hardware stored profiles then grab the device profile + // from the sensor + // TBD: Implement this + //} + //else + { +#endif + // Grab the model and serial number from the device and use it to access the device + // profile file stored on the local machine + success = LoadDeviceFile(deviceKey.ProductId, deviceKey.PrintedSerial); + //} + + return success; +} + +//----------------------------------------------------------------------------- +bool Profile::LoadUser(JSON* root, + const char* user, + const char* model_name, + const char* device_serial) +{ + if (user == NULL) + return false; + + // For legacy files, convert to old style names + //if (model_name && OVR_strcmp(model_name, "Oculus Rift DK1") == 0) + // model_name = "RiftDK1"; + + bool user_found = false; + JSON* data = root->GetItemByName("TaggedData"); + if (data) + { + const char* tag_names[3]; + const char* tags[3]; + tag_names[0] = "User"; + tags[0] = user; + int num_tags = 1; + + if (model_name) + { + tag_names[num_tags] = "Product"; + tags[num_tags] = model_name; + num_tags++; + } + + if (device_serial) + { + tag_names[num_tags] = "Serial"; + tags[num_tags] = device_serial; + num_tags++; + } + + // Retrieve all tag permutations + for (int combos=1; combos<=num_tags; combos++) + { + for (int i=0; i<(num_tags - combos + 1); i++) + { + JSON* vals = FindTaggedData(data, tag_names+i, tags+i, combos); + if (vals) + { + if (i==0) // This tag-combination contains a user match + user_found = true; + + // Add the values to the Profile. More specialized multi-tag values + // will take precedence over and overwrite generalized ones + // For example: ("Me","RiftDK1").IPD would overwrite ("Me").IPD + JSON* item = vals->GetFirstItem(); + while (item) + { + //printf("Add %s, %s\n", item->Name.ToCStr(), item->Value.ToCStr()); + //Settings.Set(item->Name, item->Value); + SetValue(item); + item = vals->GetNextItem(item); + } + } + } + } + } + + if (user_found) + SetValue(OVR_KEY_USER, user); + + return user_found; +} + + +//----------------------------------------------------------------------------- +bool Profile::LoadProfile(JSON* root, + const char* user, + const char* device_model, + const char* device_serial) +{ + if (!LoadUser(root, user, device_model, device_serial)) + return false; + + return true; +} + + +//----------------------------------------------------------------------------- +char* Profile::GetValue(const char* key, char* val, int val_length) const +{ + JSON* value = NULL; + if (ValMap.Get(key, &value)) + { + OVR_strcpy(val, val_length, value->Value.ToCStr()); + return val; + } + else + { + val[0] = 0; + return NULL; + } +} + +//----------------------------------------------------------------------------- +const char* Profile::GetValue(const char* key) +{ + // Non-reentrant query. The returned buffer can only be used until the next call + // to GetValue() + JSON* value = NULL; + if (ValMap.Get(key, &value)) + { + TempVal = value->Value; + return TempVal.ToCStr(); + } + else + { + return NULL; + } +} + +//----------------------------------------------------------------------------- +int Profile::GetNumValues(const char* key) const +{ + JSON* value = NULL; + if (ValMap.Get(key, &value)) + { + if (value->Type == JSON_Array) + return value->GetArraySize(); + else + return 1; + } + else + return 0; +} + +//----------------------------------------------------------------------------- +bool Profile::GetBoolValue(const char* key, bool default_val) const +{ + JSON* value = NULL; + if (ValMap.Get(key, &value) && value->Type == JSON_Bool) + return (value->dValue != 0); + else + return default_val; +} + +//----------------------------------------------------------------------------- +int Profile::GetIntValue(const char* key, int default_val) const +{ + JSON* value = NULL; + if (ValMap.Get(key, &value) && value->Type == JSON_Number) + return (int)(value->dValue); + else + return default_val; +} + +//----------------------------------------------------------------------------- +float Profile::GetFloatValue(const char* key, float default_val) const +{ + JSON* value = NULL; + if (ValMap.Get(key, &value) && value->Type == JSON_Number) + return (float)(value->dValue); + else + return default_val; +} + +//----------------------------------------------------------------------------- +int Profile::GetFloatValues(const char* key, float* values, int num_vals) const +{ + JSON* value = NULL; + if (ValMap.Get(key, &value) && value->Type == JSON_Array) + { + int val_count = Alg::Min(value->GetArraySize(), num_vals); + JSON* item = value->GetFirstItem(); + int count=0; + while (item && count < val_count) + { + if (item->Type == JSON_Number) + values[count] = (float)item->dValue; + else + break; + + count++; + item = value->GetNextItem(item); + } + + return count; + } + else + { + return 0; + } +} + +//----------------------------------------------------------------------------- +double Profile::GetDoubleValue(const char* key, double default_val) const +{ + JSON* value = NULL; + if (ValMap.Get(key, &value) && value->Type == JSON_Number) + return value->dValue; + else + return default_val; +} + +//----------------------------------------------------------------------------- +int Profile::GetDoubleValues(const char* key, double* values, int num_vals) const +{ + JSON* value = NULL; + if (ValMap.Get(key, &value) && value->Type == JSON_Array) + { + int val_count = Alg::Min(value->GetArraySize(), num_vals); + JSON* item = value->GetFirstItem(); + int count=0; + while (item && count < val_count) + { + if (item->Type == JSON_Number) + values[count] = item->dValue; + else + break; + + count++; + item = value->GetNextItem(item); + } + + return count; + } + return 0; +} + +//----------------------------------------------------------------------------- +void Profile::SetValue(JSON* val) +{ + if (val == NULL) + return; + + if (val->Type == JSON_Number) + SetDoubleValue(val->Name, val->dValue); + else if (val->Type == JSON_Bool) + SetBoolValue(val->Name, (val->dValue != 0)); + else if (val->Type == JSON_String) + SetValue(val->Name, val->Value); + else if (val->Type == JSON_Array) + { + // Create a copy of the array + JSON* value = val->Copy(); + Values.PushBack(value); + ValMap.Set(value->Name, value); + } +} + +//----------------------------------------------------------------------------- +void Profile::SetValue(const char* key, const char* val) +{ + if (key == NULL || val == NULL) + return; + + JSON* value = NULL; + if (ValMap.Get(key, &value)) + { + value->Value = val; + } + else + { + value = JSON::CreateString(val); + value->Name = key; + + Values.PushBack(value); + ValMap.Set(key, value); + } +} + +//----------------------------------------------------------------------------- +void Profile::SetBoolValue(const char* key, bool val) +{ + if (key == NULL) + return; + + JSON* value = NULL; + if (ValMap.Get(key, &value)) + { + value->dValue = val; + } + else + { + value = JSON::CreateBool(val); + value->Name = key; + + Values.PushBack(value); + ValMap.Set(key, value); + } +} + +//----------------------------------------------------------------------------- +void Profile::SetIntValue(const char* key, int val) +{ + SetDoubleValue(key, val); +} + +//----------------------------------------------------------------------------- +void Profile::SetFloatValue(const char* key, float val) +{ + SetDoubleValue(key, val); +} + +//----------------------------------------------------------------------------- +void Profile::SetFloatValues(const char* key, const float* vals, int num_vals) +{ + JSON* value = NULL; + int val_count = 0; + if (ValMap.Get(key, &value)) + { + if (value->Type == JSON_Array) + { + // truncate the existing array if fewer entries provided + int num_existing_vals = value->GetArraySize(); + for (int i=num_vals; iRemoveLast(); + + JSON* item = value->GetFirstItem(); + while (item && val_count < num_vals) + { + if (item->Type == JSON_Number) + item->dValue = vals[val_count]; + + item = value->GetNextItem(item); + val_count++; + } + } + else + { + return; // Maybe we should change the data type? + } + } + else + { + value = JSON::CreateArray(); + value->Name = key; + + Values.PushBack(value); + ValMap.Set(key, value); + } + + for (; val_count < num_vals; val_count++) + value->AddArrayNumber(vals[val_count]); +} + +//----------------------------------------------------------------------------- +void Profile::SetDoubleValue(const char* key, double val) +{ + JSON* value = NULL; + if (ValMap.Get(key, &value)) + { + value->dValue = val; + } + else + { + value = JSON::CreateNumber(val); + value->Name = key; + + Values.PushBack(value); + ValMap.Set(key, value); + } +} + +//----------------------------------------------------------------------------- +void Profile::SetDoubleValues(const char* key, const double* vals, int num_vals) +{ + JSON* value = NULL; + int val_count = 0; + if (ValMap.Get(key, &value)) + { + if (value->Type == JSON_Array) + { + // truncate the existing array if fewer entries provided + int num_existing_vals = value->GetArraySize(); + for (int i=num_vals; iRemoveLast(); + + JSON* item = value->GetFirstItem(); + while (item && val_count < num_vals) + { + if (item->Type == JSON_Number) + item->dValue = vals[val_count]; + + item = value->GetNextItem(item); + val_count++; + } + } + else + { + return; // Maybe we should change the data type? + } + } + else + { + value = JSON::CreateArray(); + value->Name = key; + + Values.PushBack(value); + ValMap.Set(key, value); + } + + for (; val_count < num_vals; val_count++) + value->AddArrayNumber(vals[val_count]); +} + +//------------------------------------------------------------------------------ +bool Profile::IsDefaultProfile() +{ + return 0 == OVR::String::CompareNoCase("Default", GetValue(OVR_KEY_NAME)); +} + + +} // namespace OVR diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/OVR_Profile.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/OVR_Profile.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,222 @@ +/************************************************************************************ + +Filename : OVR_Profile.h +Content : Structs and functions for loading and storing device profile settings +Created : February 14, 2013 +Notes : + Profiles are used to store per-user settings that can be transferred and used + across multiple applications. For example, player IPD can be configured once + and reused for a unified experience across games. Configuration and saving of profiles + can be accomplished in game via the Profile API or by the official Oculus Configuration + Utility. + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#ifndef OVR_Profile_h +#define OVR_Profile_h + +#include "OVR_CAPI_Keys.h" + +#include "Sensors/OVR_DeviceConstants.h" +#include "Kernel/OVR_String.h" +#include "Kernel/OVR_RefCount.h" +#include "Kernel/OVR_Array.h" +#include "Kernel/OVR_StringHash.h" +#include "Kernel/OVR_System.h" + +namespace OVR { + +class HMDInfo; // Opaque forward declaration +class Profile; +class JSON; + + +// Device key for looking up profiles +struct ProfileDeviceKey +{ + ProfileDeviceKey(const HMDInfo* info); + + // Initialized properly? + bool Valid; + + // The HMD type + HmdTypeEnum HmdType; + + // This is the 12 character serial number printed on the HMD + String PrintedSerial; + + // This is the product name string of the USB sensor device + // Note: It has been modified from the original to remove spaces and strip off "Oculus" + String ProductName; + + // This is the product id from the HID info of the USB sensor device + unsigned ProductId; + + static String SanitizeProductName(String productName); +}; + + +// ----------------------------------------------------------------------------- +// ***** ProfileManager + +// Profiles are interfaced through a ProfileManager object. Applications should +// create a ProfileManager each time they intend to read or write user profile data. +// The scope of the ProfileManager object defines when disk I/O is performed. Disk +// reads are performed on the first profile access and disk writes are performed when +// the ProfileManager goes out of scope. All profile interactions between these times +// are performed in local memory and are fast. A typical profile interaction might +// look like this: +// +// { +// Ptr pm = *ProfileManager::Create(); +// Ptr profile = pm->LoadProfile(Profile_RiftDK1, +// pm->GetDefaultProfileName(Profile_RiftDK1)); +// if (profile) +// { // Retrieve the current profile settings +// } +// } // Profile will be destroyed and any disk I/O completed when going out of scope +class ProfileManager : public NewOverrideBase, public SystemSingletonBase +{ + friend class OVR::SystemSingletonBase; + +protected: + ProfileManager(bool sys_register); + virtual ~ProfileManager(); + virtual void OnSystemDestroy(); + +protected: + // Synchronize ProfileManager access since it may be accessed from multiple threads, + // as it's shared through DeviceManager. + Lock ProfileLock; + Ptr ProfileCache; + bool Changed; + String TempBuff; + String BasePath; + +public: + // In the service process it is important to set the base path because this cannot be detected automatically + void SetBasePath(String basePath); + + int GetUserCount(); + const char* GetUser(unsigned int index); + bool CreateUser(const char* user, const char* name); + bool HasUser(const char* user); + bool RemoveUser(const char* user); + const char* GetDefaultUser(const ProfileDeviceKey& deviceKey); + bool SetDefaultUser(const ProfileDeviceKey& deviceKey, const char* user); + + virtual Profile* CreateProfile(); + Profile* GetProfile(const ProfileDeviceKey& deviceKey, const char* user); + Profile* GetDefaultUserProfile(const ProfileDeviceKey& deviceKey); + Profile* GetDefaultProfile(HmdTypeEnum device); + Profile* GetTaggedProfile(const char** key_names, const char** keys, int num_keys); + bool SetTaggedProfile(const char** key_names, const char** keys, int num_keys, Profile* profile); + + // Force re-reading the settings + void Read(); + +protected: + // Force writing the settings + void ClearProfileData(); + void Save(); + + String GetProfilePath(); + void LoadCache(bool create); + void LoadV1Profiles(JSON* v1); + const char* GetDefaultUser(const char* product, const char* serial); +}; + + +//------------------------------------------------------------------- +// ***** Profile + +// The base profile for all users. This object is not created directly. +// Instead derived device objects provide add specific device members to +// the base profile +class Profile : public RefCountBase +{ +protected: + OVR::Hash ValMap; + OVR::Array Values; + OVR::String TempVal; + String BasePath; + +public: + ~Profile(); + + int GetNumValues(const char* key) const; + const char* GetValue(const char* key); + char* GetValue(const char* key, char* val, int val_length) const; + bool GetBoolValue(const char* key, bool default_val) const; + int GetIntValue(const char* key, int default_val) const; + float GetFloatValue(const char* key, float default_val) const; + int GetFloatValues(const char* key, float* values, int num_vals) const; + double GetDoubleValue(const char* key, double default_val) const; + int GetDoubleValues(const char* key, double* values, int num_vals) const; + + void SetValue(const char* key, const char* val); + void SetBoolValue(const char* key, bool val); + void SetIntValue(const char* key, int val); + void SetFloatValue(const char* key, float val); + void SetFloatValues(const char* key, const float* vals, int num_vals); + void SetDoubleValue(const char* key, double val); + void SetDoubleValues(const char* key, const double* vals, int num_vals); + + bool IsDefaultProfile(); + + bool Close(); + +protected: + Profile(String basePath) : + BasePath(basePath) + { + } + + void SetValue(JSON* val); + + static bool LoadProfile(const ProfileDeviceKey& deviceKey, + const char* user, + Profile** profile); + void CopyItems(JSON* root, String prefix); + + bool LoadDeviceFile(unsigned int device_id, const char* serial); + bool LoadDeviceProfile(const ProfileDeviceKey& deviceKey); + + bool LoadProfile(JSON* root, + const char* user, + const char* device_model, + const char* device_serial); + + bool LoadUser(JSON* root, + const char* user, + const char* device_name, + const char* device_serial); + + friend class ProfileManager; + friend class WProfileManager; +}; + +// This path should be passed into the ProfileManager +String GetBaseOVRPath(bool create_dir); + + +} // namespace OVR + +#endif // OVR_Profile_h diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/OVR_SerialFormat.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/OVR_SerialFormat.cpp Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,451 @@ +/************************************************************************************ + +Filename : OVR_System.cpp +Content : General kernel initialization/cleanup, including that + of the memory allocator. +Created : September 19, 2012 +Notes : + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#include "OVR_SerialFormat.h" + +#ifdef SERIAL_FORMAT_UNIT_TEST +#include "Kernel/OVR_Log.h" +#endif + +namespace OVR { + + +//// Serial Format Detection + +SerialFormatType DetectBufferFormat(uint8_t firstByte, int sizeInBytes) +{ + switch (firstByte) + { + case SerialFormatType_DK2: + if (sizeInBytes == 12) + { + return SerialFormatType_DK2; + } + break; + default: + break; + } + + return SerialFormatType_Invalid; +} + + +//// DK2 Helpers + +static bool ValidDK2ProductId(int x) +{ + switch (x) + { + case DK2ProductId_DK1: + case DK2ProductId_DK2: + case DK2ProductId_Refurb: + return true; + default: + break; + } + + return false; +} + +static bool ValidDK2PartId(int x) +{ + switch (x) + { + case DK2PartId_HMD: + case DK2PartId_PTC: + case DK2PartId_Carton: + return true; + default: + break; + } + + return false; +} + + +//// DK2BinarySerialFormat + +bool DK2BinarySerialFormat::FromBuffer(const uint8_t buffer[12], bool allowUnknownTypes) +{ + // Format Type must be 0 + + int formatType = buffer[0]; + + if (formatType != SerialFormatType_DK2) + { + return false; + } + + // Product Id + + int productId = buffer[1] >> 4; + + if (!allowUnknownTypes && !ValidDK2ProductId(productId)) + { + return false; + } + + ProductId = (DK2ProductId)productId; + + // Part Id + + int partId = buffer[1] & 15; + + if (!allowUnknownTypes && !ValidDK2PartId(partId)) + { + return false; + } + + PartId = (DK2PartId)partId; + + // Minutes Since Epoch (May 1, 2014) + + MinutesSinceEpoch = buffer[4] | ((uint32_t)buffer[3] << 8) | ((uint32_t)buffer[2] << 16); + + // Unit number on that day + + UnitNumber = buffer[6] | ((uint32_t)buffer[5] << 8); + + // Hash of MAC address + + MacHash[0] = buffer[7]; + MacHash[1] = buffer[8]; + MacHash[2] = buffer[9]; + MacHash[3] = buffer[10]; + MacHash[4] = buffer[11]; + + return true; +} + +void DK2BinarySerialFormat::ToBuffer(uint8_t buffer[12]) +{ + // Serialize to buffer + buffer[0] = SerialFormatType_DK2; + buffer[1] = (uint8_t)((ProductId << 4) | (PartId)); + buffer[2] = (uint8_t)(MinutesSinceEpoch >> 16); + buffer[3] = (uint8_t)(MinutesSinceEpoch >> 8); + buffer[4] = (uint8_t)MinutesSinceEpoch; + buffer[5] = (uint8_t)(UnitNumber >> 8); + buffer[6] = (uint8_t)UnitNumber; + + buffer[7] = MacHash[0]; + buffer[8] = MacHash[1]; + buffer[9] = MacHash[2]; + buffer[10] = MacHash[3]; + buffer[11] = MacHash[4]; +} + +bool DK2BinarySerialFormat::operator==(const DK2BinarySerialFormat& rhs) +{ + if (ProductId != rhs.ProductId) + return false; + if (PartId != rhs.PartId) + return false; + if (MinutesSinceEpoch != rhs.MinutesSinceEpoch) + return false; + if (UnitNumber != rhs.UnitNumber) + return false; + for (int ii = 0; ii < 5; ++ii) + { + if (MacHash[ii] != rhs.MacHash[ii]) + return false; + } + return true; +} + + +//// DK2PrintedSerialFormat + +// Base-32 Crockford decoding rules: +// 0 o O => 0 +// 1 i | I L l => 1 +// 2, 3, 4, 5, 6, 7, 8, 9 => 2 - 9 +// a, b, c, d, e, f, g, h => 10 - 17 +// j, k => 18, 19 +// m, n => 20, 21 +// p, q, r, s, t => 22, 23, 24, 25, 26 +// v, w, x, y, z => 27, 28, 29, 30, 31 +static const char Base32FromChar[256] = { + // Null - Unit Separator + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + // (sp)!"#$%&'()*+,-./ + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + // 0123456789:;<=>? + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1, + // @ - _ (upper case) + -1, 10, 11, 12, 13, 14, 15, 16, 17, 1, 18, 19, 1, 20, 21, 0, + 22, 23, 24, 25, 26, -1, 27, 28, 29, 30, 31, -1, -1, -1, -1, -1, + // ` - DEL (lower case) + -1, 10, 11, 12, 13, 14, 15, 16, 17, 1, 18, 19, 1, 20, 21, 0, + 22, 23, 24, 25, 26, -1, 27, 28, 29, 30, 31, -1, 1, -1, -1, -1, + + // Extended ASCII: + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 +}; + +// Base-32 Crockford encoding rules: +// 0-9 => 0-9 +// 10 - 17 => a, b, c, d, e, f, g, h +// 18, 19 => j, k +// 20, 21 => m, n +// 22, 23, 24, 25, 26 => p, q, r, s, t +// 27, 28, 29, 30, 31 => v, w, x, y, z +static const char* CharFromBase32 = "0123456789ABCDEFGHJKMNPQRSTVWXYZ"; + +bool DK2PrintedSerialFormat::FromBase32(const char* str, bool allowUnknownTypes) +{ + // Note: Truncated strings get caught by returning negative values from the table like other invalid characters + + // Product Id + + int productId = Base32FromChar[(unsigned char)str[0]]; + if (productId < 0 || (!allowUnknownTypes && !ValidDK2ProductId(productId))) + { + return false; + } + + ProductId = (DK2ProductId)productId; + + // Label Type + + int labelType = Base32FromChar[(unsigned char)str[1]]; + if (labelType < 0 || (!allowUnknownTypes && !ValidDK2PartId(labelType))) + { + return false; + } + + LabelType = (DK2LabelType)labelType; + + uint8_t dataBytes[7]; + for (int ii = 0; ii < 7; ++ii) + { + int c = Base32FromChar[(unsigned char)str[2 + ii]]; + if (c < 0) return false; + dataBytes[ii] = (uint8_t)c; + } + + // Minutes Since Epoch + + MinutesSinceEpoch = dataBytes[3] | ((uint32_t)dataBytes[2] << 5) | ((uint32_t)dataBytes[1] << 10) | ((uint32_t)dataBytes[0] << 15); + + // Unit Number + + UnitNumber = dataBytes[6] | ((uint32_t)dataBytes[5] << 5) | ((uint32_t)dataBytes[4] << 10); + + // MAC Hash + + for (int ii = 0; ii < 3; ++ii) + { + int c = Base32FromChar[(unsigned char)str[9 + ii]]; + if (c < 0) + { + return false; + } + + MacHashLow[ii] = (uint8_t)c; + } + + // String must be exactly 12 characters + if (str[12] != '\0') + { + return false; + } + + return true; +} + +String DK2PrintedSerialFormat::ToBase32() +{ + String s; + + s += CharFromBase32[ProductId]; + s += CharFromBase32[LabelType]; + s += CharFromBase32[(MinutesSinceEpoch >> 15) & 31]; + s += CharFromBase32[(MinutesSinceEpoch >> 10) & 31]; + s += CharFromBase32[(MinutesSinceEpoch >> 5) & 31]; + s += CharFromBase32[MinutesSinceEpoch & 31]; + s += CharFromBase32[(UnitNumber >> 10) & 31]; + s += CharFromBase32[(UnitNumber >> 5) & 31]; + s += CharFromBase32[UnitNumber & 31]; + s += CharFromBase32[MacHashLow[0] & 31]; + s += CharFromBase32[MacHashLow[1] & 31]; + s += CharFromBase32[MacHashLow[2] & 31]; + + return s; +} + +bool DK2PrintedSerialFormat::operator==(const DK2PrintedSerialFormat& rhs) +{ + if (ProductId != rhs.ProductId) + return false; + if (LabelType != rhs.LabelType) + return false; + if (MinutesSinceEpoch != rhs.MinutesSinceEpoch) + return false; + if (UnitNumber != rhs.UnitNumber) + return false; + for (int ii = 0; ii < 3; ++ii) + { + if (MacHashLow[ii] != rhs.MacHashLow[ii]) + return false; + } + return true; +} + +bool DK2PrintedSerialFormat::operator==(const DK2BinarySerialFormat& rhs) +{ + if (ProductId != rhs.ProductId) + return false; + if (LabelType != rhs.PartId) + return false; + if (MinutesSinceEpoch != rhs.MinutesSinceEpoch) + return false; + if (UnitNumber != rhs.UnitNumber) + return false; + for (int ii = 0; ii < 3; ++ii) + { + if (MacHashLow[ii] != (rhs.MacHash[ii] & 31)) + return false; + } + return true; +} + +void DK2PrintedSerialFormat::FromBinary(const DK2BinarySerialFormat& bin) +{ + ProductId = bin.ProductId; + LabelType = bin.PartId; + MinutesSinceEpoch = bin.MinutesSinceEpoch; + UnitNumber = bin.UnitNumber; + MacHashLow[0] = bin.MacHash[0] & 31; + MacHashLow[1] = bin.MacHash[1] & 31; + MacHashLow[2] = bin.MacHash[2] & 31; +} + + +//// Unit Tests + +#ifdef SERIAL_FORMAT_UNIT_TEST + +int DecodeBase32(char ch) +{ + if (ch >= '2' && ch <= '9') + return 2 + ch - '2'; + if (ch >= 'a' && ch <= 'h') + return 10 + ch - 'a'; + if (ch >= 'A' && ch <= 'H') + return 10 + ch - 'A'; + if (ch >= 'j' && ch <= 'k') + return 18 + ch - 'j'; + if (ch >= 'J' && ch <= 'K') + return 18 + ch - 'J'; + if (ch >= 'm' && ch <= 'n') + return 20 + ch - 'm'; + if (ch >= 'M' && ch <= 'N') + return 20 + ch - 'M'; + if (ch >= 'p' && ch <= 't') + return 22 + ch - 'p'; + if (ch >= 'P' && ch <= 'T') + return 22 + ch - 'P'; + if (ch >= 'v' && ch <= 'z') + return 27 + ch - 'v'; + if (ch >= 'V' && ch <= 'Z') + return 27 + ch - 'V'; + + switch (ch) + { + case '0': + case 'o': + case 'O': + return 0; + case '1': + case 'i': + case '|': + case 'I': + case 'L': + case 'l': + return 1; + } + + return -1; +} + +void TestSerialFormatStuff() +{ + for (int ii = 0; ii < 256; ++ii) + { + OVR_ASSERT(Base32FromChar[ii] == (char)DecodeBase32((char)ii)); + } + + DK2BinarySerialFormat sa; + sa.ProductId = DK2ProductId_DK2; + sa.PartId = DK2PartId_HMD; + sa.MinutesSinceEpoch = 65000; + sa.UnitNumber = 2; + sa.MacHash[0] = 0xa1; + sa.MacHash[1] = 0xb2; + sa.MacHash[2] = 0xc3; + sa.MacHash[3] = 0xd4; + sa.MacHash[4] = 0xe5; + + uint8_t buffer[12]; + sa.ToBuffer(buffer); + + DK2BinarySerialFormat sb; + bool success = sb.FromBuffer(buffer); + OVR_ASSERT(success); + OVR_UNUSED(success); + + OVR_ASSERT(sa == sb); + + DK2PrintedSerialFormat psn; + psn.FromBinary(sb); + + OVR_ASSERT(psn == sa); + + String s = psn.ToBase32(); + + DK2PrintedSerialFormat psn2; + psn2.FromBase32(s.ToCStr()); + + OVR_ASSERT(psn == psn2); +} + +#endif // SERIAL_FORMAT_UNIT_TEST + + +} // OVR diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/OVR_SerialFormat.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/OVR_SerialFormat.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,128 @@ +/************************************************************************************ + +PublicHeader: n/a +Filename : OVR_SerialFormat.h +Content : Serial Number format tools +Created : June 12, 2014 + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#ifndef OVR_SerialFormat_h +#define OVR_SerialFormat_h + +#include "Kernel/OVR_Types.h" +#include "Kernel/OVR_String.h" + +namespace OVR { + + +//----------------------------------------------------------------------------- +// SerialFormatType enumeration + +enum SerialFormatType +{ + SerialFormatType_Invalid = -1, // Invalid format + SerialFormatType_DK2 = 0, // Format used for DK2 +}; + +// Returns the expected serial format based on the first byte of the buffer +SerialFormatType DetectBufferFormat(uint8_t firstByte, int sizeInBytes); + + +//----------------------------------------------------------------------------- +// DK2 Serial Format + +enum DK2ProductId +{ + DK2ProductId_DK1 = 1, // DK1 + DK2ProductId_DK2 = 2, // Product Id used for initial DK2 launch + DK2ProductId_Refurb = 3, // Refurbished DK2 +}; + +enum DK2PartId +{ + DK2PartId_HMD = 0, // HMD + DK2PartId_PTC = 1, // PTC(camera) + DK2PartId_Carton = 2, // Carton: An HMD + PTC combo (should not be stamped on a component) AKA Overpack +}; + +typedef DK2PartId DK2LabelType; // Printed Serial Number version + + +// DK2 tool for reading/writing the binary serial format +class DK2BinarySerialFormat +{ +public: + static const SerialFormatType FormatType = SerialFormatType_DK2; // first byte + + DK2ProductId ProductId; // [4 bits] 2 = DK2 + DK2PartId PartId; // [4 bits] 0 means HMD, 1 means PTC(camera) + int MinutesSinceEpoch; // [3 bytes] Number of minutes that have elapsed since the epoch: May 1st, 2014 + // [0] = high byte, [1] = middle byte, [2] = low byte + int UnitNumber; // [2 bytes] Value that increments each time a new serial number is created. Resets to zero each day + // [0] = high byte, [1] = low byte + uint8_t MacHash[5]; // [5 bytes] 5 most significant bytes of MD5 hash from first ethernet adapter mac address + + bool operator==(const DK2BinarySerialFormat& rhs); + +public: + // Returns false if the input is invalid in some way + bool FromBuffer(const uint8_t buffer[12], bool allowUnknownTypes = false); + + // Fills the provided buffer with 12 bytes + void ToBuffer(uint8_t buffer[12]); +}; + + +// DK2 tool for reading/writing the printed serial format +class DK2PrintedSerialFormat +{ +public: + DK2ProductId ProductId; // [1 char] 2 = DK2, 3 = Reconditioned bundle + DK2LabelType LabelType; // [1 char] 0 means HMD, 1 means PTC(camera), 2 means Overpack(bundle) + int MinutesSinceEpoch; // [4 char] Number of minutes that have elapsed since the epoch: May 1st, 2014 + int UnitNumber; // [3 char] Value that increments each time a new serial number is created. Resets to zero each day + uint8_t MacHashLow[3]; // [3 char] 3 least significant bytes of mac hash + + bool operator==(const DK2PrintedSerialFormat& rhs); + bool operator==(const DK2BinarySerialFormat& rhs); + +public: + // Convert from binary to printed + void FromBinary(const DK2BinarySerialFormat& bin); + + // Returns false if the input is invalid in some way + // Convert from a 12 character printed serial number + bool FromBase32(const char* str, bool allowUnknownTypes = false); + + // Returns a long human-readable base32 string (20 characters), NOT a printed serial number + String ToBase32(); +}; + + +//#define SERIAL_FORMAT_UNIT_TEST +#ifdef SERIAL_FORMAT_UNIT_TEST +void TestSerialFormatStuff(); +#endif + + +} // OVR + +#endif // OVR_SerialFormat_h diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/OVR_Stereo.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/OVR_Stereo.cpp Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,1874 @@ +/************************************************************************************ + +Filename : OVR_Stereo.cpp +Content : Stereo rendering functions +Created : November 30, 2013 +Authors : Tom Fosyth + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +*************************************************************************************/ + +#include "OVR_Stereo.h" +#include "OVR_Profile.h" +#include "Kernel/OVR_Log.h" +#include "Kernel/OVR_Alg.h" + +//To allow custom distortion to be introduced to CatMulSpline. +float (*CustomDistortion)(float) = NULL; +float (*CustomDistortionInv)(float) = NULL; + + +namespace OVR { + + +using namespace Alg; + +//----------------------------------------------------------------------------------- + +// Inputs are 4 points (pFitX[0],pFitY[0]) through (pFitX[3],pFitY[3]) +// Result is four coefficients in pResults[0] through pResults[3] such that +// y = pResult[0] + x * ( pResult[1] + x * ( pResult[2] + x * ( pResult[3] ) ) ); +// passes through all four input points. +// Return is true if it succeeded, false if it failed (because two control points +// have the same pFitX value). +bool FitCubicPolynomial ( float *pResult, const float *pFitX, const float *pFitY ) +{ + float d0 = ( ( pFitX[0]-pFitX[1] ) * ( pFitX[0]-pFitX[2] ) * ( pFitX[0]-pFitX[3] ) ); + float d1 = ( ( pFitX[1]-pFitX[2] ) * ( pFitX[1]-pFitX[3] ) * ( pFitX[1]-pFitX[0] ) ); + float d2 = ( ( pFitX[2]-pFitX[3] ) * ( pFitX[2]-pFitX[0] ) * ( pFitX[2]-pFitX[1] ) ); + float d3 = ( ( pFitX[3]-pFitX[0] ) * ( pFitX[3]-pFitX[1] ) * ( pFitX[3]-pFitX[2] ) ); + + if ( ( d0 == 0.0f ) || ( d1 == 0.0f ) || ( d2 == 0.0f ) || ( d3 == 0.0f ) ) + { + return false; + } + + float f0 = pFitY[0] / d0; + float f1 = pFitY[1] / d1; + float f2 = pFitY[2] / d2; + float f3 = pFitY[3] / d3; + + pResult[0] = -( f0*pFitX[1]*pFitX[2]*pFitX[3] + + f1*pFitX[0]*pFitX[2]*pFitX[3] + + f2*pFitX[0]*pFitX[1]*pFitX[3] + + f3*pFitX[0]*pFitX[1]*pFitX[2] ); + pResult[1] = f0*(pFitX[1]*pFitX[2] + pFitX[2]*pFitX[3] + pFitX[3]*pFitX[1]) + + f1*(pFitX[0]*pFitX[2] + pFitX[2]*pFitX[3] + pFitX[3]*pFitX[0]) + + f2*(pFitX[0]*pFitX[1] + pFitX[1]*pFitX[3] + pFitX[3]*pFitX[0]) + + f3*(pFitX[0]*pFitX[1] + pFitX[1]*pFitX[2] + pFitX[2]*pFitX[0]); + pResult[2] = -( f0*(pFitX[1]+pFitX[2]+pFitX[3]) + + f1*(pFitX[0]+pFitX[2]+pFitX[3]) + + f2*(pFitX[0]+pFitX[1]+pFitX[3]) + + f3*(pFitX[0]+pFitX[1]+pFitX[2]) ); + pResult[3] = f0 + f1 + f2 + f3; + + return true; +} + +#define TPH_SPLINE_STATISTICS 0 +#if TPH_SPLINE_STATISTICS +static float max_scaledVal = 0; +static float average_total_out_of_range = 0; +static float average_out_of_range; +static int num_total = 0; +static int num_out_of_range = 0; +static int num_out_of_range_over_1 = 0; +static int num_out_of_range_over_2 = 0; +static int num_out_of_range_over_3 = 0; +static float percent_out_of_range; +#endif + +float EvalCatmullRom10Spline ( float const *K, float scaledVal ) +{ + int const NumSegments = LensConfig::NumCoefficients; + + #if TPH_SPLINE_STATISTICS + //Value should be in range of 0 to (NumSegments-1) (typically 10) if spline is valid. Right? + if (scaledVal > (NumSegments-1)) + { + num_out_of_range++; + average_total_out_of_range+=scaledVal; + average_out_of_range = average_total_out_of_range / ((float) num_out_of_range); + percent_out_of_range = 100.0f*(num_out_of_range)/num_total; + } + if (scaledVal > (NumSegments-1+1)) num_out_of_range_over_1++; + if (scaledVal > (NumSegments-1+2)) num_out_of_range_over_2++; + if (scaledVal > (NumSegments-1+3)) num_out_of_range_over_3++; + num_total++; + if (scaledVal > max_scaledVal) + { + max_scaledVal = scaledVal; + max_scaledVal = scaledVal; + } + #endif + + float scaledValFloor = floorf ( scaledVal ); + scaledValFloor = Alg::Max ( 0.0f, Alg::Min ( (float)(NumSegments-1), scaledValFloor ) ); + float t = scaledVal - scaledValFloor; + int k = (int)scaledValFloor; + + float p0, p1; + float m0, m1; + switch ( k ) + { + case 0: + // Curve starts at 1.0 with gradient K[1]-K[0] + p0 = 1.0f; + m0 = ( K[1] - K[0] ); // general case would have been (K[1]-K[-1])/2 + p1 = K[1]; + m1 = 0.5f * ( K[2] - K[0] ); + break; + default: + // General case + p0 = K[k ]; + m0 = 0.5f * ( K[k+1] - K[k-1] ); + p1 = K[k+1]; + m1 = 0.5f * ( K[k+2] - K[k ] ); + break; + case NumSegments-2: + // Last tangent is just the slope of the last two points. + p0 = K[NumSegments-2]; + m0 = 0.5f * ( K[NumSegments-1] - K[NumSegments-2] ); + p1 = K[NumSegments-1]; + m1 = K[NumSegments-1] - K[NumSegments-2]; + break; + case NumSegments-1: + // Beyond the last segment it's just a straight line + p0 = K[NumSegments-1]; + m0 = K[NumSegments-1] - K[NumSegments-2]; + p1 = p0 + m0; + m1 = m0; + break; + } + + float omt = 1.0f - t; + float res = ( p0 * ( 1.0f + 2.0f * t ) + m0 * t ) * omt * omt + + ( p1 * ( 1.0f + 2.0f * omt ) - m1 * omt ) * t * t; + + return res; +} + + + + +// Converts a Profile eyecup string into an eyecup enumeration +void SetEyeCup(HmdRenderInfo* renderInfo, const char* cup) +{ + if (OVR_strcmp(cup, "A") == 0) + renderInfo->EyeCups = EyeCup_DK1A; + else if (OVR_strcmp(cup, "B") == 0) + renderInfo->EyeCups = EyeCup_DK1B; + else if (OVR_strcmp(cup, "C") == 0) + renderInfo->EyeCups = EyeCup_DK1C; + else if (OVR_strcmp(cup, "Orange A") == 0) + renderInfo->EyeCups = EyeCup_OrangeA; + else if (OVR_strcmp(cup, "Red A") == 0) + renderInfo->EyeCups = EyeCup_RedA; + else if (OVR_strcmp(cup, "Pink A") == 0) + renderInfo->EyeCups = EyeCup_PinkA; + else if (OVR_strcmp(cup, "Blue A") == 0) + renderInfo->EyeCups = EyeCup_BlueA; + else + renderInfo->EyeCups = EyeCup_DK1A; +} + + + +//----------------------------------------------------------------------------------- + + +// The result is a scaling applied to the distance. +float LensConfig::DistortionFnScaleRadiusSquared (float rsq) const +{ + float scale = 1.0f; + switch ( Eqn ) + { + case Distortion_Poly4: + // This version is deprecated! Prefer one of the other two. + scale = ( K[0] + rsq * ( K[1] + rsq * ( K[2] + rsq * K[3] ) ) ); + break; + case Distortion_RecipPoly4: + scale = 1.0f / ( K[0] + rsq * ( K[1] + rsq * ( K[2] + rsq * K[3] ) ) ); + break; + case Distortion_CatmullRom10:{ + // A Catmull-Rom spline through the values 1.0, K[1], K[2] ... K[10] + // evenly spaced in R^2 from 0.0 to MaxR^2 + // K[0] controls the slope at radius=0.0, rather than the actual value. + const int NumSegments = LensConfig::NumCoefficients; + OVR_ASSERT ( NumSegments <= NumCoefficients ); + float scaledRsq = (float)(NumSegments-1) * rsq / ( MaxR * MaxR ); + scale = EvalCatmullRom10Spline ( K, scaledRsq ); + + + //Intercept, and overrule if needed + if (CustomDistortion) + { + scale = CustomDistortion(rsq); + } + + }break; + default: + OVR_ASSERT ( false ); + break; + } + return scale; +} + +// x,y,z components map to r,g,b +Vector3f LensConfig::DistortionFnScaleRadiusSquaredChroma (float rsq) const +{ + float scale = DistortionFnScaleRadiusSquared ( rsq ); + Vector3f scaleRGB; + scaleRGB.x = scale * ( 1.0f + ChromaticAberration[0] + rsq * ChromaticAberration[1] ); // Red + scaleRGB.y = scale; // Green + scaleRGB.z = scale * ( 1.0f + ChromaticAberration[2] + rsq * ChromaticAberration[3] ); // Blue + return scaleRGB; +} + +// DistortionFnInverse computes the inverse of the distortion function on an argument. +float LensConfig::DistortionFnInverse(float r) const +{ + OVR_ASSERT((r <= 20.0f)); + + float s, d; + float delta = r * 0.25f; + + // Better to start guessing too low & take longer to converge than too high + // and hit singularities. Empirically, r * 0.5f is too high in some cases. + s = r * 0.25f; + d = fabs(r - DistortionFn(s)); + + for (int i = 0; i < 20; i++) + { + float sUp = s + delta; + float sDown = s - delta; + float dUp = fabs(r - DistortionFn(sUp)); + float dDown = fabs(r - DistortionFn(sDown)); + + if (dUp < d) + { + s = sUp; + d = dUp; + } + else if (dDown < d) + { + s = sDown; + d = dDown; + } + else + { + delta *= 0.5f; + } + } + + return s; +} + + + +float LensConfig::DistortionFnInverseApprox(float r) const +{ + float rsq = r * r; + float scale = 1.0f; + switch ( Eqn ) + { + case Distortion_Poly4: + // Deprecated + OVR_ASSERT ( false ); + break; + case Distortion_RecipPoly4: + scale = 1.0f / ( InvK[0] + rsq * ( InvK[1] + rsq * ( InvK[2] + rsq * InvK[3] ) ) ); + break; + case Distortion_CatmullRom10:{ + // A Catmull-Rom spline through the values 1.0, K[1], K[2] ... K[9] + // evenly spaced in R^2 from 0.0 to MaxR^2 + // K[0] controls the slope at radius=0.0, rather than the actual value. + const int NumSegments = LensConfig::NumCoefficients; + OVR_ASSERT ( NumSegments <= NumCoefficients ); + float scaledRsq = (float)(NumSegments-1) * rsq / ( MaxInvR * MaxInvR ); + scale = EvalCatmullRom10Spline ( InvK, scaledRsq ); + + //Intercept, and overrule if needed + if (CustomDistortionInv) + { + scale = CustomDistortionInv(rsq); + } + + }break; + default: + OVR_ASSERT ( false ); + break; + } + return r * scale; +} + +void LensConfig::SetUpInverseApprox() +{ + float maxR = MaxInvR; + + switch ( Eqn ) + { + case Distortion_Poly4: + // Deprecated + OVR_ASSERT ( false ); + break; + case Distortion_RecipPoly4:{ + + float sampleR[4]; + float sampleRSq[4]; + float sampleInv[4]; + float sampleFit[4]; + + // Found heuristically... + sampleR[0] = 0.0f; + sampleR[1] = maxR * 0.4f; + sampleR[2] = maxR * 0.8f; + sampleR[3] = maxR * 1.5f; + for ( int i = 0; i < 4; i++ ) + { + sampleRSq[i] = sampleR[i] * sampleR[i]; + sampleInv[i] = DistortionFnInverse ( sampleR[i] ); + sampleFit[i] = sampleR[i] / sampleInv[i]; + } + sampleFit[0] = 1.0f; + FitCubicPolynomial ( InvK, sampleRSq, sampleFit ); + + #if 0 + // Should be a nearly exact match on the chosen points. + OVR_ASSERT ( fabs ( DistortionFnInverse ( sampleR[0] ) - DistortionFnInverseApprox ( sampleR[0] ) ) / maxR < 0.0001f ); + OVR_ASSERT ( fabs ( DistortionFnInverse ( sampleR[1] ) - DistortionFnInverseApprox ( sampleR[1] ) ) / maxR < 0.0001f ); + OVR_ASSERT ( fabs ( DistortionFnInverse ( sampleR[2] ) - DistortionFnInverseApprox ( sampleR[2] ) ) / maxR < 0.0001f ); + OVR_ASSERT ( fabs ( DistortionFnInverse ( sampleR[3] ) - DistortionFnInverseApprox ( sampleR[3] ) ) / maxR < 0.0001f ); + // Should be a decent match on the rest of the range. + const int maxCheck = 20; + for ( int i = 0; i < maxCheck; i++ ) + { + float checkR = (float)i * maxR / (float)maxCheck; + float realInv = DistortionFnInverse ( checkR ); + float testInv = DistortionFnInverseApprox ( checkR ); + float error = fabsf ( realInv - testInv ) / maxR; + OVR_ASSERT ( error < 0.1f ); + } + #endif + + }break; + case Distortion_CatmullRom10:{ + + const int NumSegments = LensConfig::NumCoefficients; + OVR_ASSERT ( NumSegments <= NumCoefficients ); + for ( int i = 1; i < NumSegments; i++ ) + { + float scaledRsq = (float)i; + float rsq = scaledRsq * MaxInvR * MaxInvR / (float)( NumSegments - 1); + float r = sqrtf ( rsq ); + float inv = DistortionFnInverse ( r ); + InvK[i] = inv / r; + InvK[0] = 1.0f; // TODO: fix this. + } + +#if 0 + const int maxCheck = 20; + for ( int i = 0; i <= maxCheck; i++ ) + { + float checkR = (float)i * MaxInvR / (float)maxCheck; + float realInv = DistortionFnInverse ( checkR ); + float testInv = DistortionFnInverseApprox ( checkR ); + float error = fabsf ( realInv - testInv ) / MaxR; + OVR_ASSERT ( error < 0.01f ); + } +#endif + + }break; + + default: + break; + } +} + + +void LensConfig::SetToIdentity() +{ + for ( int i = 0; i < NumCoefficients; i++ ) + { + K[i] = 0.0f; + InvK[i] = 0.0f; + } + Eqn = Distortion_RecipPoly4; + K[0] = 1.0f; + InvK[0] = 1.0f; + MaxR = 1.0f; + MaxInvR = 1.0f; + ChromaticAberration[0] = 0.0f; + ChromaticAberration[1] = 0.0f; + ChromaticAberration[2] = 0.0f; + ChromaticAberration[3] = 0.0f; + MetersPerTanAngleAtCenter = 0.05f; +} + + +enum LensConfigStoredVersion +{ + LCSV_CatmullRom10Version1 = 1 +}; + +// DO NOT CHANGE THESE ONCE THEY HAVE BEEN BAKED INTO FIRMWARE. +// If something needs to change, add a new one! +struct LensConfigStored_CatmullRom10Version1 +{ + // All these items must be fixed-length integers - no "float", no "int", etc. + uint16_t VersionNumber; // Must be LCSV_CatmullRom10Version1 + + uint16_t K[11]; + uint16_t MaxR; + uint16_t MetersPerTanAngleAtCenter; + uint16_t ChromaticAberration[4]; + // InvK and MaxInvR are calculated on load. +}; + +uint16_t EncodeFixedPointUInt16 ( float val, uint16_t zeroVal, int fractionalBits ) +{ + OVR_ASSERT ( ( fractionalBits >= 0 ) && ( fractionalBits < 31 ) ); + float valWhole = val * (float)( 1 << fractionalBits ); + valWhole += (float)zeroVal + 0.5f; + valWhole = floorf ( valWhole ); + OVR_ASSERT ( ( valWhole >= 0.0f ) && ( valWhole < (float)( 1 << 16 ) ) ); + return (uint16_t)valWhole; +} + +float DecodeFixedPointUInt16 ( uint16_t val, uint16_t zeroVal, int fractionalBits ) +{ + OVR_ASSERT ( ( fractionalBits >= 0 ) && ( fractionalBits < 31 ) ); + float valFloat = (float)val; + valFloat -= (float)zeroVal; + valFloat *= 1.0f / (float)( 1 << fractionalBits ); + return valFloat; +} + + +// Returns true on success. +bool LoadLensConfig ( LensConfig *presult, uint8_t const *pbuffer, int bufferSizeInBytes ) +{ + if ( bufferSizeInBytes < 2 ) + { + // Can't even tell the version number! + return false; + } + uint16_t version = DecodeUInt16 ( pbuffer + 0 ); + switch ( version ) + { + case LCSV_CatmullRom10Version1: + { + if ( bufferSizeInBytes < (int)sizeof(LensConfigStored_CatmullRom10Version1) ) + { + return false; + } + LensConfigStored_CatmullRom10Version1 lcs; + lcs.VersionNumber = DecodeUInt16 ( pbuffer + 0 ); + for ( int i = 0; i < 11; i++ ) + { + lcs.K[i] = DecodeUInt16 ( pbuffer + 2 + 2*i ); + } + lcs.MaxR = DecodeUInt16 ( pbuffer + 24 ); + lcs.MetersPerTanAngleAtCenter = DecodeUInt16 ( pbuffer + 26 ); + for ( int i = 0; i < 4; i++ ) + { + lcs.ChromaticAberration[i] = DecodeUInt16 ( pbuffer + 28 + 2*i ); + } + OVR_COMPILER_ASSERT ( sizeof(lcs) == 36 ); + + // Convert to the real thing. + LensConfig result; + result.Eqn = Distortion_CatmullRom10; + for ( int i = 0; i < 11; i++ ) + { + // K[] are mostly 1.something. They may get significantly bigger, but they never hit 0.0. + result.K[i] = DecodeFixedPointUInt16 ( lcs.K[i], 0, 14 ); + } + // MaxR is tan(angle), so always >0, typically just over 1.0 (45 degrees half-fov), + // but may get arbitrarily high. tan(76)=4 is a very reasonable limit! + result.MaxR = DecodeFixedPointUInt16 ( lcs.MaxR, 0, 14 ); + // MetersPerTanAngleAtCenter is also known as focal length! + // Typically around 0.04 for our current screens, minimum of 0, sensible maximum of 0.125 (i.e. 3 "extra" bits of fraction) + result.MetersPerTanAngleAtCenter = DecodeFixedPointUInt16 ( lcs.MetersPerTanAngleAtCenter, 0, 16+3 ); + for ( int i = 0; i < 4; i++ ) + { + // ChromaticAberration[] are mostly 0.0something, centered on 0.0. Largest seen is 0.04, so set max to 0.125 (i.e. 3 "extra" bits of fraction) + result.ChromaticAberration[i] = DecodeFixedPointUInt16 ( lcs.ChromaticAberration[i], 0x8000, 16+3 ); + } + result.MaxInvR = result.DistortionFn ( result.MaxR ); + result.SetUpInverseApprox(); + + OVR_ASSERT ( version == lcs.VersionNumber ); + + *presult = result; + } + break; + default: + // Unknown format. + return false; + break; + } + return true; +} + +// Returns number of bytes needed. +int SaveLensConfigSizeInBytes ( LensConfig const &config ) +{ + OVR_UNUSED ( config ); + return sizeof ( LensConfigStored_CatmullRom10Version1 ); +} + +// Returns true on success. +bool SaveLensConfig ( uint8_t *pbuffer, int bufferSizeInBytes, LensConfig const &config ) +{ + if ( bufferSizeInBytes < (int)sizeof ( LensConfigStored_CatmullRom10Version1 ) ) + { + return false; + } + + // Construct the values. + LensConfigStored_CatmullRom10Version1 lcs; + lcs.VersionNumber = LCSV_CatmullRom10Version1; + for ( int i = 0; i < 11; i++ ) + { + // K[] are mostly 1.something. They may get significantly bigger, but they never hit 0.0. + lcs.K[i] = EncodeFixedPointUInt16 ( config.K[i], 0, 14 ); + } + // MaxR is tan(angle), so always >0, typically just over 1.0 (45 degrees half-fov), + // but may get arbitrarily high. tan(76)=4 is a very reasonable limit! + lcs.MaxR = EncodeFixedPointUInt16 ( config.MaxR, 0, 14 ); + // MetersPerTanAngleAtCenter is also known as focal length! + // Typically around 0.04 for our current screens, minimum of 0, sensible maximum of 0.125 (i.e. 3 "extra" bits of fraction) + lcs.MetersPerTanAngleAtCenter = EncodeFixedPointUInt16 ( config.MetersPerTanAngleAtCenter, 0, 16+3 ); + for ( int i = 0; i < 4; i++ ) + { + // ChromaticAberration[] are mostly 0.0something, centered on 0.0. Largest seen is 0.04, so set max to 0.125 (i.e. 3 "extra" bits of fraction) + lcs.ChromaticAberration[i] = EncodeFixedPointUInt16 ( config.ChromaticAberration[i], 0x8000, 16+3 ); + } + + + // Now store them out, sensitive to endianness. + EncodeUInt16 ( pbuffer + 0, lcs.VersionNumber ); + for ( int i = 0; i < 11; i++ ) + { + EncodeUInt16 ( pbuffer + 2 + 2*i, lcs.K[i] ); + } + EncodeUInt16 ( pbuffer + 24, lcs.MaxR ); + EncodeUInt16 ( pbuffer + 26, lcs.MetersPerTanAngleAtCenter ); + for ( int i = 0; i < 4; i++ ) + { + EncodeUInt16 ( pbuffer + 28 + 2*i, lcs.ChromaticAberration[i] ); + } + OVR_COMPILER_ASSERT ( 36 == sizeof(lcs) ); + + return true; +} + +#ifdef OVR_BUILD_DEBUG +void TestSaveLoadLensConfig ( LensConfig const &config ) +{ + OVR_ASSERT ( config.Eqn == Distortion_CatmullRom10 ); + // As a test, make sure this can be encoded and decoded correctly. + const int bufferSize = 256; + uint8_t buffer[bufferSize]; + OVR_ASSERT ( SaveLensConfigSizeInBytes ( config ) < bufferSize ); + bool success; + success = SaveLensConfig ( buffer, bufferSize, config ); + OVR_ASSERT ( success ); + LensConfig testConfig; + success = LoadLensConfig ( &testConfig, buffer, bufferSize ); + OVR_ASSERT ( success ); + OVR_ASSERT ( testConfig.Eqn == config.Eqn ); + for ( int i = 0; i < 11; i++ ) + { + OVR_ASSERT ( fabs ( testConfig.K[i] - config.K[i] ) < 0.0001f ); + } + OVR_ASSERT ( fabsf ( testConfig.MaxR - config.MaxR ) < 0.0001f ); + OVR_ASSERT ( fabsf ( testConfig.MetersPerTanAngleAtCenter - config.MetersPerTanAngleAtCenter ) < 0.00001f ); + for ( int i = 0; i < 4; i++ ) + { + OVR_ASSERT ( fabsf ( testConfig.ChromaticAberration[i] - config.ChromaticAberration[i] ) < 0.00001f ); + } +} +#endif + + + +//----------------------------------------------------------------------------------- + +// TBD: There is a question of whether this is the best file for CreateDebugHMDInfo. As long as there are many +// constants for HmdRenderInfo here as well it is ok. The alternative would be OVR_Common_HMDDevice.cpp, but +// that's specialized per platform... should probably move it there onces the code is in the common base class. + +HMDInfo CreateDebugHMDInfo(HmdTypeEnum hmdType) +{ + HMDInfo info; + + if ((hmdType != HmdType_DK1) && + (hmdType != HmdType_CrystalCoveProto) && + (hmdType != HmdType_DK2)) + { + LogText("Debug HMDInfo - HmdType not supported. Defaulting to DK1.\n"); + hmdType = HmdType_DK1; + } + + // The alternative would be to initialize info.HmdType to HmdType_None instead. If we did that, + // code wouldn't be "maximally compatible" and devs wouldn't know what device we are + // simulating... so if differentiation becomes necessary we better add Debug flag in the future. + info.HmdType = hmdType; + info.Manufacturer = "Oculus VR"; + + switch(hmdType) + { + case HmdType_DK1: + info.ProductName = "Oculus Rift DK1"; + info.ResolutionInPixels = Sizei ( 1280, 800 ); + info.ScreenSizeInMeters = Sizef ( 0.1498f, 0.0936f ); + info.ScreenGapSizeInMeters = 0.0f; + info.CenterFromTopInMeters = 0.0468f; + info.LensSeparationInMeters = 0.0635f; + info.PelOffsetR = Vector2f ( 0.0f, 0.0f ); + info.PelOffsetB = Vector2f ( 0.0f, 0.0f ); + info.Shutter.Type = HmdShutter_RollingTopToBottom; + info.Shutter.VsyncToNextVsync = ( 1.0f / 60.0f ); + info.Shutter.VsyncToFirstScanline = 0.000052f; + info.Shutter.FirstScanlineToLastScanline = 0.016580f; + info.Shutter.PixelSettleTime = 0.015f; + info.Shutter.PixelPersistence = ( 1.0f / 60.0f ); + break; + + case HmdType_CrystalCoveProto: + info.ProductName = "Oculus Rift Crystal Cove"; + info.ResolutionInPixels = Sizei ( 1920, 1080 ); + info.ScreenSizeInMeters = Sizef ( 0.12576f, 0.07074f ); + info.ScreenGapSizeInMeters = 0.0f; + info.CenterFromTopInMeters = info.ScreenSizeInMeters.h * 0.5f; + info.LensSeparationInMeters = 0.0635f; + info.PelOffsetR = Vector2f ( 0.0f, 0.0f ); + info.PelOffsetB = Vector2f ( 0.0f, 0.0f ); + info.Shutter.Type = HmdShutter_RollingRightToLeft; + info.Shutter.VsyncToNextVsync = ( 1.0f / 76.0f ); + info.Shutter.VsyncToFirstScanline = 0.0000273f; + info.Shutter.FirstScanlineToLastScanline = 0.0131033f; + info.Shutter.PixelSettleTime = 0.0f; + info.Shutter.PixelPersistence = 0.18f * info.Shutter.VsyncToNextVsync; + break; + + case HmdType_DK2: + info.ProductName = "Oculus Rift DK2"; + info.ResolutionInPixels = Sizei ( 1920, 1080 ); + info.ScreenSizeInMeters = Sizef ( 0.12576f, 0.07074f ); + info.ScreenGapSizeInMeters = 0.0f; + info.CenterFromTopInMeters = info.ScreenSizeInMeters.h * 0.5f; + info.LensSeparationInMeters = 0.0635f; + info.PelOffsetR = Vector2f ( 0.5f, 0.5f ); + info.PelOffsetB = Vector2f ( 0.5f, 0.5f ); + info.Shutter.Type = HmdShutter_RollingRightToLeft; + info.Shutter.VsyncToNextVsync = ( 1.0f / 76.0f ); + info.Shutter.VsyncToFirstScanline = 0.0000273f; + info.Shutter.FirstScanlineToLastScanline = 0.0131033f; + info.Shutter.PixelSettleTime = 0.0f; + info.Shutter.PixelPersistence = 0.18f * info.Shutter.VsyncToNextVsync; + break; + + default: + break; + } + + return info; +} + + +HmdRenderInfo GenerateHmdRenderInfoFromHmdInfo ( HMDInfo const &hmdInfo, + Profile const *profile, + DistortionEqnType distortionType /*= Distortion_CatmullRom10*/, + EyeCupType eyeCupOverride /*= EyeCup_LAST*/ ) +{ + HmdRenderInfo renderInfo; + + OVR_ASSERT(profile); // profiles are required + if(!profile) + return renderInfo; + + renderInfo.HmdType = hmdInfo.HmdType; + renderInfo.ResolutionInPixels = hmdInfo.ResolutionInPixels; + renderInfo.ScreenSizeInMeters = hmdInfo.ScreenSizeInMeters; + renderInfo.CenterFromTopInMeters = hmdInfo.CenterFromTopInMeters; + renderInfo.ScreenGapSizeInMeters = hmdInfo.ScreenGapSizeInMeters; + renderInfo.LensSeparationInMeters = hmdInfo.LensSeparationInMeters; + renderInfo.PelOffsetR = hmdInfo.PelOffsetR; + renderInfo.PelOffsetB = hmdInfo.PelOffsetB; + + OVR_ASSERT ( sizeof(renderInfo.Shutter) == sizeof(hmdInfo.Shutter) ); // Try to keep the files in sync! + renderInfo.Shutter.Type = hmdInfo.Shutter.Type; + renderInfo.Shutter.VsyncToNextVsync = hmdInfo.Shutter.VsyncToNextVsync; + renderInfo.Shutter.VsyncToFirstScanline = hmdInfo.Shutter.VsyncToFirstScanline; + renderInfo.Shutter.FirstScanlineToLastScanline = hmdInfo.Shutter.FirstScanlineToLastScanline; + renderInfo.Shutter.PixelSettleTime = hmdInfo.Shutter.PixelSettleTime; + renderInfo.Shutter.PixelPersistence = hmdInfo.Shutter.PixelPersistence; + + renderInfo.LensDiameterInMeters = 0.035f; + renderInfo.LensSurfaceToMidplateInMeters = 0.025f; + renderInfo.EyeCups = EyeCup_DK1A; + +#if 0 // Device settings are out of date - don't use them. + if (Contents & Contents_Distortion) + { + memcpy(renderInfo.DistortionK, DistortionK, sizeof(float)*4); + renderInfo.DistortionEqn = Distortion_RecipPoly4; + } +#endif + + // Defaults in case of no user profile. + renderInfo.EyeLeft.NoseToPupilInMeters = 0.032f; + renderInfo.EyeLeft.ReliefInMeters = 0.012f; + + // 10mm eye-relief laser numbers for DK1 lenses. + // These are a decent seed for finding eye-relief and IPD. + // These are NOT used for rendering! + // Rendering distortions are now in GenerateLensConfigFromEyeRelief() + // So, if you're hacking in new distortions, don't do it here! + renderInfo.EyeLeft.Distortion.SetToIdentity(); + renderInfo.EyeLeft.Distortion.MetersPerTanAngleAtCenter = 0.0449f; + renderInfo.EyeLeft.Distortion.Eqn = Distortion_RecipPoly4; + renderInfo.EyeLeft.Distortion.K[0] = 1.0f; + renderInfo.EyeLeft.Distortion.K[1] = -0.494165344f; + renderInfo.EyeLeft.Distortion.K[2] = 0.587046423f; + renderInfo.EyeLeft.Distortion.K[3] = -0.841887126f; + renderInfo.EyeLeft.Distortion.MaxR = 1.0f; + + renderInfo.EyeLeft.Distortion.ChromaticAberration[0] = -0.006f; + renderInfo.EyeLeft.Distortion.ChromaticAberration[1] = 0.0f; + renderInfo.EyeLeft.Distortion.ChromaticAberration[2] = 0.014f; + renderInfo.EyeLeft.Distortion.ChromaticAberration[3] = 0.0f; + + renderInfo.EyeRight = renderInfo.EyeLeft; + + // Obtain data from profile. + char eyecup[16]; + if (profile->GetValue(OVR_KEY_EYE_CUP, eyecup, 16)) + { + SetEyeCup(&renderInfo, eyecup); + } + + switch ( hmdInfo.HmdType ) + { + case HmdType_None: + case HmdType_DKProto: + case HmdType_DK1: + // Slight hack to improve usability. + // If you have a DKHD-style lens profile enabled, + // but you plug in DK1 and forget to change the profile, + // obviously you don't want those lens numbers. + if ( ( renderInfo.EyeCups != EyeCup_DK1A ) && + ( renderInfo.EyeCups != EyeCup_DK1B ) && + ( renderInfo.EyeCups != EyeCup_DK1C ) ) + { + renderInfo.EyeCups = EyeCup_DK1A; + } + break; + + case HmdType_DKHD2Proto: + renderInfo.EyeCups = EyeCup_DKHD2A; + break; + case HmdType_CrystalCoveProto: + renderInfo.EyeCups = EyeCup_PinkA; + break; + case HmdType_DK2: + renderInfo.EyeCups = EyeCup_DK2A; + break; + default: + break; + } + + if ( eyeCupOverride != EyeCup_LAST ) + { + renderInfo.EyeCups = eyeCupOverride; + } + + switch ( renderInfo.EyeCups ) + { + case EyeCup_DK1A: + case EyeCup_DK1B: + case EyeCup_DK1C: + renderInfo.LensDiameterInMeters = 0.035f; + renderInfo.LensSurfaceToMidplateInMeters = 0.02357f; + // Not strictly lens-specific, but still wise to set a reasonable default for relief. + renderInfo.EyeLeft.ReliefInMeters = 0.010f; + renderInfo.EyeRight.ReliefInMeters = 0.010f; + break; + case EyeCup_DKHD2A: + renderInfo.LensDiameterInMeters = 0.035f; + renderInfo.LensSurfaceToMidplateInMeters = 0.02357f; + // Not strictly lens-specific, but still wise to set a reasonable default for relief. + renderInfo.EyeLeft.ReliefInMeters = 0.010f; + renderInfo.EyeRight.ReliefInMeters = 0.010f; + break; + case EyeCup_PinkA: + case EyeCup_DK2A: + renderInfo.LensDiameterInMeters = 0.04f; // approximate + renderInfo.LensSurfaceToMidplateInMeters = 0.01965f; + // Not strictly lens-specific, but still wise to set a reasonable default for relief. + renderInfo.EyeLeft.ReliefInMeters = 0.012f; + renderInfo.EyeRight.ReliefInMeters = 0.012f; + break; + default: OVR_ASSERT ( false ); break; + } + + Profile* def = ProfileManager::GetInstance()->GetDefaultProfile(hmdInfo.HmdType); + + // Set the eye position + // Use the user profile value unless they have elected to use the defaults + if (!profile->GetBoolValue(OVR_KEY_CUSTOM_EYE_RENDER, true)) + profile = def; // use the default + + char user[32]; + profile->GetValue(OVR_KEY_USER, user, 32); // for debugging purposes + + // TBD: Maybe we should separate custom camera positioning from custom distortion rendering ?? + float eye2nose[2] = { OVR_DEFAULT_IPD / 2, OVR_DEFAULT_IPD / 2 }; + if (profile->GetFloatValues(OVR_KEY_EYE_TO_NOSE_DISTANCE, eye2nose, 2) == 2) + { + renderInfo.EyeLeft.NoseToPupilInMeters = eye2nose[0]; + renderInfo.EyeRight.NoseToPupilInMeters = eye2nose[1]; + } + else + { // Legacy profiles may not include half-ipd, so use the regular IPD value instead + float ipd = profile->GetFloatValue(OVR_KEY_IPD, OVR_DEFAULT_IPD); + renderInfo.EyeLeft.NoseToPupilInMeters = 0.5f * ipd; + renderInfo.EyeRight.NoseToPupilInMeters = 0.5f * ipd; + } + + float eye2plate[2]; + if ((profile->GetFloatValues(OVR_KEY_MAX_EYE_TO_PLATE_DISTANCE, eye2plate, 2) == 2) || + (def->GetFloatValues(OVR_KEY_MAX_EYE_TO_PLATE_DISTANCE, eye2plate, 2) == 2)) + { // Subtract the eye-cup height from the plate distance to get the eye-to-lens distance + // This measurement should be the the distance at maximum dial setting + // We still need to adjust with the dial offset + renderInfo.EyeLeft.ReliefInMeters = eye2plate[0] - renderInfo.LensSurfaceToMidplateInMeters; + renderInfo.EyeRight.ReliefInMeters = eye2plate[1] - renderInfo.LensSurfaceToMidplateInMeters; + + // Adjust the eye relief with the dial setting (from the assumed max eye relief) + int dial = profile->GetIntValue(OVR_KEY_EYE_RELIEF_DIAL, OVR_DEFAULT_EYE_RELIEF_DIAL); + renderInfo.EyeLeft.ReliefInMeters -= ((10 - dial) * 0.001f); + renderInfo.EyeRight.ReliefInMeters -= ((10 - dial) * 0.001f); + } + else + { + // We shouldn't be here. The user or default profile should have the eye relief + OVR_ASSERT(false); + + // Set the eye relief with the user configured dial setting + //int dial = profile->GetIntValue(OVR_KEY_EYE_RELIEF_DIAL, OVR_DEFAULT_EYE_RELIEF_DIAL); + + // Assume a default of 7 to 17 mm eye relief based on the dial. This corresponds + // to the sampled and tuned distortion range on the DK1. + //renderInfo.EyeLeft.ReliefInMeters = 0.007f + (dial * 0.001f); + //renderInfo.EyeRight.ReliefInMeters = 0.007f + (dial * 0.001f); + } + + def->Release(); + + + // Now we know where the eyes are relative to the lenses, we can compute a distortion for each. + // TODO: incorporate lateral offset in distortion generation. + // TODO: we used a distortion to calculate eye-relief, and now we're making a distortion from that eye-relief. Close the loop! + + for ( int eyeNum = 0; eyeNum < 2; eyeNum++ ) + { + HmdRenderInfo::EyeConfig *pHmdEyeConfig = ( eyeNum == 0 ) ? &(renderInfo.EyeLeft) : &(renderInfo.EyeRight); + + float eye_relief = pHmdEyeConfig->ReliefInMeters; + LensConfig distortionConfig = GenerateLensConfigFromEyeRelief ( eye_relief, renderInfo, distortionType ); + pHmdEyeConfig->Distortion = distortionConfig; + } + + return renderInfo; +} + + +LensConfig GenerateLensConfigFromEyeRelief ( float eyeReliefInMeters, HmdRenderInfo const &hmd, DistortionEqnType distortionType /*= Distortion_CatmullRom10*/ ) +{ + struct DistortionDescriptor + { + float EyeRelief; + // The three places we're going to sample & lerp the curve at. + // One sample is always at 0.0, and the distortion scale should be 1.0 or else! + // Only use for poly4 numbers - CR has an implicit scale. + float SampleRadius[3]; + // Where the distortion has actually been measured/calibrated out to. + // Don't try to hallucinate data out beyond here. + float MaxRadius; + // The config itself. + LensConfig Config; + }; + + static const int MaxDistortions = 10; + DistortionDescriptor distortions[MaxDistortions]; + for (int i = 0; i < MaxDistortions; i++) + { + distortions[i].EyeRelief = 0.0f; + memset(distortions[i].SampleRadius, 0, sizeof(distortions[i].SampleRadius)); + distortions[i].MaxRadius = 1.0f; + distortions[i].Config.SetToIdentity(); // Note: This line causes a false Microsoft static analysis error -cat + } + int numDistortions = 0; + int defaultDistortion = 0; // index of the default distortion curve to use if zero eye relief supplied + + if ( ( hmd.EyeCups == EyeCup_DK1A ) || + ( hmd.EyeCups == EyeCup_DK1B ) || + ( hmd.EyeCups == EyeCup_DK1C ) ) + { + + numDistortions = 0; + + // Tuned at minimum dial setting - extended to r^2 == 1.8 + distortions[numDistortions].Config.Eqn = Distortion_CatmullRom10; + distortions[numDistortions].EyeRelief = 0.012760465f - 0.005f; + distortions[numDistortions].Config.MetersPerTanAngleAtCenter = 0.0425f; + distortions[numDistortions].Config.K[0] = 1.0000f; + distortions[numDistortions].Config.K[1] = 1.06505f; + distortions[numDistortions].Config.K[2] = 1.14725f; + distortions[numDistortions].Config.K[3] = 1.2705f; + distortions[numDistortions].Config.K[4] = 1.48f; + distortions[numDistortions].Config.K[5] = 1.87f; + distortions[numDistortions].Config.K[6] = 2.534f; + distortions[numDistortions].Config.K[7] = 3.6f; + distortions[numDistortions].Config.K[8] = 5.1f; + distortions[numDistortions].Config.K[9] = 7.4f; + distortions[numDistortions].Config.K[10] = 11.0f; + distortions[numDistortions].MaxRadius = sqrt(1.8f); + defaultDistortion = numDistortions; // this is the default + numDistortions++; + + // Tuned at middle dial setting + distortions[numDistortions].Config.Eqn = Distortion_CatmullRom10; + distortions[numDistortions].EyeRelief = 0.012760465f; // my average eye-relief + distortions[numDistortions].Config.MetersPerTanAngleAtCenter = 0.0425f; + distortions[numDistortions].Config.K[0] = 1.0f; + distortions[numDistortions].Config.K[1] = 1.032407264f; + distortions[numDistortions].Config.K[2] = 1.07160462f; + distortions[numDistortions].Config.K[3] = 1.11998388f; + distortions[numDistortions].Config.K[4] = 1.1808606f; + distortions[numDistortions].Config.K[5] = 1.2590494f; + distortions[numDistortions].Config.K[6] = 1.361915f; + distortions[numDistortions].Config.K[7] = 1.5014339f; + distortions[numDistortions].Config.K[8] = 1.6986004f; + distortions[numDistortions].Config.K[9] = 1.9940577f; + distortions[numDistortions].Config.K[10] = 2.4783147f; + distortions[numDistortions].MaxRadius = 1.0f; + numDistortions++; + + // Tuned at maximum dial setting + distortions[numDistortions].Config.Eqn = Distortion_CatmullRom10; + distortions[numDistortions].EyeRelief = 0.012760465f + 0.005f; + distortions[numDistortions].Config.MetersPerTanAngleAtCenter = 0.0425f; + distortions[numDistortions].Config.K[0] = 1.0102f; + distortions[numDistortions].Config.K[1] = 1.0371f; + distortions[numDistortions].Config.K[2] = 1.0831f; + distortions[numDistortions].Config.K[3] = 1.1353f; + distortions[numDistortions].Config.K[4] = 1.2f; + distortions[numDistortions].Config.K[5] = 1.2851f; + distortions[numDistortions].Config.K[6] = 1.3979f; + distortions[numDistortions].Config.K[7] = 1.56f; + distortions[numDistortions].Config.K[8] = 1.8f; + distortions[numDistortions].Config.K[9] = 2.25f; + distortions[numDistortions].Config.K[10] = 3.0f; + distortions[numDistortions].MaxRadius = 1.0f; + numDistortions++; + + + + // Chromatic aberration doesn't seem to change with eye relief. + for ( int i = 0; i < numDistortions; i++ ) + { + distortions[i].Config.ChromaticAberration[0] = -0.006f; + distortions[i].Config.ChromaticAberration[1] = 0.0f; + distortions[i].Config.ChromaticAberration[2] = 0.014f; + distortions[i].Config.ChromaticAberration[3] = 0.0f; + } + } + else if ( hmd.EyeCups == EyeCup_DKHD2A ) + { + // Tuned DKHD2 lens + numDistortions = 0; + + distortions[numDistortions].Config.Eqn = Distortion_CatmullRom10; + distortions[numDistortions].EyeRelief = 0.010f; + distortions[numDistortions].Config.MetersPerTanAngleAtCenter = 0.0425f; + distortions[numDistortions].Config.K[0] = 1.0f; + distortions[numDistortions].Config.K[1] = 1.0425f; + distortions[numDistortions].Config.K[2] = 1.0826f; + distortions[numDistortions].Config.K[3] = 1.130f; + distortions[numDistortions].Config.K[4] = 1.185f; + distortions[numDistortions].Config.K[5] = 1.250f; + distortions[numDistortions].Config.K[6] = 1.338f; + distortions[numDistortions].Config.K[7] = 1.455f; + distortions[numDistortions].Config.K[8] = 1.620f; + distortions[numDistortions].Config.K[9] = 1.840f; + distortions[numDistortions].Config.K[10] = 2.200f; + distortions[numDistortions].MaxRadius = 1.0f; + + defaultDistortion = numDistortions; // this is the default + numDistortions++; + + distortions[numDistortions] = distortions[0]; + distortions[numDistortions].EyeRelief = 0.020f; + numDistortions++; + + // Chromatic aberration doesn't seem to change with eye relief. + for ( int i = 0; i < numDistortions; i++ ) + { + distortions[i].Config.ChromaticAberration[0] = -0.006f; + distortions[i].Config.ChromaticAberration[1] = 0.0f; + distortions[i].Config.ChromaticAberration[2] = 0.014f; + distortions[i].Config.ChromaticAberration[3] = 0.0f; + } + } + else if ( hmd.EyeCups == EyeCup_PinkA || hmd.EyeCups == EyeCup_DK2A ) + { + // Tuned Crystal Cove & DK2 Lens (CES & GDC) + numDistortions = 0; + + + distortions[numDistortions].EyeRelief = 0.008f; + distortions[numDistortions].Config.MetersPerTanAngleAtCenter = 0.036f; + // TODO: Need to retune this distortion for minimum eye relief + distortions[numDistortions].Config.Eqn = Distortion_CatmullRom10; + distortions[numDistortions].Config.K[0] = 1.003f; + distortions[numDistortions].Config.K[1] = 1.02f; + distortions[numDistortions].Config.K[2] = 1.042f; + distortions[numDistortions].Config.K[3] = 1.066f; + distortions[numDistortions].Config.K[4] = 1.094f; + distortions[numDistortions].Config.K[5] = 1.126f; + distortions[numDistortions].Config.K[6] = 1.162f; + distortions[numDistortions].Config.K[7] = 1.203f; + distortions[numDistortions].Config.K[8] = 1.25f; + distortions[numDistortions].Config.K[9] = 1.31f; + distortions[numDistortions].Config.K[10] = 1.38f; + distortions[numDistortions].MaxRadius = 1.0f; + + distortions[numDistortions].Config.ChromaticAberration[0] = -0.0112f; + distortions[numDistortions].Config.ChromaticAberration[1] = -0.015f; + distortions[numDistortions].Config.ChromaticAberration[2] = 0.0187f; + distortions[numDistortions].Config.ChromaticAberration[3] = 0.015f; + + numDistortions++; + + + + + + distortions[numDistortions].EyeRelief = 0.018f; + distortions[numDistortions].Config.MetersPerTanAngleAtCenter = 0.036f; + + distortions[numDistortions].Config.Eqn = Distortion_CatmullRom10; + distortions[numDistortions].Config.K[0] = 1.003f; + distortions[numDistortions].Config.K[1] = 1.02f; + distortions[numDistortions].Config.K[2] = 1.042f; + distortions[numDistortions].Config.K[3] = 1.066f; + distortions[numDistortions].Config.K[4] = 1.094f; + distortions[numDistortions].Config.K[5] = 1.126f; + distortions[numDistortions].Config.K[6] = 1.162f; + distortions[numDistortions].Config.K[7] = 1.203f; + distortions[numDistortions].Config.K[8] = 1.25f; + distortions[numDistortions].Config.K[9] = 1.31f; + distortions[numDistortions].Config.K[10] = 1.38f; + distortions[numDistortions].MaxRadius = 1.0f; + + distortions[numDistortions].Config.ChromaticAberration[0] = -0.015f; + distortions[numDistortions].Config.ChromaticAberration[1] = -0.02f; + distortions[numDistortions].Config.ChromaticAberration[2] = 0.025f; + distortions[numDistortions].Config.ChromaticAberration[3] = 0.02f; + + defaultDistortion = numDistortions; // this is the default + numDistortions++; + + /* + // Orange Lens on DK2 + distortions[numDistortions].EyeRelief = 0.010f; + distortions[numDistortions].Config.MetersPerTanAngleAtCenter = 0.031f; + + distortions[numDistortions].Config.Eqn = Distortion_CatmullRom10; + distortions[numDistortions].Config.K[0] = 1.00f; + distortions[numDistortions].Config.K[1] = 1.0169f; + distortions[numDistortions].Config.K[2] = 1.0378f; + distortions[numDistortions].Config.K[3] = 1.0648f; + distortions[numDistortions].Config.K[4] = 1.0990f; + distortions[numDistortions].Config.K[5] = 1.141f; + distortions[numDistortions].Config.K[6] = 1.192f; + distortions[numDistortions].Config.K[7] = 1.255f; + distortions[numDistortions].Config.K[8] = 1.335f; + distortions[numDistortions].Config.K[9] = 1.435f; + distortions[numDistortions].Config.K[10] = 1.56f; + distortions[numDistortions].MaxRadius = 1.0f; + */ + } + else + { + // Unknown lens. + // Use DK1 black lens settings, just so we can continue to run with something. + distortions[0].EyeRelief = 0.005f; + distortions[0].Config.MetersPerTanAngleAtCenter = 0.043875f; + distortions[0].Config.Eqn = Distortion_RecipPoly4; + distortions[0].Config.K[0] = 1.0f; + distortions[0].Config.K[1] = -0.3999f; + distortions[0].Config.K[2] = 0.2408f; + distortions[0].Config.K[3] = -0.4589f; + distortions[0].SampleRadius[0] = 0.2f; + distortions[0].SampleRadius[1] = 0.4f; + distortions[0].SampleRadius[2] = 0.6f; + + distortions[1] = distortions[0]; + distortions[1].EyeRelief = 0.010f; + numDistortions = 2; + + // Chromatic aberration doesn't seem to change with eye relief. + for ( int i = 0; i < numDistortions; i++ ) + { + // These are placeholder, they have not been tuned! + distortions[i].Config.ChromaticAberration[0] = 0.0f; + distortions[i].Config.ChromaticAberration[1] = 0.0f; + distortions[i].Config.ChromaticAberration[2] = 0.0f; + distortions[i].Config.ChromaticAberration[3] = 0.0f; + } + } + + OVR_ASSERT(numDistortions < MaxDistortions); + + DistortionDescriptor *pUpper = NULL; + DistortionDescriptor *pLower = NULL; + float lerpVal = 0.0f; + if (eyeReliefInMeters == 0) + { // Use a constant default distortion if an invalid eye-relief is supplied + pLower = &(distortions[defaultDistortion]); + pUpper = &(distortions[defaultDistortion]); + lerpVal = 0.0f; + } + else + { + for ( int i = 0; i < numDistortions-1; i++ ) + { + OVR_ASSERT ( distortions[i].EyeRelief < distortions[i+1].EyeRelief ); + if ( ( distortions[i].EyeRelief <= eyeReliefInMeters ) && ( distortions[i+1].EyeRelief > eyeReliefInMeters ) ) + { + pLower = &(distortions[i]); + pUpper = &(distortions[i+1]); + lerpVal = ( eyeReliefInMeters - pLower->EyeRelief ) / ( pUpper->EyeRelief - pLower->EyeRelief ); + // No break here - I want the ASSERT to check everything every time! + } + } + } + + if ( pUpper == NULL ) + { +#if 0 + // Outside the range, so extrapolate rather than interpolate. + if ( distortions[0].EyeRelief > eyeReliefInMeters ) + { + pLower = &(distortions[0]); + pUpper = &(distortions[1]); + } + else + { + OVR_ASSERT ( distortions[numDistortions-1].EyeRelief <= eyeReliefInMeters ); + pLower = &(distortions[numDistortions-2]); + pUpper = &(distortions[numDistortions-1]); + } + lerpVal = ( eyeReliefInMeters - pLower->EyeRelief ) / ( pUpper->EyeRelief - pLower->EyeRelief ); +#else + // Do not extrapolate, just clamp - slightly worried about people putting in bogus settings. + if ( distortions[0].EyeRelief > eyeReliefInMeters ) + { + pLower = &(distortions[0]); + pUpper = &(distortions[0]); + } + else + { + OVR_ASSERT ( distortions[numDistortions-1].EyeRelief <= eyeReliefInMeters ); + pLower = &(distortions[numDistortions-1]); + pUpper = &(distortions[numDistortions-1]); + } + lerpVal = 0.0f; +#endif + } + float invLerpVal = 1.0f - lerpVal; + + pLower->Config.MaxR = pLower->MaxRadius; + pUpper->Config.MaxR = pUpper->MaxRadius; + + LensConfig result; + // Where is the edge of the lens - no point modelling further than this. + float maxValidRadius = invLerpVal * pLower->MaxRadius + lerpVal * pUpper->MaxRadius; + result.MaxR = maxValidRadius; + + switch ( distortionType ) + { + case Distortion_Poly4: + // Deprecated + OVR_ASSERT ( false ); + break; + case Distortion_RecipPoly4:{ + // Lerp control points and fit an equation to them. + float fitX[4]; + float fitY[4]; + fitX[0] = 0.0f; + fitY[0] = 1.0f; + for ( int ctrlPt = 1; ctrlPt < 4; ctrlPt ++ ) + { + // SampleRadius is not valid for Distortion_RecipPoly4 types. + float radiusLerp = ( invLerpVal * pLower->MaxRadius + lerpVal * pUpper->MaxRadius ) * ( (float)ctrlPt / 4.0f ); + float radiusLerpSq = radiusLerp * radiusLerp; + float fitYLower = pLower->Config.DistortionFnScaleRadiusSquared ( radiusLerpSq ); + float fitYUpper = pUpper->Config.DistortionFnScaleRadiusSquared ( radiusLerpSq ); + fitX[ctrlPt] = radiusLerpSq; + fitY[ctrlPt] = 1.0f / ( invLerpVal * fitYLower + lerpVal * fitYUpper ); + } + + result.Eqn = Distortion_RecipPoly4; + bool bSuccess = FitCubicPolynomial ( result.K, fitX, fitY ); + OVR_ASSERT ( bSuccess ); + OVR_UNUSED ( bSuccess ); + + // Set up the fast inverse. + float maxRDist = result.DistortionFn ( maxValidRadius ); + result.MaxInvR = maxRDist; + result.SetUpInverseApprox(); + + }break; + + case Distortion_CatmullRom10:{ + + // Evenly sample & lerp points on the curve. + const int NumSegments = LensConfig::NumCoefficients; + result.MaxR = maxValidRadius; + // Directly interpolate the K0 values + result.K[0] = invLerpVal * pLower->Config.K[0] + lerpVal * pUpper->Config.K[0]; + + // Sample and interpolate the distortion curves to derive K[1] ... K[n] + for ( int ctrlPt = 1; ctrlPt < NumSegments; ctrlPt++ ) + { + float radiusSq = ( (float)ctrlPt / (float)(NumSegments-1) ) * maxValidRadius * maxValidRadius; + float fitYLower = pLower->Config.DistortionFnScaleRadiusSquared ( radiusSq ); + float fitYUpper = pUpper->Config.DistortionFnScaleRadiusSquared ( radiusSq ); + float fitLerp = invLerpVal * fitYLower + lerpVal * fitYUpper; + result.K[ctrlPt] = fitLerp; + } + + result.Eqn = Distortion_CatmullRom10; + + for ( int ctrlPt = 1; ctrlPt < NumSegments; ctrlPt++ ) + { + float radiusSq = ( (float)ctrlPt / (float)(NumSegments-1) ) * maxValidRadius * maxValidRadius; + float val = result.DistortionFnScaleRadiusSquared ( radiusSq ); + OVR_ASSERT ( Alg::Abs ( val - result.K[ctrlPt] ) < 0.0001f ); + OVR_UNUSED1(val); // For release build. + } + + // Set up the fast inverse. + float maxRDist = result.DistortionFn ( maxValidRadius ); + result.MaxInvR = maxRDist; + result.SetUpInverseApprox(); + + }break; + + default: OVR_ASSERT ( false ); break; + } + + + // Chromatic aberration. + result.ChromaticAberration[0] = invLerpVal * pLower->Config.ChromaticAberration[0] + lerpVal * pUpper->Config.ChromaticAberration[0]; + result.ChromaticAberration[1] = invLerpVal * pLower->Config.ChromaticAberration[1] + lerpVal * pUpper->Config.ChromaticAberration[1]; + result.ChromaticAberration[2] = invLerpVal * pLower->Config.ChromaticAberration[2] + lerpVal * pUpper->Config.ChromaticAberration[2]; + result.ChromaticAberration[3] = invLerpVal * pLower->Config.ChromaticAberration[3] + lerpVal * pUpper->Config.ChromaticAberration[3]; + + // Scale. + result.MetersPerTanAngleAtCenter = pLower->Config.MetersPerTanAngleAtCenter * invLerpVal + + pUpper->Config.MetersPerTanAngleAtCenter * lerpVal; + /* + // Commented out - Causes ASSERT with no HMD plugged in +#ifdef OVR_BUILD_DEBUG + if ( distortionType == Distortion_CatmullRom10 ) + { + TestSaveLoadLensConfig ( result ); + } +#endif + */ + return result; +} + + +DistortionRenderDesc CalculateDistortionRenderDesc ( StereoEye eyeType, HmdRenderInfo const &hmd, + const LensConfig *pLensOverride /*= NULL */ ) +{ + // From eye relief, IPD and device characteristics, we get the distortion mapping. + // This distortion does the following things: + // 1. It undoes the distortion that happens at the edges of the lens. + // 2. It maps the undistorted field into "retina" space. + // So the input is a pixel coordinate - the physical pixel on the display itself. + // The output is the real-world direction of the ray from this pixel as it comes out of the lens and hits the eye. + // However we typically think of rays "coming from" the eye, so the direction (TanAngleX,TanAngleY,1) is the direction + // that the pixel appears to be in real-world space, where AngleX and AngleY are relative to the straight-ahead vector. + // If your renderer is a raytracer, you can use this vector directly (normalize as appropriate). + // However in standard rasterisers, we have rendered a 2D image and are putting it in front of the eye, + // so we then need a mapping from this space to the [-1,1] UV coordinate space, which depends on exactly + // where "in space" the app wants to put that rendertarget. + // Where in space, and how large this rendertarget is, is completely up to the app and/or user, + // though of course we can provide some useful hints. + + // TODO: Use IPD and eye relief to modify distortion (i.e. non-radial component) + // TODO: cope with lenses that don't produce collimated light. + // This means that IPD relative to the lens separation changes the light vergence, + // and so we actually need to change where the image is displayed. + + const HmdRenderInfo::EyeConfig &hmdEyeConfig = ( eyeType == StereoEye_Left ) ? hmd.EyeLeft : hmd.EyeRight; + + DistortionRenderDesc localDistortion; + localDistortion.Lens = hmdEyeConfig.Distortion; + + if ( pLensOverride != NULL ) + { + localDistortion.Lens = *pLensOverride; + } + + Sizef pixelsPerMeter(hmd.ResolutionInPixels.w / ( hmd.ScreenSizeInMeters.w - hmd.ScreenGapSizeInMeters ), + hmd.ResolutionInPixels.h / hmd.ScreenSizeInMeters.h); + + localDistortion.PixelsPerTanAngleAtCenter = (pixelsPerMeter * localDistortion.Lens.MetersPerTanAngleAtCenter).ToVector(); + // Same thing, scaled to [-1,1] for each eye, rather than pixels. + + localDistortion.TanEyeAngleScale = Vector2f(0.25f, 0.5f).EntrywiseMultiply( + (hmd.ScreenSizeInMeters / localDistortion.Lens.MetersPerTanAngleAtCenter).ToVector()); + + // <--------------left eye------------------><-ScreenGapSizeInMeters-><--------------right eye-----------------> + // <------------------------------------------ScreenSizeInMeters.Width-----------------------------------------> + // <----------------LensSeparationInMeters---------------> + // <--centerFromLeftInMeters-> + // ^ + // Center of lens + + // Find the lens centers in scale of [-1,+1] (NDC) in left eye. + float visibleWidthOfOneEye = 0.5f * ( hmd.ScreenSizeInMeters.w - hmd.ScreenGapSizeInMeters ); + float centerFromLeftInMeters = ( hmd.ScreenSizeInMeters.w - hmd.LensSeparationInMeters ) * 0.5f; + localDistortion.LensCenter.x = ( centerFromLeftInMeters / visibleWidthOfOneEye ) * 2.0f - 1.0f; + localDistortion.LensCenter.y = ( hmd.CenterFromTopInMeters / hmd.ScreenSizeInMeters.h ) * 2.0f - 1.0f; + if ( eyeType == StereoEye_Right ) + { + localDistortion.LensCenter.x = -localDistortion.LensCenter.x; + } + + return localDistortion; +} + +FovPort CalculateFovFromEyePosition ( float eyeReliefInMeters, + float offsetToRightInMeters, + float offsetDownwardsInMeters, + float lensDiameterInMeters, + float extraEyeRotationInRadians /*= 0.0f*/ ) +{ + // 2D view of things: + // |-| <--- offsetToRightInMeters (in this case, it is negative) + // |=======C=======| <--- lens surface (C=center) + // \ | _/ + // \ R _/ + // \ | _/ + // \ | _/ + // \|/ + // O <--- center of pupil + + // (technically the lens is round rather than square, so it's not correct to + // separate vertical and horizontal like this, but it's close enough) + float halfLensDiameter = lensDiameterInMeters * 0.5f; + FovPort fovPort; + fovPort.UpTan = ( halfLensDiameter + offsetDownwardsInMeters ) / eyeReliefInMeters; + fovPort.DownTan = ( halfLensDiameter - offsetDownwardsInMeters ) / eyeReliefInMeters; + fovPort.LeftTan = ( halfLensDiameter + offsetToRightInMeters ) / eyeReliefInMeters; + fovPort.RightTan = ( halfLensDiameter - offsetToRightInMeters ) / eyeReliefInMeters; + + if ( extraEyeRotationInRadians > 0.0f ) + { + // That's the basic looking-straight-ahead eye position relative to the lens. + // But if you look left, the pupil moves left as the eyeball rotates, which + // means you can see more to the right than this geometry suggests. + // So add in the bounds for the extra movement of the pupil. + + // Beyond 30 degrees does not increase FOV because the pupil starts moving backwards more than sideways. + extraEyeRotationInRadians = Alg::Min ( DegreeToRad ( 30.0f ), Alg::Max ( 0.0f, extraEyeRotationInRadians ) ); + + // The rotation of the eye is a bit more complex than a simple circle. The center of rotation + // at 13.5mm from cornea is slightly further back than the actual center of the eye. + // Additionally the rotation contains a small lateral component as the muscles pull the eye + const float eyeballCenterToPupil = 0.0135f; // center of eye rotation + const float eyeballLateralPull = 0.001f * (extraEyeRotationInRadians / DegreeToRad ( 30.0f)); // lateral motion as linear function + float extraTranslation = eyeballCenterToPupil * sinf ( extraEyeRotationInRadians ) + eyeballLateralPull; + float extraRelief = eyeballCenterToPupil * ( 1.0f - cosf ( extraEyeRotationInRadians ) ); + + fovPort.UpTan = Alg::Max ( fovPort.UpTan , ( halfLensDiameter + offsetDownwardsInMeters + extraTranslation ) / ( eyeReliefInMeters + extraRelief ) ); + fovPort.DownTan = Alg::Max ( fovPort.DownTan , ( halfLensDiameter - offsetDownwardsInMeters + extraTranslation ) / ( eyeReliefInMeters + extraRelief ) ); + fovPort.LeftTan = Alg::Max ( fovPort.LeftTan , ( halfLensDiameter + offsetToRightInMeters + extraTranslation ) / ( eyeReliefInMeters + extraRelief ) ); + fovPort.RightTan = Alg::Max ( fovPort.RightTan, ( halfLensDiameter - offsetToRightInMeters + extraTranslation ) / ( eyeReliefInMeters + extraRelief ) ); + } + + return fovPort; +} + + + +FovPort CalculateFovFromHmdInfo ( StereoEye eyeType, + DistortionRenderDesc const &distortion, + HmdRenderInfo const &hmd, + float extraEyeRotationInRadians /*= 0.0f*/ ) +{ + FovPort fovPort; + float eyeReliefInMeters; + float offsetToRightInMeters; + if ( eyeType == StereoEye_Right ) + { + eyeReliefInMeters = hmd.EyeRight.ReliefInMeters; + offsetToRightInMeters = hmd.EyeRight.NoseToPupilInMeters - 0.5f * hmd.LensSeparationInMeters; + } + else + { + eyeReliefInMeters = hmd.EyeLeft.ReliefInMeters; + offsetToRightInMeters = -(hmd.EyeLeft.NoseToPupilInMeters - 0.5f * hmd.LensSeparationInMeters); + } + + // Limit the eye-relief to 6 mm for FOV calculations since this just tends to spread off-screen + // and get clamped anyways on DK1 (but in Unity it continues to spreads and causes + // unnecessarily large render targets) + eyeReliefInMeters = Alg::Max(eyeReliefInMeters, 0.006f); + + // Central view. + fovPort = CalculateFovFromEyePosition ( eyeReliefInMeters, + offsetToRightInMeters, + 0.0f, + hmd.LensDiameterInMeters, + extraEyeRotationInRadians ); + + // clamp to the screen + fovPort = ClampToPhysicalScreenFov ( eyeType, distortion, fovPort ); + + return fovPort; +} + + + +FovPort GetPhysicalScreenFov ( StereoEye eyeType, DistortionRenderDesc const &distortion ) +{ + OVR_UNUSED1 ( eyeType ); + + FovPort resultFovPort; + + // Figure out the boundaries of the screen. We take the middle pixel of the screen, + // move to each of the four screen edges, and transform those back into TanAngle space. + Vector2f dmiddle = distortion.LensCenter; + + // The gotcha is that for some distortion functions, the map will "wrap around" + // for screen pixels that are not actually visible to the user (especially on DK1, + // which has a lot of invisible pixels), and map to pixels that are close to the middle. + // This means the edges of the screen will actually be + // "closer" than the visible bounds, so we'll clip too aggressively. + + // Solution - step gradually towards the boundary, noting the maximum distance. + struct FunctionHider + { + static FovPort FindRange ( Vector2f from, Vector2f to, int numSteps, + DistortionRenderDesc const &distortionL ) + { + FovPort result; + result.UpTan = 0.0f; + result.DownTan = 0.0f; + result.LeftTan = 0.0f; + result.RightTan = 0.0f; + + float stepScale = 1.0f / ( numSteps - 1 ); + for ( int step = 0; step < numSteps; step++ ) + { + float lerpFactor = stepScale * (float)step; + Vector2f sample = from + (to - from) * lerpFactor; + Vector2f tanEyeAngle = TransformScreenNDCToTanFovSpace ( distortionL, sample ); + + result.LeftTan = Alg::Max ( result.LeftTan, -tanEyeAngle.x ); + result.RightTan = Alg::Max ( result.RightTan, tanEyeAngle.x ); + result.UpTan = Alg::Max ( result.UpTan, -tanEyeAngle.y ); + result.DownTan = Alg::Max ( result.DownTan, tanEyeAngle.y ); + } + return result; + } + }; + + FovPort leftFovPort = FunctionHider::FindRange( dmiddle, Vector2f( -1.0f, dmiddle.y ), 10, distortion ); + FovPort rightFovPort = FunctionHider::FindRange( dmiddle, Vector2f( 1.0f, dmiddle.y ), 10, distortion ); + FovPort upFovPort = FunctionHider::FindRange( dmiddle, Vector2f( dmiddle.x, -1.0f ), 10, distortion ); + FovPort downFovPort = FunctionHider::FindRange( dmiddle, Vector2f( dmiddle.x, 1.0f ), 10, distortion ); + + resultFovPort.LeftTan = leftFovPort.LeftTan; + resultFovPort.RightTan = rightFovPort.RightTan; + resultFovPort.UpTan = upFovPort.UpTan; + resultFovPort.DownTan = downFovPort.DownTan; + + return resultFovPort; +} + +FovPort ClampToPhysicalScreenFov( StereoEye eyeType, DistortionRenderDesc const &distortion, + FovPort inputFovPort ) +{ + FovPort resultFovPort; + FovPort phsyicalFovPort = GetPhysicalScreenFov ( eyeType, distortion ); + resultFovPort.LeftTan = Alg::Min ( inputFovPort.LeftTan, phsyicalFovPort.LeftTan ); + resultFovPort.RightTan = Alg::Min ( inputFovPort.RightTan, phsyicalFovPort.RightTan ); + resultFovPort.UpTan = Alg::Min ( inputFovPort.UpTan, phsyicalFovPort.UpTan ); + resultFovPort.DownTan = Alg::Min ( inputFovPort.DownTan, phsyicalFovPort.DownTan ); + + return resultFovPort; +} + +Sizei CalculateIdealPixelSize ( StereoEye eyeType, DistortionRenderDesc const &distortion, + FovPort tanHalfFov, float pixelsPerDisplayPixel ) +{ + OVR_UNUSED(eyeType); // might be useful in the future if we do overlapping fovs + + Sizei result; + // TODO: if the app passes in a FOV that doesn't cover the centre, use the distortion values for the nearest edge/corner to match pixel size. + result.w = (int)(0.5f + pixelsPerDisplayPixel * distortion.PixelsPerTanAngleAtCenter.x * ( tanHalfFov.LeftTan + tanHalfFov.RightTan ) ); + result.h = (int)(0.5f + pixelsPerDisplayPixel * distortion.PixelsPerTanAngleAtCenter.y * ( tanHalfFov.UpTan + tanHalfFov.DownTan ) ); + return result; +} + +Recti GetFramebufferViewport ( StereoEye eyeType, HmdRenderInfo const &hmd ) +{ + Recti result; + result.w = hmd.ResolutionInPixels.w/2; + result.h = hmd.ResolutionInPixels.h; + result.x = 0; + result.y = 0; + if ( eyeType == StereoEye_Right ) + { + result.x = (hmd.ResolutionInPixels.w+1)/2; // Round up, not down. + } + return result; +} + + +ScaleAndOffset2D CreateNDCScaleAndOffsetFromFov ( FovPort tanHalfFov ) +{ + float projXScale = 2.0f / ( tanHalfFov.LeftTan + tanHalfFov.RightTan ); + float projXOffset = ( tanHalfFov.LeftTan - tanHalfFov.RightTan ) * projXScale * 0.5f; + float projYScale = 2.0f / ( tanHalfFov.UpTan + tanHalfFov.DownTan ); + float projYOffset = ( tanHalfFov.UpTan - tanHalfFov.DownTan ) * projYScale * 0.5f; + + ScaleAndOffset2D result; + result.Scale = Vector2f(projXScale, projYScale); + result.Offset = Vector2f(projXOffset, projYOffset); + // Hey - why is that Y.Offset negated? + // It's because a projection matrix transforms from world coords with Y=up, + // whereas this is from NDC which is Y=down. + + return result; +} + + +ScaleAndOffset2D CreateUVScaleAndOffsetfromNDCScaleandOffset ( ScaleAndOffset2D scaleAndOffsetNDC, + Recti renderedViewport, + Sizei renderTargetSize ) +{ + // scaleAndOffsetNDC takes you to NDC space [-1,+1] within the given viewport on the rendertarget. + // We want a scale to instead go to actual UV coordinates you can sample with, + // which need [0,1] and ignore the viewport. + ScaleAndOffset2D result; + // Scale [-1,1] to [0,1] + result.Scale = scaleAndOffsetNDC.Scale * 0.5f; + result.Offset = scaleAndOffsetNDC.Offset * 0.5f + Vector2f(0.5f); + + // ...but we will have rendered to a subsection of the RT, so scale for that. + Vector2f scale( (float)renderedViewport.w / (float)renderTargetSize.w, + (float)renderedViewport.h / (float)renderTargetSize.h ); + Vector2f offset( (float)renderedViewport.x / (float)renderTargetSize.w, + (float)renderedViewport.y / (float)renderTargetSize.h ); + + result.Scale = result.Scale.EntrywiseMultiply(scale); + result.Offset = result.Offset.EntrywiseMultiply(scale) + offset; + return result; +} + + + +Matrix4f CreateProjection( bool rightHanded, FovPort tanHalfFov, + float zNear /*= 0.01f*/, float zFar /*= 10000.0f*/ ) +{ + // A projection matrix is very like a scaling from NDC, so we can start with that. + ScaleAndOffset2D scaleAndOffset = CreateNDCScaleAndOffsetFromFov ( tanHalfFov ); + + float handednessScale = 1.0f; + if ( rightHanded ) + { + handednessScale = -1.0f; + } + + Matrix4f projection; + // Produces X result, mapping clip edges to [-w,+w] + projection.M[0][0] = scaleAndOffset.Scale.x; + projection.M[0][1] = 0.0f; + projection.M[0][2] = handednessScale * scaleAndOffset.Offset.x; + projection.M[0][3] = 0.0f; + + // Produces Y result, mapping clip edges to [-w,+w] + // Hey - why is that YOffset negated? + // It's because a projection matrix transforms from world coords with Y=up, + // whereas this is derived from an NDC scaling, which is Y=down. + projection.M[1][0] = 0.0f; + projection.M[1][1] = scaleAndOffset.Scale.y; + projection.M[1][2] = handednessScale * -scaleAndOffset.Offset.y; + projection.M[1][3] = 0.0f; + + // Produces Z-buffer result - app needs to fill this in with whatever Z range it wants. + // We'll just use some defaults for now. + projection.M[2][0] = 0.0f; + projection.M[2][1] = 0.0f; + projection.M[2][2] = -handednessScale * zFar / (zNear - zFar); + projection.M[2][3] = (zFar * zNear) / (zNear - zFar); + + // Produces W result (= Z in) + projection.M[3][0] = 0.0f; + projection.M[3][1] = 0.0f; + projection.M[3][2] = handednessScale; + projection.M[3][3] = 0.0f; + + return projection; +} + + +Matrix4f CreateOrthoSubProjection ( bool rightHanded, StereoEye eyeType, + float tanHalfFovX, float tanHalfFovY, + float unitsX, float unitsY, + float distanceFromCamera, float interpupillaryDistance, + Matrix4f const &projection, + float zNear /*= 0.0f*/, float zFar /*= 0.0f*/ ) +{ + OVR_UNUSED1 ( rightHanded ); + + float orthoHorizontalOffset = interpupillaryDistance * 0.5f / distanceFromCamera; + switch ( eyeType ) + { + case StereoEye_Center: + orthoHorizontalOffset = 0.0f; + break; + case StereoEye_Left: + break; + case StereoEye_Right: + orthoHorizontalOffset = -orthoHorizontalOffset; + break; + default: OVR_ASSERT ( false ); break; + } + + // Current projection maps real-world vector (x,y,1) to the RT. + // We want to find the projection that maps the range [-FovPixels/2,FovPixels/2] to + // the physical [-orthoHalfFov,orthoHalfFov] + // Note moving the offset from M[0][2]+M[1][2] to M[0][3]+M[1][3] - this means + // we don't have to feed in Z=1 all the time. + // The horizontal offset math is a little hinky because the destination is + // actually [-orthoHalfFov+orthoHorizontalOffset,orthoHalfFov+orthoHorizontalOffset] + // So we need to first map [-FovPixels/2,FovPixels/2] to + // [-orthoHalfFov+orthoHorizontalOffset,orthoHalfFov+orthoHorizontalOffset]: + // x1 = x0 * orthoHalfFov/(FovPixels/2) + orthoHorizontalOffset; + // = x0 * 2*orthoHalfFov/FovPixels + orthoHorizontalOffset; + // But then we need the sam mapping as the existing projection matrix, i.e. + // x2 = x1 * Projection.M[0][0] + Projection.M[0][2]; + // = x0 * (2*orthoHalfFov/FovPixels + orthoHorizontalOffset) * Projection.M[0][0] + Projection.M[0][2]; + // = x0 * Projection.M[0][0]*2*orthoHalfFov/FovPixels + + // orthoHorizontalOffset*Projection.M[0][0] + Projection.M[0][2]; + // So in the new projection matrix we need to scale by Projection.M[0][0]*2*orthoHalfFov/FovPixels and + // offset by orthoHorizontalOffset*Projection.M[0][0] + Projection.M[0][2]. + + float orthoScaleX = 2.0f * tanHalfFovX / unitsX; + float orthoScaleY = 2.0f * tanHalfFovY / unitsY; + Matrix4f ortho; + ortho.M[0][0] = projection.M[0][0] * orthoScaleX; + ortho.M[0][1] = 0.0f; + ortho.M[0][2] = 0.0f; + ortho.M[0][3] = -projection.M[0][2] + ( orthoHorizontalOffset * projection.M[0][0] ); + + ortho.M[1][0] = 0.0f; + ortho.M[1][1] = -projection.M[1][1] * orthoScaleY; // Note sign flip (text rendering uses Y=down). + ortho.M[1][2] = 0.0f; + ortho.M[1][3] = -projection.M[1][2]; + + if ( fabsf ( zNear - zFar ) < 0.001f ) + { + ortho.M[2][0] = 0.0f; + ortho.M[2][1] = 0.0f; + ortho.M[2][2] = 0.0f; + ortho.M[2][3] = zFar; + } + else + { + ortho.M[2][0] = 0.0f; + ortho.M[2][1] = 0.0f; + ortho.M[2][2] = zFar / (zNear - zFar); + ortho.M[2][3] = (zFar * zNear) / (zNear - zFar); + } + + // No perspective correction for ortho. + ortho.M[3][0] = 0.0f; + ortho.M[3][1] = 0.0f; + ortho.M[3][2] = 0.0f; + ortho.M[3][3] = 1.0f; + + return ortho; +} + + +//----------------------------------------------------------------------------------- +// A set of "forward-mapping" functions, mapping from framebuffer space to real-world and/or texture space. + +// This mimics the first half of the distortion shader's function. +Vector2f TransformScreenNDCToTanFovSpace( DistortionRenderDesc const &distortion, + const Vector2f &framebufferNDC ) +{ + // Scale to TanHalfFov space, but still distorted. + Vector2f tanEyeAngleDistorted; + tanEyeAngleDistorted.x = ( framebufferNDC.x - distortion.LensCenter.x ) * distortion.TanEyeAngleScale.x; + tanEyeAngleDistorted.y = ( framebufferNDC.y - distortion.LensCenter.y ) * distortion.TanEyeAngleScale.y; + // Distort. + float radiusSquared = ( tanEyeAngleDistorted.x * tanEyeAngleDistorted.x ) + + ( tanEyeAngleDistorted.y * tanEyeAngleDistorted.y ); + float distortionScale = distortion.Lens.DistortionFnScaleRadiusSquared ( radiusSquared ); + Vector2f tanEyeAngle; + tanEyeAngle.x = tanEyeAngleDistorted.x * distortionScale; + tanEyeAngle.y = tanEyeAngleDistorted.y * distortionScale; + + return tanEyeAngle; +} + +// Same, with chromatic aberration correction. +void TransformScreenNDCToTanFovSpaceChroma ( Vector2f *resultR, Vector2f *resultG, Vector2f *resultB, + DistortionRenderDesc const &distortion, + const Vector2f &framebufferNDC ) +{ + // Scale to TanHalfFov space, but still distorted. + Vector2f tanEyeAngleDistorted; + tanEyeAngleDistorted.x = ( framebufferNDC.x - distortion.LensCenter.x ) * distortion.TanEyeAngleScale.x; + tanEyeAngleDistorted.y = ( framebufferNDC.y - distortion.LensCenter.y ) * distortion.TanEyeAngleScale.y; + // Distort. + float radiusSquared = ( tanEyeAngleDistorted.x * tanEyeAngleDistorted.x ) + + ( tanEyeAngleDistorted.y * tanEyeAngleDistorted.y ); + Vector3f distortionScales = distortion.Lens.DistortionFnScaleRadiusSquaredChroma ( radiusSquared ); + *resultR = tanEyeAngleDistorted * distortionScales.x; + *resultG = tanEyeAngleDistorted * distortionScales.y; + *resultB = tanEyeAngleDistorted * distortionScales.z; +} + +// This mimics the second half of the distortion shader's function. +Vector2f TransformTanFovSpaceToRendertargetTexUV( ScaleAndOffset2D const &eyeToSourceUV, + Vector2f const &tanEyeAngle ) +{ + Vector2f textureUV; + textureUV.x = tanEyeAngle.x * eyeToSourceUV.Scale.x + eyeToSourceUV.Offset.x; + textureUV.y = tanEyeAngle.y * eyeToSourceUV.Scale.y + eyeToSourceUV.Offset.y; + return textureUV; +} + +Vector2f TransformTanFovSpaceToRendertargetNDC( ScaleAndOffset2D const &eyeToSourceNDC, + Vector2f const &tanEyeAngle ) +{ + Vector2f textureNDC; + textureNDC.x = tanEyeAngle.x * eyeToSourceNDC.Scale.x + eyeToSourceNDC.Offset.x; + textureNDC.y = tanEyeAngle.y * eyeToSourceNDC.Scale.y + eyeToSourceNDC.Offset.y; + return textureNDC; +} + +Vector2f TransformScreenPixelToScreenNDC( Recti const &distortionViewport, + Vector2f const &pixel ) +{ + // Move to [-1,1] NDC coords. + Vector2f framebufferNDC; + framebufferNDC.x = -1.0f + 2.0f * ( ( pixel.x - (float)distortionViewport.x ) / (float)distortionViewport.w ); + framebufferNDC.y = -1.0f + 2.0f * ( ( pixel.y - (float)distortionViewport.y ) / (float)distortionViewport.h ); + return framebufferNDC; +} + +Vector2f TransformScreenPixelToTanFovSpace( Recti const &distortionViewport, + DistortionRenderDesc const &distortion, + Vector2f const &pixel ) +{ + return TransformScreenNDCToTanFovSpace( distortion, + TransformScreenPixelToScreenNDC( distortionViewport, pixel ) ); +} + +Vector2f TransformScreenNDCToRendertargetTexUV( DistortionRenderDesc const &distortion, + StereoEyeParams const &eyeParams, + Vector2f const &pixel ) +{ + return TransformTanFovSpaceToRendertargetTexUV ( eyeParams, + TransformScreenNDCToTanFovSpace ( distortion, pixel ) ); +} + +Vector2f TransformScreenPixelToRendertargetTexUV( Recti const &distortionViewport, + DistortionRenderDesc const &distortion, + StereoEyeParams const &eyeParams, + Vector2f const &pixel ) +{ + return TransformTanFovSpaceToRendertargetTexUV ( eyeParams, + TransformScreenPixelToTanFovSpace ( distortionViewport, distortion, pixel ) ); +} + + +//----------------------------------------------------------------------------------- +// A set of "reverse-mapping" functions, mapping from real-world and/or texture space back to the framebuffer. + +Vector2f TransformTanFovSpaceToScreenNDC( DistortionRenderDesc const &distortion, + const Vector2f &tanEyeAngle, bool usePolyApprox /*= false*/ ) +{ + float tanEyeAngleRadius = tanEyeAngle.Length(); + float tanEyeAngleDistortedRadius = distortion.Lens.DistortionFnInverseApprox ( tanEyeAngleRadius ); + if ( !usePolyApprox ) + { + tanEyeAngleDistortedRadius = distortion.Lens.DistortionFnInverse ( tanEyeAngleRadius ); + } + Vector2f tanEyeAngleDistorted = tanEyeAngle; + if ( tanEyeAngleRadius > 0.0f ) + { + tanEyeAngleDistorted = tanEyeAngle * ( tanEyeAngleDistortedRadius / tanEyeAngleRadius ); + } + + Vector2f framebufferNDC; + framebufferNDC.x = ( tanEyeAngleDistorted.x / distortion.TanEyeAngleScale.x ) + distortion.LensCenter.x; + framebufferNDC.y = ( tanEyeAngleDistorted.y / distortion.TanEyeAngleScale.y ) + distortion.LensCenter.y; + + return framebufferNDC; +} + +Vector2f TransformRendertargetNDCToTanFovSpace( const ScaleAndOffset2D &eyeToSourceNDC, + const Vector2f &textureNDC ) +{ + Vector2f tanEyeAngle = (textureNDC - eyeToSourceNDC.Offset) / eyeToSourceNDC.Scale; + return tanEyeAngle; +} + + + +} //namespace OVR + +//Just want to make a copy disentangled from all these namespaces! +float ExtEvalCatmullRom10Spline ( float const *K, float scaledVal ) +{ + return(OVR::EvalCatmullRom10Spline ( K, scaledVal )); +} + + diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/OVR_Stereo.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/OVR_Stereo.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,681 @@ +/************************************************************************************ + +Filename : OVR_Stereo.h +Content : Stereo rendering functions +Created : November 30, 2013 +Authors : Tom Fosyth + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +*************************************************************************************/ + +#ifndef OVR_Stereo_h +#define OVR_Stereo_h + +#include "Sensors/OVR_DeviceConstants.h" +#include "Displays/OVR_Display.h" +#include "OVR_Profile.h" + +// CAPI Forward declaration. +typedef struct ovrFovPort_ ovrFovPort; +typedef struct ovrRecti_ ovrRecti; + +namespace OVR { + +class SensorDevice; // Opaque forward declaration + + +//----------------------------------------------------------------------------------- +// ***** Stereo Enumerations + +// StereoEye specifies which eye we are rendering for; it is used to +// retrieve StereoEyeParams. +enum StereoEye +{ + StereoEye_Center, + StereoEye_Left, + StereoEye_Right +}; + + +//----------------------------------------------------------------------------------- +// ***** FovPort + +// FovPort describes Field Of View (FOV) of a viewport. +// This class has values for up, down, left and right, stored in +// tangent of the angle units to simplify calculations. +// +// As an example, for a standard 90 degree vertical FOV, we would +// have: { UpTan = tan(90 degrees / 2), DownTan = tan(90 degrees / 2) }. +// +// CreateFromRadians/Degrees helper functions can be used to +// access FOV in different units. + +struct FovPort +{ + float UpTan; + float DownTan; + float LeftTan; + float RightTan; + + FovPort ( float sideTan = 0.0f ) : + UpTan(sideTan), DownTan(sideTan), LeftTan(sideTan), RightTan(sideTan) { } + FovPort ( float u, float d, float l, float r ) : + UpTan(u), DownTan(d), LeftTan(l), RightTan(r) { } + + // C-interop support: FovPort <-> ovrFovPort (implementation in OVR_CAPI.cpp). + FovPort(const ovrFovPort& src); + operator ovrFovPort () const; + + static FovPort CreateFromRadians(float horizontalFov, float verticalFov) + { + FovPort result; + result.UpTan = tanf ( verticalFov * 0.5f ); + result.DownTan = tanf ( verticalFov * 0.5f ); + result.LeftTan = tanf ( horizontalFov * 0.5f ); + result.RightTan = tanf ( horizontalFov * 0.5f ); + return result; + } + + static FovPort CreateFromDegrees(float horizontalFovDegrees, + float verticalFovDegrees) + { + return CreateFromRadians(DegreeToRad(horizontalFovDegrees), + DegreeToRad(verticalFovDegrees)); + } + + // Get Horizontal/Vertical components of Fov in radians. + float GetVerticalFovRadians() const { return atanf(UpTan) + atanf(DownTan); } + float GetHorizontalFovRadians() const { return atanf(LeftTan) + atanf(RightTan); } + // Get Horizontal/Vertical components of Fov in degrees. + float GetVerticalFovDegrees() const { return RadToDegree(GetVerticalFovRadians()); } + float GetHorizontalFovDegrees() const { return RadToDegree(GetHorizontalFovRadians()); } + + // Compute maximum tangent value among all four sides. + float GetMaxSideTan() const + { + return Alg::Max(Alg::Max(UpTan, DownTan), Alg::Max(LeftTan, RightTan)); + } + + // Converts Fov Tan angle units to [-1,1] render target NDC space + Vector2f TanAngleToRendertargetNDC(Vector2f const &tanEyeAngle); + + + // Compute per-channel minimum and maximum of Fov. + static FovPort Min(const FovPort& a, const FovPort& b) + { + FovPort fov( Alg::Min( a.UpTan , b.UpTan ), + Alg::Min( a.DownTan , b.DownTan ), + Alg::Min( a.LeftTan , b.LeftTan ), + Alg::Min( a.RightTan, b.RightTan ) ); + return fov; + } + + static FovPort Max(const FovPort& a, const FovPort& b) + { + FovPort fov( Alg::Max( a.UpTan , b.UpTan ), + Alg::Max( a.DownTan , b.DownTan ), + Alg::Max( a.LeftTan , b.LeftTan ), + Alg::Max( a.RightTan, b.RightTan ) ); + return fov; + } +}; + + +//----------------------------------------------------------------------------------- +// ***** ScaleAndOffset + +struct ScaleAndOffset2D +{ + Vector2f Scale; + Vector2f Offset; + + ScaleAndOffset2D(float sx = 0.0f, float sy = 0.0f, float ox = 0.0f, float oy = 0.0f) + : Scale(sx, sy), Offset(ox, oy) + { } +}; + + +//----------------------------------------------------------------------------------- +// ***** Misc. utility functions. + +// Inputs are 4 points (pFitX[0],pFitY[0]) through (pFitX[3],pFitY[3]) +// Result is four coefficients in pResults[0] through pResults[3] such that +// y = pResult[0] + x * ( pResult[1] + x * ( pResult[2] + x * ( pResult[3] ) ) ); +// passes through all four input points. +// Return is true if it succeeded, false if it failed (because two control points +// have the same pFitX value). +bool FitCubicPolynomial ( float *pResult, const float *pFitX, const float *pFitY ); + +//----------------------------------------------------------------------------------- +// ***** LensConfig + +// LensConfig describes the configuration of a single lens in an HMD. +// - Eqn and K[] describe a distortion function. +// - MetersPerTanAngleAtCenter is the relationship between distance on a +// screen (at the center of the lens), and the angle variance of the light after it +// has passed through the lens. +// - ChromaticAberration is an array of parameters for controlling +// additional Red and Blue scaling in order to reduce chromatic aberration +// caused by the Rift lenses. +struct LensConfig +{ + LensConfig() + : Eqn(Distortion_CatmullRom10) + //K() + , MaxR(0.0f) + , MetersPerTanAngleAtCenter(0.0f) + //ChromaticAberration() + //InvK() + , MaxInvR(0.0f) + { + memset(&K, 0, sizeof(K)); + memset(&ChromaticAberration, 0, sizeof(ChromaticAberration)); + memset(&InvK, 0, sizeof(InvK)); + } + + // The result is a scaling applied to the distance from the center of the lens. + float DistortionFnScaleRadiusSquared (float rsq) const; + // x,y,z components map to r,g,b scales. + Vector3f DistortionFnScaleRadiusSquaredChroma (float rsq) const; + + // DistortionFn applies distortion to the argument. + // Input: the distance in TanAngle/NIC space from the optical center to the input pixel. + // Output: the resulting distance after distortion. + float DistortionFn(float r) const + { + return r * DistortionFnScaleRadiusSquared ( r * r ); + } + + // DistortionFnInverse computes the inverse of the distortion function on an argument. + float DistortionFnInverse(float r) const; + + // Also computes the inverse, but using a polynomial approximation. Warning - it's just an approximation! + float DistortionFnInverseApprox(float r) const; + // Sets up InvK[]. + void SetUpInverseApprox(); + + // Sets a bunch of sensible defaults. + void SetToIdentity(); + + + + enum { NumCoefficients = 11 }; + + DistortionEqnType Eqn; + float K[NumCoefficients]; + float MaxR; // The highest R you're going to query for - the curve is unpredictable beyond it. + + float MetersPerTanAngleAtCenter; + + // Additional per-channel scaling is applied after distortion: + // Index [0] - Red channel constant coefficient. + // Index [1] - Red channel r^2 coefficient. + // Index [2] - Blue channel constant coefficient. + // Index [3] - Blue channel r^2 coefficient. + float ChromaticAberration[4]; + + float InvK[NumCoefficients]; + float MaxInvR; +}; + + +// For internal use - storing and loading lens config data + +// Returns true on success. +bool LoadLensConfig ( LensConfig *presult, uint8_t const *pbuffer, int bufferSizeInBytes ); + +// Returns number of bytes needed. +int SaveLensConfigSizeInBytes ( LensConfig const &config ); +// Returns true on success. +bool SaveLensConfig ( uint8_t *pbuffer, int bufferSizeInBytes, LensConfig const &config ); + + +//----------------------------------------------------------------------------------- +// ***** DistortionRenderDesc + +// This describes distortion for a single eye in an HMD with a display, not just the lens by itself. +struct DistortionRenderDesc +{ + // The raw lens values. + LensConfig Lens; + + // These map from [-1,1] across the eye being rendered into TanEyeAngle space (but still distorted) + Vector2f LensCenter; + Vector2f TanEyeAngleScale; + // Computed from device characteristics, IPD and eye-relief. + // (not directly used for rendering, but very useful) + Vector2f PixelsPerTanAngleAtCenter; +}; + + +//------------------------------------------------------------------------------------- +// ***** HMDInfo + +// This structure describes various aspects of the HMD allowing us to configure rendering. +// +// Currently included data: +// - Physical screen dimensions, resolution, and eye distances. +// (some of these will be configurable with a tool in the future). +// These arguments allow us to properly setup projection across HMDs. +// - DisplayDeviceName for identifying HMD screen; system-specific interpretation. +// +// TBD: +// - Power on/ off? +// - Sensor rates and capabilities +// - Distortion radius/variables +// - Screen update frequency +// - Distortion needed flag +// - Update modes: +// Set update mode: Stereo (both sides together), mono (same in both eyes), +// Alternating, Alternating scan-lines. + +// Win32 Oculus VR Display Driver Shim Information +struct Win32ShimInfo +{ + int DeviceNumber; + int NativeWidth; + int NativeHeight; + int Rotation; + int UseMirroring; + + Win32ShimInfo() : + DeviceNumber(-1), + NativeWidth(-1), + NativeHeight(-1), + Rotation(-1), + UseMirroring(1) + { + } +}; + +class HMDInfo +{ +public: + // Name string describing the product: "Oculus Rift DK1", etc. + String ProductName; + String Manufacturer; + + unsigned Version; + + // Characteristics of the HMD screen and enclosure + HmdTypeEnum HmdType; + Size ResolutionInPixels; + Size ScreenSizeInMeters; + float ScreenGapSizeInMeters; + float CenterFromTopInMeters; + float LensSeparationInMeters; + Vector2f PelOffsetR; // Offsets from the green pel in pixels (i.e. usual values are 0.5 or 0.333) + Vector2f PelOffsetB; + + + // Timing & shutter data. All values in seconds. + struct ShutterInfo + { + HmdShutterTypeEnum Type; + float VsyncToNextVsync; // 1/framerate + float VsyncToFirstScanline; // for global shutter, vsync->shutter open. + float FirstScanlineToLastScanline; // for global shutter, will be zero. + float PixelSettleTime; // estimated. + float PixelPersistence; // Full persistence = 1/framerate. + } Shutter; + + // Desktop coordinate position of the screen (can be negative; may not be present on all platforms) + int DesktopX; + int DesktopY; + + // Windows: + // "\\\\.\\DISPLAY3", etc. Can be used in EnumDisplaySettings/CreateDC. + String DisplayDeviceName; + Win32ShimInfo ShimInfo; + + // MacOS: + int DisplayId; + + bool InCompatibilityMode; + + // Printed serial number for the HMD; should match external sticker + String PrintedSerial; + + // Tracker descriptor information: + int VendorId; + int ProductId; + int FirmwareMajor; + int FirmwareMinor; + + float CameraFrustumHFovInRadians; + float CameraFrustumVFovInRadians; + float CameraFrustumNearZInMeters; + float CameraFrustumFarZInMeters; + + // Constructor initializes all values to 0s. + // To create a "virtualized" HMDInfo, use CreateDebugHMDInfo instead. + HMDInfo() : + ProductName(), + Manufacturer(), + Version(0), + HmdType(HmdType_None), + ResolutionInPixels(0), + ScreenSizeInMeters(0.0f), + ScreenGapSizeInMeters(0.0f), + CenterFromTopInMeters(0), + LensSeparationInMeters(0), + PelOffsetR(0.0f,0.0f), + PelOffsetB(0.0f,0.0f), + //Shutter (initialized below) + DesktopX(0), + DesktopY(0), + DisplayDeviceName(), + ShimInfo(), + DisplayId(-1), + InCompatibilityMode(false), + PrintedSerial(), + VendorId(-1), + ProductId(-1), + FirmwareMajor(-1), + FirmwareMinor(-1), + CameraFrustumHFovInRadians(0.0f), + CameraFrustumVFovInRadians(0.0f), + CameraFrustumNearZInMeters(0.0f), + CameraFrustumFarZInMeters(0.0f) + { + Shutter.Type = HmdShutter_LAST; + Shutter.VsyncToNextVsync = 0.0f; + Shutter.VsyncToFirstScanline = 0.0f; + Shutter.FirstScanlineToLastScanline = 0.0f; + Shutter.PixelSettleTime = 0.0f; + Shutter.PixelPersistence = 0.0f; + } + + // Operator = copies local fields only (base class must be correct already) + void operator=(const HMDInfo& src) + { + ProductName = src.ProductName; + Manufacturer = src.Manufacturer; + Version = src.Version; + HmdType = src.HmdType; + ResolutionInPixels = src.ResolutionInPixels; + ScreenSizeInMeters = src.ScreenSizeInMeters; + ScreenGapSizeInMeters = src.ScreenGapSizeInMeters; + CenterFromTopInMeters = src.CenterFromTopInMeters; + LensSeparationInMeters = src.LensSeparationInMeters; + PelOffsetR = src.PelOffsetR; + PelOffsetB = src.PelOffsetB; + DesktopX = src.DesktopX; + DesktopY = src.DesktopY; + Shutter = src.Shutter; + DisplayDeviceName = src.DisplayDeviceName; + ShimInfo = src.ShimInfo; + DisplayId = src.DisplayId; + InCompatibilityMode = src.InCompatibilityMode; + VendorId = src.VendorId; + ProductId = src.ProductId; + FirmwareMajor = src.FirmwareMajor; + FirmwareMinor = src.FirmwareMinor; + PrintedSerial = src.PrintedSerial; + CameraFrustumHFovInRadians = src.CameraFrustumHFovInRadians; + CameraFrustumVFovInRadians = src.CameraFrustumVFovInRadians; + CameraFrustumNearZInMeters = src.CameraFrustumNearZInMeters; + CameraFrustumFarZInMeters = src.CameraFrustumFarZInMeters; + } + + void SetScreenParameters(int hres, int vres, + float hsize, float vsize, + float vCenterFromTopInMeters, float lensSeparationInMeters, + bool compatibilityMode) + { + ResolutionInPixels = Sizei(hres, vres); + ScreenSizeInMeters = Sizef(hsize, vsize); + CenterFromTopInMeters = vCenterFromTopInMeters; + LensSeparationInMeters = lensSeparationInMeters; + InCompatibilityMode = compatibilityMode; + } + + bool IsSameDisplay(const HMDInfo& o) const + { + return DisplayId == o.DisplayId && + DisplayDeviceName.CompareNoCase(o.DisplayDeviceName) == 0; + } + + static bool CreateFromSensorAndDisplay(SensorDevice* sensor, Display* display, HMDInfo* hmdi); +}; + + +//----------------------------------------------------------------------------------- +// ***** HmdRenderInfo + +// All the parts of the HMD info that are needed to set up the rendering system. + +struct HmdRenderInfo +{ + // The start of this structure is intentionally very similar to HMDInfo in OVER_Device.h + // However to reduce interdependencies, one does not simply #include the other. + + HmdTypeEnum HmdType; + + // Size of the entire screen + Size ResolutionInPixels; + Size ScreenSizeInMeters; + float ScreenGapSizeInMeters; + Vector2f PelOffsetR; // Offsets from the green pel in pixels (i.e. usual values are 0.5 or 0.333) + Vector2f PelOffsetB; + + // Characteristics of the lenses. + float CenterFromTopInMeters; + float LensSeparationInMeters; + float LensDiameterInMeters; + float LensSurfaceToMidplateInMeters; + EyeCupType EyeCups; + + // Timing & shutter data. All values in seconds. + struct ShutterInfo + { + HmdShutterTypeEnum Type; + float VsyncToNextVsync; // 1/framerate + float VsyncToFirstScanline; // for global shutter, vsync->shutter open. + float FirstScanlineToLastScanline; // for global shutter, will be zero. + float PixelSettleTime; // estimated. + float PixelPersistence; // Full persistence = 1/framerate. + } Shutter; + + + // These are all set from the user's profile. + struct EyeConfig + { + // Distance from center of eyeball to front plane of lens. + float ReliefInMeters; + // Distance from nose (technically, center of Rift) to the middle of the eye. + float NoseToPupilInMeters; + + LensConfig Distortion; + } EyeLeft, EyeRight; + + + HmdRenderInfo() + { + HmdType = HmdType_None; + ResolutionInPixels.w = 0; + ResolutionInPixels.h = 0; + ScreenSizeInMeters.w = 0.0f; + ScreenSizeInMeters.h = 0.0f; + ScreenGapSizeInMeters = 0.0f; + CenterFromTopInMeters = 0.0f; + LensSeparationInMeters = 0.0f; + LensDiameterInMeters = 0.0f; + LensSurfaceToMidplateInMeters = 0.0f; + PelOffsetR = Vector2f ( 0.0f, 0.0f ); + PelOffsetB = Vector2f ( 0.0f, 0.0f ); + Shutter.Type = HmdShutter_LAST; + Shutter.VsyncToNextVsync = 0.0f; + Shutter.VsyncToFirstScanline = 0.0f; + Shutter.FirstScanlineToLastScanline = 0.0f; + Shutter.PixelSettleTime = 0.0f; + Shutter.PixelPersistence = 0.0f; + EyeCups = EyeCup_DK1A; + EyeLeft.ReliefInMeters = 0.0f; + EyeLeft.NoseToPupilInMeters = 0.0f; + EyeLeft.Distortion.SetToIdentity(); + EyeRight = EyeLeft; + } + + // The "center eye" is the position the HMD tracking returns, + // and games will also usually use it for audio, aiming reticles, some line-of-sight tests, etc. + EyeConfig GetEyeCenter() const + { + EyeConfig result; + result.ReliefInMeters = 0.5f * ( EyeLeft.ReliefInMeters + EyeRight.ReliefInMeters ); + result.NoseToPupilInMeters = 0.0f; + result.Distortion.SetToIdentity(); + return result; + } + +}; + + +//----------------------------------------------------------------------------------- + +// Stateless computation functions, in somewhat recommended execution order. +// For examples on how to use many of them, see the StereoConfig::UpdateComputedState function. + +const float OVR_DEFAULT_EXTRA_EYE_ROTATION = 30.0f * MATH_FLOAT_DEGREETORADFACTOR; + +// Creates a dummy debug HMDInfo matching a particular HMD model. +// Useful for development without an actual HMD attached. +HMDInfo CreateDebugHMDInfo(HmdTypeEnum hmdType); + + +// profile may be NULL, in which case it uses the hard-coded defaults. +// distortionType should be left at the default unless you require something specific for your distortion shaders. +// eyeCupOverride can be EyeCup_LAST, in which case it uses the one in the profile. +HmdRenderInfo GenerateHmdRenderInfoFromHmdInfo ( HMDInfo const &hmdInfo, + Profile const *profile = NULL, + DistortionEqnType distortionType = Distortion_CatmullRom10, + EyeCupType eyeCupOverride = EyeCup_LAST ); + +LensConfig GenerateLensConfigFromEyeRelief ( float eyeReliefInMeters, HmdRenderInfo const &hmd, + DistortionEqnType distortionType = Distortion_CatmullRom10 ); + +DistortionRenderDesc CalculateDistortionRenderDesc ( StereoEye eyeType, HmdRenderInfo const &hmd, + LensConfig const *pLensOverride = NULL ); + +FovPort CalculateFovFromEyePosition ( float eyeReliefInMeters, + float offsetToRightInMeters, + float offsetDownwardsInMeters, + float lensDiameterInMeters, + float extraEyeRotationInRadians = OVR_DEFAULT_EXTRA_EYE_ROTATION); + +FovPort CalculateFovFromHmdInfo ( StereoEye eyeType, + DistortionRenderDesc const &distortion, + HmdRenderInfo const &hmd, + float extraEyeRotationInRadians = OVR_DEFAULT_EXTRA_EYE_ROTATION ); + +FovPort GetPhysicalScreenFov ( StereoEye eyeType, DistortionRenderDesc const &distortion ); + +FovPort ClampToPhysicalScreenFov ( StereoEye eyeType, DistortionRenderDesc const &distortion, + FovPort inputFovPort ); + +Sizei CalculateIdealPixelSize ( StereoEye eyeType, DistortionRenderDesc const &distortion, + FovPort fov, float pixelsPerDisplayPixel ); + +Recti GetFramebufferViewport ( StereoEye eyeType, HmdRenderInfo const &hmd ); + +Matrix4f CreateProjection ( bool rightHanded, FovPort fov, + float zNear = 0.01f, float zFar = 10000.0f ); + +Matrix4f CreateOrthoSubProjection ( bool rightHanded, StereoEye eyeType, + float tanHalfFovX, float tanHalfFovY, + float unitsX, float unitsY, float distanceFromCamera, + float interpupillaryDistance, Matrix4f const &projection, + float zNear = 0.0f, float zFar = 0.0f ); + +ScaleAndOffset2D CreateNDCScaleAndOffsetFromFov ( FovPort fov ); + +ScaleAndOffset2D CreateUVScaleAndOffsetfromNDCScaleandOffset ( ScaleAndOffset2D scaleAndOffsetNDC, + Recti renderedViewport, + Sizei renderTargetSize ); + + +//----------------------------------------------------------------------------------- +// ***** StereoEyeParams + +// StereoEyeParams describes RenderDevice configuration needed to render +// the scene for one eye. +struct StereoEyeParams +{ + StereoEye Eye; + Matrix4f HmdToEyeViewOffset; // Translation to be applied to view matrix. + + // Distortion and the VP on the physical display - the thing to run the distortion shader on. + DistortionRenderDesc Distortion; + Recti DistortionViewport; + + // Projection and VP of a particular view (you could have multiple of these). + Recti RenderedViewport; // Viewport that we render the standard scene to. + FovPort Fov; // The FOVs of this scene. + Matrix4f RenderedProjection; // Projection matrix used with this eye. + ScaleAndOffset2D EyeToSourceNDC; // Mapping from TanEyeAngle space to [-1,+1] on the rendered image. + ScaleAndOffset2D EyeToSourceUV; // Mapping from TanEyeAngle space to actual texture UV coords. +}; + + +//----------------------------------------------------------------------------------- +// A set of "forward-mapping" functions, mapping from framebuffer space to real-world and/or texture space. +Vector2f TransformScreenNDCToTanFovSpace ( DistortionRenderDesc const &distortion, + const Vector2f &framebufferNDC ); +void TransformScreenNDCToTanFovSpaceChroma ( Vector2f *resultR, Vector2f *resultG, Vector2f *resultB, + DistortionRenderDesc const &distortion, + const Vector2f &framebufferNDC ); +Vector2f TransformTanFovSpaceToRendertargetTexUV ( ScaleAndOffset2D const &eyeToSourceUV, + Vector2f const &tanEyeAngle ); +Vector2f TransformTanFovSpaceToRendertargetNDC ( ScaleAndOffset2D const &eyeToSourceNDC, + Vector2f const &tanEyeAngle ); +Vector2f TransformScreenPixelToScreenNDC( Recti const &distortionViewport, + Vector2f const &pixel ); +Vector2f TransformScreenPixelToTanFovSpace ( Recti const &distortionViewport, + DistortionRenderDesc const &distortion, + Vector2f const &pixel ); +Vector2f TransformScreenNDCToRendertargetTexUV( DistortionRenderDesc const &distortion, + StereoEyeParams const &eyeParams, + Vector2f const &pixel ); +Vector2f TransformScreenPixelToRendertargetTexUV( Recti const &distortionViewport, + DistortionRenderDesc const &distortion, + StereoEyeParams const &eyeParams, + Vector2f const &pixel ); + +// A set of "reverse-mapping" functions, mapping from real-world and/or texture space back to the framebuffer. +// Be aware that many of these are significantly slower than their forward-mapping counterparts. +Vector2f TransformTanFovSpaceToScreenNDC( DistortionRenderDesc const &distortion, + const Vector2f &tanEyeAngle, bool usePolyApprox = false ); +Vector2f TransformRendertargetNDCToTanFovSpace( const ScaleAndOffset2D &eyeToSourceNDC, + const Vector2f &textureNDC ); + +// Handy wrappers. +inline Vector2f TransformTanFovSpaceToRendertargetTexUV ( StereoEyeParams const &eyeParams, + Vector2f const &tanEyeAngle ) +{ + return TransformTanFovSpaceToRendertargetTexUV ( eyeParams.EyeToSourceUV, tanEyeAngle ); +} +inline Vector2f TransformTanFovSpaceToRendertargetNDC ( StereoEyeParams const &eyeParams, + Vector2f const &tanEyeAngle ) +{ + return TransformTanFovSpaceToRendertargetNDC ( eyeParams.EyeToSourceNDC, tanEyeAngle ); +} + +} //namespace OVR + +#endif // OVR_Stereo_h diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Sensors/OVR_DeviceConstants.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Sensors/OVR_DeviceConstants.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,184 @@ +/************************************************************************************ + +Filename : OVR_DeviceConstants.h +Content : Device constants +Created : February 5, 2013 +Authors : Lee Cooper + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +*************************************************************************************/ + +#ifndef OVR_DeviceConstants_h +#define OVR_DeviceConstants_h + +#include "../Kernel/OVR_Math.h" + +// CAPI forward declarations. +struct ovrSensorData_; +typedef struct ovrSensorData_ ovrSensorData; + +namespace OVR { + + +//------------------------------------------------------------------------------------- +// Different device types supported by OVR; this type is reported by DeviceBase::GetType. +// +enum DeviceType +{ + Device_None, + Device_Manager, + Device_Sensor, + Device_LatencyTester, + Device_BootLoader, + Device_All = 0xFF // Set for enumeration only, to enumerate all device types. +}; + + + +//------------------------------------------------------------------------------------- +// Different lens distortion types supported by devices. +// +enum DistortionEqnType +{ + Distortion_No_Override = -1, + // These two are leagcy and deprecated. + Distortion_Poly4 = 0, // scale = (K0 + K1*r^2 + K2*r^4 + K3*r^6) + Distortion_RecipPoly4 = 1, // scale = 1/(K0 + K1*r^2 + K2*r^4 + K3*r^6) + + // CatmullRom10 is the preferred distortion format. + Distortion_CatmullRom10 = 2, // scale = Catmull-Rom spline through points (1.0, K[1]...K[9]) + + Distortion_LAST // For ease of enumeration. +}; + + +//------------------------------------------------------------------------------------- +// HMD types. +// +enum HmdTypeEnum +{ + HmdType_None, + + HmdType_DKProto, // First duct-tape model, never sold. + HmdType_DK1, // DevKit1 - on sale to developers. + HmdType_DKHDProto, // DKHD - shown at various shows, never sold. + HmdType_DKHD2Proto, // DKHD2, 5.85-inch panel, never sold. + HmdType_DKHDProto566Mi, // DKHD, 5.66-inch panel, never sold. + HmdType_CrystalCoveProto, // Crystal Cove, 5.66-inch panel, shown at shows but never sold. + HmdType_DK2, + + // Reminder - this header file is public - codenames only! + + HmdType_Unknown, // Used for unnamed HW lab experiments. + + HmdType_LAST +}; + + +//------------------------------------------------------------------------------------- +// HMD shutter types. +// +enum HmdShutterTypeEnum +{ + HmdShutter_Global, + HmdShutter_RollingTopToBottom, + HmdShutter_RollingLeftToRight, + HmdShutter_RollingRightToLeft, + // TODO: + // color-sequential e.g. LCOS? + // alternate eyes? + // alternate columns? + // outside-in? + + HmdShutter_LAST +}; + + + +//------------------------------------------------------------------------------------- +// For headsets that use eye cups +// +enum EyeCupType +{ + // Public lenses + EyeCup_DK1A = 0, + EyeCup_DK1B = 1, + EyeCup_DK1C = 2, + + EyeCup_DK2A = 3, + + // Internal R&D codenames. + // Reminder - this header file is public - codenames only! + EyeCup_DKHD2A, + EyeCup_OrangeA, + EyeCup_RedA, + EyeCup_PinkA, + EyeCup_BlueA, + EyeCup_Delilah1A, + EyeCup_Delilah2A, + EyeCup_JamesA, + EyeCup_SunMandalaA, + + EyeCup_LAST +}; + + +//----------------------------------------------------------------------------- +// BodyFrameState +// +#pragma pack(push, 8) + +class SensorDataType +{ +public: + + SensorDataType() : Temperature(0.0f), AbsoluteTimeSeconds(0.0) { } + + // C-interop support + SensorDataType(const ovrSensorData& s); + operator ovrSensorData () const; + + Vector3f Acceleration; // in m/s^2 + Vector3f RotationRate; // in rad/s + Vector3f MagneticField; // in Gauss + + float Temperature; // in degrees Celsius + + // The absolute time from the host computers perspective that the message should be + // interpreted as. This is based on incoming timestamp and processed by a filter + // that syncs the clocks while attempting to keep the distance between messages + // device clock matching. + // + // Integration should use TimeDelta, but prediction into the future should derive + // the delta time from PredictToSeconds - AbsoluteTimeSeconds. + // + // This value will generally be <= the return from a call to ovr_GetTimeInSeconds(), + // but could be greater by under 1 ms due to system time update interrupt delays. + // + double AbsoluteTimeSeconds; +}; + +static_assert((sizeof(SensorDataType) == 3*sizeof(Vector3f) + sizeof(float) + sizeof(double)), "sizeof(SensorDataType) failure"); + +#pragma pack(pop) + + +} // namespace OVR + +#endif diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Service/Service_NetClient.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Service/Service_NetClient.cpp Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,882 @@ +/************************************************************************************ + +Filename : Service_NetClient.cpp +Content : Client for service interface +Created : June 12, 2014 +Authors : Michael Antonov, Kevin Jenkins, Chris Taylor + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#include "Service_NetClient.h" +#include "../Net/OVR_MessageIDTypes.h" + +#if defined (OVR_OS_MAC) || defined(OVR_OS_LINUX) +#define GetCurrentProcessId getpid +#endif +OVR_DEFINE_SINGLETON(OVR::Service::NetClient); + +namespace OVR { namespace Service { + +using namespace OVR::Net; + + +//// NetClient + +NetClient::NetClient() : + LatencyTesterAvailable(false), + HMDCount(0), + EdgeTriggeredHMDCount(false) +{ + GetSession()->AddSessionListener(this); + + // Register RPC functions + registerRPC(); + + Start(); + + // Must be at end of function + PushDestroyCallbacks(); +} + +NetClient::~NetClient() +{ +} + +void NetClient::OnSystemDestroy() +{ + onSystemDestroy(); +} + +void NetClient::OnThreadDestroy() +{ + onThreadDestroy(); +} + +int NetClient::Run() +{ + SetThreadName("NetClient"); + + while (!Terminated) + { + // Note: There is no watchdog here because the watchdog is part of the private code + + GetSession()->Poll(false); + + if (GetSession()->GetActiveSocketsCount() == 0) + { + Thread::MSleep(10); + } + } + + return 0; +} + +void NetClient::OnReceive(ReceivePayload* pPayload, ListenerReceiveResult* lrrOut) +{ + OVR_UNUSED(lrrOut); + OVR_UNUSED(pPayload); +} + +void NetClient::OnDisconnected(Connection* conn) +{ + OVR_UNUSED(conn); + + OVR_DEBUG_LOG(("[NetClient] Disconnected")); + + EdgeTriggeredHMDCount = false; +} + +void NetClient::OnConnected(Connection* conn) +{ + OVR_UNUSED(conn); + + OVR_DEBUG_LOG(("[NetClient] Connected to a server running version %d.%d.%d (my version=%d.%d.%d)", + conn->RemoteMajorVersion, conn->RemoteMinorVersion, conn->RemotePatchVersion, + RPCVersion_Major, RPCVersion_Minor, RPCVersion_Patch)); + + EdgeTriggeredHMDCount = false; +} + +bool NetClient::Connect(bool blocking) +{ + // Set up bind parameters + OVR::Net::BerkleyBindParameters bbp; + bbp.Address = "::1"; // Bind to localhost only! + bbp.blockingTimeout = 5000; + OVR::Net::SockAddr sa; + sa.Set("::1", VRServicePort, SOCK_STREAM); + + // Attempt to connect + OVR::Net::SessionResult result = GetSession()->ConnectPTCP(&bbp, &sa, blocking); + + // Already connected counts as success too + return result == Net::SessionResult_OK || + result == Net::SessionResult_AlreadyConnected || + result == Net::SessionResult_ConnectInProgress; +} + +void NetClient::Disconnect() +{ + GetSession()->Shutdown(); +} + +bool NetClient::IsConnected(bool attemptReconnect, bool blockOnReconnect) +{ + // If it was able to connect, + if (GetSession()->GetConnectionCount() > 0) + { + return true; + } + else if (attemptReconnect) + { + // Attempt to connect here + Connect(blockOnReconnect); + + // If it connected, + if (GetSession()->GetConnectionCount() > 0) + { + return true; + } + } + + // No connections + return false; +} + +void NetClient::GetLocalProtocolVersion(int& major, int& minor, int& patch) +{ + major = RPCVersion_Major; + minor = RPCVersion_Minor; + patch = RPCVersion_Patch; +} + +bool NetClient::GetRemoteProtocolVersion(int& major, int& minor, int& patch) +{ + Ptr conn = GetSession()->GetConnectionAtIndex(0); + + if (conn) + { + major = conn->RemoteMajorVersion; + minor = conn->RemoteMinorVersion; + patch = conn->RemotePatchVersion; + return true; + } + + return false; +} + + +//// NetClient API + +const char* NetClient::GetStringValue(VirtualHmdId hmd, const char* key, const char* default_val) +{ + if (!IsConnected(true, true)) + { + return ""; + } + + // If a null value is provided, + if (!default_val) + { + default_val = ""; + } + + ProfileGetValue1_Str = default_val; + + OVR::Net::BitStream bsOut, returnData; + bsOut.Write(hmd); + bsOut.Write(key); + bsOut.Write(default_val); + if (!GetRPC1()->CallBlocking("GetStringValue_1", &bsOut, GetSession()->GetConnectionAtIndex(0), &returnData)) + { + return ""; + } + if (!returnData.Read(ProfileGetValue1_Str)) + { + OVR_ASSERT(false); + } + return ProfileGetValue1_Str.ToCStr(); +} +bool NetClient::GetBoolValue(VirtualHmdId hmd, const char* key, bool default_val) +{ + if (!IsConnected(true, true)) + { + return default_val; + } + + OVR::Net::BitStream bsOut, returnData; + bsOut.Write(hmd); + bsOut.Write(key); + bsOut.Write(default_val); + if (!GetRPC1()->CallBlocking("GetBoolValue_1", &bsOut, GetSession()->GetConnectionAtIndex(0), &returnData)) + { + return default_val; + } + uint8_t out = 0; + if (!returnData.Read(out)) + { + OVR_ASSERT(false); + } + return out != 0; +} +int NetClient::GetIntValue(VirtualHmdId hmd, const char* key, int default_val) +{ + if (!IsConnected(true, true)) + { + return default_val; + } + + OVR::Net::BitStream bsOut, returnData; + bsOut.Write(hmd); + bsOut.Write(key); + bsOut.Write(default_val); + if (!GetRPC1()->CallBlocking("GetIntValue_1", &bsOut, GetSession()->GetConnectionAtIndex(0), &returnData)) + { + return default_val; + } + int32_t out = (int32_t)default_val; + if (!returnData.Read(out)) + { + OVR_ASSERT(false); + } + return out; +} +double NetClient::GetNumberValue(VirtualHmdId hmd, const char* key, double default_val) +{ + if (!IsConnected(true, true)) + { + return default_val; + } + + OVR::Net::BitStream bsOut, returnData; + bsOut.Write(hmd); + bsOut.Write(key); + bsOut.Write(default_val); + if (!GetRPC1()->CallBlocking("GetNumberValue_1", &bsOut, GetSession()->GetConnectionAtIndex(0), &returnData)) + { + return default_val; + } + double out = 0.; + returnData.Read(out); + return out; +} +int NetClient::GetNumberValues(VirtualHmdId hmd, const char* key, double* values, int num_vals) +{ + if (!IsConnected(true, true)) + { + return 0; + } + + OVR::Net::BitStream bsOut, returnData; + bsOut.Write(hmd); + bsOut.Write(key); + + int32_t w = (int32_t)num_vals; + bsOut.Write(w); + + if (!GetRPC1()->CallBlocking("GetNumberValues_1", &bsOut, GetSession()->GetConnectionAtIndex(0), &returnData)) + { + return 0; + } + + int32_t out = 0; + if (!returnData.Read(out)) + { + OVR_ASSERT(false); + } + OVR_ASSERT(out >= 0 && out <= num_vals); + if (out < 0) + { + out = 0; + } + else if (out > num_vals) + { + out = num_vals; + } + + for (int i = 0; i < out && i < num_vals; i++) + { + if (!returnData.Read(values[i])) + { + return i; + } + } + + return out; +} + +bool NetClient::SetStringValue(VirtualHmdId hmd, const char* key, const char* val) +{ + if (!IsConnected(true, true)) + { + return false; + } + + OVR::Net::BitStream bsOut; + bsOut.Write(hmd); + bsOut.Write(key); + + bsOut.Write(val); + + if (!GetRPC1()->Signal("SetStringValue_1", &bsOut, GetSession()->GetConnectionAtIndex(0))) + { + return false; + } + + return true; +} + +bool NetClient::SetBoolValue(VirtualHmdId hmd, const char* key, bool val) +{ + if (!IsConnected(true, true)) + { + return false; + } + + OVR::Net::BitStream bsOut; + bsOut.Write(hmd); + bsOut.Write(key); + + uint8_t b = val ? 1 : 0; + bsOut.Write(b); + + if (!GetRPC1()->Signal("SetBoolValue_1", &bsOut, GetSession()->GetConnectionAtIndex(0))) + { + return false; + } + + return true; +} + +bool NetClient::SetIntValue(VirtualHmdId hmd, const char* key, int val) +{ + if (!IsConnected(true, true)) + { + return false; + } + + OVR::Net::BitStream bsOut; + bsOut.Write(hmd); + bsOut.Write(key); + + int32_t w = (int32_t)val; + bsOut.Write(w); + + if (!GetRPC1()->Signal("SetIntValue_1", &bsOut, GetSession()->GetConnectionAtIndex(0))) + { + return false; + } + + return true; +} + +bool NetClient::SetNumberValue(VirtualHmdId hmd, const char* key, double val) +{ + if (!IsConnected(true, true)) + { + return false; + } + + OVR::Net::BitStream bsOut; + bsOut.Write(hmd); + bsOut.Write(key); + + bsOut.Write(val); + + if (!GetRPC1()->Signal("SetNumberValue_1", &bsOut, GetSession()->GetConnectionAtIndex(0))) + { + return false; + } + + return true; +} + +bool NetClient::SetNumberValues(VirtualHmdId hmd, const char* key, const double* vals, int num_vals) +{ + if (!IsConnected(true, true)) + { + return false; + } + + OVR::Net::BitStream bsOut; + bsOut.Write(hmd); + bsOut.Write(key); + + int32_t w_count = (int32_t)num_vals; + bsOut.Write(w_count); + + for (int i = 0; i < num_vals; i++) + { + bsOut.Write(vals[i]); + } + + if (!GetRPC1()->Signal("SetNumberValues_1", &bsOut, GetSession()->GetConnectionAtIndex(0))) + { + return false; + } + + return true; +} + +int NetClient::Hmd_Detect() +{ + if (!IsConnected(true, false)) + { + return 0; + } + + // If using edge-triggered HMD counting, + if (EdgeTriggeredHMDCount) + { + // Return the last update from the server + return HMDCount; + } + + // Otherwise: We need to ask the first time + + OVR::Net::BitStream bsOut, returnData; + + if (!GetRPC1()->CallBlocking("Hmd_Detect_1", &bsOut, GetSession()->GetConnectionAtIndex(0), &returnData)) + { + return 0; + } + + int32_t out = 0; + if (!returnData.Read(out)) + { + OVR_ASSERT(false); + } + HMDCount = out; + EdgeTriggeredHMDCount = true; + return out; +} + +bool NetClient::Hmd_Create(int index, HMDNetworkInfo* netInfo) +{ + if (!IsConnected(true, true)) + { + return false; + } + + OVR::Net::BitStream bsOut, returnData; + + int32_t w = (int32_t)index; + bsOut.Write(w); + + // Need the Pid for driver mode + pid_t pid = GetCurrentProcessId(); + bsOut.Write(pid); + + if (!GetRPC1()->CallBlocking("Hmd_Create_1", &bsOut, GetSession()->GetConnectionAtIndex(0), &returnData)) + { + return false; + } + + return netInfo->Deserialize(&returnData); +} + +bool NetClient::GetDriverMode(bool& driverInstalled, bool& compatMode, bool& hideDK1Mode) +{ + if (!IsConnected(true, true)) + { + return false; + } + + OVR::Net::BitStream bsOut, returnData; + + bsOut.Write(InvalidVirtualHmdId); + + if (!GetRPC1()->CallBlocking("GetDriverMode_1", &bsOut, GetSession()->GetConnectionAtIndex(0), &returnData)) + { + return false; + } + + int32_t w_driverInstalled = 0; + int32_t w_compatMode = 0; + int32_t w_hideDK1Mode = 0; + returnData.Read(w_driverInstalled); + returnData.Read(w_compatMode); + if (!returnData.Read(w_hideDK1Mode)) + { + return false; + } + + driverInstalled = w_driverInstalled != 0; + compatMode = w_compatMode != 0; + hideDK1Mode = w_hideDK1Mode != 0; + return true; +} + +bool NetClient::SetDriverMode(bool compatMode, bool hideDK1Mode) +{ + if (!IsConnected(true, true)) + { + return false; + } + + OVR::Net::BitStream bsOut, returnData; + + bsOut.Write(InvalidVirtualHmdId); + + int32_t w_compatMode, w_hideDK1Mode; + w_compatMode = compatMode ? 1 : 0; + w_hideDK1Mode = hideDK1Mode ? 1 : 0; + bsOut.Write(w_compatMode); + bsOut.Write(w_hideDK1Mode); + + if (!GetRPC1()->CallBlocking("SetDriverMode_1", &bsOut, GetSession()->GetConnectionAtIndex(0), &returnData)) + { + return false; + } + + int32_t out = 0; + if (!returnData.Read(out)) + { + OVR_ASSERT(false); + return false; + } + + return out != 0; +} + +bool NetClient::Hmd_AttachToWindow(VirtualHmdId hmd, void* hWindow) +{ + if (!IsConnected(false, false)) + { + return false; + } + + OVR::Net::BitStream bsOut; + bsOut.Write(hmd); + + #ifdef OVR_OS_LINUX + if (hWindow == NULL) + { + return false; + } + unsigned long hWinWord = *(unsigned long *)hWindow; + #else + UInt64 hWinWord = (UPInt)hWindow; + #endif + bsOut.Write(hWinWord); + + if (!GetRPC1()->CallBlocking("Hmd_AttachToWindow_1", &bsOut, GetSession()->GetConnectionAtIndex(0))) + { + return false; + } + + return true; +} + +void NetClient::Hmd_Release(VirtualHmdId hmd) +{ + if (!IsConnected(false, false)) + { + return; + } + + OVR::Net::BitStream bsOut; + bsOut.Write(hmd); + bool result = GetRPC1()->CallBlocking("Hmd_Release_1", &bsOut, GetSession()->GetConnectionAtIndex(0)); + OVR_ASSERT_AND_UNUSED(result, result); +} + +void NetClient::SetLastError(String str) +{ + Hmd_GetLastError_Str = str; +} + +// Last string is cached locally. +const char* NetClient::Hmd_GetLastError(VirtualHmdId hmd) +{ + if (hmd == InvalidVirtualHmdId || !IsConnected(false, false)) + { + return Hmd_GetLastError_Str.ToCStr(); + } + + OVR::Net::BitStream bsOut, returnData; + bsOut.Write(hmd); + if (!GetRPC1()->CallBlocking("Hmd_GetLastError_1", &bsOut, GetSession()->GetConnectionAtIndex(0), &returnData)) + { + return Hmd_GetLastError_Str.ToCStr(); + } + if (!returnData.Read(Hmd_GetLastError_Str)) + { + OVR_ASSERT(false); + } + return Hmd_GetLastError_Str.ToCStr(); +} + + +// Fills in description about HMD; this is the same as filled in by ovrHmd_Create. +// The actual descriptor is a par +bool NetClient::Hmd_GetHmdInfo(VirtualHmdId hmd, HMDInfo* hmdInfo) +{ + if (!IsConnected(false, false)) + { + return false; + } + + OVR::Net::BitStream bsOut, returnData; + bsOut.Write(hmd); + if (!GetRPC1()->CallBlocking("Hmd_GetHmdInfo_1", &bsOut, GetSession()->GetConnectionAtIndex(0), &returnData)) + { + return false; + } + + return NetSessionCommon::DeserializeHMDInfo(&returnData, hmdInfo); +} + + +//------------------------------------------------------------------------------------- +unsigned int NetClient::Hmd_GetEnabledCaps(VirtualHmdId hmd) +{ + if (!IsConnected(false, false)) + { + return 0; + } + + OVR::Net::BitStream bsOut, returnData; + bsOut.Write(hmd); + if (!GetRPC1()->CallBlocking("Hmd_GetEnabledCaps_1", &bsOut, GetSession()->GetConnectionAtIndex(0), &returnData)) + { + return 0; + } + + uint32_t c = 0; + if (!returnData.Read(c)) + { + OVR_ASSERT(false); + } + return c; +} + +// Returns new caps after modification +unsigned int NetClient::Hmd_SetEnabledCaps(VirtualHmdId hmd, unsigned int hmdCaps) +{ + if (!IsConnected(false, false)) + { + return 0; + } + + OVR::Net::BitStream bsOut, returnData; + bsOut.Write(hmd); + + uint32_t c = (uint32_t)hmdCaps; + bsOut.Write(c); + + if (!GetRPC1()->CallBlocking("Hmd_SetEnabledCaps_1", &bsOut, GetSession()->GetConnectionAtIndex(0), &returnData)) + { + return 0; + } + + c = 0; + if (!returnData.Read(c)) + { + OVR_ASSERT(false); + } + return c; +} + + +//------------------------------------------------------------------------------------- +// *** Tracking Setup + +bool NetClient::Hmd_ConfigureTracking(VirtualHmdId hmd, unsigned supportedCaps, unsigned requiredCaps) +{ + if (!IsConnected(false, false)) + { + return false; + } + + OVR::Net::BitStream bsOut, returnData; + bsOut.Write(hmd); + + uint32_t w_sc = supportedCaps; + bsOut.Write(w_sc); + uint32_t w_rc = requiredCaps; + bsOut.Write(w_rc); + + if (!GetRPC1()->CallBlocking("Hmd_ConfigureTracking_1", &bsOut, GetSession()->GetConnectionAtIndex(0), &returnData)) + { + return false; + } + + uint8_t b; + if (!returnData.Read(b)) + { + OVR_ASSERT(false); + } + + return b != 0; +} + + +void NetClient::Hmd_ResetTracking(VirtualHmdId hmd) +{ + if (!IsConnected(false, false)) + { + return; + } + + OVR::Net::BitStream bsOut; + bsOut.Write(hmd); + if (!GetRPC1()->CallBlocking("Hmd_ResetTracking_1", &bsOut, GetSession()->GetConnectionAtIndex(0))) + { + return; + } +} + +bool NetClient::LatencyUtil_ProcessInputs(double startTestSeconds, unsigned char rgbColorOut[3]) +{ + if (!IsConnected(false, false)) + { + return false; + } + + if (!LatencyTesterAvailable) + { + return false; + } + + OVR::Net::BitStream bsOut, returnData; + bsOut.Write(startTestSeconds); + if (!GetRPC1()->CallBlocking("LatencyUtil_ProcessInputs_1", &bsOut, GetSession()->GetConnectionAtIndex(0), &returnData)) + { + return false; + } + + uint8_t u; + returnData.Read(u); + rgbColorOut[0] = u; + returnData.Read(u); + rgbColorOut[1] = u; + if (!returnData.Read(u)) + { + return false; + } + rgbColorOut[2] = u; + + return true; +} + +const char* NetClient::LatencyUtil_GetResultsString() +{ + if (!IsConnected(false, false)) + { + return NULL; + } + + OVR::Net::BitStream bsOut, returnData; + if (!GetRPC1()->CallBlocking("LatencyUtil_GetResultsString_1", &bsOut, GetSession()->GetConnectionAtIndex(0), &returnData)) + { + return NULL; + } + + if (!returnData.Read(LatencyUtil_GetResultsString_Str)) + { + OVR_ASSERT(false); + } + + return LatencyUtil_GetResultsString_Str.ToCStr(); +} + +bool NetClient::ShutdownServer() +{ + if (!IsConnected(false, false)) + { + return false; + } + + OVR::Net::BitStream bsOut; + GetRPC1()->BroadcastSignal("Shutdown_1", &bsOut); + + return true; +} + + +//// Push Notifications: + +void NetClient::registerRPC() +{ +#define RPC_REGISTER_SLOT(observerScope, functionName) \ + observerScope.SetHandler(OVR::Net::Plugins::RPCSlot::FromMember(this)); pRPC->RegisterSlot(OVR_STRINGIZE(functionName), observerScope); + + // Register RPC functions: + RPC_REGISTER_SLOT(InitialServerStateScope, InitialServerState_1); + RPC_REGISTER_SLOT(LatencyTesterAvailableScope, LatencyTesterAvailable_1); + RPC_REGISTER_SLOT(DefaultLogOutputScope, DefaultLogOutput_1); + RPC_REGISTER_SLOT(HMDCountUpdateScope, HMDCountUpdate_1); +} + +void NetClient::InitialServerState_1(BitStream* userData, ReceivePayload* pPayload) +{ + LatencyTesterAvailable_1(userData, pPayload); +} + +void NetClient::LatencyTesterAvailable_1(BitStream* userData, ReceivePayload* pPayload) +{ + OVR_UNUSED(pPayload); + + uint8_t b = 0; + if (!userData->Read(b)) + { + OVR_ASSERT(false); + return; + } + + LatencyTesterAvailable = (b != 0); +} + +void NetClient::DefaultLogOutput_1(BitStream* userData, ReceivePayload* pPayload) +{ + OVR_UNUSED(pPayload); + + String formattedText; + LogMessageType messageType = Log_Text; // Will normally be overwritten below. + userData->Read(messageType); + if (userData->Read(formattedText)) + { + if (OVR::Log::GetGlobalLog()) + { + OVR::String logStr = "[From Service] "; + logStr.AppendString(formattedText); + OVR::Log::GetGlobalLog()->LogMessage(messageType, "%s", logStr.ToCStr()); + } + } +} + +void NetClient::HMDCountUpdate_1(BitStream* userData, ReceivePayload* pPayload) +{ + OVR_UNUSED(pPayload); + + int32_t hmdCount = 0; + if (!userData->Read(hmdCount)) + { + OVR_ASSERT(false); + return; + } + + HMDCount = hmdCount; + EdgeTriggeredHMDCount = true; +} + + +}} // namespace OVR::Service diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Service/Service_NetClient.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Service/Service_NetClient.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,149 @@ +/************************************************************************************ + +Filename : Service_NetClient.h +Content : Client for service interface +Created : June 12, 2014 +Authors : Michael Antonov, Kevin Jenkins, Chris Taylor + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#ifndef OVR_Service_NetClient_h +#define OVR_Service_NetClient_h + +#include "../Net/OVR_NetworkTypes.h" +#include "Service_NetSessionCommon.h" +#include "../Kernel/OVR_System.h" +#include "../OVR_CAPI.h" +#include "../Util/Util_Render_Stereo.h" + +namespace OVR { namespace Service { + +using namespace OVR::Net; + + +//------------------------------------------------------------------------------------- +// NetClient + +class NetClient : public NetSessionCommon, + public Net::Plugins::NetworkPlugin, + public SystemSingletonBase +{ + OVR_DECLARE_SINGLETON(NetClient); + virtual void OnThreadDestroy(); + + // Status + bool LatencyTesterAvailable; + int HMDCount; + bool EdgeTriggeredHMDCount; + + virtual void OnReceive(Net::ReceivePayload* pPayload, Net::ListenerReceiveResult* lrrOut); + virtual void OnDisconnected(Net::Connection* conn); + virtual void OnConnected(Net::Connection* conn); + + virtual int Run(); + +public: + bool Connect(bool blocking); + bool IsConnected(bool attemptReconnect, bool blockOnReconnect); + void Disconnect(); + + void GetLocalProtocolVersion(int& major, int& minor, int& patch); + // This function may fail if it is not connected + bool GetRemoteProtocolVersion(int& major, int& minor, int& patch); + + void SetLastError(String str); + +public: + // Persistent key-value storage + const char* GetStringValue(VirtualHmdId hmd, const char* key, const char* default_val); + bool GetBoolValue(VirtualHmdId hmd, const char* key, bool default_val); + int GetIntValue(VirtualHmdId hmd, const char* key, int default_val); + double GetNumberValue(VirtualHmdId hmd, const char* key, double default_val); + int GetNumberValues(VirtualHmdId hmd, const char* key, double* values, int num_vals); + + bool SetStringValue(VirtualHmdId hmd, const char* key, const char* val); + bool SetBoolValue(VirtualHmdId hmd, const char* key, bool val); + bool SetIntValue(VirtualHmdId hmd, const char* key, int val); + bool SetNumberValue(VirtualHmdId hmd, const char* key, double val); + bool SetNumberValues(VirtualHmdId hmd, const char* key, const double* vals, int num_vals); + + bool GetDriverMode(bool& driverInstalled, bool& compatMode, bool& hideDK1Mode); + bool SetDriverMode(bool compatMode, bool hideDK1Mode); + + int Hmd_Detect(); + bool Hmd_Create(int index, HMDNetworkInfo* netInfo); + void Hmd_Release(VirtualHmdId hmd); + + // Last string is cached locally. + const char* Hmd_GetLastError(VirtualHmdId hmd); + + // TBD: Replace with a function to return internal, original HMDInfo? + + // Fills in description about HMD; this is the same as filled in by ovrHmd_Create. + // The actual descriptor is a par + bool Hmd_GetHmdInfo(VirtualHmdId hmd, HMDInfo* hmdInfo); + + //------------------------------------------------------------------------------------- + unsigned int Hmd_GetEnabledCaps(VirtualHmdId hmd); + // Returns new caps after modification + unsigned int Hmd_SetEnabledCaps(VirtualHmdId hmd, unsigned int hmdCaps); + + // Updates driver render target + bool Hmd_AttachToWindow(VirtualHmdId hmd, void* hWindow); + + //------------------------------------------------------------------------------------- + // *** Tracking Setup + + bool Hmd_ConfigureTracking(VirtualHmdId hmd, unsigned supportedCaps, unsigned requiredCaps); + void Hmd_ResetTracking(VirtualHmdId hmd); + + // TBD: Camera frames + bool LatencyUtil_ProcessInputs(double startTestSeconds, unsigned char rgbColorOut[3]); + const char* LatencyUtil_GetResultsString(); + + bool ShutdownServer(); + +protected: + String Hmd_GetLastError_Str; + String LatencyUtil_GetResultsString_Str; + String ProfileGetValue1_Str, ProfileGetValue3_Str; + +protected: + //// Push Notifications: + + void registerRPC(); + + ObserverScope InitialServerStateScope; + void InitialServerState_1(BitStream* userData, ReceivePayload* pPayload); + + ObserverScope LatencyTesterAvailableScope; + void LatencyTesterAvailable_1(BitStream* userData, ReceivePayload* pPayload); + + ObserverScope DefaultLogOutputScope; + void DefaultLogOutput_1(BitStream* userData, ReceivePayload* pPayload); + + ObserverScope HMDCountUpdateScope; + void HMDCountUpdate_1(BitStream* userData, ReceivePayload* pPayload); +}; + + +}} // namespace OVR::Service + +#endif // OVR_Service_NetClient_h diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Service/Service_NetSessionCommon.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Service/Service_NetSessionCommon.cpp Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,343 @@ +/************************************************************************************ + +Filename : Service_NetSessionCommon.cpp +Content : Server for service interface +Created : June 12, 2014 +Authors : Kevin Jenkins, Chris Taylor + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#include "Service_NetSessionCommon.h" +#include "../OVR_Stereo.h" + +namespace OVR { namespace Service { + + +//// NetSessionCommon + +NetSessionCommon::NetSessionCommon() : + Terminated(false) +{ + pSession = new Net::Session; + OVR_ASSERT(pSession != NULL); + + pRPC = new Net::Plugins::RPC1; + OVR_ASSERT(pRPC != NULL); + + pSession->AddSessionListener(pRPC); +} + +NetSessionCommon::~NetSessionCommon() +{ + if (pSession) + { + delete pSession; + pSession = NULL; + } + if (pRPC) + { + delete pRPC; + pRPC = NULL; + } + + Terminated = true; + + OVR_ASSERT(IsFinished()); +} + +void NetSessionCommon::onSystemDestroy() +{ + Terminated = true; + + Join(); + + Release(); +} + +void NetSessionCommon::onThreadDestroy() +{ + Terminated = true; + if (pSession) + { + pSession->Shutdown(); + } +} + +void NetSessionCommon::SerializeHMDInfo(Net::BitStream *bitStream, HMDInfo* hmdInfo) +{ + bitStream->Write(hmdInfo->ProductName); + bitStream->Write(hmdInfo->Manufacturer); + + int32_t w = hmdInfo->Version; + bitStream->Write(w); + + w = hmdInfo->HmdType; + bitStream->Write(w); + + w = hmdInfo->ResolutionInPixels.w; + bitStream->Write(w); + + w = hmdInfo->ResolutionInPixels.h; + bitStream->Write(w); + + w = hmdInfo->ShimInfo.DeviceNumber; + bitStream->Write(w); + + w = hmdInfo->ShimInfo.NativeWidth; + bitStream->Write(w); + + w = hmdInfo->ShimInfo.NativeHeight; + bitStream->Write(w); + + w = hmdInfo->ShimInfo.Rotation; + bitStream->Write(w); + + bitStream->Write(hmdInfo->ScreenSizeInMeters.w); + bitStream->Write(hmdInfo->ScreenSizeInMeters.h); + bitStream->Write(hmdInfo->ScreenGapSizeInMeters); + bitStream->Write(hmdInfo->CenterFromTopInMeters); + bitStream->Write(hmdInfo->LensSeparationInMeters); + + w = hmdInfo->DesktopX; + bitStream->Write(w); + + w = hmdInfo->DesktopY; + bitStream->Write(w); + + w = hmdInfo->Shutter.Type; + bitStream->Write(w); + + bitStream->Write(hmdInfo->Shutter.VsyncToNextVsync); + bitStream->Write(hmdInfo->Shutter.VsyncToFirstScanline); + bitStream->Write(hmdInfo->Shutter.FirstScanlineToLastScanline); + bitStream->Write(hmdInfo->Shutter.PixelSettleTime); + bitStream->Write(hmdInfo->Shutter.PixelPersistence); + bitStream->Write(hmdInfo->DisplayDeviceName); + + w = hmdInfo->DisplayId; + bitStream->Write(w); + + bitStream->Write(hmdInfo->PrintedSerial); + + uint8_t b = hmdInfo->InCompatibilityMode ? 1 : 0; + bitStream->Write(b); + + w = hmdInfo->VendorId; + bitStream->Write(w); + + w = hmdInfo->ProductId; + bitStream->Write(w); + + bitStream->Write(hmdInfo->CameraFrustumFarZInMeters); + bitStream->Write(hmdInfo->CameraFrustumHFovInRadians); + bitStream->Write(hmdInfo->CameraFrustumNearZInMeters); + bitStream->Write(hmdInfo->CameraFrustumVFovInRadians); + + w = hmdInfo->FirmwareMajor; + bitStream->Write(w); + + w = hmdInfo->FirmwareMinor; + bitStream->Write(w); + + bitStream->Write(hmdInfo->PelOffsetR.x); + bitStream->Write(hmdInfo->PelOffsetR.y); + bitStream->Write(hmdInfo->PelOffsetB.x); + bitStream->Write(hmdInfo->PelOffsetB.y); + + // Important please read before modifying! + // ---------------------------------------------------- + // Please add new serialized data to the end, here. + // Otherwise we will break backwards compatibility + // and e.g. 0.4.4 runtime will not work with 0.4.3 SDK. + + // Please also update the DeserializeHMDInfo() function + // below also and make sure that the members you added + // are initialized properly in the HMDInfo constructor. + + // Note that whenever new fields are added here you + // should also update the minor version of the RPC + // protocol in OVR_Session.h so that clients fail at + // a version check instead of when this data is + // found to be truncated from the server. +} + +bool NetSessionCommon::DeserializeHMDInfo(Net::BitStream *bitStream, HMDInfo* hmdInfo) +{ + bitStream->Read(hmdInfo->ProductName); + bitStream->Read(hmdInfo->Manufacturer); + + int32_t w = 0; + if (!bitStream->Read(w)) + { + // This indicates that no HMD could be found + return false; + } + hmdInfo->Version = w; + + bitStream->Read(w); + hmdInfo->HmdType = (HmdTypeEnum)w; + + bitStream->Read(w); + hmdInfo->ResolutionInPixels.w = w; + + bitStream->Read(w); + hmdInfo->ResolutionInPixels.h = w; + + bitStream->Read(w); + hmdInfo->ShimInfo.DeviceNumber = w; + + bitStream->Read(w); + hmdInfo->ShimInfo.NativeWidth = w; + + bitStream->Read(w); + hmdInfo->ShimInfo.NativeHeight = w; + + bitStream->Read(w); + hmdInfo->ShimInfo.Rotation = w; + + bitStream->Read(hmdInfo->ScreenSizeInMeters.w); + bitStream->Read(hmdInfo->ScreenSizeInMeters.h); + bitStream->Read(hmdInfo->ScreenGapSizeInMeters); + bitStream->Read(hmdInfo->CenterFromTopInMeters); + bitStream->Read(hmdInfo->LensSeparationInMeters); + + bitStream->Read(w); + hmdInfo->DesktopX = w; + + bitStream->Read(w); + hmdInfo->DesktopY = w; + + bitStream->Read(w); + hmdInfo->Shutter.Type = (HmdShutterTypeEnum)w; + + bitStream->Read(hmdInfo->Shutter.VsyncToNextVsync); + bitStream->Read(hmdInfo->Shutter.VsyncToFirstScanline); + bitStream->Read(hmdInfo->Shutter.FirstScanlineToLastScanline); + bitStream->Read(hmdInfo->Shutter.PixelSettleTime); + bitStream->Read(hmdInfo->Shutter.PixelPersistence); + bitStream->Read(hmdInfo->DisplayDeviceName); + + bitStream->Read(w); + hmdInfo->DisplayId = w; + + bitStream->Read(hmdInfo->PrintedSerial); + + uint8_t b = 0; + bitStream->Read(b); + hmdInfo->InCompatibilityMode = (b != 0); + + bitStream->Read(w); + hmdInfo->VendorId = w; + + bitStream->Read(w); + hmdInfo->ProductId = w; + + bitStream->Read(hmdInfo->CameraFrustumFarZInMeters); + bitStream->Read(hmdInfo->CameraFrustumHFovInRadians); + bitStream->Read(hmdInfo->CameraFrustumNearZInMeters); + bitStream->Read(hmdInfo->CameraFrustumVFovInRadians); + + bitStream->Read(w); + hmdInfo->FirmwareMajor = w; + + if (!bitStream->Read(w)) + { + OVR_ASSERT(false); + return false; + } + hmdInfo->FirmwareMinor = w; + + bitStream->Read(hmdInfo->PelOffsetR.x); + bitStream->Read(hmdInfo->PelOffsetR.y); + bitStream->Read(hmdInfo->PelOffsetB.x); + if (!bitStream->Read(hmdInfo->PelOffsetB.y)) + { + OVR_ASSERT(false); + return false; + } + + // Important please read before modifying! + // ---------------------------------------------------- + // Please add new serialized data to the end, here. + // Otherwise we will break backwards compatibility + // and e.g. 0.4.4 runtime will not work with 0.4.3 SDK. + + // Be sure to check that the very last one read properly + // since HMD Info truncation should be caught here. + + return true; +} + +// Prefix key names with this to pass through to server +static const char* BypassPrefix = "server:"; + +static const char* KeyNames[][NetSessionCommon::ENumTypes] = { + /* EGetStringValue */ { "CameraSerial", "CameraUUID", 0 }, + /* EGetBoolValue */ { "ReleaseDK2Sensors", "ReleaseLegacySensors", 0 }, + /* EGetIntValue */ { 0 }, + /* EGetNumberValue */{ "CenterPupilDepth", "LoggingMask", 0 }, + /* EGetNumberValues */{ "NeckModelVector3f", 0 }, + /* ESetStringValue */ { 0 }, + /* ESetBoolValue */ { "ReleaseDK2Sensors", "ReleaseLegacySensors", 0 }, + /* ESetIntValue */ { 0 }, + /* ESetNumberValue */{ "CenterPupilDepth", "LoggingMask", 0 }, + /* ESetNumberValues */{ "NeckModelVector3f", 0 }, +}; + +bool IsInStringArray(const char* a[], const char* key) +{ + for (int i = 0; a[i]; ++i) + { + if (OVR_strcmp(a[i], key) == 0) + return true; + } + + return false; +} + +const char *NetSessionCommon::FilterKeyPrefix(const char* key) +{ + // If key starts with BypassPrefix, + if (strstr(key, BypassPrefix) == key) + { + key += strlen(BypassPrefix); + } + + return key; +} + +bool NetSessionCommon::IsServiceProperty(EGetterSetters e, const char* key) +{ + if ((e >= 0 && e < ENumTypes) && IsInStringArray(KeyNames[e], key)) + { + return true; + } + + // If key starts with BypassPrefix, + if (strstr(key, BypassPrefix) == key) + { + return true; + } + + return false; +} + + +}} // namespace OVR::Service diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Service/Service_NetSessionCommon.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Service/Service_NetSessionCommon.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,142 @@ +/************************************************************************************ + +Filename : Service_NetSessionCommon.h +Content : Shared networking for service +Created : June 12, 2014 +Authors : Kevin Jenkins, Chris Taylor + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#ifndef OVR_Service_NetSessionCommon_h +#define OVR_Service_NetSessionCommon_h + +#include "../OVR_CAPI.h" +#include "../Net/OVR_RPC1.h" +#include "../Kernel/OVR_Threads.h" +#include "../Net/OVR_BitStream.h" +#include "../Kernel/OVR_System.h" + +namespace OVR { + +class HMDInfo; + +namespace Service { + + +//----------------------------------------------------------------------------- +// VirtualHmdId + +// This is an identifier that is unique to each VirtualHmd object on the server +// side. The client side uses this to opaquely reference those objects. + +typedef int32_t VirtualHmdId; +static const int32_t InvalidVirtualHmdId = -1; + +// Localhost-bound TCP port that the service listens on for VR apps +static const int VRServicePort = 30322; // 0x7672 = "vr" little-endian + +// HMDInfo section related to networking +struct HMDNetworkInfo +{ + HMDNetworkInfo() : + NetId(InvalidVirtualHmdId) + { + } + + // Network identifier for HMD + VirtualHmdId NetId; + + // Name of the shared memory object + String SharedMemoryName; + + void Serialize(Net::BitStream* bs) + { + bs->Write(NetId); + bs->Write(SharedMemoryName); + } + bool Deserialize(Net::BitStream* bs) + { + bs->Read(NetId); + return bs->Read(SharedMemoryName); + } +}; + + +//------------------------------------------------------------------------------------- +// ***** NetSessionCommon + +// Common part networking session/RPC implementation shared between client and server. + +class NetSessionCommon : public Thread +{ +protected: + virtual void onSystemDestroy(); + virtual void onThreadDestroy(); + +public: + NetSessionCommon(); + virtual ~NetSessionCommon(); + + Net::Plugins::RPC1* GetRPC1() const + { + return pRPC; + } + Net::Session* GetSession() const + { + return pSession; + } + + static void SerializeHMDInfo(Net::BitStream* bitStream, HMDInfo* hmdInfo); + static bool DeserializeHMDInfo(Net::BitStream* bitStream, HMDInfo* hmdInfo); + +public: + // Getter/setter tools + enum EGetterSetters + { + // Note: If this enumeration changes, then the Servce_NetSessionCommon.cpp + // IsServiceProperty() function should be updated. + + EGetStringValue, + EGetBoolValue, + EGetIntValue, + EGetNumberValue, + EGetNumberValues, + ESetStringValue, + ESetBoolValue, + ESetIntValue, + ESetNumberValue, + ESetNumberValues, + + ENumTypes + }; + + static const char* FilterKeyPrefix(const char* key); + static bool IsServiceProperty(EGetterSetters e, const char* key); + +protected: + bool Terminated; // Thread termination flag + Net::Session* pSession; // Networking session + Net::Plugins::RPC1* pRPC; // Remote procedure calls object +}; + + +}} // namespace OVR::Service + +#endif // OVR_Service_NetSessionCommon_h diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Tracking/Tracking_PoseState.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Tracking/Tracking_PoseState.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,133 @@ +/************************************************************************************ + +Filename : Tracking_PoseState.h +Content : Describes the complete pose at a point in time, including derivatives +Created : May 13, 2014 +Authors : Dov Katz + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +*************************************************************************************/ + +#ifndef Tracking_PoseState_h +#define Tracking_PoseState_h + +#include "../Kernel/OVR_Math.h" + +namespace OVR { + +// PoseState describes the complete pose, or a rigid body configuration, at a +// point in time, including first and second derivatives. It is used to specify +// instantaneous location and movement of the headset. +// SensorState is returned as a part of the sensor state. + +template +class PoseState +{ +public: + typedef typename CompatibleTypes >::Type CompatibleType; + + PoseState() : TimeInSeconds(0.0) { } + PoseState(Pose pose, double time) : ThePose(pose), TimeInSeconds(time) { } + + // float <-> double conversion constructor. + explicit PoseState(const PoseState::OtherFloatType> &src) + : ThePose(src.ThePose), + AngularVelocity(src.AngularVelocity), LinearVelocity(src.LinearVelocity), + AngularAcceleration(src.AngularAcceleration), LinearAcceleration(src.LinearAcceleration), + TimeInSeconds(src.TimeInSeconds) + { } + + // C-interop support: PoseStatef <-> ovrPoseStatef + PoseState(const typename CompatibleTypes >::Type& src) + : ThePose(src.ThePose), + AngularVelocity(src.AngularVelocity), LinearVelocity(src.LinearVelocity), + AngularAcceleration(src.AngularAcceleration), LinearAcceleration(src.LinearAcceleration), + TimeInSeconds(src.TimeInSeconds) + { } + + operator typename CompatibleTypes >::Type() const + { + typename CompatibleTypes >::Type result; + result.ThePose = ThePose; + result.AngularVelocity = AngularVelocity; + result.LinearVelocity = LinearVelocity; + result.AngularAcceleration = AngularAcceleration; + result.LinearAcceleration = LinearAcceleration; + result.TimeInSeconds = TimeInSeconds; + return result; + } + + Pose ThePose; + Vector3 AngularVelocity; + Vector3 LinearVelocity; + Vector3 AngularAcceleration; + Vector3 LinearAcceleration; + // Absolute time of this state sample; always a double measured in seconds. + double TimeInSeconds; + + // ***** Helpers for Pose integration + + // Stores and integrates gyro angular velocity reading for a given time step. + void StoreAndIntegrateGyro(Vector3d angVel, double dt); + // Stores and integrates position/velocity from accelerometer reading for a given time step. + void StoreAndIntegrateAccelerometer(Vector3d linearAccel, double dt); + + // Performs integration of state by adding next state delta to it + // to produce a combined state change + void AdvanceByDelta(const PoseState& delta); +}; + + +template +PoseState operator*(const OVR::Pose& trans, const PoseState& poseState) +{ + PoseState result; + result.ThePose = trans * poseState.ThePose; + result.LinearVelocity = trans.Rotate(poseState.LinearVelocity); + result.LinearAcceleration = trans.Rotate(poseState.LinearAcceleration); + result.AngularVelocity = trans.Rotate(poseState.AngularVelocity); + result.AngularAcceleration = trans.Rotate(poseState.AngularAcceleration); + return result; +} + + +// External API returns pose as float, but uses doubles internally for quaternion precision. +typedef PoseState PoseStatef; +typedef PoseState PoseStated; + + +} // namespace OVR::Vision + + +namespace OVR { + + template<> struct CompatibleTypes > { typedef ovrPoseStatef Type; }; + template<> struct CompatibleTypes > { typedef ovrPoseStated Type; }; + + static_assert((sizeof(PoseState) == sizeof(Pose) + 4*sizeof(Vector3) + sizeof(double)), "sizeof(PoseState) failure"); +#ifdef OVR_CPU_X86_64 + static_assert((sizeof(PoseState) == sizeof(Pose) + 4*sizeof(Vector3) + sizeof(uint32_t) + sizeof(double)), "sizeof(PoseState) failure"); //TODO: Manually pad template. +#elif defined(OVR_OS_WIN32) // The Windows 32 bit ABI aligns 64 bit values on 64 bit boundaries + static_assert((sizeof(PoseState) == sizeof(Pose) + 4*sizeof(Vector3) + sizeof(uint32_t) + sizeof(double)), "sizeof(PoseState) failure"); +#else // Else Unix/Apple 32 bit ABI, which aligns 64 bit values on 32 bit boundaries. + static_assert((sizeof(PoseState) == sizeof(Pose) + 4*sizeof(Vector3) + sizeof(double)), "sizeof(PoseState) failure"); +#endif +} + +#endif // Tracking_PoseState_h diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Tracking/Tracking_SensorState.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Tracking/Tracking_SensorState.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,212 @@ +/************************************************************************************ + +Filename : Tracking_SensorState.h +Content : Sensor state information shared by tracking system with games +Created : May 13, 2014 +Authors : Dov Katz, Chris Taylor + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +*************************************************************************************/ + +#ifndef Tracking_SensorState_h +#define Tracking_SensorState_h + +#include "Tracking_PoseState.h" +#include "../Kernel/OVR_SharedMemory.h" +#include "../Kernel/OVR_Lockless.h" +#include "../Kernel/OVR_String.h" +#include "../Util/Util_LatencyTest2State.h" +#include "../Sensors/OVR_DeviceConstants.h" + +// CAPI forward declarations. +struct ovrTrackingState_; +typedef struct ovrTrackingState_ ovrTrackingState; +struct ovrPoseStatef_; +typedef struct ovrPoseStatef_ ovrPoseStatef; + +namespace OVR { namespace Tracking { + + +//------------------------------------------------------------------------------------- +// ***** Sensor State +// These values are reported as compatible with C API. + +// Bit flags describing the current status of sensor tracking. +enum StatusBits +{ + // Tracked bits: Toggled by SensorFusion + Status_OrientationTracked = 0x0001, // Orientation is currently tracked (connected and in use) + Status_PositionTracked = 0x0002, // Position is currently tracked (false if out of range) + Status_CameraPoseTracked = 0x0004, // Camera pose is currently tracked + + // Connected bits: Toggled by TrackingManager + Status_PositionConnected = 0x0020, // Position tracking HW is connected + Status_HMDConnected = 0x0080, // HMD is available & connected + + // Masks + Status_AllMask = 0xffff, + Status_TrackingMask = Status_PositionTracked | Status_OrientationTracked | Status_CameraPoseTracked, + Status_ConnectedMask = Status_PositionConnected | Status_HMDConnected, +}; + + +// Full state of of the sensor reported by GetSensorState() at a given absolute time. +class TrackingState +{ +public: + TrackingState() : HeadPose(), CameraPose(), LeveledCameraPose(), RawSensorData(), StatusFlags(0), LastVisionProcessingTime(0.0) { } + + // C-interop support + TrackingState(const ovrTrackingState& s); + operator ovrTrackingState () const; + + // HMD pose information for the requested time. + PoseStatef HeadPose; + + // Orientation and position of the external camera, if present. + Posef CameraPose; + // Orientation and position of the camera after alignment with gravity + Posef LeveledCameraPose; + + // Most recent sensor data received from the HMD + SensorDataType RawSensorData; + + // Sensor status described by ovrStatusBits. + uint32_t StatusFlags; + + //// 0.4.1 + + // Measures the time from receiving the camera frame until vision CPU processing completes. + double LastVisionProcessingTime; + + //// 0.4.3 + + // Measures the time from exposure until the pose is available for the frame, including processing time. + double LastVisionFrameLatency; + + // Tag the vision processing results to a certain frame counter number. + uint32_t LastCameraFrameCounter; +}; + + +// ----------------------------------------------- + +#pragma pack(push, 8) + +struct LocklessSensorStatePadding; + +// State version stored in lockless updater "queue" and used for +// prediction by GetPoseAtTime/GetSensorStateAtTime +struct LocklessSensorState +{ + PoseState WorldFromImu; + SensorDataType RawSensorData; + Pose WorldFromCamera; + uint32_t StatusFlags; + uint32_t _PAD_0_; + + // ImuFromCpf for HMD pose tracking + Posed ImuFromCpf; + + // Performance logging + double LastVisionProcessingTime; + double LastVisionFrameLatency; + uint32_t LastCameraFrameCounter; + uint32_t _PAD_1_; + + // Initialized to invalid state + LocklessSensorState() : + WorldFromImu() + , RawSensorData() + , WorldFromCamera() + , StatusFlags(0) + , _PAD_0_(0) // This assignment should be irrelevant, but it quells static/runtime analysis complaints. + , ImuFromCpf() + , LastVisionProcessingTime(0.0) + , LastVisionFrameLatency(0.0) + , LastCameraFrameCounter(0) + , _PAD_1_(0) // " + { + } + + LocklessSensorState& operator = (const LocklessSensorStatePadding& rhs); +}; + +static_assert((sizeof(LocklessSensorState) == sizeof(PoseState) + sizeof(SensorDataType) + sizeof(Pose) + 2*sizeof(uint32_t) + sizeof(Posed) + sizeof(double)*2 + sizeof(uint32_t)*2), "sizeof(LocklessSensorState) failure"); + +// Padded out version stored in the updater slots +// Designed to be a larger fixed size to allow the data to grow in the future +// without breaking older compiled code. +struct LocklessSensorStatePadding +{ + uint64_t words[64]; + + static const int DataWords = (sizeof(LocklessSensorState) + sizeof(uint64_t) - 1) / sizeof(uint64_t); + + // Just copy the low data words + inline LocklessSensorStatePadding& operator=(const LocklessSensorState& rhs) + { + const uint64_t* src = (const uint64_t*)&rhs; + + // if this fires off, then increase words' array size + OVR_ASSERT(sizeof(words) > sizeof(LocklessSensorState)); + + for (int i = 0; i < DataWords; ++i) + { + words[i] = src[i]; + } + + return *this; + } +}; + +// Just copy the low data words +inline LocklessSensorState& LocklessSensorState::operator = (const LocklessSensorStatePadding& rhs) +{ + uint64_t* dest = (uint64_t*)this; + + for (int i = 0; i < LocklessSensorStatePadding::DataWords; ++i) + { + dest[i] = rhs.words[i]; + } + + return *this; +} + +#pragma pack(pop) + +// A lockless updater for sensor state +typedef LocklessUpdater SensorStateUpdater; + + +//// Combined state + +struct CombinedSharedStateUpdater +{ + SensorStateUpdater SharedSensorState; + Util::LockessRecordUpdater SharedLatencyTestState; +}; + +typedef SharedObjectWriter< CombinedSharedStateUpdater > CombinedSharedStateWriter; +typedef SharedObjectReader< CombinedSharedStateUpdater > CombinedSharedStateReader; + + +}} // namespace OVR::Tracking + +#endif diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Tracking/Tracking_SensorStateReader.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Tracking/Tracking_SensorStateReader.cpp Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,207 @@ +/************************************************************************************ + +Filename : Tracking_SensorStateReader.cpp +Content : Separate reader component that is able to recover sensor pose +Created : June 4, 2014 +Authors : Chris Taylor + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +*************************************************************************************/ + +#include "Tracking_SensorStateReader.h" +#include "Tracking_PoseState.h" + +namespace OVR { namespace Tracking { + + +//------------------------------------------------------------------------------------- + +// This is a "perceptually tuned predictive filter", which means that it is optimized +// for improvements in the VR experience, rather than pure error. In particular, +// jitter is more perceptible at lower speeds whereas latency is more perceptible +// after a high-speed motion. Therefore, the prediction interval is dynamically +// adjusted based on speed. Significant more research is needed to further improve +// this family of filters. +static Pose calcPredictedPose(const PoseState& poseState, double predictionDt) +{ + Pose pose = poseState.ThePose; + const double linearCoef = 1.0; + Vector3d angularVelocity = poseState.AngularVelocity; + double angularSpeed = angularVelocity.Length(); + + // This could be tuned so that linear and angular are combined with different coefficients + double speed = angularSpeed + linearCoef * poseState.LinearVelocity.Length(); + + const double slope = 0.2; // The rate at which the dynamic prediction interval varies + double candidateDt = slope * speed; // TODO: Replace with smoothstep function + + double dynamicDt = predictionDt; + + // Choose the candidate if it is shorter, to improve stability + if (candidateDt < predictionDt) + { + dynamicDt = candidateDt; + } + + if (angularSpeed > 0.001) + { + pose.Rotation = pose.Rotation * Quatd(angularVelocity, angularSpeed * dynamicDt); + } + + pose.Translation += poseState.LinearVelocity * dynamicDt; + + return pose; +} + + +//// SensorStateReader + +SensorStateReader::SensorStateReader() : + Updater(NULL), + LastLatWarnTime(0.) +{ +} + +void SensorStateReader::SetUpdater(const CombinedSharedStateUpdater* updater) +{ + Updater = updater; +} + +void SensorStateReader::RecenterPose() +{ + if (!Updater) + { + return; + } + + /* + This resets position to center in x, y, z, and resets yaw to center. + Other rotation components are not affected. + */ + + const LocklessSensorState lstate = Updater->SharedSensorState.GetState(); + + Posed worldFromCpf = lstate.WorldFromImu.ThePose * lstate.ImuFromCpf; + double hmdYaw, hmdPitch, hmdRoll; + worldFromCpf.Rotation.GetEulerAngles(&hmdYaw, &hmdPitch, &hmdRoll); + + Posed worldFromCentered(Quatd(Axis_Y, hmdYaw), worldFromCpf.Translation); + + CenteredFromWorld = worldFromCentered.Inverted(); +} + +bool SensorStateReader::GetSensorStateAtTime(double absoluteTime, TrackingState& ss) const +{ + if (!Updater) + { + ss.StatusFlags = 0; + return false; + } + + const LocklessSensorState lstate = Updater->SharedSensorState.GetState(); + + // Update time + ss.HeadPose.TimeInSeconds = absoluteTime; + + // Update the status flags + ss.StatusFlags = lstate.StatusFlags; + // If no hardware is connected, override the tracking flags + if (0 == (ss.StatusFlags & Status_HMDConnected)) + { + ss.StatusFlags &= ~Status_TrackingMask; + } + if (0 == (ss.StatusFlags & Status_PositionConnected)) + { + ss.StatusFlags &= ~(Status_PositionTracked | Status_CameraPoseTracked); + } + + // If tracking info is invalid, + if (0 == (ss.StatusFlags & Status_TrackingMask)) + { + return false; + } + + // Delta time from the last available data + double pdt = absoluteTime - lstate.WorldFromImu.TimeInSeconds; + static const double maxPdt = 0.1; + + // If delta went negative due to synchronization problems between processes or just a lag spike, + if (pdt < 0.) + { + pdt = 0.; + } + else if (pdt > maxPdt) + { + if (LastLatWarnTime != lstate.WorldFromImu.TimeInSeconds) + { + LastLatWarnTime = lstate.WorldFromImu.TimeInSeconds; + LogText("[SensorStateReader] Prediction interval too high: %f s, clamping at %f s\n", pdt, maxPdt); + } + pdt = maxPdt; + } + + ss.HeadPose = PoseStatef(lstate.WorldFromImu); + // Do prediction logic and ImuFromCpf transformation + ss.HeadPose.ThePose = Posef(CenteredFromWorld * calcPredictedPose(lstate.WorldFromImu, pdt) * lstate.ImuFromCpf); + + ss.CameraPose = Posef(CenteredFromWorld * lstate.WorldFromCamera); + + Posed worldFromLeveledCamera = Posed(Quatd(), lstate.WorldFromCamera.Translation); + ss.LeveledCameraPose = Posef(CenteredFromWorld * worldFromLeveledCamera); + + ss.RawSensorData = lstate.RawSensorData; + ss.LastVisionProcessingTime = lstate.LastVisionProcessingTime; + ss.LastVisionFrameLatency = lstate.LastVisionFrameLatency; + + return true; +} + +bool SensorStateReader::GetPoseAtTime(double absoluteTime, Posef& transform) const +{ + TrackingState ss; + if (!GetSensorStateAtTime(absoluteTime, ss)) + { + return false; + } + + transform = ss.HeadPose.ThePose; + + return true; +} + +uint32_t SensorStateReader::GetStatus() const +{ + if (!Updater) + { + return 0; + } + + const LocklessSensorState lstate = Updater->SharedSensorState.GetState(); + + // If invalid, + if (0 == (lstate.StatusFlags & Status_TrackingMask)) + { + // Return 0 indicating no orientation nor position tracking + return 0; + } + + return lstate.StatusFlags; +} + +}} // namespace OVR::Tracking diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Tracking/Tracking_SensorStateReader.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Tracking/Tracking_SensorStateReader.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,87 @@ +/************************************************************************************ + +Filename : Tracking_SensorStateReader.h +Content : Separate reader component that is able to recover sensor pose +Created : June 4, 2014 +Authors : Chris Taylor + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +*************************************************************************************/ + +#ifndef Tracking_SensorStateReader_h +#define Tracking_SensorStateReader_h + +#include "../Kernel/OVR_Lockless.h" +#include "Tracking_SensorState.h" + +#include "../OVR_Profile.h" + +namespace OVR { namespace Tracking { + + +//----------------------------------------------------------------------------- +// SensorStateReader + +// User interface to retrieve pose from the sensor fusion subsystem +class SensorStateReader : public NewOverrideBase +{ +protected: + const CombinedSharedStateUpdater *Updater; + + + // Last latency warning time + mutable double LastLatWarnTime; + + // Transform from real-world coordinates to centered coordinates + Posed CenteredFromWorld; + +public: + SensorStateReader(); + + // Initialize the updater + void SetUpdater(const CombinedSharedStateUpdater *updater); + + // Re-centers on the current yaw (optionally pitch) and translation + void RecenterPose(); + + // Get the full dynamical system state of the CPF, which includes velocities and accelerations, + // predicted at a specified absolute point in time. + bool GetSensorStateAtTime(double absoluteTime, Tracking::TrackingState& state) const; + + // Get the predicted pose (orientation, position) of the center pupil frame (CPF) at a specific point in time. + bool GetPoseAtTime(double absoluteTime, Posef& transform) const; + + // Get the sensor status (same as GetSensorStateAtTime(...).Status) + uint32_t GetStatus() const; + + const Posed getCenteredFromWorld() + { + return CenteredFromWorld; + } + + void setCenteredFromWorld(const Posed _CenteredFromWorld) + { + CenteredFromWorld = _CenteredFromWorld; + } +}; + + +}} // namespace OVR::Tracking + +#endif // Tracking_SensorStateReader_h diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Util/GUIConsole.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Util/GUIConsole.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,51 @@ +/************************************************************************************ + +Filename : GUIConsole.h +Content : A stdout console window that runs alongside Windows GUI applications +Created : Feb 4, 2013 +Authors : Brant Lewis + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +*************************************************************************************/ + +#ifndef GUICONSOLE_H +#define GUICONSOLE_H + +#include "../../Include/OVR_Kernel.h" + +#ifdef OVR_INTERNAL_USE + +#include +#include +#define WIN32_LEAN_AND_MEAN +#include + +class GUIConsole +{ +public: + // constructors + GUIConsole(); + ~GUIConsole(); + + // member variables + HANDLE hStdIn, hStdOut, hStdError; +}; +#endif // #ifdef OVR_INTERNAL_USE + +#endif diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Util/Util_ImageWindow.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Util/Util_ImageWindow.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,204 @@ +/************************************************************************************ + +Filename : Util_ImageWindow.h +Content : An output object for windows that can display raw images for testing +Created : March 13, 2014 +Authors : Dean Beeler + +Copyright : Copyright 2014 Oculus, Inc. All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +*************************************************************************************/ + +#ifndef UTIL_IMAGEWINDOW_H +#define UTIL_IMAGEWINDOW_H + +#if defined(OVR_OS_WIN32) +#include +#include +#define WIN32_LEAN_AND_MEAN +#include +#include +#include +#endif + +#include "../Kernel/OVR_Hash.h" +#include "../Kernel/OVR_Array.h" +#include "../Kernel/OVR_Threads.h" +#include "../Kernel/OVR_Deque.h" + +#include + +namespace OVR { namespace Util { + + typedef struct + { + float x; + float y; + float radius; + float r; + float g; + float b; + bool fill; + } CirclePlot; + + typedef struct + { + float x; + float y; + float r; + float g; + float b; + OVR::String text; + } TextPlot; + +class Frame : virtual public RefCountBaseV + { +public: + + Frame( int frame ) : + frameNumber( frame ), + imageData( NULL ), + colorImageData( NULL ), + plots(), + textLines(), + width( 0 ), + height( 0 ), + colorPitch( 0 ), + ready( false ) + { + + } + + ~Frame() + { + if( imageData ) + free( imageData ); + if( colorImageData ) + free( colorImageData ); + + plots.ClearAndRelease(); + textLines.ClearAndRelease(); + } + + int frameNumber; + + Array plots; + Array textLines; + void* imageData; + void* colorImageData; + int width; + int height; + int colorPitch; + bool ready; +}; + +#if defined(OVR_OS_WIN32) +class ImageWindow +{ + HWND hWindow; + ID2D1RenderTarget* pRT; + D2D1_SIZE_U resolution; + + Mutex* frontBufferMutex; + + InPlaceMutableDeque< Ptr > frames; + + ID2D1Bitmap* greyBitmap; + ID2D1Bitmap* colorBitmap; + +public: + // constructors + ImageWindow(); + ImageWindow( uint32_t width, uint32_t height ); + virtual ~ImageWindow(); + + void GetResolution( size_t& width, size_t& height ) { width = resolution.width; height = resolution.height; } + + void OnPaint(); // Called by Windows when it receives a WM_PAINT message + + void UpdateImage( const uint8_t* imageData, uint32_t width, uint32_t height ) { UpdateImageBW( imageData, width, height ); } + void UpdateImageBW( const uint8_t* imageData, uint32_t width, uint32_t height ); + void UpdateImageRGBA( const uint8_t* imageData, uint32_t width, uint32_t height, uint32_t pitch ); + void Complete(); // Called by drawing thread to submit a frame + + void Process(); // Called by rendering thread to do window processing + + void AssociateSurface( void* surface ); + + void addCircle( float x , float y, float radius, float r, float g, float b, bool fill ); + void addText( float x, float y, float r, float g, float b, OVR::String text ); + + static ImageWindow* GlobalWindow( int window ) { return globalWindow[window]; } + static int WindowCount() { return windowCount; } + +private: + + Ptr lastUnreadyFrame(); + + static const int MaxWindows = 4; + static ImageWindow* globalWindow[MaxWindows]; + static int windowCount; + static ID2D1Factory* pD2DFactory; + static IDWriteFactory* pDWriteFactory; + static HINSTANCE hInstD2d1; + static HINSTANCE hInstDwrite; + +}; + +#else + +class ImageWindow +{ +public: + // constructors + ImageWindow() {} + ImageWindow( uint32_t width, uint32_t height ) { OVR_UNUSED( width ); OVR_UNUSED( height ); } + virtual ~ImageWindow() { } + + void GetResolution( size_t& width, size_t& height ) { width = 0; height = 0; } + + void OnPaint() { } + + void UpdateImage( const uint8_t* imageData, uint32_t width, uint32_t height ) { UpdateImageBW( imageData, width, height ); } + void UpdateImageBW( const uint8_t* imageData, uint32_t width, uint32_t height ) { OVR_UNUSED( imageData ); OVR_UNUSED( width ); OVR_UNUSED( height ); } + void UpdateImageRGBA( const uint8_t* imageData, uint32_t width, uint32_t height, uint32_t pitch ) { OVR_UNUSED( imageData ); OVR_UNUSED( width ); OVR_UNUSED( height ); OVR_UNUSED( pitch ); } + void Complete() { } + + void Process() { } + + void AssociateSurface( void* surface ) { OVR_UNUSED(surface); } + + void addCircle( float x , float y, float radius, float r, float g, float b, bool fill ) { OVR_UNUSED( x ); OVR_UNUSED( y ); OVR_UNUSED( radius ); OVR_UNUSED( r ); OVR_UNUSED( g ); OVR_UNUSED( b ); OVR_UNUSED( fill ); } + void addText( float x, float y, float r, float g, float b, OVR::String text ) { OVR_UNUSED( x ); OVR_UNUSED( y ); OVR_UNUSED( r ); OVR_UNUSED( g ); OVR_UNUSED( b ); OVR_UNUSED( text ); } + + static ImageWindow* GlobalWindow( int window ) { return globalWindow[window]; } + static int WindowCount() { return windowCount; } + +private: + + static const int MaxWindows = 4; + static ImageWindow* globalWindow[4]; + static int windowCount; +}; + +#endif + +}} // namespace OVR::Util + + +#endif diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Util/Util_Interface.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Util/Util_Interface.cpp Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,34 @@ +/************************************************************************************ + +Filename : Util_Interface.cpp +Content : Simple interface, utilised by internal demos, + with access to wider SDK as needed. + Located in the body of the SDK to ensure updated + when new SDK features are added. +Created : February 20, 2014 +Authors : Tom Heath + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +*************************************************************************************/ + +#include "Util_Interface.h" + + + +//Files left in to ease its possible return...... diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Util/Util_Interface.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Util/Util_Interface.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,36 @@ +/************************************************************************************ + +Filename : Util_Interface.h +Content : Simple interface, utilised by internal demos, + with access to wider SDK as needed. + Located in the body of the SDK to ensure updated + when new SDK features are added. +Created : February 20, 2014 +Authors : Tom Heath + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +*************************************************************************************/ + +#ifndef OVR_Util_Interface_h +#define OVR_Util_Interface_h +#include "../OVR_CAPI.h" + +//Files left in to ease its possible return...... + +#endif diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Util/Util_LatencyTest2Reader.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Util/Util_LatencyTest2Reader.cpp Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,118 @@ +/************************************************************************************ + +Filename : Util_LatencyTest2Reader.cpp +Content : Shared functionality for the DK2 latency tester +Created : July 8, 2014 +Authors : Volga Aksoy, Chris Taylor + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +*************************************************************************************/ + +#include "Util_LatencyTest2Reader.h" + +namespace OVR { namespace Util { + + +//// FrameTimeRecord + +bool FrameTimeRecord::ColorToReadbackIndex(int *readbackIndex, unsigned char color) +{ + int compareColor = color - LT2_ColorIncrement/2; + int index = color / LT2_ColorIncrement; // Use color without subtraction due to rounding. + int delta = compareColor - index * LT2_ColorIncrement; + + if ((delta < LT2_PixelTestThreshold) && (delta > -LT2_PixelTestThreshold)) + { + *readbackIndex = index; + return true; + } + return false; +} + +unsigned char FrameTimeRecord::ReadbackIndexToColor(int readbackIndex) +{ + OVR_ASSERT(readbackIndex < LT2_IncrementCount); + return (unsigned char)(readbackIndex * LT2_ColorIncrement + LT2_ColorIncrement/2); +} + + +//// FrameTimeRecordSet + +FrameTimeRecordSet::FrameTimeRecordSet() +{ + NextWriteIndex = 0; + memset(this, 0, sizeof(FrameTimeRecordSet)); +} + +void FrameTimeRecordSet::AddValue(int readValue, double timeSeconds) +{ + Records[NextWriteIndex].ReadbackIndex = readValue; + Records[NextWriteIndex].TimeSeconds = timeSeconds; + NextWriteIndex++; + if (NextWriteIndex == RecordCount) + NextWriteIndex = 0; +} +// Matching should be done starting from NextWrite index +// until wrap-around + +const FrameTimeRecord& FrameTimeRecordSet::operator [] (int i) const +{ + return Records[(NextWriteIndex + i) & RecordMask]; +} + +const FrameTimeRecord& FrameTimeRecordSet::GetMostRecentFrame() +{ + return Records[(NextWriteIndex - 1) & RecordMask]; +} + +// Advances I to absolute color index +bool FrameTimeRecordSet::FindReadbackIndex(int* i, int readbackIndex) const +{ + for (; *i < RecordCount; (*i)++) + { + if ((*this)[*i].ReadbackIndex == readbackIndex) + return true; + } + return false; +} + +bool FrameTimeRecordSet::IsAllZeroes() const +{ + for (int i = 0; i < RecordCount; i++) + if (Records[i].ReadbackIndex != 0) + return false; + return true; +} + + +//// RecordStateReader + +void RecordStateReader::GetRecordSet(FrameTimeRecordSet& recordset) +{ + if(!Updater) + { + return; + } + + recordset = Updater->SharedLatencyTestState.GetState(); + return; +} + + +}} // namespace OVR::Util diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Util/Util_LatencyTest2Reader.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Util/Util_LatencyTest2Reader.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,63 @@ +/************************************************************************************ + +Filename : Util_LatencyTest2Reader.h +Content : Shared functionality for the DK2 latency tester +Created : July 8, 2014 +Authors : Volga Aksoy, Chris Taylor + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +*************************************************************************************/ + +#ifndef OVR_Util_LatencyTest2Reader_h +#define OVR_Util_LatencyTest2Reader_h + +#include "../Tracking/Tracking_SensorState.h" +#include "Util_LatencyTest2State.h" + +namespace OVR { namespace Util { + + +//----------------------------------------------------------------------------- +// RecordStateReader + +// User interface to retrieve pose from the sensor fusion subsystem +class RecordStateReader : public NewOverrideBase +{ +protected: + const Tracking::CombinedSharedStateUpdater* Updater; + +public: + RecordStateReader() + : Updater(NULL) + { + } + + // Initialize the updater + void SetUpdater(const Tracking::CombinedSharedStateUpdater *updater) + { + Updater = updater; + } + + void GetRecordSet(FrameTimeRecordSet& recordset); +}; + + +}} // namespace OVR::Util + +#endif // OVR_Util_LatencyTest2Reader_h diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Util/Util_LatencyTest2State.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Util/Util_LatencyTest2State.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,96 @@ +/************************************************************************************ + +Filename : Util_LatencyTest2Reader.h +Content : Shared functionality for the DK2 latency tester +Created : July 8, 2014 +Authors : Volga Aksoy, Chris Taylor + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +*************************************************************************************/ + +#ifndef OVR_Util_LatencyTest2_State_h +#define OVR_Util_LatencyTest2_State_h + +#include "../Kernel/OVR_Lockless.h" + +namespace OVR { namespace Util { + + +enum LatencyTester2Constants +{ + LT2_ColorIncrement = 32, + LT2_PixelTestThreshold = LT2_ColorIncrement / 3, + LT2_IncrementCount = 256 / LT2_ColorIncrement, + LT2_TimeoutWaitingForColorDetected = 1000 // 1 second +}; + + +//------------------------------------------------------------------------------------- +// FrameTimeRecord + +// Describes frame scan-out time used for latency testing. +struct FrameTimeRecord +{ + int ReadbackIndex; + double TimeSeconds; + + // Utility functions to convert color to readBack indices and back. + // The purpose of ReadbackIndex is to allow direct comparison by value. + + static bool ColorToReadbackIndex(int *readbackIndex, unsigned char color); + static unsigned char ReadbackIndexToColor(int readbackIndex); +}; + + +//----------------------------------------------------------------------------- +// FrameTimeRecordSet + +// FrameTimeRecordSet is a container holding multiple consecutive frame timing records +// returned from the lock-less state. Used by FrameTimeManager. +struct FrameTimeRecordSet +{ + enum { + RecordCount = 4, + RecordMask = RecordCount - 1 + }; + FrameTimeRecord Records[RecordCount]; + int NextWriteIndex; + + FrameTimeRecordSet(); + + void AddValue(int readValue, double timeSeconds); + // Matching should be done starting from NextWrite index + // until wrap-around + + const FrameTimeRecord& operator [] (int i) const; + + const FrameTimeRecord& GetMostRecentFrame(); + + // Advances I to absolute color index + bool FindReadbackIndex(int* i, int readbackIndex) const; + + bool IsAllZeroes() const; +}; + +typedef LocklessUpdater LockessRecordUpdater; + + +}} // namespace OVR::Util + +#endif // OVR_Util_LatencyTest2_State_h diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Util/Util_Render_Stereo.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Util/Util_Render_Stereo.cpp Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,1554 @@ +/************************************************************************************ + +Filename : Util_Render_Stereo.cpp +Content : Stereo rendering configuration implementation +Created : October 22, 2012 +Authors : Michael Antonov, Andrew Reisse, Tom Forsyth + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +*************************************************************************************/ + +#include "Util_Render_Stereo.h" + +namespace OVR { namespace Util { namespace Render { + +using namespace OVR::Tracking; + + +//----------------------------------------------------------------------------------- +// **** Useful debug functions. + +char const* GetDebugNameEyeCupType ( EyeCupType eyeCupType ) +{ + switch ( eyeCupType ) + { + case EyeCup_DK1A: return "DK1 A"; + case EyeCup_DK1B: return "DK1 B"; + case EyeCup_DK1C: return "DK1 C"; + case EyeCup_DKHD2A: return "DKHD2 A"; + case EyeCup_OrangeA: return "Orange A"; + case EyeCup_RedA: return "Red A"; + case EyeCup_PinkA: return "Pink A"; + case EyeCup_BlueA: return "Blue A"; + case EyeCup_Delilah1A: return "Delilah 1 A"; + case EyeCup_Delilah2A: return "Delilah 2 A"; + case EyeCup_JamesA: return "James A"; + case EyeCup_SunMandalaA: return "Sun Mandala A"; + case EyeCup_DK2A: return "DK2 A"; + case EyeCup_LAST: return "LAST"; + default: OVR_ASSERT ( false ); return "Error"; + } +} + +char const* GetDebugNameHmdType ( HmdTypeEnum hmdType ) +{ + switch ( hmdType ) + { + case HmdType_None: return "None"; + case HmdType_DK1: return "DK1"; + case HmdType_DKProto: return "DK1 prototype"; + case HmdType_DKHDProto: return "DK HD prototype 1"; + case HmdType_DKHDProto566Mi: return "DK HD prototype 566 Mi"; + case HmdType_DKHD2Proto: return "DK HD prototype 585"; + case HmdType_CrystalCoveProto: return "Crystal Cove"; + case HmdType_DK2: return "DK2"; + case HmdType_Unknown: return "Unknown"; + case HmdType_LAST: return "LAST"; + default: OVR_ASSERT ( false ); return "Error"; + } +} + + +//----------------------------------------------------------------------------------- +// **** Internal pipeline functions. + +struct DistortionAndFov +{ + DistortionRenderDesc Distortion; + FovPort Fov; +}; + +static DistortionAndFov CalculateDistortionAndFovInternal ( StereoEye eyeType, HmdRenderInfo const &hmd, + LensConfig const *pLensOverride = NULL, + FovPort const *pTanHalfFovOverride = NULL, + float extraEyeRotationInRadians = OVR_DEFAULT_EXTRA_EYE_ROTATION ) +{ + // pLensOverride can be NULL, which means no override. + + DistortionRenderDesc localDistortion = CalculateDistortionRenderDesc ( eyeType, hmd, pLensOverride ); + FovPort fov = CalculateFovFromHmdInfo ( eyeType, localDistortion, hmd, extraEyeRotationInRadians ); + // Here the app or the user would optionally clamp this visible fov to a smaller number if + // they want more perf or resolution and are willing to give up FOV. + // They may also choose to clamp UDLR differently e.g. to get cinemascope-style views. + if ( pTanHalfFovOverride != NULL ) + { + fov = *pTanHalfFovOverride; + } + + // Here we could call ClampToPhysicalScreenFov(), but we do want people + // to be able to play with larger-than-screen views. + // The calling app can always do the clamping itself. + DistortionAndFov result; + result.Distortion = localDistortion; + result.Fov = fov; + + return result; +} + + +static Recti CalculateViewportInternal ( StereoEye eyeType, + Sizei const actualRendertargetSurfaceSize, + Sizei const requestedRenderedPixelSize, + bool bRendertargetSharedByBothEyes, + bool bMonoRenderingMode = false ) +{ + Recti renderedViewport; + if ( bMonoRenderingMode || !bRendertargetSharedByBothEyes || (eyeType == StereoEye_Center) ) + { + // One eye per RT. + renderedViewport.x = 0; + renderedViewport.y = 0; + renderedViewport.w = Alg::Min ( actualRendertargetSurfaceSize.w, requestedRenderedPixelSize.w ); + renderedViewport.h = Alg::Min ( actualRendertargetSurfaceSize.h, requestedRenderedPixelSize.h ); + } + else + { + // Both eyes share the RT. + renderedViewport.x = 0; + renderedViewport.y = 0; + renderedViewport.w = Alg::Min ( actualRendertargetSurfaceSize.w/2, requestedRenderedPixelSize.w ); + renderedViewport.h = Alg::Min ( actualRendertargetSurfaceSize.h, requestedRenderedPixelSize.h ); + if ( eyeType == StereoEye_Right ) + { + renderedViewport.x = (actualRendertargetSurfaceSize.w+1)/2; // Round up, not down. + } + } + return renderedViewport; +} + +static Recti CalculateViewportDensityInternal ( StereoEye eyeType, + DistortionRenderDesc const &distortion, + FovPort const &fov, + Sizei const &actualRendertargetSurfaceSize, + bool bRendertargetSharedByBothEyes, + float desiredPixelDensity = 1.0f, + bool bMonoRenderingMode = false ) +{ + OVR_ASSERT ( actualRendertargetSurfaceSize.w > 0 ); + OVR_ASSERT ( actualRendertargetSurfaceSize.h > 0 ); + + // What size RT do we need to get 1:1 mapping? + Sizei idealPixelSize = CalculateIdealPixelSize ( eyeType, distortion, fov, desiredPixelDensity ); + // ...but we might not actually get that size. + return CalculateViewportInternal ( eyeType, + actualRendertargetSurfaceSize, + idealPixelSize, + bRendertargetSharedByBothEyes, bMonoRenderingMode ); +} + +static ViewportScaleAndOffset CalculateViewportScaleAndOffsetInternal ( + ScaleAndOffset2D const &eyeToSourceNDC, + Recti const &renderedViewport, + Sizei const &actualRendertargetSurfaceSize ) +{ + ViewportScaleAndOffset result; + result.RenderedViewport = renderedViewport; + result.EyeToSourceUV = CreateUVScaleAndOffsetfromNDCScaleandOffset( + eyeToSourceNDC, renderedViewport, actualRendertargetSurfaceSize ); + return result; +} + + +static StereoEyeParams CalculateStereoEyeParamsInternal ( StereoEye eyeType, HmdRenderInfo const &hmd, + DistortionRenderDesc const &distortion, + FovPort const &fov, + Sizei const &actualRendertargetSurfaceSize, + Recti const &renderedViewport, + bool bRightHanded = true, float zNear = 0.01f, float zFar = 10000.0f, + bool bMonoRenderingMode = false, + float zoomFactor = 1.0f ) +{ + // Generate the projection matrix for intermediate rendertarget. + // Z range can also be inserted later by the app (though not in this particular case) + float fovScale = 1.0f / zoomFactor; + FovPort zoomedFov = fov; + zoomedFov.LeftTan *= fovScale; + zoomedFov.RightTan *= fovScale; + zoomedFov.UpTan *= fovScale; + zoomedFov.DownTan *= fovScale; + Matrix4f projection = CreateProjection ( bRightHanded, zoomedFov, zNear, zFar ); + + // Find the mapping from TanAngle space to target NDC space. + // Note this does NOT take the zoom factor into account because + // this is the mapping of actual physical eye FOV (and our eyes do not zoom!) + // to screen space. + ScaleAndOffset2D eyeToSourceNDC = CreateNDCScaleAndOffsetFromFov ( fov ); + + // The size of the final FB, which is fixed and determined by the physical size of the device display. + Recti distortedViewport = GetFramebufferViewport ( eyeType, hmd ); + Vector3f virtualCameraOffset = CalculateEyeVirtualCameraOffset(hmd, eyeType, bMonoRenderingMode); + + StereoEyeParams result; + result.Eye = eyeType; + result.HmdToEyeViewOffset = Matrix4f::Translation(virtualCameraOffset); + result.Distortion = distortion; + result.DistortionViewport = distortedViewport; + result.Fov = fov; + result.RenderedProjection = projection; + result.EyeToSourceNDC = eyeToSourceNDC; + ViewportScaleAndOffset vsao = CalculateViewportScaleAndOffsetInternal ( eyeToSourceNDC, renderedViewport, actualRendertargetSurfaceSize ); + result.RenderedViewport = vsao.RenderedViewport; + result.EyeToSourceUV = vsao.EyeToSourceUV; + + return result; +} + + +Vector3f CalculateEyeVirtualCameraOffset(HmdRenderInfo const &hmd, + StereoEye eyeType, bool bmonoRenderingMode) +{ + Vector3f virtualCameraOffset(0); + + if (!bmonoRenderingMode) + { + float eyeCenterRelief = hmd.GetEyeCenter().ReliefInMeters; + + if (eyeType == StereoEye_Left) + { + virtualCameraOffset.x = hmd.EyeLeft.NoseToPupilInMeters; + virtualCameraOffset.z = eyeCenterRelief - hmd.EyeLeft.ReliefInMeters; + } + else if (eyeType == StereoEye_Right) + { + virtualCameraOffset.x = -hmd.EyeRight.NoseToPupilInMeters; + virtualCameraOffset.z = eyeCenterRelief - hmd.EyeRight.ReliefInMeters; + } + } + + return virtualCameraOffset; +} + + +//----------------------------------------------------------------------------------- +// **** Higher-level utility functions. + +Sizei CalculateRecommendedTextureSize ( HmdRenderInfo const &hmd, + bool bRendertargetSharedByBothEyes, + float pixelDensityInCenter /*= 1.0f*/ ) +{ + Sizei idealPixelSize[2]; + for ( int eyeNum = 0; eyeNum < 2; eyeNum++ ) + { + StereoEye eyeType = ( eyeNum == 0 ) ? StereoEye_Left : StereoEye_Right; + + DistortionAndFov distortionAndFov = CalculateDistortionAndFovInternal ( eyeType, hmd, NULL, NULL, OVR_DEFAULT_EXTRA_EYE_ROTATION ); + + idealPixelSize[eyeNum] = CalculateIdealPixelSize ( eyeType, + distortionAndFov.Distortion, + distortionAndFov.Fov, + pixelDensityInCenter ); + } + + Sizei result; + result.w = Alg::Max ( idealPixelSize[0].w, idealPixelSize[1].w ); + result.h = Alg::Max ( idealPixelSize[0].h, idealPixelSize[1].h ); + if ( bRendertargetSharedByBothEyes ) + { + result.w *= 2; + } + return result; +} + +StereoEyeParams CalculateStereoEyeParams ( HmdRenderInfo const &hmd, + StereoEye eyeType, + Sizei const &actualRendertargetSurfaceSize, + bool bRendertargetSharedByBothEyes, + bool bRightHanded /*= true*/, + float zNear /*= 0.01f*/, float zFar /*= 10000.0f*/, + Sizei const *pOverrideRenderedPixelSize /* = NULL*/, + FovPort const *pOverrideFovport /*= NULL*/, + float zoomFactor /*= 1.0f*/ ) +{ + DistortionAndFov distortionAndFov = CalculateDistortionAndFovInternal ( eyeType, hmd, NULL, NULL, OVR_DEFAULT_EXTRA_EYE_ROTATION ); + if ( pOverrideFovport != NULL ) + { + distortionAndFov.Fov = *pOverrideFovport; + } + + Recti viewport; + if ( pOverrideRenderedPixelSize != NULL ) + { + viewport = CalculateViewportInternal ( eyeType, actualRendertargetSurfaceSize, *pOverrideRenderedPixelSize, bRendertargetSharedByBothEyes, false ); + } + else + { + viewport = CalculateViewportDensityInternal ( eyeType, + distortionAndFov.Distortion, + distortionAndFov.Fov, + actualRendertargetSurfaceSize, bRendertargetSharedByBothEyes, 1.0f, false ); + } + + return CalculateStereoEyeParamsInternal ( + eyeType, hmd, + distortionAndFov.Distortion, + distortionAndFov.Fov, + actualRendertargetSurfaceSize, viewport, + bRightHanded, zNear, zFar, false, zoomFactor ); +} + + +FovPort CalculateRecommendedFov ( HmdRenderInfo const &hmd, + StereoEye eyeType, + bool bMakeFovSymmetrical /* = false */ ) +{ + DistortionAndFov distortionAndFov = CalculateDistortionAndFovInternal ( eyeType, hmd, NULL, NULL, OVR_DEFAULT_EXTRA_EYE_ROTATION ); + FovPort fov = distortionAndFov.Fov; + if ( bMakeFovSymmetrical ) + { + // Deal with engines that cannot support an off-center projection. + // Unfortunately this means they will be rendering pixels that the user can't actually see. + float fovTanH = Alg::Max ( fov.LeftTan, fov.RightTan ); + float fovTanV = Alg::Max ( fov.UpTan, fov.DownTan ); + fov.LeftTan = fovTanH; + fov.RightTan = fovTanH; + fov.UpTan = fovTanV; + fov.DownTan = fovTanV; + } + return fov; +} + +ViewportScaleAndOffset ModifyRenderViewport ( StereoEyeParams const ¶ms, + Sizei const &actualRendertargetSurfaceSize, + Recti const &renderViewport ) +{ + return CalculateViewportScaleAndOffsetInternal ( params.EyeToSourceNDC, renderViewport, actualRendertargetSurfaceSize ); +} + +ViewportScaleAndOffset ModifyRenderSize ( StereoEyeParams const ¶ms, + Sizei const &actualRendertargetSurfaceSize, + Sizei const &requestedRenderSize, + bool bRendertargetSharedByBothEyes /*= false*/ ) +{ + Recti renderViewport = CalculateViewportInternal ( params.Eye, actualRendertargetSurfaceSize, requestedRenderSize, bRendertargetSharedByBothEyes, false ); + return CalculateViewportScaleAndOffsetInternal ( params.EyeToSourceNDC, renderViewport, actualRendertargetSurfaceSize ); +} + +ViewportScaleAndOffset ModifyRenderDensity ( StereoEyeParams const ¶ms, + Sizei const &actualRendertargetSurfaceSize, + float pixelDensity /*= 1.0f*/, + bool bRendertargetSharedByBothEyes /*= false*/ ) +{ + Recti renderViewport = CalculateViewportDensityInternal ( params.Eye, params.Distortion, params.Fov, actualRendertargetSurfaceSize, bRendertargetSharedByBothEyes, pixelDensity, false ); + return CalculateViewportScaleAndOffsetInternal ( params.EyeToSourceNDC, renderViewport, actualRendertargetSurfaceSize ); +} + + +//----------------------------------------------------------------------------------- +// **** StereoConfig Implementation + +StereoConfig::StereoConfig(StereoMode mode) + : Mode(mode), + DirtyFlag(true) +{ + // Initialize "fake" default HMD values for testing without HMD plugged in. + // These default values match those returned by DK1 + // (at least they did at time of writing - certainly good enough for debugging) + Hmd.HmdType = HmdType_None; + Hmd.ResolutionInPixels = Sizei(1280, 800); + Hmd.ScreenSizeInMeters = Sizef(0.1498f, 0.0936f); + Hmd.ScreenGapSizeInMeters = 0.0f; + Hmd.PelOffsetR = Vector2f ( 0.0f, 0.0f ); + Hmd.PelOffsetB = Vector2f ( 0.0f, 0.0f ); + Hmd.CenterFromTopInMeters = 0.0468f; + Hmd.LensSeparationInMeters = 0.0635f; + Hmd.LensDiameterInMeters = 0.035f; + Hmd.LensSurfaceToMidplateInMeters = 0.025f; + Hmd.EyeCups = EyeCup_DK1A; + Hmd.Shutter.Type = HmdShutter_RollingTopToBottom; + Hmd.Shutter.VsyncToNextVsync = ( 1.0f / 60.0f ); + Hmd.Shutter.VsyncToFirstScanline = 0.000052f; + Hmd.Shutter.FirstScanlineToLastScanline = 0.016580f; + Hmd.Shutter.PixelSettleTime = 0.015f; + Hmd.Shutter.PixelPersistence = ( 1.0f / 60.0f ); + Hmd.EyeLeft.Distortion.SetToIdentity(); + Hmd.EyeLeft.Distortion.MetersPerTanAngleAtCenter = 0.043875f; + Hmd.EyeLeft.Distortion.Eqn = Distortion_RecipPoly4; + Hmd.EyeLeft.Distortion.K[0] = 1.0f; + Hmd.EyeLeft.Distortion.K[1] = -0.3999f; + Hmd.EyeLeft.Distortion.K[2] = 0.2408f; + Hmd.EyeLeft.Distortion.K[3] = -0.4589f; + Hmd.EyeLeft.Distortion.MaxR = 1.0f; + Hmd.EyeLeft.Distortion.ChromaticAberration[0] = 0.006f; + Hmd.EyeLeft.Distortion.ChromaticAberration[1] = 0.0f; + Hmd.EyeLeft.Distortion.ChromaticAberration[2] = -0.014f; + Hmd.EyeLeft.Distortion.ChromaticAberration[3] = 0.0f; + Hmd.EyeLeft.NoseToPupilInMeters = 0.62f; + Hmd.EyeLeft.ReliefInMeters = 0.013f; + Hmd.EyeRight = Hmd.EyeLeft; + + SetViewportMode = SVPM_Density; + SetViewportPixelsPerDisplayPixel = 1.0f; + // Not used in this mode, but init them anyway. + SetViewportSize[0] = Sizei(0,0); + SetViewportSize[1] = Sizei(0,0); + SetViewport[0] = Recti(0,0,0,0); + SetViewport[1] = Recti(0,0,0,0); + + OverrideLens = false; + OverrideTanHalfFov = false; + OverrideZeroIpd = false; + ExtraEyeRotationInRadians = OVR_DEFAULT_EXTRA_EYE_ROTATION; + IsRendertargetSharedByBothEyes = true; + RightHandedProjection = true; + + // This should cause an assert if the app does not call SetRendertargetSize() + RendertargetSize = Sizei ( 0, 0 ); + + ZNear = 0.01f; + ZFar = 10000.0f; + + Set2DAreaFov(DegreeToRad(85.0f)); +} + +void StereoConfig::SetHmdRenderInfo(const HmdRenderInfo& hmd) +{ + Hmd = hmd; + DirtyFlag = true; +} + +void StereoConfig::Set2DAreaFov(float fovRadians) +{ + Area2DFov = fovRadians; + DirtyFlag = true; +} + +const StereoEyeParamsWithOrtho& StereoConfig::GetEyeRenderParams(StereoEye eye) +{ + if ( DirtyFlag ) + { + UpdateComputedState(); + } + + static const uint8_t eyeParamIndices[3] = { 0, 0, 1 }; + + OVR_ASSERT(eye < sizeof(eyeParamIndices)); + return EyeRenderParams[eyeParamIndices[eye]]; +} + +void StereoConfig::SetLensOverride ( LensConfig const *pLensOverrideLeft /*= NULL*/, + LensConfig const *pLensOverrideRight /*= NULL*/ ) +{ + if ( pLensOverrideLeft == NULL ) + { + OverrideLens = false; + } + else + { + OverrideLens = true; + LensOverrideLeft = *pLensOverrideLeft; + LensOverrideRight = *pLensOverrideLeft; + if ( pLensOverrideRight != NULL ) + { + LensOverrideRight = *pLensOverrideRight; + } + } + DirtyFlag = true; +} + +void StereoConfig::SetRendertargetSize (Size const rendertargetSize, + bool rendertargetIsSharedByBothEyes ) +{ + RendertargetSize = rendertargetSize; + IsRendertargetSharedByBothEyes = rendertargetIsSharedByBothEyes; + DirtyFlag = true; +} + +void StereoConfig::SetFov ( FovPort const *pfovLeft /*= NULL*/, + FovPort const *pfovRight /*= NULL*/ ) +{ + DirtyFlag = true; + if ( pfovLeft == NULL ) + { + OverrideTanHalfFov = false; + } + else + { + OverrideTanHalfFov = true; + FovOverrideLeft = *pfovLeft; + FovOverrideRight = *pfovLeft; + if ( pfovRight != NULL ) + { + FovOverrideRight = *pfovRight; + } + } +} + + +void StereoConfig::SetZeroVirtualIpdOverride ( bool enableOverride ) +{ + DirtyFlag = true; + OverrideZeroIpd = enableOverride; +} + + +void StereoConfig::SetZClipPlanesAndHandedness ( float zNear /*= 0.01f*/, float zFar /*= 10000.0f*/, bool rightHandedProjection /*= true*/ ) +{ + DirtyFlag = true; + ZNear = zNear; + ZFar = zFar; + RightHandedProjection = rightHandedProjection; +} + +void StereoConfig::SetExtraEyeRotation ( float extraEyeRotationInRadians ) +{ + DirtyFlag = true; + ExtraEyeRotationInRadians = extraEyeRotationInRadians; +} + +Sizei StereoConfig::CalculateRecommendedTextureSize ( bool rendertargetSharedByBothEyes, + float pixelDensityInCenter /*= 1.0f*/ ) +{ + return Render::CalculateRecommendedTextureSize ( Hmd, rendertargetSharedByBothEyes, pixelDensityInCenter ); +} + + + +void StereoConfig::UpdateComputedState() +{ + int numEyes = 2; + StereoEye eyeTypes[2]; + + switch ( Mode ) + { + case Stereo_None: + numEyes = 1; + eyeTypes[0] = StereoEye_Center; + break; + + case Stereo_LeftRight_Multipass: + numEyes = 2; + eyeTypes[0] = StereoEye_Left; + eyeTypes[1] = StereoEye_Right; + break; + + default: + numEyes = 0; + OVR_ASSERT( false ); + break; + } + + // If either of these fire, you've probably forgotten to call SetRendertargetSize() + OVR_ASSERT ( RendertargetSize.w > 0 ); + OVR_ASSERT ( RendertargetSize.h > 0 ); + + for ( int eyeNum = 0; eyeNum < numEyes; eyeNum++ ) + { + StereoEye eyeType = eyeTypes[eyeNum]; + LensConfig *pLensOverride = NULL; + if ( OverrideLens ) + { + if ( eyeType == StereoEye_Right ) + { + pLensOverride = &LensOverrideRight; + } + else + { + pLensOverride = &LensOverrideLeft; + } + } + + FovPort *pTanHalfFovOverride = NULL; + if ( OverrideTanHalfFov ) + { + if ( eyeType == StereoEye_Right ) + { + pTanHalfFovOverride = &FovOverrideRight; + } + else + { + pTanHalfFovOverride = &FovOverrideLeft; + } + } + + DistortionAndFov distortionAndFov = + CalculateDistortionAndFovInternal ( eyeType, Hmd, + pLensOverride, pTanHalfFovOverride, + ExtraEyeRotationInRadians ); + + EyeRenderParams[eyeNum].StereoEye.Distortion = distortionAndFov.Distortion; + EyeRenderParams[eyeNum].StereoEye.Fov = distortionAndFov.Fov; + } + + if ( OverrideZeroIpd ) + { + // Take the union of the calculated eye FOVs. + FovPort fov; + fov.UpTan = Alg::Max ( EyeRenderParams[0].StereoEye.Fov.UpTan , EyeRenderParams[1].StereoEye.Fov.UpTan ); + fov.DownTan = Alg::Max ( EyeRenderParams[0].StereoEye.Fov.DownTan , EyeRenderParams[1].StereoEye.Fov.DownTan ); + fov.LeftTan = Alg::Max ( EyeRenderParams[0].StereoEye.Fov.LeftTan , EyeRenderParams[1].StereoEye.Fov.LeftTan ); + fov.RightTan = Alg::Max ( EyeRenderParams[0].StereoEye.Fov.RightTan, EyeRenderParams[1].StereoEye.Fov.RightTan ); + EyeRenderParams[0].StereoEye.Fov = fov; + EyeRenderParams[1].StereoEye.Fov = fov; + } + + for ( int eyeNum = 0; eyeNum < numEyes; eyeNum++ ) + { + StereoEye eyeType = eyeTypes[eyeNum]; + + DistortionRenderDesc localDistortion = EyeRenderParams[eyeNum].StereoEye.Distortion; + FovPort fov = EyeRenderParams[eyeNum].StereoEye.Fov; + + // Use a placeholder - will be overridden later. + Recti tempViewport = Recti ( 0, 0, 1, 1 ); + + EyeRenderParams[eyeNum].StereoEye = CalculateStereoEyeParamsInternal ( + eyeType, Hmd, localDistortion, fov, + RendertargetSize, tempViewport, + RightHandedProjection, ZNear, ZFar, + OverrideZeroIpd ); + + // We want to create a virtual 2D surface we can draw debug text messages to. + // We'd like it to be a fixed distance (OrthoDistance) away, + // and to cover a specific FOV (Area2DFov). We need to find the projection matrix for this, + // and also to know how large it is in pixels to achieve a 1:1 mapping at the center of the screen. + float orthoDistance = 0.8f; + float orthoHalfFov = tanf ( Area2DFov * 0.5f ); + Vector2f unityOrthoPixelSize = localDistortion.PixelsPerTanAngleAtCenter * ( orthoHalfFov * 2.0f ); + float localInterpupillaryDistance = Hmd.EyeLeft.NoseToPupilInMeters + Hmd.EyeRight.NoseToPupilInMeters; + if ( OverrideZeroIpd ) + { + localInterpupillaryDistance = 0.0f; + } + Matrix4f ortho = CreateOrthoSubProjection ( true, eyeType, + orthoHalfFov, orthoHalfFov, + unityOrthoPixelSize.x, unityOrthoPixelSize.y, + orthoDistance, localInterpupillaryDistance, + EyeRenderParams[eyeNum].StereoEye.RenderedProjection ); + EyeRenderParams[eyeNum].OrthoProjection = ortho; + } + + // ...and now set up the viewport, scale & offset the way the app wanted. + setupViewportScaleAndOffsets(); + + if ( OverrideZeroIpd ) + { + // Monocular rendering has some fragile parts... don't break any by accident. + OVR_ASSERT ( EyeRenderParams[0].StereoEye.Fov.UpTan == EyeRenderParams[1].StereoEye.Fov.UpTan ); + OVR_ASSERT ( EyeRenderParams[0].StereoEye.Fov.DownTan == EyeRenderParams[1].StereoEye.Fov.DownTan ); + OVR_ASSERT ( EyeRenderParams[0].StereoEye.Fov.LeftTan == EyeRenderParams[1].StereoEye.Fov.LeftTan ); + OVR_ASSERT ( EyeRenderParams[0].StereoEye.Fov.RightTan == EyeRenderParams[1].StereoEye.Fov.RightTan ); + OVR_ASSERT ( EyeRenderParams[0].StereoEye.RenderedProjection.M[0][0] == EyeRenderParams[1].StereoEye.RenderedProjection.M[0][0] ); + OVR_ASSERT ( EyeRenderParams[0].StereoEye.RenderedProjection.M[1][1] == EyeRenderParams[1].StereoEye.RenderedProjection.M[1][1] ); + OVR_ASSERT ( EyeRenderParams[0].StereoEye.RenderedProjection.M[0][2] == EyeRenderParams[1].StereoEye.RenderedProjection.M[0][2] ); + OVR_ASSERT ( EyeRenderParams[0].StereoEye.RenderedProjection.M[1][2] == EyeRenderParams[1].StereoEye.RenderedProjection.M[1][2] ); + OVR_ASSERT ( EyeRenderParams[0].StereoEye.RenderedViewport == EyeRenderParams[1].StereoEye.RenderedViewport ); + OVR_ASSERT ( EyeRenderParams[0].StereoEye.EyeToSourceUV.Offset == EyeRenderParams[1].StereoEye.EyeToSourceUV.Offset ); + OVR_ASSERT ( EyeRenderParams[0].StereoEye.EyeToSourceUV.Scale == EyeRenderParams[1].StereoEye.EyeToSourceUV.Scale ); + OVR_ASSERT ( EyeRenderParams[0].StereoEye.EyeToSourceNDC.Offset == EyeRenderParams[1].StereoEye.EyeToSourceNDC.Offset ); + OVR_ASSERT ( EyeRenderParams[0].StereoEye.EyeToSourceNDC.Scale == EyeRenderParams[1].StereoEye.EyeToSourceNDC.Scale ); + OVR_ASSERT ( EyeRenderParams[0].OrthoProjection.M[0][0] == EyeRenderParams[1].OrthoProjection.M[0][0] ); + OVR_ASSERT ( EyeRenderParams[0].OrthoProjection.M[1][1] == EyeRenderParams[1].OrthoProjection.M[1][1] ); + OVR_ASSERT ( EyeRenderParams[0].OrthoProjection.M[0][2] == EyeRenderParams[1].OrthoProjection.M[0][2] ); + OVR_ASSERT ( EyeRenderParams[0].OrthoProjection.M[1][2] == EyeRenderParams[1].OrthoProjection.M[1][2] ); + } + + DirtyFlag = false; +} + + + +ViewportScaleAndOffsetBothEyes StereoConfig::setupViewportScaleAndOffsets() +{ + for ( int eyeNum = 0; eyeNum < 2; eyeNum++ ) + { + StereoEye eyeType = ( eyeNum == 0 ) ? StereoEye_Left : StereoEye_Right; + + DistortionRenderDesc localDistortion = EyeRenderParams[eyeNum].StereoEye.Distortion; + FovPort fov = EyeRenderParams[eyeNum].StereoEye.Fov; + + Recti renderedViewport; + switch ( SetViewportMode ) + { + case SVPM_Density: + renderedViewport = CalculateViewportDensityInternal ( + eyeType, localDistortion, fov, + RendertargetSize, IsRendertargetSharedByBothEyes, + SetViewportPixelsPerDisplayPixel, OverrideZeroIpd ); + break; + case SVPM_Size: + if ( ( eyeType == StereoEye_Right ) && !OverrideZeroIpd ) + { + renderedViewport = CalculateViewportInternal ( + eyeType, RendertargetSize, + SetViewportSize[1], + IsRendertargetSharedByBothEyes, OverrideZeroIpd ); + } + else + { + renderedViewport = CalculateViewportInternal ( + eyeType, RendertargetSize, + SetViewportSize[0], + IsRendertargetSharedByBothEyes, OverrideZeroIpd ); + } + break; + case SVPM_Viewport: + if ( ( eyeType == StereoEye_Right ) && !OverrideZeroIpd ) + { + renderedViewport = SetViewport[1]; + } + else + { + renderedViewport = SetViewport[0]; + } + break; + default: OVR_ASSERT ( false ); break; + } + + ViewportScaleAndOffset vpsao = CalculateViewportScaleAndOffsetInternal ( + EyeRenderParams[eyeNum].StereoEye.EyeToSourceNDC, + renderedViewport, + RendertargetSize ); + EyeRenderParams[eyeNum].StereoEye.RenderedViewport = vpsao.RenderedViewport; + EyeRenderParams[eyeNum].StereoEye.EyeToSourceUV = vpsao.EyeToSourceUV; + } + + ViewportScaleAndOffsetBothEyes result; + result.Left.EyeToSourceUV = EyeRenderParams[0].StereoEye.EyeToSourceUV; + result.Left.RenderedViewport = EyeRenderParams[0].StereoEye.RenderedViewport; + result.Right.EyeToSourceUV = EyeRenderParams[1].StereoEye.EyeToSourceUV; + result.Right.RenderedViewport = EyeRenderParams[1].StereoEye.RenderedViewport; + return result; +} + +// Specify a pixel density - how many rendered pixels per pixel in the physical display. +ViewportScaleAndOffsetBothEyes StereoConfig::SetRenderDensity ( float pixelsPerDisplayPixel ) +{ + SetViewportMode = SVPM_Density; + SetViewportPixelsPerDisplayPixel = pixelsPerDisplayPixel; + return setupViewportScaleAndOffsets(); +} + +// Supply the size directly. Will be clamped to the physical rendertarget size. +ViewportScaleAndOffsetBothEyes StereoConfig::SetRenderSize ( Sizei const &renderSizeLeft, Sizei const &renderSizeRight ) +{ + SetViewportMode = SVPM_Size; + SetViewportSize[0] = renderSizeLeft; + SetViewportSize[1] = renderSizeRight; + return setupViewportScaleAndOffsets(); +} + +// Supply the viewport directly. This is not clamped to the physical rendertarget - careful now! +ViewportScaleAndOffsetBothEyes StereoConfig::SetRenderViewport ( Recti const &renderViewportLeft, Recti const &renderViewportRight ) +{ + SetViewportMode = SVPM_Viewport; + SetViewport[0] = renderViewportLeft; + SetViewport[1] = renderViewportRight; + return setupViewportScaleAndOffsets(); +} + +Matrix4f StereoConfig::GetProjectionWithZoom ( StereoEye eye, float fovZoom ) const +{ + int eyeNum = ( eye == StereoEye_Right ) ? 1 : 0; + float fovScale = 1.0f / fovZoom; + FovPort fovPort = EyeRenderParams[eyeNum].StereoEye.Fov; + fovPort.LeftTan *= fovScale; + fovPort.RightTan *= fovScale; + fovPort.UpTan *= fovScale; + fovPort.DownTan *= fovScale; + return CreateProjection ( RightHandedProjection, fovPort, ZNear, ZFar ); +} + + + + +//----------------------------------------------------------------------------------- +// ***** Distortion Mesh Rendering + + +// Pow2 for the Morton order to work! +// 4 is too low - it is easy to see the "wobbles" in the HMD. +// 5 is realllly close but you can see pixel differences with even/odd frame checking. +// 6 is indistinguishable on a monitor on even/odd frames. +static const int DMA_GridSizeLog2 = 6; +static const int DMA_GridSize = 1< 0.5, then right goes 0.5 -> 1.0 + result.TimewarpLerp = screenNDC.x * 0.25f + 0.25f; + if (rightEye) + { + result.TimewarpLerp += 0.5f; + } + break; + case HmdShutter_RollingRightToLeft: + // Retrace is right to left - right eye goes 0.0 -> 0.5, then left goes 0.5 -> 1.0 + result.TimewarpLerp = 0.75f - screenNDC.x * 0.25f; + if (rightEye) + { + result.TimewarpLerp -= 0.5f; + } + break; + case HmdShutter_RollingTopToBottom: + // Retrace is top to bottom on both eyes at the same time. + result.TimewarpLerp = screenNDC.y * 0.5f + 0.5f; + break; + default: OVR_ASSERT ( false ); break; + } + + // When does the fade-to-black edge start? Chosen heuristically. + float fadeOutBorderFractionTexture = 0.1f; + float fadeOutBorderFractionTextureInnerEdge = 0.1f; + float fadeOutBorderFractionScreen = 0.1f; + float fadeOutFloor = 0.6f; // the floor controls how much black is in the fade region + + if (hmdRenderInfo.HmdType == HmdType_DK1) + { + fadeOutBorderFractionTexture = 0.3f; + fadeOutBorderFractionTextureInnerEdge = 0.075f; + fadeOutBorderFractionScreen = 0.075f; + fadeOutFloor = 0.25f; + } + + // Fade out at texture edges. + // The furthest out will be the blue channel, because of chromatic aberration (true of any standard lens) + Vector2f sourceTexCoordBlueNDC = TransformTanFovSpaceToRendertargetNDC ( eyeToSourceNDC, tanEyeAnglesB ); + if (rightEye) + { + // The inner edge of the eye texture is usually much more magnified, because it's right against the middle of the screen, not the FOV edge. + // So we want a different scaling factor for that. This code flips the texture NDC so that +1.0 is the inner edge + sourceTexCoordBlueNDC.x = -sourceTexCoordBlueNDC.x; + } + float edgeFadeIn = ( 1.0f / fadeOutBorderFractionTextureInnerEdge ) * ( 1.0f - sourceTexCoordBlueNDC.x ) ; // Inner + edgeFadeIn = Alg::Min ( edgeFadeIn, ( 1.0f / fadeOutBorderFractionTexture ) * ( 1.0f + sourceTexCoordBlueNDC.x ) ); // Outer + edgeFadeIn = Alg::Min ( edgeFadeIn, ( 1.0f / fadeOutBorderFractionTexture ) * ( 1.0f - sourceTexCoordBlueNDC.y ) ); // Upper + edgeFadeIn = Alg::Min ( edgeFadeIn, ( 1.0f / fadeOutBorderFractionTexture ) * ( 1.0f + sourceTexCoordBlueNDC.y ) ); // Lower + + // Also fade out at screen edges. Since this is in pixel space, no need to do inner specially. + float edgeFadeInScreen = ( 1.0f / fadeOutBorderFractionScreen ) * + ( 1.0f - Alg::Max ( Alg::Abs ( screenNDC.x ), Alg::Abs ( screenNDC.y ) ) ); + edgeFadeIn = Alg::Min ( edgeFadeInScreen, edgeFadeIn ) + fadeOutFloor; + + // Note - this is NOT clamped negatively. + // For rendering methods that interpolate over a coarse grid, we need the values to go negative for correct intersection with zero. + result.Shade = Alg::Min ( edgeFadeIn, 1.0f ); + result.ScreenPosNDC.x = 0.5f * screenNDC.x - 0.5f + xOffset; + result.ScreenPosNDC.y = -screenNDC.y; + + return result; +} + + +void DistortionMeshDestroy ( DistortionMeshVertexData *pVertices, uint16_t *pTriangleMeshIndices ) +{ + OVR_FREE ( pVertices ); + OVR_FREE ( pTriangleMeshIndices ); +} + +void DistortionMeshCreate ( DistortionMeshVertexData **ppVertices, uint16_t **ppTriangleListIndices, + int *pNumVertices, int *pNumTriangles, + const StereoEyeParams &stereoParams, const HmdRenderInfo &hmdRenderInfo ) +{ + bool rightEye = ( stereoParams.Eye == StereoEye_Right ); + int vertexCount = 0; + int triangleCount = 0; + + // Generate mesh into allocated data and return result. + DistortionMeshCreate(ppVertices, ppTriangleListIndices, &vertexCount, &triangleCount, + rightEye, hmdRenderInfo, stereoParams.Distortion, stereoParams.EyeToSourceNDC); + + *pNumVertices = vertexCount; + *pNumTriangles = triangleCount; +} + + +// Generate distortion mesh for a eye. +void DistortionMeshCreate( DistortionMeshVertexData **ppVertices, uint16_t **ppTriangleListIndices, + int *pNumVertices, int *pNumTriangles, + bool rightEye, + const HmdRenderInfo &hmdRenderInfo, + const DistortionRenderDesc &distortion, const ScaleAndOffset2D &eyeToSourceNDC ) +{ + *pNumVertices = DMA_NumVertsPerEye; + *pNumTriangles = DMA_NumTrisPerEye; + + *ppVertices = (DistortionMeshVertexData*) + OVR_ALLOC( sizeof(DistortionMeshVertexData) * (*pNumVertices) ); + *ppTriangleListIndices = (uint16_t*) OVR_ALLOC( sizeof(uint16_t) * (*pNumTriangles) * 3 ); + + if (!*ppVertices || !*ppTriangleListIndices) + { + if (*ppVertices) + { + OVR_FREE(*ppVertices); + } + if (*ppTriangleListIndices) + { + OVR_FREE(*ppTriangleListIndices); + } + *ppVertices = NULL; + *ppTriangleListIndices = NULL; + *pNumTriangles = 0; + *pNumVertices = 0; + return; + } + + + + // Populate vertex buffer info + + // First pass - build up raw vertex data. + DistortionMeshVertexData* pcurVert = *ppVertices; + + for ( int y = 0; y <= DMA_GridSize; y++ ) + { + for ( int x = 0; x <= DMA_GridSize; x++ ) + { + + Vector2f sourceCoordNDC; + // NDC texture coords [-1,+1] + sourceCoordNDC.x = 2.0f * ( (float)x / (float)DMA_GridSize ) - 1.0f; + sourceCoordNDC.y = 2.0f * ( (float)y / (float)DMA_GridSize ) - 1.0f; + Vector2f tanEyeAngle = TransformRendertargetNDCToTanFovSpace ( eyeToSourceNDC, sourceCoordNDC ); + + // Find a corresponding screen position. + // Note - this function does not have to be precise - we're just trying to match the mesh tessellation + // with the shape of the distortion to minimise the number of trianlges needed. + Vector2f screenNDC = TransformTanFovSpaceToScreenNDC ( distortion, tanEyeAngle, false ); + // ...but don't let verts overlap to the other eye. + screenNDC.x = Alg::Max ( -1.0f, Alg::Min ( screenNDC.x, 1.0f ) ); + screenNDC.y = Alg::Max ( -1.0f, Alg::Min ( screenNDC.y, 1.0f ) ); + + // From those screen positions, generate the vertex. + *pcurVert = DistortionMeshMakeVertex ( screenNDC, rightEye, hmdRenderInfo, distortion, eyeToSourceNDC ); + pcurVert++; + } + } + + + // Populate index buffer info + uint16_t *pcurIndex = *ppTriangleListIndices; + + for ( int triNum = 0; triNum < DMA_GridSize * DMA_GridSize; triNum++ ) + { + // Use a Morton order to help locality of FB, texture and vertex cache. + // (0.325ms raster order -> 0.257ms Morton order) + OVR_ASSERT ( DMA_GridSize <= 256 ); + int x = ( ( triNum & 0x0001 ) >> 0 ) | + ( ( triNum & 0x0004 ) >> 1 ) | + ( ( triNum & 0x0010 ) >> 2 ) | + ( ( triNum & 0x0040 ) >> 3 ) | + ( ( triNum & 0x0100 ) >> 4 ) | + ( ( triNum & 0x0400 ) >> 5 ) | + ( ( triNum & 0x1000 ) >> 6 ) | + ( ( triNum & 0x4000 ) >> 7 ); + int y = ( ( triNum & 0x0002 ) >> 1 ) | + ( ( triNum & 0x0008 ) >> 2 ) | + ( ( triNum & 0x0020 ) >> 3 ) | + ( ( triNum & 0x0080 ) >> 4 ) | + ( ( triNum & 0x0200 ) >> 5 ) | + ( ( triNum & 0x0800 ) >> 6 ) | + ( ( triNum & 0x2000 ) >> 7 ) | + ( ( triNum & 0x8000 ) >> 8 ); + int FirstVertex = x * (DMA_GridSize+1) + y; + // Another twist - we want the top-left and bottom-right quadrants to + // have the triangles split one way, the other two split the other. + // +---+---+---+---+ + // | /| /|\ |\ | + // | / | / | \ | \ | + // |/ |/ | \| \| + // +---+---+---+---+ + // | /| /|\ |\ | + // | / | / | \ | \ | + // |/ |/ | \| \| + // +---+---+---+---+ + // |\ |\ | /| /| + // | \ | \ | / | / | + // | \| \|/ |/ | + // +---+---+---+---+ + // |\ |\ | /| /| + // | \ | \ | / | / | + // | \| \|/ |/ | + // +---+---+---+---+ + // This way triangle edges don't span long distances over the distortion function, + // so linear interpolation works better & we can use fewer tris. + if ( ( x < DMA_GridSize/2 ) != ( y < DMA_GridSize/2 ) ) // != is logical XOR + { + *pcurIndex++ = (uint16_t)FirstVertex; + *pcurIndex++ = (uint16_t)FirstVertex+1; + *pcurIndex++ = (uint16_t)FirstVertex+(DMA_GridSize+1)+1; + + *pcurIndex++ = (uint16_t)FirstVertex+(DMA_GridSize+1)+1; + *pcurIndex++ = (uint16_t)FirstVertex+(DMA_GridSize+1); + *pcurIndex++ = (uint16_t)FirstVertex; + } + else + { + *pcurIndex++ = (uint16_t)FirstVertex; + *pcurIndex++ = (uint16_t)FirstVertex+1; + *pcurIndex++ = (uint16_t)FirstVertex+(DMA_GridSize+1); + + *pcurIndex++ = (uint16_t)FirstVertex+1; + *pcurIndex++ = (uint16_t)FirstVertex+(DMA_GridSize+1)+1; + *pcurIndex++ = (uint16_t)FirstVertex+(DMA_GridSize+1); + } + } +} + +//----------------------------------------------------------------------------------- +// ***** Heightmap Mesh Rendering + + +static const int HMA_GridSizeLog2 = 7; +static const int HMA_GridSize = 1<TanEyeAngles = tanEyeAngle; + + HmdShutterTypeEnum shutterType = hmdRenderInfo.Shutter.Type; + switch ( shutterType ) + { + case HmdShutter_Global: + pcurVert->TimewarpLerp = 0.0f; + break; + case HmdShutter_RollingLeftToRight: + // Retrace is left to right - left eye goes 0.0 -> 0.5, then right goes 0.5 -> 1.0 + pcurVert->TimewarpLerp = sourceCoordNDC.x * 0.25f + 0.25f; + if (rightEye) + { + pcurVert->TimewarpLerp += 0.5f; + } + break; + case HmdShutter_RollingRightToLeft: + // Retrace is right to left - right eye goes 0.0 -> 0.5, then left goes 0.5 -> 1.0 + pcurVert->TimewarpLerp = 0.75f - sourceCoordNDC.x * 0.25f; + if (rightEye) + { + pcurVert->TimewarpLerp -= 0.5f; + } + break; + case HmdShutter_RollingTopToBottom: + // Retrace is top to bottom on both eyes at the same time. + pcurVert->TimewarpLerp = sourceCoordNDC.y * 0.5f + 0.5f; + break; + default: OVR_ASSERT ( false ); break; + } + + // Don't let verts overlap to the other eye. + //sourceCoordNDC.x = Alg::Max ( -1.0f, Alg::Min ( sourceCoordNDC.x, 1.0f ) ); + //sourceCoordNDC.y = Alg::Max ( -1.0f, Alg::Min ( sourceCoordNDC.y, 1.0f ) ); + + //pcurVert->ScreenPosNDC.x = 0.5f * sourceCoordNDC.x - 0.5f + xOffset; + pcurVert->ScreenPosNDC.x = sourceCoordNDC.x; + pcurVert->ScreenPosNDC.y = -sourceCoordNDC.y; + + pcurVert++; + } + } + + + // Populate index buffer info + uint16_t *pcurIndex = *ppTriangleListIndices; + + for ( int triNum = 0; triNum < HMA_GridSize * HMA_GridSize; triNum++ ) + { + // Use a Morton order to help locality of FB, texture and vertex cache. + // (0.325ms raster order -> 0.257ms Morton order) + OVR_ASSERT ( HMA_GridSize < 256 ); + int x = ( ( triNum & 0x0001 ) >> 0 ) | + ( ( triNum & 0x0004 ) >> 1 ) | + ( ( triNum & 0x0010 ) >> 2 ) | + ( ( triNum & 0x0040 ) >> 3 ) | + ( ( triNum & 0x0100 ) >> 4 ) | + ( ( triNum & 0x0400 ) >> 5 ) | + ( ( triNum & 0x1000 ) >> 6 ) | + ( ( triNum & 0x4000 ) >> 7 ); + int y = ( ( triNum & 0x0002 ) >> 1 ) | + ( ( triNum & 0x0008 ) >> 2 ) | + ( ( triNum & 0x0020 ) >> 3 ) | + ( ( triNum & 0x0080 ) >> 4 ) | + ( ( triNum & 0x0200 ) >> 5 ) | + ( ( triNum & 0x0800 ) >> 6 ) | + ( ( triNum & 0x2000 ) >> 7 ) | + ( ( triNum & 0x8000 ) >> 8 ); + int FirstVertex = x * (HMA_GridSize+1) + y; + // Another twist - we want the top-left and bottom-right quadrants to + // have the triangles split one way, the other two split the other. + // +---+---+---+---+ + // | /| /|\ |\ | + // | / | / | \ | \ | + // |/ |/ | \| \| + // +---+---+---+---+ + // | /| /|\ |\ | + // | / | / | \ | \ | + // |/ |/ | \| \| + // +---+---+---+---+ + // |\ |\ | /| /| + // | \ | \ | / | / | + // | \| \|/ |/ | + // +---+---+---+---+ + // |\ |\ | /| /| + // | \ | \ | / | / | + // | \| \|/ |/ | + // +---+---+---+---+ + // This way triangle edges don't span long distances over the distortion function, + // so linear interpolation works better & we can use fewer tris. + if ( ( x < HMA_GridSize/2 ) != ( y < HMA_GridSize/2 ) ) // != is logical XOR + { + *pcurIndex++ = (uint16_t)FirstVertex; + *pcurIndex++ = (uint16_t)FirstVertex+1; + *pcurIndex++ = (uint16_t)FirstVertex+(HMA_GridSize+1)+1; + + *pcurIndex++ = (uint16_t)FirstVertex+(HMA_GridSize+1)+1; + *pcurIndex++ = (uint16_t)FirstVertex+(HMA_GridSize+1); + *pcurIndex++ = (uint16_t)FirstVertex; + } + else + { + *pcurIndex++ = (uint16_t)FirstVertex; + *pcurIndex++ = (uint16_t)FirstVertex+1; + *pcurIndex++ = (uint16_t)FirstVertex+(HMA_GridSize+1); + + *pcurIndex++ = (uint16_t)FirstVertex+1; + *pcurIndex++ = (uint16_t)FirstVertex+(HMA_GridSize+1)+1; + *pcurIndex++ = (uint16_t)FirstVertex+(HMA_GridSize+1); + } + } +} + +//----------------------------------------------------------------------------------- +// ***** Prediction and timewarp. +// + +// Calculates the values from the HMD info. +PredictionValues PredictionGetDeviceValues ( const HmdRenderInfo &hmdRenderInfo, + bool withTimewarp /*= true*/, + bool withVsync /*= true*/ ) +{ + PredictionValues result; + + result.WithTimewarp = withTimewarp; + result.WithVsync = withVsync; + + // For unclear reasons, most graphics systems add an extra frame of latency + // somewhere along the way. In time we'll debug this and figure it out, but + // for now this gets prediction a little bit better. + const float extraFramesOfBufferingKludge = 1.0f; + + if ( withVsync ) + { + // These are the times from the Present+Flush to when the middle of the scene is "averagely visible" (without timewarp) + // So if you had no timewarp, this, plus the time until the next vsync, is how much to predict by. + result.PresentFlushToRenderedScene = extraFramesOfBufferingKludge * hmdRenderInfo.Shutter.FirstScanlineToLastScanline; + // Predict to the middle of the screen being scanned out. + result.PresentFlushToRenderedScene += hmdRenderInfo.Shutter.VsyncToFirstScanline + 0.5f * hmdRenderInfo.Shutter.FirstScanlineToLastScanline; + // Time for pixels to get half-way to settling. + result.PresentFlushToRenderedScene += hmdRenderInfo.Shutter.PixelSettleTime * 0.5f; + // Predict to half-way through persistence + result.PresentFlushToRenderedScene += hmdRenderInfo.Shutter.PixelPersistence * 0.5f; + + // The time from the Present+Flush to when the first scanline is "averagely visible". + result.PresentFlushToTimewarpStart = extraFramesOfBufferingKludge * hmdRenderInfo.Shutter.FirstScanlineToLastScanline; + // Predict to the first line being scanned out. + result.PresentFlushToTimewarpStart += hmdRenderInfo.Shutter.VsyncToFirstScanline; + // Time for pixels to get half-way to settling. + result.PresentFlushToTimewarpStart += hmdRenderInfo.Shutter.PixelSettleTime * 0.5f; + // Predict to half-way through persistence + result.PresentFlushToTimewarpStart += hmdRenderInfo.Shutter.PixelPersistence * 0.5f; + + // Time to the the last scanline. + result.PresentFlushToTimewarpEnd = result.PresentFlushToTimewarpStart + hmdRenderInfo.Shutter.FirstScanlineToLastScanline; + + // Ideal framerate. + result.PresentFlushToPresentFlush = hmdRenderInfo.Shutter.VsyncToNextVsync; + } + else + { + // Timewarp without vsync is a little odd. + // Currently, we assume that without vsync, we have no idea which scanline + // is currently being sent to the display. So we can't do lerping timewarp, + // we can just do a full-screen late-stage fixup. + + // "PresentFlushToRenderedScene" means the time from the Present+Flush to when the middle of the scene is "averagely visible" (without timewarp) + // So if you had no timewarp, this, plus the time until the next flush (which is usually the time to render the frame), is how much to predict by. + // Time for pixels to get half-way to settling. + result.PresentFlushToRenderedScene = hmdRenderInfo.Shutter.PixelSettleTime * 0.5f; + // Predict to half-way through persistence + result.PresentFlushToRenderedScene += hmdRenderInfo.Shutter.PixelPersistence * 0.5f; + + // Without vsync, you don't know timings, and so can't do anything useful with lerped warping. + result.PresentFlushToTimewarpStart = result.PresentFlushToRenderedScene; + result.PresentFlushToTimewarpEnd = result.PresentFlushToRenderedScene; + + // There's no concept of "ideal" when vsync is off. + result.PresentFlushToPresentFlush = 0.0f; + } + + return result; +} + +Matrix4f TimewarpComputePoseDelta ( Matrix4f const &renderedViewFromWorld, Matrix4f const &predictedViewFromWorld, Matrix4f const&hmdToEyeViewOffset ) +{ + Matrix4f worldFromPredictedView = (hmdToEyeViewOffset * predictedViewFromWorld).InvertedHomogeneousTransform(); + Matrix4f matRenderFromNowStart = (hmdToEyeViewOffset * renderedViewFromWorld) * worldFromPredictedView; + + // The sensor-predicted orientations have: X=right, Y=up, Z=backwards. + // The vectors inside the mesh are in NDC to keep the shader simple: X=right, Y=down, Z=forwards. + // So we need to perform a similarity transform on this delta matrix. + // The verbose code would look like this: + /* + Matrix4f matBasisChange; + matBasisChange.SetIdentity(); + matBasisChange.M[0][0] = 1.0f; + matBasisChange.M[1][1] = -1.0f; + matBasisChange.M[2][2] = -1.0f; + Matrix4f matBasisChangeInv = matBasisChange.Inverted(); + matRenderFromNow = matBasisChangeInv * matRenderFromNow * matBasisChange; + */ + // ...but of course all the above is a constant transform and much more easily done. + // We flip the signs of the Y&Z row, then flip the signs of the Y&Z column, + // and of course most of the flips cancel: + // +++ +-- +-- + // +++ -> flip Y&Z columns -> +-- -> flip Y&Z rows -> -++ + // +++ +-- -++ + matRenderFromNowStart.M[0][1] = -matRenderFromNowStart.M[0][1]; + matRenderFromNowStart.M[0][2] = -matRenderFromNowStart.M[0][2]; + matRenderFromNowStart.M[1][0] = -matRenderFromNowStart.M[1][0]; + matRenderFromNowStart.M[2][0] = -matRenderFromNowStart.M[2][0]; + matRenderFromNowStart.M[1][3] = -matRenderFromNowStart.M[1][3]; + matRenderFromNowStart.M[2][3] = -matRenderFromNowStart.M[2][3]; + + return matRenderFromNowStart; +} + +Matrix4f TimewarpComputePoseDeltaPosition ( Matrix4f const &renderedViewFromWorld, Matrix4f const &predictedViewFromWorld, Matrix4f const&hmdToEyeViewOffset ) +{ + Matrix4f worldFromPredictedView = (hmdToEyeViewOffset * predictedViewFromWorld).InvertedHomogeneousTransform(); + Matrix4f matRenderXform = (hmdToEyeViewOffset * renderedViewFromWorld) * worldFromPredictedView; + + return matRenderXform.Inverted(); +} + +TimewarpMachine::TimewarpMachine() + : VsyncEnabled(false), + RenderInfo(), + CurrentPredictionValues(), + DistortionTimeCount(0), + DistortionTimeCurrentStart(0.0), + //DistortionTimes[], + DistortionTimeAverage(0.f), + //EyeRenderPoses[], + LastFramePresentFlushTime(0.0), + PresentFlushToPresentFlushSeconds(0.f), + NextFramePresentFlushTime(0.0) +{ + #if defined(OVR_BUILD_DEBUG) + memset(DistortionTimes, 0, sizeof(DistortionTimes)); + #endif + + for ( int i = 0; i < 2; i++ ) + { + EyeRenderPoses[i] = Posef(); + } +} + +void TimewarpMachine::Reset(HmdRenderInfo& renderInfo, bool vsyncEnabled, double timeNow) +{ + RenderInfo = renderInfo; + VsyncEnabled = vsyncEnabled; + CurrentPredictionValues = PredictionGetDeviceValues ( renderInfo, true, VsyncEnabled ); + PresentFlushToPresentFlushSeconds = 0.0f; + DistortionTimeCount = 0; + DistortionTimeAverage = 0.0f; + LastFramePresentFlushTime = timeNow; + AfterPresentAndFlush(timeNow); +} + +void TimewarpMachine::AfterPresentAndFlush(double timeNow) +{ + AfterPresentWithoutFlush(); + AfterPresentFinishes ( timeNow ); +} + +void TimewarpMachine::AfterPresentWithoutFlush() +{ + // We've only issued the Present - it hasn't actually finished (i.e. appeared) + // But we need to estimate when the next Present will appear, so extrapolate from previous data. + NextFramePresentFlushTime = LastFramePresentFlushTime + 2.0 * (double)PresentFlushToPresentFlushSeconds; +} + +void TimewarpMachine::AfterPresentFinishes(double timeNow) +{ + // The present has now actually happened. + PresentFlushToPresentFlushSeconds = (float)(timeNow - LastFramePresentFlushTime); + LastFramePresentFlushTime = timeNow; + NextFramePresentFlushTime = timeNow + (double)PresentFlushToPresentFlushSeconds; +} + + + +double TimewarpMachine::GetViewRenderPredictionTime() +{ + // Note that PredictionGetDeviceValues() did all the vsync-dependent thinking for us. + return NextFramePresentFlushTime + CurrentPredictionValues.PresentFlushToRenderedScene; +} + +bool TimewarpMachine::GetViewRenderPredictionPose(SensorStateReader* reader, Posef& pose) +{ + return reader->GetPoseAtTime(GetViewRenderPredictionTime(), pose); +} + +double TimewarpMachine::GetVisiblePixelTimeStart() +{ + // Note that PredictionGetDeviceValues() did all the vsync-dependent thinking for us. + return NextFramePresentFlushTime + CurrentPredictionValues.PresentFlushToTimewarpStart; +} +double TimewarpMachine::GetVisiblePixelTimeEnd() +{ + // Note that PredictionGetDeviceValues() did all the vsync-dependent thinking for us. + return NextFramePresentFlushTime + CurrentPredictionValues.PresentFlushToTimewarpEnd; +} +bool TimewarpMachine::GetPredictedVisiblePixelPoseStart(SensorStateReader* reader, Posef& pose) +{ + return reader->GetPoseAtTime(GetVisiblePixelTimeStart(), pose); +} +bool TimewarpMachine::GetPredictedVisiblePixelPoseEnd(SensorStateReader* reader, Posef& pose) +{ + return reader->GetPoseAtTime(GetVisiblePixelTimeEnd(), pose); +} +bool TimewarpMachine::GetTimewarpDeltaStart(SensorStateReader* reader, Posef const &renderedPose, Matrix4f& transform) +{ + Posef visiblePose; + if (!GetPredictedVisiblePixelPoseStart(reader, visiblePose)) + { + return false; + } + + Matrix4f visibleMatrix(visiblePose); + Matrix4f renderedMatrix(renderedPose); + Matrix4f identity; // doesn't matter for orientation-only timewarp + transform = TimewarpComputePoseDelta ( renderedMatrix, visibleMatrix, identity ); + + return true; +} +bool TimewarpMachine::GetTimewarpDeltaEnd(SensorStateReader* reader, Posef const &renderedPose, Matrix4f& transform) +{ + Posef visiblePose; + if (!GetPredictedVisiblePixelPoseEnd(reader, visiblePose)) + { + return false; + } + + Matrix4f visibleMatrix(visiblePose); + Matrix4f renderedMatrix(renderedPose); + Matrix4f identity; // doesn't matter for orientation-only timewarp + transform = TimewarpComputePoseDelta ( renderedMatrix, visibleMatrix, identity ); + + return true; +} + + +// What time should the app wait until before starting distortion? +double TimewarpMachine::JustInTime_GetDistortionWaitUntilTime() +{ + if ( !VsyncEnabled || ( DistortionTimeCount < NumDistortionTimes ) ) + { + // Don't wait. + return LastFramePresentFlushTime; + } + + // Note - 1-2ms fudge factor (because Windows timer granularity etc) is NOT added here, + // because otherwise you end up adding multiple fudge factors! + // So it's left for the calling app to add just one fudge factor. + + float howLongBeforePresent = DistortionTimeAverage; + // Subtlety here. Technically, the correct time is NextFramePresentFlushTime - howLongBeforePresent. + // However, if the app drops a frame, this then perpetuates it, + // i.e. if the display is running at 60fps, but the last frame was slow, + // (e.g. because of swapping or whatever), then NextFramePresentFlushTime is + // 33ms in the future, not 16ms. Since this function supplies the + // time to wait until, the app will indeed wait until 32ms, so the framerate + // drops to 30fps and never comes back up! + // So we return the *ideal* framerate, not the *actual* framerate. + return LastFramePresentFlushTime + (float)( CurrentPredictionValues.PresentFlushToPresentFlush - howLongBeforePresent ); +} + +double TimewarpMachine::JustInTime_AverageDistortionTime() +{ + if ( JustInTime_NeedDistortionTimeMeasurement() ) + { + return 0.0; + } + return DistortionTimeAverage; +} + +bool TimewarpMachine::JustInTime_NeedDistortionTimeMeasurement() const +{ + if (!VsyncEnabled) + { + return false; + } + return ( DistortionTimeCount < NumDistortionTimes ); +} + +void TimewarpMachine::JustInTime_BeforeDistortionTimeMeasurement(double timeNow) +{ + DistortionTimeCurrentStart = timeNow; +} + +void TimewarpMachine::JustInTime_AfterDistortionTimeMeasurement(double timeNow) +{ + float timeDelta = (float)( timeNow - DistortionTimeCurrentStart ); + if ( DistortionTimeCount < NumDistortionTimes ) + { + DistortionTimes[DistortionTimeCount] = timeDelta; + DistortionTimeCount++; + if ( DistortionTimeCount == NumDistortionTimes ) + { + // Median. + float distortionTimeMedian = 0.0f; + for ( int i = 0; i < NumDistortionTimes/2; i++ ) + { + // Find the maximum time of those remaining. + float maxTime = DistortionTimes[0]; + int maxIndex = 0; + for ( int j = 1; j < NumDistortionTimes; j++ ) + { + if ( maxTime < DistortionTimes[j] ) + { + maxTime = DistortionTimes[j]; + maxIndex = j; + } + } + // Zero that max time, so we'll find the next-highest time. + DistortionTimes[maxIndex] = 0.0f; + distortionTimeMedian = maxTime; + } + DistortionTimeAverage = distortionTimeMedian; + } + } + else + { + OVR_ASSERT ( !"Really didn't need more measurements, thanks" ); + } +} + + +}}} // OVR::Util::Render + diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Util/Util_Render_Stereo.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Util/Util_Render_Stereo.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,500 @@ +/************************************************************************************ + +Filename : Util_Render_Stereo.h +Content : Sample stereo rendering configuration classes. +Created : October 22, 2012 +Authors : Michael Antonov, Tom Forsyth + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +*************************************************************************************/ + +#ifndef OVR_Util_Render_Stereo_h +#define OVR_Util_Render_Stereo_h + +#include "../OVR_Stereo.h" +#include "../Tracking/Tracking_SensorStateReader.h" + +namespace OVR { namespace Util { namespace Render { + + + +//----------------------------------------------------------------------------------- +// **** Useful debug functions. +// +// Purely for debugging - the results are not very end-user-friendly. +char const* GetDebugNameEyeCupType ( EyeCupType eyeCupType ); +char const* GetDebugNameHmdType ( HmdTypeEnum hmdType ); + + + +//----------------------------------------------------------------------------------- +// **** Higher-level utility functions. + +Sizei CalculateRecommendedTextureSize ( HmdRenderInfo const &hmd, + bool bRendertargetSharedByBothEyes, + float pixelDensityInCenter = 1.0f ); + +FovPort CalculateRecommendedFov ( HmdRenderInfo const &hmd, + StereoEye eyeType, + bool bMakeFovSymmetrical = false); + +StereoEyeParams CalculateStereoEyeParams ( HmdRenderInfo const &hmd, + StereoEye eyeType, + Sizei const &actualRendertargetSurfaceSize, + bool bRendertargetSharedByBothEyes, + bool bRightHanded = true, + float zNear = 0.01f, float zFar = 10000.0f, + Sizei const *pOverrideRenderedPixelSize = NULL, + FovPort const *pOverrideFovport = NULL, + float zoomFactor = 1.0f ); + +Vector3f CalculateEyeVirtualCameraOffset(HmdRenderInfo const &hmd, + StereoEye eyeType, bool bMonoRenderingMode ); + + +// These are two components from StereoEyeParams that can be changed +// very easily without full recomputation of everything. +struct ViewportScaleAndOffset +{ + Recti RenderedViewport; + ScaleAndOffset2D EyeToSourceUV; +}; + +// Three ways to override the size of the render view dynamically. +// None of these require changing the distortion parameters or the regenerating the distortion mesh, +// and can be called every frame if desired. +ViewportScaleAndOffset ModifyRenderViewport ( StereoEyeParams const ¶ms, + Sizei const &actualRendertargetSurfaceSize, + Recti const &renderViewport ); + +ViewportScaleAndOffset ModifyRenderSize ( StereoEyeParams const ¶ms, + Sizei const &actualRendertargetSurfaceSize, + Sizei const &requestedRenderSize, + bool bRendertargetSharedByBothEyes = false ); + +ViewportScaleAndOffset ModifyRenderDensity ( StereoEyeParams const ¶ms, + Sizei const &actualRendertargetSurfaceSize, + float pixelDensity = 1.0f, + bool bRendertargetSharedByBothEyes = false ); + + +//----------------------------------------------------------------------------------- +// ***** StereoConfig + +// StereoConfig maintains a scene stereo state and allow switching between different +// stereo rendering modes. To support rendering, StereoConfig keeps track of HMD +// variables such as screen size, eye-to-screen distance and distortion, and computes +// extra data such as FOV and distortion center offsets based on it. Rendering +// parameters are returned though StereoEyeParams for each eye. +// +// Beyond regular 3D projection, this class supports rendering a 2D orthographic +// surface for UI and text. The 2D surface will be defined by CreateOrthoSubProjection(). +// The (0,0) coordinate corresponds to eye center location. +// +// Applications are not required to use this class, but they should be doing very +// similar sequences of operations, and it may be useful to start with this class +// and modify it. + +struct StereoEyeParamsWithOrtho +{ + StereoEyeParams StereoEye; + Matrix4f OrthoProjection; +}; + +struct ViewportScaleAndOffsetBothEyes +{ + ViewportScaleAndOffset Left; + ViewportScaleAndOffset Right; +}; + +class StereoConfig +{ +public: + + // StereoMode describes rendering modes that can be used by StereoConfig. + // These modes control whether stereo rendering is used or not (Stereo_None), + // and how it is implemented. + enum StereoMode + { + Stereo_None = 0, // Single eye + Stereo_LeftRight_Multipass = 1, // One frustum per eye + }; + + + StereoConfig(StereoMode mode = Stereo_LeftRight_Multipass); + + //--------------------------------------------------------------------------------------------- + // *** Core functions - every app MUST call these functions at least once. + + // Sets HMD parameters; also initializes distortion coefficients. + void SetHmdRenderInfo(const HmdRenderInfo& hmd); + + // Set the physical size of the rendertarget surface the app created, + // and whether one RT is shared by both eyes, or each eye has its own RT: + // true: both eyes are rendered to the same RT. Left eye starts at top-left, right eye starts at top-middle. + // false: each eye is rendered to its own RT. Some GPU architectures prefer this arrangement. + // Typically, the app would call CalculateRecommendedTextureSize() to suggest the choice of RT size. + // This setting must be exactly the size of the actual RT created, or the UVs produced will be incorrect. + // If the app wants to render to a subsection of the RT, it should use SetRenderSize() + void SetRendertargetSize (Size const rendertargetSize, + bool rendertargetIsSharedByBothEyes ); + + // Returns full set of Stereo rendering parameters for the specified eye. + const StereoEyeParamsWithOrtho& GetEyeRenderParams(StereoEye eye); + + + + //--------------------------------------------------------------------------------------------- + // *** Optional functions - an app may call these to override default behaviours. + + const HmdRenderInfo& GetHmdRenderInfo() const { return Hmd; } + + // Returns the recommended size of rendertargets. + // If rendertargetIsSharedByBothEyes is true, this is the size of the combined buffer. + // If rendertargetIsSharedByBothEyes is false, this is the size of each individual buffer. + // pixelDensityInCenter may be set to any number - by default it will match the HMD resolution in the center of the image. + // After creating the rendertargets, the application MUST call SetRendertargetSize() with the actual size created + // (which can be larger or smaller as the app wishes, but StereoConfig needs to know either way) + Sizei CalculateRecommendedTextureSize ( bool rendertargetSharedByBothEyes, + float pixelDensityInCenter = 1.0f ); + + // Sets a stereo rendering mode and updates internal cached + // state (matrices, per-eye view) based on it. + void SetStereoMode(StereoMode mode) { Mode = mode; DirtyFlag = true; } + StereoMode GetStereoMode() const { return Mode; } + + // Sets the fieldOfView that the 2D coordinate area stretches to. + void Set2DAreaFov(float fovRadians); + + // Really only for science experiments - no normal app should ever need to override + // the HMD's lens descriptors. Passing NULL removes the override. + // Supply both = set left and right. + // Supply just left = set both to the same. + // Supply neither = remove override. + void SetLensOverride ( LensConfig const *pLensOverrideLeft = NULL, + LensConfig const *pLensOverrideRight = NULL ); + + // Override the rendered FOV in various ways. All angles in tangent units. + // This is not clamped to the physical FOV of the display - you'll need to do that yourself! + // Supply both = set left and right. + // Supply just left = set both to the same. + // Supply neither = remove override. + void SetFov ( FovPort const *pfovLeft = NULL, + FovPort const *pfovRight = NULL ); + + void SetFovPortRadians ( float horizontal, float vertical ) + { + FovPort fov = FovPort::CreateFromRadians(horizontal, vertical); + SetFov( &fov, &fov ); + } + + + // This forces a "zero IPD" mode where there is just a single render with an FOV that + // is the union of the two calculated FOVs. + // The calculated render is for the left eye. Any size & FOV overrides for the right + // eye will be ignored. + // If you query the right eye's size, you will get the same render + // size & position as the left eye - you should not actually do the render of course! + // The distortion values will be different, because it goes to a different place on the framebuffer. + // Note that if you do this, the rendertarget does not need to be twice the width of + // the render size any more. + void SetZeroVirtualIpdOverride ( bool enableOverride ); + + // Allows the app to specify near and far clip planes and the right/left-handedness of the projection matrix. + void SetZClipPlanesAndHandedness ( float zNear = 0.01f, float zFar = 10000.0f, + bool rightHandedProjection = true ); + + // Allows the app to specify how much extra eye rotation to allow when determining the visible FOV. + void SetExtraEyeRotation ( float extraEyeRotationInRadians = 0.0f ); + + // The dirty flag is set by any of the above calls. Just handy for the app to know + // if e.g. the distortion mesh needs regeneration. + void SetDirty() { DirtyFlag = true; } + bool IsDirty() { return DirtyFlag; } + + // An app never needs to call this - GetEyeRenderParams will call it internally if + // the state is dirty. However apps can call this explicitly to control when and where + // computation is performed (e.g. not inside critical loops) + void UpdateComputedState(); + + // This returns the projection matrix with a "zoom". Does not modify any internal state. + Matrix4f GetProjectionWithZoom ( StereoEye eye, float fovZoom ) const; + + + //--------------------------------------------------------------------------------------------- + // The SetRender* functions are special. + // + // They do not require a full recalculation of state, and they do not change anything but the + // ViewportScaleAndOffset data for the eyes (which they return), and do not set the dirty flag! + // This means they can be called without regenerating the distortion mesh, and thus + // can happily be called every frame without causing performance problems. Dynamic rescaling + // of the rendertarget can help keep framerate up in demanding VR applications. + // See the documentation for more details on their use. + + // Specify a pixel density - how many rendered pixels per pixel in the physical display. + ViewportScaleAndOffsetBothEyes SetRenderDensity ( float pixelsPerDisplayPixel ); + + // Supply the size directly. Will be clamped to the physical rendertarget size. + ViewportScaleAndOffsetBothEyes SetRenderSize ( Sizei const &renderSizeLeft, Sizei const &renderSizeRight ); + + // Supply the viewport directly. This is not clamped to the physical rendertarget - careful now! + ViewportScaleAndOffsetBothEyes SetRenderViewport ( Recti const &renderViewportLeft, Recti const &renderViewportRight ); + +private: + + // *** Modifiable State + + StereoMode Mode; + HmdRenderInfo Hmd; + + float Area2DFov; // FOV range mapping to the 2D area. + + // Only one of these three overrides can be true! + enum SetViewportModeEnum + { + SVPM_Density, + SVPM_Size, + SVPM_Viewport, + } SetViewportMode; + // ...and depending which it is, one of the following are used. + float SetViewportPixelsPerDisplayPixel; + Sizei SetViewportSize[2]; + Recti SetViewport[2]; + + // Other overrides. + bool OverrideLens; + LensConfig LensOverrideLeft; + LensConfig LensOverrideRight; + Sizei RendertargetSize; + bool OverrideTanHalfFov; + FovPort FovOverrideLeft; + FovPort FovOverrideRight; + bool OverrideZeroIpd; + float ZNear; + float ZFar; + float ExtraEyeRotationInRadians; + bool IsRendertargetSharedByBothEyes; + bool RightHandedProjection; + + bool DirtyFlag; // Set when any if the modifiable state changed. Does NOT get set by SetRender*() + + // Utility function. + ViewportScaleAndOffsetBothEyes setupViewportScaleAndOffsets(); + + // *** Computed State + +public: // Small hack for the config tool. Normal code should never read EyeRenderParams directly - use GetEyeRenderParams() instead. + // 0/1 = left/right main views. + StereoEyeParamsWithOrtho EyeRenderParams[2]; +}; + + +//----------------------------------------------------------------------------------- +// ***** Distortion Mesh Rendering +// + +// Stores both texture UV coords, or tan(angle) values. +// Use whichever set of data the specific distortion algorithm requires. +// This struct *must* be binary compatible with CAPI ovrDistortionVertex. +struct DistortionMeshVertexData +{ + // [-1,+1],[-1,+1] over the entire framebuffer. + Vector2f ScreenPosNDC; + // [0.0-1.0] interpolation value for timewarping - see documentation for details. + float TimewarpLerp; + // [0.0-1.0] fade-to-black at the edges to reduce peripheral vision noise. + float Shade; + // The red, green, and blue vectors in tan(angle) space. + // Scale and offset by the values in StereoEyeParams.EyeToSourceUV.Scale + // and StereoParams.EyeToSourceUV.Offset to get to real texture UV coords. + Vector2f TanEyeAnglesR; + Vector2f TanEyeAnglesG; + Vector2f TanEyeAnglesB; +}; + +// If you just want a single point on the screen transformed. +DistortionMeshVertexData DistortionMeshMakeVertex ( Vector2f screenNDC, + bool rightEye, + const HmdRenderInfo &hmdRenderInfo, + const DistortionRenderDesc &distortion, const ScaleAndOffset2D &eyeToSourceNDC ); + +void DistortionMeshCreate ( DistortionMeshVertexData **ppVertices, uint16_t **ppTriangleListIndices, + int *pNumVertices, int *pNumTriangles, + const StereoEyeParams &stereoParams, const HmdRenderInfo &hmdRenderInfo ); + +// Generate distortion mesh for a eye. +// This version requires less data then stereoParms, supporting dynamic change in render target viewport. +void DistortionMeshCreate( DistortionMeshVertexData **ppVertices, uint16_t **ppTriangleListIndices, + int *pNumVertices, int *pNumTriangles, + bool rightEye, + const HmdRenderInfo &hmdRenderInfo, + const DistortionRenderDesc &distortion, const ScaleAndOffset2D &eyeToSourceNDC ); + +void DistortionMeshDestroy ( DistortionMeshVertexData *pVertices, uint16_t *pTriangleMeshIndices ); + + +//----------------------------------------------------------------------------------- +// ***** Heightmap Mesh Rendering +// + +// Stores both texture UV coords, or tan(angle) values. +// This struct *must* be binary compatible with CAPI ovrHeightmapVertex. +struct HeightmapMeshVertexData +{ + // [-1,+1],[-1,+1] over the entire framebuffer. + Vector2f ScreenPosNDC; + // [0.0-1.0] interpolation value for timewarping - see documentation for details. + float TimewarpLerp; + // The vectors in tan(angle) space. + // Scale and offset by the values in StereoEyeParams.EyeToSourceUV.Scale + // and StereoParams.EyeToSourceUV.Offset to get to real texture UV coords. + Vector2f TanEyeAngles; +}; + + +void HeightmapMeshCreate ( HeightmapMeshVertexData **ppVertices, uint16_t **ppTriangleListIndices, + int *pNumVertices, int *pNumTriangles, + const StereoEyeParams &stereoParams, const HmdRenderInfo &hmdRenderInfo ); + +// Generate heightmap mesh for a eye. This version requires less data then stereoParms, supporting +// dynamic change in render target viewport. +void HeightmapMeshCreate( HeightmapMeshVertexData **ppVertices, uint16_t **ppTriangleListIndices, + int *pNumVertices, int *pNumTriangles, bool rightEye, + const HmdRenderInfo &hmdRenderInfo, const ScaleAndOffset2D &eyeToSourceNDC ); + +void HeightmapMeshDestroy ( HeightmapMeshVertexData *pVertices, uint16_t *pTriangleMeshIndices ); + + + +//----------------------------------------------------------------------------------- +// ***** Prediction and timewarp. +// + +struct PredictionValues +{ + // All values in seconds. + // These are the times in seconds from a present+flush to the relevant display element. + // The time is measured to the middle of that element's visibility window, + // e.g. if the device is a full-persistence display, the element will be visible for + // an entire frame, so the time measures to the middle of that period, i.e. half the frame time. + float PresentFlushToRenderedScene; // To the overall rendered 3D scene being visible. + float PresentFlushToTimewarpStart; // To when the first timewarped scanline will be visible. + float PresentFlushToTimewarpEnd; // To when the last timewarped scanline will be visible. + float PresentFlushToPresentFlush; // To the next present+flush, i.e. the ideal framerate. + + bool WithTimewarp; + bool WithVsync; +}; + +// Calculates the values from the HMD info. +PredictionValues PredictionGetDeviceValues ( const HmdRenderInfo &hmdRenderInfo, + bool withTimewarp = true, + bool withVsync = true ); + +// Pass in an orientation used to render the scene, and then the predicted orientation +// (which may have been computed later on, and thus is more accurate), and this +// will return the matrix to pass to the timewarp distortion shader. +// TODO: deal with different handedness? +Matrix4f TimewarpComputePoseDelta ( Matrix4f const &renderedViewFromWorld, Matrix4f const &predictedViewFromWorld, Matrix4f const&hmdToEyeViewOffset ); +Matrix4f TimewarpComputePoseDeltaPosition ( Matrix4f const &renderedViewFromWorld, Matrix4f const &predictedViewFromWorld, Matrix4f const&hmdToEyeViewOffset ); + + + +// TimewarpMachine helps keep track of rendered frame timing and +// handles predictions for time-warp rendering. +class TimewarpMachine +{ +public: + TimewarpMachine(); + + // Call this on and every time something about the setup changes. + void Reset ( HmdRenderInfo& renderInfo, bool vsyncEnabled, double timeNow ); + + // The only reliable time in most engines is directly after the frame-present and GPU flush-and-wait. + // This call should be done right after that to give this system the timing info it needs. + void AfterPresentAndFlush(double timeNow); + // But some engines queue up the frame-present and only later find out when it actually happened. + // They should call these two at those times. + void AfterPresentWithoutFlush(); + void AfterPresentFinishes(double timeNow); + + // The "average" time the rendered frame will show up, + // and the predicted pose of the HMD at that time. + // You usually only need to call one of these functions. + double GetViewRenderPredictionTime(); + bool GetViewRenderPredictionPose(Tracking::SensorStateReader* reader, Posef& transform); + + + // Timewarp prediction functions. You usually only need to call one of these three sets of functions. + + // The predicted times that the first and last pixel will be visible on-screen. + double GetVisiblePixelTimeStart(); + double GetVisiblePixelTimeEnd(); + // Predicted poses of the HMD at those first and last pixels. + bool GetPredictedVisiblePixelPoseStart(Tracking::SensorStateReader* reader, Posef& transform); + bool GetPredictedVisiblePixelPoseEnd(Tracking::SensorStateReader* reader, Posef& transform); + // The delta matrices to feed to the timewarp distortion code, + // given the pose that was used for rendering. + // (usually the one returned by GetViewRenderPredictionPose() earlier) + bool GetTimewarpDeltaStart(Tracking::SensorStateReader* reader, Posef const &renderedPose, Matrix4f& transform); + bool GetTimewarpDeltaEnd(Tracking::SensorStateReader* reader, Posef const &renderedPose, Matrix4f& transform); + + // Just-In-Time distortion aims to delay the second sensor reading & distortion + // until the very last moment to improve prediction. However, it is a little scary, + // since the delay might wait too long and miss the vsync completely! + // Use of the JustInTime_* functions is entirely optional, and we advise allowing + // users to turn it off in their video options to cope with odd machine configurations. + + // What time should the app wait until before starting distortion? + double JustInTime_GetDistortionWaitUntilTime(); + + // Used to time the distortion rendering + bool JustInTime_NeedDistortionTimeMeasurement() const; + void JustInTime_BeforeDistortionTimeMeasurement(double timeNow); + void JustInTime_AfterDistortionTimeMeasurement(double timeNow); + double JustInTime_AverageDistortionTime(); // Just for profiling - use JustInTime_GetDistortionWaitUntilTime() for functionality. + +private: + bool VsyncEnabled; + HmdRenderInfo RenderInfo; + PredictionValues CurrentPredictionValues; + + enum { NumDistortionTimes = 100 }; + int DistortionTimeCount; + double DistortionTimeCurrentStart; + float DistortionTimes[NumDistortionTimes]; + float DistortionTimeAverage; + + // Pose at which last time the eye was rendered. + Posef EyeRenderPoses[2]; + + // Absolute time of the last present+flush + double LastFramePresentFlushTime; + // Seconds between present+flushes + float PresentFlushToPresentFlushSeconds; + // Predicted absolute time of the next present+flush + double NextFramePresentFlushTime; + +}; + + + +}}} // OVR::Util::Render + +#endif diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Util/Util_SystemGUI.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Util/Util_SystemGUI.cpp Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,190 @@ +/************************************************************************************ + +Filename : Util_SystemGUI.cpp +Content : OS GUI access, usually for diagnostics. +Created : October 20, 2014 +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +*************************************************************************************/ + +#include "Util_SystemGUI.h" +#include "../Kernel/OVR_UTF8Util.h" +#include + +#if defined(OVR_OS_MS) + #include +#endif + + +namespace OVR { namespace Util { + + +#if defined(OVR_OS_MS) + + // On Windows we implement a manual dialog message box. The reason for this is that there's no way to + // have a message box like this without either using MFC or WinForms or relying on Windows Vista+. + + bool DisplayMessageBox(const char* pTitle, const char* pText) + { + #define ID_EDIT 100 + + struct Dialog + { + static size_t LineCount(const char* pText) + { + size_t count = 0; + while(*pText) + { + if(*pText++ == '\n') + count++; + } + return count; + } + + static WORD* WordUp(WORD* pIn){ return (WORD*)((((uintptr_t)pIn + 3) >> 2) << 2); } + + static BOOL CALLBACK Proc(HWND hDlg, UINT iMsg, WPARAM wParam, LPARAM lParam) + { + switch (iMsg) + { + case WM_INITDIALOG: + { + HWND hWndEdit = GetDlgItem(hDlg, ID_EDIT); + + const char* pText = (const char*)lParam; + SetWindowTextA(hWndEdit, pText); + + HFONT hFont = CreateFontW(-11, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, L"Courier New"); + if(hFont) + SendMessage(hWndEdit, WM_SETFONT, WPARAM(hFont), TRUE); + + SendMessage(hWndEdit, EM_SETSEL, (WPARAM)0, (LPARAM)0); + + return TRUE; + } + + case WM_COMMAND: + switch (LOWORD(wParam)) + { + case ID_EDIT: + { + // Handle messages from the edit control here. + HWND hWndEdit = GetDlgItem(hDlg, ID_EDIT); + SendMessage(hWndEdit, EM_SETSEL, (WPARAM)0, (LPARAM)0); + return TRUE; + } + + case IDOK: + EndDialog(hDlg, 0); + return TRUE; + } + break; + } + + return FALSE; + } + }; + + + char dialogTemplateMemory[1024]; + memset(dialogTemplateMemory, 0, sizeof(dialogTemplateMemory)); + DLGTEMPLATE* pDlg = (LPDLGTEMPLATE)dialogTemplateMemory; + + const size_t textLineCount = Dialog::LineCount(pText); + + // Sizes are in Windows dialog units, which are relative to a character size. Depends on the font and environment settings. Often the pixel size will be ~3x the dialog unit x size. Often the pixel size will be ~3x the dialog unit y size. + const int kGutterSize = 6; // Empty border space around controls within the dialog + const int kButtonWidth = 24; + const int kButtonHeight = 10; + const int kDialogWidth = 600; // To do: Clip this against screen bounds. + const int kDialogHeight = ((textLineCount > 100) ? 400 : ((textLineCount > 25) ? 300 : 200)); + + // Define a dialog box. + pDlg->style = WS_POPUP | WS_BORDER | WS_SYSMENU | DS_MODALFRAME | WS_CAPTION; + pDlg->cdit = 2; // Control count + pDlg->x = 10; // X position To do: Center the dialog. + pDlg->y = 10; + pDlg->cx = (short)kDialogWidth; + pDlg->cy = (short)kDialogHeight; + WORD* pWord = (WORD*)(pDlg + 1); + *pWord++ = 0; // No menu + *pWord++ = 0; // Default dialog box class + + WCHAR* pWchar = (WCHAR*)pWord; + const size_t titleLength = strlen(pTitle); + size_t wcharCount = OVR::UTF8Util::DecodeString(pWchar, pTitle, (titleLength > 128) ? 128 : titleLength); + pWord += wcharCount + 1; + + // Define an OK button. + pWord = Dialog::WordUp(pWord); + + DLGITEMTEMPLATE* pDlgItem = (DLGITEMTEMPLATE*)pWord; + pDlgItem->x = pDlg->cx - (kGutterSize + kButtonWidth); + pDlgItem->y = pDlg->cy - (kGutterSize + kButtonHeight); + pDlgItem->cx = kButtonWidth; + pDlgItem->cy = kButtonHeight; + pDlgItem->id = IDOK; + pDlgItem->style = WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON; + + pWord = (WORD*)(pDlgItem + 1); + *pWord++ = 0xFFFF; + *pWord++ = 0x0080; // button class + + pWchar = (WCHAR*)pWord; + pWchar[0] = 'O'; pWchar[1] = 'K'; pWchar[2] = '\0'; // Not currently localized. + pWord += 3; // OK\0 + *pWord++ = 0; // no creation data + + // Define an EDIT contol. + pWord = Dialog::WordUp(pWord); + + pDlgItem = (DLGITEMTEMPLATE*)pWord; + pDlgItem->x = kGutterSize; + pDlgItem->y = kGutterSize; + pDlgItem->cx = pDlg->cx - (kGutterSize + kGutterSize); + pDlgItem->cy = pDlg->cy - (kGutterSize + kButtonHeight + kGutterSize + (kGutterSize / 2)); + pDlgItem->id = ID_EDIT; + pDlgItem->style = ES_LEFT | ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN | ES_READONLY | WS_VSCROLL | WS_BORDER | WS_TABSTOP | WS_CHILD | WS_VISIBLE; + + pWord = (WORD*)(pDlgItem + 1); + *pWord++ = 0xFFFF; + *pWord++ = 0x0081; // edit class atom + *pWord++ = 0; // no creation data + + LRESULT ret = DialogBoxIndirectParam(NULL, (LPDLGTEMPLATE)pDlg, NULL, (DLGPROC)Dialog::Proc, (LPARAM)pText); + + return (ret != 0); + } +#elif defined(OVR_OS_MAC) + // For Apple we use the Objective C implementation in Util_GUI.mm +#else + // To do. + bool DisplayMessageBox(const char* pTitle, const char* pText) + { + printf("\n\nMessageBox\n%s\n", pTitle); + printf("%s\n\n", pText); + return false; + } +#endif + + +} } // namespace OVR::Util + + + + diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Util/Util_SystemGUI.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Util/Util_SystemGUI.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,39 @@ +/************************************************************************************ + +Filename : Util_SystemGUI.h +Content : OS GUI access, usually for diagnostics. +Created : October 20, 2014 +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +*************************************************************************************/ + +#ifndef OVR_Util_GUI_h +#define OVR_Util_GUI_h + + +namespace OVR { namespace Util { + + // Displays a modal message box on the default GUI display (not on a VR device). + // The message box interface (e.g. OK button) is not localized. + bool DisplayMessageBox(const char* pTitle, const char* pText); + + +} } // namespace OVR::Util + + +#endif diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Util/Util_SystemInfo.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Util/Util_SystemInfo.cpp Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,289 @@ +/************************************************************************************ + +Filename : Util_SystemInfo.cpp +Content : Various operations to get information about the system +Created : September 26, 2014 +Author : Kevin Jenkins + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + +#include "Util_SystemInfo.h" +#include "../Kernel/OVR_Timer.h" +#include "../Kernel/OVR_Threads.h" +#include "../Kernel/OVR_Log.h" +#include "../Kernel/OVR_Array.h" + +/* +// Disabled, can't link RiftConfigUtil +#ifdef OVR_OS_WIN32 +#define _WIN32_DCOM +#include +#include + +# pragma comment(lib, "wbemuuid.lib") +#endif +*/ + + +namespace OVR { namespace Util { + +// From http://blogs.msdn.com/b/oldnewthing/archive/2005/02/01/364563.aspx +#if defined (OVR_OS_WIN64) || defined (OVR_OS_WIN32) + +#pragma comment(lib, "version.lib") + +typedef BOOL(WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL); +BOOL Is64BitWindows() +{ +#if defined(_WIN64) + return TRUE; // 64-bit programs run only on Win64 +#elif defined(_WIN32) + // 32-bit programs run on both 32-bit and 64-bit Windows + // so must sniff + BOOL f64 = FALSE; + LPFN_ISWOW64PROCESS fnIsWow64Process; + + fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(GetModuleHandle(L"kernel32"), "IsWow64Process"); + if (NULL != fnIsWow64Process) + { + return fnIsWow64Process(GetCurrentProcess(), &f64) && f64; + } + return FALSE; +#else + return FALSE; // Win64 does not support Win16 +#endif +} +#endif + +const char * OSAsString() +{ +#if defined (OVR_OS_IPHONE) + return "IPhone"; +#elif defined (OVR_OS_DARWIN) + return "Darwin"; +#elif defined (OVR_OS_MAC) + return "Mac"; +#elif defined (OVR_OS_BSD) + return "BSD"; +#elif defined (OVR_OS_WIN64) || defined (OVR_OS_WIN32) + if (Is64BitWindows()) + return "Win64"; + else + return "Win32"; +#elif defined (OVR_OS_ANDROID) + return "Android"; +#elif defined (OVR_OS_LINUX) + return "Linux"; +#elif defined (OVR_OS_BSD) + return "BSD"; +#else + return "Other"; +#endif +} + +uint64_t GetGuidInt() +{ + uint64_t g = Timer::GetTicksNanos(); + + uint64_t lastTime, thisTime; + int j; + // Sleep a small random time, then use the last 4 bits as a source of randomness + for (j = 0; j < 8; j++) + { + lastTime = Timer::GetTicksNanos(); + Thread::MSleep(1); + Thread::MSleep(0); + thisTime = Timer::GetTicksNanos(); + uint64_t diff = thisTime - lastTime; + unsigned int diff4Bits = (unsigned int)(diff & 15); + diff4Bits <<= 32 - 4; + diff4Bits >>= j * 4; + ((char*)&g)[j] ^= diff4Bits; + } + + return g; +} +String GetGuidString() +{ + uint64_t guid = GetGuidInt(); + + char buff[64]; +#if defined(OVR_CC_MSVC) + OVR_sprintf(buff, sizeof(buff), "%I64u", guid); +#else + OVR_sprintf(buff, sizeof(buff), "%llu", (unsigned long long) guid); +#endif + return String(buff); +} + +const char * GetProcessInfo() +{ + #if defined (OVR_CPU_X86_64 ) + return "64 bit"; +#elif defined (OVR_CPU_X86) + return "32 bit"; +#else + return "TODO"; +#endif +} +#ifdef OVR_OS_WIN32 + + +String OSVersionAsString() +{ + return GetSystemFileVersionString("\\kernel32.dll"); +} +String GetSystemFileVersionString(String filePath) +{ + char strFilePath[MAX_PATH]; // Local variable + UINT sysDirLen = GetSystemDirectoryA(strFilePath, ARRAYSIZE(strFilePath)); + if (sysDirLen != 0) + { + OVR_strcat(strFilePath, MAX_PATH, filePath.ToCStr()); + return GetFileVersionString(strFilePath); + } + else + { + return "GetSystemDirectoryA failed"; + } +} +// See http://stackoverflow.com/questions/940707/how-do-i-programatically-get-the-version-of-a-dll-or-exe-file +String GetFileVersionString(String filePath) +{ + String result; + + DWORD dwSize = GetFileVersionInfoSizeA(filePath.ToCStr(), NULL); + if (dwSize == 0) + { + OVR_DEBUG_LOG(("Error in GetFileVersionInfoSizeA: %d (for %s)", GetLastError(), filePath.ToCStr())); + result = filePath + " not found"; + } + else + { + BYTE* pVersionInfo = new BYTE[dwSize]; + if (!pVersionInfo) + { + OVR_DEBUG_LOG(("Out of memory allocating %d bytes (for %s)", dwSize, filePath.ToCStr())); + result = "Out of memory"; + } + else + { + if (!GetFileVersionInfoA(filePath.ToCStr(), 0, dwSize, pVersionInfo)) + { + OVR_DEBUG_LOG(("Error in GetFileVersionInfo: %d (for %s)", GetLastError(), filePath.ToCStr())); + result = "Cannot get version info"; + } + else + { + VS_FIXEDFILEINFO* pFileInfo = NULL; + UINT pLenFileInfo = 0; + if (!VerQueryValue(pVersionInfo, TEXT("\\"), (LPVOID*)&pFileInfo, &pLenFileInfo)) + { + OVR_DEBUG_LOG(("Error in VerQueryValue: %d (for %s)", GetLastError(), filePath.ToCStr())); + result = "File has no version info"; + } + else + { + int major = (pFileInfo->dwFileVersionMS >> 16) & 0xffff; + int minor = (pFileInfo->dwFileVersionMS) & 0xffff; + int hotfix = (pFileInfo->dwFileVersionLS >> 16) & 0xffff; + int other = (pFileInfo->dwFileVersionLS) & 0xffff; + + char str[128]; + OVR::OVR_sprintf(str, 128, "%d.%d.%d.%d", major, minor, hotfix, other); + + result = str; + } + } + + delete[] pVersionInfo; + } + } + + return result; +} + + +String GetDisplayDriverVersion() +{ + return GetSystemFileVersionString("\\OVRDisplay32.dll"); +} +String GetCameraDriverVersion() +{ + return GetSystemFileVersionString("\\drivers\\OCUSBVID.sys"); +} + +// From http://stackoverflow.com/questions/9524309/enumdisplaydevices-function-not-working-for-me +void GetGraphicsCardList( Array< String > &gpus) +{ + gpus.Clear(); + + DISPLAY_DEVICEA dd; + + dd.cb = sizeof(dd); + + DWORD deviceNum = 0; + while( EnumDisplayDevicesA(NULL, deviceNum, &dd, 0) ){ + if (dd.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE) + gpus.PushBack(dd.DeviceString); + deviceNum++; + } +} +#else + +// used for driver files + +String GetFileVersionString(String /*filePath*/) +{ + return String(); +} + +String GetSystemFileVersionString(String /*filePath*/) +{ + return String(); +} + +String GetDisplayDriverVersion() +{ + return String(); +} + +String GetCameraDriverVersion() +{ + return String(); +} + +#ifdef OVR_OS_MAC + //use objective c source +#else + +//todo linux, this requires searching /var/ files +void GetGraphicsCardList(OVR::Array< OVR::String > &gpus) +{ + gpus.Clear(); +} +String OSVersionAsString() +{ + return String(); +} +#endif //OVR_OS_MAC +#endif // WIN32 + +} } // namespace OVR { namespace Util { diff -r 000000000000 -r 1b39a1b46319 LibOVR/Src/Util/Util_SystemInfo.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LibOVR/Src/Util/Util_SystemInfo.h Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,51 @@ +/************************************************************************************ + +Filename : Util_SystemInfo.h +Content : Various operations to get information about the system +Created : September 26, 2014 +Author : Kevin Jenkins + +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. + +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); +you may not use the Oculus VR Rift SDK except in compliance with the License, +which is provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. + +You may obtain a copy of the License at + +http://www.oculusvr.com/licenses/LICENSE-3.2 + +Unless required by applicable law or agreed to in writing, the Oculus VR SDK +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +************************************************************************************/ + + +#ifndef OVR_Util_SystemInfo_h +#define OVR_Util_SystemInfo_h + +#include "../Kernel/OVR_String.h" +#include "../Kernel/OVR_Types.h" +#include "../Kernel/OVR_Array.h" + +namespace OVR { namespace Util { + +const char * OSAsString(); +String OSVersionAsString(); +uint64_t GetGuidInt(); +String GetGuidString(); +const char * GetProcessInfo(); +String GetFileVersionString(String filePath); +String GetSystemFileVersionString(String filePath); +String GetDisplayDriverVersion(); +String GetCameraDriverVersion(); +void GetGraphicsCardList(OVR::Array< OVR::String > &gpus); +String GetProcessorInfo(int* numcores = NULL); + +} } // namespace OVR { namespace Util { + +#endif // OVR_Util_SystemInfo_h diff -r 000000000000 -r 1b39a1b46319 Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Makefile Wed Jan 14 06:51:16 2015 +0200 @@ -0,0 +1,104 @@ +############################################################################# +# +# Filename : Makefile +# Content : Makefile for building linux libovr and OculusWorldDemo +# Created : 2013 +# Authors : Simon Hallam and Peter Giokaris +# Copyright : Copyright 2013 OculusVR, Inc. All Rights Reserved +# Instruction : See 'make help' +# +# make builds the release versions for the +# current architechture +# make clean delete intermediate release object files +# and library and executable +# make DEBUG=1 builds the debug version for the current +# architechture +# make clean DEBUG=1 deletes intermediate debug object files +# and the library and executable +# +# Output : Relative to the directory this Makefile lives in, libraries +# and executables are built at the following locations +# depending upon the architechture of the system you are +# running: +# +# ./LibOVR/Lib/Linux/Debug/i386/libovr.a +# ./LibOVR/Lib/Linux/Debug/x86_64/libovr.a +# ./LibOVR/Lib/Linux/Release/i386/libovr.a +# ./LibOVR/Lib/Linux/Release/x86_64/libovr.a +# ./Samples/OculusWorldDemo/Release/OculusWorldDemo_i386_Release +# ./Samples/OculusWorldDemo/Release/OculusWorldDemo_x86_64_Release +# ./Samples/OculusWorldDemo/Release/OculusWorldDemo_i386_Debug +# ./Samples/OculusWorldDemo/Release/OculusWorldDemo_x86_64_Debug +# +############################################################################# + +####### Include makefiles in current directory +RELEASESUFFIX = +-include Makefile.*[^~] + +####### Detect system architecture + +SYSARCH = i386 +ifeq ($(shell uname -m),x86_64) +SYSARCH = x86_64 +endif + +####### Compiler, tools and options + +CXX = g++ +LINK = ar rvs +DELETEFILE = rm -f + +####### Detect debug or release + +DEBUG = 0 +ifeq ($(DEBUG), 1) + RELEASETYPE = Debug$(RELEASESUFFIX) +else + RELEASETYPE = Release$(RELEASESUFFIX) +endif + +# Override release types and DEBUG settings in child makefiles. +export RELEASETYPE +export DEBUG + +####### Target settings +LIBOVRPATH = ./LibOVR +OWDPATH = ./Samples/OculusWorldDemo + +LIBOVRTARGET = $(LIBOVRPATH)/Lib/Linux/$(RELEASETYPE)/$(SYSARCH)/libovr.a +OWDTARGET = $(OWDPATH)/Release/OculusWorldDemo_$(SYSARCH)_$(RELEASETYPE) + +####### Targets + +all: $(LIBOVRTARGET) $(OWDTARGET) + +$(OWDTARGET): force_look $(LIBOVRTARGET) + $(MAKE) -C $(OWDPATH) + +$(LIBOVRTARGET): force_look + $(MAKE) -C $(LIBOVRPATH) + +run: $(OWDTARGET) + $(MAKE) -C $(OWDPATH) run + +clean: + $(MAKE) -C $(LIBOVRPATH) clean + $(MAKE) -C $(OWDPATH) clean + +force_look: + true + +# Generate help based on descriptions of targets given in this Makefile. +help: ##- Show this help + @echo "Targets:" + @echo " all : Build LibOVR and Oculus World Demo" + @echo " run : Run Oculus World Demo" + @echo " clean : Clean selected release (DEBUG=[0,1])" + @echo " cleanall : Clean all possible release targets" + @echo "" + @echo "Options:" + @echo " DEBUG : 'make DEBUG=1' will build the current target in DEBUG mode" + +# Experimental method of automatically generating help from target names. +#@grep -h "##-" $(MAKEFILE_LIST) | grep -v grep | sed -e 's/^/ /' | sed -e 's/\:\s*##-/:/' | awk '{printf "%+6s\n", $$0}'