I'm using OpenGL ES 1.1 on the iPhone, and I'd like to use the following functions:
glBlendFuncSeparate
glBlendColor
With their related constants. These didn't exist in early iPhone GL implementations, but according to this page:
http://developer.apple.com/iphone/library/releasenotes/General/iPhone30APIDiffs/index.html
they should be there in 3.0+, which I'm building for. But I'm getting "implicit definition" warnings. What do I need to do to get those functions?
Thanks!
These functions are only defined for OpenGL ES 2.0. glBlendFuncSeparate does have a 1.1 extension version as glBlendFuncSeparateOES, but there is no equivalent for glBlendColor.
Extensions are included in the glext.h header files. Specifically, #include <OpenGLES/ES1/glext.h>
Related
In Unity, Wen can call objective-C code from C# by import the function of objective-C as extern function.
But how call C# script code from objective-C ?
You can use
UnitySendMessage("GameObjectName1", "MethodName1", "Message to send");
in which you fill your gameobject name which will receive this message and the message name.
You can implement your own delegate/event once you receive this message from native code. The limit of UnitySendMessage is when it arrives to Unity code, it is always 1 frame after you call this in native code. And it can only take string as parameter. But most of time it is not big problem.
The method to be used for this is UnitySendMessage. Have a look at Building Plugins for iOS or this blog which is partially written in Chinese.
Have a look at: http://www.tinytimgames.com/2010/01/10/the-unityobjective-c-divide/
The bolg post shows a technique that uses KVO (Key Value Observation) and the PlayerPrefs to pass commands from unity to objective-c.
PlayerPrefs.SetString("Commands",
String.Format("AwesomeCommand|{0}|{1}", awesome1, awesome2));
Turns out you can create a callback method that will allow you to do whatever you want.
Here is an example video showing it being done for OSX, but the C++ code is cross platform.
This guy has been doing videos on plugins for all the operating systems, but the mac one is the coolest so far, since it gives you function pointers to C# code.
http://www.youtube.com/watch?v=Q2dDK0ulDYY
Universal plugin for unity for iOS that allow mixing C# with objective-C
http://goo.gl/XDrQFh
Unity C#
var callbackClass = AKiOSMagic.CreateClass("MyCallbackClass", "NSObject");
callbackClass.AddMethod("methodWithArg:anotherArg:", (args)
{
// do something...
// args.GetObject(0);
// args.GetObject(1);
});
callbackClass.RegisterClass();
Objective-C
[[NSClassFromString(#"MyCallbackClass") new] methodWithArg:#"arg1" anotherArg:#"arg2"]
I am getting really desperate here. I working with Xcode, trying to implement some OpenGL stuff on the iPhone. I have to write a Shader for Phong-Lighting. I got as far as declaring my geometry (vertices, indices, calculating etc.) and passing the respective arguments as attributes to the shader (written in GLSL). Using these attributes works fine, some really basic shader programs compile correctly and give the expected output.
Now I'm trying to start with some more advanced calculations, for which I need to use some of the built-in attributes of GLSL, namely i.e. the "gl_NormalMatrix", but whenever I try that, the program crashes and I get an "ERROR: 0:3: Use of undeclared identifier 'gl_NormalMatrix'".
It happens identically whenever use any of the built-in attributes such as gl_Vertex, gl_Normal etc.
Are these attributes not available in GLSL on the iPhone or am I missing something? Maybe I haven't fully understood how this works. As mentioned, passing my own vertex attributes into the shader works fine, and I am also wondering how the program should "know" the correct values "on its own" - so the whole concept of built-in attributes is still a bit confusing to me. But whenever I try to run some shaders I found online to see if something happens, I get these errors thrown, even though everyone else seems to use built-in attributes extensively when writing shaders.
I really hope someone here can shed some light on this. Thousand thanks in advance!
Julia
Those attributes aren't available in GL ES, whether on the iPhone or elsewhere. And the same goes for WebGL. You need to write your own matrix code, or use GLKit if you're supporting only iOS 5+, and supply attributes for yourself. See Kronos' reference card for an incredibly concise summary of what made it into ES 2.0 — amongst other things it lists all the available built-in special variables as:
gl_Position
gl_PointSize
gl_FragCoord
gl_FrontFacing
gl_PointCoord
gl_FragColor
gl_FragData[n]
GLKit's maths stuff is really good because it inlines and uses the ARM's NEON SIMD unit. I consider it a sufficient reason to specify iOS 5 as a minimum in all new GL projects.
I am reading a book about iPhone game development, it uses some functions start with 'gl' and ends with 'OES'.
like this:
glGetRenderbufferParameterivOES
Where can I get reference of these functions?
you can find the man pages for OpenGL ES on the Khronos website:
http://www.khronos.org/opengles/sdk/docs/man/
As far as I know the OES extension was removed as of OpenGL ES 2.0.
Hope this helps.
http://www.khronos.org/opengles/sdk/docs/man/
In your case http://www.khronos.org/opengles/sdk/docs/man/xhtml/glGetRenderbufferParameteriv.xml
The OES suffix just marks it as being specific to OpenGL-ES (OES).
I read some info regarding getting .h files for undocumented API. Most of sources recommend class-dump (or class-dump-x and class-dump-z).
However it doesn't work with iPhone Security.framework. It doesn't contain Objective-C runtime information.
The only other way which I found is to use nm or otool. This will give the names of functions and disassembly for them.
Does anybody know some faster way to get undocumented functions signature than reading disassembly and trying to figure out what parameters go where and what could it be?
You mean this undocumented api, documented here..
Security.framework is not private or undocumented.
As far as headers go, installed on my harddrive in the 3.2 sdk i find:
/Security.framework/Headers/Security.h
/Security.framework/Headers/Secbase.h
/Security.framework/Headers/SecCertificate.h
/Security.framework/Headers/SecIdentitiy.h
/Security.framework/Headers/SecImportExport.h
/Security.framework/Headers/SecItem.h
/Security.framework/Headers/SecKey.h
/Security.framework/Headers/SecPolicy.h
/Security.framework/Headers/SecRandom.h
/Security.framework/Headers/SecTrust.h
As for a little reverse engineering 101, you should realise that a framework doesn't contain or in anyway have a use for header files, or function signatures. When provided they are solely for the benefit of the developer. There is no C or C++ or objective-c code in the compiled framework, only the raw machine code.
As you have seen, if objective-c was used Class-Dump can do a pretty good job of arranging objective-c symbols into something that looks like a header file, only missing type information that isn't used at runtime, so still not that useful.
If the source language was C then you are screwed. There may be a function name symbol but there is no info about arguments or return type.
There are bunch of additional undocumented API's which are not mentioned in official documentation. As example, part of them could be seen here:
http://www.opensource.apple.com/source/Security/Security-55163.44/sec/Security/
In summary, I think my question is this:
How can I force hxcpp to compile haxe code for Flash 8 ?
Here's where I'm at. I'm new to haxe, and am trying to get a sample from here:
http://tilestudio.sourceforge.net/flash/Demo.html
to compile using hxcpp, in my tests to see how haxe compiled apps work on the iphone.
I've gotten other samples to compile fine and put them on the iphone, but when I compile this sample, it complains with things like:
Demo.hx:32: characters 17-53 : Class not found : flash.MovieClip
Demo.hx:42: characters 20-36 : Class not found : flash.Key
Demo.hx:44: characters 43-60 : Class not found : flash.Stage
and as I mentioned, this compiles fine using the following hxml file (flash.hxml):
-swf Demo.swf
-swf-lib DemoRes.swf
-main Demo.hx
-swf-header 480:320:100:808080
but fails as detailed above using this (cpp.hxml):
-main Demo.hx
-lib nme
-lib neash
-swf-lib DemoRes.swf
--remap neko:cpp
--remap flash:neash
-cpp cpp
So I think the problem is that hxcpp is targeting Flash version 9 swf's, and the haxe code is targetting Flash 8. I tried forcing it to accept Flash 8 syntax using "-swf-version 8" but it doesn't work (gives the same errors).
Although Neash is quite complete I am not sure it does map 100% of the Flash API. That said you have for sure a problem with -swf-lib that will not work with Neash; that beacuse it is not possible to embed swf files in other platforms than flash. You have to manage your assets differently.
Maybe in a not so distant future it will be possible to embed even swf resources, but first someone has to write a nice decompiler that transform them for the intended target.
I asked Hugh, the guy behind the hxcpp compiler part of Haxe that's doing all the haxe / iphone / hxcpp stuff, and he basically said that Flash 8 isn't an available target for hxcpp, just Flash 9 and up.... Thanks for the response Hugh!
http://gamehaxe.com/2009/08/17/switched-to-immix-for-internal-garbage-collection/#comment-309