i am trying to render images and text to screen, all configured to be at 0,0 but this is the results
and this is my code: public class Main implements GLEventListener { private TextRenderer textRenderer; private static final int WIN_WIDTH = 600; private static final int WIN_HEIGHT = 400; public static void main(String[] args) { JFrame frame = new JFrame("JOGL Application"); GLProfile profile = GLProfile.getDefault(); GLCapabilities capabilities = new GLCapabilities(profile); GLCanvas canvas = new GLCanvas(capabilities); Main mainInstance = new Main(); canvas.addGLEventListener(mainInstance); frame.getContentPane().add(canvas); frame.setSize(WIN_WIDTH, WIN_HEIGHT); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } @Override public void init(GLAutoDrawable drawable) { textRenderer = new TextRenderer(new java.awt.Font("Arial", java.awt.Font.BOLD, 12)); textRenderer.setColor(1.0f, 1.0f, 1.0f, 1.0f); // White color } @Override public void display(GLAutoDrawable drawable) { GL2 gl = drawable.getGL().getGL2(); // Clear the color buffer with a black background gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f); gl.glClear(GL2.GL_COLOR_BUFFER_BIT); // Enable blending for transparency gl.glEnable(GL2.GL_BLEND); gl.glBlendFunc(GL2.GL_SRC_ALPHA, GL2.GL_ONE_MINUS_SRC_ALPHA); // Set up the orthographic projection matrix gl.glMatrixMode(GL2.GL_PROJECTION); gl.glLoadIdentity(); gl.glOrtho(0, drawable.getSurfaceWidth(), drawable.getSurfaceHeight(), 0, -1, 1); // Switch back to the modelview matrix gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glLoadIdentity(); // Render the sprite using SpriteRenderer.renderSprite method SpriteRenderer.renderSprite(Assets.image, gl, drawable, 0, 0, 64, 64); } @Override public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { // Unused } @Override public void dispose(GLAutoDrawable drawable) { // Unused } } it worked once, but then i upgraded my jogl version and this bug started |
Administrator
|
Hello
Please provide a SSCCE and indicate which versions of JOGL you use (i.e before and after observing a possible regression).
Julien Gouesse | Personal blog | Website
|
Hi
this is the SSCCE: package main; import javax.swing.JFrame; import com.jogamp.opengl.GL2; import com.jogamp.opengl.GLAutoDrawable; import com.jogamp.opengl.GLCapabilities; import com.jogamp.opengl.GLEventListener; import com.jogamp.opengl.GLProfile; import com.jogamp.opengl.awt.GLCanvas; public class MVP implements GLEventListener { private static final int WIN_WIDTH = 600; private static final int WIN_HEIGHT = 400; public static void main(String[] args) { JFrame frame = new JFrame("JOGL Application"); GLProfile profile = GLProfile.getDefault(); GLCapabilities capabilities = new GLCapabilities(profile); GLCanvas canvas = new GLCanvas(capabilities); MVP mainInstance = new MVP(); canvas.addGLEventListener(mainInstance); frame.getContentPane().add(canvas); frame.setSize(WIN_WIDTH, WIN_HEIGHT); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } @Override public void init(GLAutoDrawable drawable) { } @Override public void display(GLAutoDrawable drawable) { GL2 gl = drawable.getGL().getGL2(); gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f); gl.glClear(GL2.GL_COLOR_BUFFER_BIT); gl.glMatrixMode(GL2.GL_PROJECTION); gl.glLoadIdentity(); gl.glOrtho(0, drawable.getSurfaceWidth(), drawable.getSurfaceHeight(), 0, -1, 1); gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glLoadIdentity(); gl.glBegin(GL2.GL_QUADS); gl.glColor3f(1.0f, 0.0f, 0.0f); // Set color to red gl.glVertex2f(0, 0); // Bottom-left corner gl.glVertex2f(32, 0); // Bottom-right corner gl.glVertex2f(32, 32); // Top-right corner gl.glVertex2f(0, 32); // Top-left corner gl.glEnd(); gl.glFlush(); } @Override public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { // Unused } @Override public void dispose(GLAutoDrawable drawable) { // Unused } } About the versions: - i am currently use maven, this is the dependcy: <groupId>org.jogamp.jogl</groupId> <artifactId>jogl-all</artifactId> <version>2.3.2</version> - i was using a jar file before, which i cant find, but it was a way older version |
Administrator
|
You can use a more recent version with Maven but without Maven Central:
https://jogamp.org/cgit/jogl-demos.git/tree/maven/trivial-test/pom.xml https://jogamp.org/wiki/index.php?title=Maven#The_jogamp.org_test_repository https://jogamp.org/deployment/maven/org/jogamp/jogl/jogl-all-main/2.5.0/
Julien Gouesse | Personal blog | Website
|
Thank you very much, it worked perfactly
|
Administrator
|
Thank you for the feedback.
Julien Gouesse | Personal blog | Website
|
Free forum by Nabble | Edit this page |