|
Appemting to load a font in android allegro (part 2) |
nshade
Member #4,372
February 2004
|
I can't seem to post in the other thread(timeout) , so I'll try here. I decided to tackle loading fonts in android allegro as well It's not working In Android Studio 3 I didn't see an assets folder so I made one. Now, if I load a font, the application will hang. Here's my code 1#include <stdio.h>
2#include <allegro5/allegro.h>
3#include <allegro5/allegro_android.h>
4#include <allegro5/allegro_font.h>
5
6
7void goodscreen(void)
8{
9 al_clear_to_color(al_map_rgb(0,255,0));
10 al_flip_display();
11 while(1);
12
13}
14
15void badscreen(void)
16{
17 al_clear_to_color(al_map_rgb(255,0,0));
18 al_flip_display();
19 while(1);
20}
21
22int main(int argc, char **argv){
23int x;
24 ALLEGRO_DISPLAY *display = NULL;
25 ALLEGRO_FONT *vl_font=NULL;
26 if(!al_init()) {
27 fprintf(stderr, "failed to initialize allegro!\n");
28 return -1;
29 }
30 al_init_font_addon();
31 al_android_set_apk_file_interface();
32 al_android_set_apk_fs_interface();
33
34 display = al_create_display(0, 0);
35 if(!display) {
36 fprintf(stderr, "failed to create display!\n");
37 return -1;
38 }
39 vl_font = al_load_font("VL-PGothic-Regular.ttf",20,0);
40 if (vl_font == NULL) {
41 badscreen();
42 }
43 goodscreen();
44}
I have VL-PGothic-Regular.ttf in my assets folder, but when I run the app I don't get a red or green screen, but a black one and it hangs... |
Edgar Reynaldo
Major Reynaldo
May 2007
|
nshade said: What are you trying to do here? You can't set a zero resolution display. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
nshade
Member #4,372
February 2004
|
I borrowing the code from the example at the bottom of liballeg lib for Android here... https://github.com/liballeg/android not only that - the example works |
Edgar Reynaldo
Major Reynaldo
May 2007
|
Setting zero width and height is unprecedented. The manual says absolutely nothing about ever doing that. I see the example does do that though, and if you say it works, fine. Elias, that really needs to be documented. By the way, you're not calling al_init_ttf_addon. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
nshade
Member #4,372
February 2004
|
GRRR! I forgot the ttf header. It's tricky as phone development makes you lose the printf() debug console! Now to figure out how to lock the screen in landscape! |
Edgar Reynaldo
Major Reynaldo
May 2007
|
I mean, I understand setting zero width and height if you're creating a fullscreen window, as the width and height are automatic. But you never set the new display flags, so I don't know why it would default to that. I thought default was windowed mode. nshade said: GRRR! I forgot the ttf header. It's tricky as phone development makes you lose the printf() debug console! Use logcat instead. It will log to the android console. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Ian Lewis
Member #15,817
December 2014
|
nshade said: Now to figure out how to lock the screen in landscape! According to some notes I made a while back: to force landscape add: in AndroidManifest.xml, inside <activity> android:configChanges="orientation|screenSize" android:screenOrientation="landscape"
al_set_new_display_option(ALLEGRO_SUPPORTED_ORIENTATIONS,ALLEGRO_DISPLAY_ORIENTATION_LANDSCAPE,ALLEGRO_REQUIRE);
|
Elias
Member #358
May 2000
|
Edgar Reynaldo said: Elias, that really needs to be documented. Well, those phones only support FULLSCREEN_WINDOW mode, so technically we could either make al_create_display fail if anything else is requested or fail if width/height are anything but 0 - but instead I think we just completely ignore them. -- |
Edgar Reynaldo
Major Reynaldo
May 2007
|
A simple note in the docs would be good enough, as long as it states the parameters passed to al_create_display will be ignored when creating a full screen window edit, and that full screen windows are the default. It just struck me dumb that it worked. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
|