diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..52b04f2 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +sphinx_rtd_theme \ No newline at end of file diff --git a/source/_static/1/hello_world.png b/source/_static/1/hello_world.png new file mode 100644 index 0000000..7f33aa4 Binary files /dev/null and b/source/_static/1/hello_world.png differ diff --git a/source/_static/1/intellij.png b/source/_static/1/intellij.png new file mode 100644 index 0000000..8419fe9 Binary files /dev/null and b/source/_static/1/intellij.png differ diff --git a/source/_static/1/maven_project.png b/source/_static/1/maven_project.png new file mode 100644 index 0000000..2e05491 Binary files /dev/null and b/source/_static/1/maven_project.png differ diff --git a/source/conf.py b/source/conf.py index 9fe3776..8f04115 100644 --- a/source/conf.py +++ b/source/conf.py @@ -15,6 +15,7 @@ # import os # import sys # sys.path.insert(0, os.path.abspath('.')) +import sphinx_rtd_theme from recommonmark.parser import CommonMarkParser @@ -90,6 +91,8 @@ html_theme = 'sphinx_rtd_theme' # # html_theme_options = {} +html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] + # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". diff --git a/source/first-steps.md b/source/first-steps.md index 983b250..71a68b1 100644 --- a/source/first-steps.md +++ b/source/first-steps.md @@ -1,26 +1,27 @@ -# First steps +# 事前准备 -In this book we will learn the principal techniques involved in developing 3D games. We will develop our samples in Java and we will use the Lightweight Java Game Library \([LWJGL](http://www.lwjgl.org/)\). The LWJGL library enables the access to low-level APIs \(Application Programming Interface\) such as OpenGL. +在本书中,我们将学习开发3D游戏所涉及的主要技术。本书将使用Java语言和Java轻量级游戏库([LWJGL](http://www.lwjgl.org/))来编写示例代码。LWJGL库允许我们访问底层的API(应用程序接口),例如OpenGL。 -LWJGL is a low level API that acts like a wrapper around OpenGL. If your idea is to start creating 3D games in a short period of time maybe you should consider other alternatives like \[JmonkeyEngine\]. By using this low level API you will have to go through many concepts and write lots of lines of code before you see the results. The benefit of doing it this way is that you will get a much better understanding of 3D graphics and also you can get better control. +LWJGL是一个底层的API,它像一个OpenGL包装库。如果你是想在短时间内开始制作一个3D游戏,那么也许你该考虑别的选择,比如使用引擎[JmonkeyEngine]。使用LWJGL这个底层API,在你看到效果之前,你需要了解许多概念并且编写大量的代码。这样做的好处是你可以更好的理解3D图形渲染,并且可以更好的控制它。 -As said in the previous paragraphs we will be using Java for this book. We will be using Java 10, so you need to download the Java SDK from Oracle’s pages. Just choose the installer that suits your Operating System and install it. This book assumes that you have a moderate understanding of the Java language. +在前文我们说过在本书中我们将使用Java。更确切来说我们将使用Java 10,所以你需要从Oracle的页面下载对应版本的JDK。 请选择适合你的操作系统的安装程序。本书假定你对Java语言有一定的了解。 -You may use the Java IDE you want in order to run the samples. You can download IntelliJ IDEA which has good support for Java 10. Since Java 10 is only available, by now, for 64 bits platforms, remeber to download the 64 bits version of IntelliJ. IntelliJ provides a free open source version, the Community version, which you can download from here: [https://www.jetbrains.com/idea/download/](https://www.jetbrains.com/idea/download/ "Intellij"). +如果你需要一个可以运行示例代码的Java IDE(集成开发环境),你可以下载为Java 10提供良好支持的IntelliJ IDEA。 由于Java 10仅支持64位的平台,记得下载64位版本的IntelliJ。IntelliJ提供有一个免费且开源的社区版,你可以在这里下载它: [https://www.jetbrains.com/idea/download/](https://www.jetbrains.com/idea/download/ "Intellij"). -![](/chapter01/intellij.png) +![](/_static/1/intellij.png) -For building our samples we will be using [Maven](https://maven.apache.org/). Maven is already integrated in most IDEs and you can directly open the different samples inside them. Just open the folder that contains the chapter sample and IntelliJ will detect that it is a maven project. +为了构建我们的示例代码,我们将使用[Maven](https://maven.apache.org/)。Maven已经集成在大多数IDE中,你可以在IDE中直接打开不同章节的示例代码。只要打开了示例代码的文件夹,IntelliJ就会检测到它是一个Maven项目。 -![](/chapter01/maven_project.png) +![](/_static/1/maven_project.png) -Maven builds projects based on an XML file named `pom.xml` \(Project Object Model\) which manages project dependencies \(the libraries you need to use\) and the steps to be performed during the build process. Maven follows the principle of convention over configuration, that is, if you stick to the standard project structure and naming conventions the configuration file does not need to explicitly say where source files are or where compiled classes should be located. +Maven基于一个名为`pom.xml`(Project Object Model,项目对象模型)的XML文件来构建项目,它管理了项目的依赖(需要使用的库)和在构建过程中需要执行的步骤。Maven遵循约定高于配置的原则,即如果你遵守标准的项目结构和命名约定,就不需要在配置文件中明确地声明源文件在哪里或者应该在哪里编译类。 -This book does not intend to be a maven tutorial, so please find the information about it in the web in case you need it. The source code folder defines a parent project which defines the plugins to be used and collects the versions of the libraries employed. +本书不是一个Maven教程,如果有需要,请在网上搜索Maven的相关资料。源代码文件夹定义了一个父项目,它声明需要使用的插件并且声明需要使用的库的版本。 -LWJGL 3.1 introduced some changes in the way that the project is built. Now the base code is much more modular, and we can be more selective in the packages that we want to use instead of using a giant monolithic jar file. This comes at a cost: You now need to carefully specify the dependencies one by one. But the [download](https://www.lwjgl.org/download) page includes a fancy script that generates the pom file for you. In our case, we will just be using GLFW and OpenGL bindings. You can check what the pom file looks like in the source code. +LWJGL 3.1 有了一些在项目构建上的改变。现在,它变得更加模块化,我们可以有选择的使用类库,而不是导入一个巨大的Jar文件。 +但这是有代价的:你需要仔细地逐个指定依赖关系。不过[LWJGL下载](https://www.lwjgl.org/download)页面提供了一个为您生成POM文件的脚本。在我们的示例中,我们将只使用GLFW和OpenGL。你可以在源代码中查看我们的POM文件。 -The LWJGL platform dependency already takes care of unpacking native libraries for your platform, so there's no need to use other plugins \(such as `mavennatives`\). We just need to set up three profiles to set a property that will configure the LWJGL platform. The profiles will set up the correct values of that property for Windows, Linux and Mac OS families. +LWJGL平台依赖库已经可以为你的操作系统自动解压本地库,因此不需要使用其他插件(例如`mavennatives`)。我们只需要配置三个Profile来设置LWJGL所处的操作系统。Profile将会为Windows、Linux和Mac OS系列设置正确的属性值。 ```xml @@ -60,7 +61,7 @@ The LWJGL platform dependency already takes care of unpacking native libraries f ``` -Inside each project, the LWJGL platform dependency will use the correct property established in the profile for the current platform. +在每一个项目中,LWJGL平台依赖项将使用当前操作系统指定的配置中的属性值。 ```xml @@ -71,16 +72,16 @@ Inside each project, the LWJGL platform dependency will use the correct property ``` -Besides that, every project generates a runnable jar \(one that can be executed by typing java -jar name\_of\_the\_jar.jar\). This is achieved by using the maven-jar-plugin which creates a jar with a `MANIFEST.MF` file with the correct values. The most important attribute for that file is `Main-Class`, which sets the entry point for the program. In addition, all the dependencies are set as entries in the `Class-Path` attribute for that file. In order to execute it on another computer, you just need to copy the main jar file and the lib directory \(with all the jars included there\) which are located under the target directory. +此外,每个项目生成一个可运行的Jar(一种可以通过输入`java -jar name_of_the_jar.jar`就可运行的Jar)。这是通过使用Maven的`maven-jar-plugin`插件实现的,该插件创建了一个含有`MANIFEST.MF`文件的Jar,并且文件内有指定的值。该文件最重要的属性就是`Main-Class`,它指明了程序的入口。此外,所有的依赖库都被设置在该文件的`Class-Path`属性中。要在另一台计算机上运行它,你只需要复制位于目标目录下的主Jar文件和Lib目录(包括其中所有的Jar文件)。 -The jars that contain LWJGL classes, also contain the native libraries. LWJGL will also take care of extracting them and adding them to the path where the JVM will look for libraries. +Jar文件包含着LWJGL类和本地库。LWJGL还将负责提取它们,并将它们添加到JVM的库路径中。 -Chapter 1 source code is taken directly from the getting started sample in the LWJGL site \([http://www.lwjgl.org/guide](http://www.lwjgl.org/guide)\). You will see that we are not using Swing or JavaFX as our GUI library. Instead of that we are using [GLFW](www.glfw.org) which is a library to handle GUI components \(Windows, etc.\) and events \(key presses, mouse movements, etc.\) with an OpenGL context attached in a straightforward way. Previous versions of LWJGL provided a custom GUI API but, for LWJGL 3, GLFW is the preferred windowing API. +本章的源代码是LWJGL网站([http://www.lwjgl.org/guide](http://www.lwjgl.org/guide))的入门示例,你可以看到我们没有使用Swing或JavaFX作为我们的GUI库。我们使用的是[GLFW](www.glfw.org),它是一个用来处理GUI组件(窗口等)和事件(按键按下、鼠标移动等),并且与OpenGL上下文进行简单连接的库。此前版本的LWJGL提供了一个自定义GUI API,但在LWJGL 3中,GLFW是首选的窗口API。 -The samples source code is very well documented and straightforward so we won’t repeat the comments here. +示例源码是简单的并且有着良好的文档,所以我们不会在书中再次说明。 -If you have your environment correctly set up you should be able to execute it and see a window with a red background. +如果你正确地配置了环境,你应该能够运行它并且看到一个有着红色背景的窗口。 -![Hello World](hello_world.png) +![Hello World](/_static/1/hello_world.png) -**The source code of this book is published in **[**GitHub**](https://github.com/lwjglgamedev/lwjglbook)**.** +**本书中源代码发布于 [**GitHub**](https://github.com/lwjglgamedev/lwjglbook)**。