/dpt/ - Daily Programming Thread

Old thread: What are you working on, nyaa?

Other urls found in this thread:

youtube.com/watch?v=JYG5LFHkUuE
hexus.net/tech/news/software/105895-vulkan-opencl-will-merge-single-api/
github.com/Drakulix/fireplace
youtube.com/watch?v=RwdQA0pGWa4&list=PLGvfHSgImk4acseLJnjc6_QUPvxVmjm7o
community.arm.com/processors/b/blog/posts/condition-codes-1-condition-flags-and-codes
github.com/cristicbz/rust-doom/blob/master/engine/src/type_list.rs
reference.wolfram.com/language/howto/CreateAMatrix.html
open.gl/
twitter.com/NSFWRedditImage

I wish I had friends

And?

nth for opengl brainlets

im trying to get a girlfriend at the moment

nothing
bingewatching cppcon

youtube.com/watch?v=JYG5LFHkUuE

>stuck on OpenGL 2.1
>mesa drivers support random extensions that exist in OpenGL core 4.0+
>I can write a shitty mix of glBegin and shader code if I want

What should I target?

Working on a tiling algorithm/system for a window manager I've written in C. Lots of fun. Also starting to learn kernel basics, my copy of the MINIX book is on the way and I'm reading a few babby's first kernel resources. Also touching up the code for my Sup Forums bulk image downloader, also in C

>working on an old project of mine and it's so bad an inconsistent I just want to resign and cry myself to sleep
I wish I were a good programmer

>opengl lacking behind dx for decades
>only good quality is it is cross platform
>vulkan happens
opengl fags on suicide watch

OpenGL 2.1 has vertex buffers.

Except plenty of developers (including Valve) have said OGL implementations outperform DX.

khronos hurry the fuck up and give us multi gpu

>ywn be this good
Why even bother
Just end me

hexus.net/tech/news/software/105895-vulkan-opencl-will-merge-single-api/

Reviewing the source of a wayland compatible window manager written in 100.0% Rust.

github.com/Drakulix/fireplace

...

Do you program in rust or are you just interested in learning? I've actually been looking at that wm as well, kind of as a jumping off point to get into more serious/larger scale rust code once I'm comfortable with the basic stuff

Does anyone know if c# has a method somewhere that basicly does the following:
//if (expr1) return -1;
//if (expr2) return 1;
//return 0;
int SomeFunction(bool expr1, bool expr2) => expr1 ? -1 : expr2 ? 1 : 0;


This is what I am currently using. But I was hoping there would be a build in method for this.

Yeah, I'm in the middle of the rust book myself, just wanted to see how people do low level things. It's pretty nice actually.

On codefights.com you can go head to head with a random person in a codewriting competition. You can also go against a bot. How can there be a code writing bot? Theres no way they are fuzzing a correct solution right?

they probably just arbitrarily slow down type-writer text

They are talking about "engineers working on them" and its all in a serious tone. Like it really sounds like marketing bullshit, but their audience is actual programmers, I dont get it.

I guess its supposed to be taken as a joke.

/dpt/, I'm a beginner in assembly and I'm terribly confused about how to do loops

I'm trying a simple division program, trying to divide 2 numbers, 7 and 3 as a test

mov r3,#0 @loop counter
.loop:
cmp r0,r1 @loop while r0-r1 > 0
sub r0,r0,r1 @store in r0 the subtraction of r0 and r1
add r3,r3,#1 @add 1 to loop
ble .loop @loop while cmp is less equal?

IDK how the loop conditions work or how it's checked, I'm doing this trying to figure it out but fuck.

Can you write a function with variadic generics in Rust? Or emulate it with macros or something

How do I write multithreaded applications with OpenGL?
The state machine design pretty much limits drawing to a single thread only.

Only draw from one thread.

you should cmp before ble

What steps are you taking to achieve this?

For some reason that only loops once...
E.G if I run 7 R0, and 2 R1 I get 5 (7-2=5).
It should keep looping until R0 is less than R1, IDK why it's not though.

Does anyone have the answer key for the PSM1, or at least know where I can get it? This is serious, I don't have money to waste if I fuck up on it

