Java Game Programming - Drawing to the Screen

preview_player
Показать описание
In this episode of Java Game Programming we cover how to create the display, keep it on the screen and draw a line to it.
Рекомендации по теме
Комментарии
Автор

Wow I'm really liking this series so far, perfect pace.

DuskDesertdude
Автор

Just Wanted to let you know that these tutorials are helping massively with me learning java, and teach it in a way I can understand.

Thanks :-)

diamondninjagaming
Автор

Finaly some1 that explains calm and simple... :D

LordPunckyii
Автор

To anyone attempting this using JDK 9+ you will get an error that looks something like "Exception in thread "main" sun/misc/Unsafe"
Thankfully it's an easy fix. Just go to your module-info.java and add a line inside the module
"requires jdk.unsupported;"
That should fix it. This is necessary as this method is no longer supported by current version of JDK.

Katrik
Автор

For those who get
Exception in thread "main" java.lang.RuntimeException: No OpenGL context found in the current thread.
at
at
at

add this in the try-catch statement after the setDisplayMode line:

Display.create();

Hope it helps :)

cristiancurran
Автор

I am really liking the videos, but I can not get the game screen to open up. In the bottom section, it says there is a JRE System Library Problem, but there is no errors anywhere.

chrismckinley
Автор

Hey so i've been going crazy trying to set this up right. First my program wasn't building and in the "Problems", it said: "No JRE's installed compatible with the current execution environment." So i switched the JRE to the default(jre.1.8.0_25) instead of the one for Java-SE 1.7.
The Problem went away but when i click "Run" as you do at 5:56, it seems that the program builds because there's this green bar that pops up at the bottom right of the screen and goes away in 1.5seconds. But nothing shows up on my screen.
Keep in mind there are no Errors in my code, and it is EXACTLY the same as yours up until 5:56.
If you can help me out i'd appreciate it. I've been researching everywhere. No luck. I really wanna continue this series.

kylevladimir
Автор

when I tried to run it, that's what the console shows:
Exception in thread "main" java.lang.RuntimeException: No OpenGL context found in the current thread.
at
at
at
at
can someone tell me how to fix it?

ahmadbelhaj
Автор

When I run, there is absolutely no line at all. I need help for that.

chargedcreeper
Автор

I get an error when run saying No OpenGL context found in the current thread. What do I do?

ThatEntityGirl
Автор

Hey, thanks for the cool tutorial. For some reason, when I hit run I do get an extremely glitchy screen. The code is copied exactly (as far as my eyes can tell anyway) and the problem seems to lie with "Display.update();". The line displays and everything it's just the screen won't stay still/the same colour. Code is as follows:

package data;

import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;

import static org.lwjgl.opengl.GL11.*;
public class Boot {

public Boot () {
Display.setTitle("Game");
try {
Display.setDisplayMode(new DisplayMode(600, 400));
Display.create();
} catch (LWJGLException e) {
e.printStackTrace();
}


glLoadIdentity();
glOrtho(0, 600, 400, 0, 1, -1); //the screen coordinates; 
glMatrixMode(GL_MODELVIEW);

{
glBegin(GL_LINES);
glVertex2f(10, 10);
glVertex2f(100, 100);
glEnd();

//Display.update();
Display.sync(10);
}

Display.destroy();
}
public static void main(String args[]) {
new Boot();
}
}

blablabla
Автор

gLMatrixMode, gLLoadIdentity, gLOrtho, and gLMatrixMode are all not working. They are "undefined for the type Boot"

Any fix?

TisforTaco
Автор

my window keeps closing right away. Please help

brandonmcdermott
Автор

i, m getting  error  import static org.lwjgl.openal.GL11.*; watch video 30 time  try  40 time  not fix it  at all  it say cannot be Resolved

frogerwilling
Автор

Great video!  However, the way you draw the line (Immediate Mode.) is now deprecated for OpenGL.  I only point this out because people who are trying this and getting errors with no idea why, it could very well be because immediate mode is deprecated, and the version of OpenGL being used doesn't support it anymore.  It SHOULD, but you never know, especially when using a third party OpenGL interface like LWJGL!
TL; DR; if you're absolutely sure you've followed this video 100% correctly, and you're still getting errors, check to see if your OpenGL version isn't the problem =)

WeTheWounded