Hello Guest

Recent Posts

Pages: [1] 2 3 ... 10
1
NULL is not null. NULL instead is defined as a static field whose type is long and value is 0.
2
Hello. In the getting started tutorial available here : https://www.lwjgl.org/guide

Line 50 is the following,
Code: [Select]
if ( window == NULL )
But the variable window is declared as a primitive long in Line 17,
Code: [Select]
    private long window;
A primitive long can never be null. So is this a mistake in line 50?

-
3
LWJGL Documentation / Re: Issue with Gradle on MacOS
« Last post by markus on Today at 00:25:49 »
If you navigate to the MacOS section there is a server error.  The displayed error was the in attachments. 
4
I have a feeling you misunderstood my answer. This is a critical issue for LWJGL and I'll try to resolve it as soon as possible. LWJGL must support Excelsior Jet and other AOT compilers.
5
LWJGL Documentation / Re: Issue with Gradle on MacOS
« Last post by spasi on Today at 00:12:26 »
Thanks for reporting this. Looks like the OSGi artifact IDs have an "org.lwjgl." prefix, which doesn't exist in the non-OSGi artifacts. For example, instead of:

Code: [Select]
compile "org.lwjgl.osgi:lwjgl:3.1.6"
you need to specify:

Code: [Select]
compile "org.lwjgl.osgi:org.lwjgl.lwjgl:3.1.6"
and it should be able to resolve the artifacts. I'll update the build customizer on the website to generate the correct ids when the OSGi mode is enabled.

When I attempt to look at the files through the browser (https://www.lwjgl.org/browse) I get a 500 error.

Where exactly do you get the 500 error? (note that the file browser does not contain any OSGi artifacts, you can get them from Maven Central only)
6
LWJGL Documentation / Issue with Gradle on MacOS
« Last post by markus on May 21, 2018, 22:23:33 »
I'm having trouble resolving dependencies on MacOS.  I have followed the instructions for setting up the build.gradle file. 

Code: [Select]
plugins {
    id 'groovy'
    id 'java'
}

apply plugin: 'idea'
apply plugin: 'java'
apply plugin: 'application'

group 'com.example'
version '1.0'

sourceCompatibility = 1.8

import org.gradle.internal.os.OperatingSystem

switch ( OperatingSystem.current() ) {
    case OperatingSystem.WINDOWS:
        project.ext.lwjglNatives = "natives-windows"
        break
    case OperatingSystem.LINUX:
        project.ext.lwjglNatives = "natives-linux"
        break
    case OperatingSystem.MAC_OS:
        project.ext.lwjglNatives = "natives-macos"
        break
}

repositories {
    mavenCentral()
}

dependencies {
    //----------LWJGL START----------//
    compile "org.lwjgl.osgi:lwjgl:3.1.6"
    compile "org.lwjgl.osgi:lwjgl-assimp:3.1.6"
    compile "org.lwjgl.osgi:lwjgl-bgfx:3.1.6"
    compile "org.lwjgl.osgi:lwjgl-egl:3.1.6"
    compile "org.lwjgl.osgi:lwjgl-glfw:3.1.6"
    compile "org.lwjgl.osgi:lwjgl-jawt:3.1.6"
    compile "org.lwjgl.osgi:lwjgl-jemalloc:3.1.6"
    compile "org.lwjgl.osgi:lwjgl-lmdb:3.1.6"
    compile "org.lwjgl.osgi:lwjgl-lz4:3.1.6"
    compile "org.lwjgl.osgi:lwjgl-nanovg:3.1.6"
    compile "org.lwjgl.osgi:lwjgl-nfd:3.1.6"
    compile "org.lwjgl.osgi:lwjgl-nuklear:3.1.6"
    compile "org.lwjgl.osgi:lwjgl-odbc:3.1.6"
    compile "org.lwjgl.osgi:lwjgl-openal:3.1.6"
    compile "org.lwjgl.osgi:lwjgl-opencl:3.1.6"
    compile "org.lwjgl.osgi:lwjgl-opengl:3.1.6"
    compile "org.lwjgl.osgi:lwjgl-opengles:3.1.6"
    compile "org.lwjgl.osgi:lwjgl-openvr:3.1.6"
    compile "org.lwjgl.osgi:lwjgl-ovr:3.1.6"
    compile "org.lwjgl.osgi:lwjgl-par:3.1.6"
    compile "org.lwjgl.osgi:lwjgl-remotery:3.1.6"
    compile "org.lwjgl.osgi:lwjgl-rpmalloc:3.1.6"
    compile "org.lwjgl.osgi:lwjgl-sse:3.1.6"
    compile "org.lwjgl.osgi:lwjgl-stb:3.1.6"
    compile "org.lwjgl.osgi:lwjgl-tinyexr:3.1.6"
    compile "org.lwjgl.osgi:lwjgl-tinyfd:3.1.6"
    compile "org.lwjgl.osgi:lwjgl-tootle:3.1.6"
    compile "org.lwjgl.osgi:lwjgl-vulkan:3.1.6"
    compile "org.lwjgl.osgi:lwjgl-xxhash:3.1.6"
    compile "org.lwjgl.osgi:lwjgl-yoga:3.1.6"
    compile "org.lwjgl.osgi:lwjgl-zstd:3.1.6"
    compile "org.lwjgl.osgi:lwjgl:3.1.6:$lwjglNatives"
    compile "org.lwjgl.osgi:lwjgl-assimp:3.1.6:$lwjglNatives"
    compile "org.lwjgl.osgi:lwjgl-bgfx:3.1.6:$lwjglNatives"
    compile "org.lwjgl.osgi:lwjgl-glfw:3.1.6:$lwjglNatives"
    compile "org.lwjgl.osgi:lwjgl-jemalloc:3.1.6:$lwjglNatives"
    compile "org.lwjgl.osgi:lwjgl-lmdb:3.1.6:$lwjglNatives"
    compile "org.lwjgl.osgi:lwjgl-lz4:3.1.6:$lwjglNatives"
    compile "org.lwjgl.osgi:lwjgl-nanovg:3.1.6:$lwjglNatives"
    compile "org.lwjgl.osgi:lwjgl-nfd:3.1.6:$lwjglNatives"
    compile "org.lwjgl.osgi:lwjgl-nuklear:3.1.6:$lwjglNatives"
    compile "org.lwjgl.osgi:lwjgl-openal:3.1.6:$lwjglNatives"
    compile "org.lwjgl.osgi:lwjgl-opengl:3.1.6:$lwjglNatives"
    compile "org.lwjgl.osgi:lwjgl-opengles:3.1.6:$lwjglNatives"
    compile "org.lwjgl.osgi:lwjgl-openvr:3.1.6:$lwjglNatives"
    compile "org.lwjgl.osgi:lwjgl-ovr:3.1.6:$lwjglNatives"
    compile "org.lwjgl.osgi:lwjgl-par:3.1.6:$lwjglNatives"
    compile "org.lwjgl.osgi:lwjgl-remotery:3.1.6:$lwjglNatives"
    compile "org.lwjgl.osgi:lwjgl-rpmalloc:3.1.6:$lwjglNatives"
    compile "org.lwjgl.osgi:lwjgl-sse:3.1.6:$lwjglNatives"
    compile "org.lwjgl.osgi:lwjgl-stb:3.1.6:$lwjglNatives"
    compile "org.lwjgl.osgi:lwjgl-tinyexr:3.1.6:$lwjglNatives"
    compile "org.lwjgl.osgi:lwjgl-tinyfd:3.1.6:$lwjglNatives"
    compile "org.lwjgl.osgi:lwjgl-tootle:3.1.6:$lwjglNatives"
    compile "org.lwjgl.osgi:lwjgl-xxhash:3.1.6:$lwjglNatives"
    compile "org.lwjgl.osgi:lwjgl-yoga:3.1.6:$lwjglNatives"
    compile "org.lwjgl.osgi:lwjgl-zstd:3.1.6:$lwjglNatives"
    compile "org.joml:joml:1.9.9"
    compile "com.code-disaster.steamworks4j:steamworks4j:1.7.0"
    compile "com.code-disaster.steamworks4j:steamworks4j-server:1.7.0"
    //----------LWJGL END------------//

    compile 'org.codehaus.groovy:groovy-all:2.3.11'
    testCompile group: 'junit', name: 'junit', version: '4.12'
}

I am getting the following errors:

Code: [Select]
Executing task 'assemble'...

:compileJava FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Could not resolve all files for configuration ':compileClasspath'.
> Could not find org.lwjgl.osgi:lwjgl:3.1.6.
  Searched in the following locations:
      https://repo.maven.apache.org/maven2/org/lwjgl/osgi/lwjgl/3.1.6/lwjgl-3.1.6.pom
      https://repo.maven.apache.org/maven2/org/lwjgl/osgi/lwjgl/3.1.6/lwjgl-3.1.6.jar
  Required by:
      project :
> Could not find org.lwjgl.osgi:lwjgl-assimp:3.1.6.
  Searched in the following locations:
      https://repo.maven.apache.org/maven2/org/lwjgl/osgi/lwjgl-assimp/3.1.6/lwjgl-assimp-3.1.6.pom
      https://repo.maven.apache.org/maven2/org/lwjgl/osgi/lwjgl-assimp/3.1.6/lwjgl-assimp-3.1.6.jar
  Required by:
      project :
> Could not find org.lwjgl.osgi:lwjgl-bgfx:3.1.6.
  Searched in the following locations:
      https://repo.maven.apache.org/maven2/org/lwjgl/osgi/lwjgl-bgfx/3.1.6/lwjgl-bgfx-3.1.6.pom
      https://repo.maven.apache.org/maven2/org/lwjgl/osgi/lwjgl-bgfx/3.1.6/lwjgl-bgfx-3.1.6.jar
  Required by:
      project :
> Could not find org.lwjgl.osgi:lwjgl-egl:3.1.6.
  Searched in the following locations:
      https://repo.maven.apache.org/maven2/org/lwjgl/osgi/lwjgl-egl/3.1.6/lwjgl-egl-3.1.6.pom
      https://repo.maven.apache.org/maven2/org/lwjgl/osgi/lwjgl-egl/3.1.6/lwjgl-egl-3.1.6.jar
  Required by:
      project :
> Could not find org.lwjgl.osgi:lwjgl-glfw:3.1.6.
  Searched in the following locations:
      https://repo.maven.apache.org/maven2/org/lwjgl/osgi/lwjgl-glfw/3.1.6/lwjgl-glfw-3.1.6.pom
      https://repo.maven.apache.org/maven2/org/lwjgl/osgi/lwjgl-glfw/3.1.6/lwjgl-glfw-3.1.6.jar
  Required by:
      project :
> Could not find org.lwjgl.osgi:lwjgl-jawt:3.1.6.
  Searched in the following locations:
      https://repo.maven.apache.org/maven2/org/lwjgl/osgi/lwjgl-jawt/3.1.6/lwjgl-jawt-3.1.6.pom
      https://repo.maven.apache.org/maven2/org/lwjgl/osgi/lwjgl-jawt/3.1.6/lwjgl-jawt-3.1.6.jar
  Required by:
      project :
> Could not find org.lwjgl.osgi:lwjgl-jemalloc:3.1.6.
  Searched in the following locations:
      https://repo.maven.apache.org/maven2/org/lwjgl/osgi/lwjgl-jemalloc/3.1.6/lwjgl-jemalloc-3.1.6.pom
      https://repo.maven.apache.org/maven2/org/lwjgl/osgi/lwjgl-jemalloc/3.1.6/lwjgl-jemalloc-3.1.6.jar
  Required by:
      project :
> Could not find org.lwjgl.osgi:lwjgl-lmdb:3.1.6.
  Searched in the following locations:
      https://repo.maven.apache.org/maven2/org/lwjgl/osgi/lwjgl-lmdb/3.1.6/lwjgl-lmdb-3.1.6.pom
      https://repo.maven.apache.org/maven2/org/lwjgl/osgi/lwjgl-lmdb/3.1.6/lwjgl-lmdb-3.1.6.jar
  Required by:
      project :
> Could not find org.lwjgl.osgi:lwjgl-lz4:3.1.6.
  Searched in the following locations:
      https://repo.maven.apache.org/maven2/org/lwjgl/osgi/lwjgl-lz4/3.1.6/lwjgl-lz4-3.1.6.pom
      https://repo.maven.apache.org/maven2/org/lwjgl/osgi/lwjgl-lz4/3.1.6/lwjgl-lz4-3.1.6.jar
  Required by:
      project :
> Could not find org.lwjgl.osgi:lwjgl-nanovg:3.1.6.
  Searched in the following locations:
      https://repo.maven.apache.org/maven2/org/lwjgl/osgi/lwjgl-nanovg/3.1.6/lwjgl-nanovg-3.1.6.pom
      https://repo.maven.apache.org/maven2/org/lwjgl/osgi/lwjgl-nanovg/3.1.6/lwjgl-nanovg-3.1.6.jar
  Required by:
      project :
> Could not find org.lwjgl.osgi:lwjgl-nfd:3.1.6.
  Searched in the following locations:
      https://repo.maven.apache.org/maven2/org/lwjgl/osgi/lwjgl-nfd/3.1.6/lwjgl-nfd-3.1.6.pom
      https://repo.maven.apache.org/maven2/org/lwjgl/osgi/lwjgl-nfd/3.1.6/lwjgl-nfd-3.1.6.jar
  Required by:
      project :
> Could not find org.lwjgl.osgi:lwjgl-nuklear:3.1.6.
  Searched in the following locations:
      https://repo.maven.apache.org/maven2/org/lwjgl/osgi/lwjgl-nuklear/3.1.6/lwjgl-nuklear-3.1.6.pom
      https://repo.maven.apache.org/maven2/org/lwjgl/osgi/lwjgl-nuklear/3.1.6/lwjgl-nuklear-3.1.6.jar
  Required by:
      project :
> Could not find org.lwjgl.osgi:lwjgl-odbc:3.1.6.
  Searched in the following locations:
      https://repo.maven.apache.org/maven2/org/lwjgl/osgi/lwjgl-odbc/3.1.6/lwjgl-odbc-3.1.6.pom
      https://repo.maven.apache.org/maven2/org/lwjgl/osgi/lwjgl-odbc/3.1.6/lwjgl-odbc-3.1.6.jar
  Required by:
      project :
> Could not find org.lwjgl.osgi:lwjgl-openal:3.1.6.
  Searched in the following locations:
      https://repo.maven.apache.org/maven2/org/lwjgl/osgi/lwjgl-openal/3.1.6/lwjgl-openal-3.1.6.pom
      https://repo.maven.apache.org/maven2/org/lwjgl/osgi/lwjgl-openal/3.1.6/lwjgl-openal-3.1.6.jar
  Required by:
      project :
> Could not find org.lwjgl.osgi:lwjgl-opencl:3.1.6.
  Searched in the following locations:
      https://repo.maven.apache.org/maven2/org/lwjgl/osgi/lwjgl-opencl/3.1.6/lwjgl-opencl-3.1.6.pom
      https://repo.maven.apache.org/maven2/org/lwjgl/osgi/lwjgl-opencl/3.1.6/lwjgl-opencl-3.1.6.jar
  Required by:
      project :
> Could not find org.lwjgl.osgi:lwjgl-opengl:3.1.6.
  Searched in the following locations:
      https://repo.maven.apache.org/maven2/org/lwjgl/osgi/lwjgl-opengl/3.1.6/lwjgl-opengl-3.1.6.pom
      https://repo.maven.apache.org/maven2/org/lwjgl/osgi/lwjgl-opengl/3.1.6/lwjgl-opengl-3.1.6.jar
  Required by:
      project :
> Could not find org.lwjgl.osgi:lwjgl-opengles:3.1.6.
  Searched in the following locations:
      https://repo.maven.apache.org/maven2/org/lwjgl/osgi/lwjgl-opengles/3.1.6/lwjgl-opengles-3.1.6.pom
      https://repo.maven.apache.org/maven2/org/lwjgl/osgi/lwjgl-opengles/3.1.6/lwjgl-opengles-3.1.6.jar
  Required by:
      project :
> Could not find org.lwjgl.osgi:lwjgl-openvr:3.1.6.
  Searched in the following locations:
      https://repo.maven.apache.org/maven2/org/lwjgl/osgi/lwjgl-openvr/3.1.6/lwjgl-openvr-3.1.6.pom
      https://repo.maven.apache.org/maven2/org/lwjgl/osgi/lwjgl-openvr/3.1.6/lwjgl-openvr-3.1.6.jar
  Required by:
      project :
> Could not find org.lwjgl.osgi:lwjgl-ovr:3.1.6.
  Searched in the following locations:
      https://repo.maven.apache.org/maven2/org/lwjgl/osgi/lwjgl-ovr/3.1.6/lwjgl-ovr-3.1.6.pom
      https://repo.maven.apache.org/maven2/org/lwjgl/osgi/lwjgl-ovr/3.1.6/lwjgl-ovr-3.1.6.jar
  Required by:
      project :
> Could not find org.lwjgl.osgi:lwjgl-par:3.1.6.
  Searched in the following locations:
      https://repo.maven.apache.org/maven2/org/lwjgl/osgi/lwjgl-par/3.1.6/lwjgl-par-3.1.6.pom
      https://repo.maven.apache.org/maven2/org/lwjgl/osgi/lwjgl-par/3.1.6/lwjgl-par-3.1.6.jar
  Required by:
      project :
> Could not find org.lwjgl.osgi:lwjgl-remotery:3.1.6.
  Searched in the following locations:
      https://repo.maven.apache.org/maven2/org/lwjgl/osgi/lwjgl-remotery/3.1.6/lwjgl-remotery-3.1.6.pom
      https://repo.maven.apache.org/maven2/org/lwjgl/osgi/lwjgl-remotery/3.1.6/lwjgl-remotery-3.1.6.jar
  Required by:
      project :
> Could not find org.lwjgl.osgi:lwjgl-rpmalloc:3.1.6.
  Searched in the following locations:
      https://repo.maven.apache.org/maven2/org/lwjgl/osgi/lwjgl-rpmalloc/3.1.6/lwjgl-rpmalloc-3.1.6.pom
      https://repo.maven.apache.org/maven2/org/lwjgl/osgi/lwjgl-rpmalloc/3.1.6/lwjgl-rpmalloc-3.1.6.jar
  Required by:
      project :
> Could not find org.lwjgl.osgi:lwjgl-sse:3.1.6.
  Searched in the following locations:
      https://repo.maven.apache.org/maven2/org/lwjgl/osgi/lwjgl-sse/3.1.6/lwjgl-sse-3.1.6.pom
      https://repo.maven.apache.org/maven2/org/lwjgl/osgi/lwjgl-sse/3.1.6/lwjgl-sse-3.1.6.jar
  Required by:
      project :
> Could not find org.lwjgl.osgi:lwjgl-stb:3.1.6.
  Searched in the following locations:
      https://repo.maven.apache.org/maven2/org/lwjgl/osgi/lwjgl-stb/3.1.6/lwjgl-stb-3.1.6.pom
      https://repo.maven.apache.org/maven2/org/lwjgl/osgi/lwjgl-stb/3.1.6/lwjgl-stb-3.1.6.jar
  Required by:
      project :
> Could not find org.lwjgl.osgi:lwjgl-tinyexr:3.1.6.
  Searched in the following locations:
      https://repo.maven.apache.org/maven2/org/lwjgl/osgi/lwjgl-tinyexr/3.1.6/lwjgl-tinyexr-3.1.6.pom
      https://repo.maven.apache.org/maven2/org/lwjgl/osgi/lwjgl-tinyexr/3.1.6/lwjgl-tinyexr-3.1.6.jar
  Required by:
      project :
> Could not find org.lwjgl.osgi:lwjgl-tinyfd:3.1.6.
  Searched in the following locations:
      https://repo.maven.apache.org/maven2/org/lwjgl/osgi/lwjgl-tinyfd/3.1.6/lwjgl-tinyfd-3.1.6.pom
      https://repo.maven.apache.org/maven2/org/lwjgl/osgi/lwjgl-tinyfd/3.1.6/lwjgl-tinyfd-3.1.6.jar
  Required by:
      project :
> Could not find org.lwjgl.osgi:lwjgl-tootle:3.1.6.
  Searched in the following locations:
      https://repo.maven.apache.org/maven2/org/lwjgl/osgi/lwjgl-tootle/3.1.6/lwjgl-tootle-3.1.6.pom
      https://repo.maven.apache.org/maven2/org/lwjgl/osgi/lwjgl-tootle/3.1.6/lwjgl-tootle-3.1.6.jar
  Required by:
      project :
> Could not find org.lwjgl.osgi:lwjgl-vulkan:3.1.6.
  Searched in the following locations:
      https://repo.maven.apache.org/maven2/org/lwjgl/osgi/lwjgl-vulkan/3.1.6/lwjgl-vulkan-3.1.6.pom
      https://repo.maven.apache.org/maven2/org/lwjgl/osgi/lwjgl-vulkan/3.1.6/lwjgl-vulkan-3.1.6.jar
  Required by:
      project :
> Could not find org.lwjgl.osgi:lwjgl-xxhash:3.1.6.
  Searched in the following locations:
      https://repo.maven.apache.org/maven2/org/lwjgl/osgi/lwjgl-xxhash/3.1.6/lwjgl-xxhash-3.1.6.pom
      https://repo.maven.apache.org/maven2/org/lwjgl/osgi/lwjgl-xxhash/3.1.6/lwjgl-xxhash-3.1.6.jar
  Required by:
      project :
> Could not find org.lwjgl.osgi:lwjgl-yoga:3.1.6.
  Searched in the following locations:
      https://repo.maven.apache.org/maven2/org/lwjgl/osgi/lwjgl-yoga/3.1.6/lwjgl-yoga-3.1.6.pom
      https://repo.maven.apache.org/maven2/org/lwjgl/osgi/lwjgl-yoga/3.1.6/lwjgl-yoga-3.1.6.jar
  Required by:
      project :
> Could not find org.lwjgl.osgi:lwjgl-zstd:3.1.6.
  Searched in the following locations:
      https://repo.maven.apache.org/maven2/org/lwjgl/osgi/lwjgl-zstd/3.1.6/lwjgl-zstd-3.1.6.pom
      https://repo.maven.apache.org/maven2/org/lwjgl/osgi/lwjgl-zstd/3.1.6/lwjgl-zstd-3.1.6.jar
  Required by:
      project :

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 2s
1 actionable task: 1 executed
Could not find org.lwjgl.osgi:lwjgl:3.1.6.
Searched in the following locations:
    https://repo.maven.apache.org/maven2/org/lwjgl/osgi/lwjgl/3.1.6/lwjgl-3.1.6.pom
    https://repo.maven.apache.org/maven2/org/lwjgl/osgi/lwjgl/3.1.6/lwjgl-3.1.6.jar
Required by:
    project :
3:00:46 PM: Task execution finished 'assemble'.

When I attempt to look at the files, (https://repo.maven.apache.org/maven2/org/lwjgl/osgi/lwjgl/3.1.6/lwjgl-3.1.6.jar) I get a 404.

When I attempt to look at the files through the browser (https://www.lwjgl.org/browse) I get a 500 error.

It seems the whole https://repo.maven.apache.org/maven2/org/lwjgl/osgi/lwjgl directory is missing, since I can access https://repo.maven.apache.org/maven2/org/lwjgl/osgi and all the subdirectories, but not the /osgi/ directory.

Am I doing something wrong here?  My gradle build fails, and I can't seem to find the files to manually include in the IntelliJ project.  My HelloWorld.java file I copied from the github is not linking the required dependencies.

7
Oh?

How do we protect own game? - who want sell or share nice lwjgl games on Steam, Origin or other Game-Managers and hackers are happy to decompile java classes and they are spying to own game. If game has connection with store like coins, cashes or assets for game like FarmVile or  Samuari Siege etc..

Please respect to us! We love protector Excelsior Jet 15.x because hackers can't decompile it.

Please give chance with lwjgl 3.x!
8
Thanks I have moved glClearColor() to in method open() after shell.open()

It works thanks!

I am really excited to Java programming because I know much about Java. Because C# is very poor and has not more features. Thanks ! I will continue my development
9
Simply do not reset the clear color in line 141 in the draw() method: glClearColor(1.0f, 0.0f, 0.0f, 0.0f);
10
This is quote from old thread:
You can use multiple canvases. Just set the current cavas to be the current gl contex before you draw each one like so:


Code: [Select]
package com.tscribble.game.examples.swtopengl;

import static org.lwjgl.opengl.GL11.*;

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.*;

import com.tscribble.game.opengl.swt.GLComposite2D;

/**
 * @author triston
 *
 */
public class SWTMultiComposite {

private Display display;
private GLComposite2D canvas,canvas2;
private float ang,ang2 = 0;

public static void main(String[] args) {
SWTMultiComposite window = new SWTMultiComposite();
window.open();
}

public void open() {
display = Display.getDefault();
Shell shell = new Shell();
shell.setSize(1024, 600);
shell.setText("SWT GL Mutiple Composites");
shell.setLayout(new FillLayout(SWT.HORIZONTAL));

Menu mBar = new Menu(shell, SWT.BAR);
shell.setMenuBar(mBar);

MenuItem fileItem = new MenuItem(mBar, SWT.CASCADE);
fileItem.setText("File");

Menu fileMenu = new Menu(fileItem);
fileItem.setMenu(fileMenu);

for (int i = 0; i < 5; i++) {
final MenuItem importItem = new MenuItem(fileMenu, SWT.NONE);
importItem.setText("Item " + i);
}

canvas = new GLComposite2D(shell);
canvas.addListener(SWT.Resize, new Listener() {
public void handleEvent(Event event) {
doResize(canvas);
}});

canvas2 = new GLComposite2D(shell);
canvas2.addListener(SWT.Resize, new Listener() {
public void handleEvent(Event event) {
doResize(canvas2);
}});

shell.open();
start(); // render loop thread

while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
protected void initGL() {
glShadeModel(GL_SMOOTH); // Enable Smooth Shading, GL_SMOOTH (the default) or GL_FLAT.
}

private void doResize(GLComposite2D comp) {
Rectangle rec = comp.getBounds();
float w = Math.max(rec.width, 1);
float h = Math.max(rec.height, 1);

comp.makeCurrent();

glViewport(0, 0, (int) w, (int) h);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();

glOrtho(0, w, h, 0, 1, -1);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}

public void start() {
display.syncExec(new Runnable() {
public void run() {
if (!canvas.isDisposed() || !canvas2.isDisposed()) {
try {Thread.sleep(10);}catch (InterruptedException e){}
logic();
logic2();

canvas.makeCurrent();
draw();

canvas2.makeCurrent();
draw2();

canvas.swapBuffers();
canvas2.swapBuffers();

display.asyncExec(this);
}
}
});
}

public void logic() {
ang += 0.5f % 360;
}

public void logic2() {
ang2 -= 0.5f % 360;
}

private void draw() {
glClear(GL_COLOR_BUFFER_BIT);
glClearColor(1.0f, 0.0f, 0.0f, 0.0f);  // Red Background

glPushMatrix();
{
glTranslatef(10, 10, 0);
glBegin(GL_TRIANGLES);
glColor3f(1.0f, 0.0f, 0.0f); // red
glVertex2f(5.0f, 5.0f);

glColor3f(0.0f, 1.0f, 0.0f); // green
glVertex2f(400.0f, 5.0f);

glColor3f(0.0f, 0.0f, 1.0f); // blue
glVertex2f(5.0f, 400.0f);
glEnd();
}
glPopMatrix();
}

private void draw2() {
glClear(GL_COLOR_BUFFER_BIT);
glClearColor(0.0f, 0.0f, 1.0f, 0.0f);  // Blue Background

glPushMatrix();
{
glTranslatef(10, 10, 0);
glBegin(GL_TRIANGLES);
glColor3f(1.0f, 0.0f, 0.0f); // red
glVertex2f(5.0f, 5.0f);
glColor3f(0.0f, 1.0f, 0.0f); // green
glVertex2f(100.0f, 5.0f);
glColor3f(0.0f, 0.0f, 1.0f); // blue
glVertex2f(5.0f, 100.0f);
glEnd();
}
glPopMatrix();
}

}

The GLComposite
Code: [Select]
package com.tscribble.game.opengl.swt;

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.opengl.GLCanvas;
import org.eclipse.swt.opengl.GLData;
import org.eclipse.swt.widgets.*;
import org.lwjgl.LWJGLException;

import org.lwjgl.opengl.*;

/**
 * @author triston
 */
public class GLComposite2D extends GLCanvas {
private static GLData gd1;
protected Rectangle rec;

static {
gd1 = new GLData();
gd1.doubleBuffer = true;
}

public GLComposite2D(Composite parent) {
super(parent, SWT.NONE, gd1);
}

public void makeCurrent() {
setCurrent();
try {
GLContext.useContext(this);
} catch (LWJGLException e) {
e.printStackTrace();
}
}
}

hope that helps

I am sorry - It is not spam just I want continue that because Excelsior works with lwjgl 2.9.3 + swt 4.7.2 fine

And I want know how do I change color of glClearColor()

I have problem with changing color - I have tested with lwjgl 3.1 = no problem with changing color of background's glClearColor()
But how does it work for lwjgl 2.9.3?

Because I really want create powerful program alternative to Xenko GameStudio, Unity3D, MonoGame or WaveEngine. Because I feel sad that C# coders don't believe that because Java is really richer than C# because Java has a lot of features like toRadiant() from Math class, FloatBuffer() etc..

I really want know how does color change of glClearColor() by clicking

Here is code:
Code: [Select]
import static org.lwjgl.opengl.GL11.*;
 
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.*;
 
/**
 * @author triston
 *
 */
public class SwtDemo {
 
    private Display display;
    private GLComposite2D canvas;
     
    public static void main(String[] args) {
    SwtDemo window = new SwtDemo();
        window.open();
    }
 
    public void open() {
        display = Display.getDefault();
        Shell shell = new Shell();
        shell.setSize(1024, 600);
        shell.setText("SWT GL Changing color for background");
        shell.setLayout(new FillLayout(SWT.HORIZONTAL));
         
        Menu menubar = new Menu(shell, SWT.BAR);

MenuItem fileItem = new MenuItem(menubar, SWT.CASCADE);
fileItem.setText("File");

Menu fileMenu = new Menu(fileItem);
fileItem.setMenu(fileMenu);

MenuItem exitItem = new MenuItem(fileMenu, SWT.NONE);
exitItem.setText("Exit");

exitItem.addListener(SWT.Selection, event-> {
            shell.getDisplay().dispose();
            System.exit(0);
        });

MenuItem setupItem = new MenuItem(menubar, SWT.CASCADE);
setupItem.setText("Setup");

Menu setupMenu = new Menu(setupItem);
setupItem.setMenu(setupMenu);

MenuItem changebackgroundItem = new MenuItem(setupMenu, SWT.NONE);
changebackgroundItem.setText("Change background");

new MenuItem(setupMenu, SWT.SEPARATOR);

MenuItem defaultColorForBackgroundItem = new MenuItem(setupMenu, SWT.NONE);
defaultColorForBackgroundItem.setText("Default background color");

changebackgroundItem.addListener(SWT.Selection, event-> {
        ColorDialog dialog = new ColorDialog(shell);
RGB rgb = dialog.open();
       
if(rgb != null)
{
            Color col = new Color(shell.getDisplay(), rgb);
            glClearColor(col.getRed()/255.0f, col.getGreen()/255.0f, col.getBlue()/255.0f, 1.0f);
            col.dispose();
}
});
       
        defaultColorForBackgroundItem.addListener(SWT.Selection, event-> {
glClearColor(1.0f, 0.0f, 0.0f, 0.0f);
});

shell.setMenuBar(menubar);
         
        canvas = new GLComposite2D(shell); 
        canvas.addListener(SWT.Resize, new Listener() {
            public void handleEvent(Event event) {             
                doResize(canvas);
        }});     
 
        shell.open();
       
       
        display.syncExec(new Runnable() {
            public void run() {   
           
                if (!canvas.isDisposed()) {                   
                    logic();
                     
                    canvas.makeCurrent();
                    draw();         
                     
                    canvas.swapBuffers();
                     
                    display.asyncExec(this);
                }
            }
        });
 
        while (!shell.isDisposed()) {
            if (!display.readAndDispatch()) {
                display.sleep();
            }
        }
        display.dispose();
    }
    protected void initGL() {       
        glShadeModel(GL_SMOOTH); // Enable Smooth Shading, GL_SMOOTH (the default) or GL_FLAT.
    }
 
    private void doResize(GLComposite2D comp) {
        Rectangle rec = comp.getBounds();
        float w = Math.max(rec.width, 1);
        float h = Math.max(rec.height, 1);
         
        comp.makeCurrent();
 
        glViewport(0, 0, (int) w, (int) h);
 
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
 
        glOrtho(0, w, h, 0, 1, -1);
 
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
    }
 
    @SuppressWarnings("unused")
public void logic() {
    int ans = 0;
    ans += 0.5f % 360;
    }
 
    private void draw() {
        glClear(GL_COLOR_BUFFER_BIT);
        glClearColor(1.0f, 0.0f, 0.0f, 0.0f);
 
        glPushMatrix();
        {
            glTranslatef(10, 10, 0);
            glBegin(GL_TRIANGLES);
            glColor3f(1.0f, 0.0f, 0.0f); // red
            glVertex2f(5.0f, 5.0f);
             
            glColor3f(0.0f, 1.0f, 0.0f); // green
            glVertex2f(400.0f, 5.0f);
             
            glColor3f(0.0f, 0.0f, 1.0f); // blue
            glVertex2f(5.0f, 400.0f);
            glEnd();
        }
        glPopMatrix();
    }         
}

How do I get working with lwjgl 2.9.3?

Thanks!
Pages: [1] 2 3 ... 10