• Guest
HabraHabr
  • Main
  • Users

  • Development
    • Programming
    • Information Security
    • Website development
    • JavaScript
    • Game development
    • Open source
    • Developed for Android
    • Machine learning
    • Abnormal programming
    • Java
    • Python
    • Development of mobile applications
    • Analysis and design of systems
    • .NET
    • Mathematics
    • Algorithms
    • C#
    • System Programming
    • C++
    • C
    • Go
    • PHP
    • Reverse engineering
    • Assembler
    • Development under Linux
    • Big Data
    • Rust
    • Cryptography
    • Entertaining problems
    • Testing of IT systems
    • Testing Web Services
    • HTML
    • Programming microcontrollers
    • API
    • High performance
    • Developed for iOS
    • CSS
    • Industrial Programming
    • Development under Windows
    • Image processing
    • Compilers
    • FPGA
    • Professional literature
    • OpenStreetMap
    • Google Chrome
    • Data Mining
    • PostgreSQL
    • Development of robotics
    • Visualization of data
    • Angular
    • ReactJS
    • Search technologies
    • Debugging
    • Test mobile applications
    • Browsers
    • Designing and refactoring
    • IT Standards
    • Solidity
    • Node.JS
    • Git
    • LaTeX
    • SQL
    • Haskell
    • Unreal Engine
    • Unity3D
    • Development for the Internet of things
    • Functional Programming
    • Amazon Web Services
    • Google Cloud Platform
    • Development under AR and VR
    • Assembly systems
    • Version control systems
    • Kotlin
    • R
    • CAD/CAM
    • Customer Optimization
    • Development of communication systems
    • Microsoft Azure
    • Perfect code
    • Atlassian
    • Visual Studio
    • NoSQL
    • Yii
    • Mono и Moonlight
    • Parallel Programming
    • Asterisk
    • Yandex API
    • WordPress
    • Sports programming
    • Lua
    • Microsoft SQL Server
    • Payment systems
    • TypeScript
    • Scala
    • Google API
    • Development of data transmission systems
    • XML
    • Regular expressions
    • Development under Tizen
    • Swift
    • MySQL
    • Geoinformation services
    • Global Positioning Systems
    • Qt
    • Dart
    • Django
    • Development for Office 365
    • Erlang/OTP
    • GPGPU
    • Eclipse
    • Maps API
    • Testing games
    • Browser Extensions
    • 1C-Bitrix
    • Development under e-commerce
    • Xamarin
    • Xcode
    • Development under Windows Phone
    • Semantics
    • CMS
    • VueJS
    • GitHub
    • Open data
    • Sphinx
    • Ruby on Rails
    • Ruby
    • Symfony
    • Drupal
    • Messaging Systems
    • CTF
    • SaaS / S+S
    • SharePoint
    • jQuery
    • Puppet
    • Firefox
    • Elm
    • MODX
    • Billing systems
    • Graphical shells
    • Kodobred
    • MongoDB
    • SCADA
    • Hadoop
    • Gradle
    • Clojure
    • F#
    • CoffeeScript
    • Matlab
    • Phalcon
    • Development under Sailfish OS
    • Magento
    • Elixir/Phoenix
    • Microsoft Edge
    • Layout of letters
    • Development for OS X
    • Forth
    • Smalltalk
    • Julia
    • Laravel
    • WebGL
    • Meteor.JS
    • Firebird/Interbase
    • SQLite
    • D
    • Mesh-networks
    • I2P
    • Derby.js
    • Emacs
    • Development under Bada
    • Mercurial
    • UML Design
    • Objective C
    • Fortran
    • Cocoa
    • Cobol
    • Apache Flex
    • Action Script
    • Joomla
    • IIS
    • Twitter API
    • Vkontakte API
    • Facebook API
    • Microsoft Access
    • PDF
    • Prolog
    • GTK+
    • LabVIEW
    • Brainfuck
    • Cubrid
    • Canvas
    • Doctrine ORM
    • Google App Engine
    • Twisted
    • XSLT
    • TDD
    • Small Basic
    • Kohana
    • Development for Java ME
    • LiveStreet
    • MooTools
    • Adobe Flash
    • GreaseMonkey
    • INFOLUST
    • Groovy & Grails
    • Lisp
    • Delphi
    • Zend Framework
    • ExtJS / Sencha Library
    • Internet Explorer
    • CodeIgniter
    • Silverlight
    • Google Web Toolkit
    • CakePHP
    • Safari
    • Opera
    • Microformats
    • Ajax
    • VIM
  • Administration
    • System administration
    • IT Infrastructure
    • *nix
    • Network technologies
    • DevOps
    • Server Administration
    • Cloud computing
    • Configuring Linux
    • Wireless technologies
    • Virtualization
    • Hosting
    • Data storage
    • Decentralized networks
    • Database Administration
    • Data Warehousing
    • Communication standards
    • PowerShell
    • Backup
    • Cisco
    • Nginx
    • Antivirus protection
    • DNS
    • Server Optimization
    • Data recovery
    • Apache
    • Spam and antispam
    • Data Compression
    • SAN
    • IPv6
    • Fidonet
    • IPTV
    • Shells
    • Administering domain names
  • Design
    • Interfaces
    • Web design
    • Working with sound
    • Usability
    • Graphic design
    • Design Games
    • Mobile App Design
    • Working with 3D-graphics
    • Typography
    • Working with video
    • Work with vector graphics
    • Accessibility
    • Prototyping
    • CGI (graphics)
    • Computer Animation
    • Working with icons
  • Control
    • Careers in the IT industry
    • Project management
    • Development Management
    • Personnel Management
    • Product Management
    • Start-up development
    • Managing the community
    • Service Desk
    • GTD
    • IT Terminology
    • Agile
    • Business Models
    • Legislation and IT-business
    • Sales management
    • CRM-systems
    • Product localization
    • ECM / EDS
    • Freelance
    • Venture investments
    • ERP-systems
    • Help Desk Software
    • Media management
    • Patenting
    • E-commerce management
    • Creative Commons
  • Marketing
    • Conferences
    • Promotion of games
    • Internet Marketing
    • Search Engine Optimization
    • Web Analytics
    • Monetize Web services
    • Content marketing
    • Monetization of IT systems
    • Monetize mobile apps
    • Mobile App Analytics
    • Growth Hacking
    • Branding
    • Monetize Games
    • Display ads
    • Contextual advertising
    • Increase Conversion Rate
  • Sundry
    • Reading room
    • Educational process in IT
    • Research and forecasts in IT
    • Finance in IT
    • Hakatonas
    • IT emigration
    • Education abroad
    • Lumber room
    • I'm on my way

