Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
D

Dan 0

@Dan 0
About
Posts
33
Topics
0
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • How to make truncation in C++
    D Dan 0

    The FPU already does this for you.

       //! Round double to integer
    inline int iround(double v){
    	int retval;
    	\_\_asm fld qword ptr \[v\]
    	\_\_asm fistp dword ptr \[retval\]
    	return retval;
    
    }
    
    //! Round double to unsigned integer
    inline unsigned int uround(double v){
    	unsigned retval;
    	\_\_asm fld qword ptr \[v\]
    	\_\_asm fistp dword ptr \[retval\]
    	return retval;
    }
    
    C / C++ / MFC tutorial c++ question

  • check existence of file in C++
    D Dan 0

    You can also try in Windows,

    if ( 0 == _access( database.c_str(), 0 ) ) {
    cout<<"No database found.\n"
    }

    and the nix equivelant is

    if ( 0 == access( database.c_str(), 0 ) ) {
    cout<<"No database found.\n"
    }

    C / C++ / MFC question c++ perl database

  • Binary Predicate for Templated Class
    D Dan 0

    You can try

    template< typename T >
    struct curve_lt : public binary_function <T, T, bool>
    {
    bool operator()( const T &rhs, const T &lhs )
    {
    return rhs.getDate() < lhs.getData();
    }
    };
    ......
    i = lower_bound(vector.begin(), vector.end(), &c, curve_lt());

    C / C++ / MFC csharp visual-studio graphics algorithms help

  • Scaling Rotated Points
    D Dan 0

    Why don't you just inverse rotate the mouse movement?

    Graphics graphics question help tutorial

  • openGL SwapBuffers
    D Dan 0

    I get the feeling that the best approach for you is to use a FBO and do offscreen rendering. Google "opengl render to texture", you can bind a frame buffer at the start of your rendering, then blit it as needed.

    Graphics graphics question com game-dev announcement

  • openGL SwapBuffers
    D Dan 0

    Matters on what you are trying to do, you don't need to use wm_paint at all, you can update the render whenever you feel you need to. If you need to continually update the window, u can use a pump, ie:

    bool quit = false;
    while(!quit) {
        PeekMessage(&msg, hwnd, NULL, NULL, PM\_REMOVE);
        if (msg.message == WM\_QUIT) {
            quit = true;
    
        } else {
            DoRendering();
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
    }
    

    Or you can simply swap buffers when u only render, not on every paint.

    Graphics graphics question com game-dev announcement

  • openGL SwapBuffers
    D Dan 0

    No need to render twice, render once and copy.

    // Back buffer to front.
    glReadBuffer(GL_BACK);
    glDrawBuffer(GL_FRONT);
    glCopyPixels(GL_COLOR);

    // Front buffer to back.
    glReadBuffer(GL_FRONT);
    glDrawBuffer(GL_BACK);
    glCopyPixels(GL_COLOR);

    Graphics graphics question com game-dev announcement

  • [OpenGL] Drawing line with patterns
    D Dan 0

    The counter is internal to the raster unit, it is reset to zero on a glBegin and incremented for every antialiased pixel box until glEnd is called. Factor defines how many pixel blocks are printed for each single bit, so lets say you wanted to print 110011, what you could also do is 101 with factor = 2. So basically, you may not get the exact pattern you want, but by basing the factor to the smallest consecutive bits you can have a bit more freedom.

    Graphics graphics com game-dev linux regex

  • [OpenGL] Drawing line with patterns
    D Dan 0

    Not directly, but you could play with the bit pattern and the scale to make your pattern fit, using the following equation, pattern bit ( counter / factor ) mod 16

    Graphics graphics com game-dev linux regex

  • Rounding float values
    D Dan 0

    Fastest way, assembler automatically will do rounding for you, but std lib does it some bakwards way

    inline int iround(double v)
    {
    int retval;
    __asm fld qword ptr [v]
    __asm fistp dword ptr [retval]
    return retval;
    }

    C / C++ / MFC c++ question

  • brush problem in c#...
    D Dan 0

    The best way to handle this situation is to use an interpolation function to create a curve that smoothly joins the input points of the mouse. The easiest pseudo sample is below, but you can expand it to use bicubic or any spline function.

    void DrawPoint( double x, double y )
    {
    ...paint single brush dab.
    }

    void DrawLine( double x0, double y0, double x1, double y1, double spacing )
    {
    // get delta
    double dx = x1-x0;
    double dy = y1-y0;

    // Get length
    double dist = sqrt( dx \* dx + dy \* dy );
    
    // Normalize
    dx \*= 1.0 / dist;
    dy \*= 1.0 / dist;
    
    // Travel down the line ( x0, y0 ) ( x1, y1 )
    for ( double p = spacing; p <= dist; p+= spacing ) {
    	// Draw a single point at spacing pixels apart.
    	double px = x0 + p \* dx;
    	double py = y0 + p \* dy;
    	DrawPoint( px, py );
    }
    

    }

    void MyPaintCode( )
    {
    for ( int i = 0; i < NumberofPoints; i++ ) {
    // Draw lines between input points with 1 pixel spacing.
    PaintLine( Input_x[ i ], Input_y[ i ], 1.0 );
    }
    }

    Graphics question csharp data-structures help tutorial

  • How can get all files from selected directory?
    D Dan 0

    This function will return the directory contents in a vector of strings.

    std::vector< std::wstring > GetDirectoryList( const std::wstring &strDirectory )
    {
    std::vector< std::wstring > contents;
    WIN32_FIND_DATA data;
    HANDLE hFind = FindFirstFile( (strDirectory + L"\\*").c_str() , &data);

     if ( hFind != INVALID\_HANDLE\_VALUE ) {
          do {
               contents.push\_back( data.cFileName );
          } while ( FindNextFile( hFind , &data ) != 0 );
          FindClose( hFind );
     }
     return contents;
    

    }

    C / C++ / MFC help tutorial question

  • RegSvr32 exit codes [modified]
    D Dan 0

    Take a look here. http://www.dependencywalker.com/faq.html[^] Specifically Can Dependency Walker help me figure out why my component won't register?

    C / C++ / MFC delphi linux help question

  • Dll function calls are not called right
    D Dan 0

    Where is the rest of the Factory() function, could be an allocation error.

    C / C++ / MFC help

  • DWORD PTR [modified]
    D Dan 0

    DWOD defines the bit size of the memory being used, PTR is a modifier indicating that we are pointing to a memory location. The following are defined in x86

     BYTE - 8 bits
     WORD - 16 bits
     DWORD - 32 bits ( double word )
     QWORD - 64 bits ( quadruple word )
     DQWORD - 128 bits ( double quadruple word )
    
    C / C++ / MFC question c++

  • How to cut ellipse in to four regions.
    D Dan 0

    You could use GDI+ FillPie function. Just get the bounds of the ellipse, ie

    void Draw( int px, int py, int xRadius, int yRadius )
    {
    Graphics *g = ....
    Rect rcBnds( px, py, xRadius*2, yRadius*2 );
    Brush *brColor = first color;
    // Draw lower right
    g->FillPie( brColor, rcBnds, 0, 90 );
    brColor = second color;
    g->FillPie( brColor, rcBnds, 90, 180 );
    brColor = third color;
    g->FillPie( brColor, rcBnds, 180, 270 );
    brColor = last color;
    g->FillPie( brColor, rcBnds, 270, 360 );
    }

    Of course you can use regular GDI and Pie(), you just have to calc the points yourself, which is easy since you are just dividing into 4 parts.

    C / C++ / MFC graphics tutorial

  • c2120 error
    D Dan 0

    Because you are missing a comma after "test123"?

    C / C++ / MFC help

  • Basic operator overloading
    D Dan 0

    The code is fine, the compiler will generate operator= and the copy constructor for you, it's simply implicit instead of explicit. Rhe default implementation is a simple bitwise copy. The way the compiler generates the copy is sort of like:

    ClassA::ClassA( const ClassA &from)
    :member1( from.member1 )
    ,member2( from.member2 )
    ,.... etc
    {}

    This is perfectly fine for this class since you don't have any pointers to worry about. The default for operator= is functionally the same as the copy constructor. So your code for operator+ is correct. this is copied to result. result is modified. this actually remains constant. So actually to be on the safe side you should do.

    ......
    CC operator+( CC &source ) const;
    ......
    CC CC::operator+( CC &source ) const
    {
    CC result = *this;
    double sum = source.Query_X() + X;
    result.Set_X( sum );
    return result;
    }

    C / C++ / MFC question database tutorial learning

  • Inverse of NORMSDIST function
    D Dan 0

    1 / NORMSDIST

    Algorithms tutorial

  • What's the difference between function atof() and _tstof()?
    D Dan 0

    Thats the TCHAR mapping for atof/_wtof. By default vc2008 defines TCHAR as a native type. You can use it in vc6, you just need to do so explicitly.

    C / C++ / MFC c++ question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups