Can I plot individual pixels using SDL?

bilsch01 wrote:

MrTAToad wrote:

You would use SDL_RenderDrawPoint for rendering to a texture/screen

I can run other SDL programs so I think I have the SDL libraries I need. But when I put SDL_RenderDrawPoint in the program I get the following error:

sdlsnx2.c:(.text+0x192): undefined reference to `SDL_RenderDrawPoint’
collect2: error: ld returned 1 exit status

Is there some other library or header file I need? I notice the command is not included in the reference pages at:
http://www.libsdl.org/release/SDL-1.2.15/docs/html/. Apparently that site is missing some commands. Can you tell me a site that has complete set of SDL commands? Thanks.

I would go with the fact that your library pathing is somewhat inaccurate - you need to
#include “SDL2.h” and make sure that the libraries are accessible when compiling.

I’m wondering why a putpixel function is suddenly so desirable to you
guys… :slight_smile:

Anyhow, just use SDL_MapRGBA() to get a Uint32 instead of the int that
Jeff’s code uses. I’m pretty sure you can easily find the same code
elsewhere online.

Jonny DOn Sun, Mar 1, 2015 at 4:56 PM, MrTAToad wrote:

bilsch01 wrote:

MrTAToad wrote:

You would use SDL_RenderDrawPoint for rendering to a texture/screen

I can run other SDL programs so I think I have the SDL libraries I need.
But when I put SDL_RenderDrawPoint in the program I get the following error:

sdlsnx2.c[image: Sad].text+0x192): undefined reference to
`SDL_RenderDrawPoint’
collect2: error: ld returned 1 exit status

Is there some other library or header file I need? I notice the command is
not included in the reference pages at:
http://www.libsdl.org/release/SDL-1.2.15/docs/html/. Apparently that site
is missing some commands. Can you tell me a site that has complete set of
SDL commands? Thanks.

I would go with the fact that your library pathing is somewhat inaccurate

  • you need to
    #include “SDL2.h” and make sure that the libraries are accessible when
    compiling.

SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

I’m wondering why a putpixel function is suddenly so desirable to you
guys… :slight_smile:

It has its uses.

(Disclaimer: I don’t write games. I use SDL for application software involving
math and/or software development tools. I’ve also done some wrapper
applications for graphic and video software on Linux.)

Anyhow, just use SDL_MapRGBA() to get a Uint32 instead of the int that
Jeff’s code uses.

Actually, it is a Uint32. I set up the colors I need for my app during
initialization.

Uint32 red;

red      = SDL_MapRGB(vfmt, (Uint8) 0xa6, (Uint8) 0x00, (Uint8) 0x00);

and likewise for other colors. The colors are stored in an indexed array for
speed.

I probably should change the declaration of setPixel’s color
void setPixel(int x, int y, int color)
to be Uint32 instead of int just to be pedantic, but on both my 32 bit and 64
bit machines, an int is 32 bits so it’s no big deal. (64 bits is a ‘long’ to
the compiler.)

And as for the licensing issues…

C’mon guys, this is trivial code! It’s not a big deal. Do what you want with
it except don’t try to claim you have exclusive rights to it and can prevent
others from using it in their projects, which is what I mean by ‘proprietary’.

Okay, maybe I’m a bit overly sensitive on that issue right now. I’m having to
deal with an a-hole lawyer in a civil case who bitches about nickels and dimes
when hundreds of thousands of dollars are at stake. He’s convinced me that
‘Stupidity 101’ was a required course at his law school. Let’s behave like
grown-up software developers and not a-hole lawyers, okay?

(And just in case anyone might be feeling a little sympathy for my plight,
don’t bother. My lawyer intends to ask the court to issue sanctions against
the a-hole because in addition to his stupidity, he’s lied on forms he signed
under penalty of perjury and we can prove it.)

JeffOn Sunday 01 March 2015 13:00:21 Jonathan Dearborn wrote:

j_post wrote:

C’mon guys, this is trivial code! It’s not a big deal. Do what you want with
it except don’t try to claim you have exclusive rights to it and can prevent
others from using it in their projects, which is what I mean by ‘proprietary’.

