Do you have to use FreeGLUT? Why not pick something more recent (i.e have been developed on in the last 10 years), like GLFW or SFML?
Cheers,
Bob
Male
Posted by Scourage
on 10 April 2013 - 07:02 PM
Do you have to use FreeGLUT? Why not pick something more recent (i.e have been developed on in the last 10 years), like GLFW or SFML?
Cheers,
Bob
Posted by Scourage
on 16 February 2013 - 12:37 PM
I would start by thinking of all the abstractions you want from a high level. Then think of the abstractions required to support those, and keep working your way down until you're hitting OpenGL.
I would think for a 2D engine, you would need the concept of a layers. Background and foreground layers. I would guess they need to be z sorted as well. The layers are probably bigger than the screen, so they need some dimensions, and they might need to rotate, so a layer would need a rotation parameter. You probably want to have sprites be on the layers, so layers need to have a list of sprites and where to put them (sprite position might be part of the sprite). You probably need some kind of container for the layers to keep them in the right order for rendering (although simply sorting the list of layers every time you render probably won't show up in a profiler).
Sprites probably contain some kind of graphic, a position, scale, rotation. If its animated, it might contain an animation time, looping variable, and a list of graphics to animate between.
Your renderer might take a list of layers, sort them, then iterate over each layers sprites, rendering the graphic for each one. Try to keep each object you design have one and only one job.
Hope this gets you thinking in the right direction.
cheers,
Bob
Posted by Scourage
on 11 December 2012 - 12:50 PM
Posted by Scourage
on 09 December 2012 - 08:47 AM
Posted by Scourage
on 11 November 2012 - 07:03 AM
Posted by Scourage
on 10 November 2012 - 08:26 AM
Posted by Scourage
on 13 September 2011 - 07:09 PM
using System;
using System.Collections.Generic;
namespace SimEngine
{
public static class ResourceManager
{
static Dictionary<String, IResource> myResources;
static ResourceManager()
{
myResources = new Dictionary<String, IResource>();
}
public static bool init(Initializer init)
{
return true;
}
public static IResource getResource(ResourceDescriptor desc)
{
IResource res;
if (myResources.TryGetValue(desc.filename, out res))
{
return res;
}
//need to try and load the IResource here
res = load(desc);
return res;
}
static IResource load(ResourceDescriptor desc)
{
IResource res;
if (System.IO.File.Exists(desc.filename) == false)
{
Warn.print("Cannot find file {0}", desc.filename);
return null;
}
res = desc.create();
if (res != null)
{
myResources[desc.filename] = res;
}
return res;
}
}
}
using System;
namespace SimEngine
{
public interface IResource
{
}
public abstract class ResourceDescriptor
{
public ResourceDescriptor()
{
}
public ResourceDescriptor(String name)
{
filename = name;
}
public string filename { get; set; }
public abstract IResource create();
}
}
public class TextureDescriptor : ResourceDescriptor
{
bool myFlip=false;
public TextureDescriptor(string name) : this(name, false) { }
public TextureDescriptor(string name, bool flip)
: base(name)
{
myFlip = flip;
}
public override IResource create()
{
Texture t = new Texture(filename, myFlip);
if (t.isValid == false)
{
return null;
}
return t;
}
}
Find content