rendering to a java canvas

Problems building or running the engine, queries about how to use features etc.
User avatar
Schmelly
Kobold
Posts: 39
Joined: Sat Sep 18, 2004 7:11 pm
Location: Paderborn, Germany

rendering to a java canvas

Post by Schmelly »

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
User avatar
Schmelly
Kobold
Posts: 39
Joined: Sat Sep 18, 2004 7:11 pm
Location: Paderborn, Germany

Post by Schmelly »

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):
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?
User avatar
:wumpus:
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 3067
Joined: Tue Feb 10, 2004 12:53 pm
Location: The Netherlands
x 1

Post by :wumpus: »

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? :)
User avatar
Schmelly
Kobold
Posts: 39
Joined: Sat Sep 18, 2004 7:11 pm
Location: Paderborn, Germany

Post by Schmelly »

: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)
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: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? :)
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:

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))
User avatar
:wumpus:
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 3067
Joined: Tue Feb 10, 2004 12:53 pm
Location: The Netherlands
x 1

Post by :wumpus: »

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
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.

Anyway, nice work on the Java binding!
User avatar
Schmelly
Kobold
Posts: 39
Joined: Sat Sep 18, 2004 7:11 pm
Location: Paderborn, Germany

Post by Schmelly »

I forgot to mention that i replaced the platform manager stuff as well sry... Im sure this will be kind of useless later but for the first tests its ok for me ;)

The build was now successful by the way... I didnt realize that I modified a backup version of the "acinclude.m4" file :oops: :roll:
User avatar
Schmelly
Kobold
Posts: 39
Joined: Sat Sep 18, 2004 7:11 pm
Location: Paderborn, Germany

Post by Schmelly »

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:

Image

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);
}
where mDisplay and mWindow are the handles i get from the native Java AWT interface.

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>>
Does this have possibly anything to do with lacks in my RenderSystem implementation?
User avatar
yap_wil
Gnoblar
Posts: 6
Joined: Sun Dec 15, 2002 9:52 am

Post by yap_wil »

Hi.

I am just wondering if anyone is still working on a Java binding for Ogre?

Thanks.
User avatar
Schmelly
Kobold
Posts: 39
Joined: Sat Sep 18, 2004 7:11 pm
Location: Paderborn, Germany

Post by Schmelly »

Sry, me not right now...

I havent enough time to spent on this (studies and so on)
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 67

Post by sinbad »

macross has just picked up Ogre4j again, it's there in ogreaddons.