English
Source / code snippets

Images Bmp directly Opengl Program Textures

 
an small demonstration to that direct reading of BMP-Files for Textures with ASM-command/XPIA and the commands "GetDIBits" for OpenGL.
The colour "schwarz" becomes transparent drawn.
around the Program To using, must yet 2 pattern-BMP-Files prepares go.
by the good Help in the Forum could I the umsetzen.
by the 2D vorraussetzungen with Opengl can very beautiful Sprites produce and so works.
with the Keys "Q,W,E,S" can a little bit speilen.

These demonstration can eachone for itself new umsetzen and in Own programs pieces of it take.
CompileMarkSeparation
 $H Windows.ph
 {$iq}
declare bild1$
declare x1!,y1!,dx!,dy!,winkel!
declare hWin&

If 0

    AsmStart rgb_umwandlung

        Parameters bildxy#,a
        LOCAL r :BYTE
        LOCAL g :BYTE
        LOCAL b :BYTE
        LOCAL w :DWORD
        mov eax,para2
        mov w,eax
        mov ecx,0
        mov ebx,para1

        .while ecx<=w

            mov al,[ebx+ecx]
            mov b,al
            mov al,[ebx+ecx+1]
            mov g,al
            mov al,[ebx+ecx+2]
            mov r,al
            and b,255
            and g,255
            and r,255
            mov al,b

            .if al>0

                mov al,255
                mov [ebx+ecx+3],al
                mov al,b
                mov [ebx+ecx+2],al
                mov al,r
                mov [ebx+ecx],al
                jmp weiter

            .endif

            mov al,g

            .if al>0

                mov al,255
                mov [ebx+ecx+3],al
                mov al,b
                mov [ebx+ecx+2],al
                mov al,r
                mov [ebx+ecx],al
                jmp weiter

            .endif

            mov al,r

            .if al>0

                mov al,255
                mov [ebx+ecx+3],al
                mov al,b
                mov [ebx+ecx+2],al
                mov al,r
                mov [ebx+ecx],al
                jmp weiter

            .endif

            mov al,0
            mov [ebx+ecx+3],al
            mov al,b
            mov [ebx+ecx+2],al
            mov al,r
            mov [ebx+ecx],al
            weiter:
            add ecx,4

        .endw

    AsmEnd

EndIf

Window 20,20-600,450
Cls @RGB(220,220,220)
oGL("Init", %hWnd, 0,0, 0, 0)
oGL("PosMode", 1)
bild1$="muster.bmp"
var tex.auto%=erzeugetex(bild1$)
var tex.grund%=OGL("loadtexturebmp","muster1.bmp",3)
var ende%=1

WHILE ende%

    sleep 1

    if isKey(65)

        ende% = 0

    endif

    if isKey(81)

        winkel!=winkel!+0.4

    endif

    if isKey(69)

        winkel!=winkel!-0.4

    endif

    if isKey(87)

        y1!=Sin(winkel!/180.0*pi())*0.02
        x1!=Cos(winkel!/180.0*pi())*0.02
        dx!=dx!-x1!
        dy!=dy!-y1!

    endif

    if isKey(83)

        y1!=Sin(winkel!/180.0*pi())*0.02
        x1!=Cos(winkel!/180.0*pi())*0.02
        dx!=dx!+x1!
        dy!=dy!+y1!

    endif

    drawglscene()

ENDWHILE

proc drawglscene

    OGL("Clear")
    OGL("glEnable",~GL_BLEND)
    OGL("glBlendFunc",~GL_SRC_ALPHA, ~GL_ONE_MINUS_SRC_ALPHA)
    OGL("move",0,0,-3)
    OGL("texture",tex.grund%,10)
    OGL("move",0,0,0)
    OGL("quad",8,8)
    OGL("origin",dx!,dy!,-3)
    OGL("texture",tex.auto%,1)
    OGL("rotate",0,0,winkel!+90)
    OGL("quad",0.7,0.7)
    OGL("show")

endproc

