Java 上的 DirectX 是否可行?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/817216/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is DirectX on Java possible?
提问by izb
Is there an easy way to use DirectX in Java? In particular, DirectX's video APIs.
有没有一种在 Java 中使用 DirectX 的简单方法?特别是 DirectX 的视频 API。
I know that C# might be a more natural choice, but I have my devious reasons for wanting to do something so perverse.
我知道 C# 可能是一个更自然的选择,但我有我想要做一些如此反常的事情的狡猾理由。
采纳答案by Glen
I don't know about easy, but you could always use JNI to load the DirectX libs and invoke the methods.
我不知道简单,但你总是可以使用 JNI 来加载 DirectX 库并调用方法。
Using something like Swigyou could auto-generate a lot of the code.
使用像Swig这样的东西,你可以自动生成很多代码。
Not sure how workable something like that would be though.
不知道这样的事情会有多可行。
回答by m_vitaly
There seems to be a standard APIabout dealing with 3D inside Java.
似乎有一个关于在 Java 内部处理 3D的标准 API。
It probably uses some kind of accelerating technology, may be even DirectX.
它可能使用了某种加速技术,甚至可能是 DirectX。
But I'm not sure about direct video support in this framework.
但我不确定这个框架中的直接视频支持。
回答by LordOfThePigs
There is a set of Direct3D bindings for Java available at http://java-direct3d.sourceforge.net/but it seems that developement stopped in 2006 with DirectX 9.
在http://java-direct3d.sourceforge.net/ 上有一组适用于 Java 的 Direct3D 绑定,但似乎开发在 2006 年随着 DirectX 9 停止了。
Otherwise, there are OpenGL binding for java called JOGL.
否则,还有称为JOGL 的Java OpenGL 绑定。
回答by Devon_C_Miller
The package that you want to investigate is the Java Media Framework (JMF). The core of it is pure Java, and per-platform "performance packs" provide acceleration via native libraries. It currently supports A/V capture and playback in a wide varietyof data types as well as streaming via RTP and RTSP.
您要研究的包是 Java Media Framework (JMF)。它的核心是纯 Java,每个平台的“性能包”通过本机库提供加速。它目前支持多种数据类型的A/V 捕获和回放,以及通过 RTP 和 RTSP 进行流传输。
Sun's JMF home page
Sun 的JMF 主页
JMF软件/硬件要求
回答by Fourth Sky Interactive
I create a library using BridJ (https://bridj.googlecode.com) that wrap DirectX classes, so you can use almost the same code than C++ examples.
我使用包装 DirectX 类的BridJ ( https://bridj.googlecode.com)创建了一个库,因此您可以使用与 C++ 示例几乎相同的代码。
You can find the library in https://bitbucket.org/fourthskyinteractive/directx-for-java.
您可以在https://bitbucket.org/fourthskyinteractive/directx-for-java 中找到该库。
Please, let me know about projects you develop.
请让我知道您开发的项目。
回答by Stefan Carlson
Minecraft is coded in Java with LWJGL, but Messiah Andrew's Renderer Wrapper converts the OpenGL to DirectX by using a modified version of the LWJGL libraries. Using these libraries, you should be able to code in LWJGL and have the game be running DirectX.
Minecraft 使用 LWJGL 用 Java 编码,但 Messiah Andrew 的渲染器包装器使用 LWJGL 库的修改版本将 OpenGL 转换为 DirectX。使用这些库,您应该能够在 LWJGL 中编写代码并使游戏运行 DirectX。
回答by SkidRunner
It seems that most are forgetting that JavaFX and Java3D support both DirectX and OpenGL using the best context for the machine you are on... well actually if you are on windows it attempts to load DirectX if it is newer than your OpenGL version.
似乎大多数人都忘记了 JavaFX 和 Java3D 使用您所在机器的最佳上下文支持 DirectX 和 OpenGL……实际上,如果您在 Windows 上,它会尝试加载比您的 OpenGL 版本新的 DirectX。
I am not telling anyone to use either Java3D or JavaFX, but if you look at the source you can see how it is done.
我不会告诉任何人使用 Java3D 或 JavaFX,但是如果您查看源代码,您会看到它是如何完成的。
GrepCode"good for looking for how things are implemented"
GrepCode“非常适合寻找事情是如何实现的”
Open JavaFX"Open JavaFX project home" source
I should note that you want to look at the
com.sun.prism
package.
我应该注意到你想看看
com.sun.prism
包。
Java3D"Java3D project home" sources
I have been LEARNINGdevelopment, LOL, for 20 years. Professionally for about 8 possible has never been the question, but how long, and/or is it worth it... Those are the questions.
我一直在学习发展,哈哈,20 年了。专业地大约 8 可能从来都不是问题,但需要多长时间,和/或是否值得......这些就是问题。
Good luck my friend!
祝你好运,我的朋友!
If you need any help I would be interested in creating a DirectX wrapper for java so
GIVE ME A SHOUT!
如果您需要任何帮助,我会对为 Java 创建 DirectX 包装器感兴趣,因此
给我大喊大叫!