SoftLK-lib/examples/resize
Captain4LK 012737d608 Remove SLK_config.h, update SLKIMAGE files, add SLK_core_set_visible
Scrapped idea of optional features,
Things like that will be managed as seperate, complete projects with SoftLKlib as a git submodule.
Those subprojects should come with a set of tools.
2020-06-24 16:51:36 +02:00
..
assets Added dynamic windows sizes (resizable windows) 2020-05-10 21:21:10 +02:00
data Remove SLK_config.h, update SLKIMAGE files, add SLK_core_set_visible 2020-06-24 16:51:36 +02:00
build_linux.sh Added dynamic windows sizes (resizable windows) 2020-05-10 21:21:10 +02:00
main.c Remove SLK_config.h, update SLKIMAGE files, add SLK_core_set_visible 2020-06-24 16:51:36 +02:00
README.md Remove SLK_variables.h 2020-05-17 17:13:35 +02:00

Resize example

This example demonstrates dynamic sized windows, layer scaling, moving and resizing. The image is drawn on a seperate layer, the window itself is resizeable with layer 1 being resized dynamicly. Hold the ctrl key and scroll the mouse wheel to scale the layer, hold the mouse wheel and move the mouse to move it.

Code Example

This code example creates a resizable window with one dynamic layer.

#include "../../include/SLK/SLK.h"

int main(int argc, char *argv[])
{
   //Create a resizable window
   //width,height,layer count,window title,fullscreen,pixel scale,dynamic
   SLK_setup(320,240,1,"Resizable window",0,3,1);

   //Create layer 0 as a rgb layer
   SLK_layer_create(0,SLK_LAYER_RGB);
   //Flag the layer as active (layers only get drawn if flagged as active)
   SLK_layer_activate(0,1);
   //Now flag the layer as dynamic. If the dynamic flag is set and SoftLK
   //has been started in dynamic mode, windows will be resizable and
   //the layer is resized accordingly to the window dimensions.
   SLK_layer_set_dynamic(0,1);

   while(SLK_core_running())
   {
      SLK_update();

      //Clear the layer so that it does not look weird when resized.
      SLK_layer_set_current(0);
      SLK_draw_rgb_set_clear_color(SLK_colore_create(255,128,0,255));
      SLK_draw_rgb_clear();

      SLK_render_update();
   }

   return 0;
}