• Advertisement


  • Content count

  • Joined

  • Last visited

Community Reputation

310 Neutral

About andrew111

  • Rank
  1. You might find these interesting:   Game Developer Dec 2012 p36 - recording unity - Building a replay system in Unity http://twvideo01.ubm-us.net/o1/vault/GD_Mag_Archives/GDM_December_2012.pdf    Game Developer May 2008 p46 - IMPLEMENTING DETERMINISTIC PLAYBACK SYSTEMS http://twvideo01.ubm-us.net/o1/vault/GD_Mag_Archives/GDM_May_2008.pdf   Game Developer Jun-Jul 2008 p47 - IMPLEMENTING DETERMINISTIC PLAYBACK SYSTEMS PART 2 http://twvideo01.ubm-us.net/o1/vault/GD_Mag_Archives/GDM_JuneJuly_2008.pdf
  2. 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/  
  3. X11 Client Events

    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); } }
  4. Any other way to draw shadows ?

    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.
  5. Font Rendering

    This library really needs some kind of docs or at least example code, I wasn't able to figure it out.
  6. Thanks, I'll give it a try when I get time.
  7. Okay, after Álvaro's question I realised I was confusing the problem. for two triangles sharing an edge I want to find out whether they are facing away from each other, facing towards each other or laying flat (same normal).   So a slight change from  C0lumbo's method, I dot product the normal from the first triangle to the non shared edge of the second triangle, where dotproduct=0 is both triangles laying flat, dotproduct<0 facing away (convex), dotproduct>0 facing towards (concave).   Seems like it should work.
  8.   Yes this was the problem I ran into, I'll give your suggestion a try.     The triangles are part of a 3D mesh, so I'm trying to tell if they are concave or convex, so >= PI is convex and < PI is concave.   The vertices are winded clockwise so the triangle normals always on the outer surface of the mesh.   EDIT:   Ah I just realised what you meant, I've been looking at the problem a bit wrong. I'll have think about this a bit more and get back to you.
  9. Hi I have two triangles sharing an edge and I have their normal vectors. Na          Nb  \    F   /   \  /|\  /   \/ | \/    /\ | /\    \  | /     \ | /     \|/       G (Na and Nb are the triangle normals, F and G are their shared edge) I want to check if the angle between the normals is: = 0, < PI, = PI or > PI.   I'm a bit rusty on 3d related math, but I looked at dot product and I don't think that works since I believe it can only be used to find the angle between 0 and PI, where as I  want between 0 and 2*PI.   I think maybe something could be done with cross product, e.g. since normals are unit length I have: Na * Nb = sinX*V (V being the cross product, X being the angle).   But I don't know where to go from there.       I've looked at this post from a similar/same question: http://www.gamedev.net/topic/112385-detecting-if-2-triangles-are-concave-or-convex/?view=findpost&p=1604381     But in this I don't understand what the a1 and a2 is (I'm guessing something like sinX), or what he means on the second step, compute the components?   Thanks.
  10. OpenGL How can I use multiple shaders in one mesh?

    If you mean to combine the results of multiple shader programs into one, I think you will have to render the mesh to a texture with each shader program, and then blend the results together (probably using another shader program).
  11. When I learn a new language I usually find a decent book to go through, where I go through each of the language features, e.g. syntax, modules, classes, functions, data types, inputting/outputting text etc, while trying out some small examples from each part (just so I don't immediately forget) and spending only enough time to get an idea of how each work (nothing in depth). Then once I've got all that down I'll flip through the standard libraries and write some examples on any that interest me, while just making mental notes of the rest of the libraries so I know whats available if I ever need them. Then after that like others have said, working on various projects that interest me, or for whatever reason I picked that language.
  12. [quote name='jeffkingdev' timestamp='1352837944' post='5000654'] I'm not sure what LuaJIT is, [/quote] Well one thing you can do is use c code from within it. I've just started looking at LuaJIT recently, and an idea I had apart from scripting world objects, was to use it to setup all the monotonous code, such geometry data (eg vertexarrayobjects, vertex buffers, attribute bindings, index buffers etc), shader programs, textures, texture samplers etc. Using luajit ffi to minimise the amount of cbindings necessary. And then in your main program, load those 'resource files' into a table and just say: [code] load_resource("shader_program.lua"); lua_getfield(L,-1,"prog"); GLuint program = *((GLuint*)lua_touserdata(L,-1)); lua_pop(L,2); .. glUseProgam(program); [/code] A resource file might look like: [code] prog = CreateShaderProgram { {"vert", [[ attribute vec3 a_pos; void main() { .. } ]]}, {"frag", [[ void main() { .. } ]]}, {"attrib", "a_pos", 0}} vao = CreateVertexArrayObject { .. } [/code]
  13. Texturing a Hemisphere/Skydome

    The [i]More OpenGL Game Programming[/i] book's [url="http://glbook.gamedev.net/GLBOOK/glbook.gamedev.net/moglgp/code.html"]source code[/url] has an example under [i]Chapter09/SkyDomesWin32[/i]. I'm not sure if the book explains it or not.
  14. Please simplify my code.

    [quote name='antiHUMANDesigns' timestamp='1340547802' post='4952317'] Don't you agree that C++ without OOP could just be C instead? Most of the improvements in C++ are related to abstraction. If you chose to ignore those, you might as well go with C? Do note that I'm trying to teach a beginner the difference between C and C++. I dont have any other agenda here. But don't get me wrong, I never meant to claim that you can't write C++ procedurally. I agree that it will compile, but I'm also quite sure that the only reason it will still compile is because C++ never got a chance to get free of C. Stroustrup himself says that C is obsolete, and that he wants C++ to be free of it. [/quote] I'm not sure if you've programmed in c, I've used it a bit for writing libraries, and the main problems I have with it, are things that c++ has introduced shortcuts for, and of course its painfully lacking of the standard template library (So you have to implement your own lists, hashmaps etc). So not defining classes isn't really equivalent to c code. [quote name='antiHUMANDesigns' timestamp='1340550633' post='4952331'] And mixing procedural and OOP is the same application simply feels right-off stupid to me. I see no defense for it. (OR, more correcly: I see no defense for ME to do that.) [/quote] I know the feeling, I dislike mixing functional code with imperative code, but I think procedural and oop can fit together fine. I know the feeling of over obsessing with oop from when I first started programming. If you want to see programming from another perspective, to see why oop isn't so important, you should look at a functional language like scheme ([url="http://racket-lang.org/"]racket[/url] is a good implementation) or [url="http://www.haskell.org/haskellwiki/Introduction"]haskell[/url]. Also if you're interested in alternate oop systems, look at [url="http://www.gigamonkeys.com/book/object-reorientation-classes.html"]clos[/url] (common lisp object system), I think it's a vast improvement over the c++/java/c# oop system. Knowing some of these things, I believe will help you put things in a better perspective.
  15. Please simplify my code.

    [quote name='antiHUMANDesigns' timestamp='1340513578' post='4952233'] but C++ does not run on a virtual machine like Java does. [/quote] That does not have anything to do with why c++ doesn't have an "Application" class for the main. riverreal is correct in that c++ is a multi paradigm language, which means you use oop where it helps, and procedural or functional (limited) programming etc where they help. And I don't think having an "Application" class helps at all, making a class to be instantiated once (except for cases of inheritance) seems like a wasted effort.
  • Advertisement