Jeff, can you, please, post a link to your code (at any site)? I don’t like to show my email at public forum.

j_post wrote:> On Sunday 01 March 2015 05:46:34 bilsch01 wrote:

I don’t see that the code posted by Jeff will plot a
pixel.

It sets the pixel in the SDL_Surface pointed to by ‘screen’. At some point you
need to call SDL_UpdateRect to actually display the changes, but you don’t
want to do that after every call to setPixel or it will be real slow.

What my code (call ‘polygraph’ for polynomial graphing) does is plot the
entire function within the applicable domain and range using calls to setPixel
and only then calls SDL_UpdateRect. I’ve never actually timed how long it
takes since once it begins plotting, the curve appears on screen faster than a
human can detect. Good enough for my uses.

If, on the other hand, by ‘plot a pixel’ you mean knowing which pixel to set
to what color, that’s the job of your application code.

Again, if you’d like the program’s source code (which is GPL’d) I’ll send you
a zip or tar.gz file, but I see no need to burden the mailing list with it. It
will compile for either Linux or Windows, but not OSX, 'cause, you know, Apple
sucks :wink:

My code computes x and y coordinates for 640x480 display and uses
TurboC putpixel() to display the computed point. putpixel is very slow.

It’s been ages since I’ve used TurboC so I can’t say for sure, but it could be
that the TurboC library is updating the displayed data (the physical screen)
after every call to putpixel(). See above.

Jeff

Thanks Jeff, but I’m going to abandon SDL for now.

Bill S.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Alex wrote:

bilsch01 wrote:

The SDL2 library is in my system however I think my capability is limited to 1.2 because the compiler says UNDEFINED REFERENCE to SDL_RenderDrawPoint.

You should correctly add paths to your include and libs files when compiling and linking your app.
Try this console commands:
sdl2-config --cflags
sdl2-config --libs
Is this commands show something on your system?

Those console commands generate more errors. I’m going to abandon SDL for now. Thanks for your time.

Bill S.

j_post wrote:

C’mon guys, this is trivial code! It’s not a big deal. Do what you want
with it except don’t try to claim you have exclusive rights to it and can
prevent others from using it in their projects, which is what I mean by
‘proprietary’.

Jeff, can you, please, post a link to your code (at any site)? I don’t like
to show my email at public forum.

I don’t have a web site since AT&T reneged on their deal. Your email is in the

From header and I’ve sent the tar.gz file of the source code to that address.

JeffOn Sunday 01 March 2015 15:16:52 Alex wrote:

I’m wondering why a putpixel function is suddenly so desirable to
you guys… :slight_smile:

It has its uses.

It certainly has. Personally, for all my pixel-crunching needs, I’ve
been using the putpixel/setpixel (or variations of those) described in
the SDL 1.2 docs

http://www.libsdl.org/release/SDL-1.2.15/docs/html/guidevideo.html

and although I never liked them not being in the SDL itself, I think
being in the docs is the next best thing.On Sun, 1 Mar 2015 14:55:30 -0800 “j_post” <j_post at pacbell.net> wrote:

On Sunday 01 March 2015 13:00:21 Jonathan Dearborn wrote:


driedfruit

    SDL-announce)"  <sdl at lists.libsdl.org>

Message-ID:
<CA+DSiHYhsVki5HYhDHDTX1NK1oF6CRYOoyBFW7Y5cxibb_P2gw at mail.gmail.com>
Content-Type: text/plain; charset=“utf-8”

I’m wondering why a putpixel function is suddenly so desirable to you
guys… :slight_smile:

In my case, it’s because the last time that I tried writing it myself
I eventually just gave up on debugging the code that used it.

Anyhow, just use SDL_MapRGBA() to get a Uint32 instead of the int that
Jeff’s code uses. I’m pretty sure you can easily find the same code
elsewhere online.

I already dug it up in Hg. Thanks, though.> Date: Sun, 1 Mar 2015 17:00:21 -0400

From: Jonathan Dearborn
To: "A list for developers using the SDL library. (includes
Subject: Re: [SDL] Can I plot individual pixels using SDL?

Jonny D