Home » Eclipse Projects » Standard Widget Toolkit (SWT) » SWT OpenGL
SWT OpenGL [message #432265] |
Wed, 17 March 2004 15:28 |
Eclipse User |
|
|
|
Originally posted by: alr.atthis.com
Hi there,
I'm using the OpenGL Experimental Library for SWT, and i've some troubles.
Using the GL.glTess functions requires to get pointers on functions that
will be used as callback and pointers on data, in order to make the
tesselator work fine.
Usage :
-------------------------------------------------
int iTess = GLU.gluNewTess();
GLU.gluTessCallback(iTess,GLU.GLU_BEGIN , getGlBeginPtr());
...
double[] vertexCoord = getVertexCoord ();
int iVertexPtr = createPtr(ardCoord);
GLU.gluTessVertex(iTess, vertexCoord, iVertexPtr );
...
freePtr(iVertexPtr);
-------------------------------------------------
but, how can i get some of these pointers ? (getGlBeginPtr() and
getVertexCoordPtr ())
I tryied something that works fine, but after a while JVM
crashs...(solution is given below).
What is the right way to do things like that ? What did i miss ? or is
there any workaround ?
Should i use GlobalAlloc instead ?
to do that i was using the following functions :
-------------------------------------------------
TO get a pointer on an array :
package test.internal.win32;
import org.eclipse.swt.internal.win32.OS;
import org.eclipse.swt.internal.win32.TCHAR;
class LazyCreatePointer {
...
public static synchronized int createPtr(double[] array) {
int hHeap = OS.GetProcessHeap();
int newPtr = OS.HeapAlloc(hHeap,
OS.HEAP_ZERO_MEMORY,
array.length * SIZEOF_DOUBLE);
if (newPtr < 1)
throw new OutOfMemoryError("Cannot allocate memory for pointer !");
OS.MoveMemory(newPtr, array, array.length * SIZEOF_DOUBLE);
return newPtr;
}
and on a function (such as the OpenGL's glBegin function)
public static int getGlBeginPtr() {
return getProcAddress("opengl32\0", "glBegin");
}
private static int getProcAddress(String strModuleName, byte[] strProc) {
TCHAR moduleName = new TCHAR(850, strModuleName, false);
int iModuleHandle = OS.GetModuleHandle(moduleName);
int iProcPtr = OS.GetProcAddress(iModuleHandle, strProc);
return iProcPtr;
}
JVM Crash stack
--------------------------------
An unexpected exception has been detected in native code outside the VM.
Unexpected Signal : EXCEPTION_ACCESS_VIOLATION occurred at PC=0x10026273
Function=[Unknown.]
Library=C:\dev\eclipse\plugins\org.eclipse.swt.win32_2.1.2\o s\win32\x86\swt-win32-2135.dll
NOTE: We are unable to locate the function name symbol for the error
just occurred. Please refer to release documentation for possible
reason and solutions.
Current Java thread:
at org.eclipse.swt.internal.win32.OS.MoveMemory(Native Method)
at
test.internal.win32.LazyCreatePointer.createPtr(LazyCreatePo inter.java:31)
|
|
|
Re: SWT OpenGL [message #432572 is a reply to message #432265] |
Tue, 23 March 2004 12:23 |
Eclipse User |
|
|
|
Originally posted by: alr.atthis.com
please ! some body can help me ?
> Hi there,
> I'm using the OpenGL Experimental Library for SWT, and i've some troubles.
> Using the GL.glTess functions requires to get pointers on functions that
> will be used as callback and pointers on data, in order to make the
> tesselator work fine.
> Usage :
> -------------------------------------------------
> int iTess = GLU.gluNewTess();
> GLU.gluTessCallback(iTess,GLU.GLU_BEGIN , getGlBeginPtr());
> ...
> double[] vertexCoord = getVertexCoord ();
> int iVertexPtr = createPtr(ardCoord);
> GLU.gluTessVertex(iTess, vertexCoord, iVertexPtr );
> ...
> freePtr(iVertexPtr);
> -------------------------------------------------
> but, how can i get some of these pointers ? (getGlBeginPtr() and
> getVertexCoordPtr ())
> I tryied something that works fine, but after a while JVM
> crashs...(solution is given below).
> What is the right way to do things like that ? What did i miss ? or is
> there any workaround ?
> Should i use GlobalAlloc instead ?
> to do that i was using the following functions :
> -------------------------------------------------
> TO get a pointer on an array :
> package test.internal.win32;
> import org.eclipse.swt.internal.win32.OS;
> import org.eclipse.swt.internal.win32.TCHAR;
> class LazyCreatePointer {
> ...
> public static synchronized int createPtr(double[] array) {
> int hHeap = OS.GetProcessHeap();
> int newPtr = OS.HeapAlloc(hHeap,
> OS.HEAP_ZERO_MEMORY,
> array.length * SIZEOF_DOUBLE);
> if (newPtr < 1)
> throw new OutOfMemoryError("Cannot allocate memory for pointer !");
> OS.MoveMemory(newPtr, array, array.length * SIZEOF_DOUBLE);
> return newPtr;
> }
> and on a function (such as the OpenGL's glBegin function)
> public static int getGlBeginPtr() {
> return getProcAddress("opengl32
|
|
|
Re: SWT OpenGL [message #432586 is a reply to message #432572] |
Tue, 23 March 2004 16:35 |
Grant Gayed Messages: 2150 Registered: July 2009 |
Senior Member |
|
|
Please log a report with Platform - SWT to ensure that this doesn't get
lost. This should be investigated, but this will be a difficult week to fit
it in.
Thanks,
Grant
"alr" <alr@atthis.com> wrote in message news:c3pa75$g09$1@eclipse.org...
> please ! some body can help me ?
>
> > Hi there,
> > I'm using the OpenGL Experimental Library for SWT, and i've some
troubles.
>
> > Using the GL.glTess functions requires to get pointers on functions that
> > will be used as callback and pointers on data, in order to make the
> > tesselator work fine.
>
> > Usage :
> > -------------------------------------------------
> > int iTess = GLU.gluNewTess();
> > GLU.gluTessCallback(iTess,GLU.GLU_BEGIN , getGlBeginPtr());
> > ...
> > double[] vertexCoord = getVertexCoord ();
> > int iVertexPtr = createPtr(ardCoord);
> > GLU.gluTessVertex(iTess, vertexCoord, iVertexPtr );
> > ...
> > freePtr(iVertexPtr);
> > -------------------------------------------------
>
> > but, how can i get some of these pointers ? (getGlBeginPtr() and
> > getVertexCoordPtr ())
> > I tryied something that works fine, but after a while JVM
> > crashs...(solution is given below).
>
> > What is the right way to do things like that ? What did i miss ? or is
> > there any workaround ?
>
> > Should i use GlobalAlloc instead ?
>
>
> > to do that i was using the following functions :
> > -------------------------------------------------
> > TO get a pointer on an array :
>
> > package test.internal.win32;
> > import org.eclipse.swt.internal.win32.OS;
> > import org.eclipse.swt.internal.win32.TCHAR;
>
> > class LazyCreatePointer {
> > ...
> > public static synchronized int createPtr(double[] array) {
> > int hHeap = OS.GetProcessHeap();
> > int newPtr = OS.HeapAlloc(hHeap,
> > OS.HEAP_ZERO_MEMORY,
> > array.length * SIZEOF_DOUBLE);
> > if (newPtr < 1)
> > throw new OutOfMemoryError("Cannot allocate memory for pointer !");
> > OS.MoveMemory(newPtr, array, array.length * SIZEOF_DOUBLE);
> > return newPtr;
> > }
>
> > and on a function (such as the OpenGL's glBegin function)
>
> > public static int getGlBeginPtr() {
> > return getProcAddress("opengl32
>
|
|
|
Goto Forum:
Current Time: Thu Apr 25 17:26:11 GMT 2024
Powered by FUDForum. Page generated in 0.03310 seconds
|