How to set hints in OpenGL ES 2? - objective-c

In previous versions of OpenGL, you could set various hints such as GL_LINE_SMOOTH_HINT, and set the shade model to GL_SMOOTH. How can you do this in OpenGL ES 2?
The only hint target in ES is GL_GENERATE_MIPMAP_HINT and other things such as 1D textures are missing.

GL_SMOOTH and other lighting related (or even matrix projection) hints are not something you can hint at OpenGL ES 2.0 to do because this functionality must be implemented in the programmable shader pipeline which is left to the developer to implement in OpenGL ES 2.0 and is not handled by OpenGL ES as it was in the 1.x versions.
However, OpenGL ES 2.0 still handles mip-map generation. That is why hints like GL_GENERATE_MIPMAP_HINT are still valid.

Related

How do I convert OpenGLES shaders to Metal compatible ones?

I have a project which uses about 2 dozen .vsh and .fsh files to draw 2D tiles using OpenGLES. Since that is deprecated, I want to convert my project to Metal. My head is now swimming with vocabulary and techniques involved in both systems - graphics is not my forte.
Can I use OpenGLES to compile the .vsh/.fsh files, and then save them in a metal-compatible format? The goal would be to then use the saved information in a metal-centric world and remove all the OpenGLES code from the project. I've spent a few days on this already, and yet I don't understand the processes enough to fully attempt the transition to Metal. Any/all help is appreciated.
I saw this: "On devices that support it, the GLSL code you provide to SKShader is automatically converted to Metal shading language and run on a Metal renderer", which leads me to believe there is a way to get this done. I just don't know where to begin. OpenGL ES deprecated in iOS 12 and SKShader
I have seen this:
Convert OpenGL shader to Metal (Swift) to be used in CIFilter, and if it answers my question, I don't understand how.
I don't think this answers it either: OpenGL ES and OpenGL compatible shaders
Answers/techniques can use either Objective-C or Swift - the existing code is Objective-C, the rest of the project has been converted to Swift 5.
There are many ways to do what you want:
1) You can use MoltenGL to seamlessly convert your GLSL shaders to MSL.
2) You can use open-source shader cross-compilers like: krafix, pmfx-shader, etc.
I would like to point out that based on my experience it would be better in terms of performance that you try to rewrite the shaders yourself.

Pixel Shader performance in Directx9 not equivalent to Opengl ES2.0

I am using a drop effect by the help of pixel shader in directx-9 to be specific SlimDX.Direct3D9 written in hlsl used for transition between two images. I have written the same pixel shader in glsl language to be used in an android project using java 6.0.
The issue here is with the performance difference in both the machines. Android machines is showing smooth transition but there is a visible pixelation in Windows machines during transition. Pixel shader 2.0 version is being used in directx project
I think a couple of pictures would help immensely.
It could be a difference in sampling coordinates. Make sure you are getting 1:1 texture/pixel mapping.
Another possibility could be that the filtering is set to point instead of linear.

glmaterialfv is deprecated in opengl es2?

I found some functions like glmaterialfv are no longer available in OpenGL ES2 headers.
like the following method,
glmaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE,color)
How to set the materials using OpenGL ES2? I need to set both Front and Back ambient, diffuse colors?
The fixed function pipeline is not available in ES 2.0. So everything that includes materials, lights, the matrix stack, etc., is gone. If you look at the official spec file, ES 2.0 was actually specified as a new API, not a new version of the ES 1.1 API.
With ES 2.0, you have to write your own shader programs in GLSL for lighting calculations, and a lot of other functionality that the fixed pipeline previously handled for you. The initial hurdle might look higher than it is for ES 1.1, but you will get used to it pretty quickly, and then appreciate the new power and flexibility.
You should be able to find some good tutorials for ES 2.0 online.
OpenGL ES 2.0 is not backwards compatible with OpenGL ES 1.1 - these are two completely different APIs.

Game development using OpenGL ES 2.0 and C

I wanted to develop a game. I want to develop with the knowledge that I am having in OpenGL ES 2.0 and C language.
First thing that comes into my mind is how to develop textures etc. So please can any one tell me what are all the tools, game engine etc what all i need.
Any good tutorials for the same.
thanks in advance.
You said you want to use OPENGL ES 2.0, I understand you want develop for an Android or IPhone device.
You need read some about matrix, rotation, translations. OpenGl ES doesn't have glrotate and gltranslate methods(and more), but you can develop your own methods method using then OpenGl documentation:
http://www.opengl.org/sdk/docs/man/xhtml/glRotate.xml
http://www.opengl.org/sdk/docs/man/xhtml/glTranslate.xml
If you want to use OPENGL for draw, you will need write a vertex and fragment shader
What kind of shader for 2D games (ie. Super Mario)
A lot of stuff you need, this is only a little piece. I hope this be helpful to you.

how do I pass the View/Model/Projection matrices to my vertex shader in OpenGL ES 2.0?

In OpenGL ES 2.0, you apparently can't do
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
any more to set the model matrix, but I think these matrices are still built in somehow, since the GLSL spec tells you how to access them in a vertex shader.
//
// Matrix state. p. 31, 32, 37, 39, 40.
//
uniform mat4 gl_ModelViewMatrix;
uniform mat4 gl_ProjectionMatrix;
uniform mat4 gl_ModelViewProjectionMatrix;
so how do I pass these values to my shader? do I use glUniformMatrix4fv somehow?
The source code from the OpenGL ES 2.0 Programming Guide has been helpful for the shader part but all the examples appear to just leave the matrix transforms alone and just make sure their vertices are between -1.0 and 1.0.
UPDATE: apparently the OpenGL ES Shader Language does not support the pre-defined entries like gl_ModelViewMatrix, so the only answer is to define your own custom model/view/projection matrices as done in the code linked below, using glGetUniformLocation and glUniformMatrix4fv. I was confused because the OpenGL Shader Builder does support them, but that's plain OpenGL, not OpenGL ES.
gl_ModelViewProjectionMatrix does not appear to be in the "OpenGL ES Shading Language version 1.00" specification. There seems to be many Shading Language specifications, so that likely was the cause of confusion. As I understand it, you define your own uniforms for matrix storage.