initializing ogre without config dialog

the_cX

01-02-2006 19:15:31

has anyone successfully initialized ogre without using the config dialog?

this is something i am trying to do with my program but i cant get it to work. it seems like the Ogre::RenderSystemList hasnt been converted yet and i dont know how else to go about this.

the closest ive got is using the RestoreConfig() function to load the parameters from an existing file, but ofcoarse the program wont initialize when run on a different computer because of the RenderSystem.

just wondering if anyone has done this or has some insight on how it may be done.

thanks

GregH

01-02-2006 22:02:07

Hi The_Cx,

I don't know if I have insight, but I've got loads of hindsight !!! Like you, I knew the day would come when I would want my commercial application to launch directly into the opening scene without the OGRE config...and before I even started to use OGRE I did a little research to ensure this could be done...if not, I'd have stopped right there.

The document found at http://www.ogre3D.org/wiki/index.php/Pr ... ialization discusses code that (should) accomplish the tasks that your seek.

Having said this though, 1) I have only read the doc, 2) It's not written in VB.Net :cry: and 3) so I have no proof it will work. But I suspect with some tweaking that it will.

If it works, and you are a VB.Net programmer, feel free to send me the code...or if not, just verify that the doc is correct !!!

Cheers,

G.

the_cX

02-02-2006 00:01:52

hi greg,

in the wiki article:
Ogre::RenderSystemList *renderSystems = NULL;
Ogre::RenderSystemList::iterator r_it;

val = opts.find("renderSystem")->second;
renderSystems = ogre->getAvailableRenderers();


like i said, the RenderSystem class hasnt been converted yet in ODN. thanks though :)

anyone else?

GregH

02-02-2006 01:37:03

Hi The_Cx,

I'm quite new to this so I could be quite wrong, but my object browser has a RenderSystem class with stacks of methods, properties and data types...and I cannot imagine how OGRE could launch without them...indeed I don't know how the very Config Dialogue your'e trying to bypass could do it's job without this class being available.

Am I missing something here...or perhaps it's a version issue???

Cheers,

G.

GregH

02-02-2006 01:47:50

Hi The_Cx,

If you want to determine the available render systems, I've tried this code in VB.Net and it correctly enumerates the three render systems on my box:



'Test for available render systems...

Dim RenderSystems As RenderSystemList
Dim ThisRenderSystem As RenderSystem

RenderSystems = MyOgreRoot.GetAvailableRenderers

For Each ThisRenderSystem In RenderSystems

Debug.WriteLine(ThisRenderSystem.GetName)

Next ThisRenderSystem



If I've misinterpreted your request, I apologise in advance...and if it's a matter of reading the current config values in Ogre.Cfg, you could use non-ogre code to open and access the file...but I'm sure that it will have been implemented in OgreDotNet also (I just haven't tried it yet).

Cheers,

G.

rastaman

02-02-2006 04:29:23

@the_cX
You need to update your ogredotnet. cvs now has the classes you'r looking for. I haven't tried starting ogre this way but I think the interfaces you need are there now. I'll try over the weekend. I just started on a big project at work now, just too tired of programming to do anything when i get home.

EagleEye

02-02-2006 04:51:09

@the_cX
You need to update your ogredotnet. cvs now has the classes you'r looking for. I haven't tried starting ogre this way but I think the interfaces you need are there now. I'll try over the weekend. I just started on a big project at work now, just too tired of programming to do anything when i get home.


Takea break buddy... as far as I'm aware, ODN is stable and ready to use for most applications currently. We'll let things run as they are for now and see how things go.

GregH

02-02-2006 06:31:46

Rastaman wrote:


You need to update your ogredotnet. cvs now has the classes you'r looking for. I haven't tried starting ogre this way but I think the interfaces you need are there now.


Well if they ain't there, I'm witnessing a miracle (see my code above).

Cheers,

G. PS// Has anyone noticed replies appearing and disappearing from the forum today? One thread says it has 1 reply (by me to Rom) and yet it doesn't appear when you open the thread...

EagleEye

02-02-2006 07:02:34

You had a double post in that "research project" thread. I deleted the duplicate post. Try refreshing it?

rastaman

04-02-2006 23:24:48

has anyone successfully initialized ogre without using the config dialog?

Insted of calling Root.ShowConfigDialog, you can try this code. if you main class derives form ExampleApplication just copy the setup function. change virtual to override and paste this on top of the if statment with ShowConfigDialog.

RenderSystemList oRSL=null;
RenderSystem oRS=null;
oRSL = mRoot.GetAvailableRenderers();
Console.WriteLine("select a RenderSystem:");
for (int i=0; i<oRSL.Count; i++)
{
oRS =oRSL[i];
Console.WriteLine( " (0) {1}", i ,oRS.GetName() );
}

string sline = Console.ReadLine();
int iSelectedIndex = Convert.ToInt32(sline);
if ( (iSelectedIndex<0) || (iSelectedIndex >= oRSL.Count) )
return false;
oRS = oRSL[iSelectedIndex];
if (oRS == null)
return false;

