При открытом окне imgui съедает около 50+- фпс.

sat0ry

Известный
Автор темы
1,087
290
Версия MoonLoader
.026-beta
Привет, добавил картиночку в окно imgui теперь фпс падает при открытом окне.
 
Решение
Lua:
require "lib.moonloader" -- подключение библиотеки
local keys = require "vkeys"
local imgui = require 'imgui'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8

local themes = import "resource/imgui_themes.lua"

main_window_state = imgui.ImBool(false)

-- for RADIO
local checked_radio = imgui.ImInt(1)
--

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end

    sampRegisterChatCommand("themes", cmd_themes)

    img = imgui.CreateTextureFromFile(getGameDirectory() .. "\\moonloader\\images\\memes.png")
    _, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
    nick = sampGetPlayerNickname(id)

    imgui.Process = false...

sat0ry

Известный
Автор темы
1,087
290
Можно код скрипта?
Попробую помочь
lua:
require "lib.moonloader" -- подключение библиотеки
local keys = require "vkeys"
local imgui = require 'imgui'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8

local themes = import "resource/imgui_themes.lua"

main_window_state = imgui.ImBool(false)

-- for RADIO
local checked_radio = imgui.ImInt(1)
--

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end

    sampRegisterChatCommand("themes", cmd_themes)

    _, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
    nick = sampGetPlayerNickname(id)

    imgui.Process = false

    imgui.SwitchContext()
    themes.SwitchColorTheme()

    --sampAddChatMessage("Скрипт imgui перезагружен", -1)


    while true do
        wait(0)

        if isKeyJustPressed(VK_F3) then
            sampAddChatMessage("Вы нажали клавишу {FFFFFF}F3." .. main_color_text .. "Ваш ник: {FFFFFF}" .. nick .. ", " .. main_color_text .. "ваш ID: {FFFFFF}" .. id, main_color)
        end

        if isKeyDown(VK_MENU) and isKeyJustPressed(VK_9) then
            sampAddChatMessage("Вы крут, вы зажали комбинацию клавиш!", main_color)
            wait(500)
            sampAddChatMessage("Прошло пол секунды", main_color)
        end
        -- Блок выполняющийся бесконечно (пока самп активен)

    end
end

function cmd_themes(arg)
    main_window_state.v = not main_window_state.v
    imgui.Process = main_window_state.v
   
    themes.SwitchColorTheme(tonumber(arg))
end