Writing a game on LWJGL

 
3r3-31.

Creating a game on LWJGL # 1

3r33333.  
3r33333.  
Writing a game is a complex and interesting process that takes a lot of time. In this series of articles, I will explain how to create a simple 3D Java game using the LWJGL library. 3r33380. 3r33333.  
To create your game you need the following:
3r33333.  
 
3r3333. Ability to write Java code (minimum necessary: ​​understanding of the work of conditions, cycles, strings, arrays, functions, classes) 3-33430.  
3r3333. Development environment (I will use Eclipse)
 
3r3333. LWJGL library
 
3r3333. Video card that supports OpengGL version not lower than ???r33430.  
3r3333. Leisure time
 
3r3333. The idea of ​​
 
3r33432. 3r33333.  
Who cares, I ask under the cat. 3r33333.  
How to install Eclipse . 3r33333.  
Download LWJGL ??? , 3D graphics library, add her in your project. 3r33333.  
3r33333.  
Download slick-util , a library that simplifies loading textures, add it to the project. 3r33333.  
3r33333.  

Step two, check 3r33280. 3r33333.  
First of all, create the Main class in the main package, put the following code in it:
 
3r375. 3r33333.  
3r33333.  
If the line with input is not highlighted in red, then everything is OK (on the screen it is highlighted in yellow, since this library is not used in the code). 3r33333.  
3r33333.  
Step three, display 3—3–3280. 3r33333.  
Fill the Main class with the following code:
 
