= 创作分享 =
编程开发
JNI的jdouble值错误救助
3.14159265358979

JNI的jdouble值错误救助

3.14159265358979 于 2023-2-11 23:28 ( 1年前 ) [复制链接] [只看楼主] [打印]
360 0
dll部分源码:
void setSpeed(JNIEnv_* env, double speed) {
    MessageBox(NULL, to_wstring(speed).c_str(), L"speed", MB_OK);
    speed4f = speed;
}
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* jvm, void* res) {
        JNIEnv_* env;
        if (JNI_OK != jvm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_8))
        {
                MessageBox(NULL, L"JNI_OnLoad couldn't get JNIEnv_", L"JNI ERR", MB_OK);
                return JNI_ERR;
        }
        HMODULE lwjgl_opengl = GetModuleHandle(L"lwjgl_opengl.dll");
    if (lwjgl_opengl == 0)
    {
        MessageBox(NULL, L"JNI_OnLoad couldn't find lwjgl_opengl.dll", L"DLL ERR", MB_OK);
        return JNI_ERR;
    }
        color4f=(typeGLcolor4f)GetProcAddress(lwjgl_opengl, "Java_org_lwjgl_opengl_GL11_glColor4f");
    jclass gl11 = env->FindClass("org/lwjgl/opengl/GL11");
    jclass mod = env->FindClass("net/mcreator/colourful/ColourfulMod");
    JNINativeMethod colourfulGL[] = { { "glColor4f","(FFFF)V",reinterpret_cast<void*>(myColourfulGLcolor4f)} };
    JNINativeMethod nsetSpeed[] = { { "setSpeed","(D)V",reinterpret_cast<void*>(setSpeed)} };
    JNINativeMethod nsetEnabled[] = { { "setEnabled","(Z)V",reinterpret_cast<void*>(setEnabled)} };
    env->RegisterNatives(gl11, colourfulGL, 1);
    env->RegisterNatives(mod, nsetSpeed, 1);
    env->RegisterNatives(mod, nsetEnabled, 1);
        return env->GetVersion();
}
ColourfulMod.class里:
setSpeed(ColourModCfg.Speed.get());
public static native void setSpeed(double speed);
MessageBox显示的值是一个随机的值
azaz
azzz
eee
zaza
zzza
发表于 2023-2-11 23:28:10 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

回复 | 举报

该帖共收到 0 条回复!
百科目前不允许匿名发帖哦~ 请先 [ 登陆 ][ 注册 ] 吧~

本版积分规则

发新帖
  • 回复
  • 点评
  • 评分

[ MC百科(mcmod.cn) 除另有声明,所有开放公共编辑的内容均使用 BY-NC-SA 3.0 协议 ]

Minecraft百科CC协议
快速回复 返回顶部 返回列表