Jump to content

  • Log In with Google      Sign In   
  • Create Account

ic0de

Member Since 11 Nov 2010
Offline Last Active Yesterday, 12:35 PM
*----

#4981105 Choosing a 2D game engine for my project

Posted by ic0de on 17 September 2012 - 07:53 PM

Allegro's free and it offers only outdated C code as a graphics wrapper.


Don't ever forget that C is C++. Any C is perfectly valid C++, and C isn't really outdated Its still used for a lot of modern programming.


#4981068 bilateral gaussian blur

Posted by ic0de on 17 September 2012 - 06:25 PM

In order to accomplish a bilateral blur you will need to use FBOs (Frame Buffer Objects). You essentially render your scene to an FBO and then blur that in one direction. You then render the first FBO to either another FBO or to the screen then you blur that in the other direction.

Your Shaders are going to look something like this, you will have two of them, each in a different direction.

uniform sampler2D color_texture;
varying vec2 vTexCoord;

const float blurSize = 1.0/512.0;

void main(void)
{
vec4 sum = vec4(0.0);
sum += texture2D(color_texture, vec2(vTexCoord.x, vTexCoord.y - 4.0*blursize)) * 0.05;
sum += texture2D(color_texture, vec2(vTexCoord.x, vTexCoord.y - 3.0*blursize)) * 0.09;
sum += texture2D(color_texture, vec2(vTexCoord.x, vTexCoord.y - 2.0*blursize)) * 0.12;
sum += texture2D(color_texture, vec2(vTexCoord.x, vTexCoord.y - blursize)) * 0.15;
sum += texture2D(color_texture, vec2(vTexCoord.x, vTexCoord.y)) * 0.16;
sum += texture2D(color_texture, vec2(vTexCoord.x, vTexCoord.y + blursize)) * 0.15;
sum += texture2D(color_texture, vec2(vTexCoord.x, vTexCoord.y + 2.0*blursize)) * 0.12;
sum += texture2D(color_texture, vec2(vTexCoord.x, vTexCoord.y + 3.0*blursize)) * 0.09;
sum += texture2D(color_texture, vec2(vTexCoord.x, vTexCoord.y + 4.0*blursize)) * 0.05;
gl_FragColor = sum;
}



#4980362 C++, should I switch?

Posted by ic0de on 15 September 2012 - 07:22 AM

Oh, really? Please, do enlighten us on how you write GPU shaders. Do you cobble them together from C++ macros? Or perhaps you write them directly in IL assembly, hardcore-style? Also, how long does it take you to write a tool that replaces sequences of bytes in a binary buffer? Still waiting, cause in Python I'm done: buf.replace(). Oh, yours is... what? Faster? Oh, but I was only going to use it for a 10kb file anyway.


I'm sorry that came of so rudely but what I meant was for making games, yes scripting languages like python and javascript are great for doing small automation and I admit I use them from time to time, but if you are writing games the bulk of it is usually time critical and should be written in a fast language like c++, that said languages like GLSL are useful but they are incredibly application specific, they really just supplement other languages and not replace them.

More specifically c++ is in my opinion the best general purpose language for writing games.


#4980290 C++, should I switch?

Posted by ic0de on 14 September 2012 - 10:56 PM

Once you've programmed in a sane language, C++ feels SOOOOOOO much *more* painful. I need to make my own ??what??, to do what?? Really..... sheeesh.


C++ is the only sane language.

Once you know c++ there is no reason to use anything else. Unless of course you want the best speed possible in that case you would use assembly (sometimes I use it inline with c++ just for speed). As for making your own code for complicated things you can either have fun and do it yourself or use a third party library.

I tried learning JAVA, I decided it was just like c++ but slower and with too many rules.


#4977471 Framerate is low on Intel

Posted by ic0de on 06 September 2012 - 09:07 PM

Thanks. I'm a little reluctant to switch to VBOs at this point, especially if the gain won't be much.


VBO's look really complicated at first but start to make sense if you just take a half hour and really just study some example code you will get them. The performance gain will be massive if you are currently using glbegin/glend but if you are already using vertex arrays then it won't be huge but still measurable.

All in all glbegin/glend sucks for speed on anything.


#4905323 Anti-aliasing Techniques

Posted by ic0de on 22 January 2012 - 10:10 PM

many image based anti-aliasing methods handle all kinds of aliasing not just edges

look into FXAA:

http://developer.download.nvidia.com/assets/gamedev/files/sdk/11/FXAA_WhitePaper.pdf


#4892833 Define a plane knowing a point and the normal

Posted by ic0de on 11 December 2011 - 11:15 AM

I'm developing an opengl application and I have cast a ray from the camera to a point in 3D space. I would like to define a plane where such point lays, with the cast ray vector perpendicular to such plane.
Is it possible? If it's not clear I can make an image.


You should be able to define this plane if you know the tangent and the binormal, which can be derived from the normal.

We know that these vectors are both perpendicular to the normal. To find the tangent you will find two vectors perpendicular to the normal and pick one depending on whether the normal is positive or negative, the binormal will be the cross product of the tangent and the normal and at that point you should have enough information to define a plane, this will however be a massive burden on your CPU if you want to do this in real time so see if you can offload some calculations to the GPU using shaders or OpenCL.




#4889659 Orthographic projection issue

Posted by ic0de on 01 December 2011 - 08:28 PM

Hey everybody,

I have a 3D environment, created with JOGL (I'm using Eclipse) and now I want to create a simple 2D menu that the user can open by pressing "esc".

So I was thinking of using the orthographic projection. As I never used that projection, I tried looking up some sample code, but it just shows a black screen.

 GL2 gl = (GL2) drawable.getGL();

 gl.glMatrixMode(GL2.GL_PROJECTION);
 gl.glPushMatrix();
 gl.glLoadIdentity();
 gl.glOrtho(0, 500, 500, 0, 0, 1);
 gl.glScalef(1, -1, 1);
 gl.glTranslatef(0, -500, 0);
 gl.glMatrixMode(GL2.GL_MODELVIEW);
   
 gl.glColor3d(1.0, 1.0, 0.0);
 gl.glBegin(GL2.GL_QUADS);
    gl.glVertex2f(125, 125);
    gl.glVertex2f(125, 375);
    gl.glVertex2f(375, 375);
    gl.glVertex2f(375, 125);
 gl.glEnd();
 	
 gl.glMatrixMode(GL2.GL_PROJECTION); 
 gl.glPopMatrix(); 
 gl.glMatrixMode(GL2.GL_MODELVIEW);  

This is where I got the example code from: http://www.swiftless.com/tutorials/

Or do I need to search the mistake somewhere else?

Kind regards,
Dave


try gl.glTranslatef(0, -500, -1); instead of gl.glTranslatef(0, -500, 0); right now you are rendering it at the viewer and not in front of it.

also I would use glColor3f not glColor3d




PARTNERS