Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7965265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T06:06:10+00:00 2026-06-04T06:06:10+00:00

I have just started studying JOGL and there is one problem. Below is simple

  • 0

I have just started studying JOGL and there is one problem.

Below is simple implementation of two methods of GLEventListener.

@Override
public void init(GLDrawable glDrawable) {

    GL gl = glDrawable.getGL();
    GLU glu = glDrawable.getGLU();

    gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);

    glu.gluOrtho2D(0.0, 600.0, 0.0, 500.0);

}

@Override
public void display(GLDrawable glDrawable) {

    GL gl = glDrawable.getGL();
    gl.glPointSize(100.0f);

    gl.glColor3f(0.0f, 1.0f, 0.0f);
    gl.glBegin(GL.GL_POINTS);
    gl.glVertex2i(300, 250);
    gl.glEnd();

    gl.glEnd();

}

That is how I insert component in JFrame window.

package scribble;

import net.java.games.jogl.GLCanvas;
import net.java.games.jogl.GLCapabilities;
import net.java.games.jogl.GLDrawableFactory;
import javax.swing.*;
import java.awt.*;

public class ScribbleComponent extends JFrame {

    public static void main(String[] args) {
        ScribbleComponent component = new ScribbleComponent();
        ScribbleRunnable runnable = new ScribbleRunnable(component);
        SwingUtilities.invokeLater(runnable);
    }

    public ScribbleComponent() {
        super("Scribble");
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        GLCapabilities glCapabilities = new GLCapabilities();
        GLCanvas glCanvas = GLDrawableFactory.getFactory().createGLCanvas(glCapabilities);
        glCanvas.addGLEventListener(new ScribbleListener());
        getContentPane().add(glCanvas, BorderLayout.CENTER);
        getContentPane().add(new JButton("Clear Screen"), BorderLayout.SOUTH);
        setSize(600, 500);
        ScribbleHelper.centerWindow(this);
    }

}

ScribbleRunnable(component) makes component visible.

ScribbleHelper.centerWindow(this) just centering of the JFrame window.

I expect to see green square on white background.

It works correctly on the first computer, but on the second I am getting dark red square on black background. That happens always, I can not set any other colors.

Both computers are running Windows 7, using JDK 1.6 and the same libs.

Where could be the problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T06:06:12+00:00Added an answer on June 4, 2026 at 6:06 am

    You should implement an com.jogamp.opengl.util.FPSAnimator to constantly update you display() method. Then have a look at it.

    Also use gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT); to keep you display clean.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just started studying Objective - C..and I encountered a problem which I
I have just started working with nodejs. I wonder if there is a way
I have just started learning asp.net mvc and one reason of the primary reasons
I have just started studying Python . I am referring to the tutorials at
I have just started studying Android and I am still lost. I would just
I have just started studying Android, I have limited java knowledge but am semi
I have just started using vc++ 2008. I just want to see one message
I have just started self-studying the Dragon book of Compiler Design. I am working
I have just started studying OOP and I am a little confused of the
I just started studying programming about 6 months ago and I have really been

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.