Skip to content

Commit

Permalink
Set WebGL target to 2. Make importRelative xml macro more generic
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugh Sanderson committed Sep 18, 2024
1 parent 4a21a19 commit 9473bbb
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
2 changes: 2 additions & 0 deletions project/ToolkitBuild.xml
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,8 @@
<section if="HXCPP_JS_PRIME || emscripten">
<vflag name="-s" value="EXPORTED_FUNCTIONS=['_malloc','_free','_main','ccall']" />
<vflag name="-s" value="FETCH=1" />
<vflag name="-s" value="STACK_SIZE=262144" if="wasm" />
<vflag name="-s" value="MIN_WEBGL_VERSION=2" if="wasm" />
</section>

<section if="android">
Expand Down
1 change: 1 addition & 0 deletions project/src/opengl/OGLExport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ unsigned int getResource(value inResource, ResoType inType)
else if (resource->contextVersion!=gTextureContextVersion)
{
ELOG("Warning: %s resource is from old context in %s", getTypeString(inType), sDebugName);
resource->contextVersion=gTextureContextVersion;
}
else if (resource->type!=inType)
{
Expand Down
4 changes: 3 additions & 1 deletion project/src/sdl/SDLStage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ class SDLStage : public Stage

void Resize(int inWidth, int inHeight, bool resizeWindow = false)
{
#ifdef HX_WINDOWS
#if (defined(HX_WINDOWS) || defined(emscripten))
if (mIsOpenGL && !resizeWindow)
{
// Little hack to help windows
Expand All @@ -378,6 +378,8 @@ class SDLStage : public Stage
// display lists. So Work around it.
gTextureContextVersion++;



if (mIsOpenGL)
{
Event contextLost(etRenderContextLost);
Expand Down
2 changes: 1 addition & 1 deletion src/nme/StaticNme.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package nme;

@:cppFileCode('extern "C" int nme_register_prims();')
#if !nmelink
@:build(nme.macros.BuildXml.importRelative("../../../project/ToolkitBuild.xml"))
@:build(nme.macros.BuildXml.importRelative("../../../project/ToolkitBuild.xml","NME_STATIC_LINK","nme-target"))
#else
@:buildXml("
<target id='haxe'>
Expand Down
6 changes: 3 additions & 3 deletions src/nme/macros/BuildXml.hx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ using haxe.macro.PositionTools;

class BuildXml
{
public static macro function importRelative(inFilename:String):Array<Field>
public static macro function importRelative(inFilename:String, compileDef:String, mergeTarget:String ):Array<Field>
{
var dir = Path.directory(Context.currentPos().getInfos().file);
if (!Path.isAbsolute(dir))
Expand All @@ -20,10 +20,10 @@ class BuildXml
dir = here + dir;
}
var xmlInject =
"<set name='NME_STATIC_LINK' value='1' />\n" +
"<set name='"+ compileDef + "' value='1' />\n" +
"<import name='" + Path.normalize( dir+inFilename ) + "'/>\n" +
"<target id='haxe'>\n" +
" <merge id='nme-target'/>\n" +
" <merge id='" + mergeTarget + "'/>\n" +
"</target>;\n";
var p = Context.currentPos();
Context.getLocalClass().get().meta.add(":buildXml", [ { expr:EConst( CString( xmlInject ) ), pos:p } ], p );
Expand Down

0 comments on commit 9473bbb

Please sign in to comment.