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);
Related
I am working on a small game engine on my main computer, but when i cloned the project on my laptop I just get a lot of error messages and displays a blank screen.
Here are some of the error messages I am getting every frame from calling the SFML draw function:
Warning: The created OpenGL context does not fully meet the settings that were requested
Requested: version = 4.4 ; depth bits = 24 ; stencil bits = 8 ; AA level = 1 ; core = false ; debug = false ; sRGB = false
Created: version = 4.5 ; depth bits = 24 ; stencil bits = 8 ; AA level = 4 ; core = true ; debug = false ; sRGB = false
An internal OpenGL call failed in RenderTarget.cpp(369).
Expression:
GLEXT_glClientActiveTexture(GLEXT_GL_TEXTURE0)
Error description:
GL_INVALID_OPERATION
The specified operation is not allowed in the current state.
An internal OpenGL call failed in RenderTarget.cpp(375).
Expression:
glDisable(GL_LIGHTING)
Error description:
GL_INVALID_ENUM
An unacceptable value has been specified for an enumerated argument.
An internal OpenGL call failed in RenderTarget.cpp(377).
Expression:
glDisable(GL_ALPHA_TEST)
Error description:
GL_INVALID_ENUM
An unacceptable value has been specified for an enumerated argument.
An internal OpenGL call failed in RenderTarget.cpp(378).
Expression:
glEnable(GL_TEXTURE_2D)
Error description:
GL_INVALID_ENUM
An unacceptable value has been specified for an enumerated argument.
An internal OpenGL call failed in RenderTarget.cpp(380).
Expression:
glMatrixMode(GL_MODELVIEW)
Error description:
GL_INVALID_OPERATION
The specified operation is not allowed in the current state.
An internal OpenGL call failed in RenderTarget.cpp(381).
Expression:
glEnableClientState(GL_VERTEX_ARRAY)
Error description:
GL_INVALID_OPERATION
The specified operation is not allowed in the current state.
I am simply drawing sprites and textures in the menu screen, and it seems like even the OpenGL functions to draw also produces errors. Here's the link to my github repo: https://github.com/ZzkilzZ/mfengine
I am running the LTS version of Ubuntu on both my computers, and what i think it might be is a discrepancy in the versions of certain dependencies?
EDIT:
These are my glxinfo results:
OpenGL vendor string: Intel Open Source Technology Center
OpenGL renderer string: Mesa DRI Intel(R) Haswell Mobile
OpenGL core profile version string: 4.5 (Core Profile) Mesa 19.0.8
OpenGL core profile shading language version string: 4.50
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
OpenGL version string: 3.0 Mesa 19.0.8
OpenGL shading language version string: 1.30
OpenGL context flags: (none)
OpenGL extensions:
OpenGL ES profile version string: OpenGL ES 3.1 Mesa 19.0.8
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.10
OpenGL ES profile extensions:
I am running Ubuntu 18.4 LTS
You are creating an OpenGL Core Profile context, but the code uses legacy fixed-function stuff like glDisable(GL_LIGHTING). The solution is to request a compatiblity profile when creating the context. It depends on your OpenGL implementation if compatibility profile is available. I suggest you find a more modern example code.
It looks like that Compatibility Profile can be set in SFML's sf::ContextSettings::attributeFlags or
glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR,4);
glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR,5);
glfwOpenWindowHint(GLFW_OPENGL_PROFILE,GLFW_OPENGL_COMPAT_PROFILE);
Thank you to #SurvivalMachine and #derhass for your help!
I eventually downgraded the opengl all the way down to version 3.0 and glsl down to 130 core and got the menu screen working again. It loads everything but the shaders but i suspect this is the result of me using more modern functions. I am giving up on older computers, this seems like too much of a sacrifice just for 2015 computers to work :D
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 am updating a Maya 2016 plugin (C++) to Maya 2017. This plugin is displaying OpenGL shapes (VBOs) in the standard 2.0 ViewPort, and was working perfectly in Maya 2016 with OpenGL 2.1.
Now Maya 2017 comes with OpenGL 4.1 and before doing any opengl action, the glErrorString executed in the prepareForDraw function gives Invalid Operation (code 1282).
This seems to come from the fact no OpenGL context is available. Do I need to manually create an OpenGL context or has Maya a function to create it for me, or should I link an existing Maya context to OpenGL ?
I can share some code if need be, but not sure it would be relevant at this stage.
The issue came from an old define I had:
#ifdef __APPLE__
#define glGenVertexArrays glGenVertexArraysAPPLE
#define glBindVertexArray glBindVertexArrayAPPLE
#define glDeleteVertexArrays glDeleteVertexArraysAPPLE
#endif
removing these lines made the errors disappear
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
_____________________________^
I'm developing a 3D stereoscopic OpenGL app specifically for Windows 7 and nVidia Quadro K5000 cards. Rendering the scene from left and right-eye perspectives using glDrawBuffer(GL_BACK_LEFT) and glDrawBuffer(GL_BACK_RIGHT) works fine, and the 3D effect is displayed nicely.
While this works, I'd like to use nVidia's nSight Graphics local debugging. However, I get the error "Cannot enter frame debugging. nSight only supports frame debugging for ... OpenGL 4.2. Reason: glDrawBuffer(bufs[i] = 0x00000402)"
If the calls to glDrawBuffer are removed, nSight local debugging works.
Going through the OpenGL 4.2 spec, DrawBuffer is described in section 4.2.1
So, two questions:
1) Is there some other way (besides DrawBuffer) to specify BACK_RIGHT or BACK_LEFT buffers for drawing to quad-buffers?
2) Is nSight capable of doing frame-level debugging on quad-buffered stereoscopic setups? If so, how?