
Running GTK# and OpenTK GameWindow at Once?
Posted Friday, 22 October, 2010 - 14:51 by jp-sdt inHi all,
I would like to create an "Preferences"-Window using GTK# and make a depend to my OpenTK gamewindow.
I don't plan to use GLWidged. It would be nicer to see Preferences window and OpenTk window running at once.
Any possibilitys there?
Thanks in advance
JP-sdt
// Sorry for my bad english ^^"


Comments
Re: Running GTK# and OpenTK GameWindow at Once?
This should work, as long you open the GTK# window on a different thread than the GameWindow.
You will also need to add a call to OpenTK.Toolkit.Init() as the very first thing in your Main() method:
Re: Running GTK# and OpenTK GameWindow at Once?
Thank you for your answer.
Are there any tutorials what describe what exactly you're meaning?
Thanks ^^
reguards
JP-sdt
Re: Running GTK# and OpenTK GameWindow at Once?
Ok
I tried it out, but it didn't work correctly. I'm sure that I'm doing anywhat false. First I tried to test it with the Quickstart Project.
What I have to do in the GTK#-part?
Here's the main method of Starterkit.cs :
_______________________________________________________________________________________________________
"A person who never made a mistake never tried anything new."
Albert Einstein
Re: Running GTK# and OpenTK GameWindow at Once?
You need to create a new Thread and launch either GameWindow or MainWindow from there (your choice). Otherwise, the event loops of GTK# and OpenTK will interfere with each other.
Check out the Multithreading example (modify it to use 1 extra thread and move either the GameWindow or the MainWindow to that thread. Don't change the thread priority either).
Re: Running GTK# and OpenTK GameWindow at Once?
Yeah,
Got it work :D
Thank you very much Fiddler ... I love that Comnuity :* ^^
Kind reguards
JP-sdt
_________________________________________________________________________________________________________
A person who never made a mistake never tried anything new.
Albert Einstein
Re: Running GTK# and OpenTK GameWindow at Once?
Hi,
Got a new problem with Multithreading. How can I acces the Button Click events and so on? The void is static so i cant acces the user input data from the Gtk window, isn't it?
_________________________________________________________________________________________________________
A person who never made a mistake never tried anything new.
Albert Einstein
Re: Running GTK# and OpenTK GameWindow at Once?
Events work as usual with the difference that GameWindow events fire in the GameWindow thread and GTK# events fire in the GTK# thread. As a rule of thumb, you shouldn't use instance methods of a class from a different thread. Static methods should be thread-safe.
What do you mean when you say "the void is static"?
Re: Running GTK# and OpenTK GameWindow at Once?
My english is bad ^^
I think you missunderstood my question.
An quiet easy example to explain my want.
An Gtk-sharp window with a Combobox, where you can find the Items "Box","sphere"and "torus". Is it possible to send the given Combobox-item to the gamewindow, to draw the shape, the user want?
What do you mean when you say "the void is static"?
Its an bad result of my very bad english x.x
just forget it ^^
_________________________________________________________________________________________________________
A person who never made a mistake never tried anything new.
Albert Einstein
Re: Running GTK# and OpenTK GameWindow at Once?
Oh Sorry ^^
I forgot to use the variables as static ^^
My problem is solved now.
thanks for your help fiddler :D
_________________________________________________________________________________________________________
A person who never made a mistake never tried anything new.
Albert Einstein
Re: Running GTK# and OpenTK GameWindow at Once?
Has anyone had any joy doing this on a Mac? I'm trying to have a GTK# (or winForms) app coincide with a GameWindow, and even though they're both on separate threads (and the same code works fine from both windows and Linux), the Mac is behaving as if they are both on the same thread.
I've followed the multithreading example for structuring the threads and this makes the situation worse. Having the gamewindow on the main app thread, and creating a side thread for the GUI causes the GTK# or WinForms app to show properly, but then crash after some time, and all the input goes to the OpenTK window (as if it was the same thread, but I can confirm it isn't, the GUI will run from a different thread ID than openTK will, (e.g. OTK in thread 1, GTK# in thread 5) and I'm just testing the logic now, so there's no event passing going on between the two yet, and definitely no join commands from one to the other).
If I follow the multithreaded example exactly, then both the OpenTK window and the GUI (either GTK# or WinForms) freeze up, and neither are responsive. Obviosuly running just OpenTK or just GTK or just winForms it all works fine.
Is threading properly implemented on the Mac in Mono? Does anybody have any success with this?
Any thoughts on this would be appreciated, it's been an all-day headscratcher.
Cheers,
Euan
Icarus Scene Engine. OpenTK-based 3D simulation & games solution:
http://www.pointscape.com.sg/joomla
See Icarus videos on YouTube at: