diff options
author | Dan Gudmundsson <[email protected]> | 2010-11-15 15:24:58 +0100 |
---|---|---|
committer | Dan Gudmundsson <[email protected]> | 2010-11-15 15:24:58 +0100 |
commit | 8ecbdaf5eb54052d7b4756037e6dc481a36358ed (patch) | |
tree | 3db1d8e9cf250003fa240ba33072d509edeab382 /lib/wx/api_gen | |
parent | 2e605129613ba88427de27520a19456903d40cca (diff) | |
download | otp-8ecbdaf5eb54052d7b4756037e6dc481a36358ed.tar.gz otp-8ecbdaf5eb54052d7b4756037e6dc481a36358ed.tar.bz2 otp-8ecbdaf5eb54052d7b4756037e6dc481a36358ed.zip |
Initilize opengl after setCurrent
No rendering context is available until setCurrent is called the
first time, opengl extensions can not be loaded before the rendering
context is created.
Diffstat (limited to 'lib/wx/api_gen')
-rw-r--r-- | lib/wx/api_gen/gen_util.erl | 4 | ||||
-rw-r--r-- | lib/wx/api_gen/wx_gen.erl | 2 | ||||
-rw-r--r-- | lib/wx/api_gen/wx_gen.hrl | 6 | ||||
-rw-r--r-- | lib/wx/api_gen/wx_gen_cpp.erl | 12 | ||||
-rw-r--r-- | lib/wx/api_gen/wx_gen_erl.erl | 22 | ||||
-rw-r--r-- | lib/wx/api_gen/wxapi.conf | 48 |
6 files changed, 49 insertions, 45 deletions
diff --git a/lib/wx/api_gen/gen_util.erl b/lib/wx/api_gen/gen_util.erl index 841e0c9594..b53f817ce0 100644 --- a/lib/wx/api_gen/gen_util.erl +++ b/lib/wx/api_gen/gen_util.erl @@ -40,6 +40,10 @@ strip_name([H|R1],[H|R2]) -> strip_name(R1,R2); strip_name(String,[]) -> String. + +get_hook(_Type, undefined) -> ignore; +get_hook(Type, List) -> proplists:get_value(Type, List, ignore). + open_write(File) -> %% io:format("Generating ~s~n",[File]), {ok, Fd} = file:open(File++".temp", [write]), diff --git a/lib/wx/api_gen/wx_gen.erl b/lib/wx/api_gen/wx_gen.erl index c075324c1f..2f20c42a5d 100644 --- a/lib/wx/api_gen/wx_gen.erl +++ b/lib/wx/api_gen/wx_gen.erl @@ -887,7 +887,7 @@ add_method2(M0=#method{name=Name,params=Ps0,type=T0},#class{name=CName,parent=Pa id = next_id(func_id), pre_hook = get_opt(pre_hook, Name, length(Ps), Opts), post_hook = get_opt(post_hook, Name, length(Ps), Opts), - doc = get_opt(doc, Name, length(Ps), Opts) + doc = get_opt(doc, Name, length(Ps), Opts) }, M = case Name of CName -> diff --git a/lib/wx/api_gen/wx_gen.hrl b/lib/wx/api_gen/wx_gen.hrl index 17265a2842..426e3adfae 100644 --- a/lib/wx/api_gen/wx_gen.hrl +++ b/lib/wx/api_gen/wx_gen.hrl @@ -43,9 +43,9 @@ id = undefined, % Id (integer) doc, % Extra documentation virtual, % Is virtual? - pre_hook, % Pre hook before call in c-code - post_hook % Post hook after call in c-code - } + pre_hook = [], % Pre hook before call in c-code + post_hook = [] % Post hook after call in c-code + } ). -record(param, diff --git a/lib/wx/api_gen/wx_gen_cpp.erl b/lib/wx/api_gen/wx_gen_cpp.erl index 4bcdbe6a68..4b33068d8f 100644 --- a/lib/wx/api_gen/wx_gen_cpp.erl +++ b/lib/wx/api_gen/wx_gen_cpp.erl @@ -269,14 +269,14 @@ gen_method(CName, M=#method{name=N,params=Ps0,type=T,method_type=MT,id=MethodId Opts = [Opt || Opt = #param{def=Def,in=In,where=Where} <- Ps2, Def =/= none, In =/= false, Where =/= c], decode_options(Opts, Align), - case M#method.pre_hook of - {c,Pre} -> w(" ~s;~n", [Pre]); - _ -> skip + case gen_util:get_hook(c, M#method.pre_hook) of + ignore -> skip; + Pre -> w(" ~s;~n", [Pre]) end, Ps3 = call_wx(N,{MT,CName},T,Ps2), - case M#method.post_hook of - {c, Post} -> w(" ~s;~n", [Post]); - _ -> skip + case gen_util:get_hook(c, M#method.post_hook) of + ignore -> skip; + Post -> w(" ~s;~n", [Post]) end, free_args(), build_return_vals(T,Ps3), diff --git a/lib/wx/api_gen/wx_gen_erl.erl b/lib/wx/api_gen/wx_gen_erl.erl index 8648174b5b..e1201ab0d4 100644 --- a/lib/wx/api_gen/wx_gen_erl.erl +++ b/lib/wx/api_gen/wx_gen_erl.erl @@ -270,14 +270,14 @@ gen_method2(M=#method{name=N,alias=A,params=Ps,type=T,method_type=MT,id=MethodId MId = arg_type_tests(Args, "?" ++ get_unique_name(MethodId)), {MArgs,Align} = marshal_args(Args), MOpts = marshal_opts(Optional, Align, Args), - case M#method.pre_hook of - {erl,Pre} -> w(" ~s~n", [Pre]); - _ -> skip + case gen_util:get_hook(erl, M#method.pre_hook) of + ignore -> skip; + Pre -> w(" ~s~n", [Pre]) end, - case M#method.post_hook of - {erl,_} -> w(" _Result = ~n", []); - _ -> skip + case gen_util:get_hook(erl, M#method.post_hook) of + ignore -> skip; + _ -> w(" _Result =", []) end, case have_return_vals(T, Ps) of @@ -288,11 +288,11 @@ gen_method2(M=#method{name=N,alias=A,params=Ps,type=T,method_type=MT,id=MethodId false -> w(" wxe_util:cast(~s,~n <<~s~s>>)", [MId, MArgs,MOpts]) end, - case M#method.post_hook of - {erl,Post} -> - w(" ~s~n", [Post]), - w(" _Result~n", []); - _ -> skip + case gen_util:get_hook(erl, M#method.post_hook) of + ignore -> skip; + Post -> + w(",~n ~s~n", [Post]), + w(" _Result", []) end, erase(current_func), diff --git a/lib/wx/api_gen/wxapi.conf b/lib/wx/api_gen/wxapi.conf index 63b136e075..aec8a4944a 100644 --- a/lib/wx/api_gen/wxapi.conf +++ b/lib/wx/api_gen/wxapi.conf @@ -505,15 +505,15 @@ {"data",[in,{base,binary}]}, {"alpha",[in,{base,binary}]}, {{4,pre_hook}, - {c, "if(!static_data) {" - "data = (unsigned char *) malloc(Ecmd.bin[0]->size);" - "memcpy(data,Ecmd.bin[0]->base,Ecmd.bin[0]->size);}"}}, + [{c, "if(!static_data) {" + "data = (unsigned char *) malloc(Ecmd.bin[0]->size);" + "memcpy(data,Ecmd.bin[0]->base,Ecmd.bin[0]->size);}"}]}, {{5,pre_hook}, - {c, "if(!static_data) {" - " data = (unsigned char *) malloc(Ecmd.bin[0]->size);" - " alpha = (unsigned char *) malloc(Ecmd.bin[1]->size);" - " memcpy(data,Ecmd.bin[0]->base,Ecmd.bin[0]->size);" - " memcpy(alpha,Ecmd.bin[1]->base,Ecmd.bin[1]->size);}"}} + [{c, "if(!static_data) {" + " data = (unsigned char *) malloc(Ecmd.bin[0]->size);" + " alpha = (unsigned char *) malloc(Ecmd.bin[1]->size);" + " memcpy(data,Ecmd.bin[0]->base,Ecmd.bin[0]->size);" + " memcpy(alpha,Ecmd.bin[1]->base,Ecmd.bin[1]->size);}"}]} ]}, '~wxImage',%'AddHandler', 'Blur','BlurHorizontal','BlurVertical', @@ -524,15 +524,15 @@ {"data",[in,{base,binary}]}, {"alpha",[in,{base,binary}]}, {{4,pre_hook}, - {c, "if(!static_data) {" + [{c, "if(!static_data) {" "data = (unsigned char *) malloc(Ecmd.bin[0]->size);" - "memcpy(data,Ecmd.bin[0]->base,Ecmd.bin[0]->size);}"}}, + "memcpy(data,Ecmd.bin[0]->base,Ecmd.bin[0]->size);}"}]}, {{5,pre_hook}, - {c, "if(!static_data) {" - " data = (unsigned char *) malloc(Ecmd.bin[0]->size);" - " alpha = (unsigned char *) malloc(Ecmd.bin[1]->size);" - " memcpy(data,Ecmd.bin[0]->base,Ecmd.bin[0]->size);" - " memcpy(alpha,Ecmd.bin[1]->base,Ecmd.bin[1]->size);}"}} + [{c, "if(!static_data) {" + " data = (unsigned char *) malloc(Ecmd.bin[0]->size);" + " alpha = (unsigned char *) malloc(Ecmd.bin[1]->size);" + " memcpy(data,Ecmd.bin[0]->base,Ecmd.bin[0]->size);" + " memcpy(alpha,Ecmd.bin[1]->base,Ecmd.bin[1]->size);}"}]} ]}, 'Destroy','FindFirstUnusedColour', % 'FindHandler', 'GetImageExtWildcard', @@ -551,15 +551,15 @@ 'Rotate90','SaveFile','Scale','Size', {'SetAlpha', [{{2,"alpha"},[in,{base,binary}, {def, none}]}, {{2,pre_hook}, - {c, "if(!static_data) {" - "alpha = (unsigned char *) malloc(Ecmd.bin[0]->size);" - "memcpy(alpha,Ecmd.bin[0]->base,Ecmd.bin[0]->size);}"}} + [{c, "if(!static_data) {" + "alpha = (unsigned char *) malloc(Ecmd.bin[0]->size);" + "memcpy(alpha,Ecmd.bin[0]->base,Ecmd.bin[0]->size);}"}]} ]}, {'SetData', [{"data",[in,{base,binary}]}, {pre_hook, - {c, "if(!static_data) {" - "data = (unsigned char *) malloc(Ecmd.bin[0]->size);" - "memcpy(data,Ecmd.bin[0]->base,Ecmd.bin[0]->size);}"}} + [{c, "if(!static_data) {" + "data = (unsigned char *) malloc(Ecmd.bin[0]->size);" + "memcpy(data,Ecmd.bin[0]->base,Ecmd.bin[0]->size);}"}]} ]}, 'SetMask','SetMaskColour','SetMaskFromImage','SetOption', 'SetPalette', @@ -1146,10 +1146,10 @@ {class, wxGLCanvas, wxWindow, [{skip, [{'SetCurrent', 2}]}], %% NA MAC - [{'wxGLCanvas', [{"attribList", [in, {single,array}]}, - {pre_hook, {erl, "{ok, _} = wxe_master:init_opengl(),"}}]}, + [{'wxGLCanvas', [{"attribList", [in, {single,array}]}]}, 'GetContext', - {'SetCurrent', [{post_hook,{c, "if(This->GetContext()) setActiveGL(Ecmd.caller,This)"}}]}, + {'SetCurrent', [{post_hook,[{c, "if(This->GetContext()) setActiveGL(Ecmd.caller,This)"}, + {erl, "{ok, _} = wxe_master:init_opengl(),"}]}]}, %%{'SetColour', [{"colour", [in, {single,array}]}]}, 'SwapBuffers']}. |