ConfigOptionMap oCOM = oRS.GetConfigOptions();
Console.WriteLine("Config Options:" );
for (int i=0; i<oCOM.size(); i++)
{
ConfigOption oCO = oCOM.getitemValue(i);
Console.WriteLine("{0}:", oCO.name );

StringVector oPV = oCO.possibleValues;
for (int j=0; j<oPV.Count; j++)
{
if (oCO.currentValue == oPV[j])
Console.WriteLine("->{0}: {1}:", j, oPV[j] );
else
Console.WriteLine(" {0}: {1}:", j, oPV[j] );
}
sline = Console.ReadLine();
iSelectedIndex = Convert.ToInt32(sline);
if ( (iSelectedIndex<0) || (iSelectedIndex >= oPV.Count) )
return false;
oRS.SetConfigOption( oCO.name, oPV[iSelectedIndex] );
}
mRoot.SetRenderSystem(oRS);
mRoot.SaveConfig();



Well if they ain't there, I'm witnessing a miracle (see my code above).
I was talking to the_cX :)

GregH

05-02-2006 00:09:09

Hi Rastaman,

Yes, I know you were talking to The_Cx, :idea: but he was saying he didn't think the classes were there, and you said you think the interfaces were there...so I was just confirming that they *are* available in order to take the guess work out. That's why I provided the code snippet. I also suggested it might have been a version issue quite early in the discussion. :lol:

Does this make sense? :wink:

[Edited] Also, thank you for the startup code sample you provided, I'll have a go at translating it to VB.Net ASAP...

Cheers,

G.

GregH

14-02-2006 11:42:04

Hi Folks,

Following along the lines of this thread, I've created a very successful custom config dialogue to replace the default OGRE form.

One problem I'm experiencing is that Root.GetAvailableRenderers returns *all* of the available render systems including ones I don't want like DirectX 7 (aka Direct3D7) which crashes OGRE if selected. (Question One: does OGRE support DX7...I don't mind if it doesn't, I'd just like confirmation.)

I've tried a number of strategies to remove the unwanted render systems from the retrieved list, including the RemoveAt method on the item I don't want...I've even written a function that iterates the list and only adds wanted render systems to a new list as a return collection...but all I get is 'External Error' messages.

So the Question Two is: how to cull unwanted Render Systems that result from Root.GetAvailableRenderers ???

Cheers,

G.

rastaman

14-02-2006 18:21:54

what kind of project is it? maybe the DX7 rendere just does not support what you are trying to do.

as for the problems with not including it in what the user sees, I'd have to see some code :). I don't think you should Remove items from the internal ogre list.

try making an ArrayList of Integers save in there the index of the Renderers you want the user to choose from. fill the gui using the indexes you saved. something like that

GregH

14-02-2006 21:02:06

Hi Rastaman,

I'm just using the standard unedited config as per SDK 1.06...my Ogre log file says it's tripping over 'CreatSurfaces' when Direct3D7 is set as the render system - Error sample is:


-----------------------------------
Details:
-----------------------------------
Error #: -2147024809
Function: D3DTexture::createSurfaces
Description: Could not create DirectDraw surface..
File: c:\softwaredevelopment\c++\ogresdk\ogrenew_vc71\rendersystems\direct3d7\src\ogred3d7texture.cpp
Line: 434
Stack unwinding: <<beginning of stack>>
07:41:24: An exception has been thrown!



..and this happens for every texture required. Boot works fine for D39 and OpenGL, which suggests OGRE 1.06 isn't compatible with D37.

This is why I want to prevent it being presented as an option, but as I said, I'm having quite a deal of trouble keeping it out of my combo list and still synchronising the GetConfigOptions.

I haven't tried *really* hard for an answer - I'll play around with indexes as you've suggested, and post a progress report when I can.

Cheers,

G.

the_cX

19-02-2006 21:00:55

sorry for the delay, was caught in other projects. :oops:

rastaman: thanks a lot for your contributions. i was in fact using some prebuilt binaries i found on here that still didnt have the RenderSystemList. i built through cvs this time successfully and it works. :)

one thing though, in the code you posted above, this throws an exception:

oCOM.getitemValue(i);

im not using the the ConfigOptionsMap where i have to use that function, but it did crash when i tried to use it.

anyways, thanks. :)

rastaman

19-02-2006 22:50:37

hmm.. well i just tried it again with DemoRSQ on windows and its working.


The only problem was where it writes the RenderSystem names. The "(0)" should be "{0}" in the WriteLine Statement. I didn't notice this in befor in linux.

SumsForever

28-02-2006 08:03:13

-----------------------------------
Details:
-----------------------------------
Error #: -2147024809
Function: D3DTexture::createSurfaces
Description: Could not create DirectDraw surface..
File: e:\projects\ogrecvs\branches\azathoth_vc8_clean\ogrenew\rendersystems\direct3d7\src\ogred3d7texture.cpp
Line: 434
Stack unwinding: <<beginning of stack>>

i have the same error
someone could help me please.im a new in ogre and english too ^^

rastaman

01-03-2006 01:13:37

can you use DX7 with the regular ogre config window ?

maybe the problems with dx7 hare related to this thread http://www.ogre3d.org/phpBB2/viewtopic.php?t=17922&highlight=create+directdraw+surface

GregH

01-03-2006 10:07:09

Hi All,

I've never been able to use ODN with DX7...not with the native config dialogue or with my custom dialogue. That's why I wanted to remove DX7 as an option.

Like (I think) everyone else, I get the same "CreateSurface" error.

Rather than focusing on trying to get DX7 to work, I'd prefer to ignore it as a viable renderer. Bit of a struggle, but I'll eventually squash it out of the available options in my custom dialogue.

Cheers,

GregH.

EagleEye

14-03-2006 06:37:51

I hadn't followed this discussion earlier because I wasn't to the point of doing this for my own project yet...

For the DX7 render system, you may want to check your plugins.cfg file... it's probably listed there as a plugin... simply remove it from that plugins.cfg (and remove the RenderSystem_Direct3D7.dll file, since you won't be using it), and you should be good.

Here's my plugins.cfg...

# Defines plugins to load

# Define plugin folder
PluginFolder=./Plugins

# Define plugins
Plugin=RenderSystem_Direct3D9
Plugin=RenderSystem_GL
Plugin=Plugin_ParticleFX
Plugin=Plugin_CgProgramManager
Plugin=Plugin_BSPSceneManager
Plugin=Plugin_OctreeSceneManager
Plugin=Plugin_PagingLandScapeSceneManager2


See, it used to have:

Plugin=RenderSystem_Direct3D7

but I removed that line and it's not even an option in my config dialog.

EagleEye

14-03-2006 07:24:16

The way I program, I don't like using text for config options at all... I much prefer binary data... this is one of the main reasons I don't like XML... it's bulky... plus it's editable by the user which isn't something I like...

Now, it's arguable that video options should be configurable in a text file, just in case there's a problem, but the way I have this set up, it will default to something that should be supported by all if the file gets destroyed... so if there's a problem with an incompatability, you COULD opt to delete the file and start over... *shrugs*... I'm just doing this for my own good so I don't have to parse a text file for proper config options.

What I'm using here is serialization/deserialization of a "baseVideoOptions" class, which is contained in a controller class simply called "Video" in my app's namespace. This makes it extendable for later use of other video stuff if I need it later.

Imports System.IO
Imports VermundData.Vermund.Data

Namespace Vermund.Client
Public Class Video
Public Options As BaseVideoOptions
Private MyPath As String = App_Path() & "/video.cfg"
Sub New()
Try
If File.Exists(MyPath) Then
Dim fStream As New FileStream(MyPath, FileMode.Open)
Dim ByteArray() As Byte
fStream.Read(ByteArray, 0, fStream.Length)
fStream.Close()
Options = DeserialData(ByteArray)
Else
Options = New BaseVideoOptions
SaveOptions()
End If
Catch ex As Exception
End Try
End Sub


In Sub New here, we see that we are first checking to see if the video.cfg file exists in our app path directory (I have an app_path global defined for my project). If it doesn't, the default options are saved... (the file is created in that sub)

If the file DOES exist, the options variable is filled with the deserialized data of the byte array read in by the fstream. I have serialize/deserialize functions that I use for generic serialization and deserialization (handy for database blob storage, network packet transmission, and binary data file storage)...

I'll paste those 2 functions later in this post... for now, let's look at the "SaveOptions" function.

Public Function SaveOptions() As Boolean
Try
Dim bytes() As Byte = SerialData(Options)
Dim fstream As New FileStream(MyPath, FileMode.Create, FileAccess.Write)
fstream.Write(bytes, 0, bytes.Length)
fstream.Close()
Catch ex As Exception

End Try
End Function
End Class
End Namespace


So what's this "BaseVideoOptions" class?

<Serializable()> Public Class BaseVideoOptions

Public Enum RenderSystems As Byte
OpenGL
DX9
End Enum
Public Enum VideoModes As Byte
y640x480
y800x600
y1024x768
End Enum

Public RenderSystem As RenderSystems = RenderSystems.OpenGL
Public ColorDepth As Byte = 32
Public DisplayFreq As Byte = 56
Public FSAA As Byte = 0
Public FullScreen As Boolean = False
Public VSync As Boolean = False
Public VideoMode As VideoModes = VideoModes.y800x600

End Class


This is what I'm playing with right now... it's not complete, but I figured I'd share my approach with you.

I plan on using these video options that are saved to determine the startup options.

Of course, there are more options not shown here yet, like anti-aliasing, etc... but those can be added easily.