forum-msg-id-133996-edit

Original date:2019-07-01 02:14:11 Edited by: Icy_Viking Subject: Window Appears Briefly Then Disappears

Hello all,

I am currently wrapping the RayLib, https://www.raylib.com/index.html, while I don't have all of it wrapped yet, I decided to make a small test program to see if it is working. Right now, the window appears, but goes away quickly. Here is the code

--Wrapper Code 
public constant xInitWindow = define_c_proc(ray,"InitWindow",{C_INT,C_INT,C_POINTER}), 
				xWindowShouldClose = define_c_func(ray,"WindowShouldClose",{},C_BOOL), 
				xCloseWindow = define_c_proc(ray,"CloseWindow",{}) 
 
public procedure InitWindow(atom w,atom h,sequence title) 
 
 atom str = allocate_string(title,1) 
 c_proc(xInitWindow,{w,h,str}) 
	 
end procedure 
 
public function WindowShouldClose() 
 
 return c_func(xWindowShouldClose,{}) 
	 
end function 
 
public procedure CloseWindow() 
 
 c_proc(xCloseWindow,{}) 
	 
end procedure 
--Example Program 
include std/machine.e 
include Euraylib.ew 
 
atom width = 800, height = 600 
 
InitWindow(width,height,"Basic Win") 
 
	SetTargetFPS(30) 
 
while not WindowShouldClose()  do 
	 
	BeginDrawing() 
	 
	ClearBackground(0) 
	 
	EndDrawing() 
 
end while 
 
CloseWindow() 

I know it might be possible, I need to wrap more of the library. The C code below is the example, I am trying to re-create in Euphoria code.

 
#include "raylib.h" 
 
int main(void) 
{ 
    // Initialization 
    //-------------------------------------------------------------------------------------- 
    const int screenWidth = 800; 
    const int screenHeight = 450; 
 
    InitWindow(screenWidth, screenHeight, "raylib [core] example - basic window"); 
 
    SetTargetFPS(60);               // Set our game to run at 60 frames-per-second 
    //-------------------------------------------------------------------------------------- 
 
    // Main game loop 
    while (!WindowShouldClose())    // Detect window close button or ESC key 
    { 
        // Update 
        //---------------------------------------------------------------------------------- 
        // TODO: Update your variables here 
        //---------------------------------------------------------------------------------- 
 
        // Draw 
        //---------------------------------------------------------------------------------- 
        BeginDrawing(); 
 
            ClearBackground(RAYWHITE); 
 
            DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY); 
 
        EndDrawing(); 
        //---------------------------------------------------------------------------------- 
    } 
 
    // De-Initialization 
    //-------------------------------------------------------------------------------------- 
    CloseWindow();        // Close window and OpenGL context 
    //-------------------------------------------------------------------------------------- 
 
    return 0; 
} 
 

Not Categorized, Please Help

Search



Quick Links

User menu

Not signed in.

Misc Menu