i created new project i added:
Size winSize = Director::getInstance()->getWinSize();
RenderTexture* pRenderTexture = RenderTexture::create(winSize.width, winSize.height, Texture2D::PixelFormat::BGRA8888);
and i keep getting this error:
cocos2d: Texture2D: Error uploading compressed texture level: 0 . glError: 0x0500
Assert failed: Could not attach texture to framebuffer
Assertion failed!
by the way the cpp-test RenderTexture example do work .
what im doing wrong here ?
Using:
cocos2d-x v3.3
win7 32bit
It means that BGRA8888 is not supported by your opengl. Use RGBA8888 if it suitable for you.
And you have typo:
RenderTexture* pRenderTexture; = RenderTexture::create
_____________________________^
Related
I'm working on a university project and it requires us to load up a cube model, texture it and do some other stuff with it.
We have been provided with a basic framework that uses SOIL to load up textures into OpenGL.
However, when I call the function:
SOIL_load_OGL_texture("Barren Reds.JPG", SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, SOIL_FLAG_MIPMAPS);
I get the following error:
OpenGL Debug Output: Source(OpenGL), Type(Error), Priority(High), Error has been generated. GL error GL_INVALID_ENUM in GetString: (ID: 491340553) Generic error
OpenGL Debug Output: Source(OpenGL), Type(Error), Priority(High), Error has been generated. GL error GL_INVALID_ENUM in TexParameteri: (ID: 2102148481) Generic error
OpenGL Debug Output: Source(OpenGL), Type(Error), Priority(High), Error has been generated. GL error GL_INVALID_ENUM in TexParameteri: (ID: 2102148481) Generic error
The thing is, I have another framework that uses SOIL too and when I run the same function with the same texture, it works fine. So I figured my SOIL build is not good, so I copied the working SOIL build to my project and still the same error.
I get these 3 lines of error whenever I call the function, so if I call it to create 3 textures I get it 3 times.
If you're using a Core context be aware that SOIL's query_tex_rectangle_capability() unconditionally calls glGetString(GL_EXTENSIONS) (GL_EXTENSIONS is not a valid argument for glGetString() in Core contexts and will generate a GL_INVALID_ENUM) instead of using glGetStringi() to iterate over extension strings.
Your options are:
Fix SOIL, or
Use stb_image.h directly and handle texture upload yourself, or
Use a Compatibility context (where glGetString(GL_EXTENSIONS) is still valid usage)
I'm implementing gameplay recording feature into cross platform Cocos2d-x game. I managed to implement those features for iOS and Android but I'm struggling to get good performance on macOS. I have implemented succesfully gameplay recording using glReadPixels function but performance is very low. I'm getting about 10-15 fps on my Macbook Pro. I was trying to implement AVCaptureSession to record whole screen and then crop required area just like in the AVScreenShack sample from Apple but I'm getting Cocos2d-x Renderer errors.
Error log looks like this:
OpenGL error 0x0501 in /Users/milosz/Documents/job/butterflix/blix/cocos2d/cocos/2d/CCParticleSystemQuad.cpp postStep 458
OpenGL error 0x0506 in /Users/milosz/Documents/job/butterflix/blix/cocos2d/cocos/renderer/CCFrameBuffer.cpp applyFBO 445
FrameBuffer Status Error 33305
OpenGL error 0x0506 in /Users/milosz/Documents/job/butterflix/blix/cocos2d/cocos/renderer/CCFrameBuffer.cpp applyFBO 445
FrameBuffer Status Error 33305
FrameBuffer Status Error 33305
OpenGL error 0x0501 in /Users/milosz/Documents/job/butterflix/blix/cocos2d/cocos/renderer/CCRenderer.cpp saveRenderState 161
OpenGL error 0x0501 in /Users/milosz/Documents/job/butterflix/blix/cocos2d/cocos/renderer/CCTextureAtlas.cpp drawNumberOfQuads 691
FrameBuffer Status Error 33305
OpenGL error 0x0501 in /Users/milosz/Documents/job/butterflix/blix/cocos2d/cocos/renderer/CCRenderer.cpp restoreRenderState 192
OpenGL error 0x0501 in /Users/milosz/Documents/job/butterflix/blix/cocos2d/cocos/2d/CCParticleSystemQuad.cpp postStep 458
OpenGL error 0x0501 in /Users/milosz/Documents/job/butterflix/blix/cocos2d/cocos/2d/CCParticleSystemQuad.cpp postStep 458
OpenGL error 0x0506 in /Users/milosz/Documents/job/butterflix/blix/cocos2d/cocos/renderer/CCFrameBuffer.cpp applyFBO 445
FrameBuffer Status Error 33305
OpenGL error 0x0506 in /Users/milosz/Documents/job/butterflix/blix/cocos2d/cocos/renderer/CCFrameBuffer.cpp applyFBO 445
FrameBuffer Status Error 33305
FrameBuffer Status Error 33305
OpenGL error 0x0501 in /Users/milosz/Documents/job/butterflix/blix/cocos2d/cocos/renderer/CCRenderer.cpp saveRenderState 161
My first thought was that the AVCaptureSession uses NSOpengGLContext to render frames so I checked if the context has changed but it didn't. I also was trying CVOpenGLTextureCache accordingly to the method I'm using on iOS but without success.
However when I'm running AVScreenShack example while playing my game it records whole screen and doesn't mess with the Cocos2d-x renderer. I think that is because both apps running on separate main threads and therefore there is no some kind of race condition occuring. Can I replicate this kind of behaviour in single Mac app? Or there is any other method to record Cocos2d-x gameplay with reasonable performance on MacOS?
I had a similiar issue but with Qt app. After calling [AVCaptureSession startRunning] my OpenGL stopped working properly.
In my case current NSOpenGLContext was nil after calling startRunning.
So solution for me was:
QOpenGLContext *currentContext = QOpenGLContext::currentContext();
QSurface *currentSurface = currentContext->surface();
[m_Session startRunning];
currentContext->makeCurrent(currentSurface);
I can load 725x483 jpg texture but not 725x544
the code:
texId = SOIL_load_OGL_texture(fileName, SOIL_LOAD_AUTO,
SOIL_CREATE_NEW_ID, 0);
I got error:
Access violation reading location 0x06851002 - VS2012 express
I debugged SOIL a bit and it seems that the error comes just after we call glTexImage2D (in the SOIL library).
When I add SOIL_FLAG_MIPMAP to the loading code it works fine.
This error was on AMD (5570) and Intel (HD 4000) as well.
Solved, but I think it is worth to mention the solution:
use proper GL_UNPACK_ALIGNMENT, by default it is 4, but when I changed it to 1 it worked!
or change data format from SOIL_LOAD_AUTO to SOIL_RGBA. AUTO means original texture format and for jpg images it is RGB, so it can be problematic when unpack alignment is 4.
with SOIL_FLAG_MIPMAP soil actually rescales image to POT and that way there are no problems with unpack alignment size.
I have only a line to load particle.png, and the texture is embedded in it.
Sometimes the texture is seen and somethimes it does not appear.
I noticed I get a warning message:
cocos2d: Warning: File not found: particleTexture.png
My just code to load plist particle is this :
CCParticleSystemQuad emitter=[CCParticleSystemQuad particleWithFile:#"rain.plist"];
This is interesting:
Sometimes the texture is seen: sometimes it is not, and instead of the texture I see gradient balls.
I have created cocos2d game. During testing i got some memory warnings, i solved all memory warnings in ipad3(New ipad) but i couldnt solve the below memory warning in ipad 1. Can you guys please help me....
1.
2012-08-01 22:19:16.399 Game[238:707] cocos2d: CCSpriteFrameCache: Trying to use file 'Animation.png' as texture
2012-08-01 22:19:16.662 Game[238:707] cocos2d: CCSpriteFrameCache: Trying to use file 'Ani.png' as texture
2012-08-01 22:19:16.681 Game[238:707] cocos2d: CCSpriteFrameCache: Trying to use file 'Faces.png' as texture
2012-08-01 22:19:16.753 Game[238:707] cocos2d: removeChildByTag: child not found!
2012-08-01 22:19:16.819 Game[238:707] Received memory warning.
2.
2012-08-01 22:23:11.573 Game[238:707] cocos2d: Received memory warning.
2012-08-01 22:23:11.573 Game[238:707] cocos2d: CCTextureCache: removing unused texture: img.jpg
2012-08-01 22:23:11.576 Game[238:707] cocos2d: CCTextureCache: removing unused texture: play.png
2012-08-01 22:23:11.582 Game[238:707] cocos2d: CCTextureCache: removing unused texture: img1.png
2012-08-01 22:23:11.585 Game[238:707] cocos2d: CCTextureCache: removing unused texture: youNeedToPopup.png
2012-08-01 22:23:11.590 Game[238:707] cocos2d: CCTextureCache: removing unused texture: popup.png
2012-08-01 22:23:11.599 Game[238:707] cocos2d: CCTextureCache: removing unused texture: conti.png
thanks
Memory warnings are completely normal. Indeed, this is the mechanism that allow iOS to retake back used memory that can be freed and continue working without crashing.
You can observe that in Instruments Allocation tools: memory is gradually filled up; then a memory warning is sent, and you will see memory quickly to be freed (up to a point). This is the sign of a healthy application.
What you should worry about is that, when a memory warning is sent out, memory is not recovered. But then your app would promptly be killed.
So, memory warnings + app not crashing is no worry at all.