Hi,
Id like to render directly into a java canvas out of Ogre with OpenGL but im not sure if i understood the Ogre architecture correctly so i can implement this...
So lets think of the steps which used to be done on Ogre site:
1: I have to write my own RenderWindow and GLSupport implementation that provides rendering into a java canvas. I think for the GLSupport i can use the existing GLX support class.
2: I have to create the appropriate makefiles and adjust the configure,in file to build Ogre with my Java Canvas support.
Is there anything i forgot? Any further classes i have to implement? Any "unexptected" changes to the existing configuration?
thx, Schmelly
rendering to a java canvas
-
Schmelly
- Kobold
- Posts: 39
- Joined: Sat Sep 18, 2004 7:11 pm
- Location: Paderborn, Germany
-
Schmelly
- Kobold
- Posts: 39
- Joined: Sat Sep 18, 2004 7:11 pm
- Location: Paderborn, Germany
Right now i have a problem with creating the makefiles for my own RenderWindow implementation.
The following steps i made so far are:
1. First of all, i copied the present GLX implementation to my own folder in /ogrenew/RenderSystems/GL/src/JavaAWT and renamed the source files as well as the include paths of these files to my needs. (The appropriate include files were copied and modified as well)
2. I added "JavaAWT" to the DIST_SUBDIRS variable in the "Makefile.am" in /ogrenew/RenderSystems/GL/src/
3. Last but not least i modified the "AC_DEFUN([OGRE_GET_GLSUPPORT]" section in the "/ogrenew/acinclude.m4" file (changes are bold):
The problem is now, that no makefile is generated in /ogrenew/RenderSystems/GL/src/JavaAWT/ when i run bootstrap and configure --disable-static --enable-shared --with-gl-support=JavaAWT --with-platform=JavaAWT
Does somebody know what i forgot?
The following steps i made so far are:
1. First of all, i copied the present GLX implementation to my own folder in /ogrenew/RenderSystems/GL/src/JavaAWT and renamed the source files as well as the include paths of these files to my needs. (The appropriate include files were copied and modified as well)
2. I added "JavaAWT" to the DIST_SUBDIRS variable in the "Makefile.am" in /ogrenew/RenderSystems/GL/src/
3. Last but not least i modified the "AC_DEFUN([OGRE_GET_GLSUPPORT]" section in the "/ogrenew/acinclude.m4" file (changes are bold):
AC_DEFUN([OGRE_GET_GLSUPPORT],
[OGRE_GLSUPPORT=SDL
AC_ARG_WITH(gl-support,
AC_HELP_STRING([--with-gl-support=PLATFORM],
[the platform to build, currently SDL or gtk]),
OGRE_GLSUPPORT=$withval,
OGRE_GLSUPPORT=SDL)
if test ! -d RenderSystems/GL/src/$OGRE_GLSUPPORT; then
OGRE_GLSUPPORT=SDL
fi
GLSUPPORT_CFLAGS=""
GLSUPPORT_LIBS=""
dnl Do the extra checks per type here
case $OGRE_GLSUPPORT in
SDL) AM_PATH_SDL(1.2.0)
GLSUPPORT_CFLAGS=$SDL_CFLAGS
GLSUPPORT_LIBS=$SDL_LIBS
;;
gtk)
PKG_CHECK_MODULES(GLSUPPORT, gtkglextmm-1.0)
GLSUPPORT_LIBS="$GLSUPPORT_LIBS"
;;
GLX)
GLSUPPORT_CFLAGS="-I/usr/X11R6/include"
GLSUPPORT_LIBS="-L/usr/X11R6/lib -lX11 -lXext -lGL -lXrandr"
;;
JavaAWT)
GLSUPPORT_CFLAGS="-I/usr/X11R6/include"
GLSUPPORT_LIBS="-L/usr/X11R6/lib -lX11 -lXext -lGL -lXrandr"
esac
AC_SUBST(GLSUPPORT_CFLAGS)
AC_SUBST(GLSUPPORT_LIBS)
AC_SUBST(OGRE_GLSUPPORT)
AC_CONFIG_FILES([RenderSystems/GL/src/gtk/Makefile
RenderSystems/GL/src/SDL/Makefile
RenderSystems/GL/src/GLX/Makefile
RenderSystems/GL/src/JavaAWT/Makefile])
])
The problem is now, that no makefile is generated in /ogrenew/RenderSystems/GL/src/JavaAWT/ when i run bootstrap and configure --disable-static --enable-shared --with-gl-support=JavaAWT --with-platform=JavaAWT
Does somebody know what i forgot?
-
:wumpus:
- OGRE Retired Team Member