The starting code is 3r33285.
import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;
public class Main {
static int width = 80? height = 600;
static DisplayMode mainDisplayMode = new DisplayMode (width, height);
static boolean running = true;
static void update () {
if (Display.wasResized ()) {
width = Display.getWidth ();
height = Display.getHeight ();
}
Display.update ();
Display.sync (60);
if (Display.isCloseRequested ()) {
running = false;
}
}
public static void main (String[]args) {
try {
Display.setLocation (
(Display.getDesktopDisplayMode (). GetWidth () - mainDisplayMode.getWidth ()) /?
Display.getDesktopDisplayMode (). GetHeight () - mainDisplayMode.
Display.setResizable (true);
Display.setVSyncEnabled (true);
Display.setDisplayMode (mainDisplayMode);
Display.create ();
} catch (LWJGLException ex) {
System.err.println (ex.getStackTrace (). ToString ());
Display.destroy ();
System.exit (1);
}
while (running) {
update ();
}
Display.destroy ();
System.exit (0);
}
}
3r33358.
3r33333.  
3r3442. 3r3442. 3r33333.  
3r33333.  
So what happens here:
 
Display.
Display.setResizable (true);
Display.setVSyncEnabled (true);
Display.setDisplayMode (mainDisplayMode);
Display.create ();
3r33358.
3r33333.  
3r33333.  
In these lines:
 
1. sets the display position (in the center of the screen) 3r33333.  
2. It is allowed to change its size
 
3. Vertical sync turns on
 
4. Set the DisplayMode in which the screen sizes and some other parameters
are stored.  
5. in the last line the display is created and displayed on the screen. 3r33333.  
3r33333.  
static void update () {
if (Display.wasResized ()) {
width = Display.getWidth ();
height = Display.getHeight ();
}
Display.update ();
Display.sync (60);
if (Display.isCloseRequested ()) {
running = false;
}
}
3r33358.
3r33333.  
3r33333.  
In the update function, which is called in an infinite loop:
 
1. Check for resizing the
window.  
2. Update display
 
3. In the Display.sync (60) line, the display synchronizes with 60 hertz (if you have a different screen refresh rate, for example, 5? 7? 12? 14? etc., set your frequency). 3r33333.  
4. Verify that the window is closed
 
3r33333.  
Notice how the program ends when the user clicks on the cross, the window’s close flag, Display.isCloseRequested () becomes true, and the running variable becomes false, and the next iteration will not execute the while (running) loop and go to the Display lines .destroy (), which will destroy the display and System.exit (0), the call of which will end the program. 3r33333.  
3r33333.  
Step Four, OpenGL

3r33333.  
To initialize OpenGL to the main function before the while (running) loop, add the following code:
 
if (! GLContext.getCapabilities (). OpenGL33) {
System.err.println ("Your video card does not support OpenGL 3.3.");
System.exit (0);
}
3r33358.
3r33333.  
This code checks if the video card supports OpenGL 3.? if the video card does not support this version, try updating the drivers or switching to another video card (if you have more than one). 3r33333.  
3r33333.  
So, the check is done, if everything is good, the video card supports OpenGL 3.? then we move on. After the verification code, add the following code before the loop:
 
glShadeModel (GL_SMOOTH);
glEnable (GL_TEXTURE_2D);
glEnable (GL_DEPTH_TEST);
glClearColor (1f, 0f, 0f, 1f);
3r33358.
3r33333.  
This code will configure OpenGL as follows:
 
1. Turn on soft lighting in shaders
 
2. Turn on textures
 
3. Turn on depth checking (so that nearby objects overlap distant ones)
 
4. Set the cleaning color to
 
3r33333.  
In the loop while (running), before calling the function update (), add the line
 
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
3r33358.
3r33333.  
3r33333.  
Which will clear the color buffer and depth buffer every time the screen is refreshed. 3r33333.  
3r33333.  

The resulting code is

3r33333.  
Click to view [/b]
import static org.lwjgl.opengl.GL11.GL_COLOR_BUFFER_BIT;
import static org.lwjgl.opengl.GL11.GL_DEPTH_BUFFER_BIT;
import static org.lwjgl.opengl.GL11.GL_DEPTH_TEST;
import static org.lwjgl.opengl.GL11.GL_SMOOTH;
import static org.lwjgl.opengl.GL11.GL_TEXTURE_2D;
import static org.lwjgl.opengl.GL11.glClear;
import static org.lwjgl.opengl.GL11.glClearColor;
import static org.lwjgl.opengl.GL11.glEnable;
import static org.lwjgl.opengl.GL11.glShadeModel;
import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;
import org.lwjgl.opengl.GLContext;
public class Main {
static int width = 80? height = 600;
static DisplayMode mainDisplayMode = new DisplayMode (width, height);
static boolean running = true;
static void update () {
if (Display.wasResized ()) {
width = Display.getWidth ();
height = Display.getHeight ();
}
Display.update ();
Display.sync (60);
if (Display.isCloseRequested ()) {
running = false;
}
}
public static void main (String[]args) {
try {
Display.setLocation ((Display.getDesktopDisplayMode (). GetWidth () - mainDisplayMode.getWidth ()) /? (Display.getDesktopDisplayMode (). GetHeight () - mainDisplayMode.getHeight ()) /2);
Display.setResizable (true);
Display.setVSyncEnabled (true);
Display.setDisplayMode (mainDisplayMode);
Display.create ();
} catch (LWJGLException ex) {
System.err.println (ex.getStackTrace (). ToString ());
Display.destroy ();
System.exit (1);
}
if (! GLContext.getCapabilities (). OpenGL33) {
System.err.println ("Your video card does not support OpenGL 3.3.");
System.exit (0);
}
glShadeModel (GL_SMOOTH);
glEnable (GL_TEXTURE_2D);
glEnable (GL_DEPTH_TEST);
glClearColor (1f, 0f, 0f, 1f);
while (running) {
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
update ();
}
Display.destroy ();
System.exit (0);
}
}
3r33358.
3r33333.  
3r3442. 3r3442. 3r33333.  
3r33333.  
This concludes the first article on writing a game on LWJGL, if the survey contains more than 50% positive answers, I will continue to write a series of articles. 3r3442.
3r33333. ! function (e) {function t (t, n) {if (! (n in e)) {for (var r, a = e.document, i = a.scripts, o = i.length; o-- ;) if (-1! == i[o].src.indexOf (t)) {r = i[o]; break} if (! r) {r = a.createElement ("script"), r.type = "text /jаvascript", r.async =! ? r.defer =! ? r.src = t, r.charset = "UTF-8"; var d = function () {var e = a.getElementsByTagName ("script")[0]; e.parentNode.insertBefore (r, e)}; "[object Opera]" == e.opera? a.addEventListener? a.addEventListener ("DOMContentLoaded", d,! 1): e.attachEvent ("onload", d ): d ()}}} t ("//mediator.mail.ru/script/2820404/"""_mediator") () ();
3r3442.
Only registered users can participate in the survey. Enter , you are welcome. 3r33380.
3r33383.
3r33385.
Continue writing a series of articles? 3r33434.
3r3442.
3r33393.
3r33395.
3r33399.
3r3402.
3r33418.
3r33420.
3r33424. Yes
3r33427.
3r33430.
3r33418.
3r33420.
3r33424. No 3r33434.
3r33427.
3r33430.
3r33432.
3r33434.
3r3442.
2 users have voted. Abstained 2 users. 3r3442.
3r3442.

It may be interesting

  • Comments
  • About article
  • Similar news
This publication has no comments.

weber

Author

28-10-2018, 12:38

Publication Date

Game development / JavaScript

Category
  • Comments: 0
  • Views: 273
SHOCK! New software for phishing does
Let's talk about metrics as a way to
“How to turn a simple project into a
The story of one game or 4 strategy,
Notes IoT provider. Case: we make a
Another way to use docker-compose is
Write a comment
Name:*
E-Mail:


Comments
this is really nice to read..informative post is very good to read..thanks a lot! How is the cost of house cleaning calculated?
Today, 17:14

Legend SEO

It’s very informative and you are obviously very knowledgeable in this area. You have opened my eyes to varying views on this topic with interesting and solid content.

entegrasyon programları
Today, 17:09

taxiseo2

I am really enjoying reading your well written articles. It looks like you spend a lot of effort and time on your blog. I have bookmarked it and I am looking forward to reading new articles. Keep up the good work.

entegrasyon programları
Today, 17:02

taxiseo2

I found so many interesting stuff in your blog especially its discussion. From the tons of comments on your articles, I guess I am not the only one having all the enjoyment here! keep up the good work...먹튀

Today, 16:50

raymond weber

Lose Weight Market provides the best fitness tips, workout guides, keto recipes and diet plans, yoga workout routine and plans, healthy recipes, and more! Check Out: Lose Weight Market


Corvus Health provides medical training services as well as recruiting high quality health workers for you or placing our own best team in your facility. Check Out: Health Workforce Recruitment


Today, 19:37

noorseo

Adv
Website for web developers. New scripts, best ideas, programming tips. How to write a script for you here, we have a lot of information about various programming languages. You are a webmaster or a beginner programmer, it does not matter, useful articles will help to make your favorite business faster.

Login

Registration Forgot password