I'm trying to get a texture id from metal surface.
I have two problems
1. That function is not defined
GLint glTextureID = CGLTexImageIOSurface2D(self.mEAGLContext, GL_TEXTURE_2D, GL_RGBA , textureWidth, textureHeight, GL_RGBA , GL_UNSIGNED_BYTE, ioSurface, 0);
I tried to include it #import OpenGL/CGLIOSurface.h
but xcode doesn't recognize it, it's not there.
Are there any other methods to obtain a texture id from an iosurface in ios, metal ?
In my software, the following line pulls in the requested function:
#include <OpenGL/CGLIOSurface.h>
This header file is at the following location in my xcode installation:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Versions/A/Headers/CGLIOSurface.h
Note that I am using the MacOS SDK. Perhaps iOS doesn't support GL/IOSurface sharing?
Related
I'm trying to understand Apple's Metal and converting some old opengl shaders. I'm stuck in an error that appears only in one project and not the others. I wanted to ask if there is a compiler option or something like that, that I do not know and can cause this error.
So... I've got an audio visualizer for a music player that I wrote sometime ago using opengl on ndk for Android. I converted the shader to metal on an empty project. The fragment method signature is like this:
fragment float4 spectrum_fragment_func(
Vertex vert [[stage_in]],
device Fragment *uniforms [[buffer(0)]],
device float *left [[buffer(1)]],
device float *right [[buffer(2)]]
)
I'm updating the Fragment object in code. It has a "time" value and needs to be updated for the effects to take place, meaning I cannot use constant values.
Shader compiles and works without any problems on the test application, that simply has a ViewController and my MTKView class.
When I copy the classes and shaders as-is to another project, I start getting this error:
/Volumes/Additional/Projects/.../Visuals/Shaders.metal:31:189:
Pointer argument to fragment function must be const
If I convert the Fragment variable to constant, this time error appears for the next value in the signature. It seems that in this project, something is changed and does not accept any other types of variables but only consts...
If anyone had a similar problem, or know how to solve this I'm stuck and need some help.
I'm working with Qt(especially 5.5) on iOS device not simulator
I'm just add Video object to QML code for play HLS stream like below.
Video {
id: livePlayer
anchors.fill: parent
source: "http://content.jwplatform.com/manifests/vM7nH0Kl.m3u8"
autoPlay: true
}
But Qt returns me bug with log like below
Failed to find shader ":/qtmultimediaquicktools/shaders/rgbvideo.vert"
Failed to find shader ":/qtmultimediaquicktools/shaders/rgbvideo.frag"
QOpenGLShader::link: "ERROR: Compiled vertex shader was corrupt.\nERROR: Compiled fragment shader was corrupt.\n"
shader compilation failed:
"ERROR: Compiled vertex shader was corrupt.\nERROR: Compiled fragment shader was corrupt.\n"
QOpenGLShader::link: "ERROR: Compiled vertex shader was corrupt.\nERROR: Compiled fragment shader was corrupt.\n"
QOpenGLShaderProgram::uniformLocation( qt_Matrix ): shader program is not linked
QOpenGLShaderProgram::uniformLocation( rgbTexture ): shader program is not linked
QOpenGLShaderProgram::uniformLocation( opacity ): shader program is not linked
I was doing somethings what I can -Clean, Run QMake, etc-
But its useless.
Give me some help plz.
Thanks have a good day.
This is a temporary bug in the Qt 5.5 branch.
To fix it with the current 5.5 snapshots, add this to your main() function:
Q_INIT_RESOURCE(qtmultimediaquicktools);
The issue is already fixed in the current 5.5 branch of Qt, find the fix here or wait for the next snapshot.
Hi everyone, i have been trying Instanced drawing in OpenGLES2.0, in IOS platform. My rendering code
glEnableVertexAttribArray(...);
glVertexAttribPointer(...)
glDrawElementsInstancedEXT(GL_TRIANGLES,IndicesCount, GL_UNSIGNED_SHORT, 0, 5);
And my Vertex Shader
attribute vec4 VertPosition;
uniform mat4 mvpMatrix[600];
void main()
{
gl_Position = (mvpMatrix[gl_InstanceID]) * VertPosition;
}
I'm getting ERROR: Use of undeclared identifier 'gl_InstanceID'
my glsl version is 1.0, if version is the issue then how can i upgrade ? Any other way to use "gl_InstanceID" in GLSL ?
gl_InstanceID is only available starting from GLSL ES 3.0 as stated here.
So this is, as you already suspected, a version issue. As far as I know, the only available GLSL ES version in OpenGL ES 2.0 is GLSL ES 1.0, and if you want to use a higher GLSL ES version you have to upgrade to OpenGL ES 3.0. (more details here)
Edit: I was thinking about what you want to achieve with the usage of gl_InstanceID. This variable does only make sense when using one of the instanced draw commands (glDrawArraysInstanced etc.), which are also not available in ES 2.0.
Apparently, there is a possibility to use instanced rendering in OpenGL ES 2.0 by using the GL_EXT_draw_instanced extension. This extension provides one with two additional draw commands for instanced drawing (glDrawElementsInstancedEXT and glDrawArraysInstancedEXT). When using the extension, one has to enable it in the shader
#extension GL_EXT_draw_instanced : enable
and use gl_InstanceIDEXT instead of gl_InstanceID.
When using Swift to create an OpenGL app I get this error whenever I use OpenGL commands, for example:
glBindRenderbuffer(GL_RENDERBUFFER, self.colorRenderBuffer)
I get an error 'Int32' is not convertible to 'Glenum'
Any ideas how to fix this?
Constants like the ones OpenGL uses are imported in Swift as top-level variable declarations instead of enum declarations. Because OpenGL doesn't actually use an enum, you'll have to explicitly construct a GLenum with GL_RENDERBUFFER as its primitive value:
glBindRenderbuffer(GLenum(GL_RENDERBUFFER), 0)
I have written the following piece of code to extract the image of the region detected as face using the OpenCV2.2 facedetect.c code.
//Extracting the image of just the ROI
IplImage* rectImage;
rectImage->roi=NULL;
CvRect boundingBox={point1.x,point1.y,r->width,r->height};
cvSetImageROI(rectImage,boundingBox);
IplImage* originalBox=cvCreateImage(cvSize(r->width,r->height),IPL_DEPTH_8U,3);
IplImage* reSizedBox=cvCreateImage(cvSize(100,100),IPL_DEPTH_8U,3);
cvCopy(rectImage, originalBox, 0);
cvResize(originalBox,reSizedBox,CV_INTER_LINEAR);
cvSaveImage("MyFaceBox.jpg", reSizedBox);
Problem: When I build it, it gives the following error:
"error: ‘cvResize’ was not declared in this scope"
I am using xcode as a developer tool. I cannot understand what is creating the problem. Can someone please help?
Thanks
Did you include the relating header file, like
#include <imgproc/imgproc_c.h>