proc erzeugetex

    parameters namebild$
    declare width%,height%
    declare Handle&,a&
    declare bmi#,bildxy#
    var texid%=0
    mcls 0,0,0
    startpaint -1
    mloadbmp namebild$,0,0
    endpaint
    height%=%bmpx
    width%=%bmpy
    def &BI_RGB 0
    def &DIB_RGB_COLORS 0
    struct BITMAPINFOHEADER =
    biSize&, biWidth&, biHeight&, biPlanes%, biBitCount%, biCompression&,
    biSizeImage&, biXPelsPerMeter&, biYPelsPerMeter&, biClrUsed&, biClrImportant&
    dim bmi#,BITMAPINFOHEADER
    clear bmi#

    with bmi#

        .biSize&        = sizeof(bmi#)
        .biWidth&       = width%
        .biHeight&      = height%
        .biPlanes%      = 1
        .biBitCount%    = 32
        .biCompression& = &BI_RGB
        .biSizeImage&   = ((.biWidth& * .biBitCount%  8 - 1) | 3 + 1) * abs(.biHeight&)

    endwith

    Handle& = Create("hPic", -1, namebild$)
    a&=bmi#.biSizeImage&
    dim bildxy#,a&
    ~GetDIBits(%hdc,Handle&,0,bmi#.biHeight&,bildxy#,bmi#,0)
    Call(xpia_getprocaddressm(xpia_hmodule&,"rgb_umwandlung"),bildxy#,a&)
    OGL("glGenTextures",1,ADDR(texid%))
    OGL("glBindTexture",~GL_TEXTURE_2D,texid%)
    OGL("glEnable",~GL_ALPHA_TEST)
    OGL("glAlphaFunc",~GL_GREATER, 0.1)
    OGL("glTexParameteri",~GL_TEXTURE_2D, ~GL_TEXTURE_MAG_FILTER, ~GL_LINEAR)
    OGL("glTexParameteri",~GL_TEXTURE_2D, ~GL_TEXTURE_MIN_FILTER, ~GL_LINEAR)
    OGL("gluBuild2DMipmaps",~GL_TEXTURE_2D, ~GL_RGBA, height%, width%, ~GL_RGBA, ~GL_UNSIGNED_BYTE, bildxy#)
    dispose bmi#
    dispose bildxy#
    RETURN texid%

endproc

 
08/19/08  
 




Jörg
Sellmeyer
by me becomes the first Image circa 90° against whom Uhrzeigersinn turned. If solid is, can I the at least in the code not find.
 
Windows XP SP2 XProfan X4
... und hier mal was ganz anderes als Profan ...
08/19/08  
 



because it The Achsen (not) vertauscht.
 
08/19/08  
 



the was in my think about solid , because it The Grafikform required.

OGL("rotate",0,0,winkel!+90) set : OGL("rotate",0,0,winkel! )

can also yet The SINUS and COSINUS change at will.

mfg
 
08/19/08  
 




Jörg
Sellmeyer
OK, had I do not seen.
 
Windows XP SP2 XProfan X4
... und hier mal was ganz anderes als Profan ...
08/19/08  
 



The ASM-code is a bisschen gekürzt with : "jmp wandle".
And so can itself then on the code yet calm with better routines.

If one The DLL takes, can too this reinsetzen :

DEF rgb_umwandlung(2) ! "muster.dll","rgb_umwandlung"
and so Call:
rgb_umwandlung(bildxy#,a&)
CompileMarkSeparation
If 0

    AsmStart rgb_umwandlung

        Parameters bildxy#,a
        LOCAL r :BYTE
        LOCAL g :BYTE
        LOCAL b :BYTE
        LOCAL w :DWORD
        mov eax,para2
        mov w,eax
        mov ecx,0
        mov ebx,para1

        .while ecx<=w

            mov al,[ebx+ecx]
            mov b,al
            mov al,[ebx+ecx+1]
            mov g,al
            mov al,[ebx+ecx+2]
            mov r,al
            and b,255
            and g,255
            and r,255
            mov al,b

            .if al>0

                jmp wandle

            .endif

            mov al,g

            .if al>0

                jmp wandle

            .endif

            mov al,r

            .if al>0

                jmp wandle

            .endif

            mov al,0
            mov [ebx+ecx+3],al
            mov al,b
            mov [ebx+ecx+2],al
            mov al,r
            mov [ebx+ecx],al
            jmp weiter
            wandle:
            mov al,255
            mov [ebx+ecx+3],al
            mov al,b
            mov [ebx+ecx+2],al
            mov al,r
            mov [ebx+ecx],al
            weiter:
            add ecx,4

        .endw

    AsmEnd

ss=s4 href='./../../function-references/XProfan/endif/'>EndIf
 
08/19/08  
 



Zum Quelltext


Topictitle, max. 100 characters.
 

Systemprofile:

no Systemprofil laid out. [anlegen]

XProfan:

 Posting  Font  Smilies  ▼ 

Please register circa a Posting To verfassen.
 

Topic-Options

7.055 Views

Untitledvor 0 min.
H.Brill10/29/23
Tango10/30/21
Sven Bader07/09/21
Normann Strübli08/03/20
More...

Themeninformationen

this Topic has 3 subscriber:

unbekannt (3x)
Jörg Sellmeyer (2x)
iF (1x)


Admins  |  AGB  |  Applications  |  Authors  |  Chat  |  Privacy Policy  |  Download  |  Entrance  |  Help  |  Merchantportal  |  Imprint  |  Mart  |  Interfaces  |  SDK  |  Services  |  Games  |  Search  |  Support

One proposition all XProfan, The there's!


My XProfan
Private Messages
Own Storage Forum
Topics-Remember-List
Own Posts
Own Topics
Clipboard
Log off
 Deutsch English Français Español Italia
Translations

Privacy Policy


we use Cookies only as Session-Cookies because of the technical necessity and with us there no Cookies of Drittanbietern.

If you here on our Website click or navigate, stimmst You ours registration of Information in our Cookies on XProfan.Net To.

further Information To our Cookies and moreover, How You The control above keep, find You in ours nachfolgenden Datenschutzerklärung.


all rightDatenschutzerklärung
i want none Cookie