News:

Want to praise Simutrans?
Your feedback is important for us ;D.

Hardware accelerated display, OpenGL back-end & Simutrans 3D

Started by eddielexx, January 02, 2010, 03:38:33 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Markohs

I wanna thank to whoever added a assert in the function mark_tiles_dirty (disabled by preprocessor, but still). The heap corruption was coming from there, it was writing some extra bytes ahead and giving me all those problems. :)

Man, I think I'd have never been able to track it if it wasn't for the assert. ;)

O01eg

Is it possible to build simutrans3d under Linux? I fix Makefile and change backslash to slash but some win-specifics like TRUE and Sleep cause errors:

simsys_ogre.cc: In function 'int dr_os_init(const int*)':
simsys_ogre.cc:396:36: error: new declaration 'int dr_os_init(const int*)'
simsys.h:63:6: error: ambiguates old declaration 'bool dr_os_init(const int*)'
simsys_ogre.cc:466:9: error: 'TRUE' was not declared in this scope
simsys_ogre.cc: In function 'int dr_os_close()':
simsys_ogre.cc:773:21: error: new declaration 'int dr_os_close()'
simsys.h:74:6: error: ambiguates old declaration 'void dr_os_close()'
simsys_ogre.cc:779:9: error: 'TRUE' was not declared in this scope
simsys_ogre.cc: In function 'long unsigned int dr_time()':
simsys_ogre.cc:1151:6: error: 'first' was not declared in this scope
simsys_ogre.cc:1156:41: error: 'first' was not declared in this scope
simsys_ogre.cc: In function 'void dr_sleep(uint32)':
simsys_ogre.cc:1163:12: error: 'Sleep' was not declared in this scope

Revision 5283
Ogre 1.7.3

Markohs

There are some things going on here:

- I never compiled it in linux, so some tweaks might be necessary
- I didn't knew TRUE was windows specific.
- that sleep is copied from the SDL version(simsys_s.cc), I guessed it should work but wasn't really sure. Might be a include missing.
- I recently updated from subversion head revision, and simsys.h headers have changed since the last time, that needs a fix too.

I'll have it a look when I'm able to, but now I'm focusing more in the CEGUI project, but any patch you or anybody makes is welcome.

isidoro

In fact TRUE is a macro of windows.h.  I guess it comes from the times of C.  C++ has a full-fledged true keyword.  The same goes for BOOL, WORD, LPWORD, etc., all Microsoft stuff...

Sleep is also a Win32 API call, though SDL may have an equivalent function...


jamespetts

Weren't all the instances of "TRUE" replaced by the standard C++ "true" in the code in Standard recently?
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Ters

I think so, but that was after Simutrans 3D forked and could not spread to files unique to Simutrans 3D.

Markohs

No, in fact I typed TRUE in caps myself, correcting it.

O01eg

I fix some more errors.

Markohs

Thank you, just applied them

IgorEliezer

Quote from: O01eg on February 12, 2012, 06:09:08 PM
I fix some more errors.
Thanks dude. And welcome to the community.

O01eg

What is the difference between ogre, cegui and opengl backends?

Markohs

 They are 3 projects, thought as an incremental implementation of the final goal, a simutrans with 3D models in it:

- opengl just renders the window using OpenGL+SDL, it's mainly the code Ters made in the CEGUI topic.
- cegui it's based on the opengl build, and targets the migration of the current GUI windows to CEGUI engine, that allows many improvements in the current GUI.
- ogre is the final 3D enabled project, it will use cegui as a base. It will render current simutrans2D objects plus 3D objects, that will be merged in the screen.

I'm mainly alone on this, if anybody wants to help in any of these projects, just tell me and we can find a area you are comfortable working with.  I just have some spare time some days a week to program atm, will be able to spend more time in a few months.

Markohs

The TODO list (from the top of my head) is:

opengl:
- Fix known bugs.
- Explore if using non-pow2 texture is a problem in a significant number of nowadays computers, and find a acceptable solution.
- Fully document the simsys_opengl.cc file.

cegui:
- Figure how to integrate with the current simwin.cc, gui/* classes in a way they can co-exist in the first steps of the development.
- Adapt .lookandfeel file to the needed simutrans widgets.
- Artistic work in the .imageset file
- Design how we can provide customizable .layout, .lookandfeel and a LUA interface to the PAK creators so they can modify default settings freely.
- Migrate current simutrans widgets/windows to CEGUI
- Explore new/interesting ideas all the windows scaling/deformation/alphablending capabilities have can be applied to the GUI
- Generate a in-memory imageset from the PAK GUI images, they are needed across the GUI

ogre:
- Implement the current 2D drawing algorithm using imagesets to get performance closer or better than current code.
- Explore the new possibilities sprites alpha and rotation/scaling can give to the 2D render (rotate trains on curves for smoother display, train tiling, inclination on slopes )
- Replace the world fundament drawing part of the algorithm with a 3D (perspective) world, it needs memory paging or we'll reach the 2Gb limit easy.
- Figure a way to get rid of the trees so they don't punish performance, LOD levels will be necessary.
- replacing vehicles with 3D models
- replacing buildings with 3D objects.

O01eg

I've fixed yet some error but one cann't be fiexd:

simgraphogre.cc: In function 'void display_img_pc(KOORD_VAL, KOORD_VAL, KOORD_VAL, const PIXVAL*)':
simgraphogre.cc:1769:16: error: 'textur' was not declared in this scope
simgraphogre.cc:1769:30: error: 'rowpitch' was not declared in this scope


How can it be compilable even under Windows?

Markohs

Comment out the whole function body. Have in mind that code is not complete and only the display_img_aux function is implemeted using ogre.

Just implementing that, showed the perfromance was not acceptable, and a new approach, requiring imagesets, is necessary.

The textur pointer is gone, since there is not any buffer there.

That code lacks code for display_color_img,display_rezoomed_img_blend,display_base_img and display_base_img_blend

Ashley

Once I get the Quartz frontend working I'll work next on making a Quartz + OpenGL version too, since this would be complimentary. I'm still seeing all sorts of random crashes which I don't think are from my additions though.
Use Firefox? Interested in IPv6? Try SixOrNot the IPv6 status indicator for Firefox.
Why not try playing Simutrans online? See the Game Servers board for details.

O01eg

All compiles but doesn't link.

$ grep -n -R "set_3d_map" *
sim3d/sim3dmap.cc:48: welt->set_3d_map(this);
simworld.h:1084: void set_3d_map(sim_3d_map* sim3dmapin);


Did you forget commit changes to rep?

Markohs

I'll comit as soon as I arrive home, can't do it here. :)

References to sim3dmap.cc have to be removed atm, they are not needed now, I thought I removed them some days ago, I'll have it a look too.

About the OpenGL in quartz, it can be a good addition, I don't think you'll have much problems integrating it. :)

Markohs

Applied your patch, 001eg, with some minor modifications

O01eg


build/default/simgraphogre.o:(.data+0x8): multiple definition of `large_font_height'
build/default/simgraphogre.o:(.data+0x8): first defined here
build/default/simgraphogre.o:(.data+0x18): multiple definition of `tile_raster_width'
build/default/simgraphogre.o:(.data+0x18): first defined here
build/default/simgraphogre.o:(.data+0x1a): multiple definition of `base_tile_raster_width'
build/default/simgraphogre.o:(.data+0x1a): first defined here
build/default/simgraphogre.o: In function `min':
/mnt/another/tmp/simutrans3d/simtypes.h:153: multiple definition of `display_normal'
build/default/simgraphogre.o:/mnt/another/tmp/simutrans3d/simtypes.h:153: first defined here


It's inconceivable.

Markohs

Might be related to the Makefile including in SOURCES simgraphogre 2 times:

line 367:

ifeq ($(BACKEND),ogre)
  SOURCES += simgraphogre.cc
else
  SOURCES += simgraph$(COLOUR_DEPTH).cc
endif

and line 479:

  SOURCES += simgraphogre.cc

  Updated the svn. Have in mind, 001eg, as I told you already I never compiled that in linux (I build it with visual studio 2010), and code is work in progress.

O01eg

Can you also rename *.cpp to *.cc because Makefile doesn't support .cpp extension?

Markohs


O01eg

I've fixed last error. Now it compiles. It's possible to remove sim3dmap.* and sim3dwin.*

I copy sim from build/default/ to simutrans/ folder. Whet I run its I get error:


terminate called after throwing an instance of 'Ogre::FileNotFoundException'
  what():  OGRE EXCEPTION(6:FileNotFoundException): 'resources.cfg' file not found! in ConfigFile::load at /tmp/portage/dev-games/ogre-1.7.3/work/ogre_src_v1-7-3/OgreMain/src/OgreConfigFile.cpp (line 83)

Markohs

You need a media folder on simutrans folder, use this one: http://dl.dropbox.com/u/30024783/media.zip

O01eg

Fixes for rev5398. Don't use \ in include path. Types for functions' arguments must be equal in declaration and implementation. bool and int are different types. Don't use int for logical variables.

Errors in gui_templated/pakselector.cc:

gui_templated/pakselector.cc: In member function 'void pakselector_t::fill_list()':
gui_templated/pakselector.cc:123:22: error: aggregate 'pakselector_t::fill_list()::_finddata_t entry' has incomplete type and cannot be defined
gui_templated/pakselector.cc:126:42: error: '_findfirst' was not declared in this scope
gui_templated/pakselector.cc:135:25: error: '_A_SUBDIR' was not declared in this scope
gui_templated/pakselector.cc:149:35: error: '_findnext' was not declared in this scope
gui_templated/pakselector.cc:151:19: error: '_findclose' was not declared in this scope
make: *** [build/default/gui_templated/pakselector.o] Error 1


Also media.zip doesn't contain resources.cfg.

Markohs

 Thank you for your comments and patches, 001eg, just applied your patch.

Yes, I know pakselector.cc doesn't work in linux atm, I first want to make a working windows code and solve how will I manage the event handling, that's unclear to me yet. That code it's based in gui/savegame_frame.cc, there is the non visualc code too.

Right now I'm not coding anything ogre related, my focus is the CEGUI version, but you can use a resources.cfg like this one:


[General]
FileSystem=media/materials/scripts
FileSystem=media/materials/textures
FileSystem=media/materials/textures/nvidia
FileSystem=media/models


plugins.cfg:


# Defines plugins to load

# Define plugin folder
PluginFolder=.

# Define plugins
# Plugin=RenderSystem_Direct3D9
# Plugin=RenderSystem_Direct3D10
# Plugin=RenderSystem_Direct3D11
Plugin=RenderSystem_GL

O01eg

Quote from: Markohs on February 20, 2012, 02:19:56 PM
Yes, I know pakselector.cc doesn't work in linux atm, I first want to make a working windows code and solve how will I manage the event handling, that's unclear to me yet. That code it's based in gui/savegame_frame.cc, there is the non visualc code too.

Why do not you use code for searching files from trunk? It works both under Linux and Windows. It's need to change gui related stuff to CEGUI.

Markohs


missingpiece

Just wanted to give a shout out to the brave coders in this thread hacking on the 3D version. You have my compassion. Looking forward to anything presentable.

Markohs

There is indeed a lot of code to be done still.

O01eg

Fixes for simutrans3d branch:

Index: Makefile
===================================================================
--- Makefile (revision 5610)
+++ Makefile (working copy)
@@ -477,7 +477,14 @@
   SOURCES += music/no_midi.cc
   SOURCES += sound/no_sound.cc
   CFLAGS += $(shell pkg-config --cflags OIS)
+  CFLAGS += $(shell pkg-config --cflags CEGUI)
+  CFLAGS += $(shell pkg-config --cflags CEGUI-OPENGL)
+  CFLAGS += $(shell pkg-config --cflags sdl)
+  CFLAGS += -DSIM_CEGUI
   LIBS += $(shell pkg-config --libs OIS)
+  LIBS += $(shell pkg-config --libs CEGUI)
+  LIBS += $(shell pkg-config --libs CEGUI-OPENGL)
+  LIBS += $(shell pkg-config --libs sdl)
endif


Index: simsys_cegui.cc
===================================================================
--- simsys_cegui.cc (revision 5610)
+++ simsys_cegui.cc (working copy)
@@ -21,8 +21,8 @@
#include <CEGUIScheme.h>
#include <CEGUIImage.h>

-#include <elements\CEGUIItemListbox.h>
-#include <elements\CEGUIItemEntry.h>
+#include <elements/CEGUIItemListbox.h>
+#include <elements/CEGUIItemEntry.h>

#include <GL/gl.h>
#include <GL/glext.h>


I can successfully compile sim with this patch but get this errors when try to run:

$ ./sim
Use work dir /mnt/another/tmp/simutrans3d/simutrans/
Reading low level config data ...
parse_simuconf() at config/simuconf.tab: Reading simuconf.tab successful!
Preparing display ...
Screen Flags: requested=12, actual=12
CEGUI::InvalidRequestException in file CEGUIDefaultResourceProvider.cpp(103) : DefaultResourceProvider::load: /mnt/another/tmp/simutrans3d/simutrans/./media/gui/imagesets/WindowsLook.png does not exist
DefaultResourceProvider::load: /mnt/another/tmp/simutrans3d/simutrans/./media/gui/imagesets/WindowsLook.png does not existLoading font 'font/prop.fnt'
font/prop.fnt successfully loaded as old format prop font!
Init done.
CEGUI::UnknownObjectException in file CEGUIWindowFactoryManager.cpp(180) : WindowFactoryManager::getFactory - A WindowFactory object, an alias, or mapping for 'WindowsLook/FrameWindow' Window objects is not registered with the system.
CEGUI::InvalidRequestException in file CEGUIGUILayout_xmlHandler.cpp(233) : GUILayout_xmlHandler::startElement - layout loading has been aborted since no WindowFactory is available for 'WindowsLook/FrameWindow' objects.
GUILayout_xmlHandler::startElement - layout loading has been aborted since no WindowFactory is available for 'WindowsLook/FrameWindow' objects.CEGUI::UnknownObjectException in file CEGUIWindowFactoryManager.cpp(180) : WindowFactoryManager::getFactory - A WindowFactory object, an alias, or mapping for 'WindowsLook/ListboxItemCustom' Window objects is not registered with the system.
CEGUI::InvalidRequestException in file CEGUIGUILayout_xmlHandler.cpp(233) : GUILayout_xmlHandler::startElement - layout loading has been aborted since no WindowFactory is available for 'WindowsLook/ListboxItemCustom' objects.
GUILayout_xmlHandler::startElement - layout loading has been aborted since no WindowFactory is available for 'WindowsLook/ListboxItemCustom' objects.


media/gui/imagesets/ contain only WindowsLook.imageset and WindowsLook.png doesn't exists anywhere.

Markohs

Yep that's because I've tried to upload it to svn and it rejects it, says it has no newline because it expects text, not binaries.

It also doesn't allow me to upload the .ttf. You can dowload here.

I plan spending more time with this this week again, I also got a working linux machine to test it there too, so soon I'll make a new release that will hopefully fix those things.

prissi

Then set teh appropriate properties for the thing in question. svn propset shoudl do this.

Markohs

Tried already to se their mime-tipe to binary, I desisted. :)