GDR Forum Index
Podcast Podcast
Dev Dev Logs
Search Search
RSS RSS
Register Register
Log in Log in
Reply to topic GDR Forum Index -> Game Developer's Refuge -> Development Log - Gliese: Gamedev Support Library Page Previous  1, 2, 3  Next
View previous topic :: View next topic  
Author Message
sonrisu
Moderator

Joined: 31 Aug 2005
Posts: 4998
Location: Silicon Valley!
PostPosted: Mon Dec 10, 2007 5:07 pm    Post subject: Reply with quote

If it's really a "support" library I'd end up going with something like "Crutch". I tend to like names that are quite common, but also slightly obscure, if that makes sense. They are easy to remember, and they sound cool. Come on: gcc *.c -lcrutch

My minimalist OSX framework that will never get finished because CoreAudio eludes me was called "mini2d", stemming from the fact that 1: it was attempting to be minimalistic, and 2: it was for 2D only.

I think using a name like Gliese might be hard because it's difficult to spell (it's easy to transpose the i/e, even if you know proper grammar) as well as the fact that it begins with GL, which is a pretty synonymous thing indicating affiliation with/extension of OpenGL. While your library plays with OpenGL, it's not really OpenGL specific.
_________________
loomsoft :]
View user's profile Send private message Visit poster's website
NyanNyanKoneko
Contributor

Joined: 19 Oct 2005
Posts: 450
Location: In your L1 CPU cache
PostPosted: Mon Dec 10, 2007 11:03 pm    Post subject: Reply with quote



Well, I started working on 2D drawing routines today. I decided that 2D drawing will primarily be done via a context with (0,0) in the center. People used to having positive Y being negative and 0 being the side of the screen are going to be confused. The screen always has a height of 2 (-1 bottom -> 1 top), but the width varies based on the aspect ratio of the display / window.

Anyway, the results are neat. You can resize the window at will, and everything you draw will be in the correct perspective. Expand the window to the right or left, and you can view more of the screen. Increase the height of the window to blow up the image.

Of course, you can just define the metrics of the 2d screen as you wish (such as (0,0) being the top left corner of the screen).
View user's profile Send private message Visit poster's website
sonrisu
Moderator

Joined: 31 Aug 2005
Posts: 4998
Location: Silicon Valley!
PostPosted: Tue Dec 11, 2007 6:16 am    Post subject: Reply with quote

Is the horizontal window stretching going to allow for stretching of the actual window contents? For instance, if one doesn't want to put in the ability to make their application widescreen and also doesn't want to do the work of putting in vertical bars: is there a way to tell the engine: stretch on both axes?

This might be useful for, say, those people who want to have in-game selectors to double up the display size and have the engine take care of scaling it upward.
_________________
loomsoft :]
View user's profile Send private message Visit poster's website
NyanNyanKoneko
Contributor

Joined: 19 Oct 2005
Posts: 450
Location: In your L1 CPU cache
PostPosted: Tue Dec 11, 2007 10:18 am    Post subject: Reply with quote

Sonriu: Yes, you can make it so when you scale a window, it just blows up the contents. I will also make a way to clamp aspect ratios, so if you just want to support resolutions between 4:3 to 16:9, you can do that and the engine will automatically create the bars on the tops or sides of the display.

So like, if you want to make a game that is is only 16:9, and you want to run it in 800x600, it'll create black (or whatever your background color is) bars on the top and bottom of the screen. You, as the programmer, won't have to think about it.

But for indie games though, I think it's a good idea to let the user resize the window at will for a lot of stuff.
View user's profile Send private message Visit poster's website
NyanNyanKoneko
Contributor

Joined: 19 Oct 2005
Posts: 450
Location: In your L1 CPU cache
PostPosted: Tue Dec 11, 2007 10:36 am    Post subject: Reply with quote

So here's a visual example of what I mean. Here's a 4:3 screen. Y is clamped between -1, and 1, and X is clamped between -4/3 and 4/3.



