AccessViolationException was unhandled

Irrlicht.Net is no longer developed or supported, Irrlicht.Net Cross Platform is a much more complete wrapper. Please ask your C# related questions on their forums first.
Locked
cypher543
Posts: 78
Joined: Sat Apr 15, 2006 5:24 pm
Location: Missouri, USA
Contact:

AccessViolationException was unhandled

Post by cypher543 »

Alrighty, hello everyone. I'm working on a project called "The Cerberus Game Engine". Basically, I'm putting physics, scripting, ai, and audio together with Irrlicht. This is mostly just a hobby project. But I've got a problem...

First, here's the code in my CGEGraphics class (it handles Irrlicht):

Code: Select all

#Region "Namespace/Class Imports"
Imports Irrlicht
Imports Irrlicht.Video
Imports Irrlicht.Core
Imports Irrlicht.Scene
#End Region
Public Class CGEGraphics
#Region "Variable Definitions"
    Dim device As IrrlichtDevice
#End Region
#Region "Properties"
    Public WriteOnly Property WindowText()
        Set(ByVal value)
            device.WindowCaption = value
        End Set
    End Property
#End Region
    Public Sub New()
        Dim device As New IrrlichtDevice(Irrlicht.Video.DriverType.OPENGL)
    End Sub
    Public Sub StartRender()
        While device.Run() = True
            If device.WindowActive Then
                device.VideoDriver.BeginScene(True, True, New Color(0, 100, 100, 100))
                device.SceneManager.DrawAll()
            End If
        End While
    End Sub
End Class
I put that together in a hurry using the examples. But it looks like it should work. :(

Next, I made a little demo project to test everything. Here is the code for it:

Code: Select all

Imports CerberusEngine
Imports System.Threading
Module Module1
    Dim graphics As CGEGraphics
    Dim rndrThread As Thread
    Sub Main()
        graphics = New CGEGraphics
        rndrThread = New Thread(AddressOf graphics.StartRender)
    End Sub
End Module
But then it gives me: "Attempted to read or write protected memory. This is often an indication that other memory is corrupt."

What did I do wrong? (Also, if anyone is interested in this, you can contact me on yahoo or msn (nicknames in my profile). As you can see, I'm going to need some help) :P

Thanks!
Guest

Post by Guest »

if u would have searched the forum, the u would have found this thread, which is currently just 5 threads under your thread:

http://irrlicht.sourceforge.net/phpBB2/ ... php?t=8704
cypher543
Posts: 78
Joined: Sat Apr 15, 2006 5:24 pm
Location: Missouri, USA
Contact:

Post by cypher543 »

Thank you for pointing that out... unfortunately, it does not provide an answer to the problem. Also, I DID search the forum, and found nothing. So forgive me for not reading a few topics after I had already searched for it. I've been posting on forums for over 6 years... I think I would know to use the search function.
Guest

UsulSK

Post by Guest »

cypher543 wrote:Thank you for pointing that out... unfortunately, it does not provide an answer to the problem. Also, I DID search the forum, and found nothing. So forgive me for not reading a few topics after I had already searched for it. I've been posting on forums for over 6 years... I think I would know to use the search function.
lol. So you really searched the forum, found this thread, and ur question was not answered? Well, I had the same problem. I searched the forum. I found this thread (the link I posted above). And I found:
I get the same AccessViolation while exiting (OPENGL) or while calling SceneManager.DrawAll (SOFTWARE2). If I use DirectX 8/9 or Software, I don't get the exception .........
So the problem only occures with OPENGL. Why did I find this?
RapchikProgrammer
Posts: 279
Joined: Fri Dec 24, 2004 6:37 pm

Post by RapchikProgrammer »

I think the problem lies here:

Code: Select all

    Public Sub New() 
        Dim device As New IrrlichtDevice(Irrlicht.Video.DriverType.OPENGL) 
    End Sub 
dont declare dim device as new irrlichtdevice, this causes it to declare a local instance of device and not an instance of the global declared device. So use device = new IrrlichtDevice(Irrlicht.Video.DriverType.OPENGL) and it should work fine!
Locked