Wers schon getestet hat: Hab 2 kleine Bugs (mit Grim_System_SetState() und Grim_Quads_SetRotation()) gefunden, sind jetzt behoben.
Und hier noch die Übersetzung des 3. Tutorials:
Code: Alles auswählen
Procedure FrameFunc()
Static time.f
tex_id.l = Grim_Texture_Get("rendertarget")
; now let's set the texture as render target
If Grim_System_SetRenderTarget(tex_id) = #False
MessageRequester("Message","Failed To set render target!")
ProcedureReturn #False
EndIf
; now if succeeded all the quads are drawn into the
; TEXTURE. let's render text with random color:
r.f = Random(100) * 0.01
g.f = Random(100) * 0.01
b.f = Random(100) * 0.01
Grim_Quads_SetColor(r, g, b, 1)
; set the text size To 100% of the bitmap pixel size
Grim_System_SetState(#grSTATE_FONTSCALE, 1.0);
Grim_Quads_RenderText(Random(256), Random(256), "Grim")
; calling the funtion with parameter -1 (Default
; parameter) sets the target back To screen Buffer.
Grim_System_SetRenderTarget();
; now clear the screen to white
Grim_System_ClearScreen(1,1,1,0);
Grim_Quads_SetSubset(0,0,1,1);
Grim_Quads_SetColor(1,1,1,1);
; let's set the render target texture as current texture
Grim_Texture_Set(tex_id);
; let's draw couple of them on screen
Grim_Quads_Begin();
; rotate 45 degrees For artistic impression =)
Grim_Quads_SetRotation(3.141 / 4);
Grim_Quads_Draw(100,100,256,256);
Grim_Quads_SetRotation(3.141 / 3);
Grim_Quads_Draw(300,300,256,256);
Grim_Quads_End();
If Grim_Key_Down(#DIK_ESCAPE)
ProcedureReturn #False
EndIf
ProcedureReturn #True
EndProcedure
If OpenLibrary(0,"c:\purebasic\compilers\grim.dll")
If Grim_GetInterface(0,"c:\purebasic\compilers\grim.dll")
; this time we use the Default config box to set up
; screen mode and stuff.
If Grim_System_InvokeConfig() = #False
; user chose "Exit" from the dialog, so by all
; means let's exit..
Grim_Inferface_Release()
End
EndIf
; User chose "Run". The states grSTATE_WINDOWED,
; grSTATE_SCREENBPP/WIDTH/HEIGHT are now set for us.
; set the window title
Grim_System_SetState(#grSTATE_TITLE, "Grim tut 03 - Render Target: Texture");
Grim_System_SetState(#grSTATE_KEYBOARD, #True);
Grim_System_SetState(#grSTATE_FRAMEFUNC, @FrameFunc());
; some system states have to be set before call
; to Initiate(), some after
Grim_System_Initiate()
If Grim_Texture_Create("rendertarget", 256, 256) = #False
cout.s + Grim_System_GetErrorMessage() + #CRLF$
cout + "Render target texture creation failed."
cout + "Your display adapter might not support render"
cout + "target texs or you might be out of tex memory." + #CRLF$
MessageRequester("Message",cout)
EndIf
tex_id.l = Grim_Texture_Get("rendertarget")
; now let's set the texture as render target
If Grim_System_SetRenderTarget(tex_id) = #False
MessageRequester("Message","Failed to set render target!")
EndIf
; clear the TEXTURE to black
Grim_System_ClearScreen(0,0,0,0)
; set the target back to screen buffer:
Grim_System_SetRenderTarget();
Grim_System_Start()
Grim_System_Shutdown()
Grim_Inferface_Release()
EndIf
CloseLibrary(0)
EndIf