From f8a7aa53470089c0d2a3a1b5fe61deed2a785b35 Mon Sep 17 00:00:00 2001 From: cvs2svn Date: Fri, 25 Jun 2004 15:37:05 +0000 Subject: This commit was manufactured by cvs2svn to create branch 'R3_0_maintenance'. Sprout from master 2004-06-25 15:37:02 UTC Carolyn MacLeod 'fix line delimiters' Delete: bundles/org.eclipse.swt.opengl/common/gl_library/gl.c bundles/org.eclipse.swt.opengl/common/gl_library/glu.c bundles/org.eclipse.swt.opengl/common/gl_library/swt.h bundles/org.eclipse.swt.opengl/common/org/eclipse/swt/opengl/GL.java bundles/org.eclipse.swt.opengl/common/org/eclipse/swt/opengl/GLU.java bundles/org.eclipse.swt.opengl/common/org/eclipse/swt/opengl/GLYPHMETRICSFLOAT.java bundles/org.eclipse.swt.opengl/gtk/gl_library/build.sh bundles/org.eclipse.swt.opengl/gtk/gl_library/glx.c bundles/org.eclipse.swt.opengl/gtk/gl_library/make_gtk.mak bundles/org.eclipse.swt.opengl/gtk/gl_library/structs.c bundles/org.eclipse.swt.opengl/gtk/gl_library/structs.h bundles/org.eclipse.swt.opengl/gtk/gl_library/xgtk.c bundles/org.eclipse.swt.opengl/gtk/org/eclipse/swt/opengl/GLContext.java bundles/org.eclipse.swt.opengl/gtk/org/eclipse/swt/opengl/internal/gtk/XGL.java bundles/org.eclipse.swt.opengl/gtk/org/eclipse/swt/opengl/internal/gtk/XGTK.java bundles/org.eclipse.swt.opengl/gtk/org/eclipse/swt/opengl/internal/gtk/XVisualInfo.java bundles/org.eclipse.swt.opengl/motif/gl_library/build.csh bundles/org.eclipse.swt.opengl/motif/gl_library/glx.c bundles/org.eclipse.swt.opengl/motif/gl_library/make_aix.mak bundles/org.eclipse.swt.opengl/motif/gl_library/make_hpux.mak bundles/org.eclipse.swt.opengl/motif/gl_library/make_linux.mak bundles/org.eclipse.swt.opengl/motif/gl_library/make_solaris.mak bundles/org.eclipse.swt.opengl/motif/gl_library/structs.c bundles/org.eclipse.swt.opengl/motif/gl_library/structs.h bundles/org.eclipse.swt.opengl/win32/gl_library/build.bat bundles/org.eclipse.swt.opengl/win32/gl_library/glw.c bundles/org.eclipse.swt.opengl/win32/gl_library/make_win32.mak bundles/org.eclipse.swt.opengl/win32/gl_library/structs.c bundles/org.eclipse.swt.opengl/win32/gl_library/structs.h bundles/org.eclipse.swt.opengl/win32/gl_library/swt.rc bundles/org.eclipse.swt.opengl/win32/org/eclipse/swt/opengl/GLContext.java bundles/org.eclipse.swt.opengl/win32/org/eclipse/swt/opengl/internal/win32/POINTFLOAT.java examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/BezierTab.java examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/BitmapTextTab.java examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/OutlineTextTab.java examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/SelectionTab.java--- .../org/eclipse/swt/opengl/examples/BezierTab.java | 211 ----------------- .../eclipse/swt/opengl/examples/BitmapTextTab.java | 203 ----------------- .../swt/opengl/examples/OutlineTextTab.java | 251 --------------------- .../eclipse/swt/opengl/examples/SelectionTab.java | 57 ----- 4 files changed, 722 deletions(-) delete mode 100644 examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/BezierTab.java delete mode 100644 examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/BitmapTextTab.java delete mode 100644 examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/OutlineTextTab.java delete mode 100644 examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/SelectionTab.java (limited to 'examples') diff --git a/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/BezierTab.java b/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/BezierTab.java deleted file mode 100644 index e66b8414c8..0000000000 --- a/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/BezierTab.java +++ /dev/null @@ -1,211 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.swt.opengl.examples; - - -import org.eclipse.swt.*; -import org.eclipse.swt.events.*; -import org.eclipse.swt.graphics.*; -import org.eclipse.swt.opengl.*; -import org.eclipse.swt.widgets.*; - -class BezierTab extends SelectionTab { - private boolean showCtrlPoints = true; - private Point offset; - private int currentPoint = -1; - private int lineDivisions = 30; - private double[][] ctrlPts = { - { 1.5, 0.5, 0.0, 0.6, 0.9, 0.0, 0.85, 0.12, - 0.0, 1.1, 1.0, 0.0, 0.53, 1.4, 0.0 - }, - { 0.53, 1.4, 0.0, 1.03, 1.87, 0.0, 1.52, 0.26, - 0.0, 1.86, 0.43, 0.0, 1.5, 0.5, 0.0 - } - }; - private static final int LENGTH = 5; - private static final int[][] PICK_NAMES = { - { 1, 2, 3, 4, 5 }, - { 6, 7, 8, 9, 10 } - }; - - /** - * @see OpenGLTab#createControls(Composite) - */ - void createControls(Composite composite) { - new Label(composite, SWT.NONE).setText("Click and drag points to adjust shape."); - new Label(composite, SWT.NONE).setText("Line division count:"); - final Slider divisions = new Slider(composite, SWT.NONE); - divisions.setIncrement(1); - divisions.setMaximum(52); - divisions.setMinimum(1); - divisions.setThumb(2); - divisions.setPageIncrement(2); - divisions.setSelection(30); - divisions.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event e) { - lineDivisions = divisions.getSelection(); - } - }); - - final Button showPointsButton = new Button(composite, SWT.CHECK); - showPointsButton.setText("Show Points"); - showPointsButton.setSelection(true); - showPointsButton.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event e) { - showCtrlPoints = showPointsButton.getSelection(); - } - }); - - final Button blendButton = new Button(composite, SWT.CHECK); - blendButton.setText("Blend"); - blendButton.setSelection(true); - blendButton.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event e) { - if (blendButton.getSelection()) { - GL.glEnable(GL.GL_BLEND); - } else { - GL.glDisable(GL.GL_BLEND); - } - } - }); - - final Button smoothLineButton = new Button(composite, SWT.CHECK); - smoothLineButton.setText("Smooth Line"); - smoothLineButton.setSelection(true); - smoothLineButton.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event e) { - if (smoothLineButton.getSelection()) { - GL.glEnable(GL.GL_LINE_SMOOTH); - } else { - GL.glDisable(GL.GL_LINE_SMOOTH); - } - } - }); - - final Canvas glCanvas = getGlCanvas(); - glCanvas.addMouseListener(new MouseAdapter() { - public void mouseUp(MouseEvent e) { - offset = null; - } - - }); - - glCanvas.addListener(SWT.MouseDown, new Listener() { - public void handleEvent(Event e) { - e.y = glCanvas.getClientArea().height - e.y; - if (e.button == 1) { - if (processSelection(e.x, e.y, 10) > 0) { - offset = new Point(e.x, e.y); - } else { - currentPoint = 0; - } - } - } - }); - - glCanvas.addListener(SWT.MouseMove, new Listener() { - public void handleEvent(Event e) { - if (offset == null) return; - int currentSegment = (currentPoint - 1) / LENGTH; - int current = (currentPoint - 1) * 3; - if (currentPoint > LENGTH) { - current = (currentPoint - 6) * 3; - } - Rectangle rect = glCanvas.getClientArea(); - e.y = rect.height - e.y; - if (0 < e.x && e.x < rect.width && 0 < e.y && e.y < rect.height && currentPoint > 0) { - ctrlPts[currentSegment][current] = (float) e.x / (float) 200; - ctrlPts[currentSegment][current + 1] = (float) e.y / (float) 200; - switch (currentPoint) { - case 10 : - ctrlPts[0][0] = (float) e.x / (float) 200; - ctrlPts[0][1] = (float) e.y / (float) 200; - break; - case 6 : - ctrlPts[0][12] = (float) e.x / (float) 200; - ctrlPts[0][13] = (float) e.y / (float) 200; - break; - } - } - } - }); - } - - /** - * @see OpenGLTab#getTabText() - */ - String getTabText() { - return "Bezier"; - } - - /** - * @see OpenGLTab#init() - */ - void init() { - GL.glClearColor(1.0f, 1.0f, 1.0f, 1.0f); - GL.glHint(GL.GL_LINE_SMOOTH_HINT, GL.GL_NICEST); - GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); - GL.glPointSize(7.0f); - GL.glLineWidth(4.0f); - - GL.glEnable(GL.GL_AUTO_NORMAL); - GL.glEnable(GL.GL_MAP1_VERTEX_3); - GL.glEnable(GL.GL_LINE_SMOOTH); - GL.glEnable(GL.GL_BLEND); - } - - /** - * @see SelectionTab.processPick (int[], int) - */ - void processPick(int[] pSelectBuff, int hits) { - int counter = 0; - currentPoint = 0; - for (int i = 0; i < hits; i++) { - int count = pSelectBuff[counter]; - counter += 3; - for (int j = 0; j < count; j++) { - currentPoint = pSelectBuff[counter]; - counter++; - } - } - } - - /** - * @see OpenGLTab#renderScene() - */ - void renderScene() { - GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); - GL.glLoadIdentity(); - GL.glTranslatef(-1.0f, -1.0f, -2.45f); - GL.glColor3f(0.0f, 0.0f, 1.0f); - for (int i = 0; i < ctrlPts.length; i++) { - GL.glMapGrid1d(lineDivisions, 0.0f, 1f); - GL.glMap1d(GL.GL_MAP1_VERTEX_3, 0, 1, 3, LENGTH, ctrlPts[i]); - GL.glEvalMesh1(GL.GL_LINE, 0, lineDivisions); - } - if (showCtrlPoints) { - GL.glPushName(0); - for (int j = 0; j < ctrlPts.length; j++) { - for (int i = 0; i < LENGTH * 3; i += 3) { - GL.glLoadName(PICK_NAMES[j][i / 3]); - GL.glBegin(GL.GL_POINTS); - if (PICK_NAMES[j][i / 3] == currentPoint) { - GL.glColor3f(1.0f, 0.0f, 0.0f); - } else { - GL.glColor3f(0.0f, 0.0f, 0.0f); - } - GL.glVertex3d(ctrlPts[j][i], ctrlPts[j][i + 1], ctrlPts[j][i + 2]); - GL.glEnd(); - } - } - } - } -} diff --git a/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/BitmapTextTab.java b/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/BitmapTextTab.java deleted file mode 100644 index 084f45a213..0000000000 --- a/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/BitmapTextTab.java +++ /dev/null @@ -1,203 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.swt.opengl.examples; - - -import org.eclipse.swt.*; -import org.eclipse.swt.graphics.*; -import org.eclipse.swt.layout.*; -import org.eclipse.swt.opengl.*; -import org.eclipse.swt.widgets.*; - -class BitmapTextTab extends OpenGLTab { - private Text messageText; - private FontData fontData; - private float[] textColor = { 1.0f, 0.0f, 0.0f }; - private float xPos = -130.0f, yPos = 0.0f; - private int listIndexBase; - private final static int LIST_INDEX_SIZE = 256; - private final static int DEFAULT_FONT_SIZE = 24; - private final static String DEFAULT_FONT_NAME = "Courier"; - - /** - * @see OpenGLTab#createControls(Composite) - */ - void createControls(Composite composite) { - Group movementGroup = new Group(composite, SWT.NONE); - movementGroup.setText("Translation"); - movementGroup.setLayout(new GridLayout(2, false)); - - new Label(movementGroup, SWT.NONE).setText("X:"); - final Slider xMove = new Slider(movementGroup, SWT.NONE); - xMove.setIncrement(1); - xMove.setMaximum(42); - xMove.setMinimum(0); - xMove.setThumb(2); - xMove.setPageIncrement(2); - xMove.setSelection(7); - xMove.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event e) { - xPos = (xMove.getSelection() * 10) - 200; - } - }); - - new Label(movementGroup, SWT.NONE).setText("Y:"); - final Slider yMove = new Slider(movementGroup, SWT.NONE); - yMove.setIncrement(1); - yMove.setMaximum(42); - yMove.setMinimum(0); - yMove.setThumb(2); - yMove.setPageIncrement(2); - yMove.setSelection(20); - yMove.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event e) { - yPos = (yMove.getSelection() * 10) - 200; - } - }); - - Composite textGroup = new Composite(composite,SWT.NONE); - GridLayout layout = new GridLayout(2,false); - layout.marginHeight = 0; - layout.marginWidth = 0; - textGroup.setLayout(layout); - textGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); - - new Label(textGroup, SWT.NONE).setText("Text:"); - messageText = new Text(textGroup, SWT.BORDER); - GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); - data.grabExcessHorizontalSpace = true; - messageText.setLayoutData(data); - messageText.setText("OpenGL - SWT"); - - final Button fontSelectButton = new Button(composite, SWT.NONE); - fontSelectButton.setText("Set Font"); - - final ColorSelectionGroup colorGroup = - new ColorSelectionGroup(composite, SWT.NONE); - colorGroup.setText("Text color"); - colorGroup.addColorSelectionListener(new IColorSelectionListener() { - public void handleColorSelection(RGB rgb) { - GL.glColor3ub((byte) rgb.red, (byte) rgb.green, (byte) rgb.blue); - } - }); - - fontSelectButton.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event e) { - FontDialog fontDialog = new FontDialog(fontSelectButton.getShell()); - fontDialog.setText("Choose Font Options"); - double[] currentColor = new double[4]; - GL.glGetDoublev(GL.GL_CURRENT_COLOR, currentColor); - fontDialog.setRGB( - new RGB( - (int) currentColor[0] * 255, - (int) currentColor[1] * 255, - (int) currentColor[2] * 255)); - fontDialog.setFontData(fontData); - FontData result = fontDialog.open(); - if (result != null) { - fontData = result; - RGB rgb = fontDialog.getRGB(); - GL.glColor3ub((byte) rgb.red, (byte) rgb.green, (byte) rgb.blue); - colorGroup.setRGB(rgb); - getContext().loadBitmapFont(fontData, null, listIndexBase, 32, 96); - } - } - }); - } - - /** - * @see OpenGLTab#dispose() - */ - void dispose() { - super.dispose(); - GL.glDeleteLists(listIndexBase, LIST_INDEX_SIZE); - } - - /** - * Draws the text to the screen - * - * @param string the text to draw - */ - void drawText(String string) { - char[] stringChars = string.toCharArray(); - int[] text = new int[stringChars.length]; - for (int i = 0; i < text.length; i++) { - text[i] = (int) stringChars[i]; - } - // pushes the display list bits - GL.glPushAttrib(GL.GL_LIST_BIT); - // sets the base character to 32 - GL.glListBase(listIndexBase - 32); - GL.glCallLists(text.length, GL.GL_UNSIGNED_INT, text); - // pops the display list bits - GL.glPopAttrib(); - } - - /** - * @see OpenGLTab#getTabText() - */ - String getTabText() { - return "Bitmap Text"; - } - - /** - * @see OpenGLTab#init() - */ - void init() { - GL.glClearColor(1.0f, 1.0f, 1.0f, 1.0f); - GL.glColor3fv(textColor); - GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); - GL.glEnable(GL.GL_DEPTH_TEST); - GL.glEnable(GL.GL_BLEND); - // build the initial font - listIndexBase = GL.glGenLists(LIST_INDEX_SIZE); - fontData = new FontData(); - fontData.setHeight(DEFAULT_FONT_SIZE); - fontData.setName(DEFAULT_FONT_NAME); - getContext().loadBitmapFont(fontData, null, listIndexBase, 32, LIST_INDEX_SIZE); - } - - /** - * @see OpenGLTab#renderScene() - */ - void renderScene() { - GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); - GL.glLoadIdentity(); - GL.glRasterPos2f(xPos, yPos); - drawText(messageText.getText()); - } - - /** - * @see OpenGLTab#setupViewingArea() - */ - void setupViewingArea() { - // use ortho view since this tab does not need any depth - Rectangle rect = getGlCanvas().getClientArea(); - int width = rect.width; - int height = rect.height; - width = Math.max(width, 1); - GL.glViewport(0, 0, width, height); - float nRange = 200.0f; - GL.glMatrixMode(GL.GL_PROJECTION); - GL.glLoadIdentity(); - if (width <= height) { - GL.glOrtho( - -nRange, nRange, -nRange * height / width, - nRange * height / width, -nRange, nRange); - } else { - GL.glOrtho( - -nRange * height / width, nRange * height / width, -nRange, - nRange, -nRange, nRange); - } - GL.glMatrixMode(GL.GL_MODELVIEW); - GL.glLoadIdentity(); - } -} diff --git a/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/OutlineTextTab.java b/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/OutlineTextTab.java deleted file mode 100644 index 0742f0056d..0000000000 --- a/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/OutlineTextTab.java +++ /dev/null @@ -1,251 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.swt.opengl.examples; - - -import org.eclipse.swt.*; -import org.eclipse.swt.graphics.*; -import org.eclipse.swt.layout.*; -import org.eclipse.swt.opengl.*; -import org.eclipse.swt.widgets.*; - -class OutlineTextTab extends OpenGLTab { - private Text messageText; - private FontData fontData; - private float[] textColor = { 1.0f, 0.0f, 0.0f }; - private boolean fill = true; - private float extrude = 0.0f; - private float xPos = 0.0f, yPos = 0.0f, zPos = -10.0f; - private float xRot = 0.0f; - private int listIndexBase; - private final static int LIST_INDEX_SIZE = 256; - private final static int DEFAULT_FONT_SIZE = 24; - private final static String DEFAULT_FONT_NAME = "Arial"; - private final static int SLEEP_LENGTH = 50; - - /** - * @see OpenGLTab#createControls(Composite) - */ - void createControls(final Composite composite) { - if (!SWT.getPlatform().startsWith("win32")) { - new Label(composite, SWT.NONE).setText("This tab requires win32."); - return; - } - - Group movementGroup = new Group(composite, SWT.NONE); - movementGroup.setText("Translation"); - movementGroup.setLayout(new GridLayout(2, false)); - - new Label(movementGroup, SWT.NONE).setText("X:"); - final Slider xMove = new Slider(movementGroup, SWT.NONE); - xMove.setIncrement(1); - xMove.setMaximum(22); - xMove.setMinimum(0); - xMove.setThumb(2); - xMove.setPageIncrement(2); - xMove.setSelection(10); - xMove.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event e) { - xPos = xMove.getSelection() - 10; - } - }); - - new Label(movementGroup, SWT.NONE).setText("Y:"); - final Slider yMove = new Slider(movementGroup, SWT.NONE); - yMove.setIncrement(1); - yMove.setMaximum(22); - yMove.setMinimum(0); - yMove.setThumb(2); - yMove.setPageIncrement(2); - yMove.setSelection(10); - yMove.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event e) { - yPos = yMove.getSelection() - 10; - } - }); - - new Label(movementGroup, SWT.NONE).setText("Z:"); - final Slider zMove = new Slider(movementGroup, SWT.NONE); - zMove.setIncrement(1); - zMove.setMaximum(22); - zMove.setMinimum(0); - zMove.setThumb(2); - zMove.setPageIncrement(2); - zMove.setSelection(10); - zMove.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event e) { - zPos = zMove.getSelection() - 20; - } - }); - - Composite textGroup = new Composite(composite,SWT.NONE); - GridLayout layout = new GridLayout(2,false); - layout.marginHeight = 0; - layout.marginWidth = 0; - textGroup.setLayout(layout); - textGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); - - new Label(textGroup, SWT.NONE).setText("Text:"); - messageText = new Text(textGroup, SWT.BORDER); - GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); - data.grabExcessHorizontalSpace = true; - messageText.setLayoutData(data); - messageText.setText("OpenGL - SWT"); - - new Label(composite, SWT.NONE).setText("Extrude:"); - final Slider extrudeSlider = new Slider(composite, SWT.NONE); - extrudeSlider.setIncrement(1); - extrudeSlider.setMaximum(22); - extrudeSlider.setMinimum(0); - extrudeSlider.setThumb(2); - extrudeSlider.setPageIncrement(2); - extrudeSlider.setSelection(0); - extrudeSlider.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event e) { - extrude = (float) extrudeSlider.getSelection() / 10; - getContext().loadOutlineFont( - fontData, extrudeSlider.getDisplay(), - listIndexBase, 0, 255, 0.0f, extrude, - fill ? GL.GL_POLYGON : GL.GL_LINE, - null); - } - }); - - final Button fontSelectButton = new Button(composite, SWT.NONE); - fontSelectButton.setText("Set Font"); - final ColorSelectionGroup colorGroup = - new ColorSelectionGroup(composite, SWT.NONE); - colorGroup.setText("Text color"); - colorGroup.addColorSelectionListener(new IColorSelectionListener() { - public void handleColorSelection(RGB rgb) { - GL.glColor3ub((byte) rgb.red, (byte) rgb.green, (byte) rgb.blue); - } - }); - - fontSelectButton.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event e) { - FontDialog fontDialog = new FontDialog(fontSelectButton.getShell()); - fontDialog.setText("Choose Font Options"); - double[] currentColor = new double[4]; - GL.glGetDoublev(GL.GL_CURRENT_COLOR, currentColor); - fontDialog.setRGB( - new RGB( - (int) currentColor[0] * 255, - (int) currentColor[1] * 255, - (int) currentColor[2] * 255)); - fontDialog.setFontData(fontData); - FontData result = fontDialog.open(); - if (result != null) { - fontData = result; - RGB rgb = fontDialog.getRGB(); - GL.glColor3ub((byte) rgb.red, (byte) rgb.green, (byte) rgb.blue); - colorGroup.setRGB(rgb); - getContext().loadOutlineFont( - fontData, fontSelectButton.getDisplay(), - listIndexBase, 0, 255, 0.0f, extrude, - fill ? GL.GL_POLYGON : GL.GL_LINE, - null); - } - } - }); - - final Button fillButton = new Button(composite, SWT.CHECK); - fillButton.setText("Fill"); - fillButton.setSelection(true); - fillButton.addListener(SWT.Selection, new Listener() { - public void handleEvent(Event e) { - fill = fillButton.getSelection(); - getContext().loadOutlineFont( - fontData, fillButton.getDisplay(), - listIndexBase, 0, 255, 0.0f, extrude, - fill ? GL.GL_POLYGON : GL.GL_LINE, - null); - } - }); - } - - /** - * @see OpenGLTab#dispose() - */ - void dispose() { - super.dispose(); - GL.glDeleteLists(listIndexBase, LIST_INDEX_SIZE); - } - - /** - * Draws the text to the screen - * - * @param string the text to draw - */ - void drawText(String string) { - char[] stringChars = string.toCharArray(); - int[] text = new int[stringChars.length]; - for (int i = 0; i < text.length; i++) { - text[i] = (int) stringChars[i]; - } - GL.glPushAttrib(GL.GL_LIST_BIT); - GL.glListBase(listIndexBase); - GL.glCallLists(text.length, GL.GL_UNSIGNED_INT, text); - GL.glPopAttrib(); - } - - /** - * @see OpenGLTab#getSleepLength() - */ - int getSleepLength() { - return SLEEP_LENGTH; - } - - /** - * @see OpenGLTab#getTabText() - */ - String getTabText() { - return "Outline Text"; - } - - /** - * @see OpenGLTab#init() - */ - void init() { - GL.glClearColor(1.0f, 1.0f, 1.0f, 1.0f); - GL.glColor3fv(textColor); - GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); - GL.glEnable(GL.GL_DEPTH_TEST); - GL.glEnable(GL.GL_BLEND); - // build the initial font - listIndexBase = GL.glGenLists(LIST_INDEX_SIZE); - fontData = new FontData(); - fontData.setHeight(DEFAULT_FONT_SIZE); - fontData.setName(DEFAULT_FONT_NAME); - getContext().loadOutlineFont( - fontData, getGlCanvas().getDisplay(), - listIndexBase, 0, 255, 0f, extrude, - fill ? GL.GL_POLYGON : GL.GL_LINE, - null); - } - - /** - * @see OpenGLTab#renderScene() - */ - void renderScene() { - GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); - GL.glLoadIdentity(); - GL.glTranslatef(xPos, yPos, zPos); - GL.glRotatef(xRot, 1.0f, 0.0f, 0.0f); // rotate on X axis - // use GL.glScalef to change size since outline fonts - // don't support size - float size = (float) fontData.getHeight() / 24; - GL.glScalef(size, size, 1.0f); - // draw the text, assuming that we're running on win32 - if (messageText != null) drawText(messageText.getText()); - xRot += 1.2f; - } -} diff --git a/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/SelectionTab.java b/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/SelectionTab.java deleted file mode 100644 index e4c8fa8859..0000000000 --- a/examples/org.eclipse.swt.opengl.examples/src/org/eclipse/swt/opengl/examples/SelectionTab.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.swt.opengl.examples; - - -import org.eclipse.swt.graphics.*; -import org.eclipse.swt.opengl.*; - -abstract class SelectionTab extends OpenGLTab { - private final static int BUFFER_LENGTH = 64; - - /** - * Sets the selected object. Subclasses must override this method. - */ - abstract void processPick(int[] pSelectBuff, int hits); - - /** - * Invoke processPick for the object at the specified coordinate. - */ - int processSelection(int xPos, int yPos, int pointSize) { - int[] selectBuffer = new int[BUFFER_LENGTH]; - int[] viewport = new int[4]; - // new fix for sun jre - int ptr = getContext().getSelectBufferPtr(selectBuffer); - - GL.glSelectBuffer(BUFFER_LENGTH, ptr); - GL.glGetIntegerv(GL.GL_VIEWPORT, viewport); - GL.glRenderMode(GL.GL_SELECT); - GL.glMatrixMode(GL.GL_PROJECTION); - GL.glPushMatrix(); - GL.glLoadIdentity(); - GLU.gluPickMatrix(xPos, yPos, pointSize, pointSize, viewport); - Rectangle rect = getGlCanvas().getClientArea(); - float fAspect = (float) rect.width / (float) rect.height; - GLU.gluPerspective(45.0f, fAspect, 0.5f, 600.0f); - GL.glMatrixMode(GL.GL_MODELVIEW); - GL.glInitNames(); - render(); - int hits = GL.glRenderMode(GL.GL_RENDER); - // new fix for sun jre - // must be called after render mode is switched - getContext().getSelectBuffer(ptr, selectBuffer); - if (hits != 0) processPick(selectBuffer, hits); - GL.glMatrixMode(GL.GL_PROJECTION); - GL.glPopMatrix(); - GL.glMatrixMode(GL.GL_MODELVIEW); - return hits; - } -} -- cgit v1.2.3