Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Game Development

Reply
 
LinkBack Thread Tools Display Modes
Old 10-08-2010, 08:59 AM   #1 (permalink)
Registered Member
 
Join Date: Aug 2010
Location: Cluj-Napoca, Romania
Posts: 15
Vladutzz is on a distinguished road
Send a message via Yahoo to Vladutzz
Default CCRenderTexture

Hey,

I'm having a problem using the CCRenderTexture class.
I am trying to get my game background, which is loaded on every level and stays the same.
What i am trying to achieve is
- on load, call begin on the renderTexture object
- render a sprite by calling [someImageSprite visit]
- [renderTexture end]
- draw the rendered sprite on screen by adding the renderTexture on the layer.

All i get is a big black square -- Nothing rendered. In some cases i get like a small portion of my sprite (which is 480 x 320), something like 10x10, streched onto the entire screen.
Sprite dimensions are fine, renderTexture size is fine also.

Any ideas on what i might be doing wrong?
PS: not very much documentation on CCRenderTexture on the web either
Vladutzz is offline   Reply With Quote
Old 10-08-2010, 09:07 AM   #2 (permalink)
Registered Member
 
Join Date: Aug 2010
Location: Cluj-Napoca, Romania
Posts: 15
Vladutzz is on a distinguished road
Send a message via Yahoo to Vladutzz
Default

This is the code:

Code:
	// Create a render texture that is the size of the background asset
	CCSprite *backGroundSprite = [CCSprite spriteWithFile:@"bg_default.png"];
	CCRenderTexture *textureRenderer = [[CCRenderTexture renderTextureWithWidth:backGroundSprite.contentSize.width height:backGroundSprite.contentSize.height] retain];
	[textureRenderer setPosition:ccp(240, 160)];
	textureRenderer.sprite = backGroundSprite;
	[[textureRenderer sprite] setBlendFunc:(ccBlendFunc){GL_ONE, GL_ONE_MINUS_SRC_ALPHA}];
	// Everything between [textureRenderer begin] and [textureRenderer end]
	// will render into our renderTexture
	[textureRenderer begin];
	[backGroundSprite visit];
	[textureRenderer end];
	[self addChild:textureRenderer z:SW_Z_ORDER_TERRAIN];
Vladutzz is offline   Reply With Quote
Old 10-08-2010, 10:03 AM   #3 (permalink)
Registered Member
 
Join Date: Aug 2010
Location: Cluj-Napoca, Romania
Posts: 15
Vladutzz is on a distinguished road
Send a message via Yahoo to Vladutzz
Default

I've done some progression.
The sprite i am trying to render is 480x320 (landscape).
If i set scale for the spriteObject to an extremly small value, something like
Code:
[backGroundSprite setScale:0.005];
the rendering works correctly, the whole image loads, however i can't make it to fit the screen as it's supposed to, due to resizinng.

If anyone has ever encountered this, i would like to know how the rendering is done, regarding to how the images are scaled when rendered.
Thanks.
Vladutzz is offline   Reply With Quote
Old 02-01-2012, 06:07 AM   #4 (permalink)
Registered Member
 
Join Date: Feb 2012
Posts: 1
ziip is on a distinguished road
Default

Quote:
Originally Posted by Vladutzz View Post
I've done some progression.
The sprite i am trying to render is 480x320 (landscape).
If i set scale for the spriteObject to an extremly small value, something like
Code:
[backGroundSprite setScale:0.005];
the rendering works correctly, the whole image loads, however i can't make it to fit the screen as it's supposed to, due to resizinng.

If anyone has ever encountered this, i would like to know how the rendering is done, regarding to how the images are scaled when rendered.
Thanks.
When you want to draw in new thread you should setup projection matrix and matrix mode. So try this:
Code:
[EAGLContext setCurrentContext:context] 
[[CCDirector sharedDirector] setGLDefaultValues];
ziip is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 404
11 members and 393 guests
7twenty7, ChrisYates, djohnson, gmarro, hussain1982, Kirkout, Retouchable, skrew88, SLIC, walex, xzoonxoom
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,679
Threads: 94,128
Posts: 402,921
Top Poster: BrianSlick (7,990)
Welcome to our newest member, xzoonxoom
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 08:08 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0