// common private void parseCommonArguments(string line) { ////////////////////////////////////////////////////////////////////////// // line to parse: // common lineHeight=104 base=26 scaleW=1024 scaleH=512 pages=1 packed=0 ////////////////////////////////////////////////////////////////////////// // Height int index = line.IndexOf("lineHeight="); int index2 = line.IndexOf(' ', index); string value = line.Substring(index, index2 - index); m_nCommonHeight = CCUtils.CCParseInt(value.Replace("lineHeight=", "")); // scaleW. sanity check index = line.IndexOf("scaleW=") + "scaleW=".Length; index2 = line.IndexOf(' ', index); value = line.Substring(index, index2 - index); //CCAssert(atoi(value.c_str()) <= CCConfiguration::sharedConfiguration()->getMaxTextureSize(), "CCLabelBMFont: page can't be larger than supported"); // scaleH. sanity check index = line.IndexOf("scaleH=") + "scaleH=".Length; index2 = line.IndexOf(' ', index); value = line.Substring(index, index2 - index); //CCAssert(atoi(value.c_str()) <= CCConfiguration::sharedConfiguration()->getMaxTextureSize(), "CCLabelBMFont: page can't be larger than supported"); // pages. sanity check index = line.IndexOf("pages=") + "pages=".Length; index2 = line.IndexOf(' ', index); value = line.Substring(index, index2 - index); //CCAssert(atoi(value.c_str()) == 1, "CCBitfontAtlas: only supports 1 page"); // packed (ignore) What does this mean ?? }
/* The layer recognizes some special properties, like cc_vertez */ private void ParseInternalProperties() { // if cc_vertex=automatic, then tiles will be rendered using vertexz m_fAlphaFuncValue = 0; string vertexz = PropertyNamed("cc_vertexz"); if (!String.IsNullOrEmpty(vertexz)) { // If "automatic" is on, then parse the "cc_alpha_func" too if (vertexz == "automatic") { m_bUseAutomaticVertexZ = true; string alphaFuncVal = PropertyNamed("cc_alpha_func"); //float alphaFuncValue = 0.0f; if (!String.IsNullOrEmpty(alphaFuncVal)) { m_fAlphaFuncValue = CCUtils.CCParseFloat(alphaFuncVal); } //setShaderProgram(CCShaderCache::sharedShaderCache().programForKey(kCCShader_PositionTextureColorAlphaTest)); //GLint alphaValueLocation = glGetUniformLocation(getShaderProgram().getProgram(), kCCUniformAlphaTestValue); // NOTE: alpha test shader is hard-coded to use the equivalent of a glAlphaFunc(GL_GREATER) comparison //getShaderProgram().setUniformLocationWith1f(alphaValueLocation, alphaFuncValue); } else { m_nVertexZvalue = CCUtils.CCParseInt(vertexz); } } }
private void parseCharacterDefinition(string line, ccBMFontDef characterDefinition) { ////////////////////////////////////////////////////////////////////////// // line to parse: // char id=32 x=0 y=0 width=0 height=0 xoffset=0 yoffset=44 xadvance=14 page=0 chnl=0 ////////////////////////////////////////////////////////////////////////// // Character ID int index = line.IndexOf("id="); int index2 = line.IndexOf(' ', index); string value = line.Substring(index, index2 - index); characterDefinition.charID = CCUtils.CCParseInt(value.Replace("id=", "")); //CCAssert(characterDefinition->charID < kCCBMFontMaxChars, "BitmpaFontAtlas: CharID bigger than supported"); // Character x index = line.IndexOf("x="); index2 = line.IndexOf(' ', index); value = line.Substring(index, index2 - index); characterDefinition.rect.Origin.X = CCUtils.CCParseFloat(value.Replace("x=", "")); // Character y index = line.IndexOf("y="); index2 = line.IndexOf(' ', index); value = line.Substring(index, index2 - index); characterDefinition.rect.Origin.Y = CCUtils.CCParseFloat(value.Replace("y=", "")); // Character width index = line.IndexOf("width="); index2 = line.IndexOf(' ', index); value = line.Substring(index, index2 - index); characterDefinition.rect.Size.Width = CCUtils.CCParseFloat(value.Replace("width=", "")); // Character height index = line.IndexOf("height="); index2 = line.IndexOf(' ', index); value = line.Substring(index, index2 - index); characterDefinition.rect.Size.Height = CCUtils.CCParseFloat(value.Replace("height=", "")); // Character xoffset index = line.IndexOf("xoffset="); index2 = line.IndexOf(' ', index); value = line.Substring(index, index2 - index); characterDefinition.xOffset = CCUtils.CCParseInt(value.Replace("xoffset=", "")); // Character yoffset index = line.IndexOf("yoffset="); index2 = line.IndexOf(' ', index); value = line.Substring(index, index2 - index); characterDefinition.yOffset = CCUtils.CCParseInt(value.Replace("yoffset=", "")); // Character xadvance index = line.IndexOf("xadvance="); index2 = line.IndexOf(' ', index); value = line.Substring(index, index2 - index); characterDefinition.xAdvance = CCUtils.CCParseInt(value.Replace("xadvance=", "")); }
public static RenderTarget2D CreateRenderTarget(int width, int height, SurfaceFormat colorFormat, DepthFormat depthFormat, RenderTargetUsage usage) { if (!m_AllowNonPower2Textures) { width = CCUtils.CCNextPOT(width); height = CCUtils.CCNextPOT(height); } return(new RenderTarget2D(graphicsDevice, width, height, false, colorFormat, depthFormat, 0, usage)); }
public static Texture2D CreateTexture2D(int width, int height) { PresentationParameters pp = graphicsDevice.PresentationParameters; if (!m_AllowNonPower2Textures) { width = CCUtils.CCNextPOT(width); height = CCUtils.CCNextPOT(height); } return(new Texture2D(graphicsDevice, width, height, false, SurfaceFormat.Color)); }
internal static int DeSerializeInt(StreamReader sr) { string s = sr.ReadLine(); if (s == null) { CCLog.Log("DeSerializeInt: null"); return(0); } return(CCUtils.CCParseInt(s)); }
public int GetIntegerForKey(string pKey, int defaultValue) { string value = getValueForKey(pKey); int ret = defaultValue; if (value != null) { ret = CCUtils.CCParseInt(value); } return(ret); }
internal static CCSize DeSerializeSize(StreamReader sr) { string x = sr.ReadLine(); if (x == null) { CCLog.Log("DeSerializeSize: null"); return(CCSize.Zero); } CCSize pt = new CCSize(); string[] s = x.Split(' '); pt.Width = CCUtils.CCParseFloat(s[0]); pt.Height = CCUtils.CCParseFloat(s[1]); return(pt); }
internal static CCPoint DeSerializePoint(StreamReader sr) { string x = sr.ReadLine(); if (x == null) { CCLog.Log("DeSerializePoint: null"); return(CCPoint.Zero); } CCPoint pt = new CCPoint(); string[] s = x.Split(' '); pt.X = CCUtils.CCParseFloat(s[0]); pt.Y = CCUtils.CCParseFloat(s[1]); return(pt); }
private void parseKerningEntry(string line) { ////////////////////////////////////////////////////////////////////////// // line to parse: // kerning first=121 second=44 amount=-7 ////////////////////////////////////////////////////////////////////////// // first int first; int index = line.IndexOf("first="); int index2 = line.IndexOf(' ', index); string value = line.Substring(index, index2 - index); first = CCUtils.CCParseInt(value.Replace("first=", "")); // second int second; index = line.IndexOf("second="); index2 = line.IndexOf(' ', index); value = line.Substring(index, index2 - index); second = CCUtils.CCParseInt(value.Replace("second=", "")); // amount int amount; index = line.IndexOf("amount="); index2 = line.IndexOf(' ', index); value = line.Substring(index); amount = CCUtils.CCParseInt(value.Replace("amount=", "")); try { var element = new tKerningHashElement(); element.amount = amount; element.key = (first << 16) | (second & 0xffff); m_pKerningDictionary.Add(element.key, element); } catch (Exception ex) { CCLog.Log("Failed to parse font line: {0}", line); } }
public static CCSize CCSizeFromString(string pszContent) { CCSize ret = new CCSize(); do { List <string> strs = new List <string>(); if (!CCUtils.SplitWithForm(pszContent, strs)) { break; } float width = CCUtils.CCParseFloat(strs[0]); float height = CCUtils.CCParseFloat(strs[1]); ret = new CCSize(width, height); } while (false); return(ret); }
public static CCPoint CCPointFromString(string pszContent) { CCPoint ret = CCPoint.Zero; do { List <string> strs = new List <string>(); if (!CCUtils.SplitWithForm(pszContent, strs)) { break; } float x = CCUtils.CCParseFloat(strs[0]); float y = CCUtils.CCParseFloat(strs[1]); ret.X = x; ret.Y = y; } while (false); return(ret); }
// info face private void parseInfoArguments(string line) { ////////////////////////////////////////////////////////////////////////// // possible lines to parse: // info face="Script" size=32 bold=0 italic=0 charset="" unicode=1 stretchH=100 smooth=1 aa=1 padding=1,4,3,2 spacing=0,0 outline=0 // info face="Cracked" size=36 bold=0 italic=0 charset="" unicode=0 stretchH=100 smooth=1 aa=1 padding=0,0,0,0 spacing=1,1 ////////////////////////////////////////////////////////////////////////// // padding int index = line.IndexOf("padding="); int index2 = line.IndexOf(' ', index); string value = line.Substring(index, index2 - index); value = value.Replace("padding=", ""); string[] temp = value.Split(','); m_tPadding.top = CCUtils.CCParseInt(temp[0]); m_tPadding.right = CCUtils.CCParseInt(temp[1]); m_tPadding.bottom = CCUtils.CCParseInt(temp[2]); m_tPadding.left = CCUtils.CCParseInt(temp[3]); //CCLOG("cocos2d: padding: %d,%d,%d,%d", m_tPadding.left, m_tPadding.top, m_tPadding.right, m_tPadding.bottom); }
public void StartElement(object ctx, string name, string[] atts) { CCTMXMapInfo pTMXMapInfo = this; string elementName = name; var attributeDict = new Dictionary <string, string>(); if (atts != null && atts[0] != null) { for (int i = 0; i + 1 < atts.Length; i += 2) { string key = atts[i]; string value = atts[i + 1]; attributeDict.Add(key, value); } } if (elementName == "map") { string version = attributeDict["version"]; if (version != "1.0") { CCLog.Log("cocos2d: TMXFormat: Unsupported TMX version: {0}", version); } string orientationStr = attributeDict["orientation"]; if (orientationStr == "orthogonal") { pTMXMapInfo.Orientation = (int)(CCTMXOrientation.Ortho); } else if (orientationStr == "isometric") { pTMXMapInfo.Orientation = (int)(CCTMXOrientation.Iso); } else if (orientationStr == "hexagonal") { pTMXMapInfo.Orientation = (int)(CCTMXOrientation.Hex); } else { CCLog.Log("cocos2d: TMXFomat: Unsupported orientation: {0}", pTMXMapInfo.Orientation); } CCSize sMapSize; sMapSize.Width = CCUtils.CCParseFloat(attributeDict["width"]); sMapSize.Height = CCUtils.CCParseFloat(attributeDict["height"]); pTMXMapInfo.MapSize = sMapSize; CCSize sTileSize; sTileSize.Width = CCUtils.CCParseFloat(attributeDict["tilewidth"]); sTileSize.Height = CCUtils.CCParseFloat(attributeDict["tileheight"]); pTMXMapInfo.TileSize = sTileSize; // The parent element is now "map" pTMXMapInfo.ParentElement = (int)CCTMXProperty.Map; } else if (elementName == "tileset") { // If this is an external tileset then start parsing that if (attributeDict.Keys.Contains("source")) { string externalTilesetFilename = attributeDict["source"]; externalTilesetFilename = CCFileUtils.FullPathFromRelativeFile(externalTilesetFilename, pTMXMapInfo.TMXFileName); m_uCurrentFirstGID = uint.Parse(attributeDict["firstgid"]); pTMXMapInfo.ParseXmlFile(externalTilesetFilename); } else { var tileset = new CCTMXTilesetInfo(); tileset.m_sName = attributeDict["name"]; if (m_uCurrentFirstGID == 0) { tileset.m_uFirstGid = uint.Parse(attributeDict["firstgid"]); } else { tileset.m_uFirstGid = m_uCurrentFirstGID; m_uCurrentFirstGID = 0; } if (attributeDict.Keys.Contains("spacing")) { tileset.m_uSpacing = int.Parse(attributeDict["spacing"]); } if (attributeDict.Keys.Contains("margin")) { tileset.m_uMargin = int.Parse(attributeDict["margin"]); } CCSize s; s.Width = CCUtils.CCParseFloat(attributeDict["tilewidth"]); s.Height = CCUtils.CCParseFloat(attributeDict["tileheight"]); tileset.m_tTileSize = s; pTMXMapInfo.Tilesets.Add(tileset); } } else if (elementName == "tile") { CCTMXTilesetInfo info = pTMXMapInfo.Tilesets.LastOrDefault(); var dict = new Dictionary <string, string>(); pTMXMapInfo.ParentGID = (info.m_uFirstGid + uint.Parse(attributeDict["id"])); pTMXMapInfo.TileProperties.Add(pTMXMapInfo.ParentGID, dict); pTMXMapInfo.ParentElement = (int)CCTMXProperty.Tile; } else if (elementName == "layer") { var layer = new CCTMXLayerInfo(); layer.Name = attributeDict["name"]; CCSize s; s.Width = CCUtils.CCParseFloat(attributeDict["width"]); s.Height = CCUtils.CCParseFloat(attributeDict["height"]); layer.LayerSize = s; layer.Tiles = new uint[(int)s.Width * (int)s.Height]; if (attributeDict.Keys.Contains("visible")) { string visible = attributeDict["visible"]; layer.Visible = !(visible == "0"); } else { layer.Visible = true; } if (attributeDict.Keys.Contains("opacity")) { string opacity = attributeDict["opacity"]; layer.Opacity = (byte)(255 * CCUtils.CCParseFloat(opacity)); } else { layer.Opacity = 255; } float x = attributeDict.Keys.Contains("x") ? CCUtils.CCParseFloat(attributeDict["x"]) : 0; float y = attributeDict.Keys.Contains("y") ? CCUtils.CCParseFloat(attributeDict["y"]) : 0; layer.Offset = new CCPoint(x, y); pTMXMapInfo.Layers.Add(layer); // The parent element is now "layer" pTMXMapInfo.ParentElement = (int)CCTMXProperty.Layer; } else if (elementName == "objectgroup") { var objectGroup = new CCTMXObjectGroup(); objectGroup.GroupName = attributeDict["name"]; CCPoint positionOffset = CCPoint.Zero; if (attributeDict.ContainsKey("x")) { positionOffset.X = CCUtils.CCParseFloat(attributeDict["x"]) * pTMXMapInfo.TileSize.Width; } if (attributeDict.ContainsKey("y")) { positionOffset.Y = CCUtils.CCParseFloat(attributeDict["y"]) * pTMXMapInfo.TileSize.Height; } objectGroup.PositionOffset = positionOffset; pTMXMapInfo.ObjectGroups.Add(objectGroup); // The parent element is now "objectgroup" pTMXMapInfo.ParentElement = (int)CCTMXProperty.ObjectGroup; } else if (elementName == "image") { CCTMXTilesetInfo tileset = pTMXMapInfo.Tilesets.LastOrDefault(); // build full path string imagename = attributeDict["source"]; tileset.m_sSourceImage = CCFileUtils.FullPathFromRelativeFile(imagename, pTMXMapInfo.TMXFileName); } else if (elementName == "data") { string encoding = attributeDict.ContainsKey("encoding") ? attributeDict["encoding"] : ""; string compression = attributeDict.ContainsKey("compression") ? attributeDict["compression"] : ""; if (encoding == "base64") { int layerAttribs = pTMXMapInfo.LayerAttribs; pTMXMapInfo.LayerAttribs = layerAttribs | (int)CCTMXLayerAttrib.Base64; pTMXMapInfo.StoringCharacters = true; if (compression == "gzip") { layerAttribs = pTMXMapInfo.LayerAttribs; pTMXMapInfo.LayerAttribs = layerAttribs | (int)CCTMXLayerAttrib.Gzip; } else if (compression == "zlib") { layerAttribs = pTMXMapInfo.LayerAttribs; pTMXMapInfo.LayerAttribs = layerAttribs | (int)CCTMXLayerAttrib.Zlib; } Debug.Assert(compression == "" || compression == "gzip" || compression == "zlib", "TMX: unsupported compression method"); } Debug.Assert(pTMXMapInfo.LayerAttribs != (int)CCTMXLayerAttrib.None, "TMX tile map: Only base64 and/or gzip/zlib maps are supported"); } else if (elementName == "object") { CCTMXObjectGroup objectGroup = pTMXMapInfo.ObjectGroups.LastOrDefault(); // The value for "type" was blank or not a valid class name // Create an instance of TMXObjectInfo to store the object and its properties var dict = new Dictionary <string, string>(); var pArray = new[] { "name", "type", "width", "height", "gid" }; for (int i = 0; i < pArray.Length; i++) { string key = pArray[i]; if (attributeDict.ContainsKey(key)) { dict.Add(key, attributeDict[key]); } } // But X and Y since they need special treatment // X int x = int.Parse(attributeDict["x"]) + (int)objectGroup.PositionOffset.X; dict.Add("x", x.ToString()); int y = int.Parse(attributeDict["y"]) + (int)objectGroup.PositionOffset.Y; // Correct y position. (Tiled uses Flipped, cocos2d uses Standard) y = (int)(pTMXMapInfo.MapSize.Height * pTMXMapInfo.TileSize.Height) - y - (attributeDict.ContainsKey("height") ? int.Parse(attributeDict["height"]) : 0); dict.Add("y", y.ToString()); // Add the object to the objectGroup objectGroup.Objects.Add(dict); // The parent element is now "object" pTMXMapInfo.ParentElement = (int)CCTMXProperty.Object; } else if (elementName == "property") { if (pTMXMapInfo.ParentElement == (int)CCTMXProperty.None) { CCLog.Log("TMX tile map: Parent element is unsupported. Cannot add property named '{0}' with value '{1}'", attributeDict["name"], attributeDict["value"]); } else if (pTMXMapInfo.ParentElement == (int)CCTMXProperty.Map) { // The parent element is the map string value = attributeDict["value"]; string key = attributeDict["name"]; pTMXMapInfo.Properties.Add(key, value); } else if (pTMXMapInfo.ParentElement == (int)CCTMXProperty.Layer) { // The parent element is the last layer CCTMXLayerInfo layer = pTMXMapInfo.Layers.LastOrDefault(); string value = attributeDict["value"]; string key = attributeDict["name"]; // Add the property to the layer layer.Properties.Add(key, value); } else if (pTMXMapInfo.ParentElement == (int)CCTMXProperty.ObjectGroup) { // The parent element is the last object group CCTMXObjectGroup objectGroup = pTMXMapInfo.ObjectGroups.LastOrDefault(); string value = attributeDict["value"]; string key = attributeDict["name"]; objectGroup.Properties.Add(key, value); } else if (pTMXMapInfo.ParentElement == (int)CCTMXProperty.Object) { // The parent element is the last object CCTMXObjectGroup objectGroup = pTMXMapInfo.ObjectGroups.LastOrDefault(); Dictionary <string, string> dict = objectGroup.Objects.LastOrDefault(); string propertyName = attributeDict["name"]; string propertyValue = attributeDict["value"]; dict.Add(propertyName, propertyValue); } else if (pTMXMapInfo.ParentElement == (int)CCTMXProperty.Tile) { Dictionary <string, string> dict = pTMXMapInfo.TileProperties[pTMXMapInfo.ParentGID]; string propertyName = attributeDict["name"]; string propertyValue = attributeDict["value"]; dict.Add(propertyName, propertyValue); } } else if (elementName == "polygon") { // find parent object's dict and add polygon-points to it CCTMXObjectGroup objectGroup = m_pObjectGroups.LastOrDefault(); var dict = objectGroup.Objects.LastOrDefault(); // get points value string var value = attributeDict["points"]; if (!String.IsNullOrEmpty(value)) { var pPointsArray = new List <CCPoint>(); var pointPairs = value.Split(' '); foreach (var pontPair in pointPairs) { //TODO: Parse points //CCPoint point; //point.X = x + objectGroup.PositionOffset.X; //point.Y = y + objectGroup.PositionOffset.Y; //pPointsArray.Add(point); } //dict.Add("points", pPointsArray); } } else if (elementName == "polyline") { // find parent object's dict and add polyline-points to it // CCTMXObjectGroup* objectGroup = (CCTMXObjectGroup*)m_pObjectGroups->lastObject(); // CCDictionary* dict = (CCDictionary*)objectGroup->getObjects()->lastObject(); // TODO: dict->setObject:[attributeDict objectForKey:@"points"] forKey:@"polylinePoints"]; } }
public static CCRect CCRectFromString(string pszContent) { CCRect result = CCRect.Zero; do { if (pszContent == null) { break; } string content = pszContent; // find the first '{' and the third '}' int nPosLeft = content.IndexOf('{'); int nPosRight = content.IndexOf('}'); for (int i = 1; i < 3; ++i) { if (nPosRight == -1) { break; } nPosRight = content.IndexOf('}', nPosRight + 1); } if (nPosLeft == -1 || nPosRight == -1) { break; } content = content.Substring(nPosLeft + 1, nPosRight - nPosLeft - 1); int nPointEnd = content.IndexOf('}'); if (nPointEnd == -1) { break; } nPointEnd = content.IndexOf(',', nPointEnd); if (nPointEnd == -1) { break; } // get the point string and size string string pointStr = content.Substring(0, nPointEnd); string sizeStr = content.Substring(nPointEnd + 1); //, content.Length - nPointEnd // split the string with ',' List <string> pointInfo = new List <string>(); if (!CCUtils.SplitWithForm(pointStr, pointInfo)) { break; } List <string> sizeInfo = new List <string>(); if (!CCUtils.SplitWithForm(sizeStr, sizeInfo)) { break; } float x = CCUtils.CCParseFloat(pointInfo[0]); float y = CCUtils.CCParseFloat(pointInfo[1]); float width = CCUtils.CCParseFloat(sizeInfo[0]); float height = CCUtils.CCParseFloat(sizeInfo[1]); result = new CCRect(x, y, width, height); } while (false); return(result); }
public bool Parse(string str, int length) { TextReader textReader = new StringReader(str); var setting = new XmlReaderSettings(); #if !PSM setting.DtdProcessing = DtdProcessing.Ignore; #endif XmlReader xmlReader = XmlReader.Create(textReader, setting); int dataindex = 0; int Width = 0; int Height = 0; ; while (xmlReader.Read()) { string name = xmlReader.Name; switch (xmlReader.NodeType) { case XmlNodeType.Element: string[] attrs = null; if (name == "map") { Width = CCUtils.CCParseInt(xmlReader.GetAttribute("width")); Height = CCUtils.CCParseInt(xmlReader.GetAttribute("height")); } if (xmlReader.HasAttributes) { attrs = new string[xmlReader.AttributeCount * 2]; xmlReader.MoveToFirstAttribute(); int i = 0; attrs[0] = xmlReader.Name; attrs[1] = xmlReader.Value; i += 2; while (xmlReader.MoveToNextAttribute()) { attrs[i] = xmlReader.Name; attrs[i + 1] = xmlReader.Value; i += 2; } // Move the reader back to the element node. xmlReader.MoveToElement(); } StartElement(this, name, attrs); byte[] buffer = null; //read data content of tmx file if (name == "data") { if (attrs != null) { string encoding = ""; for (int i = 0; i < attrs.Length; i++) { if (attrs[i] == "encoding") { encoding = attrs[i + 1]; } } if (encoding == "base64") { int dataSize = (Width * Height * 4) + 1024; buffer = new byte[dataSize]; xmlReader.ReadElementContentAsBase64(buffer, 0, dataSize); } else { string value = xmlReader.ReadElementContentAsString(); buffer = Encoding.UTF8.GetBytes(value); } } TextHandler(this, buffer, buffer.Length); EndElement(this, name); } else if (name == "key" || name == "integer" || name == "real" || name == "string") { string value = xmlReader.ReadElementContentAsString(); buffer = Encoding.UTF8.GetBytes(value); TextHandler(this, buffer, buffer.Length); EndElement(this, name); } else if (xmlReader.IsEmptyElement) { EndElement(this, name); } break; case XmlNodeType.EndElement: EndElement(this, xmlReader.Name); dataindex++; break; default: break; } } return(true); }
public static void Init(GraphicsDevice graphicsDevice) { CCDrawManager.graphicsDevice = graphicsDevice; spriteBatch = new SpriteBatch(graphicsDevice); m_defaultEffect = new BasicEffect(graphicsDevice); PrimitiveEffect = new BasicEffect(graphicsDevice) { TextureEnabled = false, VertexColorEnabled = true }; m_DepthEnableStencilState = new DepthStencilState { DepthBufferEnable = true, DepthBufferWriteEnable = true, TwoSidedStencilMode = true }; m_DepthDisableStencilState = new DepthStencilState { DepthBufferEnable = false }; #if !WINDOWS_PHONE && !XBOX && !WINDOWS && !NETFX_CORE && !PSM List <string> extensions = CCUtils.GetGLExtensions(); foreach (string s in extensions) { switch (s) { case "GL_OES_depth24": m_PlatformDepthFormat = DepthFormat.Depth24; break; case "GL_IMG_texture_npot": m_AllowNonPower2Textures = true; break; case "GL_NV_depth_nonlinear": // nVidia Depth 16 non-linear m_PlatformDepthFormat = DepthFormat.Depth16; break; case "GL_NV_texture_npot_2D_mipmap": // nVidia - nPot textures and mipmaps m_AllowNonPower2Textures = true; break; } } #endif PresentationParameters pp = graphicsDevice.PresentationParameters; //pp.RenderTargetUsage = RenderTargetUsage.PreserveContents; //_renderTarget = new RenderTarget2D(graphicsDevice, pp.BackBufferWidth, (int)pp.BackBufferHeight, false, pp.BackBufferFormat, pp.DepthStencilFormat, pp.MultiSampleCount, RenderTargetUsage.PreserveContents); m_fScaleY = 1.0f; m_fScaleX = 1.0f; m_eResolutionPolicy = ResolutionPolicy.UnKnown; m_obViewPortRect = new CCRect(0, 0, pp.BackBufferWidth, pp.BackBufferHeight); m_obScreenSize = m_obDesignResolutionSize = m_obViewPortRect.Size; CCDrawingPrimitives.Init(graphicsDevice); }