Changeset 1069


Ignore:
Timestamp:
Nov 15, 2011, 1:52:42 PM (11 years ago)
Author:
gary
Message:

tutorial: port the Mandelbrot dithering shader to Cg.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/platform/sdl/sdlapp.cpp

    r1063 r1069  
    7676void SdlApp::ShowPointer(bool show)
    7777{
     78#if defined USE_SDL
    7879    SDL_ShowCursor(show ? 1 : 0);
     80#endif
    7981}
    8082
  • trunk/test/math/remez.cpp

    r1050 r1069  
    3131real myfun(real const &y)
    3232{
     33real k1024 = 1024;
     34real klog32 = log((real)32);
     35return (y - k1024) / log2(log(sqrt(y))/klog32);
    3336    real x = sqrt(y);
    3437    return (sin(x) - x) / (x * y);
     
    3740real myerr(real const &y)
    3841{
     42return myfun(y);
     43return real::R_1;
    3944    real x = sqrt(y);
    4045    return sin(x) / (x * y);
     
    4348int main(int argc, char **argv)
    4449{
    45     RemezSolver<6> solver;
    46     solver.Run(real::R_1 >> 400, real::R_PI_2 * real::R_PI_2, myfun, myerr, 40);
     50    RemezSolver<3> solver;
     51    solver.Run((real)(1024.001), (real)(1024 * 1024), myfun, myerr, 40);
    4752
    4853    return EXIT_SUCCESS;
  • trunk/test/tutorial/tut03.cpp

    r1068 r1069  
    111111
    112112        ivec3 buttons = Input::GetMouseButtons();
     113#ifdef __CELLOS_LV2__
     114        if (true)
     115#else
    113116        if ((buttons[0] || buttons[2]) && mousepos.x != -1)
     117#endif
    114118        {
    115119            f64cmplx oldcenter = m_center;
    116120            double oldradius = m_radius;
     121#ifdef __CELLOS_LV2__
     122            m_radius *= pow(2.0, -deltams * 0.00015);
     123            m_center = f64cmplx(0.001643721971153, 0.822467633298876);
     124#else
    117125            double zoom = pow(2.0, (buttons[0] ? -deltams : deltams) * 0.0025);
    118126            if (m_radius * zoom > 8.0)
     
    123131            m_center = (m_center - worldmouse) * zoom + worldmouse;
    124132            worldmouse = m_center + ScreenToWorldOffset(mousepos);
     133#endif
    125134
    126135            /* Store the transformation properties to go from m_frame-1
     
    265274                "}",
    266275
    267                 "void main(float2 in_TexCoord : TEXCOORD0,"
    268                 "          uniform sampler2D tex,"
     276                "void main(float4 in_FragCoord : WPOS,"
     277                "          float2 in_TexCoord : TEXCOORD0,"
     278                "          uniform sampler2D in_Texture,"
    269279                "          out float4 out_FragColor : COLOR)"
    270280                "{"
    271                 "    out_FragColor = tex2D(tex, in_TexCoord);"
     281                "    float2 coord = in_TexCoord.xy;"
     282                "    float i = frac((in_FragCoord.x - 0.5) * 0.5) * 2.0;"
     283                "    float j = frac((in_FragCoord.y - 0.5 + i) * 0.5) * 2.0;"
     284                "    coord.y += i + j * 2;"
     285                "    coord.y *= 0.25;"
     286                "    float4 p = tex2D(in_Texture, coord);"
     287                "    out_FragColor = p;"
    272288                "}"
    273289#endif
Note: See TracChangeset for help on using the changeset viewer.