-
-
Notifications
You must be signed in to change notification settings - Fork 984
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
191 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
find_package(SWIG 3.0.8) | ||
|
||
if(NOT SWIG_FOUND) | ||
set(OGRE_BUILD_COMPONENT_CSHARP OFF CACHE BOOL "" FORCE) | ||
message(WARNING "Csharp Component disabled because SWIG or Csharp was not found") | ||
return() | ||
endif() | ||
|
||
include_directories("${PROJECT_BINARY_DIR}/include" "${PROJECT_SOURCE_DIR}/OgreMain/include") | ||
include(${SWIG_USE_FILE}) | ||
|
||
if(MSVC) | ||
# TODO: Set MSVC flags | ||
add_definitions(-DMS_NO_COREDLL) | ||
else() | ||
add_definitions(-Wno-strict-aliasing -Wno-cast-qual -Wno-shadow -Wno-missing-declarations) | ||
endif() | ||
|
||
set(CMAKE_SWIG_FLAGS -w401,314 -namespace org.ogre) | ||
|
||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/csharp/") | ||
set(CMAKE_SWIG_OUTDIR "${PROJECT_BINARY_DIR}/csharp/") | ||
|
||
set_source_files_properties(../../OgreMain/include/Ogre.i PROPERTIES CPLUSPLUS ON) | ||
set(SWIG_INPUT_MODULES ../../OgreMain/include/Ogre.i) | ||
|
||
if(OGRE_BUILD_COMPONENT_RTSHADERSYSTEM) | ||
set_source_files_properties(../RTShaderSystem/include/OgreRTShader.i PROPERTIES CPLUSPLUS ON) | ||
list(APPEND SWIG_INPUT_MODULES ../RTShaderSystem/include/OgreRTShader.i) | ||
endif() | ||
|
||
if(OGRE_BUILD_COMPONENT_OVERLAY) | ||
set_source_files_properties(../Overlay/include/OgreOverlay.i PROPERTIES CPLUSPLUS ON) | ||
list(APPEND SWIG_INPUT_MODULES ../Overlay/include/OgreOverlay.i) | ||
endif() | ||
|
||
if(OGRE_BUILD_COMPONENT_BITES) | ||
if(SDL2_FOUND) | ||
include_directories(${SDL2_INCLUDE_DIR}) | ||
endif() | ||
|
||
set_source_files_properties(../Bites/include/OgreBites.i PROPERTIES CPLUSPLUS ON) | ||
list(APPEND SWIG_INPUT_MODULES ../Bites/include/OgreBites.i) | ||
endif() | ||
|
||
swig_add_module(libOgre csharp ${SWIG_INPUT_MODULES}) | ||
SWIG_LINK_LIBRARIES(libOgre OgreBites OgreOverlay OgreRTShaderSystem OgreMain) | ||
install(TARGETS ${SWIG_MODULE_libOgre_REAL_NAME} LIBRARY DESTINATION lib/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Build instructions for Mono on Ubuntu | ||
|
||
1. inside `build/csharp/` | ||
``` | ||
mcs -target:library -out:Ogre.dll *.cs | ||
``` | ||
2. copy `Ogre.dll` and `libOgre.so` to current directory | ||
3. compile the sample | ||
``` | ||
mcs example.cs -r:Ogre.dll | ||
``` | ||
4. copy `build/bin/resources.cfg` to current directory | ||
5. to start the sample run | ||
``` | ||
mono example.exe | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
using org.ogre; | ||
|
||
public class KeyListener : InputListener | ||
{ | ||
ApplicationContext ctx; | ||
|
||
public KeyListener(ApplicationContext ctx) | ||
{ | ||
this.ctx = ctx; | ||
} | ||
|
||
public override bool keyPressed(KeyboardEvent evt) | ||
{ | ||
if (evt.keysym.sym == 27) | ||
ctx.getRoot().queueEndRendering(); | ||
return true; | ||
} | ||
} | ||
|
||
public class Example : ApplicationContext | ||
{ | ||
InputListener listener; | ||
|
||
public Example() | ||
{ | ||
listener = new KeyListener(this); | ||
} | ||
|
||
public override void setup() | ||
{ | ||
base.setup(); | ||
addInputListener(listener); | ||
|
||
var root = getRoot(); | ||
var scnMgr = root.createSceneManager(); | ||
|
||
var shadergen = ShaderGenerator.getSingleton(); | ||
shadergen.addSceneManager(scnMgr); // must be done before we do anything with the scene | ||
|
||
scnMgr.setAmbientLight(new ColourValue(.1f, .1f, .1f)); | ||
|
||
var light = scnMgr.createLight("MainLight"); | ||
var lightnode = scnMgr.getRootSceneNode().createChildSceneNode(); | ||
lightnode.setPosition(0f, 10f, 15f); | ||
lightnode.attachObject(light); | ||
|
||
var cam = scnMgr.createCamera("myCam"); | ||
cam.setAutoAspectRatio(true); | ||
cam.setNearClipDistance(5); | ||
var camnode = scnMgr.getRootSceneNode().createChildSceneNode(); | ||
camnode.attachObject(cam); | ||
|
||
var camman = new CameraMan(camnode); | ||
camman.setStyle(CameraStyle.CS_ORBIT); | ||
camman.setYawPitchDist(new Radian(0), new Radian(0.3f), 15f); | ||
addInputListener(camman); | ||
|
||
var vp = getRenderWindow().addViewport(cam); | ||
vp.setBackgroundColour(new ColourValue(.3f, .3f, .3f)); | ||
|
||
var ent = scnMgr.createEntity("Sinbad.mesh"); | ||
var node = scnMgr.getRootSceneNode().createChildSceneNode(); | ||
node.attachObject(ent); | ||
} | ||
|
||
static void Main() | ||
{ | ||
var app = new Example(); | ||
app.initApp(); | ||
app.getRoot().startRendering(); | ||
app.closeApp(); | ||
} | ||
} |