Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

SetPixel and GetPixel

Name: Anonymous 2018-04-28 14:18

Just look at this:
https://stackoverflow.com/questions/39430404/drawing-pixels-in-opengl
a person asks how he can access individual pixels of the framebuffer, to which an expert programmer gives following answer:
it sounds like you're trying to use OpenGL in place of a really old graphics library that is required for a class. Since computer graphics have changed so much that what you're trying to do in modern OpenGL is unreasonable

Since when SetPixel became unreasonable? And people still believe that progress would make things easier, not harder! Naive idiots!

I'm starting to think Unabomber was right on all accounts. We need to bomb Khronos Group offices right away!

Name: Anonymous 2018-04-28 14:23

Lol at how clueless they are: "I'm using integrated GPU (Intel HD graphics 4000), as far as I know CPU and GPU share the same memory so why is it that I need to download? Why is it impossible to get a pointer?"

The answer is obvious: because GPU Jews don't want you to access your pixels directly. You need a permission and a whole lot of boilerplate.

Name: Anonymous 2018-04-29 1:36

>>1
Since when SetPixel became unreasonable? And people still believe that progress would make things easier, not harder! Naive idiots!
Newer video APIs aren't meant to be 'easy' or 'easier' at all but to be 'close to the metal'. Check this out:
https://github.com/SaschaWillems/Vulkan/blob/master/examples/triangle/triangle.cpp
1193 lines

https://stackoverflow.com/questions/39430404/drawing-pixels-in-opengl
It's funny that the -2 answer is the most reasonable.

Name: Anonymous 2018-04-29 2:24

Name: Anonymous 2018-04-30 14:47

>>3
1193 lines

Why does it have to be so bloated? I can write triangle drawing code in C in less than 100 lines:
typedef struct lerp {
double x;
double i;
} lerp;

static void lerp_init(lerp *l, int sx, int ex, int first_step, int steps) {
l->i = (double)(ex - sx) / steps;
l->x = (double)sx + first_step*l->i;
}

static void lerp_advance(lerp *l) {
l->x += l->i;
}

#define SWAP(x,y) do {int t_ = x; x = y; y = t_;} while(0)

#define TRIANGLE_ROW(a,b) do { \
int x1 = (int)a.x; \
int x2 = (int)b.x; \
if (x1 < x2) gfx_hline(gfx, color, x1, y, x2-x1); \
else gfx_hline(gfx, color, x2, y, x1-x2); \
} while (0)

void gfx_triangle(gfx_t *gfx, uint32_t color, int ax, int ay, int bx, int by, int cx, int cy) {
int beg_y, cen_y, end_y;
int y, e;
lerp l, r;

if(ax < 0 && bx < 0 && cx < 0) return;
if(ax >= gfx->w && bx >= gfx->w && cx >= gfx->w) return;
if(ax == bx && ax == cx) return;

if (ay > by) {
SWAP(ax,bx);
SWAP(ay,by);
}

if (ay > cy) {
SWAP(ax,cx);
SWAP(ay,cy);
}

if(by > cy) {
SWAP(bx,cx);
SWAP(by,cy);
}

beg_y = ay;
cen_y = by;
end_y = cy;

if(end_y == beg_y || end_y < 0 || beg_y >= gfx->h) return;

if (beg_y < 0) {
lerp_init(&r, ax, cx, -beg_y, end_y-beg_y);
y = 0;
} else {
lerp_init(&r, ax, cx, 0, end_y-beg_y);
y = beg_y;
}

if (y < cen_y) {
if (beg_y < 0) lerp_init(&l, ax, bx,-beg_y, cen_y-beg_y);
else lerp_init(&l, ax, bx, 0, cen_y-beg_y);

if (cen_y > gfx->h) e = gfx->h;
else e = cen_y;

for (; y < e; ++y) {
TRIANGLE_ROW(l,r);
lerp_advance(&l);
lerp_advance(&r);
}
}

if(cen_y < end_y) {
lerp_init(&l, bx, cx, y-cen_y, end_y-cen_y);
if (end_y > gfx->h) end_y = gfx->h;

for (; y < end_y; ++y) {
TRIANGLE_ROW(l,r);
lerp_advance(&l);
lerp_advance(&r);
}
}
}

Name: Anonymous 2018-04-30 15:43

setters and getters? we java now

Name: Anonymous 2018-05-01 2:54

>>5
Just looked up how math professor draws a triangle, and he does crazy stuff with matrix determinants producing very inefficient algorithm:
https://fgiesen.wordpress.com/2013/02/08/triangle-rasterization-in-practice/

guess math is harmful when you're doing practical stuff.

Don't change these.
Name: Email:
Entire Thread Thread List