Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 18 Aug 2005
Offline Last Active Jan 17 2016 10:09 AM

Posts I've Made

In Topic: OpenGL Projection Matrix Clarifications

19 December 2015 - 03:40 PM

(Why does everyone say that the camera is at 0,0,0 then?!)


Saying the camera is at 0,0,0 is a bit misleading. In computer graphics, everything is a vector and vector math requires that the origin be 0. It's no more complicated then that. The camera, which is nothing more then a matrix, is the translation and rotation from 0,0,0.

In Topic: Can you help me make an Gaussian Blur filter using C

19 December 2015 - 12:01 PM

I'd post some code but my stuff is optimized so it wouldn't make any sense. I'm sure there's examples online (and DirectX SDK) for this but here's the over view in a nut shell.


First you want to compute a bell curve based on the number of samples that you want to use for your blur. You can use hard coded numbers for this but computing your own bell curve will allow you fine tune it to your needs. All we care about is half the bell curve because this is your target pixel and the number of samples taken. These values are your weights. Target pixel plus half the number of samples. We can now reused these samples for the other side of the target pixel. X = target pixel.


+++++X+++++ = 1.0


In the example above, there is 11 weights. If you were to add them all up, they would equal 1.0. You use the same array of weights to do the horizontal and vertical blur pass. At this point you simply multiply the sampled pixels by their respective weights to calculate the new color of the target pixel.


As stated above, this is a two step process and you'll need one additional buffer to complete the process. This assumes you're using a back buffer. Otherwise you'll need two buffers depending on how you are implementing it.


First pass - horizontal: Sample the values from the back buffer and write the new pixel value to the extra buffer.

Second pass - vertical: Sample the values from the extra buffer and write the new pixel value to the back buffer.


That's it in a nut shell. There's optimizations you can do like use two smaller buffers to do the blurring. Scale it down to a smaller buffer, blur between the two buffers, scale back up to the original size.

In Topic: Unable to view log info in LogCat with Android app

21 October 2015 - 10:31 AM

Thanks for all the info!

In Topic: Unable to view log info in LogCat with Android app

20 October 2015 - 09:09 PM

I tried messing with it again and now the __android_log_print is working. these tools...

In Topic: Stencil buffer not working on Android NDK implementation

20 October 2015 - 11:23 AM

I'm only setting it in the init now. My stencil needs at the moment are very simple but I can't see needing to do more at this time.


The way to think of this is the glStencilMask() is like glClearColor, you're telling OpenGL what value to use when clearing the stencil buffer, just like the color or depth buffer. This all happens when glClear is used. Example: glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT )


See my adjusted code below.

*    desc:  Init the game
void CBaseGame::Init()
    // Init the clear color
    glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
    // Init the stencil clear mask based on the bit size of the mask
    // Stencil buffer can only be 1 or 8 bits per pixel
    if( CSettings::Instance().GetStencilBufferBitSize() == 1 )
    else if( CSettings::Instance().GetStencilBufferBitSize() == 8 )

    // Cull the back face

    // Enable alpha blending

    // Make the zero texture the active texture

    // Show the window
    CDevice::Instance().ShowWindow( true );

    if( CSettings::Instance().GetClearTargetBuffer() )
        m_clearBufferMask |= GL_COLOR_BUFFER_BIT;

    if( CSettings::Instance().GetEnableDepthBuffer() )
        m_clearBufferMask |= GL_DEPTH_BUFFER_BIT;
    if( CSettings::Instance().GetClearStencilBuffer() )
        m_clearBufferMask |= GL_STENCIL_BUFFER_BIT;
    // Display a black screen
    glClear( GL_COLOR_BUFFER_BIT );
    SDL_GL_SwapWindow( m_pWindow );

}   // Init