Recently I migrate my project to Kobold2D 1.1 with Cocos2D 1.1beta2 inside for iPad Retina Display. But when I run my project and try to put a TMX tile map, the program hung up. The problem is CCTexture2D is call in InitWithImage and there's no Case for texture format AI88. Because of that, program goes to default and hang up.
I add to the code:
case kCCTexture2DPixelFormat_AI88:
data = malloc(POTHigh * POTWide);
info = kCGImageAlphaOnly;
context = CGBitmapContextCreate(data, POTWide, POTHigh, 8, POTWide, NULL, info);
break;
Is the same config as kCCTexture2DPixelFormat_A8 and now code works. I used a TMX made with Tile Editor 0.8 and uses a simple PNG not in any texture packer. The name inside TMX is fondomaze.png but in the project I must rename to fondomaze-ipad.png.
Hope you find useful. Now I can breathe relax with my project still working!
Discover a workaround for Retina Display iPad... Must to increase malloc by 4.
data = malloc(POTHigh * POTWide * 4);
Hope helps people who want to work with RD iPad.
Related
I am working on a project that presents live data acquired in real-time using the QCustomPlot plug-in for Qt. The display has a black background color, and the multiple channels of data are colored differently. When taking a screenshot, we would like to make it printer-friendly, so the background is white and all data is black. I am thinking of a solution like this:
Change all colors the way I want by manipulating the pointers for the graphical objects
Grab the screenshot using QWidget::grab() to get a QPixmap
Change all the colors back to normal
This did not work at first, because the system could not change the colors in time for the screenshot to be taken. So I used a QApplication::processEvents(), and it all worked on my Mac.
However, it does not work on a Windows 7 (which is required). Any ideas what to do?
Code:
QSting fileLocation = "...";
toggleColors(false); //function to toggle the colors
QApplication::processEvents();
QPixmap shot = grab();
toggleColors(true);
shot.save(fileLocation, "png");
Again. It works on Mac, but not Windows.
Update 1. Content of toggleColors include:
if(enable)
ui->plot->setBackground(QBrush(Qt::black));
else
ui->plot->setBackground(QBrush(Qt::white));
ui->plot->repaint();
I also tried with ui->plot->update() instead.
I am not sure what is the problem on Windows specifically, but I recommend you calling QWidget::update() on the given widget. That forces the next update to re-render itself.
On the other hand, I'm not sure why toggleColors() didn't somehow cause that to happen.
Also, ensure that QWidget::setUpdatesEnabled(bool) wasn't set to "false."
It appears the problem lies with QCustomPlot. It was solved by performing a ui->plot->replot() which is specific to QCustomPlot and not QWidget.
I have a problem.
i'm trying to make a screenshot of a scene then make a sprite and pass this sprite to other scene.
i'm doing this:
RenderTexture* texture = RenderTexture::create((int)Director::getInstance()->getWinSize().width, (int)Director::getInstance()->getWinSize().height, Texture2D::PixelFormat::RGBA8888);
texture->begin();
Director::getInstance()->getRunningScene()->visit();
texture->end();
Sprite* bgSprite = Sprite::createWithTexture(texture->getSprite()->getTexture());
bgSprite->setRotationX(180);
/-------------------------------------
LoadScreen* loadLayer = LoadScreen::create(GameScene, this->_carModel, bgSprite/*, this*/);
/-------------------------------------
then in next scene i do:
bgSprite->setPosition(Point(Director::getInstance()->getVisibleSize().width / 2, Director::getInstance()->getVisibleSize().height / 2));
bgSprite->setOpacity(200);
this->addChild(bgSprite, 1, 1);
I debug this. Sprite is not null. The texture in this sprite has size and etc.
I try to save texure in file. The result is empty .png file.
It's an engine problem, the file is alway saved with RGB in the previous version.
Since the rendering of cocos2d-x 3.0 is based on the command queue, we should always wrap the read/write frame buffer operations with commands. Invoking newImage() directly is not guaranteed to work fine. But "RenderTexture::saveToFile" should work fine because it's wrapped with a custom command in code.
I think this issue has already been solved in cocos2d-x v3.3, please refer http://www.cocos2d-x.org/issues/5562 for more information.
And also you could take a look at "cpp-tests" bundled with cocos2d-x to see how to save screenshot of your scene or sprite.
I'm trying to integrate the new Oculus SDK (for the DK2) into Game Maker Studio.
I'm doing this by creating a DLL that communicates with GM and with the new SDK. I've come to a point where i just don't know what to do anymore.
Currently, i can get the oculus to turn on, and see the Health notice displayed in the oculus. The health display also seems to get drawn over the GM application window - after which the GM application draws itself over the window again - its like 2 applications are drawing in the same window.
The problem is, i need the application display to be fed into the DLL, parsed through there (to add distortion and some filters for the lenses of the oculus), and then spit it out into the Oculus device. The GM surface and oculus surface have to be combined and put in the oculus device.
I have 2 types of pointers availble - 1 for the HWND of the application (used here), and 1 DX Device pointer (i think, its used like so:
LPDIRECT3DDEVICE9 d3ddev;
GMEXPORT double LinkD3D( long POINTER ){
d3ddev = (LPDIRECT3DDEVICE9)POINTER;
// Enable 8x Anisotropic Filtering
d3ddev->SetSamplerState(0, D3DSAMP_MAXANISOTROPY, 8);
d3ddev->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_ANISOTROPIC);
// Enable Linear Filtering
d3ddev->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
d3ddev->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);
return 1;
}
Now i wonder, how can i get that LPDIRECT3DDEVICE9 into the DX11 stuff of the oculus SDK.
Currently i get the healthwarning to get drawn over the existing window.
I was thinking, maybe i need the internal texture (used above, d3ddev), and put it in the Ouculus pRender device, somewhere around here;
https://github.com/RobQuistNL/GMOculus/blob/master/DLL/GMOculus/GMOculus/main.cpp#L223
The source code of the project is found here; https://github.com/RobQuistNL/GMOculus/blob/master/DLL/GMOculus/GMOculus/main.cpp
I'm very sorry for the vague explaination, but please keep in mind that;
Im actually a webdeveloper
I use game maker for hobby games
Know somewhat C++
Have 0 experience with DX
I'm actually happy i can already get thehealth notice to draw on the oculus.
Its just that i can't seem to convert anything. I've tried textures, swapchains, render devices - but i keep getting errors. Am i looking in the wrong direction?
I am even willing to pay if someone can help me out.
Cheers,
Rob
I have a cocos2d game that has a loading scene where we load a bunch of assets. The game starts with the splash screen, and then launches the loading scene. The loading scene starts by loading the background, so the user sees the loading scene background while the assets are being loaded.
I load the loading scene background by calling CCSprite::spriteWithFile: and passing the filepath: loadingbackground.pvr.ccz
It seems to work differently on different devices:
On iphone (3gs) simulator, I see the loading scene as expected.
On iphone retina simulator, I don't see the loading scene (there aren't many assets yet, so may be happening quickly) and it goes directly to the main menu scene.
On the ipad 3 device, the splash screen comes up, and then there is a half second of black screen, and then the main menu scene shows up.
I want to see what I can do to avoid that black screen showing up on iPad 3. I suspect this is because of the time taken to load the loading background.
I have tried the following optimizations (mostly based on #Steffen's blog post on memory optimization):
Moved the loading background (originally 2.3 MB RGB8 png file) into a pvr.ccz spritesheet by itself, which reduced its size to 1.8 MB.
Removed the image from the texture soon after use.
I still see a black screen on iPad 3. Any suggestions?
Update: Found the issue - I had some code where I was overriding OnEnter and calling [[CCDirector sharedDirector]replaceScene] in it, and also calling the same from the background thread. Removed the OnEnter overload and it worked without flicker.
Thanks
Ignore whatever happens in Simulator. That's not relevant, focus on the device.
When the loading scene initializes and you add the loading scene's background, make sure you schedule update and load your assets in the update method. Otherwise if you load the assets in init, the background won't be drawn because you're loading all the assets before cocos2d gets to redraw the screen.
If this still fails, simply send the visit message to the background sprite followed by [[CCDirector sharedDirector] drawScene]. This forces a redraw of the scene.
Is this cocos2d-iphone or cocos2d-x ? make sure the tags are correct :)
I think you're referring to the startup flicker, there are a few ways to avoid that.
first thing you need to make sure you're handling the rootViewController correctly for iOS 6 and iOS 5 and below, there are a little changes for each.
You can find a little reference here:
http://www.cocos2d-iphone.org/forum/topic/34471
Second thing you need to know that simulator's behaviour is not stable, you should always rely on real devices for testing, but it's very likely you'll still have the flicker issues.
Sorry I didn't provide example code, but you haven't supported enough information to know what's the real issue here.
I've recently noticed that things accommodate differently on the simulator and a real device when using Cocos2d.To make sure I did the following:
1. I created a blank Cocos2d project. In the init method I created 7 sprites from Icon-72.png(which is found in the resources folder of the Cocos2d template) and added them to the screen.In the simulator only 6.5 sprites could accommodate side-by-side whereas in the iPod touch all seven sprites could accommodate easily and almost half of the screen width remained unused.
2.Then I created a project from Single View Application template. I added the same Icon-72.png to the project. Then on the storyboard I added 6 image views and set their image property to Icon-72.png. This time I had exactly the same result with both simulator and the device.
I guess there should be some tweak as to how to fix this issue with Cocos2d because it's not Apple's fault. Do you know how to handle this?
The iPod Touch could have the retina display and the simulator wont have have it. If you need the same display as of the iPod Touch You can use the iPhone Simulator with the Retina Display and you would get the same screen. Another Option you can use is Copy and paste the Same file with -hd prefix ex:(Icon-72-hd.png) with 72x72 size and you can get the same result.
There is no problem with either the version of cocos2d or with the Apple for the issue you are facing.
I guess I do have poor explanation but you would understand my explanation.
The iPod Touch will be a retina display. Cocos2d doesn't automatically double the size of images.