lwjgl

Slick button will not work

若如初见. 提交于 2019-12-13 04:29:39
问题 I am following a video tutorial on a java game ( so I can go off from there ) but one of my buttons will not work (exit button). Please Help. I'm using lwjgl and slick. main class: package javagame; import org.newdawn.slick.*; import org.newdawn.slick.state.*; public class Game extends StateBasedGame { public static final String gamename = "Java Game Alpha 1.0"; public static final int menu = 0; public static final int play = 1; public Game(String gamename) { super(gamename); this.addState

Rotating a cube in modern opengl… looks strange

孤人 提交于 2019-12-13 03:45:11
问题 I'm somewhat lost, really lost. I'm trying to rotate a cube (just around the y-axis for now) and this is the (ugly and wrong) outcome: This is the code to rotate the matrix: def rotate(axis: Vector3, angle: Float): Unit = { val cosAngle: Float = Math.cos(angle).toFloat val sinAngle: Float = Math.sin(angle).toFloat val oneMinusCosAngle: Float = 1.0f - cosAngle val xy: Float = axis.x * axis.y val xz: Float = axis.x * axis.z val yz: Float = axis.y * axis.z val xs: Float = axis.x * sinAngle val

How to draw transparent textures in LWJGL?

徘徊边缘 提交于 2019-12-13 03:31:06
问题 I have been trying to draw a transparent texture in LWJGL. However, the code I have doesn't seem to work. Whenever I run the code, the transparent image appears but the background is completely black. Here's what I mean by completely black, but the image is fine: I have been able to draw non-transparent textures, but so far I've had no luck with drawing this one correctly. I would like to know what is missing/incorrect in this code. Code for drawing texture: //draw transparent texture GL11

java.lang.RuntimeException: No OpenGL context found in the current thread

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-13 02:44:53
问题 im trying to create a applet for a little game i created. when i run the game normally (no applet) it works just fine but when im trying to run it as an applet it gives me the following error. im using lwjgl 2.8.4 opengl java.lang.RuntimeException: No OpenGL context found in the current thread. java.lang.RuntimeException: Unable to create display at com.base.engine.GameApplet.init(GameApplet.java:202) at sun.applet.AppletPanel.run(AppletPanel.java:434) at java.lang.Thread.run(Thread.java:722)

get mouse in world coordinates with 2 gluUnproject calls to create ray

£可爱£侵袭症+ 提交于 2019-12-13 01:23:15
问题 I try to use what many people seem to find a good way, I call gluUnproject 2 times with different z-values and then try to calculate the direction vector for the ray from these 2 vectors. I read this question and tried to use the structure there for my own code: glGetFloat(GL_MODELVIEW_MATRIX, modelBuffer); glGetFloat(GL_PROJECTION_MATRIX, projBuffer); glGetInteger(GL_VIEWPORT, viewBuffer); gluUnProject(mouseX, mouseY, 0.0f, modelBuffer, projBuffer, viewBuffer, startBuffer); gluUnProject

Translation to world coordinates

你说的曾经没有我的故事 提交于 2019-12-12 21:16:02
问题 I have mouse coordinates: mousePos , a matrix view view , and a perspective projection matrix pMatrix . I translate the coordinates into the world: I find the inverse projection matrix and the inverse matrix view and multiply by the coordinates of the mouse. The coordinates of the origin is z = 4 , the coordinates of the end is z = -100 . In the first case, I get the coordinates mouseDir1 = (-0.1985 0.02887 4) , and in the second case mouseDir2 = (-0.1985 0.02887 -100) . Why are the

Blended textures show up fine, but ordinary coloured shapes do not

╄→гoц情女王★ 提交于 2019-12-12 19:24:51
问题 For some reason enabling alpha blending results in me not being able to draw run-of-the-mill coloured shapes. The order in which everything is drawn makes no difference. Even if the only thing being drawn is the coloured shape, it still won't show. Disabling alpha blending fixes this, but disables alpha blending (obviously). This leads me to believe the problem is in how I'm initializing openGL. The textured objects are contained in the world, which is commented out. Commenting "world.run();"

no lwjgl in java.library.path in playN hello sample

本小妞迷上赌 提交于 2019-12-12 16:28:04
问题 I'm having an error trying to run java playN project. The other ons seems to be fine. The error is: Exception in thread "main" java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path. There is dependencied library lwjgl 2.83 in the project. Whatis wrong here? 回答1: While you have the java dependency, you don't have the native library. You'll need to download lwjgl from http://www.lwjgl.org/, unpack and set up according to http://www.lwjgl.org/wiki/index.php?title=Main_Page#Getting

LWJGL Fullscreen not working

青春壹個敷衍的年華 提交于 2019-12-12 11:24:09
问题 I'm trying to add fullscreen functionality to my program but I couldn't get it to work. I'm trying Display.setFullscreen(true); I tried changing its position to above where I create the display or where I set the displaymode, but still not working. Any help about this? 回答1: From my experience the DisplayMode needs to support it. You can try this: DisplayMode displayMode = null; DisplayMode[] modes = Display.getAvailableDisplayModes(); for (int i = 0; i < modes.length; i++) { if (modes[i]

Difference between glcolor3b and glcolor3ub

青春壹個敷衍的年華 提交于 2019-12-12 11:12:12
问题 I was wondering what the difference is between glcolor3b() and glcolor3ub() . It appears that glcolor3b(255, 0, 0); does not set the color to red, but rather it sets it to black. glcolor3b(48, 160, 64) sets it to dark purple, not green. glcolor3ub() , however works as expected. Additionally, the documentation for glcolor3b() and glcolor3ub() are exactly the same, except for the "u": public static void glColor3(u)b(byte red, byte green, byte blue) Does anybody know why this is? 回答1: glColor3b(