function imgui.OnDrawFrame()

    if not main_window_state.v then
        imgui.Process = false
    end

    if main_window_state.v then
        local sw, sh = getScreenResolution()
        imgui.SetNextWindowPos(imgui.ImVec2(sw / 2, sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.SetNextWindowSize(imgui.ImVec2(510, 600), imgui.Cond.FirstUseEver)

        imgui.Begin('Imgui Themes', main_window_state, imgui.WindowFlags.NoCollapse)

        if imgui.Button(u8'Кнопка') then
            themes.SwitchColorTheme(2)
        end

        img = imgui.CreateTextureFromFile(getGameDirectory() .. "\\moonloader\\images\\memes.png")
        imgui.Image(img, imgui.ImVec2(500, 347))

        imgui.BeginChild("ChildWindow2", imgui.ImVec2(200, 175), true)
            for i, value in ipairs(themes.colorThemes) do
                if imgui.RadioButton(value, checked_radio, i) then
                    themes.SwitchColorTheme(i)
                end
            end
        imgui.EndChild()


        imgui.End()
    end
end
 

дора

Потрачен
7
8
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
каждый кадр картинку загружаешь, красава

1642335556523.png


Lua:
require "lib.moonloader" -- подключение библиотеки
local keys = require "vkeys"
local imgui = require 'imgui'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8

local img = imgui.CreateTextureFromFile(getGameDirectory() .. "\\moonloader\\images\\cat.jpg")
local themes = import "resource/imgui_themes.lua"

main_window_state = imgui.ImBool(false)

-- for RADIO
local checked_radio = imgui.ImInt(1)
--

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end

    sampRegisterChatCommand("themes", cmd_themes)

    _, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
    nick = sampGetPlayerNickname(id)

    imgui.Process = false

    imgui.SwitchContext()
    themes.SwitchColorTheme()

    --sampAddChatMessage("Скрипт imgui перезагружен", -1)


    while true do
        wait(0)

        if isKeyJustPressed(VK_F3) then
            sampAddChatMessage("Вы нажали клавишу {FFFFFF}F3." .. main_color_text .. "Ваш ник: {FFFFFF}" .. nick .. ", " .. main_color_text .. "ваш ID: {FFFFFF}" .. id, main_color)
        end

        if isKeyDown(VK_MENU) and isKeyJustPressed(VK_9) then
            sampAddChatMessage("Вы крут, вы зажали комбинацию клавиш!", main_color)
            wait(500)
            sampAddChatMessage("Прошло пол секунды", main_color)
        end
        -- Блок выполняющийся бесконечно (пока самп активен)

    end
end

function cmd_themes(arg)
    main_window_state.v = not main_window_state.v
    imgui.Process = main_window_state.v
    
    themes.SwitchColorTheme(tonumber(arg))
end

function imgui.OnDrawFrame()

    if not main_window_state.v then
        imgui.Process = false
    end

    if main_window_state.v then
        local sw, sh = getScreenResolution()
        imgui.SetNextWindowPos(imgui.ImVec2(sw / 2, sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.SetNextWindowSize(imgui.ImVec2(510, 600), imgui.Cond.FirstUseEver)

        imgui.Begin('Imgui Themes', main_window_state, imgui.WindowFlags.NoCollapse)

        if imgui.Button(u8'Кнопка') then
            themes.SwitchColorTheme(2)
        end

        imgui.Image(img, imgui.ImVec2(500, 347))

        imgui.BeginChild("ChildWindow2", imgui.ImVec2(200, 175), true)
            for i, value in ipairs(themes.colorThemes) do
                if imgui.RadioButton(value, checked_radio, i) then
                    themes.SwitchColorTheme(i)
                end
            end
        imgui.EndChild()


        imgui.End()
    end
end
 

zTechnology

Известный
1,101
485
Lua:
require "lib.moonloader" -- подключение библиотеки
local keys = require "vkeys"
local imgui = require 'imgui'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8

local themes = import "resource/imgui_themes.lua"

main_window_state = imgui.ImBool(false)

-- for RADIO
local checked_radio = imgui.ImInt(1)
--

function main()
    if not isSampLoaded() or not isSampfuncsLoaded() then return end
    while not isSampAvailable() do wait(100) end

    sampRegisterChatCommand("themes", cmd_themes)

    img = imgui.CreateTextureFromFile(getGameDirectory() .. "\\moonloader\\images\\memes.png")
    _, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
    nick = sampGetPlayerNickname(id)

    imgui.Process = false

    imgui.SwitchContext()
    themes.SwitchColorTheme()

    --sampAddChatMessage("Скрипт imgui перезагружен", -1)


    while true do
        wait(0)

        if isKeyJustPressed(VK_F3) then
            sampAddChatMessage("Вы нажали клавишу {FFFFFF}F3." .. main_color_text .. "Ваш ник: {FFFFFF}" .. nick .. ", " .. main_color_text .. "ваш ID: {FFFFFF}" .. id, main_color)
        end

        if isKeyDown(VK_MENU) and isKeyJustPressed(VK_9) then
            sampAddChatMessage("Вы крут, вы зажали комбинацию клавиш!", main_color)
            wait(500)
            sampAddChatMessage("Прошло пол секунды", main_color)
        end
        -- Блок выполняющийся бесконечно (пока самп активен)

    end
end

function cmd_themes(arg)
    main_window_state.v = not main_window_state.v
    imgui.Process = main_window_state.v
   
    themes.SwitchColorTheme(tonumber(arg))
end

function imgui.OnDrawFrame()

    if not main_window_state.v then
        imgui.Process = false
    end

    if main_window_state.v then
        local sw, sh = getScreenResolution()
        imgui.SetNextWindowPos(imgui.ImVec2(sw / 2, sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.SetNextWindowSize(imgui.ImVec2(510, 600), imgui.Cond.FirstUseEver)

        imgui.Begin('Imgui Themes', main_window_state, imgui.WindowFlags.NoCollapse)

        if imgui.Button(u8'Кнопка') then
            themes.SwitchColorTheme(2)
        end

        imgui.Image(img, imgui.ImVec2(500, 347))

        imgui.BeginChild("ChildWindow2", imgui.ImVec2(200, 175), true)
            for i, value in ipairs(themes.colorThemes) do
                if imgui.RadioButton(value, checked_radio, i) then
                    themes.SwitchColorTheme(i)
                end
            end
        imgui.EndChild()


        imgui.End()
    end
end
 
  • Нравится
Реакции: sat0ry