Now, if we tell the system that we want the aspect ratio to only be 16:9, here's how the coordinate system will look by default:



So it's completely resolution independent.
View user's profile Send private message Visit poster's website
sonrisu
Moderator

Joined: 31 Aug 2005
Posts: 4998
Location: Silicon Valley!
PostPosted: Tue Dec 11, 2007 10:40 am    Post subject: Reply with quote

Now here's the real kicker: is all of this going to be switchable on the fly?
_________________
loomsoft :]
View user's profile Send private message Visit poster's website
NyanNyanKoneko
Contributor

Joined: 19 Oct 2005
Posts: 450
Location: In your L1 CPU cache
PostPosted: Tue Dec 11, 2007 12:45 pm    Post subject: Reply with quote

Quote:
Now here's the real kicker: is all of this going to be switchable on the fly?


Yes.
View user's profile Send private message Visit poster's website
sonrisu
Moderator

Joined: 31 Aug 2005
Posts: 4998
Location: Silicon Valley!
PostPosted: Tue Dec 11, 2007 2:02 pm    Post subject: Reply with quote

Perfect. Looking forward to more updates.
_________________
loomsoft :]
View user's profile Send private message Visit poster's website
NyanNyanKoneko
Contributor

Joined: 19 Oct 2005
Posts: 450
Location: In your L1 CPU cache
PostPosted: Tue Dec 11, 2007 6:42 pm    Post subject: Reply with quote

Hello World in Gliese:

Code:

int main(void)
{
  GS_FONT *font;

  /* Initialize Gliese Components. */
  gfx_initialize(640, 480, GS_FALSE);
  input_initialize();

  /* Load the font. */
  font = gfx_create_font("data/font.ttf");
  gfx_set_clear_color(64, 64, 128, 255);

  while(!input_quit_event_recieved())
  {
    /* Get ready to start drawing. */
    gfx_set_projection_mode2d();
    gfx_clear_color_buffer();
        
    /* Print the text. */
    gfx_printf2d(font, -0.90f, 0.25f, 0.25f, "HELLO WORLD!");
        
    /* Show the text on the screen and sleep to play nice with other applications. */
    gfx_flip_backbuffer();
    input_sleep(1);
  }
  return 0;
}




And yes, that really is a printf function, so you can print variables as well.
View user's profile Send private message Visit poster's website
sonrisu
Moderator

Joined: 31 Aug 2005
Posts: 4998
Location: Silicon Valley!
PostPosted: Tue Dec 11, 2007 7:05 pm    Post subject: Reply with quote

Does it play nice with newlines? I only ask because I know allegro's printing functions definitely do not.

I'm also curious as to whether you're going to support a pixel style coordinate system, and allow the developer to choose by calling some set_* function? I'd gather that all that would be required on your part is some conversion methods to swap pixel style coordinates into float coords.

Looking good. It appears that things are progressing at a pretty steady pace. Pretty awesome.
_________________
loomsoft :]
View user's profile Send private message Visit poster's website
NyanNyanKoneko
Contributor

Joined: 19 Oct 2005
Posts: 450
Location: In your L1 CPU cache
PostPosted: Tue Dec 11, 2007 7:57 pm    Post subject: Reply with quote

Quote:
Does it play nice with newlines?

Yeah.

If you want to use pixel style for a 640x480 screen, instead of calling gfx_set_projection_mode2d(), you can call another function, gfx_set_projection_pixel_mode2d(640, 480). You don't get the neat aspect ratio changing awesomeness that you would get otherwise, though. So if it's possible, I would recommend against it.
View user's profile Send private message Visit poster's website
sonrisu
Moderator

Joined: 31 Aug 2005
Posts: 4998
Location: Silicon Valley!
PostPosted: Tue Dec 11, 2007 8:02 pm    Post subject: Reply with quote

This is shaping up to be incredibly user friendly. I personally will be hesitant to use it because of the long dependency list (I hate having to find the stuff to install). It took me forever just to warm up to using DUMB in conjunction with Allegro. Some of this reluctance, though, is due to the sometimes unavailability of libraries for OSX.

