EihiS

March 25, 2017

Using the Data-Folder libraries

Filed under: linux, neuron — admin @ 11:34 am

Pour cette fois, le post est en anglais

Today i released a first bunch of my homebrew libraries , so i’m going to post a first ‘hello world’ example program, wich uses those libraries.
I have not enough time to expose and explain all of that libraries functions, so the best is to dive into the code if you wish to understand the things.

In order to continue with the ‘neural net learning ‘ series, i need to use some graphic functions like displaying bitmaps, displaying text and buttons , and so on.. so, i’ll use those libraries in the next séries of post.

a simple “hello world” program (reminder : it uses the EHS2D_V2 folder from data.eihis.com/common/:

Opens a sdl2.0 based window, and creates a ‘text window’ inside it, displaying bitmap-based char texts :

This is a ultra-simple , first program just to use some simple functions of the library.

You can grab the necessary files from here : (ZIP : data.eihis.com/web_ehs2d_helloworld/web_ehs2d_helloworld.zip )

  • Use the makefile to build the executable
Here is , for information, the main.c code which is pretty small :
#include "classics.h"
// ehs 2d , sdl2.0 etc includes
#include "local_config.h"
int main(int argc, char **argv)
{

	int32_t h_textwindow;
	char* cb_text;
	char* cb_temp=malloc(sizeof(char)*256); // some room for sprintf functions
	uint32_t i_eventreturn;
	// hello world related variables
	uint32_t roll;
	uint32_t quit;
	//
	// (uses EHS2D globals)
	//
	ehs_main_x=0;
	ehs_main_y=0;
	ehs_main_w=900;
	ehs_main_h=600;
	// mandatory.. we wont resize the main window in this example
	ehs_dynamic_main_w=ehs_main_w;
	ehs_dynamic_main_h=ehs_main_h;
	//
	ehs_target_main_w=ehs_main_w;
	ehs_target_main_h=ehs_main_h;
	// enables/disables the background image (see local_config.h for the image's definition )
	ehs_background_name="../common/BITMAP/ARGB8888/helloworld_900x600.bmp";
	ehs_use_background=1;// if 1, would start with background enabled, displayed
	// could have been 0, with no background name defined
	//
	//
	// init EHS2D
	//
	EHS_init();
	//
	cb_text=(char*) malloc(sizeof(char)*32*12); // alloc size for the window's text
	h_textwindow=EHS_reg_elem(_EHS_SUBWINDOW,50,50,32,12,0,0,_EHS_IDLE,(uint8_t*) cb_text,"Console demo\0",_EHS_DM_CHAR,_EHS_FONTB_SIZE,fontB,fontC);//
	EHS_set_fonts(h_textwindow,0,2); // this sets the font used , aka 'font A / font C'
	EHS_SUBWIN_clear(h_textwindow,' '); // clear the window's display buffer ('cb_text') with ' ' (space) chars
	//
	EHS_SUBWIN_textAt(h_textwindow,"Hello world!",0,0);// place a text inside, at coordinates 0,0
	//
	quit=0;
	roll=0;
	while(quit==0)// loop there
	{
		// sprintf to a temp buffer for dynamic text content, then displat @ x=0,y=2 inside the ehs window
		sprintf(cb_temp,"Roll value is:%d \n",roll);
		EHS_SUBWIN_textAt(h_textwindow,cb_temp,0,2);
		// render the main window
		SDL_RenderPresent(sdlRenderer);
		// update the window's contents
		EHS_update();
		// now manage with input events
		i_eventreturn=EHS_process_events();
		switch (i_eventreturn)
		{
			case _EHS_EVENT_QUIT:
				quit=1;
			break;
			case _EHS_EVENT_KEYINPUT:
				//
				switch (input_key)
				{
					case SDLK_ESCAPE:
						quit=1;
					break;
					case SDLK_t:
						//
					break;
					//
					case SDLK_SPACE:

					break;
					//
					default:
					break;
				}
			break;
			case _EHS_MOUSECLICK:

			break;

			default:
			break;
		}
		//	some delay
	usleep(50000);
	roll++;
	}
	EHS_exit();
}

No Comments

No comments yet.

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

314159265358979323846264338327950288
419716939937510582097494459230781640
628620899862803482534211706798214808

cat{ } { post_1114 } { } 2009-2015 EIhIS Powered by WordPress