Jump to content

  • Log In with Google      Sign In   
  • Create Account

CaptainMurphy

Member Since 25 Mar 2009
Offline Last Active Dec 23 2015 12:21 PM

Posts I've Made

In Topic: Question about creating a replay system

13 December 2015 - 03:38 AM

You might find these interesting:

 

Game Developer Dec 2012 p36 - recording unity - Building a replay system in Unity
 
Game Developer May 2008 p46 - IMPLEMENTING DETERMINISTIC PLAYBACK SYSTEMS
 
Game Developer Jun-Jul 2008 p47 - IMPLEMENTING DETERMINISTIC PLAYBACK SYSTEMS PART 2

In Topic: Attribute grammar implementation?

06 December 2015 - 09:00 AM

If the implementation language doesn't matter, there is a library for Scala called Kiama at https://bitbucket.org/inkytonik/kiama

 

I don't remember all the details since it has been a while since I used it, but it uses a "packrat parser". Which you basically write the grammar directly in Scala, and specify the classes/params to be used to build the syntax tree.

 

Attributes are declared in recursive tree-like  expressions. We used the attributes for things like calculating scope and constant expressions, I forget what else, but I remember it being really easy at the time.

 

Another option is to use Ragel for lexing and Lemon for parsing. These can be used to generate parsers in C.

 

http://www.colm.net/open-source/ragel/

http://www.hwaci.com/sw/lemon/

 


In Topic: X11 Client Events

18 October 2015 - 02:02 AM

Try this:
Display *display;
Window win;
Atom wmDelete;

void onInit() {
    wmDelete=XInternAtom(display, "WM_DELETE_WINDOW", True);
    XSetWMProtocols(display, win, &wmDelete, 1);
}

void onUpdate() {
    XEvent ev;

    while(XPending(display)) {
        XNextEvent(display,&ev);

        if(ev.type==DestroyNotify) {
            //on exit
        }

        if(ev.type==ClientMessage && (Atom)ev.xclient.data.l[0] == wmDelete) {
            //on close window
        }

        XFreeEventData(display, &ev.xcookie);
    }
}


In Topic: Any other way to draw shadows ?

28 June 2015 - 03:18 PM

Looks like a cut down version of stencil shadow volumes. Where it draws the shadows quads to the stencil buffer, and then the lit things are drawn except for the pixels marked by the stencil buffer. Pretty neat idea, looks like it would work for any N sided polygon.

 

You can't do it in a vertex shader since you can only access one vertex at a time, where as that algorithm needs access to two. Also I think vertex shaders can spit out only one vertex at a time, where that spits out 4. If you had geometry shaders you could do it there but that's opengl 3.3+.

 

Edit:

Actually you could pass more than one vertex to the shader by doing something like

for verts in quad or triangle {

  glVertex4f(cur.x,cur.y,next.x,next.y);

}

 

But I don't know if you are able to emit more than 1 vertex from the shader. If you could, it might be possible...

 

 

Edit2:

Actually I just realised another idea, where you send a quad for each edge,

e.g.

for each edge {

  glBegin(GL_QUAD);

 

  glNormal(edgeNor.x,edgeNor.y,0); 

  glVertex3f(cur.x,cur.y,0);//0 represents the vertex on the edge to not extrude

 

  glNormal(edgeNor.x,edgeNor.y,0);

  glVertex3f(next.x,next.y,0); //0 represents the vertex on the edge to not extrude

 

  glNormal(edgeNor.x,edgeNor.y,0);

  glVertex3f(cur.x,cur.y,1); //1 represents the extruded vertex

 

  glNormal(edgeNor.x,edgeNor.y,0);

  glVertex3f(next.x,next.y,1);//1 represents the extruded vertex

  glEnd();

}

 

Basically in the vertex shader you:

1. redundently do the dot product check to see if a shadow should be extruded. Pass a varying float to there fragment shader, where if shadow pass 1, else pass 0

2. If the vertex.z ==1, extrude the vertex along the light direction.

 

Fragment shader:

1. Check the varying float passed from the vertex shader, if == 0 then call discard to abort drawing the shadow

 

Kind of convoluted, but it should/could work.


In Topic: Font Rendering

15 August 2014 - 01:38 PM

This library really needs some kind of docs or at least example code, I wasn't able to figure it out.


PARTNERS