If release versions come with installers or whatnot including the required dependencies and all you must do is build them, then I think that will help out a lot. If people have to hunt them down on their own then that's going to be an installation nightmare.
_________________
loomsoft :]
View user's profile Send private message Visit poster's website
NyanNyanKoneko
Contributor

Joined: 19 Oct 2005
Posts: 450
Location: In your L1 CPU cache
PostPosted: Tue Dec 11, 2007 9:31 pm    Post subject: Reply with quote

It'll come with all the libs, except for the linux release. For Linux, it'll come with a script that runs apt-get, yum, or protoge to download the libs automatically. But a full release is far off. I might make a few games with it to debug the API while I'm working on it.

If people don't mind that the API is ever-growing and changes from time to time (like today I added an extra boolean value to the texture loading functions to produce mipmaps), then I might release an alpha when the library is stable enough to create a 2D title.
View user's profile Send private message Visit poster's website
NyanNyanKoneko
Contributor

Joined: 19 Oct 2005
Posts: 450
Location: In your L1 CPU cache
PostPosted: Wed Dec 12, 2007 7:26 am    Post subject: Reply with quote

So I was thinking about what kind of effects to add to text, when I thought of a great idea. The user can set a callback and tell every printf function how to display text. So if you want to add a shadow, you simply write a function like this:

Code:

void text_add_shadow(float start_x, float start_y, float start_height, float *current_x, float *current_y, float *current_height, int string_index, const char *string, GS_QUAD2D *quad)
{
    GS_QUAD2D copy = *quad;
    
    gfx_set_quad2d_colorf(0.0f, 0.0f, 0.0f, 1.0f, &copy);
    gfx_translate_quad2df(2.0f, 2.0f, &copy);
    
    gfx_render_quad2d(&copy);
    gfx_render_quad2d(quad);
}


Then the main loop looks like this:

Code:

gfx_set_printf2d_callback(text_add_shadow);
    
while(!input_quit_event_recieved())
{
    gfx_set_projection_pixel_mode2d(640, 480);
    gfx_clear_color_buffer();
        
    gfx_printf2d(font, 5.0f, 20.0f, 24.0f, "Hello Game Developer's Refuge\nThis is a test of the printf function.");
        
    gfx_flip_backbuffer();
    input_sleep(1);
}


And you get this result:



So the possibilities are endless.
View user's profile Send private message Visit poster's website
sonrisu
Moderator

Joined: 31 Aug 2005
Posts: 4998
Location: Silicon Valley!
PostPosted: Wed Dec 12, 2007 9:01 am    Post subject: Reply with quote

That's pretty neat. I like that idea. Now you've got me thinking about per-character callbacks. That would be truly neat. Consider the scenario where the user might want to have a multicolored line, or be able to offset the letters vertically up and down in some sort of sine wave pattern -- all without having to print each character individually on their own, but having the work done in some sort of callback that uses a few global (to that callback) values.

Anyhow, aside from that randomness: this is a lot nicer of an implementation than writing a wrapper function, or worse: doing double prints everywhere you want a shadow.
_________________
loomsoft :]
View user's profile Send private message Visit poster's website
JonA
Moderator

Joined: 24 Aug 2005
Posts: 396
Location: UK
PostPosted: Wed Dec 12, 2007 11:54 am    Post subject: Reply with quote

An aside:

sonrisu wrote:
doing double prints everywhere you want a shadow.


The other day I was playing around with the text-shadow property in CSS - it worked nicely in the latest Safari, gives a nice drop-shadow to headings, but I didn't have a clue if it works in other browsers.

I accidentally leave this on screen where a manager can see it. He HAS to have it. In ALL browsers. NOW, Jon, NOW!

So what did we end up with?
Code:
<h1>Cool Heading!</h1>
<h1 class="shadow">Cool Heading!</h1>

