summaryrefslogtreecommitdiffstats
path: root/src/com/jogamp/opencl/demos/info/CLInfo.java
blob: 85edc0fce543427a558cf1b9759c31244173910e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
 * Created on Tuesday, September 07 2010 21:33
 */

package com.jogamp.opencl.demos.info;

import com.jogamp.common.JogampRuntimeException;
import com.jogamp.opencl.CLPlatform;
import com.jogamp.opencl.JoclVersion;
import com.jogamp.opencl.util.ExceptionReporter;
import java.awt.Container;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.UIManager;

/**
 * Displays OpenCL information in a table.
 * @author Michael Bien
 */
public class CLInfo {

    public static void main(String[] args) {

        Logger logger = Logger.getLogger(CLInfo.class.getName());

        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (Exception ex) {
            logger.log(Level.INFO, null, ex);
        }

        final JoclVersion joclVersion = JoclVersion.getInstance();
        logger.info("\n" + joclVersion.getAllVersions(null).toString());

        try{
            CLPlatform.initialize();
        }catch(JogampRuntimeException ex) {
            logger.log(Level.SEVERE, null, ex);
            ExceptionReporter.appear("I tried hard but I really can't initialize JOCL. Is OpenCL properly set up?", ex);
            return;
        }

        JFrame frame = new JFrame("OpenCL Info");
        frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        Container contentPane = frame.getContentPane();

        JEditorPane area = new JEditorPane();
        area.setContentType("text/html");
        area.setEditable(false);

        contentPane.add(new JScrollPane(area));

        area.setText(joclVersion.getOpenCLHtmlInfo(null).toString());

        frame.setSize(800, 600);
        frame.setVisible(true);

    }

}