Untitled
unknown
c_cpp
4 years ago
2.5 kB
13
Indexable
#include "raylib.h"
#include <Ultralight/CAPI.h>
#include <AppCore/CAPI.h>
#include <JavaScriptCore/JavaScriptCore.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
//--------------------------------------------------------------------------------------
///
/// Create default settings/config
///
ULSettings settings = ulCreateSettings();
ulSettingsSetForceCPURenderer(settings, true);
ULConfig config = ulCreateConfig();
ULRenderer renderer = ulCreateRenderer(config);
ULView view1 = ulCreateView(renderer, 200, 200, false, NULL, true);
ulViewLoadHTML(view1,"<h1>Hello World!</h1>");
ULBitmapSurface surface = ulViewGetSurface(view1);
ULBitmap bitmap = ulBitmapSurfaceGetBitmap(surface);
void* pixels = ulBitmapLockPixels(bitmap);
uint32_t width = ulBitmapGetWidth(bitmap);
uint32_t height = ulBitmapGetHeight(bitmap);
uint32_t stride = ulBitmapGetRowBytes(bitmap);
Image img = LoadImageFromMemory(".bmp", pixels, stride);
Texture2D tx =LoadTextureFromImage(img);
// 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);
DrawTexture(tx, width, height, GetColor(0xFFFFFF));
EndDrawing();
//----------------------------------------------------------------------------------
}
ulBitmapUnlockPixels(bitmap);
// De-Initialization
//--------------------------------------------------------------------------------------
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}Editor is loading...