Jump to content
  • Advertisement
Sign in to follow this  
Kobayashi

OpenGL OpenGL + VBO + C#

This topic is 4172 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello everybody! I have problem with using OpenGL extension in C#. When i am using sth like this: gr.glGenBuffersARB(1, _terview._vertex_buffer); I get error : An unhandled exception of type 'System.NullReferenceException' occurred in Terrain Viewer.exe Additional information: Object reference not set to an instance of an object. In constructor of _terview class i have created an instance of _vertex_buffer: _vertex_buffer = new int[1]; So everything should be ok, but it isnt. If anyone can help me with this extensions i would be grateful:d

Share this post


Link to post
Share on other sites
Advertisement
I don't know C# ...

But you may check if:

- that extension is supported by your graphic card ?

- how you assign the glGenBufferARB function: how do you load the extension ? do you use a parser like glee or glew ( I don't know the C# version) ? Or do you have to do the assignment yourself ( gr.glGenBuffersARB = wglgetProcAddress ...) ?

Share this post


Link to post
Share on other sites
I am using class created by Colin Fahey, there is everything you need, and you neednt to worry about this stuff. Its just this error that i am concerned about.

Share this post


Link to post
Share on other sites
Its not about framework, i used CSGL liblary too, and this error exposed there too.
I will get close to You architecture of this app, so someone can see, maybe this is my error or sthg:

//class #1
class Terview
{
public CTerrain _terrain;
public GRControl _oglcontrol;
/........./
public Terview()
{
_terrain = new CTerrain();
GR gr = _oglcontrol.GetGR();

gr.glGenBuffersARB(1, _terview._vertex_buffer); //error!
/......./
}
/...../
}

//Class #2
public class CTerrain
{
public int[] _vertex_buffer;
/................/

public CTerrain()
{
_vertex_buffer = new int[1];
/..................../
}
/..................../
};

Share this post


Link to post
Share on other sites
Have you tried running it in the debugger to see where the null reference exception is being triggered from? From the provided source, it looks like you never set (or use) _oglcontrol.

Share this post


Link to post
Share on other sites
I finnally got it!
I step into

public void glGenBuffersARB ( int n, int[] buffers )
{
mDglGenBuffersARB_IaI( n, buffers ); //->> this is delegate that gives error
}
But i am still confused, is there something that can be done to avoid this error?
I guess i must read more about this new stuff in c#, but if anyone can point me how to avoid this error it could be great!

[Edited by - Kobayashi on May 22, 2007 11:35:50 AM]

Share this post


Link to post
Share on other sites
The problem is that your delegate is actually a wrapper around a pointer to the extension function, and is null.

There's two possible causes:

1) Your video card doesn't support this extension (so that the function that retrieves the pointer returns null).

2) The function isn't being setup, whether because of a bug in the code or because of a step you missed.

CSGL is pretty old. I'd switch to the tao framework, as snk_kid suggested.

Share this post


Link to post
Share on other sites
I am not using CSGL only Colin Fahey class - CPF.GRV10.GRControl.cs.

And i figure it out now : i am using extension inside a delegate function:

_oglcontrol.OpenGLStarted += new GRControl.DelegateOpenGLStarted(this.OpenGLStarted);

I am using extension in
OpenGLStarted function and everything is ok now, but thnx anyway.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!