MCPcopy Create free account
hub / github.com/WolfireGames/overgrowth / AttachTextCanvasTextureToASContext

Function AttachTextCanvasTextureToASContext

Source/Graphics/text.cpp:712–759  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

710}
711
712void AttachTextCanvasTextureToASContext(ASContext* ctx) {
713 g_as_text_context.font_renderer = FontRenderer::Instance();
714 g_as_text_context.graphics = Graphics::Instance();
715 ctx->RegisterObjectType("TextStyle", sizeof(CanvasTextStyle), asOBJ_VALUE | asOBJ_APP_CLASS_CD);
716 ctx->RegisterObjectProperty("TextStyle", "int font_face_id", offsetof(CanvasTextStyle, font_face_id));
717 ctx->RegisterObjectBehaviour("TextStyle", asBEHAVE_CONSTRUCT, "void f()", asFUNCTION(TextStyleDefaultConstructor), asCALL_CDECL_OBJLAST);
718 ctx->RegisterObjectBehaviour("TextStyle", asBEHAVE_DESTRUCT, "void f()", asFUNCTION(TextStyledestructor), asCALL_CDECL_OBJLAST);
719 ctx->RegisterObjectMethod("TextStyle", "void SetAlignment(int i)", asFUNCTION(TextStyleAlignment), asCALL_CDECL_OBJLAST);
720 ctx->DocsCloseBrace();
721 ctx->RegisterObjectType("TextMetrics", sizeof(TextMetrics), asOBJ_VALUE | asOBJ_POD | asOBJ_APP_CLASS_CA);
722 ctx->RegisterObjectProperty("TextMetrics", "int advance_x", asOFFSET(TextMetrics, advance));
723 ctx->RegisterObjectProperty("TextMetrics", "int advance_y", asOFFSET(TextMetrics, advance) + sizeof(int));
724 ctx->RegisterObjectProperty("TextMetrics", "int bounds_x", asOFFSET(TextMetrics, bounds) + (2 * sizeof(int)));
725 ctx->RegisterObjectProperty("TextMetrics", "int bounds_y", asOFFSET(TextMetrics, bounds) + (3 * sizeof(int)));
726 ctx->RegisterObjectProperty("TextMetrics", "float ascenderRatio", asOFFSET(TextMetrics, ascenderRatio));
727
728 ctx->DocsCloseBrace();
729 ctx->RegisterObjectType("TextCanvasTexture", 0, asOBJ_REF | asOBJ_NOCOUNT);
730 ctx->RegisterObjectMethod("TextCanvasTexture", "void Create(int width, int height)", asMETHOD(TextCanvasTexture, Create), asCALL_THISCALL);
731 ctx->RegisterObjectMethod("TextCanvasTexture", "void ClearTextCanvas()", asMETHOD(TextCanvasTexture, ClearTextCanvas), asCALL_THISCALL);
732 ctx->RegisterObjectMethod("TextCanvasTexture", "void UploadTextCanvasToTexture()", asMETHOD(TextCanvasTexture, UploadTextCanvasToTexture), asCALL_THISCALL);
733
734 ctx->RegisterObjectMethod("TextCanvasTexture", "void DebugDrawBillboard(const vec3 &in pos, float scale, int lifespan)", asMETHOD(TextCanvasTexture, DebugDrawBillboard), asCALL_THISCALL);
735 ctx->RegisterObjectMethod("TextCanvasTexture", "void AddText(const string &in, const TextStyle &in, uint char_limit)", asFUNCTION(ASAddText), asCALL_CDECL_OBJFIRST);
736 ctx->RegisterObjectMethod("TextCanvasTexture", "void AddTextMultiline(const string &in, const TextStyle &in, uint char_limit)", asFUNCTION(ASAddTextMultiline), asCALL_CDECL_OBJFIRST);
737 ctx->RegisterObjectMethod("TextCanvasTexture", "void GetTextMetrics(const string &in, const TextStyle &in, TextMetrics &out, uint char_limit)", asFUNCTION(ASGetTextMetricsInfo), asCALL_CDECL_OBJFIRST);
738 ctx->RegisterObjectMethod("TextCanvasTexture", "void SetPenPosition(const vec2 &in)", asMETHOD(TextCanvasTexture, SetPenPosition), asCALL_THISCALL);
739 ctx->RegisterObjectMethod("TextCanvasTexture", "void SetPenColor(int r, int g, int b, int a)", asMETHOD(TextCanvasTexture, SetPenColor), asCALL_THISCALL);
740 ctx->RegisterObjectMethod("TextCanvasTexture", "void SetPenRotation(float rotation)", asMETHOD(TextCanvasTexture, SetPenRotation), asCALL_THISCALL);
741 ctx->DocsCloseBrace();
742 ctx->RegisterEnum("TextAtlasFlags");
743 ctx->RegisterEnumValue("TextAtlasFlags", "kSmallLowercase", TextAtlas::kSmallLowercase);
744 ctx->DocsCloseBrace();
745 ctx->RegisterGlobalFunction("int GetFontFaceID(const string &in path, int pixel_height)", asFUNCTION(ASGetFontFaceID), asCALL_CDECL);
746 ctx->RegisterGlobalFunction("void DisposeTextAtlases()", asFUNCTION(DisposeTextAtlases), asCALL_CDECL);
747
748 ctx->RegisterGlobalFunctionThis("void DrawTextAtlas(const string &in path, int pixel_height, int flags, const string &in txt, int x, int y, vec4 color)",
749 asMETHOD(ASTextContext, ASDrawTextAtlas), asCALL_THISCALL_ASGLOBAL, &g_as_text_context);
750
751 ctx->RegisterGlobalFunctionThis("void DrawTextAtlas2(const string &in path, int pixel_height, int flags, const string &in txt, int x, int y, vec4 color, uint char_limit)",
752 asMETHOD(ASTextContext, ASDrawTextAtlas2), asCALL_THISCALL_ASGLOBAL, &g_as_text_context);
753
754 ctx->RegisterGlobalFunctionThis("TextMetrics GetTextAtlasMetrics(const string &in path, int pixel_height, int flags, const string &in txt )",
755 asMETHOD(ASTextContext, ASGetTextAtlasMetrics), asCALL_THISCALL_ASGLOBAL, &g_as_text_context);
756
757 ctx->RegisterGlobalFunctionThis("TextMetrics GetTextAtlasMetrics2(const string &in path, int pixel_height, int flags, const string &in txt, uint char_limit )",
758 asMETHOD(ASTextContext, ASGetTextAtlasMetrics2), asCALL_THISCALL_ASGLOBAL, &g_as_text_context);
759}
760
761bool TextAtlas::Pack(unsigned char* pixels, int atlas_dims[2],
762 int font_face_id, int lowercase_font_face_id,

Callers 5

InitializeMethod · 0.85
InitializeMethod · 0.85
InitializeMethod · 0.85
InitializeMethod · 0.85
InitializeMethod · 0.85

Calls 9

RegisterObjectTypeMethod · 0.80
DocsCloseBraceMethod · 0.80
RegisterObjectMethodMethod · 0.45
RegisterEnumMethod · 0.45
RegisterEnumValueMethod · 0.45

Tested by

no test coverage detected