summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Gudmundsson <dgud@erlang.org>2023-03-30 19:19:03 +0200
committerDan Gudmundsson <dgud@erlang.org>2023-04-24 09:47:29 +0200
commitb1f297425d7ea4f66f641cd8742dbe5b6f9dd588 (patch)
treec5b67a0d522ebc9188f0faac5e3c7e99e7be54fb
parentcec0a672c1f4fb702af5dfa093875b16e4d65b71 (diff)
downloaderlang-b1f297425d7ea4f66f641cd8742dbe5b6f9dd588.tar.gz
gl: Fix glDebugMessage functionality
gl:getDebugMessageLog returned one list instead of several, and gl:debugMessageInsert had an unused lenght parameter.
-rw-r--r--lib/wx/api_gen/gl_gen.erl5
-rw-r--r--lib/wx/api_gen/gl_gen_erl.erl2
-rw-r--r--lib/wx/api_gen/gl_gen_nif.erl33
-rw-r--r--lib/wx/api_gen/glapi.conf16
-rw-r--r--lib/wx/c_src/gen/gl_nif.cpp18
-rw-r--r--lib/wx/doc/src/gl.xml13
-rw-r--r--lib/wx/src/gen/gl.erl11
-rw-r--r--lib/wx/test/wx_opengl_SUITE.erl83
8 files changed, 117 insertions, 64 deletions
diff --git a/lib/wx/api_gen/gl_gen.erl b/lib/wx/api_gen/gl_gen.erl
index 7a609158c7..641f21eccd 100644
--- a/lib/wx/api_gen/gl_gen.erl
+++ b/lib/wx/api_gen/gl_gen.erl
@@ -358,7 +358,10 @@ handle_arg_opt({c_only,Opt},P) -> P#arg{where=c, alt=Opt};
handle_arg_opt(list_binary, P) -> P#arg{alt=list_binary};
handle_arg_opt(string, P=#arg{type=T}) -> P#arg{type=T#type{base=string}};
handle_arg_opt({string,Max,Sz}, P=#arg{type=T}) ->
- P#arg{type=T#type{base=string, size={Max,Sz}}}.
+ P#arg{type=T#type{base=string, size={Max,Sz}}};
+handle_arg_opt({size, Sz}, P=#arg{type=T}) ->
+ P#arg{type=T#type{size={Sz,Sz}}}.
+
parse_type([], _Os) -> void;
parse_type(C, Os) ->
diff --git a/lib/wx/api_gen/gl_gen_erl.erl b/lib/wx/api_gen/gl_gen_erl.erl
index 2852da9656..7c9f97867c 100644
--- a/lib/wx/api_gen/gl_gen_erl.erl
+++ b/lib/wx/api_gen/gl_gen_erl.erl
@@ -382,6 +382,8 @@ spec_arg_type2(T=#type{single={list, _Max}}) ->
"[" ++ spec_arg_type3(T) ++ "]";
spec_arg_type2(T=#type{single={list,_,_}}) ->
"[" ++ spec_arg_type3(T) ++ "]";
+spec_arg_type2(T=#type{single={list,_,_,_}}) ->
+ "[" ++ spec_arg_type3(T) ++ "]";
spec_arg_type2(T=#type{single={tuple_list,Sz}}) ->
"[{" ++ args(fun spec_arg_type3/1, ",", lists:duplicate(Sz,T)) ++ "}]".
diff --git a/lib/wx/api_gen/gl_gen_nif.erl b/lib/wx/api_gen/gl_gen_nif.erl
index cd8fdba7cd..b8a6be3908 100644
--- a/lib/wx/api_gen/gl_gen_nif.erl
+++ b/lib/wx/api_gen/gl_gen_nif.erl
@@ -422,8 +422,8 @@ decode_var(P=#arg{name=Name, in=true, alt=Alt,
decode_var(P=#arg{name=Name, in=false,
- type=#type{name=T, base=Base, size=Szs}}, Argc)
- when Base =:= binary; Base =:= string ->
+ type=#type{name=T, base=Base, size=Szs, single=Single}}, Argc)
+ when not is_tuple(Single), (Base =:= binary orelse Base =:= string) ->
Sz = case Szs of
{Max,_} when is_integer(Max) -> integer_to_list(Max);
{Max,_} -> Max;
@@ -454,6 +454,19 @@ decode_var(P=#arg{name=Name, in=false, type=#type{name=T,single={list,Sz,_}}}, A
w(" std::vector <~s> ~s (~s);\n", [T, Name, Sz]),
w(" std::vector <ERL_NIF_TERM> ~s_ts (~s);\n", [Name, Sz]),
{P,Argc};
+decode_var(P=#arg{name=Name, in=false,
+ type=#type{base=Base, name=T,single={list,Sz,_,_}, size=Size}}, Argc) ->
+ case Base of
+ string ->
+ {BinSize, _} = Size,
+ w(" ~s = (unsigned char *) enif_alloc((int) ~s*sizeof(~s));\n", [Name,BinSize,T]),
+ w(" unsigned char *~s_ptr = ~s;\n", [Name,Name]),
+ store_free(Name ++ "_ptr");
+ _ ->
+ exit({?LINE, Base, P})
+ end,
+ w(" std::vector <ERL_NIF_TERM> ~s_ts (~s);\n", [Name, Sz]),
+ {P,Argc};
decode_var(P=#arg{name=Name, in=true, type=#type{name="GLUquadric"}}, Argc) ->
w(" if(!egl_get_ptr(env, argv[~w], (void **) &~s)) Badarg(~w,\"~s\");~n",
[Argc, Name,?OP,Name]),
@@ -576,10 +589,6 @@ build_ret(Name,_Q,#type{name=T,base=Base,size=Sz,single=true})
Ptr -> io_lib:format(" enif_make_uint64(env, (egl_uint64_t) ~s)", [Name]);
true -> io_lib:format(" enif_make_int64(env, (egl_int64_t) ~s)", [Name])
end;
-build_ret(Name,_Q,#type{base=string,single=true}) ->
- io_lib:format(" enif_make_string(env, (const char *) ~s, ERL_NIF_LATIN1)",[Name]);
-build_ret(Name,_Q,#type{base=string,size={_,_OutSz}}) ->
- io_lib:format(" enif_make_string(env, (const char *) ~s, ERL_NIF_LATIN1)",[Name]);
build_ret(Name,_Q,#type{name=_T,base=float,size=Sz,single=true}) ->
if Sz =< 4 -> io_lib:format(" enif_make_double(env, (double) ~s)", [Name]);
true -> io_lib:format(" enif_make_double(env, ~s)", [Name])
@@ -602,6 +611,12 @@ build_ret(Name,false,#type{single={list,Sz}}) when Sz >= 10, is_integer(Sz) ->
io_lib:format(" enif_make_list_from_array(env, ~s_ts, ~w)",[Name, Sz]);
build_ret(Name,false,#type{single={list,_,Sz}}) ->
io_lib:format(" enif_make_list_from_array(env, ~s_ts.data(), ~s)",[Name, Sz]);
+build_ret(Name,false,#type{single={list,_,Sz,_}}) ->
+ io_lib:format(" enif_make_list_from_array(env, ~s_ts.data(), ~s)",[Name, Sz]);
+build_ret(Name,_Q,#type{base=string,single=true}) ->
+ io_lib:format(" enif_make_string(env, (const char *) ~s, ERL_NIF_LATIN1)",[Name]);
+build_ret(Name,_Q,#type{base=string,size={_,_OutSz}}) ->
+ io_lib:format(" enif_make_string(env, (const char *) ~s, ERL_NIF_LATIN1)",[Name]);
build_ret(Name,_Q,T=#type{}) ->
io:format("{~p, {~p, {single,{tuple,X}}}}.~n", [get(current_func),Name]),
io:format(" ~p~n",[T]).
@@ -615,6 +630,12 @@ prepare_ret(#arg{name=Name, type=#type{single={list,_,Sz}}=T}) ->
Fetch = build_ret(Name ++ "[ri]", false, T#type{single=true}),
w(" for(int ri=0; ri < (int) ~s; ri++)\n"
" ~s_ts[ri] = ~s;\n",[Sz, Name, Fetch]);
+prepare_ret(#arg{name=Name, type=#type{single={list,_,Sz,Lengths}}=T}) ->
+ Fetch = build_ret(Name, false, T#type{single=true}),
+ w(" for(int ri=0; ri < (int) ~s; ri++) {\n"
+ " ~s_ts[ri] = ~s;\n",[Sz, Name, Fetch]),
+ w(" ~s += ~s[ri];\n"
+ " }\n", [Name, Lengths]);
prepare_ret(_) ->
ok.
diff --git a/lib/wx/api_gen/glapi.conf b/lib/wx/api_gen/glapi.conf
index e8304c31fe..b7b8ede1b7 100644
--- a/lib/wx/api_gen/glapi.conf
+++ b/lib/wx/api_gen/glapi.conf
@@ -483,24 +483,16 @@
{"glDebugMessageControl", [{"count", {c_only, {length, "ids"}}},
{"ids", {single, list}}]}.
-{"glDebugMessageInsertARB", {"length", {c_only, {size, "buf"}}}}.
-
-{"glGetDebugMessageLogARB", [{"sources", {single, {list, "count", "result"}}},
- {"types", {single, {list, "count", "result"}}},
- {"ids", {single, {list, "count", "result"}}},
- {"severities", {single, {list, "count", "result"}}},
- {"lengths", [{c_only, undefined}, {single, {list, "count", "result"}}]},
- {"messageLog", [{string, "bufSize", "result"}
- %%,{single, {list, "bufsize", "result"}}
- ]}]}.
+{"glDebugMessageInsert", {"length", {c_only, {size, "buf"}}}}.
{"glGetDebugMessageLog", [{"sources", {single, {list, "count", "result"}}},
{"types", {single, {list, "count", "result"}}},
{"ids", {single, {list, "count", "result"}}},
{"severities", {single, {list, "count", "result"}}},
{"lengths", [{c_only, undefined}, {single, {list, "count", "result"}}]},
- {"messageLog", [{string, "bufSize", "result"}
- %%,{single, {list, "bufsize", "result"}}
+ {"messageLog", [
+ {single, {list, "count", "result", "lengths"}},
+ {size, "bufSize"}
]}]}.
diff --git a/lib/wx/c_src/gen/gl_nif.cpp b/lib/wx/c_src/gen/gl_nif.cpp
index 57e3196d98..efe09af3f7 100644
--- a/lib/wx/c_src/gen/gl_nif.cpp
+++ b/lib/wx/c_src/gen/gl_nif.cpp
@@ -1,7 +1,7 @@
/*
* %CopyrightBegin%
*
- * Copyright Ericsson AB 2008-2021. All Rights Reserved.
+ * Copyright Ericsson AB 2008-2023. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -11518,15 +11518,13 @@ void ecb_glDebugMessageInsert(ErlNifEnv* env, ErlNifPid *self, ERL_NIF_TERM argv
GLenum type;
GLuint id;
GLenum severity;
- GLsizei length;
ErlNifBinary buf;
if(!enif_get_uint(env, argv[0], &source)) Badarg(5803,"source");
if(!enif_get_uint(env, argv[1], &type)) Badarg(5803,"type");
if(!enif_get_uint(env, argv[2], &id)) Badarg(5803,"id");
if(!enif_get_uint(env, argv[3], &severity)) Badarg(5803,"severity");
- if(!enif_get_int(env, argv[4], &length)) Badarg(5803,"length");
- if(!enif_inspect_binary(env, argv[5], &buf)) Badarg(5803,"buf");
- weglDebugMessageInsert(source,type,id,severity,length,(GLchar *) buf.data);
+ if(!enif_inspect_binary(env, argv[4], &buf)) Badarg(5803,"buf");
+ weglDebugMessageInsert(source,type,id,severity,(GLsizei) buf.size,(GLchar *) buf.data);
}
void ecb_glGetDebugMessageLog(ErlNifEnv* env, ErlNifPid *self, ERL_NIF_TERM argv[])
@@ -11549,6 +11547,8 @@ void ecb_glGetDebugMessageLog(ErlNifEnv* env, ErlNifPid *self, ERL_NIF_TERM argv
std::vector <GLsizei> lengths (count);
std::vector <ERL_NIF_TERM> lengths_ts (count);
messageLog = (unsigned char *) enif_alloc((int) bufSize*sizeof(GLchar));
+ unsigned char *messageLog_ptr = messageLog;
+ std::vector <ERL_NIF_TERM> messageLog_ts (count);
result = weglGetDebugMessageLog(count,bufSize,sources.data(),types.data(),ids.data(),severities.data(),lengths.data(),(GLchar *) messageLog);
for(int ri=0; ri < (int) result; ri++)
sources_ts[ri] = enif_make_int(env, sources[ri]);
@@ -11558,16 +11558,20 @@ void ecb_glGetDebugMessageLog(ErlNifEnv* env, ErlNifPid *self, ERL_NIF_TERM argv
ids_ts[ri] = enif_make_int(env, ids[ri]);
for(int ri=0; ri < (int) result; ri++)
severities_ts[ri] = enif_make_int(env, severities[ri]);
+ for(int ri=0; ri < (int) result; ri++) {
+ messageLog_ts[ri] = enif_make_string(env, (const char *) messageLog, ERL_NIF_LATIN1);
+ messageLog += lengths[ri];
+ }
reply = enif_make_tuple6(env,
enif_make_int(env, result),
enif_make_list_from_array(env, sources_ts.data(), result),
enif_make_list_from_array(env, types_ts.data(), result),
enif_make_list_from_array(env, ids_ts.data(), result),
enif_make_list_from_array(env, severities_ts.data(), result),
- enif_make_string(env, (const char *) messageLog, ERL_NIF_LATIN1) );
+ enif_make_list_from_array(env, messageLog_ts.data(), result) );
enif_send(NULL, self, env,
enif_make_tuple2(env, EGL_ATOM_REPLY, reply));
- enif_free(messageLog);
+ enif_free(messageLog_ptr);
}
void ecb_glPushDebugGroup(ErlNifEnv* env, ErlNifPid *self, ERL_NIF_TERM argv[])
diff --git a/lib/wx/doc/src/gl.xml b/lib/wx/doc/src/gl.xml
index 224c9d90f3..865ce91bb9 100644
--- a/lib/wx/doc/src/gl.xml
+++ b/lib/wx/doc/src/gl.xml
@@ -7,7 +7,7 @@
<erlref>
<header>
<copyright>
- <year>2020</year><year>2021</year>
+ <year>2020</year>
<holder>Ericsson AB. All Rights Reserved.</holder></copyright>
<legalnotice>
Licensed under the Apache License, Version 2.0 (the "License");
@@ -928,10 +928,10 @@
<p><url href="https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glDebugMessageControl.xhtml">External documentation.</url></p></desc>
</func>
<func>
- <name name="debugMessageInsert" arity="6" clause_i="1" since=""/>
+ <name name="debugMessageInsert" arity="5" clause_i="1" since=""/>
<fsummary>inject an application-supplied message into the debug message queue</fsummary>
<desc>
- <p><seemfa marker="gl#debugMessageInsert/6"><c>gl:debugMessageInsert/6</c></seemfa> inserts a user-supplied message into the debug output queue. <c>Source</c> specifies the source that will be used to classify the message and must be <c>?GL_DEBUG_SOURCE_APPLICATION</c> or <c>?GL_DEBUG_SOURCE_THIRD_PARTY</c>. All other sources are reserved for use by the GL implementation. <c>Type</c> indicates the type of the message to be inserted and may be one of <c>?GL_DEBUG_TYPE_ERROR</c>, <c>?GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR</c>, <c>?GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR</c>, <c>?GL_DEBUG_TYPE_PORTABILITY</c>, <c>?GL_DEBUG_TYPE_PERFORMANCE</c>, <c>?GL_DEBUG_TYPE_MARKER</c>, <c>?GL_DEBUG_TYPE_PUSH_GROUP</c>, <c>?GL_DEBUG_TYPE_POP_GROUP</c>, or <c>?GL_DEBUG_TYPE_OTHER</c>. <c>Severity</c> indicates the severity of the message and may be <c>?GL_DEBUG_SEVERITY_LOW</c>, <c>?GL_DEBUG_SEVERITY_MEDIUM</c>, <c>?GL_DEBUG_SEVERITY_HIGH</c> or <c>?GL_DEBUG_SEVERITY_NOTIFICATION</c>. <c>Id</c> is available for application defined use and may be any value. This value will be recorded and used to identify the message. </p>
+ <p><seemfa marker="gl#debugMessageInsert/5"><c>gl:debugMessageInsert/5</c></seemfa> inserts a user-supplied message into the debug output queue. <c>Source</c> specifies the source that will be used to classify the message and must be <c>?GL_DEBUG_SOURCE_APPLICATION</c> or <c>?GL_DEBUG_SOURCE_THIRD_PARTY</c>. All other sources are reserved for use by the GL implementation. <c>Type</c> indicates the type of the message to be inserted and may be one of <c>?GL_DEBUG_TYPE_ERROR</c>, <c>?GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR</c>, <c>?GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR</c>, <c>?GL_DEBUG_TYPE_PORTABILITY</c>, <c>?GL_DEBUG_TYPE_PERFORMANCE</c>, <c>?GL_DEBUG_TYPE_MARKER</c>, <c>?GL_DEBUG_TYPE_PUSH_GROUP</c>, <c>?GL_DEBUG_TYPE_POP_GROUP</c>, or <c>?GL_DEBUG_TYPE_OTHER</c>. <c>Severity</c> indicates the severity of the message and may be <c>?GL_DEBUG_SEVERITY_LOW</c>, <c>?GL_DEBUG_SEVERITY_MEDIUM</c>, <c>?GL_DEBUG_SEVERITY_HIGH</c> or <c>?GL_DEBUG_SEVERITY_NOTIFICATION</c>. <c>Id</c> is available for application defined use and may be any value. This value will be recorded and used to identify the message. </p>
<p><url href="https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glDebugMessageInsert.xhtml">External documentation.</url></p></desc>
</func>
@@ -1798,11 +1798,8 @@
<func>
<name name="getInternalformati64v" arity="4" clause_i="1" since=""/>
<name name="getInternalformativ" arity="4" clause_i="1" since=""/>
- <fsummary>retrieve information about implementation-dependent support for internal formats</fsummary>
- <desc>
- <p><seemfa marker="gl#getInternalformativ/4"><c>gl:getInternalformativ/4</c></seemfa> and <seemfa marker="gl#getInternalformativ/4"><c>gl:getInternalformati64v/4</c></seemfa> retrieve information about implementation-dependent support for internal formats. <c>Target</c> indicates the target with which the internal format will be used and must be one of <c>?GL_RENDERBUFFER</c>, <c>?GL_TEXTURE_2D_MULTISAMPLE</c>, or <c>?GL_TEXTURE_2D_MULTISAMPLE_ARRAY</c>, corresponding to usage as a renderbuffer, two-dimensional multisample texture or two-dimensional multisample array texture, respectively. </p>
-
- <p><url href="https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glGetInternalFormat.xhtml">External documentation.</url></p></desc>
+ <fsummary/>
+ <desc><p>No documentation available.</p></desc>
</func>
<func>
<name name="getLightfv" arity="2" clause_i="1" since=""/>
diff --git a/lib/wx/src/gen/gl.erl b/lib/wx/src/gen/gl.erl
index e5ac08290c..283af4a869 100644
--- a/lib/wx/src/gen/gl.erl
+++ b/lib/wx/src/gen/gl.erl
@@ -238,7 +238,7 @@
texStorage2DMultisample/6,texStorage3DMultisample/7,textureView/8,
bindVertexBuffer/4,vertexAttribFormat/5,vertexAttribIFormat/4,vertexAttribLFormat/4,
vertexAttribBinding/2,vertexBindingDivisor/2,debugMessageControl/5,
- debugMessageInsert/6,getDebugMessageLog/2,pushDebugGroup/4,popDebugGroup/0,
+ debugMessageInsert/5,getDebugMessageLog/2,pushDebugGroup/4,popDebugGroup/0,
objectPtrLabel/3,bufferStorage/4,clearTexImage/5,clearTexSubImage/11,
bindBuffersBase/3,bindBuffersRange/5,bindTextures/2,bindSamplers/2,
bindImageTextures/2,bindVertexBuffers/4,clipControl/2,createTransformFeedbacks/1,
@@ -5119,15 +5119,14 @@ debugMessageControl(Source,Type,Severity,Ids,Enabled) when is_integer(Source),is
IF:queue_cmd(Source,Type,Severity,Count,Ids,Enabled,5802),
ok.
--spec debugMessageInsert(Source, Type, Id, Severity, Length, Buf) -> 'ok'
- when Source::enum(), Type::enum(), Id::i(), Severity::enum(), Length::i(), Buf::string().
-debugMessageInsert(Source,Type,Id,Severity,Length,Buf) when is_integer(Source),is_integer(Type),is_integer(Id),is_integer(Severity),is_integer(Length),is_list(Buf) ->
+-spec debugMessageInsert(Source::enum(), Type::enum(), Id::i(), Severity::enum(), Buf::string()) -> 'ok'.
+debugMessageInsert(Source,Type,Id,Severity,Buf) when is_integer(Source),is_integer(Type),is_integer(Id),is_integer(Severity),is_list(Buf) ->
IF = get_interface(),
BufBin = unicode:characters_to_binary([Buf|[0]]),
- IF:queue_cmd(Source,Type,Id,Severity,Length,BufBin,5803),
+ IF:queue_cmd(Source,Type,Id,Severity,BufBin,5803),
ok.
--spec getDebugMessageLog(Count::i(), BufSize::i()) -> {i(),Sources::[enum()],Types::[enum()],Ids::[i()],Severities::[enum()],MessageLog::string()}.
+-spec getDebugMessageLog(Count::i(), BufSize::i()) -> {i(),Sources::[enum()],Types::[enum()],Ids::[i()],Severities::[enum()],MessageLog::[string()]}.
getDebugMessageLog(Count,BufSize) when is_integer(Count),is_integer(BufSize) ->
IF = get_interface(),
IF:queue_cmd(Count,BufSize,5804),
diff --git a/lib/wx/test/wx_opengl_SUITE.erl b/lib/wx/test/wx_opengl_SUITE.erl
index f1a7022de6..fa4e456c42 100644
--- a/lib/wx/test/wx_opengl_SUITE.erl
+++ b/lib/wx/test/wx_opengl_SUITE.erl
@@ -27,7 +27,7 @@
init_per_suite/1, end_per_suite/1,
init_per_testcase/2, end_per_testcase/2]).
--export([canvas/1, glu_tesselation/1]).
+-export([canvas/1, glu_tesselation/1, debugMessage/1]).
-include("wx_test_lib.hrl").
-include_lib("wx/include/gl.hrl").
@@ -55,7 +55,7 @@ end_per_testcase(Func,Config) ->
suite() -> [{ct_hooks,[ts_install_cth]}, {timetrap,{minutes,2}}].
all() ->
- [canvas, glu_tesselation].
+ [canvas, glu_tesselation, debugMessage].
groups() ->
[].
@@ -93,19 +93,14 @@ canvas(TestInfo) when is_atom(TestInfo) -> wx_test_lib:tc_info(TestInfo);
canvas(Config) ->
WX = ?mr(wx_ref, wx:new()),
Frame = wxFrame:new(WX,1,"Hello 3D-World",[]),
- Attrs = [?WX_GL_RGBA,
- ?WX_GL_DOUBLEBUFFER,
- ?WX_GL_MIN_RED,8,
- ?WX_GL_MIN_GREEN,8,
- ?WX_GL_MIN_BLUE,8,
- %% ?WX_GL_CORE_PROFILE,
- ?WX_GL_DEPTH_SIZE,24,0],
-
-
- true = wxGLCanvas:isDisplaySupported(Attrs),
-
- Canvas = ?mt(wxGLCanvas, wxGLCanvas:new(Frame, [{style,?wxFULL_REPAINT_ON_RESIZE},
- {attribList, Attrs}])),
+ Attrs = [{attribList, [?WX_GL_RGBA,
+ ?WX_GL_DOUBLEBUFFER,
+ ?WX_GL_MIN_RED,8,
+ ?WX_GL_MIN_GREEN,8,
+ ?WX_GL_MIN_BLUE,8,
+ %% ?WX_GL_CORE_PROFILE,
+ ?WX_GL_DEPTH_SIZE,24,0]}],
+ Canvas = ?mt(wxGLCanvas, wxGLCanvas:new(Frame, [{style,?wxFULL_REPAINT_ON_RESIZE}|Attrs])),
Context = wxGLContext:new(Canvas),
SetContext = fun() -> ?m(true, wxGLCanvas:setCurrent(Canvas, Context)) end,
@@ -239,14 +234,8 @@ glu_tesselation(Config) ->
after 1000 -> exit(show_timeout)
end,
- try %% 3.0 API
- Context = wxGLContext:new(Canvas),
- wxGLCanvas:setCurrent(Canvas, Context)
- catch _:Reason:ST -> %% 2.8 API
- io:format("Using old api: ~p~n ~p~n",[Reason, ST]),
- ?m(false, wx:is_null(wxGLCanvas:getContext(Canvas))),
- ?m(ok, wxGLCanvas:setCurrent(Canvas))
- end,
+ Context = wxGLContext:new(Canvas),
+ wxGLCanvas:setCurrent(Canvas, Context),
Simple = ?m({_,_}, glu:tesselate({0.0,0.0,1.0}, [{-1.0,0.0,0.0},{1.0,0.0,0.0},{0.0,1.0,0.0}])),
io:format("Simple ~p~n",[Simple]),
@@ -266,4 +255,50 @@ glu_tesselation(Config) ->
wx_test_lib:wx_destroy(Frame, Config).
-
+debugMessage(TestInfo) when is_atom(TestInfo) -> wx_test_lib:tc_info(TestInfo);
+debugMessage(Config) ->
+ WX = ?mr(wx_ref, wx:new()),
+ Frame = wxFrame:new(WX,1,"Hello 3D-World",[]),
+ case {?wxMAJOR_VERSION, ?wxMINOR_VERSION} of
+ {WxMajor,WxMinor} when WxMajor >= 3, WxMinor >= 2 ->
+ Attrs = [{attribList, [?WX_GL_RGBA,?WX_GL_DOUBLEBUFFER,?WX_GL_DEBUG,0]}],
+ Canvas = ?mt(wxGLCanvas, wxGLCanvas:new(Frame, Attrs)),
+ wxFrame:connect(Frame, show),
+ ?m(true, wxWindow:show(Frame)),
+
+ receive #wx{event=#wxShow{}} -> ok
+ after 1000 -> exit(show_timeout)
+ end,
+
+ Context = wxGLContext:new(Canvas),
+ wxGLCanvas:setCurrent(Canvas, Context),
+
+ case {gl:getIntegerv(?GL_MAJOR_VERSION),gl:getIntegerv(?GL_MINOR_VERSION)} of
+ {[Major|_], [Minor|_]} when Major >= 4, Minor >= 3 ->
+ io:format("~nVersion: ~p~n", [{Major,Minor}]),
+ ByteCount = 5000,
+ Count = 10,
+ %% Before any log insertion:
+ A = gl:getDebugMessageLog(Count, ByteCount),
+ io:format( "A = ~p~n", [ A ] ),
+
+ Msg1 = "Hello!",
+ gl:debugMessageInsert(?GL_DEBUG_SOURCE_APPLICATION, ?GL_DEBUG_TYPE_ERROR,
+ 10, ?GL_DEBUG_SEVERITY_HIGH, Msg1),
+ Msg2 = "Goodbye...",
+ gl:debugMessageInsert(?GL_DEBUG_SOURCE_APPLICATION, ?GL_DEBUG_TYPE_ERROR,
+ 11, ?GL_DEBUG_SEVERITY_HIGH, Msg2),
+
+ B = gl:getDebugMessageLog(Count, ByteCount),
+ io:format("B = ~p~n", [B]),
+
+ C = gl:getDebugMessageLog(Count, ByteCount),
+ io:format("C = ~p~n", [C]);
+ Versions ->
+ io:format("Not supported version: ~p~n", [Versions])
+ end;
+ _ -> ok
+ end,
+ wx_test_lib:wx_destroy(Frame, Config).
+
+