... all over the damn site. Can you guess that the 'shadow' class shifts the text by a couple of pixels? :-)

--Jon
_________________
JonAtkinson.co.uk
View user's profile Send private message Visit poster's website
Sirocco
Moderator

Joined: 19 Aug 2005
Posts: 9460
Location: Not Finland
PostPosted: Wed Dec 12, 2007 11:58 am    Post subject: Reply with quote

Quote:

I accidentally leave this on screen where a manager can see it. He HAS to have it. In ALL browsers. NOW, Jon, NOW!


This is why I keep my experiments to myself... and at home ;)
_________________
NoOP / Reyn Time -- The $ is screwing everyone these days. (0xDB)
View user's profile Send private message Visit poster's website
sonrisu
Moderator

Joined: 31 Aug 2005
Posts: 4998
Location: Silicon Valley!
PostPosted: Wed Dec 12, 2007 12:06 pm    Post subject: Reply with quote

That code is classic. Make sure it doesn't show up on the dailywtf.
_________________
loomsoft :]
View user's profile Send private message Visit poster's website
n29
Developer

Joined: 13 Sep 2005
Posts: 879

PostPosted: Wed Dec 12, 2007 7:41 pm    Post subject: Reply with quote

So my question is: If the api is C and there is no scene graph and I load a big ass level how do I use an octtree for view frustum culling?
View user's profile Send private message
NyanNyanKoneko
Contributor

Joined: 19 Oct 2005
Posts: 450
Location: In your L1 CPU cache
PostPosted: Wed Dec 12, 2007 9:42 pm    Post subject: Reply with quote

n29, good question! I don't know! I have no idea how I'll implement BSP Trees and Octtrees yet!

I imagine octtrees will be the easier of the two. I guess you make a good point though. It's going to have to have some scene-graphology. It's just not going to be an engineish scenegraph like OGRE.

The idea is to make something between allegro and Crystal Space / OGRE.
View user's profile Send private message Visit poster's website
NyanNyanKoneko
Contributor

Joined: 19 Oct 2005
Posts: 450
Location: In your L1 CPU cache
PostPosted: Thu Dec 13, 2007 2:25 am    Post subject: Reply with quote

Well, I'm playing around with Dark GDK, and I like how they set up their library. It's completely functional, and instead of returning objects, it returns integers that are references to the objects. This is similar to how OpenGL handles textures.

Similarly, since it keeps a list of all game objects, it draws all game objects in frame automatically each cycle. The user also doesn't have to worry about memory management.

Although I like the idea of returning object references instead of objects for C programming (which I'll use in future libs), for this project, I'll stay with structs unless you all would rather I not.

I think an auto-draw list would be a good idea though. All objects can be passed to the auto-draw, and a single call will draw all objects, eliminating those outside of the screen automatically.

Or better yet, you can create multiple draw lists of objects. So you can draw things in order or skip some on certain frames. Yeah, I like it! So you can send all quads that make up a tile-map to the draw list, and it will sort it, and it will automatically draw only what's visible.

I guess that also kinda answers n29's question.
View user's profile Send private message Visit poster's website
sonrisu
Moderator

Joined: 31 Aug 2005
Posts: 4998
Location: Silicon Valley!
PostPosted: Thu Dec 13, 2007 5:44 am    Post subject: Reply with quote

I tend to prefer return values that are objects/structs rather than just numbers that represent said objects. What you end up doing when you get the numbers is calling some function that returns the object when passed the number anyway, so you're saving everyone an annoying step by skipping the whole number thing.

Auto-draw sounds cool, but how is the list management going to work? I can think of some scenarios where auto-draw isn't really the end-all be-all system, but for most normal working stuff it should be fine. For instance, consider that some objects/whatever's drawing methods may require additional arguments be passed to them--how will you handle this? VarArg style? Not at all?
_________________
loomsoft :]
View user's profile Send private message Visit poster's website
n29
Developer

Joined: 13 Sep 2005
Posts: 879

