Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
PnP Bios
Oct 24, 2005
optional; no images are allowed, only text
If people are still interested in doing 2D with OpenGL, I wrote a pretty good C library for doing so. It can be downloaded at http://joel.slylabs.com/?q=node/4 . The documentation is here http://joel.slylabs.com/?q=node/12 , and a tutorial for getting it set up with SDL can be found here http://joel.slylabs.com/?q=node/14 .

I even used it for my final graphics project.

Adbot
ADBOT LOVES YOU

PnP Bios
Oct 24, 2005
optional; no images are allowed, only text

pianoSpleen posted:

A lot of stuff is really poorly explained and there's no logical progression to the tutorials past the first few. There wasn't, for example, a useful tutorial about things like vectors/matrices. Instead there was suddenly some fancy effect that needed an understanding of them and almost no explanation of what was going on that someone who didn't have an understanding of vectors would be able to make sense of. To be honest, past about tutorial 20 it's more like a parade of demos combined with "Look at me! I can prove I wrote it!" than an attempt to teach you what you need to know.

Also almost all the tutorials are written in straight C and very poorly organised. You cannot write code like that in a real game - game engines are large things and need reasonably good design. Some of the techniques are also largely obsolete and a lot of important stuff (mostly the stuff that can't be used to make a prettier demo) isn't covered.

//Every Single Comment In Every Single Program Is Written Like This For Some Reason, Which As You Can See Is Not Only Unbelievably Obnoxious But Is Also A Neat Hint As To When People Have Copy-Pasted From That Site.

I kept an old version of my first serious attempt at writing a game around purely so I can scare people off NeHe tutorials and Sams books for life. I'll have to dig it up and post it sometime, there's comedy gold in there.

The Red Book is DEFINITELY worth buying as a reference, but it's a bit too heavy for learning the basics. If you have a half-decent DirectX background you'll find a lot of the concepts map to OpenGL quite easily.

Ages ago someone gave me a GameTutorials CD; I skimmed over some of it and it looks a lot better than NeHe's stuff - one of the most complex tutorials has a full BSP renderer, lightmaps, collision detection and all. They cost money though, so I'd wait for someone else to look through it properly before putting down cash.

Game Tutorials is crap, at least when they were free it was. It just gives you a folder full of source files, with no clear reading direction, and the 'tutorial' was comments in the source. I would definitely recommend not spending money on them.

PnP Bios
Oct 24, 2005
optional; no images are allowed, only text
Mr. Dog, it's because your program is using PeekMessage instead of WaitMessage. Instead of waiting for input, you are polling for it, which means your program is going to cycle through regardless of what's in the message, so your process running at 100% is perfectly normal.

If CPU usage is that important to you, you may consider using waitMessage, and periodically forcing the window invalidation and using that as an indication as when to redraw the window.

PnP Bios
Oct 24, 2005
optional; no images are allowed, only text

TSDK posted:

No it's not. Using present parameters of either ONE or DEFAULT should be causing the loop to sync with the refresh rate of the monitor. If it's not, then either the window is minimised, or (another random thought) the drivers have been told to ignore vsync.

Unless you're writing a turn based non-realtime game, using WaitMessage in a game loop is mostly retarded.

He was worried about it running at 100%. Anything polling the event loop is going to be running at 100%. I agree about using WaitMessage being mostly retarded, but that's a way to make it not run at 100%.

PnP Bios
Oct 24, 2005
optional; no images are allowed, only text
http://www.devmaster.net/news/index.php?storyid=2062

Truespace 7.6 is now free. This is good news for those of us who can't wrap our heads around blender.

PnP Bios
Oct 24, 2005
optional; no images are allowed, only text

not a dinosaur posted:

I left something out- before doing glTexImage2D, you need to call glPixelStorei

code:
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
Which tells OpenGL that your pixel data is byte-aligned (as opposed to word-aligned which I believe is the default). Otherwise, you'll probably have a segfault or something because glTexImage2D will try to read four times the data you actually have.

I think it's a few pages back now, but we do have an OpenGL thread here in CoC. People there will be much better at answering your questions.

You don't need glPixelStorei. And technically, shouldn't he be using PBO's :P

PnP Bios
Oct 24, 2005
optional; no images are allowed, only text

Pfhreak posted:

It's on my old rear end laptop, with no video card, and 1 gig of ram for Vista, my video card, and all my other applications. Even then, it runs it pretty solid at 40 frames per second or so when I'm drawing a 40x40 grid. On average, each cell draws ~2-3 blocks and a shadow. So that's 5600 quads roughly, and I don't know how much of a performance hit using managed code brings.

I am smart about only drawing the tiles that intersect with my viewable area. (I use a division and a mod to determine this, then just count N cells to the right and down.) I've got plenty of early outs for preventing draws.

My desktop runs it fine, but I'm interested in learning some new techniques and ways of organizing things in a more efficient manner. Knowing how to make XNA put a sprite on screen is one thing -- knowing what other tools I have access to is another.

How are you drawing your sprite batch? The biggest hit you can take is when you change textures. The standard method is deferred, which does no sorting, try using textured instead.

http://msdn.microsoft.com/en-us/library/bb195102.aspx -- SpriteBatch.Begin
http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.spritesortmode.aspx -- SpriteSortMode

PnP Bios
Oct 24, 2005
optional; no images are allowed, only text

Contero posted:

What is a commonly used file format for game models? What's one that wouldn't be mind numbingly hard to create an implementation for? What I'm looking for:

-Ascii format and at least somewhat human readable
-Animation and texture map support
-Easily exported from maya or blender

Right now I'm looking at MD5, but the exporters for blender are either bizarre or badly implemented and I haven't looked much at the maya ones. I want to know if there is some alternative model format that I've been overlooking.

OBJ is basically the BMP format for models. It's Ascii and easy to parse, there's no built-in animation support, but blender can export each keyframe as an individual file. It supports grouping, normals, materials, UV texture coordinate mapping, etc.

PnP Bios
Oct 24, 2005
optional; no images are allowed, only text
If you want to do stuff in .NET but don't like XNA for whatever reason, and can't stand Tao.NET, there is OpenTK, which is a quite nice light weight toolkit.

http://www.opentk.com/

This one is nice because it's actively being developed. It also works hard to be more than just a managed API wrapper. Works great in mono and .net!

PnP Bios
Oct 24, 2005
optional; no images are allowed, only text
Is there any scripting engine for .net? I'd like to be able to use some ECMA or python in a game I'm working on.

PnP Bios
Oct 24, 2005
optional; no images are allowed, only text
wow. boo looks great. Thanks!

PnP Bios
Oct 24, 2005
optional; no images are allowed, only text

GuyGizmo posted:

I'm also looking for a game engine recommendation.

I'm looking for a good, preferably cross-platform, and preferably free engine that can be used for 2D or 2.5D games (and in this case, 2.5D means a 2D game rendered with 3D graphics, to some extent). I've already explored XNA, and the problem is that it's not powerful enough for what I want to do. Essentially, I'm looking to make a game with music synchronization of user events, much like Rez or Lumines, and unfortunately XNA doesn't have enough low level control of audio to do what I need.

My guess is I might just need to resort to DirectX, or if I want cross platform OpenGL and some cross-platform audio library (like OpenAL maybe?), but having a game engine that simplifies things would be awesome. Any good suggestions?

Take a look at OpenTK. http://opentk.org/project/opentk
It has direct bindings to OpenAL, and is probably the best OpenGL wrapper available.

PnP Bios
Oct 24, 2005
optional; no images are allowed, only text

UberJumper posted:

What is the standard for 3d Models? Or do most engines just use their own internal format?

Most engines have their own internal formats. The easiest to get started with is probably Waveform OBJ files. They are pretty simple to parse.

PnP Bios
Oct 24, 2005
optional; no images are allowed, only text
It's close to being finished, but I've been working on a graphics library for .net. It sits on top of OpenTK and does 2D drawing using OpenGL. I started this project 5 years ago in C. The goal was to allow for a more natural handling of sprites and images and overcome some of the limits of drawing with SDL.

I'm sure that it's no where as fast as XNA's sprite batching, but it suits my purposes. I'm working on commenting the code, writing documentation, and coming up with some examples.

http://code.google.com/p/angrymoose/ I don't have any downloads yet, but you can check the project out of subversion. There's a simple example, it demonstrates how to set things up and how to do some basic drawing.

One of my favorite features is that it uses a factory pattern to determine what kind of surface to make depending on what version of OpenGL you are running. For older versions of OpenGL, it will use a sort of tiling system to get around cards that don't support n-P2 or larger textures.

Any kind of feedback would be appreciated.

PnP Bios
Oct 24, 2005
optional; no images are allowed, only text

almostkorean posted:

I just started as an intern working for a car company, and they want me to makes a car simulation. I need to pick out a USB wheel/pedals to use for the project, but I don't really have any experience programming for hardware. So is there is a certain brand/type of wheel that is better to program with?

Edit: I guess I should make my question more clear: is there a usb wheel that has good/any documentation?

I'd think any of the Logitech ones for PC using DirectX to handle the input should work well enough.

PnP Bios
Oct 24, 2005
optional; no images are allowed, only text

Gyshall posted:

I'm interested in making my own side scroller game just as a hobby. I don't know any programming languages, but I have dabbled in Python before and I can do web design/CSS, if that helps. I used to mess around with RPG Maker and could get around that fairly easily, so I'm wondering if there is a free or sub $150 game engine designed around making side scrolling beat em' ups like Comix Zone or Streets of Rage et al. Any suggestions on where to start?

http://en.wikipedia.org/wiki/M.U.G.E.N - mugen may be worth taking a look at.

or

http://www.senileteam.com/beatsofrage.html - beats of rage

PnP Bios
Oct 24, 2005
optional; no images are allowed, only text
I'm working on a geometry library for a game, and need just a bit of assistance dividing a simple polygon into a list of triangles.



If I was just dealing with a convex polygon, this would be simple, you start from a point and build a triangle fan. But with a concave polygon, this is a bit more tricky, would possibly need to first divide up into 2 or more convex polygons first.

My idea was to start with the first vertex and go around the polygon, finding the largest internal polygon that is still convex, splitting that into triangles, then removing everything but the first and last elements, and repeating until all the vertices are used up.

Does this method have any merit? The idea would be to do this once, and basically just for rendering as triangles instead of a polygon for speed.

PnP Bios
Oct 24, 2005
optional; no images are allowed, only text

ynohtna posted:

The ear clipping method is a simple method for decomposing an arbitrary poly into triangles assuming your shape contains no holes, but you could also look up Delaunay triangulation and it's variants if you fancy getting fancy.

I've been researching ear clipping, i think that will work well for me.

PnP Bios
Oct 24, 2005
optional; no images are allowed, only text


A doom-a-like I've been working on in my free time with C# and OpenTK

Needs .NET 4 to run, haven't tested it under mono, but give it a test run if you feel like it.

ASDW - move
ESC - quit
Mouse - move

I doubt it will work on Linux since I had to use some p-invoke to handle the input.

http://dl.dropbox.com/u/2126236/Sandbox2.1.zip

PnP Bios
Oct 24, 2005
optional; no images are allowed, only text

Jo posted:

I'm not sure if it's a better idea to have my EntityManager object do all the collision checking or it's a better idea to have the collision checking inside the Entity superclass. Suggestions or advice?

EDIT: First seems more reasonable. Have the entity objects do their updating position-wise, then the entity manager check for collisions.

I would have a static class with all your collision definitions and use overridable calls to your check collision code, like this...

pre:
public static class Collisions
{
 public static void Collision( abstractGameObject a, abstractGameObject b)
 {
 }

 public static void Collision (Player p, abstractEnemy e)
 {
 }

 public static void Collision (Player p, abstractLevelPiece l)
 {
 }
}

PnP Bios
Oct 24, 2005
optional; no images are allowed, only text
I did a writeup on how reflection can be useful for building a game editor for your .NET game. Let me know what you think?

http://unicorn21.tumblr.com/post/1641105473/a-new-detailed-writeup-on-using-reflection-in-your

PnP Bios
Oct 24, 2005
optional; no images are allowed, only text
This is some sample code of how I solved the problem of processing object interactions. Critiques or thoughts?

code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace xTest
{
    public abstract class BaseObject
    {
        protected string _name;
        public string Name { get; set; }
    }

    public class Red : BaseObject
    {
        public Red()
        {
            _name = "Red";
        }
    }

    public class Blue : BaseObject
    {
        public Blue()
        {
            _name = "Blue";
        }
    }

    public class Green : BaseObject
    {
        public Green()
        {
            _name = "Green";
        }
    }

    public class DetectionEvent
    {
        public BaseObject obj1 { get; set; }
        public BaseObject obj2 { get; set; }
    }

    public class DetectionManager
    {
        public delegate void Interaction(DetectionEvent e);

        private Dictionary<KeyValuePair<Type, Type>, Interaction> _reactions;

        public DetectionManager()
        {
            _reactions = new Dictionary<KeyValuePair<Type, Type>, Interaction>();
        }

        public void AddInteraction(Type a, Type b, Interaction i)
        {
            if (_reactions.Keys.Contains(new KeyValuePair<Type, Type>(a, b))
                ||
                _reactions.Keys.Contains(new KeyValuePair<Type, Type>(b, a)))
            { return; }
            _reactions[new KeyValuePair<Type, Type>(a, b)] = i;
        }

        public Interaction GetInteraction(Type a, Type b)
        {
            if (_reactions.Keys.Contains(new KeyValuePair<Type, Type>(a, b)))
                return _reactions[new KeyValuePair<Type, Type>(a, b)];
            return null;
        }

        public void ProcessInteraction(BaseObject a, BaseObject b)
        {
            Interaction i = null;
            i = GetInteraction(a.GetType(), b.GetType());
            if (i != null)
            {
                i.Invoke(new DetectionEvent() { obj1 = a, obj2 = b });
                return;
            }

            i = GetInteraction(b.GetType(), a.GetType());
            if (i != null)
            {
                i.Invoke(new DetectionEvent() { obj1 = b, obj2 = a });

            }


        }
    }



    class Program
    {
        static void Main(string[] args)
        {
            var n = new DetectionManager();

            n.AddInteraction(typeof(Red), typeof(Red), delegate(DetectionEvent e) { Console.WriteLine("More Red!"); });
            n.AddInteraction(typeof(Blue), typeof(Red), delegate(DetectionEvent e) { Console.WriteLine("Purple!"); });

            n.ProcessInteraction(new Red(), new Red());

            n.ProcessInteraction(new Red(), new Blue());
            n.ProcessInteraction(new Blue(), new Red());

            Console.Read();
        }
    }
}

PnP Bios
Oct 24, 2005
optional; no images are allowed, only text

Orzo posted:

Your code is fine. I don't know if you'll want this or not (it depends on your desired end design), but for your particular example I've made a few modifications to take advantage of generics. The main problem (it might not be a problem at all, if you don't need it!) with your code is that the callback delegate receives BaseObject, not the actual object defined in the interaction. Using generic interaction types, you can make your client code a little fancier. Note at the bottom how the interaction events take advantage of the specific types of the interaction (I've added dumb little properties to Red, Blue, and Green to demonstrate).

Also you don't need to call .Invoke on a delegate, just open the parenthesis.

code:
...

You know... I knew this could be improved on with generics, I just didn't know how.
Thanks!

PnP Bios
Oct 24, 2005
optional; no images are allowed, only text

Bizarro Buddha posted:

What's your actual use case for this interaction system? When it comes to games I'm very wary of writing anything generic especially as a first pass. What are the chances that you're making yourself a hammer before you've realised that you need to deal with screws?

I'm working on a game engine. (insert rolly eyes here...) but I've already got a few demos working. This system in my case is specifically for object collisions. such as player-bullet, player-switch, etc. The idea being it can be extended to more than just first person shooters. I would say that it's over 90% complete, and am working to implement a game with it. Currently I have about half a dozen sandboxes testing various features.

PnP Bios
Oct 24, 2005
optional; no images are allowed, only text

Orzo posted:

People will tell you to write games, not engines. It's an annoying mantra parroted all over the place by people that probably wrote an engine at some time and failed. Do your own thing, writing an engine is a great learning experience which may or may not end up in a successful game.

I'm usually one of those people, but I have a good reason for writing this one. I'm going for a specific look, and I'm keeping things ridiculously simple.

PnP Bios
Oct 24, 2005
optional; no images are allowed, only text

Bizarro Buddha posted:

Sounds reasonable for triggers like switches, though for collisions like bullet-player you'd usually want more information like point of intersection, normal, and so on, which makes your system less generic.
Position and velocity are components of the game objects. I have a different pass for the level geometry.

Bizarro Buddha posted:

These people are right. An engine is something that grows out of carrying code over between projects. If you set out to write "an engine" with no game to keep the feature set on track and constantly tested for usefulness, you'll end up with a huge set of systems that are of absolutely no use to you in practice. You should listen to people that tried things and failed, and think about the reasons, rather than calling it an annoying mantra.

This isn't a from the ground up engine design. This is the refinement of a series of prototypes. This is the 7th iteration, which I'm going to turn into a full blown game instead of a fancy physics test.

PnP Bios
Oct 24, 2005
optional; no images are allowed, only text

Bizarro Buddha posted:

Slightly nitpicky but position and velocity doesn't give you intersection point and normal without doing work that you probably would already have done in your collision detection, so it doesn't make sense to be forced to redo that work in the handler.

I think you under-estimate how simple my engine is. Right now I'm only doing cylinder-cylinder detection.

PnP Bios
Oct 24, 2005
optional; no images are allowed, only text

Zero The Hero posted:

I've been trying to learn SDL for a while now, using the [url="https://"http://www.lazyfoo.net/SDL_tutorials/"]Lazy Foo Tutorials[/url] if you're familiar with them, but it's been slow going. I was checking out XNA recently and it looks a lot... cleaner. And easier. Is there any good reason NOT to use XNA and keep trying SDL?
Well, what language are you going to use?

PnP Bios
Oct 24, 2005
optional; no images are allowed, only text
I've been working on a 2D graphics library in C# that will work well with OpenTK. I'm fine tuning the sprite batching, but the cool thing about mine is how it handles drawing the sprites.

The idea is to make calls that look like this.

code:
_context.Draw( sprite.Translate(64,64));
_context.Draw( sprite.Translate(512,512).Scale(1.5,1.5).RotateCenter(30));

or

_bakedSprite = sprite.Translate(512,512).Scale(1.5,1.5).RotateCenter(30);

_context.Draw( _bakedSprite);
If anybody is interested in trying it out, here is the codeplex for it. http://mannagum.codeplex.com/

http://mannagum.codeplex.com/releases/view/66880 -- release files

There is documentation, and the sampler project contains a few examples (switch screens by pressing 1-3)

Thanks.

PnP Bios
Oct 24, 2005
optional; no images are allowed, only text

poemdexter posted:

I really like this idea instead of having a draw method that is overwritten like 7 times and takes anywhere from 1 to 9 parameters.

The only problem I can see is that it's creating a lot of objects so the garbage collector is going to be working overtime.

But I figure anybody who is worrying about cache misses would be writing their game in C already.

I would definitely appreciate a second set of eyes to see if I'm missing anything obvious.

PnP Bios
Oct 24, 2005
optional; no images are allowed, only text

PDP-1 posted:

Is there any reason you have to copy the entire object every time you do a transformation instead of just transforming in place and returning a reference? For example the code

code:
        public Sprite Rotate(double degrees)
        {
            var c = Copy();
            c.TranformationHistory = Matrix4d.Mult(Matrix4d.RotateZ(degrees * Math.PI / 180), TranformationHistory);
            return c;
        }
could get changed to

code:
        public Sprite Rotate(double degrees)
        {
            TranformationHistory = Matrix4d.Mult(Matrix4d.RotateZ(degrees * Math.PI / 180), TranformationHistory);
            return this;
        }
and you'll still get the kind of method call format that you're going for without working the GC so hard. You might need to make the final Draw call reset the transformations to a neutral starting state but that's not too terrible.

The question then becomes, how do you know which is the last call?
No drawing actually takes place during the draw command. It just queues everything up, and all the magic happens in EndSpriteBatch()

One option I do see is only making one clone. You don't want to pollute the original sprite. I will play around with this idea tonight and see if it works. Thanks for the feedback!

PnP Bios
Oct 24, 2005
optional; no images are allowed, only text

PnP Bios posted:

The question then becomes, how do you know which is the last call?
No drawing actually takes place during the draw command. It just queues everything up, and all the magic happens in EndSpriteBatch()

One option I do see is only making one clone. You don't want to pollute the original sprite. I will play around with this idea tonight and see if it works. Thanks for the feedback!

This sorta works... Just not if you plan on retaining the state after making the call. You'll need to some how mark it back as not a clone.

PnP Bios
Oct 24, 2005
optional; no images are allowed, only text
I've gotten into writing DOS games for some dumb reason. Does anybody know how to check for multiple key presses at once? I have been dicking around with `int 16h` and it seems pretty responsive, but only reads in one key at a time. Also it does a stupid repeat thing. If anybody has found a good way to just scan keys, that would be neat.

Adbot
ADBOT LOVES YOU

PnP Bios
Oct 24, 2005
optional; no images are allowed, only text

Sagacity posted:

You'll need to write your own keyboard handler iirc. Found some old stuff here.

Thanks!

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply