tater1337
Posts: 40
Joined: Sun May 04, 2014 6:11 pm

looking to code just simple graphics

Wed Oct 07, 2015 10:19 pm

what do I use? seems like all the graphics programs mentioned on the forums are for video or 3d stuff. all I really want is something to do LINE(X,Y,X2,Y2) or equivalent, is there such a thing out there for the pi and my google-fu is weak?

BillStephenson
Posts: 254
Joined: Thu May 17, 2012 1:25 am
Location: SW Missouri Ozarks
Contact: Website

Re: looking to code just simple graphics

Thu Oct 08, 2015 12:40 am

all I really want is something to do LINE(X,Y,X2,Y2) or equivalent, is there such a thing out there for the pi and my google-fu is weak?
Check into HTML5 and Javascript Canvas libraries. You can view the graphics you've coded in a web browser.

https://developer.mozilla.org/en-US/doc ... I/Tutorial

You can also look into the GD Graphics libraries. Those make it simple to create lines and simple shapes, and can do more complex shapes as well. I used the GD.pm perl module and sent them directly to a web browser with a ".cgi" script and you can save them to files as well in several formats.

http://libgd.github.io

I've used both of those on a Pi.There's also a graphics engine called ImageMagick called that works with lots of languages and outputs several formats. I'm pretty sure that would run on the Pi too.

http://www.imagemagick.org/script/index.php

User avatar
scruss
Posts: 2356
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: looking to code just simple graphics

Thu Oct 08, 2015 2:16 am

Try python's turtle library. It's very simple. Take a look at Paul Sutton's article in The MagPi Issue 24 — https://www.raspberrypi.org/magpi-issues/MagPi24.pdf.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.

raysan5
Posts: 37
Joined: Tue Sep 30, 2014 4:44 pm
Location: Barcelona
Contact: Website

Re: looking to code just simple graphics

Sun Oct 11, 2015 3:00 pm

You can try using my library: raylib (http://www.raylib.com/).

raylib is a simple and easy-to-use library to learn videogames programming. It's pure C, multiplatform (works on RPI, no X-windows) and with minimum external dependencies.

Here it is the minimum program to draw a line in screen:

Code: Select all

#include "raylib.h"

int main()
{
    InitWindow(1280, 720, "raylib example - draw a line");

    while (!WindowShouldClose())
    {
        BeginDrawing();

            ClearBackground(RAYWHITE);

            DrawLine(0, 0, 1280, 720, RED);

        EndDrawing();
    }

    CloseWindow();

    return 0;
}
Hope it fits on what you're looking for. :)

tvjon
Posts: 706
Joined: Mon Jan 07, 2013 9:11 am

Re: looking to code just simple graphics

Sun Oct 11, 2015 4:54 pm

I'm using jessie currently, so would like to try your raylib.

Reading your README.md, is:

openal1

a typo?

There seems to be no openAL in jessie's repo, so I built the library from source.

Next:

make

which generates:

libraylib.a

Then on to examples & make, which produces:

[email protected] ~/Downloads/raylib-master/examples $ make
gcc -o core_basic_window core_basic_window.c -O2 -Wall -std=c99 -I. -I../src -I../external/glfw3/include -I../external/glew/include -I../external/openal_soft/include -L. -L../src -L../external/glfw3/lib/linux -L../external/openal_soft/lib/linux -L../external/glew/lib/linux -lraylib -lglfw3 -lGLEW -lGL -lopenal -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor -lm -pthread -DPLATFORM_DESKTOP
../external/glfw3/lib/linux/libglfw3.a: error adding symbols: File format not recognized
collect2: error: ld returned 1 exit status
makefile:207: recipe for target 'core_basic_window' failed
make: *** [core_basic_window] Error 1


Any suggestions please?

raysan5
Posts: 37
Joined: Tue Sep 30, 2014 4:44 pm
Location: Barcelona
Contact: Website

Re: looking to code just simple graphics

Sun Oct 11, 2015 7:22 pm

raylib depends only on OpenAL library for sound (libopenal1), probably you already have it installed.

To compile raylib sources, just use:

Code: Select all

make PLATFORM=PLATFORM_RPI
To compile raylib examples, use:

Code: Select all

make PLATFORM=PLATFORM_RPI
This should work.

tvjon
Posts: 706
Joined: Mon Jan 07, 2013 9:11 am

Re: looking to code just simple graphics

Mon Oct 12, 2015 8:09 am

Indeed that works fine, thank you.

All the examples work (including sound, so the openAL I built from source must be working too. Jessie currently has no knowledge of openAL) except for mouse & scroll wheel. Those 2 examples froze the RPi so I had to power down & reboot.

I see that mouse0 is commented out in core.c, so I enabled that, & then no freezing but no mouse movement either, so I'll take a closer look at that.

It's nice that at example start, lots of information is printed to the console, so for example I can see that my gamepad is recognised.

It's also very helpful (for me anyway) that you've written your library in C so I stand a chance of understanding what's going on :)

So, thank you raysan5 for what looks to be a very useful library. I wish I'd seen it earlier.

tvjon
Posts: 706
Joined: Mon Jan 07, 2013 9:11 am

Re: looking to code just simple graphics

Tue Oct 13, 2015 8:25 am

Raysan5,

I just tried to register with your forum, but after entering all the details the Epiphany browser on this RPi came back with "could not open socket". I'll try later with a different browser.

The intention was to respond to the post about the rope puzzle game. I downloaded it to try but unfortunately the executable is for a mswin system. I don't use mswin, so can't try it.


I was going to modify the library code to allow different than the default display to be used. Rather than tie up a power consuming, perhaps costly laptop, or desktop (or another RPi) to ssh in to the RPI, I use "Gert's VGA666" board & output to a cheap vga screen, as well as hdmi. That way I can edit via the hdmi display whilst watching the egls output on vga (or the reverse, if say the hdmi screen is much higher quality than the vga).

Then I realised I don't need to do any such change, as a recent firmware update has provided a new environmnent variable for displays :)

For example, say I want to view one of the code snippets in the examples folder on the vga screen, I just type:

[email protected] ~/Downloads/raylib-master/examples $ VC_DISPLAY=4 ./core_3d_camera_first_person

The argument to VC_DISPLAY depends on the screen, so if I want to edit on hdmi but see the output on the new LCD screen, it becomes:

[email protected] ~/Downloads/raylib-master/examples $ VC_DISPLAY=6 ./core_3d_camera_first_person

Fortunately, keyboard presses relate to the output on the alternative screen, but mouse operations are inconsistent, with no mouse scroll-wheel, or visible cursor, at all, so I'll see if I can fix that... I think there've been some changes to the HW cursor code on RPi recently too.

Unfortunately, as yet, it's not possible to use hdmi, vga & LCD at the same time...

raysan5
Posts: 37
Joined: Tue Sep 30, 2014 4:44 pm
Location: Barcelona
Contact: Website

Re: looking to code just simple graphics

Thu Oct 15, 2015 7:45 am

Hi tvjon,

Glad to read you like the library, a lot of time and work has been invested on it.

About the inputs system, there is an issue in GitHub to review it (https://github.com/raysan5/raylib/issues/39). Right now mouse input is hardcoded to /dev/input/event1 and prepared to work with this type of events instead of /dev/input/mouse0. Despite the initialization message, gamepad is not implemented yet...

About the forum, that's a problem with my hosting, I tried to change the registering method but the forum gets full of bots... I'm looking for a solution...

There are some games made with raylib out there, I have to add a new section to the web to show them all (most of them are open source).

Wow, I didn't know about the display selection! That's great! Thanks for the info!

raysan5
Posts: 37
Joined: Tue Sep 30, 2014 4:44 pm
Location: Barcelona
Contact: Website

Re: looking to code just simple graphics

Mon Feb 22, 2016 10:05 pm

Hi tvjon,

Just let you know that I've published raylib 1.4 (http://www.raylib.com/). This new version improves input system and it also comes with a bunch of game samples (https://github.com/raysan5/raylib/tree/master/games) ready to work on RaspberryPi. You can also test those games on the web (http://www.raylib.com/games.htm).

Cheers!

tvjon
Posts: 706
Joined: Mon Jan 07, 2013 9:11 am

Re: looking to code just simple graphics

Thu Sep 29, 2016 3:25 pm

Hello again Raysan5,

I'm sorry I didn´t spot your reply several months ago, hence I didn´t reply!

I did have input problems with it, as noted, & have been busy with other things so have not used raylib since I´m sad to say.

However yesterday I managed to see:

viewtopic.php?f=67&t=160633&sid=7a2dc98 ... c71178f496

so in between rain showers I´ve taken another look.

I see you too have been busy making some RPi input improvements, thank you!

I was going to mention some makefile problems but I see some already listed here:

viewtopic.php?f=78&t=88182&p=1042392&hi ... 0#p1042392

As I mentioned earlier, I like to use 2 displays when using graphics orientated applications, one of RPi´s strengths, so I built the latest release, after modifyiing it slightly to use RPI´s DPI output.

Well, nothing showing on screen, odd...

Additionally, I really want to use raylib as a shared library, but I see the makefile has no option for that so I modified it to create .so, which also means small programs are also small executables, saving a lot of space on µSD cards, for example :)

Having done that, one of the example applications appeared just fine on my second screen. It would be nice to find out why the static version did not work though.

Keyboard input doesn´t work using the second screen yet, but mouse is fine.

Edit: probably operator error. Keyboard is working now.

Do you have a preferred place for feedback? There are a few threads on different sub forums here, + github. I will also have another try at joining your own forum.

Thank you again for all your effort on raylib.

raysan5
Posts: 37
Joined: Tue Sep 30, 2014 4:44 pm
Location: Barcelona
Contact: Website

Re: looking to code just simple graphics

Thu Sep 29, 2016 6:05 pm

Hi tvjon!

Wow, it's been a while since the last post... :P In that time, just published raylib 1.5 with a bunch of changes and raylib 1.6 is in production (check github develop branch: https://github.com/raysan5/raylib/tree/develop).

New version already includes shared library building support, a complete raylib binding for LUA, redesigned audio system... and lately one user is also implementing complete CMake support! raylib forum (http://forum.raylib.com/) should also be working now.

There are already some RPI related issues on GitHub (https://github.com/raysan5/raylib/issues), that's the best place to post issues or bugs, for more general questions, you can use forum.

Thanks to you for trying raylib and for giving me feedback, it's really welcome!

Return to “Graphics programming”