PostPosted: Thu Dec 13, 2007 6:16 am    Post subject: Reply with quote

NyanNyanKoneko wrote:
Well, I'm playing around with Dark GDK, and I like how they set up their library. It's completely functional, and instead of returning objects, it returns integers that are references to the objects. This is similar to how OpenGL handles textures.

Similarly, since it keeps a list of all game objects, it draws all game objects in frame automatically each cycle. The user also doesn't have to worry about memory management.

Although I like the idea of returning object references instead of objects for C programming (which I'll use in future libs), for this project, I'll stay with structs unless you all would rather I not.

I think an auto-draw list would be a good idea though. All objects can be passed to the auto-draw, and a single call will draw all objects, eliminating those outside of the screen automatically.

Or better yet, you can create multiple draw lists of objects. So you can draw things in order or skip some on certain frames. Yeah, I like it! So you can send all quads that make up a tile-map to the draw list, and it will sort it, and it will automatically draw only what's visible.

I guess that also kinda answers n29's question.


The "integer index to an array of resource's" (meshes, samples, textures, images, etc...) is how both Darkbasic and Blitzbasic get around support for structs/classes in the language, they typically don't provide dynamic memory allocation in the language, and they also don't provide the user with the capability to manipulate the data of those objects. I think following that scheme in Gliese would be very limiting to the developers. That is how handle resources in NASIC though. (Note: since the semesters over I may have time to put NASIC on sourceforge over Christmas...)

So far as supporting octtrees, you could just have a function:

OcttreeMesh createOcttreeMestFromMesh(Mesh* m) {....}

Or something.....
View user's profile Send private message
NyanNyanKoneko
Contributor

Joined: 19 Oct 2005
Posts: 450
Location: In your L1 CPU cache
PostPosted: Thu Dec 13, 2007 10:23 am    Post subject: Reply with quote

Quote:
Auto-draw sounds cool, but how is the list management going to work?


Instead of drawing 10 objects, you send all 10 objects to a list and draw the list. OpenGL has a similar feature built in. For objects that you don't want in a list, I guess you draw them one by one like normal.

Quote:
For instance, consider that some objects/whatever's drawing methods may require additional arguments be passed to them--how will you handle this? VarArg style? Not at all?


That will be up to you. The list will only be good for static objects now that I think about it.

Quote:
So far as supporting octtrees, you could just have a function:


Well yeah, but the hard part will be having the engine use the octtree. Octtrees work well for outside environments, but not inside ones, and the library is designed to throw stuff at it and have it render. So it may have to deal with some objects using octtrees, BSPs, and other partitioning algorithms to eliminate off-screen drawing all at the same scene. Ideally, it should be simple like "drawMesh(octree, frustrum, model);", but at this point, I have no idea how it'll work.
View user's profile Send private message Visit poster's website
sonrisu
Moderator

Joined: 31 Aug 2005
Posts: 4998
Location: Silicon Valley!
PostPosted: Fri Dec 14, 2007 5:32 am    Post subject: Reply with quote

Quote:
Instead of drawing 10 objects, you send all 10 objects to a list and draw the list. OpenGL has a similar feature built in. For objects that you don't want in a list, I guess you draw them one by one like normal.

For list management I really mean how creating the actual list will be. Is it a pain in the ass to add items to the list? What if you're constantly adding items and deleting items from some list you're keeping managed in memory? Some people may want this, and if it's a hassle to manage the actual contents of the list, most likely they'll use some other manual method to get around the deficiency.
_________________
loomsoft :]
View user's profile Send private message Visit poster's website
Reply to topic GDR Forum Index -> Game Developer's Refuge -> Development Log - Gliese: Gamedev Support Library Page Previous  1, 2, 3  Next

Use this link to get a Sign-On Bonus when you get started!

All trademarks and copyrights on this page are owned by their respective owners. All comments owned by their respective posters.
phpBB code © 2001, 2005 phpBB Group. Other message board code © Kevin Reems.