2012-05-18 13 views
6

मैं दो छवियों है:GL_CLAMP_TO_EDGE NPOT बनावट में इस्तेमाल किया जाना चाहिए

  1. पीएनजी (sRGB) 64x64 (नेटवर्क से पूछेगा)
  2. पीएनजी (sRGB), png को fla, तो से पोर्ट, के लिए png से एसआरबीबी के साथ जेपीजी, फिर पीएनजी (एसआरबीबी) के लिए।
मैं बनावट के साथ बहुभुज को भरने के लिए कोशिश कर रहा हूँ

, इस छवि से बनाए गए:

CCTexture2D *texture = [[CCTextureCache sharedTextureCache] addImage:spriteName]; 

    polygon = [[[PhisicsFilledPoligon alloc] initWithPoints:points 
         andTexture:texture] autorelease]; 

PhysicsFilledPolygon box2d के लिए PhysicsSprite की तरह है, लेकिन overrided 'आकर्षित' विधि के साथ:

-(void) draw 
{ 
    ccGLBindTexture2D([self.texture name]); 

    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); 
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); 

    ccGLEnableVertexAttribs(kCCVertexAttribFlag_Position | kCCVertexAttribFlag_TexCoords); 

    [prog use]; 
    [prog setUniformForModelViewProjectionMatrix]; 

    glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, sizeof(CGPoint), areaTrianglePoints); 
    glVertexAttribPointer(kCCVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, sizeof(CGPoint), textureCoordinates); 

    glDrawArrays(GL_TRIANGLES, 0, areaTrianglePointCount); 
} 

जब मैं बनावट के लिए पहली छवि का उपयोग करने की कोशिश कर रहा हूं, तो सभी ठीक काम करते हैं। लेकिन चूंकि मैं 2 एक का उपयोग कर रहा हूँ, अनुप्रयोग त्रुटि के साथ दुर्घटनाओं:

*** Assertion failure in -[CCTexture2D setTexParameters:], /Users/SentineL/Documents/squirrels ios/squirrels/libs/cocos2d/CCTexture2D.m:743 
2012-05-18 14:42:26.603 squirrels[21436:707] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'GL_CLAMP_TO_EDGE should be used in NPOT textures' 

क्या कभी छवि मैं उपयोग करने के लिए कोशिश कर रहा हूँ, परिणाम एक ही त्रुटि है। Cocos2d संस्करण 2.0 आरसी 0 है। यहां cocos2d जानकारी शुरू हो रही है:

2012-05-18 14:42:25.038 squirrels[21436:707] cocos2d: OS version: 5.1 (0x05010000) 
2012-05-18 14:42:25.041 squirrels[21436:707] cocos2d: GL_VENDOR: Imagination Technologies 
2012-05-18 14:42:25.042 squirrels[21436:707] cocos2d: GL_RENDERER: PowerVR SGX 543 
2012-05-18 14:42:25.044 squirrels[21436:707] cocos2d: GL_VERSION: OpenGL ES 2.0 IMGSGX543-63.24 
2012-05-18 14:42:25.047 squirrels[21436:707] cocos2d: GL_MAX_TEXTURE_SIZE: 4096 
2012-05-18 14:42:25.048 squirrels[21436:707] cocos2d: GL_MAX_TEXTURE_UNITS: 8 
2012-05-18 14:42:25.049 squirrels[21436:707] cocos2d: GL_MAX_SAMPLES: 4 
2012-05-18 14:42:25.051 squirrels[21436:707] cocos2d: GL supports PVRTC: YES 
2012-05-18 14:42:25.053 squirrels[21436:707] cocos2d: GL supports BGRA8888 textures: YES 
2012-05-18 14:42:25.054 squirrels[21436:707] cocos2d: GL supports NPOT textures: YES 
2012-05-18 14:42:25.056 squirrels[21436:707] cocos2d: GL supports discard_framebuffer: YES 
2012-05-18 14:42:25.057 squirrels[21436:707] cocos2d: compiled with Profiling Support: NO 

2012-05-18 14:42:25.059 squirrels[21436:707] cocos2d: **** WARNING **** CC_ENABLE_GL_STATE_CACHE is disabled. To improve performance, enable it by editing ccConfig.h 

2012-05-18 14:42:25.061 squirrels[21436:707] cocos2d: cocos2d v2.0.0-rc0 
2012-05-18 14:42:25.063 squirrels[21436:707] cocos2d: Using Director Type:CCDirectorDisplayLink 
2012-05-18 14:42:25:201 squirrels[21436:707] Retina Display Not supported 
2012-05-18 14:42:25.214 squirrels[21436:707] cocos2d: animation started with frame interval: 60.00 
2012-05-18 14:42:25.234 squirrels[21436:707] cocos2d: surface size: 1024x768 

मेरी समस्या कहां है?

+0

मैं अपनी परियोजना में 64X47 और दूसरी छवि कैसे चला सकता हूं ..? – ilesh

उत्तर

11

आप नॉट-पावर-ऑफ-टू आयामों के साथ बनावट का उपयोग कर रहे हैं।

9

समस्या, मुझे लगता है, लाइनों में है:

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); 
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); 

GL_REPEAT कोर NPOT बनावट के लिए ओपन ES 2.0 कल्पना का हिस्सा नहीं है, केवल GL_CLAMP_TO_EDGE है, और इस तरह GL_REPEAT समर्थित नहीं है।

आपको मूल रूप से GL_REPEAT के बजाय GL_CLAMP_TO_EDGE सेट करना होगा, या पीओटी बनावट का उपयोग करना होगा।

2

GL_REPEAT को GL_CLAMP_TO_EDGE पर स्विच करने से त्रुटि को हटा दिया जाता है और मेरी प्रोजेक्ट में फिर से निर्माण होता है, लेकिन मैंने दोहराना प्रभाव खो दिया। मुझे कोकोस 2 डी 2.x में अपग्रेड करने के बाद ऐसा करना पड़ा। सर्वश्रेष्ठ शर्त, बस अपनी छवि आयामों को 2 की शक्ति बनाएं ... (2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048)

0

जादू शब्द हैं: सीसीसी कॉन्फ़िगरेशन। एम: // चारों ओर लाइन 122

supportsNPOT_ = NO; // before it said YES 
संबंधित मुद्दे

 संबंधित मुद्दे