User Tag List

Results 1 to 3 of 3

Thread: Can't seem to graba bitmap pointer?

  1. #1
    The Timelord
    QDB Manager
    ZC Developer

    Join Date
    Oct 2006
    Location
    Prydon Academy
    Posts
    1,396
    Mentioned
    112 Post(s)
    Tagged
    1 Thread(s)
    vBActivity - Stats
    Points
    4,781
    Level
    21
    vBActivity - Bars
    Lv. Percent
    73.06%

    Can't seem to graba bitmap pointer?

    Spoiler: show
    Code:
    //Bitmap Quad()
    
    void do_bmpdrawquadr(BITMAP *bmp, int *sdci, int xoffset, int yoffset)
    {
        //sdci[1]=layer
        //sdci[2]=x1
        //sdci[3]=y1
        //sdci[4]=x2
        //sdci[5]=y2
        //sdci[6]=x3
        //sdci[7]=y3
        //sdci[8]=x4
        //sdci[9]=y4
    	//sdci[10]=sourcex
    	//sdci[11]=sourcey
    	//sdci[12]=sourcew
    	//sdci[13]=sourceh
        //sdci[14]=width
        //sdci[15]=height
        //sdci[16]=tile/combo
        //sdci[17]=polytype
        
        int x1 = sdci[2]/10000;
        int y1 = sdci[3]/10000;
        int x2 = sdci[4]/10000;
        int y2 = sdci[5]/10000;
        int x3 = sdci[6]/10000;
        int y3 = sdci[7]/10000;
        int x4 = sdci[8]/10000;
        int y4 = sdci[9]/10000;
        int sx = sdci[10]/10000;
        int sy = sdci[11]/10000;
        int sw = sdci[12]/10000;
        int sh = sdci[13]/10000;
        int w = sdci[14]/10000;
        int h = sdci[15]/10000;
        int bitmapIndex = sdci[12]/10000;
        int polytype = sdci[13]/10000;
        
        //todo: finish palette shading
        /*
        POLYTYPE_FLAT
        POLYTYPE_GCOL
        POLYTYPE_GRGB
        POLYTYPE_ATEX
        POLYTYPE_PTEX
        POLYTYPE_ATEX_MASK
        POLYTYPE_PTEX_MASK
        POLYTYPE_ATEX_LIT
        POLYTYPE_PTEX_LIT
        POLYTYPE_ATEX_MASK_LIT
        POLYTYPE_PTEX_MASK_LIT
        POLYTYPE_ATEX_TRANS
        POLYTYPE_PTEX_TRANS
        POLYTYPE_ATEX_MASK_TRANS
        POLYTYPE_PTEX_MASK_TRANS
        */
        polytype = vbound(polytype, 0, 14);
    
        
        
        BITMAP *tex = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex);
        
        /*
        
        //When I did this, ZC crashed...
        
        BITMAP *sourceBitmap = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex);
        BITMAP* subBmp = 0;
        
    	subBmp = script_drawing_commands.AquireSubBitmap(w, h);
    	stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, w, h);
        
        */
        
        bool mustDestroyBmp = false;
        
        
        if(!tex)
        {
            mustDestroyBmp = true;
            Z_message("BitmapQuad() : Invalid Bitmap ID", bitmapIndex);
            return; //non power of two error
            clear_bitmap(tex);
        }
        
        
        V3D_f V1 = { static_cast<float>(x1+xoffset), static_cast<float>(y1+yoffset), 0, 0,                             0,                             0 };
        V3D_f V2 = { static_cast<float>(x2+xoffset), static_cast<float>(y2+yoffset), 0, 0,                             static_cast<float>(h), 0 };
        V3D_f V3 = { static_cast<float>(x3+xoffset), static_cast<float>(y3+yoffset), 0, static_cast<float>(w), static_cast<float>(h),0 };
        V3D_f V4 = { static_cast<float>(x4+xoffset), static_cast<float>(y4+yoffset), 0, static_cast<float>(w), 0,                              0 };
        
        Z_message("BitmapQuad() : Trying to draw Bitmap ID", bitmapIndex);
        quad3d_f(bmp, polytype, tex, &V1, &V2, &V3, &V4);
        
        if(mustDestroyBmp)
            destroy_bitmap(tex);
    //    destroy_bitmap(sourceBitmap);
            
    }


    When run, the statement if ( !tex ) catches, and returns an error.

    What did I do wrongly here, that it isn't grabbing an existing ZScript bitmap to use as the texture?

    When I tried to make a bitmap, and blit, then use the dest bitmap, ZC crashed. The code that I tried for that is in a comment block.

  2. #2
    The Time-Loop Continues ZC Developer
    Gleeok's Avatar
    Join Date
    Apr 2007
    Posts
    4,827
    Mentioned
    259 Post(s)
    Tagged
    10 Thread(s)
    vBActivity - Stats
    Points
    12,978
    Level
    33
    vBActivity - Bars
    Lv. Percent
    28.31%
    What is the value of bitmapIndex? It appears to be wrong. Also what debugger are you (not) using?


    I already added the ability to use off-screen bitmaps for every tri/quad/polygon drawing command in ZScript [in the next version (not finished yet)].


    Ex Zscript:
    Code:
    Screen->SetRenderSource(RT_BITMAP1); // All subsequent drawing commands use bitmap 1
    Screen->DrawQuad(...);
    Screen->SetRenderSource(RT_DEFAULT);
    This post contains the official Gleeok seal of approval. Look for these and other posts in an area near you.

  3. #3
    The Timelord
    QDB Manager
    ZC Developer

    Join Date
    Oct 2006
    Location
    Prydon Academy
    Posts
    1,396
    Mentioned
    112 Post(s)
    Tagged
    1 Thread(s)
    vBActivity - Stats
    Points
    4,781
    Level
    21
    vBActivity - Bars
    Lv. Percent
    73.06%
    Quote Originally Posted by Gleeok View Post
    What is the value of bitmapIndex? It appears to be wrong. Also what debugger are you (not) using?


    I already added the ability to use off-screen bitmaps for every tri/quad/polygon drawing command in ZScript [in the next version (not finished yet)].


    Ex Zscript:
    Code:
    Screen->SetRenderSource(RT_BITMAP1); // All subsequent drawing commands use bitmap 1
    Screen->DrawQuad(...);
    Screen->SetRenderSource(RT_DEFAULT);


    That's what I thought that was, but the inherent lack of stability of that stuff, when I merged it, essentially told me that none of it was going to work as-is.

    I was using the value of RT_BITMAP1, passed through sdci[n]/10000, with zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex);
    Effectively, zscriptDrawingRenderTarget->GetBitmapPtr(RT_BITMAP1/10000);

    That seems to work everywhere else...?

    Would you making making the entire screen bitmap, as it is rendered each frame after drawing objects/sprites,including the passive subscreen, available as a render source through that function?

    I managed to merge enough from allegro 4.4.2 thus far, to get draw_sprite_ex to work, but I;m still missing some component that is critical to rotate_sprite_trans and pivot_sprite_trans. I took a break from drawing functions, to add Link->Diagonal, and Link->BigHitbox, both with abstraction functions, and I know that Diagonal works. I haven't tested BigHitbox, primarily because of the set-up time to make big link tiles.

    At least I'm sure now, that I comprehend how to add class variables, properly. That will help with Itemdata, although I'm uncertain how to add an ID field to the classes, permitting for example, 'this->ID ' in item scripts, to grab itemdata values.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Armageddon Games is a game development group founded in 1997. We are extremely passionate about our work and our inspirations are mostly drawn from games of the 8-bit and 16-bit era.
Social