Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - dabbertorres

Pages: 1 ... 10 11 [12] 13 14 ... 34
166
DotNet / Re: OpenTK and SFML
« on: May 19, 2016, 09:53:27 am »
Well huh. Of course it wasn't that easy. Very odd that it seems to vary by computer too. Have you put a breakpoint on those lines? Can you determine which function call causes the issue? I'm wondering if it's a race condition. Or varies by graphics hardware/driver.

What graphics card and driver are you running this on?

Also, what OpenTK dlls are you using? I was testing with the dlls distributed with SFML.NET.

167
DotNet / Re: OpenTK and SFML
« on: May 18, 2016, 11:41:14 pm »
Alright, I got it working over here.

(click to show/hide)

Two things:
You were having two contexts: one from SFML, and the one you created with OpenTK. Apparently, passing ContextHandle.Zero to the GraphicsContext constructor makes OpenTK find the already-existing context (from SFML in this case). A little nicer than manually doing so with a P/Invoke to wglGetCurrentContext (What I did in the first place!). I'm not certain if this was the issue (or part of it), but I could see it potentially causing complications in the future.

The part I am certain was at least part of the issue was coming from your cube's vertex buffer still being bound when SFML tries to draw. I haven't ever dug through enough of SFML's internals to know what it does that would make this an issue, but, in the future, make sure to unbind your buffers (pass 0 as the buffer id for glBindBuffer) before drawing with SFML (and can be a good thing to do anyways).

Beyond that, I think that was all I changed!

PS: You can also move your projection and view matrix code out of your while loop, and before it now, if you wish:
(click to show/hide)

168
DotNet / Re: OpenTK and SFML
« on: May 17, 2016, 06:17:24 am »
Hmm. That sounds like states or matrices being changed... Oh. What happens if you add your
            GL.MatrixMode(MatrixMode.Modelview);
            GL.Translate(0, 0, -4);
before your GL.Rotate() in your while loop?

If that doesn't fix anything, can you post the current code?

(Sorry for the laggy responses, I only have time to check the forums between classes and work. :) )

169
DotNet / Re: OpenTK and SFML
« on: May 16, 2016, 10:12:24 pm »
I don't think you should be calling glEnd() at all. Especially since you don't even call glBegin() anywhere. glBegin() and glEnd() are for defining single vertices to draw together.

And I believe you need a call to glClear() before drawing anything (glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) usually suffices).

170
DotNet / Re: OpenTK and SFML
« on: May 16, 2016, 05:12:10 pm »
You're forgetting to change MatrixMode to Projection in win.Resized. Right now, your Resized event is setting the View matrix.

171
Hehe, I don't blame you! At least it's fun to experiment with different solutions. :D

172
Ah yes, I forgot about a few of those odd static initialization rules, especially with templates.

I got something working though:
(click to show/hide)

Basically, two things are required: an out-of-class provision of Meta<T>::metaBuilder, and a (non-) use of the member. (Above, in Meta<T>::doWork()). Basically, for the compiler/runtime to decide for it to be statically initialized as desired, it must be directly accessed. Plain-Old-Data types don't have this restriction. Kinda weird. But it works, and it's not even that much work.

tl;dr: The above code will have T::registerClass() called for any class used as Meta<T>'s template parameter.

EDIT: Test::registered was just for testing, it wouldn't ever actually be needed, as it will always be true.

So, we came to quite similar conclusions. The constructor being called when desired is the only difference!

173
1) How should I handle error handling? Should I throw exceptions? I want to be able to write error messages like this: "Error: Animation::name should be string, but int was passed" if JSON is incorrect. Should serialize/deserialize throw exceptions like this? (Right now I only return true if deserialization was successful and false otherwise... which is not great, of course!), or maybe there are other ways to handle errors... (Silently ignoring them is not the way!)

I think this is a good use of exceptions.
I usually throw the exception with the error message, catch the exceptions in the caller, and then log the message (plus anything else I find necessary) from there.

2) Is there any reliable way to create function for template class which will be called on template class instantiation?  Is such thing possible? How can I achieve it and be sure that static members are initialized at the point the function is called?
For example, I write this function:
void Animation::registerClass(MetaBuilder<Animation>& builder)
and I want it to be called automatically by Meta<Animation> class. I want this to be called automatically because of Meta<T> instantiation:
Meta<T>::init() {
    T::registerClass(MetaBuilder<T>());
}

If I am understanding what you want to do correctly, I think you could add a static MetaBuilder<T> member to Meta<T>. And then, in the constructor of MetaBuilder<T>, call T::registerClass(*this)

template<typename T>
class MetaBuilder
{
        public:
                MetaBuilder()
                {
                        T::registerClass(*this);
                }
};

template<typename T>
class Meta
{
        static MetaBuilder<T> metaBuilder;
};

 

Also, it looks like this would be more standard C++. It looks like you're passing a temporary to a non-const reference parameter, which is a VC++ extension.

174
General discussions / Re: Question In Regards to Crediting SFML
« on: April 16, 2016, 02:25:48 am »
That is not required, but is appreciated.

175
General / Re: Sprite rotation
« on: April 10, 2016, 03:46:17 am »
It's even easier than rectangles.

Think about how the size of a circle is determined. From there, can you figure out if a point is inside of or outside of the circle?

With the ship and the bullet, you know positions, and once you decide on a max distance from the ship for the bullet, you also know that.

176
General / Re: Need help to connect OpenGl project with SFML
« on: April 08, 2016, 07:09:34 pm »
If you got the same exact error message, then I don't think you installed the correct driver.

What graphics card are you using, and what driver did you install?

If I understand correctly, the above OpenGL/glut sample separately works, and the above SFML sample separately does not work. Am I correct? They are two separate programs?

177
General / Re: Need help to connect OpenGl project with SFML
« on: April 08, 2016, 05:52:50 am »
Looks like you don't have a proper driver for your graphics card installed.

Your basic OpenGL project works because you're using the version supported by MS's OpenGL driver (1.1 iirc).

SFML version isn't working because it needs a more recent version (I can't remember the specific version) or vendor-specific extensions not offered by the MS driver.

178
Feature requests / Re: Add support for Opus audio
« on: April 01, 2016, 08:00:24 pm »
Looks like OP is working on it. So he may be planning on submitting a PR.

179
SFML projects / Re: Amsale
« on: March 26, 2016, 08:37:11 pm »
You want to read this. It'll fix the problem you mentioned, and allow faster machines to not be a waste.

180
Window / Re: Interprocess Comunication (SendMessage / GetMessage)
« on: March 23, 2016, 02:53:32 am »
SystemHandle (.NET binding since you mentioned it and C#) is what you need from SFML. Implementing the actual communication is up to you.

If you're comfortable with a bit of C++, Boost.Interprocess should make shared memory easier. If you're wanting to do the main application in C#, writing a wrapper to call the C++ dll isn't difficult at all.

Pages: 1 ... 10 11 [12] 13 14 ... 34