Results 1 to 8 of 8

Thread: C# and volume render with glTexImage3D

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2009
    Posts
    10

    C# and volume render with glTexImage3D

    Hi

    Can anyone provide me with any example of volume rendering in C# using glTexImage3D method? I've tried to do it myself, but stucked with exception, that nothing says to me...

    I'm using Visual Studio 2008 (Windows XP), tried Tao, csgl and NeHe codes...
    I'm sure to have support of volume render. My video card is nVidia Quadro FX 1600M.

    I found the http://gpwiki.org/index.php/OpenGL:T...ls:3D_Textures , which is something I need, but I couldn't rewrite it to C#...

    I'd be really grateful for any help.

    PS.

    Hello to everyone!
    My cat has ADHD.... -.-'

  2. #2
    Senior Member Regular Contributor
    Join Date
    Mar 2007
    Location
    Latvia
    Posts
    225

    Re: C# and volume render with glTexImage3D

    With what kind an exception do you have stucked? And on what code?

  3. #3
    Junior Member Newbie
    Join Date
    Jan 2009
    Posts
    10

    Re: C# and volume render with glTexImage3D

    Exception:
    Code :
    System.Reflection.TargetInvocationException was unhandled
      Message="Obiekt docelowy wywołania zgłosił wyjątek."
      Source="mscorlib"
      StackTrace:
           w System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
           w System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
           w System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
           w System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
           w System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
           w System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args)
           w NeHe.NeHe.SelectExample() w C:\Program Files\TaoFramework\source\examples\NeHe\NeHe.cs:wiersz 73
           w NeHe.NeHe.lstExamples_SelectedIndexChanged(Object sender, EventArgs e) w C:\Program Files\TaoFramework\source\examples\NeHe\NeHe.cs:wiersz 79
           w System.Windows.Forms.Control.OnDoubleClick(EventArgs e)
           w System.Windows.Forms.ListBox.WndProc(Message& m)
           w System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
           w System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
           w System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
           w System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
           w System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
           w System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
           w System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
           w System.Windows.Forms.Application.Run(Form mainForm)
           w NeHe.Program.Main() w C:\Program Files\TaoFramework\source\examples\NeHe\Program.cs:wiersz 44
           w System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
           w System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
           w Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
           w System.Threading.ThreadHelper.ThreadStart_Context(Object state)
           w System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
           w System.Threading.ThreadHelper.ThreadStart()
      InnerException: 
           Message="BŁĄD!\r\n   w Tao.OpenGl.Gl.Imports.ActiveTexture(Int32 texture)\r\n   w Tao.OpenGl.Gl.glActiveTexture(Int32 texture)\r\n   w NeHe.Lesson05.build_texture() w C:\\Program Files\\TaoFramework\\source\\examples\\NeHe\\Lesson05.cs:wiersz 460"
           Source="NeHe"
           StackTrace:
                w NeHe.Lesson05.build_texture() w C:\Program Files\TaoFramework\source\examples\NeHe\Lesson05.cs:wiersz 476
                w NeHe.Lesson05.InitGL() w C:\Program Files\TaoFramework\source\examples\NeHe\Lesson05.cs:wiersz 420
                w NeHe.Lesson05.CreateGLWindow(String title, Int32 width, Int32 height, Int32 bits, Boolean fullscreenflag) w C:\Program Files\TaoFramework\source\examples\NeHe\Lesson05.cs:wiersz 317
                w NeHe.Lesson05.Run() w C:\Program Files\TaoFramework\source\examples\NeHe\Lesson05.cs:wiersz 136
           InnerException:
    I was editing some NeHe tutorials.
    Message = "Target object of the call throws an exception"

    Debugger report it here:
    Code :
    private void SelectExample()
            {
                if (lstExamples.SelectedItem != null)
                {
                    Type example = Assembly.GetExecutingAssembly().GetType("NeHe." + lstExamples.SelectedItem.ToString(), true, true);
                    example.InvokeMember("Run", BindingFlags.InvokeMethod, null, null, null); /*Highlighted by debugger*/
                }
            }
    but after investigation I found that problem is line when i try to generate texture3d:
    Code :
    Gl.glTexImage3D(Gl.GL_TEXTURE_3D, 0, (int)Gl.GL_RGB8, 1, 1, 1, 1, Gl.GL_BGR_EXT, Gl.GL_UNSIGNED_BYTE, IntPtr.Zero);
    I hope all parameters are alright... Otherwise exception would point it.

    But anyway I would prefer just a simple example of glTexImage3D.

    Thanks for replying!
    My cat has ADHD.... -.-'

  4. #4
    Senior Member Regular Contributor
    Join Date
    Mar 2007
    Location
    Latvia
    Posts
    225

    Re: C# and volume render with glTexImage3D

    Are you sure it is glTexImage3D which is guilty?
    Your exception has following information on InnerException member:
    Code :
           Message="BŁĄD!\r\n   w Tao.OpenGl.Gl.Imports.ActiveTexture(Int32 texture)\r\n   w Tao.OpenGl.Gl.glActiveTexture(Int32 texture)\r\n   w NeHe.Lesson05.build_texture() w C:\\Program Files\\TaoFramework\\source\\examples\\NeHe\\Lesson05.cs:wiersz 460"
           Source="NeHe"
           StackTrace:
                w NeHe.Lesson05.build_texture() w C:\Program Files\TaoFramework\source\examples\NeHe\Lesson05.cs:wiersz 476
    What is on 476 line in Lesson05.cs ?
    I think you have there some problem with glActiveTexture call.

  5. #5
    Junior Member Newbie
    Join Date
    Jan 2009
    Posts
    10

    Re: C# and volume render with glTexImage3D

    Oh.. sorry.. I'v been doing some changes and put wrong exception stack trace.. :stupid:

    This one comes exacly when I uncomment the line with glTexImage3D
    Code :
    System.Reflection.TargetInvocationException was unhandled
      Message="Obiekt docelowy wywołania zgłosił wyjątek."
      Source="mscorlib"
      StackTrace:
           w System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
           w System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
           w System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
           w System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
           w System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
           w System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args)
           w NeHe.NeHe.SelectExample() w C:\Program Files\TaoFramework\source\examples\NeHe\NeHe.cs:wiersz 73
           w NeHe.NeHe.lstExamples_SelectedIndexChanged(Object sender, EventArgs e) w C:\Program Files\TaoFramework\source\examples\NeHe\NeHe.cs:wiersz 79
           w System.Windows.Forms.Control.OnDoubleClick(EventArgs e)
           w System.Windows.Forms.ListBox.WndProc(Message& m)
           w System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
           w System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
           w System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
           w System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
           w System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
           w System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
           w System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
           w System.Windows.Forms.Application.Run(Form mainForm)
           w NeHe.Program.Main() w C:\Program Files\TaoFramework\source\examples\NeHe\Program.cs:wiersz 44
           w System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
           w System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
           w Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
           w System.Threading.ThreadHelper.ThreadStart_Context(Object state)
           w System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
           w System.Threading.ThreadHelper.ThreadStart()
      InnerException: 
           Message="BŁĄD!\r\n   w Tao.OpenGl.Gl.Imports.TexImage3D(Int32 target, Int32 level, Int32 internalformat, Int32 width, Int32 height, Int32 depth, Int32 border, Int32 format, Int32 type, IntPtr pixels)\r\n   w Tao.OpenGl.Gl.glTexImage3D(Int32 target, Int32 level, Int32 internalformat, Int32 width, Int32 height, Int32 depth, Int32 border, Int32 format, Int32 type, IntPtr pixels)\r\n   w NeHe.Lesson05.build_texture() w C:\\Program Files\\TaoFramework\\source\\examples\\NeHe\\Lesson05.cs:wiersz 461"
           Source="NeHe"
           StackTrace:
                w NeHe.Lesson05.build_texture() w C:\Program Files\TaoFramework\source\examples\NeHe\Lesson05.cs:wiersz 476
                w NeHe.Lesson05.InitGL() w C:\Program Files\TaoFramework\source\examples\NeHe\Lesson05.cs:wiersz 420
                w NeHe.Lesson05.CreateGLWindow(String title, Int32 width, Int32 height, Int32 bits, Boolean fullscreenflag) w C:\Program Files\TaoFramework\source\examples\NeHe\Lesson05.cs:wiersz 317
                w NeHe.Lesson05.Run() w C:\Program Files\TaoFramework\source\examples\NeHe\Lesson05.cs:wiersz 136
           InnerException:

    Realy noone have done some 3d texturing??
    My cat has ADHD.... -.-'

  6. #6
    Junior Member Newbie
    Join Date
    Jan 2009
    Posts
    10

    Re: C# and volume render with glTexImage3D

    OK, I manage to compile program with TexImage3D in C++, but I realy hope somehow it's possible also in C#. Any ideas?

    Maybe the problem is the last parameter, texel data, IntPtr pixels? But would it throw different exception?
    My cat has ADHD.... -.-'

  7. #7
    Senior Member OpenGL Pro
    Join Date
    Sep 2004
    Location
    Prombaatu
    Posts
    1,386

    Re: C# and volume render with glTexImage3D

    Sorry, szamil, but what was your question again?

    There's lots of info on interop marshaling in the MSDN docs if you're having trouble in that area. There are also several open source .NET libraries that wrap all this stuff up for you, like Tao.

  8. #8
    Senior Member Regular Contributor
    Join Date
    Jun 2009
    Posts
    357

    Re: C# and volume render with glTexImage3D

    Make sure you are using the latest version of Tao.OpenGl.dll (2.1.0.12, IIRC), because older ones didn't marshal TexImage3D correctly.
    [The Open Toolkit library: C# OpenGL 4.4, OpenGL ES 3.1, OpenAL 1.1 for Mono/.Net]

Similar Threads

  1. Replies: 3
    Last Post: 03-11-2015, 06:17 PM
  2. About large volume render ---Bricking
    By spring in forum OpenGL: GLSL
    Replies: 1
    Last Post: 07-12-2006, 04:35 PM
  3. Render to volume textures
    By jonasmr in forum OpenGL: Advanced Coding
    Replies: 8
    Last Post: 03-21-2005, 02:17 PM
  4. Volume Render
    By giado in forum OpenGL: Windows
    Replies: 4
    Last Post: 12-14-2004, 12:47 PM
  5. How to determine the render volume?
    By jrbcast in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 11-26-2001, 09:24 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean