void graphics_reset(void) { // TODO point and line drawing modes matrixstack_origin(); graphics_setColor(1.0f, 1.0f, 1.0f, 1.0f); graphics_setBackgroundColor(0.0f, 0.0f, 0.0f, 1.0f); graphics_setBlendMode(graphics_BlendMode_alpha); graphics_setDefaultShader(); graphics_setColorMask(true, true, true, true); graphics_clearScissor(); graphics_setCanvas(NULL); }
void graphics_Font_printf(graphics_Font* font, char const* text, int px, int py, int limit, graphics_TextAlign align, float r, float sx, float sy, float ox, float oy, float kx, float ky) { moduleData.x = 0; moduleData.storeX = 0; moduleData.storeY = 0; moduleData.y = font->face->ascender; graphics_Shader* shader = graphics_getShader(); graphics_setDefaultShader(); int count = 0; int wrapped = 0; glBufferData(GL_ARRAY_BUFFER, sizeof(imageVertices), imageVertices, GL_DYNAMIC_DRAW); while((moduleData.cp = utf8_scan(&text))) { font->ch = font->characters[moduleData.cp]; glBindTexture(GL_TEXTURE_2D,font->ch.textureid); if (moduleData.storeX == 0) moduleData.storeX = px ;//- font->ch.sizex; if (moduleData.storeY == 0) moduleData.storeY = py + font->ch.sizey + 1; moduleData.x = px + font->ch.bearingx; moduleData.y = py - font->ch.bearingy; if ((wrapped == 0 && ++count >= limit)){ px = moduleData.x - (((font->ch.advancex >> 6)) * (font->ch.sizex + font->ch.bearingx)); px = moduleData.storeX; py = moduleData.storeY; count = 0; wrapped = 1; } moduleData.x = px + font->ch.bearingx; moduleData.y = py - font->ch.bearingy; if (moduleData.cp == '\n'){ px = moduleData.x - (((font->ch.advancex >> 6)) * (font->ch.sizex + font->ch.bearingx)); if (px < moduleData.storeX) px = moduleData.storeX; py += floor(font->ch.bearingy + 5.25f); continue; }
static int l_graphics_setShader(lua_State *state) { if(lua_isnoneornil(state, 1)) { graphics_setDefaultShader(); luaL_unref(state, LUA_REGISTRYINDEX, moduleData.currentShaderRef); moduleData.currentShaderRef = LUA_NOREF; return 0; } else if(l_graphics_isShader(state, 1)) { l_graphics_Shader* shader = l_graphics_toShader(state, 1); luaL_unref(state, LUA_REGISTRYINDEX, moduleData.currentShaderRef); lua_settop(state, 1); moduleData.currentShaderRef = luaL_ref(state, LUA_REGISTRYINDEX); graphics_setShader(&shader->shader); return 0; } else { lua_pushstring(state, "expected nil or shader"); return lua_error(state); } }