- Posts: 3067
- Joined: Tue Feb 10, 2004 12:53 pm
- Location: The Netherlands
- x 1
Yes, this is the idea. It's about what I did on adding GLX. Weird that you get no makefile.. Are you sure OGRE_GLSUPPORT really is JavaAWT? (it uses that as subdir name inside /ogrenew/RenderSystems/GL/src)
SUBDIRS = $(OGRE_GLSUPPORT) nvparse atifs
Anyway, if all you need is to render to a given GLX window instead of a new one, why not adapt the GLX support to pass in a handle instead of copying the entire bunch?
SUBDIRS = $(OGRE_GLSUPPORT) nvparse atifs
Anyway, if all you need is to render to a given GLX window instead of a new one, why not adapt the GLX support to pass in a handle instead of copying the entire bunch?
-
Schmelly
- Kobold
- Posts: 39
- Joined: Sat Sep 18, 2004 7:11 pm
- Location: Paderborn, Germany
Well i hope so... At least the configure script doesnt try to set the glsupport for SDL and make tries to build the sources in /ogrenew/RenderSystems/GL/src/JavaAWT:wumpus: wrote:Yes, this is the idea. It's about what I did on adding GLX. Weird that you get no makefile.. Are you sure OGRE_GLSUPPORT really is JavaAWT? (it uses that as subdir name)
The answer is quite simpel: I dont really know which parts of the existing glx implementation i can take over, have to be modified or can be dropped right know. The whole procedure was only to provide a basis for further implementations::wumpus: wrote:Anyway, if all you need is to render to a given GLX window instead of a new one, why not adapt the GLX support to pass in a handle instead of copying the entire bunch?
Im working on a Java binding for ogre. For example it would be nonsense not to use the java input handling and implement a wrapper class for every listener, event etc... So i decided to support rendering directly into a java canvas. The whole input handling can then be implemented on java side and could be dropped from the existing glx support
A simple SkyBox scene is allready running by the way (except the input handling stuff (KeyListeners etc))
-
:wumpus:
- OGRE Retired Team Member

- Posts: 3067
- Joined: Tue Feb 10, 2004 12:53 pm
- Location: The Netherlands
- x 1
There is no input handling in the GLSupport, that is in the GLX platform manager. The GLX GLSupport kind of only consists the part needed to render stuff.Schmelly wrote: Im working on a Java binding for ogre. For example it would be nonsense not to use the java input handling and implement a wrapper class for every listener, event etc... So i decided to support rendering directly into a java canvas. The whole input handling can then be implemented on java side and could be dropped from the existing glx support
Anyway, nice work on the Java binding!
-
Schmelly
- Kobold
- Posts: 39
- Joined: Sat Sep 18, 2004 7:11 pm
- Location: Paderborn, Germany
-
Schmelly
- Kobold
- Posts: 39
- Joined: Sat Sep 18, 2004 7:11 pm
- Location: Paderborn, Germany
Hello again!
The rendering to my Java Canvas now works on Linux... well... a bit
I have some problems with the correct size of the rendering area... Take a look at this screenshot showing a JFrame with a JMenuBar:

Because im not very familiar with OpenGL and GLX in particular im not sure whats missing in my code.
Im initialising OpenGL in the constructor of my own RenderWindow implementation in the following way (i think there is lots of work to be done on this):
where mDisplay and mWindow are the handles i get from the native Java AWT interface.
The swapBuffers method looks like this:
Furthermore im getting a couple of exceptions when loading the resources in the Samples/Media folder like this one:
Does this have possibly anything to do with lacks in my RenderSystem implementation?
The rendering to my Java Canvas now works on Linux... well... a bit
I have some problems with the correct size of the rendering area... Take a look at this screenshot showing a JFrame with a JMenuBar:

Because im not very familiar with OpenGL and GLX in particular im not sure whats missing in my code.
Im initialising OpenGL in the constructor of my own RenderWindow implementation in the following way (i think there is lots of work to be done on this):
Code: Select all
JavaAWTWindow::JavaAWTWindow()
{
std::cerr << std::endl << "JavaAWTWindow::JavaAWTWindow" << std::endl;
mDisplay = JavaAWTContainer::getSingleton().getDisplay();
mWindow = JavaAWTContainer::getSingleton().getWindow();
int config[] = { GLX_DOUBLEBUFFER,
GLX_RGBA,
GLX_DEPTH_SIZE,
24,
GLX_RED_SIZE,
1,
GLX_BLUE_SIZE,
1,
GLX_GREEN_SIZE,
1,
None};
XVisualInfo * visualInfo = glXChooseVisual(mDisplay, DefaultScreen(mDisplay), config);
mGlxContext = glXCreateContext(mDisplay, visualInfo, 0, GL_TRUE);
glXMakeCurrent(mDisplay, mWindow, mGlxContext);
XFlush(mDisplay);
}The swapBuffers method looks like this:
Code: Select all
void JavaAWTWindow::swapBuffers(bool waitForVSync)
{
//std::cerr << "JavaAWTWindow::swapBuffers" << std::endl;
glXSwapBuffers(mDisplay,mWindow);
}Furthermore im getting a couple of exceptions when loading the resources in the Samples/Media folder like this one:
Code: Select all
Error in material Examples/BumpMapping/SingleLight at line 124 of Examples-Advanced.material: Invalid param_named_auto attribute - An exception has been thrown!
-----------------------------------
Details:
-----------------------------------
Error #: 7
Function: GpuProgramParameters::getParamIndex
Description: Cannot find a parameter named eyePosition.
File: OgreGpuProgram.cpp
Line: 393
Stack unwinding: <<beginning of stack>>-
yap_wil
- Gnoblar
- Posts: 6
- Joined: Sun Dec 15, 2002 9:52 am
-
Schmelly
- Kobold
- Posts: 39
- Joined: Sat Sep 18, 2004 7:11 pm
- Location: Paderborn, Germany
-
sinbad
- OGRE Retired Team Member

- Posts: 19269
- Joined: Sun Oct 06, 2002 11:19 pm
- Location: Guernsey, Channel Islands
- x 67