you can't
just prepare all your resources as much as possible on different threads before handing them over to the rendering thread

youtube.com/watch?v=RwdQA0pGWa4&list=PLGvfHSgImk4acseLJnjc6_QUPvxVmjm7o

UMA

who even uses opencl anyway

>vulkan is cross-platform
lmfao

Which GPU API is more portable than Vulkan?

opengl es

and vulkan is only marginally better (

I'm trying to generate a natural-seeming 2D tile-based map with no less than 250 000 (500 x 500) tiles.

How do I go about this?

for each tile, randomly decide if the title is in land or in water.

by not posting chinese cartoons you dumb dweeb

But just randomly deciding will not make the map natural.

if the map is not natural, reject it and try again

Why segfault?
#include

int * read_data() {
int three[3];
scanf("%d", three + 0);
scanf("%d", three + 1);
scanf("%d", three + 2);
return three;
}

void print_data(int * data) {
for(int i = 0; i < 3; i++)
printf("%d ", data[i]);
puts("");
}

void print_data_reverse(int * data) {
for(int i = 2; i >= 0; i--)
printf("%d ", data[i]);
puts("");
}

int main() {
int * data = read_data();
print_data(data);
print_data_reverse(data);
}

Can someone please explain this to me? Why does preallocating my array take MORE time than not doing so?

What conferences do you guys attend/watch?
I recently found myself listening to shit like defcon and black hat
Only programming one i know is cppcon, but that's hardly useful since I dev with php backend

>push
what do you think this function does when you have an array of length 5?

I am 85% sure that you're still appending to the array on the second one

webshit pls go

Look up RAII and you'll find out why

unemployed pls go

Thanks. This really made me think.

But I'm using C.
Srs, what went wrong?

Here's a better hint
Look up RAII and scope and you'll find out why

three is stored on the stack, and you returned a pointer to it. When you called printf you overwrote the memory location previously occupied by three with printf's stack data. You then attempted to dereference it, and ended up dereferencing an address that wasn't in the process' virtual address space. This triggered a segmentation fault.

This has nothing to do with RAII. In fact, that code could just be C, which doesn't have it.

>Resource Acquisition Is Initialization
>resource allocation(or acquisition) is done during object creation (specifically initialization), by theconstructor, while resource deallocation (release) is done during object destruction (specifically finalization), by thedestructor.

Replace object with array and you get why. The array was destructed as soon as it hit end of scope and it only passed a pointer

Pictured is a 4x4 array of arrays. Where is element [0][0]? What are the indices of the blue, green and red elements? How would (you) order this grid?

Assuming someone has a fast CPU, is it always faster (in terms of IO, specifically reads) to use compressed data?

Data would be compressed on writes(slower than raw writing probably), and thus smaller, so when loading it should be faster to go from disk->memory, as long as the CPU can handle the decompression algo quickly, right?

this makes sense to me

origin is top-left

I'm pretty sure you can't rightly call the automatic deallocation of stack memory "RAII."

no RAII in C lol

uses the same principles brah
And besides, nobody should be coding in a deprecated language anyway

Loading into ram would be quicker and that's pretty much it. Nothing reading and writing would be slower because of how segmented things get in lz compression. And it'll definitely be a headache in multi threaded applications

No destruction going on. The stack pointer is just being set to the frame pointer.

Trying to learn OpenGL.

Which library does Sup Forums recomends? SFML? GLFW? SDL?

Also, tutorials or something would be helpful. No "read the documentation" please, already tried, it's unbearable.

community.arm.com/processors/b/blog/posts/condition-codes-1-condition-flags-and-codes

I use SDL. It's good enough. No experience with the others.

Python3, Kafka, Spark. Doing some distributed computing and message queue work.

To add onto this, which linear algebra library is good? glm is c++ and I want to work in c.

Macros are the only place where Rust has variadic arguments of any kind, but you can use them to build recursive types and then use the trait system, which is Turing-complete, to introspect them.

Example: github.com/cristicbz/rust-doom/blob/master/engine/src/type_list.rs

like pic related

transpose of this:
reference.wolfram.com/language/howto/CreateAMatrix.html

They won't teach you opengl lad, theyre wrappers.
If you want to learn it, you should write one yourself.

try this as a babby-tier introduction but you're going to have to read the documentation and the actual spec

open.gl/

Don't bother. Skeletal animation is virtually impossible to implement.

None.
Just grab glLoadGen for your loaders, pull in winapi, and go to town

I got really excited when I saw your post because I like doing things as completely from scratch as I can but then I remembered I can't be bothers to program at all right now. Why is doing things so hard and not worth it?

Because you're a lazy piece of shit. Now get to work and impress me. Remember your programmer gear

What should I make?

Wearing programming socks

Implement atmospheric scattering

Also it has to look at least as good as this

That's too vague. I can't be bothered.

See

user, I just said I'm fucking lazy. You expect me to do this bullshit right off the bat? At least build up to it or something.

build me a sun renderer where i can play with time of day and lighting and intensity.

Did I say it was easy you scrawny little shit? You set up a big goal and work towards it. It's the carrot on a stick. Now scram.

Yeah do this one

Carrots only work when you can see them dangling in front of you.

Why do the 3d objects in TempleOS have such a grainy appearance instead of having just flat colors?
Does he apply a sort of noise effect on purpose?

/*
* wc.c
*
* Created on: Sep 8, 2017
* Author:
*/


#include
#include
#include
#include
#include
//node struct
typedef struct node {
char * word;
int count;
struct node * next;
} Node;

static Node * makeNode(char * newWord, Node * next){
char * nWord = newWord;
Node * newNode = (Node*) malloc(sizeof(Node));
newNode->word = nWord;
newNode->count = 0;
newNode->next = next;
next = newNode;
return newNode;
}
static Node * findNodeForWord(char * findWord, Node * findNode){
Node * current = findNode;
if (current->next == NULL ||(strcmp(current->next->word,findWord) > 0) ){
current->next = makeNode(findWord,current->next);
return current->next;
}
else if(strcmp(current->word,findWord) != 0) {
findNodeForWord(findWord, current->next);
}

return current;
}
static void printList(Node * head){
if(head == NULL){
printf("end");
}
else{
printf("%-10s, %1d", head->word, head->count);
printf("\n");
printList(head->next);
}
}
int main(void){
Node * head = makeNode("", NULL);
FILE *fp = fopen("Syllabus.txt", "r");
setbuf(fp,0);
char line[100];
char *lp = line;
char c = getc(fp);
char * word;
while (c != EOF){
if(isalpha(c)){
*lp = c;
lp++;
c = getc(fp);
}
else{
*lp = '\0';
word = malloc(strlen(line)+1);
strcpy(word,line);
Node * node;
node = findNodeForWord(word, head);
node->count++;
lp=line;
c = getc(fp);
}
}
printList(head);
}


This is creating a duplicate node for words. Say there are 5 of the same word, it keeps making nodes and it is not supposed to. It is supposed to go through the link list and find the node and not do anything.

The noise comes from his connection with God

You're disappointing me faggot

Give me something easier! Also I do better with positive reinforcement!

Some other user suggested Good build up for the proper thing
Also positive reinforcement is for homos and women

Thanks god. I actually hated the idea of using them, but normies be like "that's too difficult, use this shit instead". I'd rather make things from scratch

That's too hard though. Give me something easier. It doesn't even need to be opengl related.

Trying to come up with an art style that is interesting and that will allow me to use widely different art assets without the player noticing. Low light, black unlit models. The idea for the game is a combination of Fallout Shelter with twitchy mind-upload missions from Worldwide Communist Gangster Computer God where you can permanently lose your precious dudes.

forgot pic

If you're not willing to challenge yourself you're never gonna make it, and you'll be stuck in brainletdom. You might as well download unity right now

I don't think I'm dumb I can't can't be bothered to do anything. I want to do stuff though it's just too much work. Maybe I should just give up and do some shitty webdev job.

Write a crawler that lurks /dpt/, and recognizes and downloads images of cirno using neural networks