Dateien laden vor Graphics - BM ist ziemlich flexibel
Übersicht

D²OBetreff: Dateien laden vor Graphics - BM ist ziemlich flexibel |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Hi,
mir war gar nicht bewust wie flexibel BM ist ![]() Hier kann man Grafiken und Sound dateien vor dem Graphics befehl laden, die auflösung wärend der mainschleife ändern ohne alles neu zu laden, den Treiber wärend der laufzeit ändern DX<->OpenGL. Mich würde mal Interessieren ob das bei Euch auch funktioniert oder ob das ganze Systemabhängig ist. Problemme gabs bei mir nur beim wechsel zwischen 16 und 32bit farben und das auch nur im OGL modus, darum habe ich es erst mal drausen gelassen. Taste : 9 und 0 = Vollbild/Fenster 7 und 8 = DX / OpenGL Pfeil hoch/runter = Auflösung zwischen 800er und 1024er wechseln. Dann noch was nebenbei, benutzt man sehr grosse Arrays oder viele Grafiken/Sounds und man erstellt/ladet das ganze vor Graphics geht es um einiges flotter. Hier gibts das ganze mit exe,code und mediafiles http://www.deuteriumoxid.com/download/gfx_test.rar Code: [AUSKLAPPEN] Framework brl.D3D7Max2D
Import BRL.FreeAudioAudio Import BRL.OGGLoader Import BRL.PNGLoader SuperStrict Global sound:TSound = LoadSound("fun1.ogg",True) PlaySound sound Global bild:TImage = LoadAnimImage("1.png",64,64,0,4) Global frame:Int = 0 Global posx:Int = 0,posy:Int = 0 Local win:Tgraphics = New Tgraphics win.mTgraphics(1) 'Treiber auswahl,1 = GL, 0 = DX Graphics win.x,win.y,win.mode,win.frame While Not KeyHit(KEY_ESCAPE) DrawText win.driver,10,10 frame:+1 If frame > 3 Then frame = 0 posx:+1 If posx > win.x posx = 0 posy:+10 If posy > win.y Then posy = 0 End If DrawImage bild,posx,posy,frame If KeyHit(KEY_0) EndGraphics win.mode = 16 Graphics win.x,win.y,win.mode,win.frame EndIf If KeyHit(KEY_9) EndGraphics win.mode = 0 Graphics win.x,win.y,win.mode,win.frame EndIf If KeyHit(KEY_8) win.mTgraphics(0) EndGraphics Graphics win.x,win.y,win.mode,win.frame EndIf If KeyHit(KEY_7) win.mTgraphics(1) EndGraphics Graphics win.x,win.y,win.mode,win.frame EndIf If KeyHit(KEY_up) EndGraphics win.x = 1024 win.y = 768 Graphics win.x,win.y,win.mode,win.frame EndIf If KeyHit(KEY_down) EndGraphics win.x = 800 win.y = 600 Graphics win.x,win.y,win.mode,win.frame EndIf Flip Cls Wend Type Tgraphics Field x:Int = 800 Field y:Int = 600 Field mode:Int = 0 '0 = FensterModus 'ansonsten Farbtiefe für den Vollbildmodus 'angeben, z.B. 16 oder 32 Field frame:Int = 0 'Bildschirmwiederholung angeben '0 = Vsync von der Treibereinstellung bernommen '-1 = Vsync off Field driver:String Method mTgraphics(l_in:Int = 0) Select l_in Case 0 SetGraphicsDriver D3D7Max2DDriver:TD3D7Max2DDriver() driver:String ="DX7" Case 1 SetGraphicsDriver GLMax2DDriver:TGLMax2DDriver() driver:String ="OpenGL" Default SetGraphicsDriver D3D7Max2DDriver:TD3D7Max2DDriver() driver:String ="OpenGL" EndSelect End Method End Type |
||
Blitz+; Blitz3d; BlitzMax; GLBasic; Purebasic;
GameMaker Studio 1.4xx; AGK; |
![]() |
Rone |
![]() Antworten mit Zitat ![]() |
---|---|---|
moin,
finde ich gut, aber bei mir geht auch VSync an und aus....und das ziemlich unberechenbar... mfg |
||
Dreamora |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Das ganze funktioniert immer.
Wurde aus einem einfachen Grund integriert: Canvas! Denn ohne diese Möglichkeit wars ganz einfach so das jedes Bild für jeden Canvas neu hätte geladen werden müssen (da jeder ein eigenes Grafikcontext ist), was natürlich recht übel wäre. ABER: Du kannst keine images laden. was dein image laden tut insofern ist nur die pixmap laden. das image wird erst beim ersten zeichnen erzeugt. |
||
Ihr findet die aktuellen Projekte unter Gayasoft und könnt mich unter @gayasoft auf Twitter erreichen. |
D²O |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Ahh, OK.
Aber im dem fall hat man bei BM die möglichkeit die Auflösung zu ändern ohne das man halt die Grafiken (Pixmap) neu zuladen. In BB musste man ja im grunde wieder an den Codeanfang springen und alles neu von vorne laufen(Laden) lassen. Ist doch schon nicht schlecht, oder? Rone hat Folgendes geschrieben: moin,
finde ich gut, aber bei mir geht auch VSync an und aus....und das ziemlich unberechenbar... Jepp, das ist bei mir auch so. Habe den code mal etwas geändert, win.frame mal 75 gestellt. Dann lauft es bei mir in allen variante zwischen 70 und 76 frames. Code: [AUSKLAPPEN] Framework brl.D3D7Max2D
Import BRL.FreeAudioAudio Import BRL.OGGLoader Import BRL.PNGLoader SuperStrict Global sound:TSound = LoadSound("fun1.ogg",True) PlaySound sound Global bild:TImage = LoadAnimImage("1.png",64,64,0,4) Global frame:Int = 0 Global posx:Int = 0,posy:Int = 0 Local win:Tgraphics = New Tgraphics win.mTgraphics(1) 'Treiber auswahl,1 = GL, 0 = DX win.frame = 75 Graphics win.x,win.y,win.mode,win.frame While Not KeyHit(KEY_ESCAPE) DrawText win.driver,10,10 DrawText f_myframe(),10,30 frame:+1 If frame > 3 Then frame = 0 posx:+1 If posx > win.x posx = 0 posy:+10 If posy > win.y Then posy = 0 End If DrawImage bild,posx,posy,frame If KeyHit(KEY_0) EndGraphics win.mode = 16 Graphics win.x,win.y,win.mode,win.frame EndIf If KeyHit(KEY_9) EndGraphics win.mode = 0 Graphics win.x,win.y,win.mode,win.frame EndIf If KeyHit(KEY_8) win.mTgraphics(0) EndGraphics Graphics win.x,win.y,win.mode,win.frame EndIf If KeyHit(KEY_7) win.mTgraphics(1) EndGraphics Graphics win.x,win.y,win.mode,win.frame EndIf If KeyHit(KEY_up) EndGraphics win.x = 1024 win.y = 768 Graphics win.x,win.y,win.mode,win.frame EndIf If KeyHit(KEY_down) EndGraphics win.x = 800 win.y = 600 Graphics win.x,win.y,win.mode,win.frame EndIf Flip Cls Wend Function f_myframe:Int( l_in:Short = 1000) Global gfps:Int, gtempfps:Int ,gtime:Int If MilliSecs()- gtime>l_in gfps = gtempfps gtempfps = 0 gtime = MilliSecs() EndIf gtempfps:+1 Return gfps End Function Type Tgraphics Field x:Int = 800 Field y:Int = 600 Field mode:Int = 0 '0 = FensterModus 'ansonsten Farbtiefe für den Vollbildmodus 'angeben, z.B. 16 oder 32 Field frame:Int = 0 'Bildschirmwiederholung angeben '0 = Vsync von der Treibereinstellung bernommen '-1 = Vsync off Field driver:String Method mTgraphics(l_in:Int = 0) Select l_in Case 0 SetGraphicsDriver D3D7Max2DDriver:TD3D7Max2DDriver() driver:String ="DX7" Case 1 SetGraphicsDriver GLMax2DDriver:TGLMax2DDriver() driver:String ="OpenGL" Default SetGraphicsDriver D3D7Max2DDriver:TD3D7Max2DDriver() driver:String ="OpenGL" EndSelect End Method End Type |
||
Blitz+; Blitz3d; BlitzMax; GLBasic; Purebasic;
GameMaker Studio 1.4xx; AGK; |
Übersicht


Powered by phpBB © 2001 - 2006, phpBB Group